Step 4 Manually Create a Reporting Function

Visual LANSA

Step 4. Manually Create a Reporting Function

FRM115 - Writing Reports

In this step, you will manually create the report in order to learn how to use the reporting commands.

The report will simply list all employees in a department and total the salary information.

The finished report will appear something like the following:

     A new page will be printed for each Department. A count of the employee and the total of the SALARY field will be printed for each department. A grand total of all departments will be printed on the last page of the report. The report will be 80 characters wide and 66 lines long.

     Before you start, it is recommended that you review Producing Reports in the Developer Guide.

1.  You will build the reporting function in small steps. In this step, you will start coding a reporting function:

Define the report to be 66 lines long and 80 characters wide

Define a report line (#DET01) containing SECTION, EMPNO, SALARY and STARTDTE

     Select all records which generically match the Department Code and Section Code based on the number of keys entered

Print the report line (#DET01)

End the select loop

End the print.

 

2.  Create a new function iiiFN04 Manual Report belonging to process iiiPRO01. Create the function without using a template. It should be an RDMLX enabled function.

3.  Try to add the necessary code based on the function description above.

4.  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_LINE NAME(#DET01) FIELDS(#SECTION #EMPNO #SALARY #STARTDTE)
SELECT FIELDS(#REPDATA) FROM_FILE(PSLMST1) WITH_KEY(#DEPTMENT #SECTION)
NBR_KEYS(*COMPUTE) GENERIC(*YES)
PRINT LINE(#DET01)
ENDSELECT
ENDPRINT
 

5.  Save the code and then full function check or build the RDML. Make any corrections, if required, and then resave and check the function.

6.  Compile the process and function. Be sure that the function is debug enabled.

7.  Change your Submit Report form iiiDEM19 to submit function iiiFN04 and compile it.

8.  Submit your new report function using form iiiCOM19.

a.  Enter a department of ADM to list all Sections in the Administration department.

b.  Submit the report function again. Enter a department of A and leave the section blank. Notice that there is no break in the report pages when the department code changes. You will correct this in the next step.