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

Merge 3 files into one file with header of first file


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

New User


Joined: 30 May 2008
Posts: 9
Location: hyderabad

PostPosted: Mon Mar 02, 2009 11:59 am
Reply with quote

Hi All,

I want to merge 3 PS files with below requirement

File 1 Having the records in below format
Customer#¦Customer Name¦Project Name¦UserId
7777¦xyz¦Project_7777¦xyza

File 2 Having the records in below format
Customer#¦Customer Name¦Project Name¦UserId
6666¦abc¦Project_6666¦abcd

File 3 Having the records in below format
Customer#¦Customer Name¦Project Name¦UserId
5555¦pqr¦Project_5555¦pqrs
4444¦stu¦Project_4444¦stuv

The output file should have the record in below format(With common Heading):
Customer#¦Customer Name¦Project Name¦UserId
7777¦xyz¦Project_7777¦xyza
6666¦abc¦Project_6666¦abcd
5555¦pqr¦Project_5555¦pqrs
4444¦stu¦Project_4444¦stuv
Back to top
View user's profile Send private message
mmt_bit

New User


Joined: 15 Jan 2009
Posts: 14
Location: Bangalore

PostPosted: Mon Mar 02, 2009 2:23 pm
Reply with quote

Not sure this is the best method, but it will work.
It copies and deletes the duplicates:

//STEP01 EXEC PGM=SORT,
// REGION=0M
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=ISC.ISC09.SORT.DSN1,DISP=SHR
// DD DSN=ISC.ISC09.SORT.DSN2,DISP=SHR
// DD DSN=ISC.ISC09.SORT.DSN3,DISP=SHR
//SORTOUT DD DSN=ISC.ISC09.SORT.DSN4,DISP=SHR
//SYSIN DD *
SORT FIELDS=(1,1,CH,A)
SUM FIELDS=NONE
Back to top
View user's profile Send private message
Ashish Ranjan

New User


Joined: 12 Jan 2009
Posts: 2
Location: pune

PostPosted: Mon Mar 02, 2009 2:27 pm
Reply with quote

