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

Read file names from existing file then replace data


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

New User


Joined: 16 Nov 2021
Posts: 2
Location: Romania

PostPosted: Tue Nov 16, 2021 3:11 pm
Reply with quote

Hi! New to JCL.

I have an existing file(AAA) which contains 2 records: two file names (BBB, CCC)
File AAA:
Code:
=COLS>    3----+----4----+----5----+----6----+----7----+----8----+----9----+----0-
******    ***************************** Top of Data ******************************
000001                  0000000420211018BBB                   
000002                  0000000420211018CCC                   
******    **************************** Bottom of Data ****************************


File BBB:

Code:
=COLS>    ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
******    ***************************** Top of Data ******************************
000001         2211001000000011349               
000002         2212001000000021349     
000003         2213001000000031349                 
000004         2214001000000041349     
******    **************************** Bottom of Data ****************************


File CCC:
Code:

=COLS>    ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
******    ***************************** Top of Data ******************************
000001         2211001000000011111                                               
000002         2212001000000022222                                               
000003         2213001000000033333                                               
000004         2214001000000044444                                               
******    **************************** Bottom of Data ****************************


Files BBB and CCC are of the same record length.

I would like to replace the data in file BBB (position 13:24) with data from file CCC (position 13:24). Records are identified with key(position 6:12).

I really would appreaciate your help. Thank you!
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1205
Location: Dublin, Ireland

PostPosted: Tue Nov 16, 2021 4:14 pm
Reply with quote

You cannot do this with JCL.

Consider using your SORT product which should be able to do this in two stages. The first stage can use file AAA to generate the JCL for the second stage - a step to execute the SORT that will do the replacement in file BBB from file CCC using JOINKEYS if matching records on key postion.

If new to the SORT product, it might be better to address the second stage first.

Garry.
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 730
Location: Denmark

PostPosted: Tue Nov 16, 2021 7:02 pm
Reply with quote

or a program, REXX springs to mind.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2135
Location: USA

PostPosted: Tue Nov 16, 2021 7:52 pm
Reply with quote

First: there are no such things as "files" on mainframes.

Second: no dataset with DSN=BBB or similar may exist on mainframe.

So, the task can't be done.

Finally: this question has no relation to neither JCL, nor VSAM
Back to top
View user's profile Send private message
memo

New User


Joined: 16 Nov 2021
Posts: 2
Location: Romania

PostPosted: Wed Nov 17, 2021 10:02 pm
Reply with quote

Garry Carroll wrote:
You cannot do this with JCL.

Consider using your SORT product which should be able to do this in two stages. The first stage can use file AAA to generate the JCL for the second stage - a step to execute the SORT that will do the replacement in file BBB from file CCC using JOINKEYS if matching records on key postion.

If new to the SORT product, it might be better to address the second stage first.

Garry.


Thank you for your help Gary. Much appreciated!
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2135
Location: USA

PostPosted: Fri Nov 19, 2021 2:39 am
Reply with quote

Part 1 of your problem seems to be unneeded. Must be re-viewed by software designer(s)

Part 2 can be done by SORT utility, it is not JCL, absolutely!!!

Code:

//REPLACE  EXEC PGM=SORT
// . . . standard SORT utility DD statements here . . . .
// . . . can be different for DFSORT/SYNCSORT, or customized by IT department
//DATABBB  DD  *
      2211001000000011349               
      2212001000000021349     
      2213001000000031349                 
      2214001000000041349     
//*
//DATACCC  DD  *
      2211001000000011111                                               
      2212001000000022222                                               
      2213001000000033333                                               
      2214001000000044444                                               
//*
//SORTOUT  DD  SYSOUT=*
//SYSIN    DD  *
 JOINKEYS F1=DATABBB,FIELDS=(6,7,A),SORTED
 JOINKEYS F2=DATACCC,FIELDS=(6,7,A),SORTED
 JOIN UNPAIRED,F1               ignore non-matching F2 records
 REFORMAT FIELDS=(F1:1,80,F2:1,80,?)
 SORT FIELDS=COPY
 OUTREC IFTHEN=(WHEN=(161,1,CH,EQ,C'B'),   check for matching keys
                BUILD=(81,24,      =1-24 from F2, key+data
                       25,56)),    =25-80 from F1, rest of data 
        IFTHEN=(WHEN=NONE,       for non-matching keys
                BUILD=(1,80))      =1-80 from F1
 END
//*     
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Fri Nov 19, 2021 7:59 am
Reply with quote

What is the significance of AAA Data set in all this ? Second it’s a simple ask of joining two datasets and replacing values of one dataset by another data set. If you do a SEARCH JOINKEYS then you will find many posts addressing the same problem.
Moved to DFSORT section.

E.g ibmmainframes.com/about62319.html
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 Unable to interpret a hex value to De... COBOL Programming 4
No new posts db2 vs static data COBOL Programming 1
No new posts External data queue (changes?) CLIST & REXX 0
No new posts Pull data using date difference betwe... DB2 6
No new posts fast data scrambling PL/I & Assembler 10
Search our Forums:

Back to Top