INT013 Appendix B

LANSA Integrator

INT013 - Appendix B

INT013 - Create PDF Output using PDFDocumentService

RDMLX Source for Function iiiFN16 – Create PDF for a single Employee

Function Options(*DIRECT)
* Beginning of RDML commands **********

#empno := A0090
#std_textl := 'ACME Manufacturing Company, Chicago'
#std_name := #datex.asdisplayString( DDsMMsCCYY )
#rep1page := 1
Def_List Name(#footer1) Fields(#std_name #rep1page) Type(*working)
Define Field(#ID) Type(*CHAR) Length(5)
Define Field(#FNAME) Type(*CHAR) Length(20)
Define Field(#SNAME) Type(*CHAR) Length(30)

Def_List Name(#SKILLTBL) Fields(#SKILDESC #GRADEDES #STD_TEXT #COMMENT) Type(*WORKING) Entrys(*max)
Def_List Name(#header) Fields(#std_textl #fullname #address1 #address2 #address3 #postcode #phonebus #phonehme #deptdesc #secdesc) Type(*working) Entrys(*max)
* Open JSM
Use Builtin(JSMX_OPEN) To_Get(#JSMSTS #JSMMSG #jsmxhdle1)
Execute Subroutine(CHECK_STS) With_Parms(#JSMXHDLE1)

* Load Service
#jsmxcmd := ('SERVICE_LOAD SERVICE(PDFDOCUMENTSERVICE)')
Use Builtin(JSMX_COMMAND) With_Args(#jsmxhdle1 #jsmxcmd) To_Get(#JSMSTS #JSMMSG)
Execute Subroutine(CHECK_STS) With_Parms(#JSMXHDLE1)

* Create PDF Document


* Add Logo
Change Field(#JSMXCMD) To('ADD CONTENT(LOGO) ')
Use Builtin(JSMx_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMSTS #JSMMSG)
Execute Subroutine(CHECK_STS) With_Parms(#JSMXHDLE1)


* Add Header Employee Info
Clr_List Named(#header)
Fetch Fields(*all) From_File(pslmst) With_Key(#empno) Val_Error(*next)
#fullname := #surname + ', ' + #givename
Fetch Fields(#deptdesc) From_File(deptab) With_Key(#deptment)
Fetch Fields(#secdesc) From_File(sectab) With_Key(#deptment #section)
Add_Entry To_List(#header)
* If found add content


* Get employee skills
* ======================
Clr_List Named(#skilltbl)
Group_By Name(#skills) Fields(#SKILCODE #COMMENT #DATEACQ #SKILDESC #grade)
Select Fields(#skills) From_File(pslskl) With_Key(#empno) Nbr_Keys(*compute) Val_Error(*next)
Fetch Fields(#skills) From_File(skltab) With_Key(#skilcode) Val_Error(*next)
#std_text := #dateacq.asdate( DDMMYY ).asdisplayString( DDsMMsCCYY )
Execute Subroutine(grade)
Add_Entry To_List(#skilltbl)
Endselect

* If found add employee skills list


* Add Footers
clr_list #FOOTER1

Add_entry #FOOTER1
#jsmxcmd := 'ADD CONTENT(FOOTER1)'
Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD #FOOTER1) To_Get(#JSMSTS #JSMMSG)
Execute Subroutine(CHECK_STS) With_Parms(#JSMXHDLE1)

* Close document
#jsmxcmd := CLOSE
Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMSTS #JSMMSG)
Execute Subroutine(CHECK_STS) With_Parms(#JSMXHDLE1)

* Unload PDF Service
#jsmxcmd := SERVICE_UNLOAD
Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMSTS #JSMMSG)
Execute Subroutine(CHECK_STS) With_Parms(#JSMXHDLE1)

* Close the JSM
Use Builtin(JSMX_CLOSE) With_Args(#jsmxhdle1) To_Get(#JSMSTS #JSMMSG)
Execute Subroutine(CHECK_STS) With_Parms(#JSMXHDLE1)

If (#jsmsts = OK)

Message Msgtxt('Document iiiEMPREP.pdf produced')

Endif*
*  Check the status of the JSM command issued
*
Subroutine Name(CHECK_STS) Parms(#W_HDLE)
*
Define Field(#MSGDTA) Type(*CHAR) Length(132)
Define Field(#W_HDLE) Type(*CHAR) Length(4)
*
If Cond('#JSMSTS *NE OK')
*
#MSGDTA := 'Error Status Code: ' + #JSMSTS
Message Msgid(DCM9899) Msgf(DC@M01) Msgdta(#MSGDTA)
#MSGDTA := 'Error Message: ' + #JSMMSG
Message Msgid(DCM9899) Msgf(DC@M01) Msgdta(#MSGDTA)
Endif
*
Def_List Name(#WL_MSGS) Fields(#JSMSTS #JSMMSG) Type(*WORKING) Entrys(*max)
Add_Entry To_List(#WL_MSGS)
Endroutine
Subroutine Name(grade)
Case (#grade)
When (= P)
#gradedes := 'Pass'
When (= F)
#gradedes := 'Fail'
When (= M)
#gradedes := 'Merit'
When (= D)
#gradedes := 'Distinction'
Endcase

Endroutine
* End of RDML commands **********