Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Adding records and updating a field on each added record

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
saurabhgaikwad

New User


Joined: 29 Dec 2009
Posts: 4
Location: bangalore

PostPosted: Mon Feb 15, 2010 6:19 pm    Post subject: Adding records and updating a field on each added record
Reply with quote

Hi,
I have two flat files A and B both are similiar in all respect.
I need to add the records from the file A to B such that:
1. I have only one header and trailer on file B
2. A field of two character at the column 34 gets updated as shown below
3. Record count at trailer gets updated at column 35 as shown below

For Example:

Code:
File 1
00000000000000000000000000000GS  SAU00002010021100
00011111111111111111111111111SA   01
00011111111111111111111111111AA   01
00011111111111111111111111111SZ   01
00011111111111111111111111111SA   02
00011111111111111111111111111AA   02
00011111111111111111111111111SZ   02
99999999999999999999999999999GE   A02

File 2
00000000000000000000000000000GS  SAU00002010021100
00011111111111111111111111111SA   01
00011111111111111111111111111AA   01
00011111111111111111111111111SZ   01
00011111111111111111111111111SA   02
00011111111111111111111111111AA   02
00011111111111111111111111111SZ   02
99999999999999999999999999999GE   A02

O/P file - File 2

00000000000000000000000000000GS  SAU00002010021100
00011111111111111111111111111SA   01
00011111111111111111111111111AA   01
00011111111111111111111111111SZ   01
00011111111111111111111111111SA   02
00011111111111111111111111111AA   02
00011111111111111111111111111SZ   02
00011111111111111111111111111SA   03
00011111111111111111111111111AA   03
00011111111111111111111111111SZ   03
00011111111111111111111111111SA   04
00011111111111111111111111111AA   04
00011111111111111111111111111SZ   04
99999999999999999999999999999GE   A04

Is this possible using DFSORT/ICETOOL.. please suggest.
Back to top
View user's profile Send private message

Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Feb 15, 2010 11:02 pm    Post subject:
Reply with quote

saurabhgaikwad,

You need to increment the counter in file 2 with the last value from file 1 at position 34? Is it just 2 bytes of zd number? What happens if the counter exceeds 99?
Back to top
View user's profile Send private message
saurabhgaikwad

New User


Joined: 29 Dec 2009
Posts: 4
Location: bangalore

PostPosted: Tue Feb 16, 2010 12:53 am    Post subject:
Reply with quote

yes i need to increment the counter in file 2 with the last value from file 1 at position 34.

in the original file this is of 10 bytes so size will not be a problem.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Feb 16, 2010 5:45 am    Post subject:
Reply with quote

saurabhgaikwad wrote:
yes i need to increment the counter in file 2 with the last value from file 1 at position 34.

in the original file this is of 10 bytes so size will not be a problem.


You want a solution with 2 bytes where as in reality it is a 10 byte field? What about the format? Does the 2 vs 10 bytes hold good for the trailer records also? Please provide detailed information on what you're trying to accomplish. Do not make people guess what you mean. This will give you a much better chance of getting a good answer to your question.
Back to top
View user's profile Send private message
saurabhgaikwad

New User


Joined: 29 Dec 2009
Posts: 4
Location: bangalore

PostPosted: Tue Feb 16, 2010 2:03 pm    Post subject:
Reply with quote

Hi Skolusu,

Yes, 2 vs 10 bytes hold good for the trailer records also. I should not have put it as 2 bytes. Rest of the information is same.

Details:
Both files have same header and trailer. Each Detail record in both the file have SA at the 30th column (start of record) and SZ at the 30th column (end of record). So all the records between SA segment and SZ segment makes one complete record
Field at the 34th column which is of 10 bytes keeps the count of the SA/SZ segments. This field should be incremented each time another SA is encountered that is whenever we get new record.
Value of this field at the 34th column for the last record should be the value of counter in the trailer record at the 35th column.

When I add the records from the File A to B ( both files were shown above ) , I get the below result

00000000000000000000000000000GS SAU00002010021100
00011111111111111111111111111SA 00000001
00011111111111111111111111111AA 00000001
00011111111111111111111111111SZ 00000001
00011111111111111111111111111SA 00000002
00011111111111111111111111111AA 00000002
00011111111111111111111111111SZ 00000002
00011111111111111111111111111SA 00000001
00011111111111111111111111111AA 00000001
00011111111111111111111111111SZ 00000001
00011111111111111111111111111SA 00000002
00011111111111111111111111111AA 00000002
00011111111111111111111111111SZ 00000002
99999999999999999999999999999GE A00000002

Whereas i should have the below result

00000000000000000000000000000GS SAU00002010021100
00011111111111111111111111111SA 00000001
00011111111111111111111111111AA 00000001
00011111111111111111111111111SZ 00000001
00011111111111111111111111111SA 00000002
00011111111111111111111111111AA 00000002
00011111111111111111111111111SZ 00000002
00011111111111111111111111111SA 00000003
00011111111111111111111111111AA 00000003
00011111111111111111111111111SZ 00000003
00011111111111111111111111111SA 00000004
00011111111111111111111111111AA 00000004
00011111111111111111111111111SZ 00000004
99999999999999999999999999999GE A00000004


So Yes, I need to increment the record counter from the last value in file B
I hope this will help !!
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Feb 17, 2010 1:54 am    Post subject: Reply to: Adding records and updating a field on each added
Reply with quote

saurabhgaikwad,

The following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                     
00000000000000000000000000000GS  SAU00002010021100                   
00011111111111111111111111111SA  0000000001                         
00011111111111111111111111111AA  0000000001                         
00011111111111111111111111111SZ  0000000001                         
00011111111111111111111111111SA  0000000002                         
00011111111111111111111111111AA  0000000002                         
00011111111111111111111111111SZ  0000000002                         
99999999999999999999999999999GE  A0000000002                         
//         DD *                                                     
00000000000000000000000000000GS  SAU00002010021100                   
00011111111111111111111111111SA  0000000001                         
00011111111111111111111111111AA  0000000001                         
00011111111111111111111111111SZ  0000000001                         
00011111111111111111111111111SA  0000000002                         
00011111111111111111111111111AA  0000000002                         
00011111111111111111111111111SZ  0000000002                         
99999999999999999999999999999GE  A0000000002                         
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                   
  INREC IFTHEN(WHEN=GROUP,BEGIN=(34,3,CH,EQ,C'SAU'),PUSH=(81:ID=1)),
  IFTHEN(WHEN=GROUP,BEGIN=(81,1,ZD,EQ,1,AND,30,2,CH,EQ,C'SZ'),       
         PUSH=(82:34,10)),                                           
  IFTHEN(WHEN=GROUP,BEGIN=(81,1,ZD,EQ,1,AND,1,3,CH,EQ,C'999'),       
         PUSH=(92:35,10))                                           
                                                                     
  OUTFIL IFOUTLEN=80,                                               
  OMIT=(81,1,ZD,EQ,1,AND,1,3,CH,EQ,C'999',OR,                       
        81,1,ZD,EQ,2,AND,34,3,CH,EQ,C'SAU'),                         
  IFTHEN(WHEN=(81,1,ZD,EQ,2,AND,1,3,CH,EQ,C'999'),                   
      OVERLAY=(35:92,10,ZD,ADD,35,10,ZD,M11,LENGTH=10)),             
  IFTHEN(WHEN=(81,1,ZD,EQ,2,AND,1,3,CH,NE,C'999'),                   
      OVERLAY=(34:34,10,ZD,ADD,82,10,ZD,M11,LENGTH=10))             
//*
Back to top
View user's profile Send private message
saurabhgaikwad

New User


Joined: 29 Dec 2009
Posts: 4
Location: bangalore

PostPosted: Wed Feb 17, 2010 2:07 am    Post subject:
Reply with quote

Thank You Very Much .. I will try this out and let you know ..
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Record Not found in AlX but record re... mukun264 COBOL Programming 5 Fri Mar 24, 2017 9:28 am
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts Updating a VSAM file with DISP=OLD sheersh JCL & VSAM 8 Tue Mar 14, 2017 6:14 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us