Page 1 of 1

Add leading zeroes to record

PostPosted: Fri Feb 08, 2019 1:01 pm
by Manjucan
Hi all

My input record is like this

123456789 123456 123456789

Is it possible to add 4 leading zeroes to this record using INREC ?

ie I want the record as below

0000123456789 123456 123456789

Re: Add leading zeroes to record

PostPosted: Fri Feb 08, 2019 2:54 pm
by Garry F Carroll
Yes, assuming an 80 byte FB record:

INREC BUILD=(1:C'0000',1,80)


adjust for your record type/length.

Garry.

Re: Add leading zeroes to record

PostPosted: Fri Feb 08, 2019 3:15 pm
by Manjucan
Thanks Garry.

I tried this option but I am getting the below error :

INREC RECORD LENGTH=84
POTENTIALLY INEFFICIENT USE OF INREC
OUTREC RECORD LENGTH=84
SORTOUT HAS INCOMPATIBLE LRECL

Re: Add leading zeroes to record

PostPosted: Fri Feb 08, 2019 3:18 pm
by Garry F Carroll
What is your RECFM and LRECL ? Can you show the job (using the Code tags) ? Code tags are applied using the buttons above the screen where youre typing.

Garry

Re: Add leading zeroes to record

PostPosted: Fri Feb 08, 2019 4:05 pm
by Manjucan
Hi Garry

The RECFM is FB and LRECL =80


OPTION COPY
INREC BUILD=(1:C'0000',1,80)
OUTREC IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=01,ENDPOS=13,SHIFT=NO,
INOUT = (C'0000123456789',C'345678912'))),
IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=01,ENDPOS=13,SHIFT=NO,
INOUT = (C'0000',C'222222222'))),
IFTHEN


[/code]

Re: Add leading zeroes to record

PostPosted: Fri Feb 08, 2019 4:18 pm
by Garry F Carroll
Those are your control cards, not the job - and now have OUTREC, which has nothing to do with your original question. Can you show the error messages you are getting?

Also, the syntax of the OUTREC statements looks wrong - what is INOUT = ? To start with, there should be no spaces and my SORT documentation shows both IN= and OUT= parameters, not a single INOUT= parameter.

In posting your question, you should specify what you expect as output at the end of processing - what I suggested gives exactly what you looked for without OUTREC processing in your original question.

Garry.

Re: Add leading zeroes to record

PostPosted: Fri Feb 08, 2019 4:39 pm
by Garry F Carroll
Not to mention that you have multiple WHEN=INIT clauses - which is incorrect.

Garry.

Re: Add leading zeroes to record

PostPosted: Fri Feb 08, 2019 5:44 pm
by enrico-sorichetti
if You can drop the last 4 bytes use

INREC BUILD=(1:C'0000',1,76)