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

Concatenation based on the header data


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

New User


Joined: 23 Mar 2007
Posts: 35
Location: pune

PostPosted: Wed Apr 07, 2010 5:16 am
Reply with quote

Hi,

I have a requirement where i need to concatenate data from 2 or more input files and then have a single header record and have maximum date present in the header.
Important points
1. The header is present in the first record of the file
2. The date field is present in posn 23 and has the date format as YYYY-MM-DD
3. The total number of records within the file including the header record is present in the location 40 and is 5 bytes long
4. The record length of both the input files are 50 and FB


Code:
Input file 1
----+----1----+----2----+----3----+----4----+----5
ROSWELL       NM2030512010-02-04       000013     
11111111111111  101120                             
11111111111111  102000                             
11111111111111  104000                             
11111111111111  201090                             
22222222222222  301042                             
22222222222222  101310                             
22222222222222  102000                             
22222222222222  104000                             
22222222222222  102000                             
22222222222222  104000                             
22222222222222  201089                             
22222222222222  301089           

Input File 2
----+----1----+----2----+----3----+----4----+----5
ROSWELL       NM2030512010-02-02       000009   
44444444444444  101120                           
44444444444444  102000                           
44444444444444  104000                           
44444444444444  201090                           
33333333333333  301042                           
33333333333333  101310                           
33333333333333  102000                           
33333333333333  104000                     


Output file
----+----1----+----2----+----3----+----4----+----5
ROSWELL       NM2030512010-02-04       000021
11111111111111  101120                       
11111111111111  102000                       
11111111111111  104000                       
11111111111111  201090                       
22222222222222  301042                       
22222222222222  101310                       
22222222222222  102000                       
22222222222222  104000                       
22222222222222  102000                       
22222222222222  104000                       
22222222222222  201089                       
22222222222222  301089                       
44444444444444  101120                       
44444444444444  102000                       
44444444444444  104000                       
44444444444444  201090                       
33333333333333  301042                       
33333333333333  101310                       
33333333333333  102000                       
33333333333333  104000                           

Any help would be great
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Apr 07, 2010 10:34 am
Reply with quote

Does "ROSWELL" identifies Header record?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Apr 07, 2010 7:06 pm
Reply with quote

Hello,

No (at least i don't believe so).

Being the first record identifies the header.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Apr 07, 2010 9:43 pm
Reply with quote

ts,

A better question - is there anything in the header record that identifies it (e.g. non-blank in position 15, or non-blank in position 40, or ?)?

Quote:
i need to concatenate data from 2 or more input files


What is the maximum number of input files you would have?

Are you looking for a general solution that does NOT require any changes for different numbers of files? Or can you change the job depending on the number of files?
Back to top
View user's profile Send private message
thunderstorm

New User


Joined: 23 Mar 2007
Posts: 35
Location: pune

PostPosted: Wed Apr 07, 2010 10:42 pm
Reply with quote

Hi Frank,
The header portion till posn 22 is always constant.
ROSWELL NM203051

We can have a maximum of 3 files and that might increase as well.
So , to answer your question i am expecting a general solution that does not require any changes for any number of files.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Apr 07, 2010 11:28 pm
Reply with quote

Ok, first a couple of corrections:

For the output, you show the count as 21, but it should be 22 (13+9) ... right?

You say the count is 5 bytes long, but you show it in 40-45 which is 6 bytes.

Here's a DFSORT/ICETOOL job that will do what you asked for:

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD DSN=...  input file1 (FB/50)
//    DD DSN=...  input file2 (FB/50)
//    ...
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file (FB/50)
//TOOLIN DD *
SORT FROM(CON) TO(T1) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(51:SEQNUM,8,ZD)),
    IFTHEN=(WHEN=(1,7,CH,EQ,C'ROSWELL'),OVERLAY=(51:8C'0'))
  SORT FIELDS=(51,8,ZD,A,23,10,CH,D)
/*
//CTL2CNTL DD *
  OPTION EQUALS
  SORT FIELDS=(51,8,ZD,A)
  SUM FIELDS=(40,6,ZD)
  OUTREC BUILD=(1,50)
/*
Back to top
View user's profile Send private message
thunderstorm

New User


Joined: 23 Mar 2007
Posts: 35
Location: pune

PostPosted: Thu Apr 08, 2010 1:17 am
Reply with quote

Yes Frank , it was a calculation error on my part.
I ran the job but in the count section i am getting
000000002B instead of 0000000022
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Apr 08, 2010 1:30 am
Reply with quote

ts,

You could be using DFSORT with ZDPRINT=NO in effect.

Try changing the OPTION statement in CTL2CNTL to:

Code:

  OPTION EQUALS,ZDPRINT
Back to top
View user's profile Send private message
thunderstorm

New User


Joined: 23 Mar 2007
Posts: 35
Location: pune

PostPosted: Thu Apr 08, 2010 3:32 am
Reply with quote

Thanks frank ..it worked
Back to top
View user's profile Send private message
thunderstorm

New User


Joined: 23 Mar 2007
Posts: 35
Location: pune

PostPosted: Thu Apr 08, 2010 4:52 am
Reply with quote

Frank - I take back my words..The header count should be 21 and not 22 because in the final file i want only 1 header with the correct count.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Apr 08, 2010 6:07 am
Reply with quote

Ok, then use this DFSORT/ICETOOL job:

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD DSN=...  input file1 (FB/50)
//    DD DSN=...  input file2 (FB/50)
//    ...
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file (FB/50)
//TOOLIN DD *
SORT FROM(CON) TO(T1) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(51:SEQNUM,8,ZD,59:8C'0')),
    IFTHEN=(WHEN=(1,7,CH,EQ,C'ROSWELL'),
      OVERLAY=(51:8C'0',59:C'00000001'))
  SORT FIELDS=(51,8,ZD,A,23,10,CH,D)
/*
//CTL2CNTL DD *
  OPTION EQUALS
  SORT FIELDS=(51,8,ZD,A)
  SUM FIELDS=(40,6,ZD,59,8,ZD)
  OUTREC IFOUTLEN=50,
    IFTHEN=(WHEN=(1,7,CH,EQ,C'ROSWELL'),
     OVERLAY=(40:40,6,ZD,SUB,59,8,ZD,ADD,+1,TO=ZD,LENGTH=6))
/*
Back to top
View user's profile Send private message
thunderstorm

New User


Joined: 23 Mar 2007
Posts: 35
Location: pune

PostPosted: Thu Apr 08, 2010 6:50 am
Reply with quote

Thanks Frank..This is perfect
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 Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
No new posts JCL EXEC PARM data in C Java & MQSeries 2
Search our Forums:

Back to Top