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
 

 

Copying data from two diff files into one file

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

New User


Joined: 15 May 2006
Posts: 92

PostPosted: Mon Jan 24, 2011 11:46 am    Post subject: Copying data from two diff files into one file
Reply with quote

Hi there,

My requirement is as follows:

File 1 (FB/100): Contains only 1 rec and has the below data.

11015

File 2 (FB/1000): Contains only 1 rec and has the below data.

From this file I need to copy data from byte number 20 to 1000 (ALL data is in Packed decimal).

Output file (FB/2000): Will Contain only 1 rec and should be having the below data.
The output needs to look like this
OUT11015XXXXXXXXXXX

OUT --> hardcoded (We need to move OUT in this output file)
11015 --> from File 1
XXXXXXXXXXX --> From File 2 (data from byte number from 20th to 1000th)

The above is a simplified version of what I actually require. In the real scenario I am dealing with different LRECLs and different data.

My attempt is as follows:
I tried using FILEAID utility (via JCL) and successfully achieved only two parts of the requirement. That is I got my output as:

OUT11015

For OUT I used --> MOVE=(1,C'OUT')
For 11015 -->I again used MOVE statement to copy the data from FILE 1

But I couldn't manage to write data from FILE 2. I tried many things in FILEAID but didn't get any success.

Could you please advise on this. I am open to use other utilities too.
Back to top
View user's profile Send private message

gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Mon Jan 24, 2011 12:15 pm    Post subject:
Reply with quote

Hi,

you can use this
Code:
//S1       EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD DSN=input file1                                       
11015                                                                   
/*                                                                     
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)         
//SYSIN    DD    *                                                     
  OPTION COPY                                                           
  INREC BUILD=(C'FILE1VAL,''',1,5,C'''',80:X)                           
/*                                                                     
//S2       EXEC  PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)                                 
//SYMNOUT  DD SYSOUT=*                                                 
//SORTIN   DD DSN=input file2                             
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  OPTION COPY                                                           
 OUTREC BUILD=(C'OUT',FILE1VAL,20,981,2000:X)                           
/*                                                                     


Gerry
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Tue Jan 25, 2011 2:17 am    Post subject:
Reply with quote

Here's another way to do this with DFSORT:

Code:

//S1 EXEC PGM=SORT                                 
//SYSOUT DD SYSOUT=*                               
//IN1 DD DSN=...  input file1 (FB/100)         
//IN2 DD DSN=...  input file2 (FB/1000)                   
//SORTOUT DD DSN=...  output file (FB/2000)                               
//SYSIN DD *                                     
  JOINKEYS F1=IN1,FIELDS=(6,1,A),SORTED,NOSEQCK     
  JOINKEYS F2=IN2,FIELDS=(6,1,A),SORTED,NOSEQCK     
  REFORMAT FIELDS=(F1:1,5,F2:20,981)               
  OPTION COPY     
  OUTREC BUILD=(C'OUT',1,5,6,981,2000:X)                                 
/*               
//JNF2CNTL DD *                                     
  INREC OVERLAY=(6:X)                               
/*
Back to top
View user's profile Send private message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 92

PostPosted: Tue Feb 08, 2011 11:52 pm    Post subject:
Reply with quote

Thanks Frank. Sorry for the late reply. Unfortunately, my system isn't updated with latest SORT and therefore I cannot use Joinkeys. I am trying to get it working thru spice/icetool step.

I have got one more requirement which is as follows:

File 1 (FB/80): (Contains only 1 record)
XXXXXXX11029XXXXXXXX11030XXXXXXXX11031


File 2 (FB/80): (Contains only 1 record)
FFQ#####00100999999999999999999999999999

Now I want to replace "#####" in FILE 2 with 11029 (from FILE 1).

Again I tried it using FILEAID and I am able to copy the required data but everything else is replaced by spaces.

Any kind of help will be really appreciated.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Wed Feb 09, 2011 12:15 am    Post subject:
Reply with quote

If ##### is always at position 4 in File2, you can use a DFSORT job like the following:

Code:

//S1 EXEC PGM=SORT                                                 
//SYSOUT DD SYSOUT=*                                               
//SORTIN DD *                                                       
XXXXXXX11029XXXXXXXX11030XXXXXXXX11031                             
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)     
//SYSIN DD *                                                       
  OPTION COPY                                                       
  INREC BUILD=(C'REPFLD,''',8,5,C'''',80:X)                         
//S2 EXEC PGM=SORT                                                 
//SYSOUT DD SYSOUT=*                                               
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)                             
//SORTIN DD *                                                       
FFQ#####00100999999999999999999999999999                           
//SORTOUT DD SYSOUT=*                                               
//SYSIN DD *                                                       
  OPTION COPY                                                       
  INREC OVERLAY=(4:REPFLD)                                         


If ##### can be anywhere in File2, you can replace the INREC statement above with this one:

Code:

  INREC FINDREP=(IN=C'#####',OUT=REPFLD)     
Back to top
View user's profile Send private message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 92

PostPosted: Fri Feb 11, 2011 8:17 am    Post subject:
Reply with quote

Thanks frank ... I tried this out on the data that I initially provided and it is working fine.

However, when I tried the same thing on different data (Comp-3) I was getting a duplicate error (with MAXCC=16) on

Code:
INREC OVERLAY=(4:REPFLD)


Right now I don't have access to mainframes therefore I won't be able to write much on what exactly the error I am getting.
Back to top
View user's profile Send private message
mohitsaini
Warnings : 1

New User


Joined: 15 May 2006
Posts: 92

PostPosted: Fri Feb 11, 2011 10:34 am    Post subject:
Reply with quote

Hey Frank,

I have got rid of the duplicate problem by using STOPAFT and SKIPREC parameters.

Actually I have many recs in the input file and only one record in my ouput file. That's why I was getting that duplicate error.
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 copying data without knowing location arunsoods DFSORT/ICETOOL 6 Thu Jul 20, 2017 1:03 pm
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 19 Thu Jul 13, 2017 2:11 pm
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm


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