Step 3. Create RDMLX Function iiiFN14 to Produce a Single Page PDF

INT013 - Create PDF Output using PDFDocumentService

In this step you will create an RDMLX function, based on the RDMLX source in INT013 - Appendix B. You will complete this function to produce a PDF document for a single employee.

1.  Create a new process iiiPRO11 – PDF Examples.

2.  Create a new RDMLX enabled function iiiFN14 – Create PDF for an Employee, belonging to process iiiPRO11, without using a template.

3.  Replace its code with the RDMLX source from INT013. Appendix B.

4.  Save your function and review its content. Note that at the beginning of the program a number of field values are hard coded, such as EMPNO and STD_TEXTL. This function will process a single fixed employee number.

5.  Find the following comment:

* Create PDF Document

 

     Following this comment, add code to use the PDFDocumentService which has already been loaded. Use the CREATE command to create a PDF document based on the template iii_PDF_Template.xml.

6.  In your source code, copy and paste the three statements from the * Load Service code and modify the CHANGE Field(#JSMXCMD) command to define the CREATE command:

Keyword

Value

DOCUMENT

iii_EMPREP.pdf

CONTENT

xml/iii_PDF_Template.xml

 

     In a real application you would want to write the output to a specific folder, perhaps organized by user or customer.

     Your completed code should look like the following.

* Create PDF Document

#jsmxcmd := ('CREATE DOCUMENT(iii_EMPREP.pdf) CONTENT(xml/iii_PDF_Template.xml)')

Use Builtin(JSMX_COMMAND) With_Args(#jsmxhdle1 #JSMXCMD) To_Get(#JSMSTS #JSMMSG)

Execute Subroutine(CHECK_STS) With_Parms(#JSMXHDLE1)

7.  Save your changes.

8.  Locate this comment:

* If found add content

 

     The code immediately preceding this comment has created a single entry working list (#HEADER) containing the required employee detail fields.

9.  Following this comment, add logic to add content HEADER containing employee details.

     Add this code and then complete the * Add content HEADER logic:

If_Status Is(*OKAY)

* Add content HEADER

Else

Message Msgtxt('Employee A1009 not found')

Endif

 

10. Following the * Add content HEADER comment line, define an ASSIGN command to set up the JSMXCMD field to ADD based on:

Keyword

Value

CONTENT

HEADER

 

11. Define the USE the JSMX_COMMAND based on:

Keyword

Value

WITH_ARGS

#JSMXHDLE1

 

#JSMXCMD

 

#HEADER

TO_GET

#JSMSTS

 

#JSMMSG

 

     Note: You are passing the working list #HEADER as the third argument.

12. Finally add an EXECUTE command to perform subroutine to check JSM status.

     Your completed code should look like the following:

If_Status Is(*OKAY)

* Add content HEADER

#JSMXCMD := 'ADD CONTENT(HEADER)'

Use Builtin(JSMx_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD #HEADER) To_Get(#JSMSTS #JSMMSG)

Execute Subroutine(CHECK_STS) With_Parms(#JSMXHDLE1)

Else

Message Msgtxt('Employee A1009 not found')

Endif

13. Save your changes

14. Locate the following comment:

* If found add employee skills list

 

15. Add the following logic and complete your JSM logic within it:

If_Status Is_Not(*error)

* Add SKILLTBL content

 

Else

Message Msgtxt('Employee skills not found')

Endif

 

16. Following the * Add SKILTBL content comment, define an ASSIGN command to change the JSMXCMD field to ADD based on:

Keyword

Value

CONTENT

SKILLTBL

 

17. Add a USE command to perform the JSMX_COMMAND BIF, based on:

Keyword

Value

WITH_ARG

#JSMXHDLE1

 

#JSMXCMD

TO_GET

#JSMSTS

 

#JSMMSG

 

#SKILLTBL

 

18. Add an EXECUTE command to perform the subroutine to check JSM status.

     Your completed code should look like the following:

If_Status Is_Not(*error)

* add SKILLTBL content

#JSMXCMD := 'ADD CONTENT(SKILLTBL)'

Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMSTS #JSMMSG #SKILLTBL)

Execute Subroutine(CHECK_STS) With_Parms(#JSMXHDLE1)

Else

Message Msgtxt('Employee skills not found')

Endif

 

19. Compile your function. If you are running Integrator on an IBM i server, check in and compile your function on the server.

20. Execute your function iiiFN14 – Create a PDF for a Single Employee.

     Find the output PDF document in the root of your JSM instance. It will have the name iii_EMPREP.PDF. If you are running on the IBM i server, this will be a path such as:

/LANSA_<pgmlib>/jsm/instance

     where <pgmlib> is the LANSA library name.

     The PDF document should look like the following: