Step 3 Create RDML function iiiFN13

LANSA Integrator

Step 3. Create RDML function iiiFN13

INT011 - Create Excel Document

This function will accept the department and section code, check they are valid and call function iiiFN12.

1.  Create an RDML function iiiFN13 – Call Create Excel, belonging to process iiiPRO09. Do not use a template. Note this is not an RDMLX enabled function.

2.  Write your function based on the following pseudo code:

  • Loop until exit or cancel key
  • Request fields DEPTMENT and SECTION
  • Use BEGINCHECK loop and FILECHECK to validate these fields against file SECTAB
  • Exchange fields DEPTMENT and SECTION and call function iiiFN12

3.  Your completed code should look like the following

FUNCTION OPTIONS(*DIRECT)
BEGIN_LOOP
REQUEST FIELDS(#DEPTMENT #SECTION)
BEGINCHECK
FILECHECK FIELD(#SECTION) USING_FILE(SECTAB) USING_KEY(#DEPTMENT #SECTION) MSGTXT('Department/Section not found')
FILECHECK FIELD(#section) USING_FILE(PSLMST1) USING_KEY(#deptment #section) MSGTXT('No employees for this department/section')
ENDCHECK
* Call JSM function to create Excel
EXCHANGE FIELDS(#DEPTMENT #SECTION)
CALL PROCESS(*DIRECT) FUNCTION(iiifn12)
END_LOOP
 

4.  Compile your function. If you are using the configuration file jsmcltdta.txt to point to the IBM I for the JSM server, you can run function iiiFN13 in Windows. Alternatively, check in and compile it, and test using a 5250 emulator.

Test your Create Excel application. Remember your document will be written to the training subdirectory of the JSM Instance. If necessary, create the folder…/jsm/instance/training.

Open your document in Excel. It should look like the following:

     Note: If you are using the JSM Server on an IBM i server you will need to map a drive to folder /training. If you are using a local JSM Server the folder will be \JSMInstance\training.

5.  If you have problems, remember you can use debug to follow your program logic. You could also start the ExcelReadService with trace and check the trace files. To do this add TRACE(*YES) to SERVICE_LOAD of the ExcelReadService.

#jsmxcmd := 'SERVICE_LOAD SERVICE(ExcelReadService) TRACE(*YES)'