|
View previous topic :: View next topic
|
| Author |
Message |
balaji81_k
Active User
Joined: 29 Jun 2005 Posts: 155
|
|
|
|
Hi ,
I have a requirement to write missing records based on the sequence number that is missed in the input file .
Here is my input file
| Code: |
KEY SEQNUM OTHER FIELDS
AAA 01 XXXXXXXXXXX
AAA 05 XXXXXXXXXXX
BBB 10 YYYYYYYYYYY
BBB 11 YYYYYYYYYYY
BBB 15 YYYYYYYYYYY |
In this example there are two keys "AAA" and "BBB" and SEQNUM starts from "01" for Group-1 and "11" for Group-2 .
My final output should be .
| Code: |
KEY SEQNUM OTHER FIELDS
AAA 01 XXXXXXXXXXX
AAA 02 00000000000
AAA 03 00000000000
AAA 04 00000000000
AAA 05 XXXXXXXXXXX
BBB 10 YYYYYYYYYYY
BBB 11 YYYYYYYYYYY
BBB 12 00000000000
BBB 13 00000000000
BBB 14 00000000000
BBB 15 YYYYYYYYYYY |
You can find the missing records with key and seqnum got incremeneted and other-fields filled with zero . Here we need to take care the comparison of key with next record/Group and seqnumshould be incremented accordingly. If it is different key then we need to store the key as well as corresponding seqnum and increment should be happen accordingly. I tried with sample JCL , can any please help me .
| Code: |
//SORT1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
AAA 01 XXXXXXXXXXX
AAA 05 XXXXXXXXXXX
BBB 10 YYYYYYYYYYY
BBB 11 YYYYYYYYYYY
BBB 15 YYYYYYYYYYY
//OUT1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(100,100)),
// DISP=(MOD,PASS)
//OUT2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(100,100)),
// DISP=(MOD,PASS)
//OUT3 DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(OUT1) USING(CTL1)
COPY FROM(OUT1) TO(OUT2) USING(CTL2)
COPY FROM(IN1) TO(OUT2)
SORT FROM(OUT2) TO(OUT3) USING(CTL3)
//CTL1CNTL DD *
OPTION COPY
OUTREC OVERLAY=(12:SEQNUM,2,ZD,RESTART=(1,3))
//CTL2CNTL DD *
OPTION COPY
INCLUDE COND=(5,2,CH,NE,12,2,CH)
OUTREC FIELDS=(1,3,5:12,2,7:C'000')
//CTL3CNTL DD *
SORT FIELDS=(1,3,CH,A,5,2,CH,A)
OUTREC FIELDS=(1,9)
//SYSOUT DD SYSOUT=*
// |
Code'd |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| balaji81_k wrote: |
[...]
You can find the missing records with key and seqnum got incremented and other-fields filled with zero . Here we need to take care the comparison of key with next record/Group and seqnum should be incremented accordingly. If it is different key then we need to store the key as well as corresponding seqnum and increment should be happen accordingly.
[...] |
I'm confused about this.
Are you saying there are records there (and not showing them in your sample data) which just need the correct sequence numbers? This is "supported" in some part by your Control Cards not even attempting to insert any new data.
Or, is your sample data correct, you have no clue how to go about the task, but still feel someone who can do it is unable to do it without instruction, or has to do it your way? |
|
| Back to top |
|
 |
balaji81_k
Active User
Joined: 29 Jun 2005 Posts: 155
|
|
|
|
Hi,
I am still working on it and i have just written a base JCL to achieve the requierement, Yes i need to make some changes in JCL to achieve desired output based on the sample input data which i have put in?.
Can you please help me with JCL to get the desired output which i have given?
Thanks
Balaji K |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You need to "create" records. You can only do that in OUTFIL. You cannot do it a "variable" number of times, so you need code for each number of records that you want to create. The created records need to be correctly sequenced.
Have you considered writing a program to do this? It is not a difficult task for a program. |
|
| Back to top |
|
 |
balaji81_k
Active User
Joined: 29 Jun 2005 Posts: 155
|
|
|
|
Hi ,
From sample input data , Records with KEY "AAA" is missed with Seq numbers "02,03,04" . While writing the output i need to write/insert key "AAA" with missed seqnums and other-fields to be zeros.
I am working on the logic to store key and seqnum and increment the seq num based on the missing records which considered for the Keys "AAA" and "BBB".
Can you please let me know if you are not clear?
Thanks
Balaji K |
|
| Back to top |
|
 |
balaji81_k
Active User
Joined: 29 Jun 2005 Posts: 155
|
|
|
|
Hi ,
Yes it's simple to code in COBOL but is it possible to acheive in SORT/ICETOOL?
Thanks
Balaji K |
|
| Back to top |
|
 |
Akatsukami
Global Moderator

Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
| As Mr. Woodger indicates, it can be done, but would be a complex and tedious task. If this is a purely intellectual challenge, why ask for "JCL" (by which you mean control cards); if not, why the resistance to programming? |
|
| Back to top |
|
 |
balaji81_k
Active User
Joined: 29 Jun 2005 Posts: 155
|
|
|
|
Hi ,
I arrived the results by making code changes in COBOL module , instead of having that code change, i tried to change a Job to have a one more step to arrive at the same results .
Its just a try .
Thanks for your comments.
Thanks
Balaji K |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Yes, I understand what you want.
I'm saying, as has been accurately suggested to you, that because Sort Control Cards operate in a different "way" from a general-purpose programming language, there is "extra effort" (both in thinking and in the amount of code) in achieving solutions where the requirement better fits a g-p language.
It is the opposite where the requirement best fits Sort Control Cards. You will be able to do it in a g-p language, but not as "efficiently" in terms of thinking or coding.
(Efficiently in terms of running can be different, as Sort has much faster IO).
What is the maxium possible "range" of the missing numbers? Might you get two, or more, "ranges" of missing numbers per key? |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
1) No - you cannot do it with JCL which only tells the OS which program(s) you wantr to run and what resources are required.
2) You can possibly do it with your sort product if you use the correct sort control cards.
3) In your first post you say you have 2 keys, AAA & BBB, and that the second start with a seq number of 11. What, then is the record with a key of BBB and seq number of 10? |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
balaji81_k,
Assuming you only have 2 digits numbers for the sequence number, the following DFSORT JCL will give you the desired results. I only showed upto 3 missing numbers. However you can expand that upto your max number provided you have storage availability. I assumed your input has RECFM=FB and LRECL=40
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
AAA 01 XXXXXXXXXXX
AAA 05 XXXXXXXXXXX
BBB 10 YYYYYYYYYYY
BBB 11 YYYYYYYYYYY
BBB 15 YYYYYYYYYYY
CCC 21 ZZZZZZZZZZZ
CCC 23 ZZZZZZZZZZZ
DDD 25 ZZZZZZZZZZZ
DDD 28 ZZZZZZZZZZZ
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,3),PUSH=(41:12,2)),
IFTHEN=(WHEN=INIT,
OVERLAY=(44:SEQNUM,2,ZD,START=0,RESTART=(1,3),
44:41,2,ZD,ADD,44,2,ZD,EDIT=(TT))),
IFTHEN=(WHEN=(12,2,CH,NE,44,2,CH),
OVERLAY=(47:12,2,ZD,SUB,44,2,ZD,EDIT=(TT)))
OUTFIL IFOUTLEN=40,
IFTHEN=(WHEN=(47,2,ZD,EQ,01),
BUILD=(1,11,44,2,26:10C'0',/,1,40)),
IFTHEN=(WHEN=(47,2,ZD,EQ,02),
BUILD=(1,11,44,2,26:10C'0',/,
1,11,44,2,ZD,ADD,+1,EDIT=(TT),26:10C'0',/,1,40)),
IFTHEN=(WHEN=(47,2,ZD,EQ,03),
BUILD=(1,11,44,2,26:10C'0',/,
1,11,44,2,ZD,ADD,+1,EDIT=(TT),26:10C'0',/,
1,11,44,2,ZD,ADD,+2,EDIT=(TT),26:10C'0',/,1,40))
//* |
The output from the above is
| Code: |
AAA 01 XXXXXXXXXXX
AAA 02 0000000000
AAA 03 0000000000
AAA 04 0000000000
AAA 05 XXXXXXXXXXX
BBB 10 YYYYYYYYYYY
BBB 11 YYYYYYYYYYY
BBB 12 0000000000
BBB 13 0000000000
BBB 14 0000000000
BBB 15 YYYYYYYYYYY
CCC 21 ZZZZZZZZZZZ
CCC 22 0000000000
CCC 23 ZZZZZZZZZZZ
DDD 25 ZZZZZZZZZZZ
DDD 26 0000000000
DDD 27 0000000000
DDD 28 ZZZZZZZZZZZ
|
|
|
| Back to top |
|
 |
balaji81_k
Active User
Joined: 29 Jun 2005 Posts: 155
|
|
|
|
Thanks Skolusu
Learned so many things from your sort , thanks a lot for ur help !!.
If the input is of hundred's records it is fine but in production we have million of recs to process , so we need to increment the build logic accordingly . So we incorporate logic changes in COBOL Module.
Thanks a lot !!!
Thanks
Balaji K |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| balaji81_k wrote: |
Thanks Skolusu
Learned so many things from your sort , thanks a lot for ur help !!.
If the input is of hundred's records it is fine but in production we have million of recs to process , so we need to increment the build logic accordingly . So we incorporate logic changes in COBOL Module.
Thanks a lot !!!
Thanks
Balaji K |
Well there are couple of other ways to generate the missing records, however would need an additional pass. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|