Page 1 of 2

Syncsort - Copy and Reformat

PostPosted: Mon Sep 10, 2012 5:28 pm
by ranga_subham
Hi, we get a flat file (LRECL=80,RECFM=FB) and need to reformat it to populate a key field on each record.

Input:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
SRT3     STATUSFL1303404GH6                              #T#           1   
31055ABC0121X6AL5S3 D0      3012052512X226111290N   6AB6922521420        3A
33111XYZ1231Y6AH5S3 D1      3012070312Y2282     N   6AB6922521420        3A
MUT4     STATUSFL1400048MK3                              #T#           1   
74620DEF2134G1J86CC E1      3012090572Z313372650N   1JC4822521243        4J
74620ZEB3218G1J86CC E2      3012090572O313372650N   1JD4822521243        4J


Rules:
The header record should copy content from 10th column (15 bytes) and put it before value appearing in 1st column and newly formed value should begin at 13th column and 37th column.
The detail record should add a key field from -
'D' or 'E' appearing at 21st column should be converted to '13' or '14' respectively and copied to 1st column
A Value appearing at 37th column should be copied to 3rd column and 11th column
6 characters starting at 6th column should be copied to 5th column
The 10 characters (STATUSFL13 or STATUSFL14 from respective headers) appearing in header record should be copied to 13th column
The 6 digit value appearing at 23rd column should be copied to 23rd column from respective header record


Output:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
            STATUSFL1303404SRT5     STATUSFL1303404GH6                         
1312ABC01212STATUSFL130340431055ABC0121X6AL5S3 D0      3012052512X226111290N   6
1312XYZ12312STATUSFL130340433111XYZ1231Y6AH5S3 D1      3012070312Y2282     N   6
            STATUSFL1400048MUT4     STATUSFL1400048MK3                         
1472DEF21372STATUSFL140004874620DEF2134G1J86CC E1      3012090572Z313372650N   1
1472ZEB32172STATUSFL140004874620ZEB3218G1J86CC E2      3012090572O313372650N   1


Please help me to achieve this.

Thanks.

Re: Syncsort - Copy and Reformat

PostPosted: Mon Sep 10, 2012 7:40 pm
by dick scherrer
Hello,

You need to post what you have done so far and where there is a problem.

Our intent is to help you learn, not do the work for you.

There are similar topics you can find and use here in the forum to get almost all of this working (maybe even all of it).

Re: Syncsort - Copy and Reformat

PostPosted: Mon Sep 10, 2012 10:22 pm
by BillyBoyo
How do you identify the "header" record. Look at WHEN=GROUP with BEGIN and PUSH for the information you want to copy to other records.

Other than that, you have some reformatting (header and detail records) with BUILD.

If you are new to this, start with one thing, like reformatting the header, and go on from there.

Re: Syncsort - Copy and Reformat

PostPosted: Tue Sep 11, 2012 6:20 pm
by ranga_subham
I tried it like this

1). Use WHEN=GROUP on unique identifier and push header data to 90th column and populate it on to detail records
2). Use unique identifier from header and populate header data as required
3). Use WHEN=NONE and reformat detail records as required


But, I am unable to convert 'D' to 13 or 'E' to 14.

Thanks.

Re: Syncsort - Copy and Reformat

PostPosted: Tue Sep 11, 2012 7:01 pm
by ranga_subham
This is what I could all write to get the results but incomplete :cry:
I am not able to get the 'D' or 'E' from 21st position converted to '13' and '14' respectively.

//SYSIN    DD *                                               
  SORT FIELDS=COPY                                             
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(58,3,CH,EQ,C'#T#'),         
                 PUSH=(75:1,72)),                             
         IFTHEN=(WHEN=(58,3,CH,EQ,C'#T#'),                     
                 BUILD=(13:84,15,75,4,37:10,62)),             
         IFTHEN=(WHEN=NONE,BUILD=(1:92,2,3:37,2,5:6,6,11:37,2,
                                  13:84,15,28:1,72))           


Any help is greatly appreciated. Thanks.

Re: Syncsort - Copy and Reformat

PostPosted: Tue Sep 11, 2012 7:20 pm
by dick scherrer
Hello,

It will probably help if you post the informational messages generated by the run.

Was the return code = zero?

Posting a bit of the input data and the generated output data will also help. Do use the Code tag to preserve alignment.

Re: Syncsort - Copy and Reformat

PostPosted: Tue Sep 11, 2012 8:01 pm
by ranga_subham
Job ran with ZERO return code.......posted both input and output in the first post itself :o

Re: Syncsort - Copy and Reformat

PostPosted: Tue Sep 11, 2012 8:34 pm
by Akatsukami
ranga_subham wrote:Job ran with ZERO return code.......posted both input and output in the first post itself :o

dick scherrer wrote:It will probably help if you post the informational messages generated by the run.

Re: Syncsort - Copy and Reformat

PostPosted: Tue Sep 11, 2012 9:16 pm
by dick scherrer
Hello,

posted both input and output in the first post itself
Yup, but i was not sure if this was the output you got from the run or what you wanted. We probably need to see both (preferably all 3 - input, actual op, wanted op) in the same post to make it easier to work with.

And, yes - we still need the informational messages generated.

Re: Syncsort - Copy and Reformat

PostPosted: Wed Sep 12, 2012 5:10 am
by BillyBoyo
Consult you documentation and see if you have CHANGE available.

If not, you'll have IFTHEN=(WHEN= for value),OVERLAY=(1:nn).