Try below JCL.
//STEP10 EXEC PGM=ICETOOL,REGION=2048K
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=TEST.PS1,DISP=SHR
// DD DSN=TEST.PS2,DISP=SHR
// DD DSN=TEST.PS3,DISP=SHR
//OUT DD SYSOUT=*
//TOOLIN DD *
DISPLAY FROM(IN1) LIST(OUT) -
HEADER('CUST#') HEADER('CUSTNAME') HEADER('PROJNAME') -
HEADER('USERID') ON(01,4,CH) ON(05,3,CH) ON(08,12,CH) -
ON(20,4,CH)
/*
Back to top
View user's profile Send private message
mohd Waseem Ahmed

New User


Joined: 30 May 2008
Posts: 9
Location: hyderabad

PostPosted: Mon Mar 02, 2009 3:08 pm
Reply with quote

I needed DFSORT option instead of ICETOOL.

Also, regarding SUM FIELDS=NONE option. I am afraid if we can use this option as headers might not be identical as there are from .CSV file upload. User may by mistake enter any other characer and hence those header records may not be the duplicates...

Thank once again but i would be grateful if we can use any DFSORT option.
Back to top
View user's profile Send private message
mmt_bit

New User


Joined: 15 Jan 2009
Posts: 14
Location: Bangalore

PostPosted: Mon Mar 02, 2009 3:36 pm
Reply with quote

If the position of delimiter '|' of header record and the detail record is fixed and are at different positions in the file then you can use the First discard option.

In the example you have given, the 1 st delimiter for header is at 10th position and 1 st delimiter for detail record is at 5th position. Thus irrespective of what the user has entered you can delete the 2 headers.

Hope this helps....
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 02, 2009 10:16 pm
Reply with quote

mohd,

You really haven't made it clear what you're trying to do and you seem to be contradicting yourself in different posts.

You showed an example with three identical headers, but then you say they may not be identical.

But you also say

Quote:
The output file should have the record in below format(With common Heading):


If the headings were not identical, which heading would you want to use?
If the headings are identical, then why are you saying they might not be identical.

Do you have to use one of the existing headings or can the heading be "rebuilt" to look like this as you showed in your expected output:

Quote:

Customer#¦Customer Name¦Project Name¦UserId


You need to do a better job of explaining exactly what you want and the "rules" for getting from input to output before somebody can help you.

Quote:
I needed DFSORT option instead of ICETOOL.


Why? ICETOOL has been shipped as a fully documented, fully supported part of DFSORT since 1991.
Back to top
View user's profile Send private message
mohd Waseem Ahmed

New User


Joined: 30 May 2008
Posts: 9
Location: hyderabad

PostPosted: Tue Mar 03, 2009 9:47 am
Reply with quote

Hi All,

I accept that i did not make myself clear, I am sorry about that.
But presently client doesnt want us to use ICETOOL thats why i am not going for that option.

1. Firstly header will have same values(Here i meant format) in all 3 files, but these 3 files are upload from .CSV files so i expected them to be different (insertion of blank or any other characer in any one of the .CSV files so SUM FIELD =NONE will not work)

So, if there is any other option using which i can i would be grateful to you all. Thanks once again and sorry for the confusion.

Please let me know if the above explanation looks fine.

Thanks & Regards,
Waseem
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Mar 03, 2009 10:06 pm
Reply with quote

mohd Waseem Ahmed,

I assumed all your 3 files have an lrecl of 80 and recfm fb. Use the following to eliminate the headers and have a single header

Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                       
CUSTOMER#¦CUSTOMER NAME¦PROJECT NAME¦USERID                           
7777¦XYZ¦PROJECT_7777¦XYZA
//         DD *                                           
CUSTOMER#¦CUSTOMER NAME¦PROJECT NAME¦USERID                           
6666¦ABC¦PROJECT_6666¦ABCD                                             
//         DD *
CUSTOMER#¦CUSTOMER NAME¦PROJECT NAME¦USERID                           
5555¦PQR¦PROJECT_5555¦PQRS                                             
4444¦STU¦PROJECT_4444¦STUV                                             
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  INREC IFTHEN=(WHEN=(1,9,CH,EQ,C'CUSTOMER#'),OVERLAY=(81:SEQNUM,2,ZD))
  SORT FIELDS=COPY                                                     
  OUTFIL OMIT=(81,2,ZD,GT,1),BUILD=(1,80)
/*
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 03, 2009 10:10 pm
Reply with quote

Well, you didn't answer my question about which of the non-identical headings you wanted in the output file, so I'll assume you want the heading from input file1. Since you can't use ICETOOL and you can't use SUM, you'll need three steps as shown in this DFSORT job. Be sure to use MOD for step2 and step3.

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file1
//SORTOUT DD DSN=userid.OUT,DISP=(NEW,CATLG,DELETE),...
//SYSIN    DD    *
  OPTION COPY
/*
//S2    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file2
//SORTOUT DD DSN=userid.OUT,DISP=MOD
//SYSIN    DD    *
  OPTION COPY,SKIPREC=1
/*
//S3    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file3
//SORTOUT DD DSN=userid.OUT,DISP=MOD
//SYSIN    DD    *
  OPTION COPY,SKIPREC=1
/*
Back to top
View user's profile Send private message
mohd Waseem Ahmed

New User


Joined: 30 May 2008
Posts: 9
Location: hyderabad

PostPosted: Thu Mar 05, 2009 9:51 am
Reply with quote

Hi Guys,

This is perfect...Frank Yaeger ur assumption was right on target to take the first heading(This is what needed)..I ve got 2 options now from you guys without using ICETOOL..Thats wonderful

I thank once again to Ashish Ranjan, mmt_bit, Frank and Skolusu.
I appreciate your cooperation shown in this regard.

Thanks & Regards,
Waseem
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(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top