5 3 2 A Simple Inquiry

Visual LANSA

5.3.2 A Simple Inquiry

Construct a function to display records from a file.

Files Involved

Physical file CUSMST (customer master file)

RDML Program - Version 1

    GROUP_BY   NAME(#CUSTOMER) FIELDS(#CUSTNO #NAME #ADDL1 
               #ADDL2 #ADDL3)
    BEGIN_LOOP
L10 REQUEST    FIELD(#CUSTNO)
    FETCH      FIELDS(#CUSTOMER) FROM_FILE(CUSMST) 
               WITH_KEY(#CUSTNO) NOT_FOUND(L10) 
               ISSUE_MSG(*YES)
    DISPLAY    FIELDS(#CUSTOMER)
    END_LOOP

 

RDML Program - Version 2

    GROUP_BY   NAME(#CUSTOMER) FIELDS(#CUSTNO #NAME #ADDL1 
               #ADDL2 #ADDL3)
    BEGIN_LOOP
    REQUEST    FIELD(#CUSTNO)
    FETCH      FIELDS(#CUSTOMER) FROM_FILE(CUSMST) 
               WITH_KEY(#CUSTNO)
       IF_STATUS  IS(*OKAY)
       DISPLAY    FIELDS(#CUSTOMER)
       ELSE
       MESSAGE    MSGTXT('No customer exists with this number')
       ENDIF
    END_LOOP

 

Points to Note:
  • Both versions keep doing inquiries until the EXIT or MENU function key is used (BEGIN_LOOP and END_LOOP commands).
  • The EXIT and MENU function keys are enabled on the REQUEST and DISPLAY screens by default. If either key is used the function will end.
  • The first version uses the NOT_FOUND and ISSUE_MSG parameters of the FETCH command to automatically cause a "not found" message to be issued and then to return control to the request command.
  • The second version uses the IF_STATUS command to check if the record was found. If it was it is displayed, else a message is issued that will appear on line 22/24 of the REQUEST screen
  • Ý 5.3 Sample RDML Programs.