IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search Log in to check your private messages Log in
 

modifying set of records and writing into a single file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dsivapradeep

New User


Joined: 06 Jul 2012
Posts: 43
Location: INDIA

PostPosted: Thu Jan 09, 2014 12:39 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

PostPosted: Thu Jan 09, 2014 1:10 pm
Reply with quote

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
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1566
Location: Andromeda Galaxy

PostPosted: Thu Jan 09, 2014 2:44 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

PostPosted: Thu Jan 09, 2014 3:30 pm
Reply with quote

Yes, good point.
Back to top
View user's profile Send private message
dsivapradeep

New User


Joined: 06 Jul 2012
Posts: 43
Location: INDIA

PostPosted: Thu Jan 09, 2014 3:37 pm
Reply with quote

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
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Fri Jan 10, 2014 8:23 am
Reply with quote

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
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA


OUTPUT:
Code:

123AAAAAAAAAAAAAAAAAAAAA
123AAAAAAAAAAAAAAAAAAAAA
123AAAAAAAAAAAAAAAAAAAAA
123AAAAAAAAAAAAAAAAAAAAA
123AAAAAAAAAAAAAAAAAAAAA
124AAAAAAAAAAAAAAAAAAAAA
124AAAAAAAAAAAAAAAAAAAAA
124AAAAAAAAAAAAAAAAAAAAA
124AAAAAAAAAAAAAAAAAAAAA
124AAAAAAAAAAAAAAAAAAAAA
125AAAAAAAAAAAAAAAAAAAAA
125AAAAAAAAAAAAAAAAAAAAA
125AAAAAAAAAAAAAAAAAAAAA
125AAAAAAAAAAAAAAAAAAAAA
125AAAAAAAAAAAAAAAAAAAAA
126AAAAAAAAAAAAAAAAAAAAA
126AAAAAAAAAAAAAAAAAAAAA
126AAAAAAAAAAAAAAAAAAAAA
126AAAAAAAAAAAAAAAAAAAAA
126AAAAAAAAAAAAAAAAAAAAA
126AAAAAAAAAAAAAAAAAAAAA
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 

Search our Forum:

Similar Topics
Topic Forum Replies
No new posts FILE STATUS - 39 ON VARIABLE LENGTH V... COBOL Programming 1
No new posts Inserting records into the empty segm... IMS DB/DC 0
No new posts COBOL VS SORT Utility for file format... COBOL Programming 6
No new posts How to find which file contains my se... DFSORT/ICETOOL 6
No new posts Need to split single line into two li... DFSORT/ICETOOL 7

Back to Top