Step 3. Create Form iiiFRM06

INT011 - Create Excel Document

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

1.  Create form iiiFRM06 – Call Create Excel.  Do not use a template.

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

Have user input data into fields DEPTMENT and SECTION

When the user clicks on the push button with the caption Create:

          Use BEGINCHECK loop and FILECHECK to validate these fields against file SECTAB

          Exchange fields DEPTMENT and SECTION and call function iiiFN12

Messages should be shown in a status bar at the bottom of the form.

3.  Your completed code should look like the following

Function Options(*DIRECT)

Begin_Com Role(*EXTENDS #PRIM_FORM) Clientwidth(484) Clientheight(150) Componentversion(2) Left(620) Top(175)

Define_Com Class(#DEPTMENT.Visual) Name(#DEPTMENT) Displayposition(1) Left(24) Parent(#COM_OWNER) Tabposition(1) Top(17)

Define_Com Class(#SECTION.Visual) Name(#SECTION) Displayposition(2) Left(29) Parent(#COM_OWNER) Tabposition(2) Top(46)

Define_Com Class(#PRIM_PHBN) Name(#Button1) Caption('Create') Displayposition(3) Left(291) Parent(#COM_OWNER) Tabposition(3) Top(23)

Define_Com Class(#PRIM_STBR) Name(#StatusBar1) Displayposition(4) Height(28) Left(0) Messageposition(1) Parent(#COM_OWNER) Tabposition(4) Tabstop(False) Top(272) Width(476)

 

Evtroutine Handling(#com_owner.CreateInstance)

 

Set Com(#com_owner) Caption(*component_desc)

 

Endroutine

 

Evtroutine Handling(#Button1.Click)

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)

 

Endroutine

End_Com

 

4.  Compile your form.

     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 ExcelService with trace and check the trace files. To do this add TRACE(*YES) to SERVICE_LOAD of the ExcelService.

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