|
View previous topic :: View next topic
|
| Author |
Message |
amit_tater
New User
Joined: 22 Dec 2006 Posts: 9 Location: Indore
|
|
|
|
I am having a file which is having multiple records for a key. I have to build a record by taking some values from multiple rows and make a single record for a key. I tried with splice but only getting 50% correct output. The details of requirement are as follows:
For Example, the input file looks like
| Code: |
2012043001X00201111101AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111102AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111104AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111104AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111105AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111189AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111189AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111189AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111190AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111190AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111190AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH |
Here the key is from 9-20 bytes i.e. 001X002011111, the sequence is present in 21-22 bytes (i.e. for above example it is 01,02,04,05,89,90)
In Output I have to make a single record for a key with following details
From 01 sequence take bytes 24-27, 30-35, 50,53
From 02 sequence take bytes 25-28,40-43,45-48
From each 89 sequence take bytes 30-33,45-50,60-62
From each 90 sequence take byes 42-45, 47-50, 52-55
I don’t need any details from 04 and 05 sequence. Kindly suggest. Its urgent. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Are those "sequences" always present for the key? |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
then a forum is not the best place to ask for help !
we reply on ..
OUR OWN TIME,
FREE OF CHARGE
there is no commitment to reply,
and You should not have any expectations for an answer
claiming urgency is the best way not to get any! |
|
| Back to top |
|
 |
amit_tater
New User
Joined: 22 Dec 2006 Posts: 9 Location: Indore
|
|
|
|
| Quote: |
| Are those "sequences" always present for the key? |
Yes. those are always present and they can increase or decrease further. |
|
| Back to top |
|
 |
dbzTHEdinosauer
Global Moderator

