Submitted by Kim Egekjaer on Wed, 11/19/2008 - 00:00
Forums

Below I list a few tips and tricks for Auto Forms Control (AFC) in InterForm400. Remember to add the commands:

STRSBS apf3812/auto_form
MONMSG cpf0000

- and start of the other InterForm400 subsystems you might need...

a) Templates
Just like the S=Suboverlay function for overlays we have the template option for AFC definitions. We can use this feature to reuse definitions made on one outq for other output queues. The trick is to define one monitored output queue per connected printer and define the output queue of the printer as the default output queue here:

-------------------------------------------------------------------------------------
Update Auto Forms Control Definition AFC302D

Output queue . . . . . . : PRT01_IN
Library . . . . . . . : QUSRSYS

Type choices and then press Enter. Press F3 or F12 to exit.
Description . . . . . . . . Input queue for PRT01
Autostart job . . . . . . . Y (Y N)
Code page . . . . . . . . . *SYSVAL Number, *SYSVAL F4=List
When to use code page . . *SPLFATR *SPLFATR, *ALWAYS

Default output output queue and printer type
Output queue . . . . . . . . PRT01
Library . . . . . . . . . QUSRSYS
Printer type . . . . . . . . HP4D_PJL

Optional template AFC-definition to be executed after this definition
Template AFC-definition:
Output queue . . . . . . . . TEMPLATE <----
Library . . . . . . . . . QGPL <----

F3=Exit F4=Prompt F10=Additional parameters F12=Cancel
--------------------------------------------------------------------------------------

You just define all the AFC definition in the single TEMPLATE outq and let all other outqs refer to this. In this way you can insert predefined definitions into production on all printers at a new customer site VERY fast.
In this way you can use the same definitions for all printers and maintain the definitions only once.

Just remember to use *DEFAULT as the output queues of the merges inside of the template definition and *INPUT for finishing definitions.

If you have any specific definitions for a queue you can still add them and combine them with the template. The 'local' functions are executed first making sure you can cover the special cases first.

 

b) Debugging AFC jobs
Why is the AFC job not running as you would think? In order to dig into the problem you can use a few tools and tips to get closer:

If you are using an AFC template like described above it necessary to restart the AFC job in order to get a changed template into production on each outq.

With the 2008 Versions you can change the mode of a RUNNING AFC job into Step by Step mode meaning that just before a function is executed a break message is issued and you can answer it with 'G' for Go to execute the single line or '*ENDDBG' to end the Step by Step mode and go into the normal mode. This feature is a way to check which steps the spooled file actually trigger.2008 Versions also got the *=Suspend option on the AFC lines so you can temporarily disable AFC lines that you suspect are causing a problem.

Another great way to check up on a running AFC job is to look at the joblog. It is quite informative. You can even get much more information if you change these parameters of the running job: LOG(4 00 *SECLVL) LOGCLPGM(*YES). If the AFC job can 'feel' that you have activated logging of CL commands it will help you by adding even more information in the joblog - apart from the CL commands of course.

Always remember that the formtype is case sensitive. That is a common mistake.

If all of the above fails: You can always contact me :-)

 

c) Function 9=Exit in AFC
Sometimes I am asked how you can make a spooled file only partially execute the AFC definitions for an output queue. With this I mean: When the execution comes to line X in the AFC outq it should stop execution.

This is something you might want to do if you restore a spooled file from an archive solution:
The restored (*SCS) spooled file should be merged and/or mailed as usual - but it should NOT be archived again.

To make sure that the last definitions on the queue are NOT executed you can make sure, that the 9=Exit function is triggered in AFC. This will make AFC ignore the spooled file for any lines with a higher sequence number.

Some think, that if you delete or hold a spooled file you will get the same result. That is not the case.

Please consider these definitions:

--------------------------------------------------------------------------------------
Update AFC-functions attached to output queues AFC305D

Queue: PRT01_IN Library: QUSRSYS

Seqnbr Funct Form type Save Jobname Filename Device file Program
0001 1 DEMO
Merge, Overlay: IF400DEMO Fileset: SAMPLE
0002 7 DEMO
Delete Spooled File
0004 5
Move spooled file, new outq: PRT01 library: QUSRSYS
--------------------------------------------------------------------------------------  

 

What do you think will happen if you release a spooled file with form type=DEMO on the output queue???
Yes: The spooled file will be merged and deleted and then what???
AFC will still try to move a spooled file even though it was just deleted. So you will get an error in the AFC job here.

But add a 9=Exit like below and you have made a setup that works:

--------------------------------------------------------------------------------------
Update AFC-functions attached to output queues AFC305D

Queue: PRT01_IN Library: QUSRSYS

Seqnbr Funct Form type Save Jobname Filename Device file Program
0001 1 DEMO
Merge, Overlay: IF400DEMO Fileset: SAMPLE
0002 7 DEMO
Delete Spooled File
0003 9 DEMO
Exit
0004 5
Move spooled file, new outq: PRT01 library: QUSRSYS
--------------------------------------------------------------------------------------  

Feel free to ask for details if needed. 

 

d) A = Change Attributes
Have you ever used Option A=Change Attributes in AFC? Ever wondered why it did not behave as you or a customer thought? Here is an example:

--------------------------------------------------------------------------------------
Update AFC-functions attached to output queues AFC305D

Queue: PRT01_IN Library: QUSRSYS

Seqnbr Funct Form type Save Jobname Filename Device file Program
0001 1 DEMO
Merge, Overlay: IF400DEMO Fileset: SAMPLE
0002 A DEMO
Change attributes, Form type: DEMO2 User data: *SAME
0003 5 DEMO2
Move spooled file, new outq: PRT01 library: QUSRSYS


Seqnbr Function
2.0 A Change attributes
Form type . . . . . . DEMO2 Form type, *SAME
User data . . . . . . *SAME User data, *SAME

Restart with sequencenbr 1 N (Y N)
-------------------------------------------------------------------------------------- 

 

Where do you think the spooled file with form type=DEMO is placed after running through these definitions?? Is it PRT01_IN or PRT01??

No! It is PRT01_IN. Why is that then?? You cannot on the fly change the spooled file attributes as they are retrieved before the AFC job handles the spooled file. So the incoming spooled file is still considered to have form type= DEMO in sequence line 3 above - EVEN though we changed it in line 2. If you want to make it work as you would normally think you need to activate 'Restart with sequence nbr 1' on this function:

--------------------------------------------------------------------------------------
Seqnbr Function
2.0 A Change attributes

Form type . . . . . . DEMO2 Form type, *SAME
User data . . . . . . *SAME User data, *SAME

Restart with sequencenbr 1 Y <---------------  

 

With this option activated the changed spooled file attribute (form type in this case) is used when AFC rerun all the definitions - from line 1. This means that the spooled file will be held and moved below:

--------------------------------------------------------------------------------------
Seqnbr Funct Form type Save Jobname Filename Device file Program
0001 1 DEMO
Merge, Overlay: IF400DEMO Fileset: SAMPLE
0002 6 DEMO2
Hold Spooled File
0003 A DEMO
Change attributes, Form type: DEMO2 User data: *SAME
0004 5 DEMO2
Move spooled file, new outq: PRT01 library: QUSRSYS
-------------------------------------------------------------------------------------- 

If you want to change other attributes you can of course also call a user program via option 8=Call program based on demo source apf3812/apisrc.funkt_8.
If you want the same in the program you just change the attribute and then hold and release the spooled file to rerun the AFC definitions.