Insert Delimiters In File Using SYNCSORT



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Insert Delimiters In File Using SYNCSORT

Postby Mobius » Wed Sep 07, 2022 10:48 pm

My goal is to merge several files into one and, programmatically in the last step, insert a comma in the same columns on every record, then ship the results to an audience that will upload the data to an excel spreadsheet (hence the comma delimiters).

As preamble, I've been to the Syncsort manual and tried several examples (and several more plucked from search engine results), but when Syncsort inserts a value in the respective columns, it pushes all the data after the inserted character 1 column to the right, whereas I just want the commas inserted in place so the file length doesn't change.

Here's what my input looks like:


AAAAA  9999           2022             9  AA       00000000   1234567890456
AAAAA  9999           2022             9  AA       00000000   1234567890456
AAAAA  9999           2022             9  AA       00000000   1234567890456
AAAAA  9999           2022             9  AA       00000000   1234567890456
AAAAA  9999           2022             9  AA       00000000   1234567890456
AAAAA  9999           2022             9  AA       00000000   1234567890456
AAAAA  9999           2022             9  AA       00000000   1234567890456
AAAAA  9999           2022             9  AA       00000000   1234567890456
AAAAA  9999           2022             9  AA       00000000   1234567890456
AAAAA  9999           2022             9  AA       00000000   1234567890456


Here's what my sort step looks like:


//STEP0010 EXEC PGM=SORT
//SORTIN   DD DSN=MERGED.SORTED.INPUT,DISP=SHR
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD DSN=MERGED.SORTED.OUTFILE,
//            DISP=(,CATLG,DELETE),
//            SPACE=(TRK,(150,300),RLSE),
//            DSB=*.SORTIN
//SYSIN    DD
  SORT FIELDS=COPY
  OUTREC FIELDS=(1,72,
                 6:C',',
                12:C',',
                27:C',',
                40:C',',   
                44:C',',     
                60:C',')


Here's my desired output (column positions are approximate):



AAAAA, 9999,          2022,            9, AA,      00000000,  1234567890456
AAAAA, 9999,          2022,            9, AA,      00000000,  1234567890456
AAAAA, 9999,          2022,            9, AA,      00000000,  1234567890456
AAAAA, 9999,          2022,            9, AA,      00000000,  1234567890456
AAAAA, 9999,          2022,            9, AA,      00000000,  1234567890456
AAAAA, 9999,          2022,            9, AA,      00000000,  1234567890456
AAAAA, 9999,          2022,            9, AA,      00000000,  1234567890456
AAAAA, 9999,          2022,            9, AA,      00000000,  1234567890456
AAAAA, 9999,          2022,            9, AA,      00000000,  1234567890456
AAAAA, 9999,          2022,            9, AA,      00000000,  1234567890456


Here's what I get instead of desired output (the delimiters I wanted but the data gone):


         ,       ,                  ,             ,   ,               ,
         ,       ,                  ,             ,   ,               ,
         ,       ,                  ,             ,   ,               ,
         ,       ,                  ,             ,   ,               ,
         ,       ,                  ,             ,   ,               ,
         ,       ,                  ,             ,   ,               ,
         ,       ,                  ,             ,   ,               ,


My last shot was adding the "1,72" parm values to the sort card indicating I wanted to retain the data in columns 1 thru 72 while inserting the commas, but Syncsort didn't see it that way.

I feel like there's one eensy-weensy change to the sort card that will resolve this that I just haven't stumbled onto yet.

Hope this has illustrated my issue clearly. Thanks!
Mobius
 
Posts: 2
Joined: Wed Sep 07, 2022 9:13 pm
Location: USA
Has thanked: 1 time
Been thanked: 0 time

Re: Insert Delimiters In File Using SYNCSORT

Postby sergeyken » Thu Sep 08, 2022 5:28 pm

1) the parameter OUTFIL FIELDS= is considered as obsolete one; recommended to be replaced with BUILD=

2) in your case you need to use OVERLAY= in place of BUILD= (or FIELDS=), because BUILD= with explicit positions inserts blanks in between. RTFM.
Javas and Pythons come and go, but JCL and SORT stay forever.

These users thanked the author sergeyken for the post:
Mobius (Thu Sep 08, 2022 7:19 pm)
User avatar
sergeyken
 
Posts: 438
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 7 times
Been thanked: 40 times

Re: Insert Delimiters In File Using SYNCSORT

Postby Mobius » Thu Sep 08, 2022 7:19 pm

That fixed it. Thanks.
Mobius
 
Posts: 2
Joined: Wed Sep 07, 2022 9:13 pm
Location: USA
Has thanked: 1 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post