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

How to capture data from 2 files "column wise"


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

Active User


Joined: 03 Feb 2007
Posts: 175
Location: PUNE(INDIA)

PostPosted: Mon Feb 18, 2008 12:28 pm
Reply with quote

Hi Kiran,
Again there is discrepancy between what you are saying now and what you said earlier.
Now you say (2,9) of file1, but as per your sample input file 1, SSN starts at 11th byte.
Also you say (5,9) of file2, but as per your sample input file 1, SSN starts at 11th byte.

Please provide correct information in order forum members to help you.
icon_smile.gif

--Parag
Back to top
View user's profile Send private message
n.kirankumar
Warnings : 1

New User


Joined: 14 Feb 2008
Posts: 16
Location: Hyderabad

PostPosted: Mon Feb 18, 2008 1:25 pm
Reply with quote

Hi Parag,

Sorry for the discrepany.Actually the inputs were just an example.
Later when I looked into my actual inputs, I found SSNs positions differ.

Now I m putting in actual scenario below.Please accept this and provide me JCL for this.

Details are below:

Input file1

Code:
I SSN  NAME DEPT
2 0001 NICK 20
4 0005 LOE  30
3 0002 POLO 87
6 0004 PHIL 76
7 9898 JACK 87


Input file2

Code:
YEAR SSN  NAME MTOT M1 M2 D1 D2
2008 0002 POLO 200  78 76 43 65
2008 0004 PHIL 345  98 80 13 45
2008 9898 JACK 987  78 89 23 24



If (3,4) of file1 = (6,4) of file2 then I would like to append (20,11) of file2 to end of record file1
If (3,4) of file1 is not equal to (6,4) of file2 then I would like to write
only the record of file1 to output file
I want the records to be sorted on SSNs

The output file should look like below

Code:
I SSN  NAME DEPT M1 M2 D1 D2
2 0001 NICK 20   
3 0002 POLO 87   78 76 43 65
6 0004 PHIL 76   98 80 13 45
4 0005 LOE  30   
7 9898 JACK 87   78 89 23 24


I feel sorry for the discrepancies before.
And please let me know if you need any other information.

ParagChouguley wrote:
Hi Kiran,
Again there is discrepancy between what you are saying now and what you said earlier.
Now you say (2,9) of file1, but as per your sample input file 1, SSN starts at 11th byte.
Also you say (5,9) of file2, but as per your sample input file 1, SSN starts at 11th byte.

Please provide correct information in order forum members to help you.
icon_smile.gif

--Parag
Back to top
View user's profile Send private message
ParagChouguley

Active User


Joined: 03 Feb 2007
Posts: 175
Location: PUNE(INDIA)

PostPosted: Mon Feb 18, 2008 2:57 pm
Reply with quote

Now, that's what I needed and here is what you need ! icon_biggrin.gif

Code:

