|
View previous topic :: View next topic
|
| Author |
Message |
dsivapradeep
New User

Joined: 06 Jul 2012 Posts: 43 Location: INDIA
|
|
|
|
Hi,
I've a file with some hundreds of records which are sorted based on some key fields.
Now, I need to edit a key field in all these records say first 200 records should have the value 123. Next 100 records should have 124. next 300 records to have value 125 and so on for 5 times in overall. And all these modified records have to be in the same output file.
As of now, i'm trying OUTFIL & SKIPREC,STOPAFT combination and writing into 5 different files and finally merging into a single file.
Is it possible to avoid this OUTFIL option/multiple files and do a SORT Operation directly to move into a single output file ??? |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Extend each record to include a sequence number (varaible-length or fixed-length records dictate where to do the extension).
Use IFTHEN=(WHEN=INIT to set the SEQNUM with a RESTART on itself for the number of records you want in a group of records.
Use IFTHEN=(WHEN=GROUP with BEGIN for sequence zero and RECORDS= for the number in your group and PUSH an ID into where you want the data to be the same for each group.
Use IFTHEN=(WHEN=INIT to add 122 to your entire field which needs to change.
Please post your code once you have it working.
To develop the solution, add one piece at a time to a basic COPY operation. Once you are clear about what that does and that it is working, move on to the next. |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Bill,
I havent tried it ..
But cant we have the option START and have the SEQNUM start at 123.So there by we can avoid the below
| Quote: |
| Use IFTHEN=(WHEN=INIT to add 122 to your entire field which needs to change. |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Yes, good point. |
|
| Back to top |
|
 |
dsivapradeep
New User

Joined: 06 Jul 2012 Posts: 43 Location: INDIA
|
|
|
|
Thanks Bill,
I followed little different procedure for the 3rd IFTHEN.
Below is sort card. Input file is 80 bytes length.
| Code: |
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INT,
BUILD=(1:1,80,81:SEQNUM,4,ZD,START=1,INCR=1,RESTART=(81,4))),
IFTHEN=(WHEN=GROUP,BEGIN=(81,4,ZD,EQ,0001),
END=(81,4,ZD,EQ,0003),PUSH=(90:ID=1)),
IFTHEN=(WHEN=GROUP,BEGIN=(81,4,ZD,EQ,0004),
END=(81,4,ZD,EQ,0005),PUSH=(90:ID=2)),
IFTHEN=(WHEN=GROUP,BEGIN=(81,4,ZD,EQ,0006),
END=(81,4,ZD,EQ,0007),PUSH=(90:ID=3)),
IFTHEN=(WHEN=(90,1,CH,EQ,C'1'),BUILD=(C'123',4:4,77),
IFTHEN=(WHEN=(90,1,CH,EQ,C'01'),BUILD=(C'124',4:4,77),
IFTHEN=(WHEN=(90,1,CH,EQ,C'001'),BUILD=(C'125',4:4,77)
/*
|
Input file looks like this.
| Code: |
10001 A*****
12001 A*****
11001 A*****
14001 A*****
15001 A*****
1F001 A*****
1H001 A*****
|
Expected & Obtained output is :
| Code: |
123***
123***
123***
124***
124***
125***
125***
|
This is dummy data input file.. I think I can use this data card for my actual file also. |
|
| Back to top |
|
 |
sureshpathi10
Active User

Joined: 03 May 2010 Posts: 158 Location: Kuala Lumpur
|
|
|
|
You may try this as well.
| Code: |
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,BUILD=(1:1,80,81:SEQNUM,4,ZD)),
IFTHEN=(WHEN=(81,4,ZD,LE,5),BUILD=(C'123',4:4,77)),
IFTHEN=(WHEN=(81,4,ZD,GT,5,AND,81,4,ZD,LE,10),
BUILD=(C'124',4:4,77)),
IFTHEN=(WHEN=(81,4,ZD,GT,10,AND,81,4,ZD,LE,15),
BUILD=(C'125',4:4,77)),
IFTHEN=(WHEN=(81,4,ZD,GT,15),BUILD=(C'126',4:4,77))
SORT FIELDS=COPY
|
INPUT:
| Code: |
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA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