Joined: 20 Oct 2006 Posts: 6965 Location: porcelain throne
|
|
|
|
| Quote: |
| they can increase or decrease further |
not quite sure what you mean. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You have duplicates of the "sequence" in your data.
You'll have to fully explain what you want to do, including how the duplicates should be processed, and show an expected output.
Also, RECFM and LRECL. |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
amit_tater,
1) Please provide expected output for your sample input data.
2) If you have multiple records for 01,02,89,90, Is it safe to assume that the key fields you want in the output will have the same values for all the dups? For example, is it possible to have different values at 24-27, 30-35, 50,53 positions for the two 01 sequence records?
3) Provide Input RECFM/LRECL and Output RECFM/LRECL.
Thanks, |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| Quote: |
From each 89 sequence take bytes 30-33,45-50,60-62
From each 90 sequence take byes 42-45, 47-50, 52-55 |
Are there always three 89 records? Are there always three 90 records?
Or can the number of 89 and 90 records change from run to run? If so, what is the minimum and maximum number for each?
| Quote: |
| Kindly suggest. Its urgent. |
If you want help quickly, then you need to do a much better job of describing what it is you want to do exactly with all cases covered.
Show an example of the records in your input file (relevant fields only) for all situations you need to handle and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input file. If the input file can have duplicates within it, show that in your example. |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Assuming the data you need as output
| Code: |
//SRTJK EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
2012043001X00201111101AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111102AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111104AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111104AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111105AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111189AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111189AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111189AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111190AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111190AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111190AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
//SYSOUT DD SYSOUT=*
//T7 DD SYSOUT=*
//T1 DD DSN=&&T1,SPACE=(TRK,(5,5)),
// DISP=(MOD,PASS)
//T2 DD DSN=&&T2,SPACE=(TRK,(5,5)),
// DISP=(MOD,PASS)
//T3 DD DSN=&&T3,SPACE=(TRK,(5,5)),
// DISP=(MOD,PASS)
//T4 DD DSN=&&T4,SPACE=(TRK,(5,5)),
// DISP=(MOD,PASS)
//T5 DD DSN=&&T5,SPACE=(TRK,(5,5)),
// DISP=(MOD,PASS)
//T6 DD DSN=&&T6,SPACE=(TRK,(5,5)),
// DISP=(MOD,PASS)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN1) TO(T2) USING(CTL2)
COPY FROM(T2) TO(T3) USING(CTL3)
SPLICE FROM(T3) TO(T4) ON(8,13,CH) WITHALL -
WITH(37,12) WITH(49,12)-
WITH(61,12)
SPLICE FROM(T4) TO(T5) ON(8,13,CH) WITHALL -
WITH(49,12)-
WITH(61,12)
SPLICE FROM(T5) TO(T6) ON(8,13,CH) -
WITH(61,12)
COPY FROM(T6) TO(T7)
COPY FROM(T1) TO(T7)
//*
//CTL1CNTL DD *
INCLUDE COND=(21,2,CH,EQ,C'04',OR,21,2,CH,EQ,C'05')
//CTL2CNTL DD *
INCLUDE COND=(21,2,CH,NE,C'04',AND,21,2,CH,NE,C'05')
//CTL3CNTL DD *
INREC IFTHEN=(WHEN=(21,2,CH,EQ,C'01'),
BUILD=(1:1,20,C'00',23:24,4,27:30,6,33:50,4)),
IFTHEN=(WHEN=(21,2,CH,EQ,C'02'),
BUILD=(1:1,20,37:25,4,41:40,4,45:45,4)),
IFTHEN=(WHEN=(21,2,CH,EQ,C'89'),
BUILD=(1:1,20,49:30,4,53:45,6,59:60,2)),
IFTHEN=(WHEN=(21,2,CH,EQ,C'90'),
BUILD=(1:1,20,61:42,4,65:47,4,69:52,4)) |
Output
| Code: |
2012043001X00201111100AAAAABBBCCFFFGAAAADDDEEFFFABBBEFFFFFGGDEEEFFFFFGGG
2012043001X00201111104AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111104AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111105AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH |
Experts defenitly would have a much better solution with lesser steps
As I have modified 01,02,89,90 to one record I have made the record type as 00 |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
I did realise and just tried to crunch the steps and did get the same output
| Code: |
//CTL3CNTL DD *
INREC IFTHEN=(WHEN=(21,2,CH,EQ,C'01'),
BUILD=(1:1,20,C'00',23:24,4,27:30,6,33:50,4)),
IFTHEN=(WHEN=(21,2,CH,EQ,C'02'),
BUILD=(1:1,20,37:25,4,41:40,4,45:45,4)),
IFTHEN=(WHEN=(21,2,CH,EQ,C'89'),
BUILD=(1:1,20,49:30,4,53:45,6,59:60,2)),
IFTHEN=(WHEN=(21,2,CH,EQ,C'90'),
BUILD=(1:1,20,61:42,4,65:47,4,69:52,4))
//TOOLIN DD *
COPY FROM(IN1) TO(T2) USING(CTL1)
SPLICE FROM(T2) TO(T4) ON(8,13,CH) WITHALL -
WITH(37,12) WITH(49,12)-
WITH(61,12)
SPLICE FROM(T4) TO(T5) ON(8,13,CH) WITHALL -
WITH(49,12)-
WITH(61,12)
SPLICE FROM(T5) TO(T6) ON(8,13,CH) -
WITH(61,12)
COPY FROM(T6) TO(T7)
COPY FROM(IN1) TO(T7) USING(CTL2)
//*
//CTL1CNTL DD *
INCLUDE COND=(21,2,CH,NE,C'04',AND,21,2,CH,NE,C'05')
INREC IFTHEN=(WHEN=(21,2,CH,EQ,C'01'),
BUILD=(1:1,20,C'00',23:24,4,27:30,6,33:50,4)),
IFTHEN=(WHEN=(21,2,CH,EQ,C'02'),
BUILD=(1:1,20,37:25,4,41:40,4,45:45,4)),
IFTHEN=(WHEN=(21,2,CH,EQ,C'89'),
BUILD=(1:1,20,49:30,4,53:45,6,59:60,2)),
IFTHEN=(WHEN=(21,2,CH,EQ,C'90'),
BUILD=(1:1,20,61:42,4,65:47,4,69:52,4))
//CTL2CNTL DD *
INCLUDE COND=(21,2,CH,EQ,C'04',OR,21,2,CH,EQ,C'05')
|
| Code: |
2012043001X00201111100AAAAABBBCCFFFGAAAADDDEEFFFABBBEFFFFFGGDEEEFFFFFGGG
2012043001X00201111104AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111104AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH
2012043001X00201111105AAAAAAAABBBCCCCDDDDDEEEFFFFFFFGGGGGGGGGHHHHHHH |
This could be acheived with lesser steps ( which I am trying to work on ) |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Pandora-box, please wait for confirmation from TS of what the requirement is, especially with regard to the duplicates. Despite the "urgency" we may never hear from them again.
When we do hear, something with two or fewer passes of the data would be good... |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Sure Bill!!
Will ensure that going forward  |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| Pandora-Box wrote: |
Sure Bill!!
Will ensure that going forward  |
I truly appreciate your enthusiasm to provide solutions , but keep in mind that you never should exceed more than 3 passes of data to get the desired results. You might as well write a program instead of having sort job involving multiple passes. Remember that you are only seeing a small set of input data and in reality the input may be in millions.
Good Luck |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
I understand Kolusu
Would try to be matured with results going forward |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|