Step 5 Add a Header and Footer

Visual LANSA

Step 5. Add a Header and Footer

FRM115 - Writing Reports

In this step, you modify the function to include a header and footer. You will need to make the following changes:

  • Add a header to the report. Include the report page number (REP1PAGE), function name (FUNCTION), a title (STD_TITLE), DEPTMENT and the DEPTDESC fields. List the fields down the page. Specify that a new page should be printed whenever a page is full (each new page always has a header) and when the department code changes.
  • Change the STD_TITLE field to be Employee Report.
  • Add a footer to the report which lists the date (DATE), time (TIME), and report page number (REP1PAGE) across the bottom of the page.
  • In the SELECT loop, FETCH the DEPTDESC field from DEPTAB using the department code.

     Remember to include KEEP_LAST logic.

1.  Review the repository field definitions for the REP1PAGE, DATE, TIME and FUNCTION fields.

2.  Try to make the necessary code changes based on the function description above.

3.  Your code should appear as follows:

FUNCTION OPTIONS(*DIRECT)
DEF_REPORT FORMSIZE(66 80)

GROUP_BY NAME(#REPDATA) FIELDS(#DEPTMENT #DEPTDESC #SECTION #EMPNO #SALARY
#STARTDTE)

DEF_HEAD NAME(#HDR01) FIELDS(#REP1PAGE #FUNCTION #STD_TITLE #DEPTMENT #DEPTDESC)
TRIGGER_BY(*OVERFLOW #DEPTMENT) DESIGN(*DOWN)

DEF_FOOT NAME(#FTR01) FIELDS(#DATE #TIME #REP1PAGE)
DEF_LINE NAME(#DET01) FIELDS(#SECTION #EMPNO #SALARY #STARTDTE)

#STD_TITLE := 'Employee Report'
SELECT FIELDS(#REPDATA) FROM_FILE(PSLMST1) WITH_KEY(#DEPTMENT #SECTION)

NBR_KEYS(*COMPUTE) GENERIC(*YES)
FETCH FIELDS(#DEPTDESC) FROM_FILE(DEPTAB) WITH_KEY(#DEPTMENT) KEEP_LAST(1)

PRINT LINE(#DET01)
ENDSELECT

ENDPRINT

 

4.  Save the code and then full function check or build the RDML
Make any corrections as required.

     Exit the editor.

5.  Compile the function. Be sure that the function is debug enabled.

6.  Submit your new function using form iiiDEM19.

a.  Enter a department of A and leave the section blank.

b.  Check that the report headers and footers properly appear.