IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Adding records and updating a field on each added record


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
Search our Forums:

Back to Top