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

Replace string from file1 to file2 in JCL


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

New User


Joined: 05 Dec 2006
Posts: 89
Location: chennai

PostPosted: Fri Jan 20, 2012 9:52 am
Reply with quote

All,

I have requirement to get userid from FILE1 and replace on FILE2 second line ,4th Position
Both FILE1 and FILE2 having 80 bytes.

File 1 - 80 Bytes

Userid - First 6 bytes

File2 - 80 bytes


########################## - Record 1
$$$USERID$$$$$$$$$$$$$$$$$ - Record 2
%%%%%%%%%%%%%%%%%%%%%%%%%% - Record 3
************************** - Record 4



Example

FILE1

AAAAAA (First 6 characters - Userid)


FILE2

BBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDD
EEEEEEEEEEEEEEEEEEEEEEEEEEEE


I need to get userid from first file and override on second file ,2 record ,4the position.

OUTPUT -
FILE3

BBBBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCCCC
DDDAAAAAADDDDDDDDDDDDDDDD
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

Above shows userid replaced on FILE2
ie) always i need to copy paste userid from FILE1 to FILE2 (2nd record ,4the position)


Thanks
Jagadesh
Back to top
View user's profile Send private message
itjagadesh

New User


Joined: 05 Dec 2006
Posts: 89
Location: chennai

PostPosted: Fri Jan 20, 2012 9:55 am
Reply with quote

Correstion in output file
Example

FILE1

AAAAAA


FILE2

BBBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDDDD
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE


I need to get userid from first file and override on second file ,2 record ,4th position.

OUTPUT -
FILE3

BBBBBBBBBBBBBBBBBBBBBBBBBBB
CCCAAAAAACCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDDDDD
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE


ie) always i need to copy paste userid from FILE1 to FILE2 (2nd record ,4th position)
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Fri Jan 20, 2012 11:36 am
Reply with quote

what is the join key in FILE1 & FILE2?
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Jan 20, 2012 12:19 pm
Reply with quote

I would suggest to create the sort card dynamically to achieve the same

Edit : Does your input contains only four records ?
Or your input contains records in group of four ?
Or your input contains many but you wanted to consider only second record?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10879
Location: italy

PostPosted: Fri Jan 20, 2012 12:44 pm
Reply with quote

the description seemed clear to me ...

file 1 ==> 1 record
file 2 ==> n records

whatever the content of file 2 only the second record should be considered
and the content of the only record of file1 should overlay part of it.


hint ...
apply a sequence number to file1 starting from 2 ( at column 81 )
apply a sequence number to file2 ( at column 81 )
joinkeys on the sequence number and process accordingly

no need for dynamic sort cards.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Jan 20, 2012 12:49 pm
Reply with quote

Arg I get that Enrico my shop doesn't have the latest product Thanks guess got to take a break
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10879
Location: italy

PostPosted: Fri Jan 20, 2012 12:51 pm
Reply with quote

up to a certain extent You can get the same result using icetool splice
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Jan 20, 2012 12:54 pm
Reply with quote

Yes I was trying to work it on splice then realised it may not be needed.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Jan 20, 2012 1:56 pm
Reply with quote

Enrico:

Here goes my splice version of code icon_cool.gif
Considering 25 as LRECL

Code:

//S010 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
AAAA
//IN2 DD *
AAAAAAAAAAAAAAAAAAAA
CCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDD
//OUT DD SYSOUT=*
//T1 DD DSN=&&T1,SPACE=(TRK,(5,5)),
//  DISP=(MOD,PASS)
//TOOLIN   DD *
  COPY FROM(IN1) TO(T1) USING(CTL1)
  COPY FROM(IN2) TO(T1) USING(CTL2)
  SPLICE FROM(T1) TO(OUT) ON(30,2,ZD) WITH(1,3) WITH(8,22)-
    USING(CTL3) KEEPNODUPS
//*
//CTL1CNTL DD *
  OUTREC FIELDS=(4:1,4,30:C'02')
//CTL2CNTL DD *
  OUTREC FIELDS=(1:1,25,30:SEQNUM,2,ZD)
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,OUTREC=(1,25)
//*



OUTPUT
Code:

AAAAAAAAAAAAAAAAAAAA
CCCAAAACCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDD
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10879
Location: italy

PostPosted: Fri Jan 20, 2012 2:43 pm
Reply with quote

nice shot!
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Jan 20, 2012 2:54 pm
Reply with quote

Thanks icon_biggrin.gif
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Jan 20, 2012 10:44 pm
Reply with quote

itjagadesh wrote:
I need to get userid from first file and override on second file ,2 record ,4th position.


itjagadesh,

The following DFSORT JCL will give you the desired results. Since both files are having same DCB properties just concatenate them together to SORTIN and pick the value from 1st file and overlay on to the 3rd record.


Code:

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD DSN=Your FB 80 byte 1 record USERid file,DISP=SHR
//         DD DSN=Your FB 80 byte file to have 2nd record replaced,DISP=SHR       
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                                 
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),               
  IFTHEN=(WHEN=GROUP,BEGIN=(81,8,ZD,EQ,1),PUSH=(89:1,6),RECORDS=3),
  IFTHEN=(WHEN=(81,8,ZD,EQ,3),OVERLAY=(4:89,6))                   
  OUTFIL BUILD=(1,80),OMIT=(81,8,ZD,EQ,1)                         
//*


PS: Enrico and prem , it is a very simple requirement , lets keep it that way
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Jan 20, 2012 10:57 pm
Reply with quote

Just in case if your shop doesn't support when=group, then you can use the symbol generation method shown here as we are only dealing with just 1 record from file 1.
Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                 
AAAAAA                                                           
//SORTOUT  DD DSN=&&S1,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)       
//SYSIN    DD *                                                 
  OPTION COPY,STOPAFT=1                                         
  OUTFIL REMOVECC,NODETAIL,HEADER1=('USERID,C''',1,6,C'''',80:X)
//*                                                             
//STEP0200 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SYMNAMES DD DSN=&&S1,DISP=SHR                                 
//SORTIN   DD *                                                 
BBBBBBBBBBBBBBBBBBBBBBBBBB                                       
CCCCCCCCCCCCCCCCCCCCCCCC                                         
DDDDDDDDDDDDDDDDDDDDDDDD                                         
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE                                   
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  OPTION COPY                                               
  INREC IFOUTLEN=80,IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
  IFTHEN=(WHEN=(81,8,ZD,EQ,2),OVERLAY=(4:USERID))               
//*
Back to top
View user's profile Send private message
itjagadesh

New User


Joined: 05 Dec 2006
Posts: 89
Location: chennai

PostPosted: Tue May 15, 2012 3:21 am
Reply with quote

Sorry for delayed response.Post given by 'Pandora-Box' worked fine.
Thank you all for your help
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: Tue May 15, 2012 3:32 am
Reply with quote

With due respect to Pandora-Box, a strange choice, but there we go. Did you even try Kolusu's two solutions?
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 ICETOOL to SUM String DFSORT/ICETOOL 1
No new posts Mark Previous & next lines when a... DFSORT/ICETOOL 9
No new posts Using Multiple IFTHEN and WHEN condit... SYNCSORT 12
No new posts sort to find out the char which repea... Mainframe Interview Questions 10
No new posts Help with C character vs C string All Other Mainframe Topics 3
Search our Forums:

Back to Top