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
 

 

Replace string from file1 to file2 in JCL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Replace string from file1 to file2 in JCL
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    Post subject: Reply to: Replace string from file1 to file2 particular posi
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    Post subject:
Reply with quote

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

Moderator


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

PostPosted: Fri Jan 20, 2012 12:19 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Fri Jan 20, 2012 12:44 pm    Post subject: Reply to: Replace string from file1 to file2 particular posi
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

Moderator


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

PostPosted: Fri Jan 20, 2012 12:49 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Fri Jan 20, 2012 12:51 pm    Post subject: Reply to: Replace string from file1 to file2 particular posi
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

Moderator


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

PostPosted: Fri Jan 20, 2012 12:54 pm    Post subject:
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

Moderator


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

PostPosted: Fri Jan 20, 2012 1:56 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Fri Jan 20, 2012 2:43 pm    Post subject: Reply to: Replace string from file1 to file2 particular posi
Reply with quote

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

Moderator


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

PostPosted: Fri Jan 20, 2012 2:54 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject: Reply to: Replace string from file1 to file2 particular posi
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Tue May 15, 2012 3:32 am    Post subject: Reply to: Replace string from file1 to file2 particular posi
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    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 Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
This topic is locked: you cannot edit posts or make replies. Sort card to replace text using cross... Susanta SYNCSORT 32 Tue Sep 13, 2016 4:17 pm
No new posts Replace function abdulrafi COBOL Programming 13 Mon Sep 12, 2016 10:12 am
No new posts Random Password (in string format) ge... ezhavendhan COBOL Programming 10 Mon Aug 29, 2016 3:18 pm


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