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

Merge two files with some replace/overlay function.


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

New User


Joined: 03 Sep 2015
Posts: 10
Location: Peru

PostPosted: Thu Sep 03, 2015 7:59 pm
Reply with quote

I have a requirement where in I have two files as given below: -
File 1 (80 bytes): -
AB111111 COBOLPG
AB222222 COBOLPG
AB333333 COBOLPG
AB444444 COBOLPG
AB555555 COBOLPG
AB666666 COBOLPG
.
.
.
.
n number of member names with their types.

File 2 (80 bytes): -
ADD ELEMENT 'MEMBNAME'
FROM DSNAME 'XXXX.YYYY.ZZZZ'
TO ENVIRONMENT 'DEVELP' SYSTEM 'ABCDEFG' SUBSYSTEM 'XYZXYZ'
TYPE 'MEMTYPE'
OPTIONS CCID '99999' COMMENTS "AB123456789" PROC GROUP 'ABC'
.
ADD ELEMENT 'MEMBNAME'
FROM DSNAME 'XXXX.YYYY.ZZZZ'
TO ENVIRONMENT 'DEVELP' SYSTEM 'ABCDEFG' SUBSYSTEM 'XYZXYZ'
TYPE 'MEMTYPE'
OPTIONS CCID '99999' COMMENTS "AB123456789" PROC GROUP 'ABC'
.
ADD ELEMENT 'MEMBNAME'
FROM DSNAME 'XXXX.YYYY.ZZZZ'
TO ENVIRONMENT 'DEVELP' SYSTEM 'ABCDEFG' SUBSYSTEM 'XYZXYZ'
TYPE 'MEMTYPE'
OPTIONS CCID '99999' COMMENTS "AB123456789" PROC GROUP 'ABC'
.
.
.
.
.
.
repeated to n number of times (equal to the number of member names in first file).

My requirement is to replace the MEMBNAME and MEMTYPE with actual member names and types from the first fle.

I played with some FINDREP, IFTHEN-OVERLAY options but could not get even close to what is desired. Is this even possible with SORT?
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Thu Sep 03, 2015 8:14 pm
Reply with quote

Use IFTHEN=(WHEN=GROUP in second file to form a group with Seq number and also add seq number in first file. (Group can start with 'ADD ELEMENT')

Now match seq numbers, use JOINKEYS and replace/overlay the data.

.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Thu Sep 03, 2015 8:26 pm
Reply with quote

Dheeraj, Welcome to the forum.
Please use the code tags next time , there are variety of examples on the similar requirements on this forum.

This should help you to construct the solution.
Page-17
ftp.software.ibm.com/storage/dfsort/mvs/sorttrck.pdf
ibmmainframes.com/about63209.html
ibmmainframes.com/about53689.html
ibmmainframes.com/about60421.html
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Thu Sep 03, 2015 8:27 pm
Reply with quote

dheeraj.ramchandani,
Do you intend to change static content of second file often? If not, why not build final output file from first file itself using OUTFIL?

Thanks,
Back to top
View user's profile Send private message
dheeraj.ramchandani

New User


Joined: 03 Sep 2015
Posts: 10
Location: Peru

PostPosted: Thu Sep 03, 2015 9:16 pm
Reply with quote

Thanks a lot RahulG31, Rohil Umarjikar and sqlcode1.

Rohit,
How to use code tags on the forum?

sqlcode1,
Yes I need to change the contents of the second file very often based on the contents of the first file. Thanks.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Thu Sep 03, 2015 9:34 pm
Reply with quote

Quote:
How to use code tags on the forum?


ibmmainframes.com/faq.php?mode=bbcode
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Sep 03, 2015 9:57 pm
Reply with quote

You are creating Endevor 'ADD' cards. Why not let Endevor do that for you?
Back to top
View user's profile Send private message
dheeraj.ramchandani

New User


Joined: 03 Sep 2015
Posts: 10
Location: Peru

PostPosted: Thu Sep 03, 2015 10:05 pm
Reply with quote

Because its good to automate a process when there are some 1000 components.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Thu Sep 03, 2015 11:16 pm
Reply with quote

Quote:
sqlcode1,
Yes I need to change the contents of the second file very often based on the contents of the first file. Thanks.


Code:
ADD ELEMENT 'MEMBNAME'
FROM DSNAME 'XXXX.YYYY.ZZZZ'
TO ENVIRONMENT 'DEVELP' SYSTEM 'ABCDEFG' SUBSYSTEM 'XYZXYZ'
TYPE 'MEMTYPE'
OPTIONS CCID '99999' COMMENTS "AB123456789" PROC GROUP 'ABC'

I was asking about static content like "ADD ELEMENT", "FROM DSNAME", "TO ENVIRONMENT". Do you also need to change this frequently? I didn't see anything in the original question about changing this dynamically based on module name. Do you need something like below (i changed your quotes to make this easier to read)? The idea is to keep static content in the card itself and use your MEMBNAME and MEMTYPE from file1 to drive everything.

Code:
//STEP0001 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                       
AB111111 COBOLPG                                                       
AB222222 COBOLPG                                                       
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN DD *                                                           
 SORT FIELDS=COPY                                                     
 OUTFIL BUILD=(1:C'ADD ELEMENT ',1,8,/,                               
               1:C'FROM DSNAME "XXXX.YYYY.ZZZZ"',/,                   
    1:C'TO ENVIRONMENT "DEVELP" SYSTEM "ABCDEFG" SUBSYSTEM',/,         
    1:C'TYPE',10,07,/,                                                 
    1:C'OPTIONS CCID "99999" COMMENTS "AB123456789" PROC GROUP "ABC"')
/*                                                                     


Output
Code:
ADD ELEMENT AB111111                                       
FROM DSNAME "XXXX.YYYY.ZZZZ"                               
TO ENVIRONMENT "DEVELP" SYSTEM "ABCDEFG" SUBSYSTEM         
TYPECOBOLPG                                                 
OPTIONS CCID "99999" COMMENTS "AB123456789" PROC GROUP "ABC"
ADD ELEMENT AB222222                                       
FROM DSNAME "XXXX.YYYY.ZZZZ"                               
TO ENVIRONMENT "DEVELP" SYSTEM "ABCDEFG" SUBSYSTEM         
TYPECOBOLPG                                                 
OPTIONS CCID "99999" COMMENTS "AB123456789" PROC GROUP "ABC"
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Sep 04, 2015 12:54 am
Reply with quote

If the groups on the second file are always identical (within a file for a run, not necessarily across runs) then sqlcode1's solution is best.

If the groups are not identical, then read what RahulG31 wrote and look at Rohit Umarjikar's examples.
Back to top
View user's profile Send private message
dheeraj.ramchandani

New User


Joined: 03 Sep 2015
Posts: 10
Location: Peru

PostPosted: Fri Sep 04, 2015 2:39 am
Reply with quote

Thanks a lot sqlcode1, I don't know why I was going for the difficult option icon_sad.gif
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 Replace each space in cobol string wi... COBOL Programming 2
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 Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling an Open C library function in... CICS 1
Search our Forums:

Back to Top