Page 1 of 1

can it be done using SORT

PostPosted: Thu Mar 29, 2012 4:10 pm
by nareshv_99
hi all,
i have below req.
I have input file1and input file2. input file1 has paried records means each record (lrec of 160) is divided into two small records (lrec 80, showed with part1 and part2),indicated by 2 and 3 at col# 1 in below example. Key starts at col# 8 of length 4 and Key is present only in the first part of the small record.

e.g: let

file1: FB, LREC=80,
2 qwer 1111 qw (part1)
3 nn1 00 00 (part2)
2 qwer 1112 qw (part1)
3 nn2 00 00 (part2)
2 qwer 1113 qw (part1)
3 nn3 00 00( part2)
2 qwer 1114 qw (part1)
3 nn4 00 00 (part2)

P.S: part1 and part2 are not part of the records. just for sake of understanding that part1 and part2 constitute of one record.

file2: FB, 80
1111
1114

so when join/splice file1 and file2 the output should contain only unparied records of File1.

output file FB, 80 and it should be,
2 qwer 1112 qw
3 nn2 00 00
2 qwer 1113 qw
3 nn3 00 00


the below records should not be in the output as its key matches with file2
2 qwer 1111 qw
3 nn1 00 00
2 qwer 1114 qw
3 nn4 00 00


can it be done in SORT using SPLICE/JOIN ?? Thanks!

Re: can it be done using SORT

PostPosted: Thu Mar 29, 2012 7:00 pm
by BillyBoyo
Almost certainly yes.

However, I for one don't understand about your first file.

Does it consist of "paired" records on an FB/80 dataset?

Or does it consist of records on an FB/160, where the "pairing" is of interest to you but doesn't make any difference to the matching?

Re: can it be done using SORT

PostPosted: Thu Mar 29, 2012 8:07 pm
by nareshv_99
file1is member of a PDS of LREC=80. file1 contains records of length 160 but lrec is defined as of length 80 so we can't store whole record so spiltted into two lines of length 80.
so it consist of paried records on FB/80.

first line contains Key filed, second line is continuation of the first record.

file1: FB, LREC=80,
cols:
-------------------------80
2 qwer 1111 qw (part1 of length 80) --
3 nn1 00 00 (part2 of length 80, cont. of part1) --

same as other records.

my requirement is whenever Key field matches with file2 key filed, output should not include both the records (part1 and part2) of the matched record in the file1.

one more information: from col# 60 spaces are occupied in both parts of records(part1,part2).
my idea was to copy the key filed of part1 at col# 60,61,62,63 in the both parts. i can copy key field into part1 record by using below overlay
inrec overlay=(60:8,4) but i'm not sure how can i copy part1 key into part2 record at col#60.

could you tell me how can I get the required output? Thanks!

Re: can it be done using SORT

PostPosted: Thu Mar 29, 2012 8:28 pm
by BillyBoyo
OK, can you post the ICE201I message from one of your sort steps. This (the letter after the message) will show what level of DFSORT you have.

Since you have pairs of records (presumably reliably so) you can GROUP with RECORDS=2. Another possibility is to have a RESIZE in an ICETOOL step to make one 160-byte record from the input pairs.

Are the records (pairs) on your PDS member in sequence by the key? What sequence do they need to be on the output?

Do you have any "strange" limits on what you can do to implement this? Can you use ICETOOL? Can you use more than one step?

Bear in mind, it would be very good, if you want to write the output back to the original PDS member, to have at least two steps.

Re: can it be done using SORT

PostPosted: Thu Mar 29, 2012 8:49 pm
by skolusu
nareshv_99,

Use the following DFSORT JCL which will you give you the desired results
//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//INA      DD *                                                 
2 QWER 1111 QW (PART1)                                         
3 NN1 00 00 (PART2)                                             
2 QWER 1112 QW (PART1)                                         
3 NN2 00 00 (PART2)                                             
2 QWER 1113 QW (PART1)                                         
3 NN3 00 00( PART2)                                             
2 QWER 1114 QW (PART1)                                         
3 NN4 00 00 (PART2)                                             
//INB      DD *                                                 
1111                                                           
1114                                                           
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                                 
  OPTION COPY                                                   
  JOINKEYS F1=INA,FIELDS=(81,4,A)                               
  JOINKEYS F2=INB,FIELDS=(01,4,A)                               
  JOIN UNPAIRED,F1,ONLY                                         
  INREC BUILD=(1,80)                                           
//JNF1CNTL DD *                                                 
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'2'),PUSH=(81:8,4))
//*

Re: can it be done using SORT

PostPosted: Thu Mar 29, 2012 10:13 pm
by nareshv_99
Kolusu,

I'm out of office now. I can't try it out. But I think above sort will produce below output.
Output:
2 QWER 1112 QW
2 QWER 1113 QW

but I want output should be:
2 qwer 1112 qw
3 nn2 00 00
2 qwer 1113 qw
3 nn3 00 00

correct me if i'm wrong.

BillyBoyo,
I don't have any constrains in terms of number of steps and usage of ICETOOL.

let me explain
I have a production PDS member of LREC = 80. for some reason they are storing 160 line of data in two lines of 80 length.

e.g: consider below data

cols:
-----------------40------------80----------120------------160
2 qwer 1111 qw 3 nn1 00 00

if they want store the above data they can't store it directly.
As LREC is 80 I can't store 160 length of data. data has been splitted into 2 lines of length 80 as shown below,

-----------------40------------80
2 qwer 1111 qw
3 nn1 00 00

layout/Format of the data:
col#1:
2 - represents first part
3 - represents second part
Key filed is present in part1 at col#8 of length 4, all my records ordered by Key in ascending order.

all remaining lines are like the above example. SPACES are occupied from col# 41onwards to col#80 in both parts of the record.

so if

file1: FB, LREC=80,
-----------------40------------80
2 qwer 1111 qw
3 nn1 00 00
2 qwer 1112 qw
3 nn2 00 00
2 qwer 1113 qw
3 nn3 00 00
2 qwer 1114 qw
3 nn4 00 00

file2: FB, 80
1111
1114

output file FB, 80 and it should be,
2 qwer 1112 qw
3 nn2 00 00
2 qwer 1113 qw
3 nn3 00 00

i hope its clear now. Thanks!

Re: can it be done using SORT

PostPosted: Thu Mar 29, 2012 10:30 pm
by skolusu
nareshv_99 wrote:Kolusu,

I'm out of office now. I can't try it out. But I think above sort will produce below output.
Output:
2 QWER 1112 QW
2 QWER 1113 QW

but I want output should be:
2 qwer 1112 qw
3 nn2 00 00
2 qwer 1113 qw
3 nn3 00 00

correct me if i'm wrong.


nareshv_99,

If you had tested and checked out the solution , you would understand how wrong you are. So test it out and let me know if you got the wrong results.

Re: can it be done using SORT

PostPosted: Thu Mar 29, 2012 11:01 pm
by BillyBoyo
You didn't answer about the order of the output data. Is it OK sorted on the Key?

If 41-80 on both of the records which make a pair are blank, then there would be room for the data to live on one record (but no room for exansion on an 80-byte lrecl PDS). You can have a PDS with LRECL 160, or whatever you like.

Unsurprisingly, Kolusu's code is going to work how he intended, not how you think. Even if not at work, the manuals are available on the Web and you could check on GROUP and PUSH and anything else you are not sure of. Kolusu is about 20,000 times better at this than I, so he doesn't need my support on this :-)