Step 1 Create a Simple List Style Report Using a Template

Visual LANSA

Step 1. Create a Simple List Style Report Using a Template

FRM115 - Writing Reports

In this step, you will create a simple list style report on the Section file. A simple function will be created by executing a LANSA template. In later steps in this exercise, you will code a similar reporting function. Reporting commands are not supported from LANSA forms. You need to code reports using LANSA functions.

1.  Create a process iiiPRO03 Reporting Process (where iii are your course assigned initials). If you are using iii=DEM, then your component must be named DEMPRO01. Do not open the process in the editor.

2.  Create a function iiiFN02 Section Report belonging to your process iiiPRO03. Select the template FRPRT01 List Style Report with Generic Selection. The function should NOT be Enabled for RDMLX since it creates an entry panel, using a REQUEST command, which cannot be used in an RDMLX Enabled function.

     Open the function in the editor in order to allow the template to execute.

3.  Answer the template questions as shown in the table below. Use the online help if you need additional information about the answer to each template question.

TEMPLATE QUESTION

ANSWER

Do you want this function to be part of an action-bar style process?

N

Enter the name of the primary file to be used by this template

SECTAB

Select related files

Select DEPTAB

Fields to appear in header line

Select DEPTMENT and DEPTDESC

Fields to appear in detail line

Select SECTION, SECDESC, SECADDRR1

Fields to trigger new page

Select DEPTMENT

Please specify a title for this report

Section Listing by Department

Do you want this report to run in batch

Y

 

4.  The template generated code should appear something like the following:

FUNCTION OPTIONS(*DEFERWRITE *DIRECT)
OPEN USE_OPTION(*ONDEMAND)
GROUP_BY NAME(#FETCHDATA) FIELDS(#SECTION #SECDESC #SECADDR1 #DEPTMENT #DEPTDESC)
DEF_HEAD NAME(#HDR01) FIELDS(#REP1PAGE #DATE #TIME #FUNCTION #STD_TITLE #DEPTMENT
#DEPTDESC) TRIGGER_BY(*OVERFLOW #DEPTMENT) DESIGN(*DOWN)
DEF_LINE NAME(#DET01) FIELDS(#SECTION #SECDESC #SECADDR1)
CHANGE FIELD(#STD_TITLE) TO('''Section Listing By Department''')
* If this program is running online
IF COND('*JOBMODE = I')
* Request report print criteria
REQUEST FIELDS(#DEPTMENT #SECTION) DESIGN(*DOWN) IDENTIFY(*DESC)
* Submit batch run of this program
SUBMIT PROCESS(#PROCESS) FUNCTION(#FUNCTION) EXCHANGE(#DEPTMENT #SECTION)
JOB(#FUNCTION)
* Else, if this program is running in batch
ELSE
* Select required SECTAB details
SELECT FIELDS(#FETCHDATA) FROM_FILE(SECTAB) WITH_KEY(#DEPTMENT #SECTION)
NBR_KEYS(*COMPUTE) GENERIC(*YES)
* Fetch file DEPTAB details
FETCH FIELDS(#FETCHDATA) FROM_FILE(DEPTAB) WITH_KEY(#DEPTMENT) KEEP_LAST(1)
* Print the detail line
PRINT LINE(#DET01)
ENDSELECT
* Finish all printing and end program
ENDPRINT
ENDIF

 

5.  Compile the process and function.

6.  Execute the process that contains your reporting function.

a.  When you execute your function, notice the Default Printer setting. The value *PATH will output the report as a file in the partition directory. For example C:\Program Files\LANSA\X_WIN95\X_LANSA\X_PPP where PPP is your partition. The file will have  the same name as the function with a sequentially numbered file extension. e.g. demfn02.001. Refer to the Technical Reference Guide for more information on this topic.

b.  When the process menu appears, select the Section Report by double-clicking. Your function should appear something like the following:

c.  Enter a department of ADM to list all Sections in the Administration department. (If you do not enter a department or section, a list of all records in the Section file will be created.)

d.  Run the report by clicking on the OK button.

e.  Open your report file in Notepad to view it. It should look like the following:

f.  Execute your reporting function again. Enter a department of ADM and a section of 01.

g.  Execute your reporting function again. Enter a department of A. You should see listings for both the ADM and AUD departments.