Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

2.      Delete these two lines from the top of the function

     #empno := A1009
#rep1page := 1

3.      Locate the * Add Footers comment line. Create a FOOTER subroutine and move add footers logic into it. Your code should look like the following

Subroutine Name(FOOTER)
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)
Endroutine

4.      Add an EXECUTE subroutine to replace the code moved into the subroutine. Your code should look like the following:

* Add Footers
EXECUTE Subroutine(FOOTER)

5.      Locate the * Close document comment. Create a CLOSE subroutine, and move the code shown into it:

Subroutine Name(CLOSE)
#jsmxcmd := CLOSE
Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMSTS #JSMMSG)
Execute Subroutine(CHECK_STS) With_Parms(#JSMXHDLE1)
#rep1page -= 1
Message Msgtxt('Employees PDF Report produced with ' + #rep1page.asstring + ' pages')
* 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)
Endroutine

6.      Add an Execute subroutine to replace the code moved into the subroutine. Your code should look like the following:

     * Close document
EXECUTE Subroutine(CLOSE)

...

8.      Add a case loop for STD_FLAG around your existing single employee logic. The new code is shown in red. For example:

Case

...

Of_Field(#STD_FLAG)
*

...

Search

...

for

...

single

...

employee

...

number
When

...

(=

...

E)
*

...

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

...

Footer
Execute

...

Subroutine(FOOTER1)
*

...

Close

...

the

...

PDF

...

Document

...

and

...

the

...

PDF

...

Service
Execute

...

Subroutine(CLOSE)
Endcase

9.      At the top of the function, define a work field OUTSTS based on field IO$STS. This field will be used to control whether the PDF document should be closed, because output was produced.

10.     Your existing CASE loop handles a single employee only. The CASE loop should now be extended by adding the next WHEN condition below EXECUTE FOOTER for the single employee. Copy the code to handle search by surname and search by department which is supplied in INT013 - Appendix C.

11.     Save your changes.

...