So many of these basic "input this/output that" requirements can easily be solved by simply inserting "specific code" into a small GET/PUT Assembler shell with an appropriate output file DCB:
Code: Select all
GETPUT CSECT
BAKR 14,0
LR 12,15
USING GETPUT,12
PRINT NOGEN
OPEN (INFILE,INPUT,OUTFILE,OUTPUT)
LOOP GET INFILE R1 -> INREC
*
* insert "specific code" here
*
B LOOP DO WHILE MORE INPUT
EOF CLOSE (INFILE,,OUTFILE)
PR
INFILE DCB DSORG=PS,DDNAME=INFILE,MACRF=GL,EODAD=EOF
*
* insert appropriate OUTFILE DCB here
*
DCBD DEVD=DA,DSORG=PS
END
For example, fixed-length input to fixed-length output:
Code: Select all
* specific code
LR 0,1 R0 -> INREC
PUT OUTFILE,(0) OUTPUT FROM INPUT
* appropriate OUTFILE DCB
OUTFILE DCB DSORG=PS,DDNAME=OUTFILE,MACRF=PM
Or, for the OPs case, variable-length input to fixed-length output padded with "$" chars:
Code: Select all
* specific code
LA 2,4(,1) R2 -> INREC DATA (FOLLOWS RDW)
LH 3,INFILE+(DCBLRECL-IHADCB) R3 = INREC LEN (+RDW LEN)
LHI 4,4 R4 = 4
SR 3,4 R3 = INREC DATA LEN
ICM 3,8,=C'$' SET PAD CHARACTER
PUT OUTFILE R1 -> OUTPUT AREA
LR 0,1 R0 -> OUTPUT AREA
LH 1,OUTFILE+(DCBLRECL-IHADCB) R1 = OUTREC LEN
MVCL 0,2 MOVE RECORD TO OUTPUT AREA WITH FILL
* appropriate OUTFILE DCB
OUTFILE DCB DSORG=PS,DDNAME=OUTFILE,MACRF=PL
Note in the OPs case, we use "...MACRF=PL" (Locate Mode) for the Output File. With this variation, "PUT OUTFILE" returns a pointer to a buffer location to which the record may be moved. The OP's requirement specifies a "$" fill character, but this could just as easily any other character, such as a blank (X'40').
In every case, the JCL is likewise very simple:
Code: Select all
// EXEC PGM=<Get/Put program name>
//OUTFILE DD DSN=<output file DSN>,DISP=<output file disp>,DCB=<output file DCB specifications, if needed>
//INFILE DD DSN=<input file DSN>,DISP=<input file disp>,DCB=<input file DCB specifications, if needed>
//