Convert VB to FB file but with padding.
Convert VB to FB file but with padding.
Hi,
I am facing a problem for which I need some help. I am in need to convert a VB file to FB file. But in this, if the record length is shorter than the LRECL, we need to pad the remaining of the length with a character '$'. How can I do that?
Thanks,
I am facing a problem for which I need some help. I am in need to convert a VB file to FB file. But in this, if the record length is shorter than the LRECL, we need to pad the remaining of the length with a character '$'. How can I do that?
Thanks,
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Convert VB to FB file but with padding.
Well, your SORT product can do it. Use VTOF (better) or CONVERT and us VLFILL to get your pad-character.
Re: Convert VB to FB file but with padding.
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:
For example, fixed-length input to fixed-length output:
Or, for the OPs case, variable-length input to fixed-length output padded with "$" chars:
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
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
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
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
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>
//
Re: Convert VB to FB file but with padding.
I am not very good with Assembler. I will take to understand your code. Thanks for your explanation.ApexNC wrote: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:For example, fixed-length input to fixed-length output: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
Or, for the OPs case, variable-length input to fixed-length output padded with "$" chars: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
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').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
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> //
Re: Convert VB to FB file but with padding.
With the VLFILL hint, I got the below example from IBM site:
It should give me the correct result. Testing it.
And made my job like this:You can convert a VB data set to an FB data set with OUTFIL's VTOF and BUILD or OUTREC parameters. All of the PARSE, BUILD, or OUTREC features are available (input fields, strings, editing, and so on). For VTOF, you specify the input positions of the VB input record (with the RDW), and the output columns of the FB output record (without the RDW). DFSORT does not include the RDW in the FB output records.
Attention: You cannot specify OVERLAY, FINDREP, or IFTHEN with VTOF.
The following JCL and DFSORT control statements convert a VB data set with LRECL=104 to an FB data set with LRECL=100:
//VBFB JOB A92,PROGRAMMER
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=A123456.VBIN,DISP=SHR
//FBOUT DD DSN=A123456.FBOUT,DISP=(NEW,CATLG,DELETE),
// UNIT=3390,SPACE=(CYL,(5,5))
//SYSIN DD *
OPTION COPY
OUTFIL FNAMES=FBOUT,VTOF,OUTREC=(5,100)
/*
Up to 100 bytes of data starting at position 5 (after the RDW) of the VB input record appears in the FB output record starting at position 1. The FB output records are all 100 bytes long. By default, if a VB input record has less than 100 data bytes, DFSORT pads the output data with blanks on the right to 100 bytes. However, you can change the padding character to anything you like with OUTFIL's VLFILL parameter. For example, VLFILL=C'*' pads with asterisks and VLFILL=X'00' pads with binary zeros:
SORT FIELDS=(25,10,CH,A)
* Pad short fields on the right with blanks (default is VLFILL=C' ')
OUTFIL FNAMES=PADB,VTOF,
OUTREC=(41,40,C'Blank padding',11,20)
* Pad short fields on the right with asterisks
OUTFIL FNAMES=PADA,VTOF,
OUTREC=(5,60,C'Asterisk padding',61,40),VLFILL=C'*'.
* Pad short fields on the right with binary zeros
OUTFIL FNAMES=PADZ,VTOF,
OUTREC=(21,60,C'Binary zero padding'),VLFILL=X'00'
LRECL=73 is set for the PADB output data set, which has 73 byte FB records.
Short input fields are padded with blanks on the right as needed.
LRECL=116 is set for the PADA output data set, which has 116 byte FB records.
Short input fields are padded with asterisks on the right as needed.
LRECL=79 is set for the PADZ output data set, which has 79 byte FB records.
Short input fields are padded with binary zeros on the right as needed.
Code: Select all
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=my.file.VBIN,DISP=SHR
//FBOUT DD DSN=my.file.FBOUT,DISP=(NEW,CATLG,DELETE),
// UNIT=3390,SPACE=(CYL,(5,5))
//SYSIN DD *
OPTION COPY
OUTFIL FNAMES=FBOUT,VTOF,OUTREC=(5,80)
OUTREC=(5,80),VLFILL=C'$'
/*
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute