|
View previous topic :: View next topic
|
| Author |
Message |
mohitsaini Warnings : 1 New User
Joined: 15 May 2006 Posts: 92
|
|
|
|
Hi,
Actually, my requirement is to put sequence number at a particular position based on record type. It is a variable lenght file.
TYPE --- Position for Sequnce number (8)
--------- -----------------------------
1644 --- 107
1240 --- 689
1540 --- 151
1740 --- 179
I tried doing it (only for 2 rec types) and below is my attempt:
| Code: |
//SYSIN DD *
RECORD TYPE=V
OPTION COPY
INREC IFTHEN=(WHEN=(56,4,CH,EQ,C'1240'),OVERLAY=(693:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(56,4,CH,EQ,C'1644'),OVERLAY=(111:SEQNUM,8,ZD))
// |
But the issue with it is that the sequence number resets for next record type.
For eg. It is coming like like
1240 - 000001
1240 - 000002
1240 - 000003
1644 - xxxxxxx000001
1644 - xxxxxxx000002
1644 - xxxxxxx000003
1644 - xxxxxxx000004
But I require something like:
1240 - 000001
1240 - 000002
1240 - 000003
1644 - xxxxxxx000004
1644 - xxxxxxx000005
1644 - xxxxxxx000006
1644 - xxxxxxx000007
Any kind of help will be really appreciated.
Regards,
Mohit |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Every time you use SEQNUM it is a different one.
So, if you have SEQNUM on WHEN=INIT, inserted at the beginning of your records (because your records are variable) (unless there is an "unused" portion of the fixed part of the record you could re-use temporarily) and then with the WHEN=(condition) copy the added field to where you want it for that particular record-type.
After each record is processed, you have to "clean up" the now surplus SEQNUM, with BUILD, |
|
| Back to top |
|
 |
nagaraj_bez
New User
.jpg)
Joined: 09 Jun 2005 Posts: 10
|
|
|
|
Hi Mohitsaini,
Try the following steps.
Step-1: Number all records
Step-2: using overlay as u have tried, write the output record based on conditions.
Example:
input :
1234561240
1234561644
expected output :
add seq number in 7th position( before 1240) for 1240, 11th position(after 1644) for 1644 condition
123456000000011240
123456164400000002
Step1 o/p : (added seq number at starting 1-8 position)
000000011234561240
000000021234561644
Step2 o/p: based on condition
123456000000011240
123456164400000002 |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
mohitsaini,
Use the following DFSORT JCL which will give you the desired results.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=Your Input VB File,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,8X,5)),
IFTHEN=(WHEN=(64,4,SS,EQ,C'1240,1540,1644,1740'),
OVERLAY=(5:SEQNUM,8,ZD),HIT=NEXT),
IFTHEN=(WHEN=(64,4,CH,EQ,C'1240'),OVERLAY=(701:5,8)),
IFTHEN=(WHEN=(64,4,CH,EQ,C'1540'),OVERLAY=(163:5,8)),
IFTHEN=(WHEN=(64,4,CH,EQ,C'1644'),OVERLAY=(119:5,8)),
IFTHEN=(WHEN=(64,4,CH,EQ,C'1740'),OVERLAY=(191:5,8))
OUTREC BUILD=(1,4,13)
//* |
|
|
| Back to top |
|
 |
mohitsaini Warnings : 1 New User
Joined: 15 May 2006 Posts: 92
|
|
|
|
| Thanks it is working . .. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|