Good CA 2E code or coding takes some effort. A key aspect of creating good code is to make the action diagram simple to read. It is always good to include comments in code so the next programmer can read your intent. It is also very helpful to divide your code into separate sections of related code. Then you can use the H key to hide that section of code. When you want to look at your code, use Z to zoom into the section or us an S to show the expanded section of code. These concepts are probably old news to the seasoned 2E professional.

One of the ways that I have often used to divide my code into sections is by using IS or ISF to Insert a Sequence. This works great and allows you to divide code into sections and add some comments to a section of code. When looking at the source code, you will see that in RPG or COBOL, a separate sub-routine is created for this code.

Sub-routines are not a problem, but sometimes it is easier during debugging to not have to go back and forth between sub-routines.  I found a great trick that helps you deal with this more smoothly – ‘insert a case statement.’ Insert a Case Statement then insert an’ otherwise in the case.’ Finally, delete the ‘New Condition’ statement of the Case Statement. It sounds sort of strange to have a Case Statement with no conditions but in effect, it is creating a section of code that will always be executed. Plus no sub-routine is generated in the source code.

 

Untitled

Untitled1

Untitled2