As documented, the HLASM PUNCH statement output is processed during the same pass as generating object code, so if any earlier statement causes object code to be generated, then it will not be the first output, and the object deck will not be valid for the binder.
To avoid that problem, you would need to ensure that you do not generate any object code until after the macro. For a single assembly, there is no way to get round that. If you use the BATCH option, you can generate object code from more than one assembly in the same file, so for example you could generate a PUNCH statement by a separate assembly after the END statement of the main program, or before the start. That would be a separate assembly that could not make use of any conditional assembly variables shared with the main program, although it could for example use the same &SYSPARM or the variables &SYSIN_DSN and &SYSIN_MEMBER containing the input data set information. Jonathan Scott, HLASM IBM Hursley, UK
