Need help with sort



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

Need help with sort

Postby Srini1808 » Thu Sep 25, 2014 11:26 am

Greetings!
I have a file in the following format - rec size 94,bytes.first byte is record type. Record type 6 is the main record and record type 7 is the continuation record. All the other record types need to be copied to the output file as it is, but if there is a record type 7 immediately after record type 6, that entire record 7 must be concatenated to position 95 onwards to the previous record. Not all rev type 6 may be followed by rec type 7 as they may not have continuation record. Final output will not contain 7 on the column 1 as they are appended to the previous record. I can write a cobol program, but I was thinking it should be possible using sort. Any suggestion is appreciated! Thanks - Srini
1xxxxxxxxxxxxxxyuuiou
2 utuyuyu uiyuiyui
3ytuyiuiuiuiui
4yuyiyuyuyuyiiuiu
5asdfghjk
6Abcdefpghijkl
7Par stubs
6xxxxxxxxxxx
6qqqqqqqqqq
6tttttttttt
7$$$$$$$$$
Srini1808
 
Posts: 8
Joined: Thu Sep 25, 2014 11:05 am
Has thanked: 2 times
Been thanked: 0 time

Re: Need help with sort

Postby BillyBoyo » Thu Sep 25, 2014 11:46 am

Can there be multiple type 7's per type 6?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Need help with sort

Postby Srini1808 » Thu Sep 25, 2014 12:06 pm

Thanks for quick response, no, there will be only one 7 followed by 6, but there may be type 6 with no 7 at all
Srini1808
 
Posts: 8
Joined: Thu Sep 25, 2014 11:05 am
Has thanked: 2 times
Been thanked: 0 time

Re: Need help with sort

Postby BillyBoyo » Thu Sep 25, 2014 2:09 pm

Are the records variable-length?

I think the easiest way will be with JOINKEYS, specifying the same input DSN for both JOINKEYS statements. In JNFnCNTL you add a sequence number temporarily, starting from 1 (default) in JNF1CNTL and from 0 in JNF2CNTL. Use the two sequence numbers as the key for the JOINKEYS. This will get you records "matched" with their following record.

The details depend on whether you have F or V records.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Need help with sort

Postby Srini1808 » Thu Sep 25, 2014 6:48 pm

Thanks for the reply! The records are FB. But I am still not sure about the solution! I want only type 6 records to contain record 7 appended to the end, all other type of records must be copied one to one. So, if I had 100 records in the input file of record size 94 and if there are 5 records that belong to to type '7', the output file will have 95 records of record size 188, and few type 6 records will have some data from type 7 records which were moved from the next record. All other types like type 1 thru 5, type 8 and 9 ( as well as those type 6 records which don't have a type 7 records following them) are just copied from input file to position 1-94' with spaces in 95-188
Srini1808
 
Posts: 8
Joined: Thu Sep 25, 2014 11:05 am
Has thanked: 2 times
Been thanked: 0 time

Re: Need help with sort

Postby BillyBoyo » Thu Sep 25, 2014 7:21 pm

Try this. You need a DD name for INA and another for INB, and you specify the same DSN for both.

//SYSIN    DD *                                   
  JOINKEYS FILES=INA,FIELDS=(95,5,A),SORTED,NOSEQCK
  JOINKEYS FILES=INB,FIELDS=(95,5,A),SORTED,NOSEQCK
  REFORMAT FIELDS=(F1:1,94,F2:100,94)               
  JOIN UNPAIRED,F1                                 
  SORT FIELDS=COPY               
//JNF1CNTL DD *                                   
  OPTION COPY                                     
  INREC OVERLAY=(95:SEQNUM,5,ZD)                   
//JNF2CNTL DD *                                   
  OPTION COPY                                     
  INREC OVERLAY=(95:SEQNUM,5,ZD,START=0)


If you look at the output (subject to any typos, this is untested) then on the "left" of each record you will see the "current" record, and on the "right" you will see the "next" record.

You then just need INREC IFTHEN=(WHEN=(logical expression) to OVERLAY 95:88X for those (most) occasions that you do not want to see the data on the right.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Need help with sort

Postby Srini1808 » Fri Sep 26, 2014 12:38 am

Thank you very much Billy,
It seems to be stuck with an error message WER230A reformat field outside the range
Srini1808
 
Posts: 8
Joined: Thu Sep 25, 2014 11:05 am
Has thanked: 2 times
Been thanked: 0 time

Re: Need help with sort

Postby BillyBoyo » Fri Sep 26, 2014 2:19 am

Can you paste the full sysout from the failed step please?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Need help with sort

Postby Srini1808 » Fri Sep 26, 2014 2:47 am

Thank you very much Billy!
REFORMAT FIELDS=(F1:1,94,F2:100,94) Should have been REFORMAT FIELDS=(F1:1,94,F2:1,94). And it worked fine. Later I put another sort step to initialize col 95 onwards for all records that died not have 7 in position 95 and only extracted the ones that has values in poisition 1 that is not a 7 and worked perfectly!
Once agin, thank you very much!
Srini
Srini1808
 
Posts: 8
Joined: Thu Sep 25, 2014 11:05 am
Has thanked: 2 times
Been thanked: 0 time

Re: Need help with sort

Postby BillyBoyo » Fri Sep 26, 2014 3:31 am

No problem. Good work.

You shouldn't need another sort step to do the final part. A JOINKYES consists of two Sub-Tasks, and the Main Task. The Main Task is exactly like any normal SORT, it just takes as its input the joined REFORMAT records, So you can put the code from your extra step immediately after your REFORMAT statement and be good-to-go in one step.

These users thanked the author BillyBoyo for the post:
Srini1808 (Fri Sep 26, 2014 8:43 am)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Next

Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post