Today’s little tip is about how to use WAPL to complete an application group in the current plan.
The key thing about groups in the plan is that they are a collection of occurrences, rather than a single object in itself. So whilst from the ISPF dialogs you can use the CG (complete group) line command, to do this programmatically you must first find all the occurrences and then complete each one of them before issuing an EXECUTE.
The EXECUTE is the point all of the changes are committed to the current plan in a synchronized manner and can avoid some nasty side effects. For example if your group included APPLA followed by APPLB, if each complete action was committed instantly, then the point APPLA is completed the jobs in APPLB could potentially start before your code reaches the point of completing APPLB. The EXECUTE methodology allows you to prepare all the changes in advance and make them live in the current plan simultaneously.
For low level PIF commands like INSERT and MODIFY, WAPL will automatically perform an EXECUTE at the end of the job if one is needed, though you can choose to explicitly perform an EXECUTE yourself at various points in your WAPL program as needed.
A simple WAPL program like this can be used to complete a group.
The LIST statement will find all of the occurrences within a particular Application Group. The GROUPDEF keyword names the Application Group to complete, and the IA keyword identifies which one. If you are sure there is only one occurrence of the group in the plan, the IA is not needed, otherwise you need to specifically identify the IA in some way. Usually you will know the time part of the IA as this will not vary from day to day, so the time part can be hard coded, the date part will usually need to be the same day as the job doing the complete, so you can use variable OADID to pick up the scheduled date or variable CYYMMDD to pick up the current date.
The LIST command then creates an object variable called GRP which allows the rest of the WAPL code to step through the results to create the MODIFY commands to complete each individual occurrence. The high level variable !@GRP contains the number of occurrences that were found which can be used to drive a loop to pick up the application name (CPOCADI) and the Input Arrival (CPOPIA). Which then forms each MODIFY command.
Once the loop has been completed, it is then time to perform the EXECUTE to commit all the changes to the Current Plan.
Note that WAPL will NOT let you do something you couldn’t do in ISPF. So you must have the necessary access rights and you will not be able to break any rules surrounding status, dependencies or anything else.
You can use similar WAPL programs for all sorts of functions, varying the LIST statement arguments to find your target occurrences or operations and then process them in a loop, possibly filtering the results with IF statements if you don’t want to apply the action to every record identified by the LIST statement.
The main thing to consider when using this technique is to keep the result of your LIST as targeted as possible. This will avoid memory issues with large lists, and save time filtering out results you don’t want to process. Depending on the functions you are trying to achieve the LIST can be several separate statements which could then be processed in separate loops, as long as the overall goal is achieved.