Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note how the arrow --> is used to indicate the new lines inserted in each step:

Step 1

...

     --> ********** Do until terminated by EXIT or MENU key

...

     --> BEGIN_LOOP

...

     --> END_LOOP

...

Step 2

...

         ********** 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 

...

Step 3

...

         ********** 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

...

Step 4

...

         ********** 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

...

Step 5

...

         ********** 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

...

Step 6

...

         ********** 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

...

Step 7

...

         ********** 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 

...

Step 8

...

         ********** 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 

Step 9

...

         ********** 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

...

Step 10

...

         ********** 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:

  • entering the structured programming constructs completely before coming back to fill in the details. For example:   BEGIN_LOOP/END_LOOP, DOUNTIL/ENDUNTIL, SELECT/ENDSELECT, IF/ELSE/END, etc. etc.
  • including the comments before the commands.