Step 2 Define Transformation Map

LANSA Composer

Step 2. Define Transformation Map

LIC007 - Extract Database to CSV File

In this step you will add the file PSLMST – Personnel to the map and add a text file (CSV) and define its fields. You will then define the basic mapping between the two objects.

1.  From the Details tab, use the Edit button  to open Mapforce.

2.  In Mapforce, use the Insert / Database menu option:

3.  Select IBM DB/2 (ODBC) in the Connection Wizard and click the Next button.

4.On the next dialog, select ODBC:

5.  If you already completed the earlier LIC003 tutorial exercise, then you will already have defined a DSN that you can again use here.  In that case, select the 'Use an existing Data Source Name' option and follow the prompts to select the DSN you created earlier.  Then proceed to step 8.

   Otherwise, select the 'Create a new Data Source Name' option. Click the Connect button.

6.  Enter a Data Source Name of <server>_<library>, where <server> is the IBM i and <library> is the specific library which will be the default for this connection - this should be the library containing the Personnel Demonstration system files, for example, LICLICLIB.

     Do not click OK at this point.

7.  Select the Server tab. Enter an SQL default library of <library> where <library> is the library containing the Personnel Demonstration system files, for example, LICLICLIB.

     Then click OK.

8.Signon to the iSeries when the login dialog appears, using your iSeries user id and password.. You may need to signon three times (this depends on the configuration of IBM i Access security options).

9.  In the Insert Database Objects dialog, the highlighted area shows the first IBM i library or the first database schema or collection. Select the arrow icon and select the required library, schema or collection from the drop down list. As before, the required IBM i library will depend on the LANSA Composer installation, for example, LICLICLIB. On a Windows server, the schema name is LC_DTA.

10. Select the file DEPTAB – Department Table.

11. Then scroll down and select file PSLMST – Personnel.

12. Select the Add/Edit Table Relations button (highlighted above).

13. In the Add/Edit Table Relations dialog, begin by selecting the Add Relation button.

14. In the left hand Primary/Unique Key Table column, select table DEPTAB and then column DEPTMENT. In the right hand Foreign Key Table column, select table PSLMST and then column DEPTMENT.

15. Click the OK button.

16. Continue by clicking the OK button in the Insert Database Objects dialog. Your map should look like the following:

17. Add a text file using the Insert / Text File menu option.

18. Select the radio button – Use simple processing for standard CSV or FLF files and click Continue.

19. Ensure the checkbox First row contains field names is NOT checked. Initially there will be one field only defined. Click in the top line and replace Field 1 with EmployNumber.

20. Continue to add new fields by pressing the Append Field button and adding the following fields:

a.  Surname

b.  GivenName

c.  Address1

d.  Address2

e.  Address3

f.  PostCode

g.  Department

h.  DeptDescription

21.Change the field PostCode to Integer.

22.Check the checkbox First row contains field names .Your form should now look like the following:

23. Save your changes by clicking the OK button.

     Your form should now look like the following:

24.Click OK to insert the text file.

     Your map should now look like the following:

25.Expand the DEPTAB table below table PSLMST and then define the required mapping between fields in tables PSLMST and DEPTAB and fields in the text file.

   When mapping the DEPTDESC field, it is important that you select the instance of DEPTAB/DEPTDESC that is nested below PSLMST.  This ensures that the database table relation you defined in step 14 is effective and that you pick up the DEPTDESC value that corresponds to the DEPTMENT (department code) that is in PSLMST.

   Your map should now look like the following:

     Mapforce will display a message box, because at this stage the input database file is not connected to Rows in the output text file. Click OK and continue.  You will be completing this link in the next step.

Note ODBC DSN

In general MapForce database components are qualified with the database schema name. On IBM i, this  corresponds to the IBM i library name.

In the context of LANSA Composer, it would not be satisfactory for the prepared Transformation Map to contain hard-coded references to database tables in a named library, which is what would happen if LANSA Composer did nothing else.

For LANSA Composer version 3.0, the map definition (the .mfd file) is modified BEFORE MapForce generates the Java code. The modification (if found to be necessary) is made to a temporary copy of the map definition (.mfd) file that is used only for the Prepare step (the original map definition file is NOT changed).  The nature of the modification is to automatically switch on MapForce's own "Strip schema names" option in the database component, and thereby rely on MapForce's own code generator to get the unqualified database references correct.  (This MapForce option was not available in earlier MapForce versions.)

One other consideration is that "strip schema names" may lead to a "Prepare Map failure" due to the required file(s) not being found if:

  • the map uses SQL SELECT and/or SQL-WHERE components, AND
  • the ODBC DSN in use does not specify an appropriate library list.

This means that in such cases it will be necessary to use a DSN that specifies an appropriate SQL default library and/or library list.

This and related issues are discussed and described more fully in Additional Considerations for Transformation Maps Using IBM DB2 for i5/OS in Appendix C of the LANSA Composer User Guide. It is recommended reading if you work with Transformation maps that reference IBM i databases in LANSA Composer version 3.0 (or later).

Further note:

Even when MapForce's own "Strip schema names" option is used (whether by the map designer or applied automatically by the Prepare step as described above), MapForce does NOT strip schema names from user-entered SQL - in other words, from any SQL entered using MapForce's SQL SELECT feature.