1. The values to be picked from the old file are from specific position always and where it needs to be put in the new file is also fixed.
i.e. There is a mapping for each of the fields and the field positions.
2. The hardcoded values in the new file are also fixed, both for value and position.
As I had mentioned in the initial post, that was only an example report. We do not have to check for conditions or derive values.
The basic requirement is to pick values from input file, from specific positions and place it in specific positions on the output file.
Along with this, I need to incorporate some static hardcoded text in the output file.
The record format is FB and LRECL is 133 for both input and output.
So, use a number of IFTHEN=(WHEN=GROUP with BEGIN to identify the lines containing the data you want, and PUSH to locate a copy of that data (all that you need) into different positions.
This will mean that all records after your last WHEN-GROUP contain all the data you need, and all the previous records are useless. So arrange for an OUTFIL INCLUDE to pick up a record which now has all the data.
Use OUTFIL BUILD with the "slash operator" (/) which allows multiple output records from a single input record. Use several of these to format your new report, with a mixture of the data you have PUSHed and the new constants that you need.
Untested, but this should take the input "report", extract some "data" to, here, the last record (not because it is the last, but because it has '2' in the first position of the record), include only the last record, then produce a new "report" with contstants and the extracted data.