Generating transformations for dictionary table types

In this recipe, we will see how we can create transformations for dictionary table types. We will first create a table type using SE11 and then generate its transformation using the graphical tool editor of the transaction XSLT_TOOL.

We will create a table type, ZST6_TT_PER, that will comprise of employee number, PERNR, employee name, NAME, and grade field, GRADE.

How to do it...

We will now carry out the following steps:

  1. Call transaction SE11. We will first create a line type by the name of ZST6_ST_PER. Enter the name in the Data Type field. Then, click on the Create button and choose the Structure option in the dialog box that appears.
    How to do it...
  2. Next, we specify the fields of the line type. These are: PERNR, GRADE, and NAME. These are based upon the component types, PERSNO, TRFGR, and EMNAM, respectively.
    How to do it...
  3. We then create a table type using the transaction SE11. We give it the name ZST_TT_PER. We make sure that the line type defined earlier is used as the line type for the table type.
  4. Then, call the transaction XSLT_TOOL. Create a simple transformation.
  5. From the transformation change screen, click the Edit Transformation Graphically (How to do it...) button from the toolbar. This will take you to the screen shown as Transformation Editor.
  6. On the left-hand side, select the ROOT node and choose the context menu option Insert new root.
    How to do it...
  7. In the dialog box that appears, enter MYTAB and ZST_TT_PER in the Root-Name and Type-Name fields respectively. (Alternatively, we may enter the line type created earlier, that is, ZST6_ST_PER, in the Type-Name field and check the Line Type? indicator). Then, press Enter.
    How to do it...
  8. This will add the MYTAB table node to the Data roots section. Drag-and-drop the MYTAB node to the right-hand side (the Simple Transformation pane). This will create MYTAB and its components withinthe Simple transformation pane.
    How to do it...
  9. We need to make adjustments in the nodes. We will delete the ROOT node on the left-hand side so that only one ROOT element (that is, MYTAB) remains.

How it works...

We first declared a line type and then created a table type. We then created a new simple transformation. We then inserted a root element named MYTAB based on the dictionary type ZST6_TT_PER defined earlier. Drag-and-drop added the table MYTAB to Transformation and also included all the components, PERNR, NAME, and GRADE. The generated code of the transformation is shown in the following screenshot:

How it works...

In the template, a loop is run on each line of the table MYTAB. The contents of the fields PERNR, NAME, and GRADE are written within the XML text element ZT6_ST_PER (based on the name of the line type). The completed graphical form of the transformation is shown in the following screenshot:

How it works...

The transformation may then be called in programs using the statement CALL TRANSFORMATION.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.216.7