//S1      EXEC PGM=ICETOOL                   
//TOOLMSG DD SYSOUT=*                       
//DFSMSG  DD SYSOUT=*                       
//*                                         
//IN1     DD *                               
I SSN  NAME DEPT                             
2 0001 NICK 20                               
4 0005 LOE  30                               
3 0002 POLO 87                               
6 0004 PHIL 76                               
7 9898 JACK 87                               
/*                                           
//IN2     DD *                                         
YEAR SSN  NAME MTOT M1 M2 D1 D2                       
2008 0002 POLO 200  78 76 43 65                       
2008 0004 PHIL 345  98 80 13 45                       
2008 9898 JACK 987  78 89 23 24                       
/*                                                     
//TEMP1    DD DSN=&&TEMP1,DISP=(MOD,PASS,DELETE),     
//      DSORG=PS,RECFM=FB                             
//TEMP2    DD DSN=&&TEMP2,DISP=(MOD,PASS,DELETE),     
//      DSORG=PS,RECFM=FB                             
//OUT1    DD DSN=OUTPUT-FILE-NAME,                     
//      DSORG=PS,RECFM=FB,                             
//      DISP=(MOD,CATLG,DELETE)                       
//TOOLIN  DD *                                                       
    COPY FROM(IN1) TO(TEMP1) USING(SRT1)                             
    COPY FROM(IN2) TO(TEMP1) USING(SRT2)                             
    SPLICE FROM(TEMP1) TO(TEMP2) ON(6,4,CH) WITH(3,1) WITH(20,12) -   
    KEEPNODUPS USING(SRT3)                                           
    SORT FROM(TEMP2) TO(OUT1) USING(SRT4)                             
/*                                                                   
//SRT1CNTL DD *                                                       
    OPTION COPY                                                       
    OUTREC IFTHEN=(WHEN=(3,3,CH,EQ,C'SSN'),                           
           BUILD=(C'1AA',1,16,12X)),                                 
           IFTHEN=(WHEN=NONE,                                         
           BUILD=(C'2AA',1,16,12X))                                   
/*                                                                   
//SRT2CNTL DD *                                             
    OPTION COPY                                             
    OUTREC FIELDS=(C'2BB',2X,6,4,10X,20,12)                 
/*                                                         
//SRT3CNTL DD *                                             
    OUTREC FIELDS=(1,31)                                   
/*                                                         
//SRT4CNTL DD *                                             
    INCLUDE COND=(2,2,CH,EQ,C'AA',OR,2,2,CH,EQ,C'AB')       
    SORT FIELDS=(1,1,CH,A,6,4,ZD,A)                         
    OUTREC FIELDS=(4,28)                                   
/*                                                         


Output :
Code:

----+----1----+----2----+---
I SSN  NAME DEPT M1 M2 D1 D2
2 0001 NICK 20             
3 0002 POLO 87   78 76 43 65
6 0004 PHIL 76   98 80 13 45
4 0005 LOE  30             
7 9898 JACK 87   78 89 23 24


--Parag
Back to top
View user's profile Send private message
n.kirankumar
Warnings : 1

New User


Joined: 14 Feb 2008
Posts: 16
Location: Hyderabad

PostPosted: Mon Feb 18, 2008 4:30 pm
Reply with quote

Thanks Parag.

I tried executing the JCL provided by you.
I am getting a RC = 12 and i found the below statement in Spool:

Code:
OUTREC STATEMENT FOUND BUT NOT ALLOWED - USE OUTFIL STATEMENT INSTEAD
OPERATION RETURN CODE:  12                                   


I tried executing the jcl by replacing the OUTREC with OUTFIL.

It's throwing a RC=16 with below statement in spool:

Code:
    OUTFIL FIELDS=(1,31)       
           $                   
INVALID OUTFIL STATEMENT OPERAND


Please help me with this.
Back to top
View user's profile Send private message
ParagChouguley

Active User


Joined: 03 Feb 2007
Posts: 175
Location: PUNE(INDIA)

PostPosted: Mon Feb 18, 2008 4:56 pm
Reply with quote

Kiran,
I guess FIELDS doesn't work with OUTFIL. Instead use OUTFIL BUILD=

Now here comes the role of Frank, as I too am unaware about internal details of DFSORT/ICETOOL.

Let us wait for Frank's reply !

--Parag
Back to top
View user's profile Send private message
n.kirankumar
Warnings : 1

New User


Joined: 14 Feb 2008
Posts: 16
Location: Hyderabad

PostPosted: Mon Feb 18, 2008 5:00 pm
Reply with quote

I have a question.

Can you please tell me how the below sort card SRT1CNTL works.

Code:
SRT1CNTL DD *                                                       
    OPTION COPY                                                       
    OUTREC IFTHEN=(WHEN=(3,3,CH,EQ,C'SSN'), ----->If I m not wrong, it should be (WHEN=(3,4,CH,EQ,C'SSN')---and please tell me how it works                         
           BUILD=(C'1AA',1,16,12X)),                                 
           IFTHEN=(WHEN=NONE,                                         
           BUILD=(C'2AA',1,16,12X))
Back to top
View user's profile Send private message
n.kirankumar
Warnings : 1

New User


Joined: 14 Feb 2008
Posts: 16
Location: Hyderabad

PostPosted: Mon Feb 18, 2008 6:37 pm
Reply with quote

Hi Frank,

Could you please help me with this.


ParagChouguley wrote:
Kiran,
I guess FIELDS doesn't work with OUTFIL. Instead use OUTFIL BUILD=

Now here comes the role of Frank, as I too am unaware about internal details of DFSORT/ICETOOL.

Let us wait for Frank's reply !

--Parag
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: Mon Feb 18, 2008 9:50 pm
Reply with quote

Parag,

You cannot use the OUTREC statement with SPLICE - you need to use the OUTFIL statement. You used the OUTREC statement in your first example and I corrected it. In hindsight, I suppose it would have better if I'd deleted your post and posted the correct solution myself since you've posted an incorrect DFSORT job again. Unless you're using an old version of DFSORT, you would have gotten an error message when you used the OUTREC statement. So I suspect you're using Syncsort, not DFSORT. Is that true? I don't know if Syncsort actually allows the OUTREC statement or just doesn't flag it as an error, but DFSORT does flag it as an error. If you're using Syncsort, I wish you wouldn't post in the DFSORT Forum as you're just confusing people and making more work for me.

Quote:
Now here comes the role of Frank, as I too am unaware about internal details of DFSORT/ICETOOL.


The use of OUTFIL statement rather than the OUTREC statement with SPLICE is not an internal detail. It's an external detail - it's documented in the DFSORT books and an error message is produced when you use it. If you don't know the external details of DFSORT and you're NOT using DFSORT, then why are you posting in the DFSORT Forum?

Quote:
I guess FIELDS doesn't work with OUTFIL. Instead use OUTFIL BUILD=


BUILD can be used with INREC, OUTREC or OUTFIL. FIELDS can be used with INREC and OUTREC, but not with OUTFIL. OUTREC can be used with OUTFIL, but not with INREC or OUTREC. I recommend the use of BUILD since it can be used with all three statements (that's why I added it to DFSORT).


Quote:
Could you please help me with this.


Kiran,

Well, I wanted to help you with your question from the beginning, but Parag and other people kept answering and you kept directing your questions to them, so I stayed out of it. I'll read through it all later today and see if I can figure out what you want and give you a solution and explanations.

Everyone,

I really would prefer that people let the two DFSORT developers (Kolusu and I) who participate on this board every day answer the DFSORT questions in the DFSORT Forum. I know that other people who respond are just trying to help, but their responses actually result in more work for us and often just confuse people.
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: Mon Feb 18, 2008 10:41 pm
Reply with quote

Kiran,

Well, as it turns out the DFSORT/ICETOOL job you need is much simpler than Parag's job. Here are two jobs, one of which should do what you asked for. The first job assumes the headers are NOT actually in the input files and are NOT needed in the output file. The second job assumes the headers are in the input files and are needed in the output file.

without headers

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD *
2 0001 NICK 20
4 0005 LOE  30
3 0002 POLO 87
6 0004 PHIL 76
7 9898 JACK 87
/*
//IN2 DD *
2008 0002 POLO 200 78 76 43 65
2008 0004 PHIL 345 98 80 13 45
2008 9898 JACK 987 78 89 23 24
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(3,4,CH) KEEPNODUPS -
 WITH(18,11)
/*
//CTL1CNTL DD *
  INREC BUILD=(1,14,28:X)
/*
//CTL2CNTL DD *
  INREC BUILD=(3:6,4,18:20,11)
/*


OUT has:

Code:

2 0001 NICK 20                   
3 0002 POLO 87   78 76 43 65     
6 0004 PHIL 76   98 80 13 45     
4 0005 LOE  30                   
7 9898 JACK 87   78 89 23 24     


with headers

Code:

//S2    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD *
I SSN  NAME DEPT
2 0001 NICK 20
4 0005 LOE  30
3 0002 POLO 87
6 0004 PHIL 76
7 9898 JACK 87
/*
//IN2 DD *
YEAR SSN  NAME MTOTM1 M2 D1 D2
2008 0002 POLO 200 78 76 43 65
2008 0004 PHIL 345 98 80 13 45
2008 9898 JACK 987 78 89 23 24
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(3,4,CH) KEEPNODUPS -
 WITH(18,11) USING(CTL3)
/*
//CTL1CNTL DD *
  OPTION SKIPREC=1
  INREC BUILD=(1,14,28:X)
/*
//CTL2CNTL DD *
  OPTION SKIPREC=1
  INREC BUILD=(3:6,4,18:20,11)
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,REMOVECC,
    HEADER2=('I SSN  NAME DEPT M1 M2 D1 D2')
/*


OUT has:

Code:

I SSN  NAME DEPT M1 M2 D1 D2 
2 0001 NICK 20               
3 0002 POLO 87   78 76 43 65 
6 0004 PHIL 76   98 80 13 45 
4 0005 LOE  30               
7 9898 JACK 87   78 89 23 24 
Back to top
View user's profile Send private message
n.kirankumar
Warnings : 1

New User


Joined: 14 Feb 2008
Posts: 16
Location: Hyderabad

PostPosted: Tue Feb 19, 2008 12:15 pm
Reply with quote

When I try executing the JCL provided by you.

I m getting the below message in the spool.

Code:
E RECORD TYPE IS F - DATA STARTS IN POSITION 1           
0 INCONSISTENT *INREC   IFTHEN 0 REFORMATTING FIELD FOUND


The input files "Record Format" is FB.

Am I getting this because of both the files "Record format" being FB?

Please suggest on this.
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: Tue Feb 19, 2008 9:38 pm
Reply with quote

I assumed both input files have RECFM=FB.

Both of my jobs work fine when I run them here. So something is different for you that's causing the error message.

You haven't given me anything to work with to figure out what you're doing different. I don't even know which job you used or which operator you received that message for.

You need to send me more information offline (yaeger@us.ibm.com) so I can figure out what you're doing. Send me your complete JCL and control statements, and the complete set of //TOOLMSG and //DFSMSG messages you receive when you run the job. Include the ICExxxs prefixes for the messages (e.g. ICE201I).

Please put "DFSORT" somewhere in the Subject line of your e-mail to catch my attention.
Back to top
View user's profile Send private message
n.kirankumar
Warnings : 1

New User


Joined: 14 Feb 2008
Posts: 16
Location: Hyderabad

PostPosted: Mon Mar 03, 2008 2:29 pm
Reply with quote

Hi Frank,

Sorry for the late response.
The JCL provided by you is working fine.
Thanks a lot.

But there is slight change in my requirement.

File 1:

Code:
2 0001 NICK 20
4 0005 LOE  30
3 0002 POLO 87
6 0004 PHIL 76
7 9898 JACK 87


File 2:

Code:
2008 0002 POLO 200 78 76 43 65
2008 0004 PHIL 345 98 80 13 45
2008 0003 MIKE 876 87 09 98 12
2008 0008 GEOR 879 90 20 12 89
2008 9898 JACK 987 78 89 23 24


If (3,4) of file1 = (6,4) of file2 then I would like to append (21,11) of file2 to the end of first file record and that record needs to be written to output file.
If (3,4) of first file is not equal to (6,4) of second file then I would like to write only the record of file1 to output file.

OUTPUT should look like below:

Code:

I SSN  NAME DEPT M1 M2 D1 D2 
2 0001 NICK 20               
3 0002 POLO 87   78 76 43 65 
6 0004 PHIL 76   98 80 13 45 
4 0005 LOE  30               
7 9898 JACK 87   78 89 23 24 



Awaiting quick reply.



Frank Yaeger wrote:
Kiran,

Well, as it turns out the DFSORT/ICETOOL job you need is much simpler than Parag's job. Here are two jobs, one of which should do what you asked for. The first job assumes the headers are NOT actually in the input files and are NOT needed in the output file. The second job assumes the headers are in the input files and are needed in the output file.

without headers

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD *
2 0001 NICK 20
4 0005 LOE  30
3 0002 POLO 87
6 0004 PHIL 76
7 9898 JACK 87
/*
//IN2 DD *
2008 0002 POLO 200 78 76 43 65
2008 0004 PHIL 345 98 80 13 45
2008 9898 JACK 987 78 89 23 24
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(3,4,CH) KEEPNODUPS -
 WITH(18,11)
/*
//CTL1CNTL DD *
  INREC BUILD=(1,14,28:X)
/*
//CTL2CNTL DD *
  INREC BUILD=(3:6,4,18:20,11)
/*


OUT has:

Code:

2 0001 NICK 20                   
3 0002 POLO 87   78 76 43 65     
6 0004 PHIL 76   98 80 13 45     
4 0005 LOE  30                   
7 9898 JACK 87   78 89 23 24     


with headers

Code:

//S2    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD *
I SSN  NAME DEPT
2 0001 NICK 20
4 0005 LOE  30
3 0002 POLO 87
6 0004 PHIL 76
7 9898 JACK 87
/*
//IN2 DD *
YEAR SSN  NAME MTOTM1 M2 D1 D2
2008 0002 POLO 200 78 76 43 65
2008 0004 PHIL 345 98 80 13 45
2008 9898 JACK 987 78 89 23 24
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(3,4,CH) KEEPNODUPS -
 WITH(18,11) USING(CTL3)
/*
//CTL1CNTL DD *
  OPTION SKIPREC=1
  INREC BUILD=(1,14,28:X)
/*
//CTL2CNTL DD *
  OPTION SKIPREC=1
  INREC BUILD=(3:6,4,18:20,11)
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,REMOVECC,
    HEADER2=('I SSN  NAME DEPT M1 M2 D1 D2')
/*


OUT has:

Code:

I SSN  NAME DEPT M1 M2 D1 D2 
2 0001 NICK 20               
3 0002 POLO 87   78 76 43 65 
6 0004 PHIL 76   98 80 13 45 
4 0005 LOE  30               
7 9898 JACK 87   78 89 23 24 
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: Mon Mar 03, 2008 11:31 pm
Reply with quote

Huh? What exactly is the slight change in your requirement? Is it just that you want to use 21,11 now vs 20,11 before? If so, you just need to change the 20 to a 21 in the CTL2CNTL INREC statement (you mean you couldn't figure that out?). Or is it something else?
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: Tue Mar 04, 2008 10:45 pm
Reply with quote

Based on the private message you sent me offline, I believe this DFSORT job will do what you want. I didn't add the headers - you can do that yourself.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD *
2 0001 NICK 20
4 0005 LOE  30
3 0002 POLO 87
6 0004 PHIL 76
7 9898 JACK 87
//IN2 DD *
2008 0002 POLO 200  78 76 43 65
2008 0004 PHIL 345  98 80 13 45
2008 0003 MIKE 876  87 09 98 12
2008 0008 GEOR 879  90 20 12 89
2008 9898 JACK 987  78 89 23 24
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(3,4,CH) KEEPNODUPS -
 WITH(16,11) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC BUILD=(1,14,28:X,29:C'1')
/*
//CTL2CNTL DD *
  INREC BUILD=(3:6,4,16:21,11,29:C'2')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,OMIT=(29,1,CH,EQ,C'2'),
    BUILD=(1,28)
/*
Back to top
View user's profile Send private message
n.kirankumar
Warnings : 1

New User


Joined: 14 Feb 2008
Posts: 16
Location: Hyderabad

PostPosted: Wed Mar 05, 2008 6:58 pm
Reply with quote

Hi Frank,
Thanks a lot for your help.
The JCL you posted is absolutely working.And i got the output as expected.
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 Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Store the data for fixed length COBOL Programming 1
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
Search our Forums:

Back to Top