This guideline is very simple, yet it will allow LANSA programs to be completed more quickly and accurately.
When working on the code of a specific RDML function, always attempt to use a "top down" approach to coding. For instance, you may be given a program "specification" which looks like this:
You must now "translate" this specification into the LANSA rapid development language.
With a structured (or organized) approach to coding, the program will follow similar steps to the example below.
Note how the arrow --> is used to indicate the new lines inserted in each step:
--> ********** Do until terminated by EXIT or MENU key --> BEGIN_LOOP --> END_LOOP
********** Do until terminated by EXIT or MENU key BEGIN_LOOP --> ********** Request order number input until order is found --> ********** Build a list of all order lines --> ********** Display the order and its lines to the user END_LOOP
********** Do until terminated by EXIT or MENU key BEGIN_LOOP ********** Request order number until order is found --> DOUNTIL COND('#IO$STS = OK') --> ENDUNTIL ********** Build a list of all order lines ********** Display the order and its lines to the user END_LOOP
********** Do until terminated by EXIT or MENU key BEGIN_LOOP ********** Request order number until order is found DOUNTIL COND('#IO$STS = OK') ENDUNTIL ********** Build a list of all order lines --> CLR_LIST NAMED(#LINES) --> SELECT FIELDS(#LINES) FROM_FILE(ORDLIN) WITH_KEY(#ORDNUM) --> ENDSELECT ********** Display the order and its lines to the user END_LOOP
********** Do until terminated by EXIT or MENU key BEGIN_LOOP ********** Request order number until order is found DOUNTIL COND('#IO$STS = OK') ENDUNTIL ********** Build a list of all order lines CLR_LIST NAMED(#LINES) SELECT FIELDS(#LINES) FROM_FILE(ORDLIN) WITH_KEY(#ORDNUM) ENDSELECT ********** Display the order and its lines to the user --> DISPLAY FIELDS(#HEADER) BROWSELIST(#LINES) END_LOOP
********** Do until terminated by EXIT or MENU key BEGIN_LOOP ********** Request order number until order is found DOUNTIL COND('#IO$STS = OK') --> ********** Request user inputs an order number --> ********** Attempt to locate the order --> ********** Issue message if order was not found ENDUNTIL ********** Build a list of all order lines CLR_LIST NAMED(#LINES) SELECT FIELDS(#LINES) FROM_FILE(ORDLIN) WITH_KEY(#ORDNUM) ENDSELECT ********** Display the order and its lines to the user DISPLAY FIELDS(#HEADER) BROWSELIST(#LINES) END_LOOP
********** Do until terminated by EXIT or MENU key BEGIN_LOOP ********** Request order number until order is found DOUNTIL COND('#IO$STS = OK') ********** Request user inputs an order number REQUEST FIELDS(#ORDNUM) ********** Attempt to locate the order --> FETCH FIELDS(#HEAD) FROM_FILE(ORDMST) WITH_KEY(#ORDNUM) ********** Issue message if order was not found ENDUNTIL ********** Build a list of all order lines CLR_LIST NAMED(#LINES) SELECT FIELDS(#LINES) FROM_FILE(ORDLIN) WITH_KEY(#ORDNUM) ENDSELECT ********** Display the order and its lines to the user DISPLAY FIELDS(#HEADER) BROWSELIST(#LINES) END_LOOP
********** Do until terminated by EXIT or MENU key BEGIN_LOOP ********** Request order number until order is found DOUNTIL COND('#IO$STS = OK') ********** Request user inputs an order number REQUEST FIELDS(#ORDNUM) ********** Attempt to locate the order FETCH FIELDS(#HEAD) FROM_FILE(ORDMST) WITH_KEY(#ORDNUM) ********** Issue message if order was not found --> IF_STATUS WAS_NOT(*OKAY) --> ENDIF ENDUNTIL ********** Build a list of all order lines CLR_LIST NAMED(#LINES) SELECT FIELDS(#LINES) FROM_FILE(ORDLIN) WITH_KEY(#ORDNUM) ENDSELECT ********** Display the order and its lines to the user DISPLAY FIELDS(#HEADER) BROWSELIST(#LINES) END_LOOP
********** Do until terminated by EXIT or MENU key BEGIN_LOOP ********** Request order number until order is found DOUNTIL COND('#IO$STS = OK') ********** Request user inputs an order number REQUEST FIELDS(#ORDNUM) ********** Attempt to locate the order FETCH FIELDS(#HEAD) FROM_FILE(ORDMST) WITH_KEY(#ORDNUM) ********** Issue message if order was not found IF_STATUS WAS_NOT(*OKAY) --> MESSAGE MSGTXT('No details of this order found') ENDIF ENDUNTIL ********** Build a list of all order lines CLR_LIST NAMED(#LINES) SELECT FIELDS(#LINES) FROM_FILE(ORDLIN) WITH_KEY(#ORDNUM) ENDSELECT ********** Display the order and its lines to the user DISPLAY FIELDS(#HEADER) BROWSELIST(#LINES) END_LOOP
********** Do until terminated by EXIT or MENU key BEGIN_LOOP ********** Request order number until order is found DOUNTIL COND('#IO$STS = OK') ********** Request user inputs an order number REQUEST FIELDS(#ORDNUM) ********** Attempt to locate the order FETCH FIELDS(#HEAD) FROM_FILE(ORDMST) WITH_KEY(#ORDNUM) ********** Issue message if order was not found IF_STATUS WAS_NOT(*OKAY) MESSAGE MSGTXT('No details of this order found') ENDIF ENDUNTIL ********** Build a list of all order lines CLR_LIST NAMED(#LINES) SELECT FIELDS(#LINES) FROM_FILE(ORDLIN) WITH_KEY(#ORDNUM) --> ADD_ENTRY TO_LIST(#LINES) ENDSELECT ********** Display the order and its lines to the user DISPLAY FIELDS(#HEADER) BROWSELIST(#LINES) END_LOOP
You should find that well structured and documented programs are very easy to produce by using this type of approach, which basically consists of always: