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

Replace HEX value with another HEX value in VB DS


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

New User


Joined: 14 Dec 2020
Posts: 10
Location: Germany

PostPosted: Sat Mar 13, 2021 2:47 am
Reply with quote

I have a VB file were can a HEX value ‘0D25’ come in any position from 1 to 20 (values from 21 position onwrd should not be changed). This need to be replaced with HEX value ‘4040’.

Input:
Code:

----+----1----+----2----+----3----+----4----+
0000/12345678  566  @(#)@0000/12345678  566 
FFFF6FFFFFFFF02FFF44B475BFFFF6FFFFFFFF02FFF02
0000112345678D5566005DBD50000112345678D5566D5


Expected output:
Code:

----+----1----+----2----+----3----+----4----+
0000/12345678  566  @(#)@0000/12345678  566 
FFFF6FFFFFFFF44FFF44B475BFFFF6FFFFFFFF02FFF02
000011234567800566005DBD50000112345678D5566D5


I was using SORT with below control card.
Code:

SORT FIELDS=COPY                                     
OUTREC FIELDS=(1,4,5,20,CHANGE=(20,X'0D25',X'4040'),
                        NOMATCH=(5,20),             
               21) 

could you please help me to adjust the control card?
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 457
Location: Bamberg, Germany

PostPosted: Sat Mar 13, 2021 2:55 am
Reply with quote

Use FINDREP.
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 457
Location: Bamberg, Germany

PostPosted: Sun Mar 14, 2021 11:14 am
Reply with quote

Code:
OPTION COPY                                                   
INREC IFTHEN=(WHEN=INIT,                                       
  FINDREP=(INOUT=(X'0D25',X'4040'),STARTPOS=5,ENDPOS=24,DO=99))
END
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Mon Mar 15, 2021 7:21 pm
Reply with quote

FYI- CHANGE will only replace if something found at that position and hence it will not work here as it will not scan thru 5-20.
Code:
DO=n
Specifies the maximum number of times find and replace is to be performed for a record,
overriding the default of every time. Scanning for the input constant stops when n input constants
have been found and replaced. Use DO=n if you want to stop after a particular number of
constants have been replaced. n can be 1 to 1000.
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 457
Location: Bamberg, Germany

PostPosted: Mon Mar 15, 2021 8:08 pm
Reply with quote

Rohit Umarjikar wrote:
FYI- CHANGE will only replace if something found at that position and hence it will not work here as it will not scan thru 5-20.

Obviously it does work.

Input:
Code:
0000/12345678  566  @(#)@0000/12345678  566 
FFFF6FFFFFFFF02FFF44B475BFFFF6FFFFFFFF02FFF02
0000112345678D5566005DBD50000112345678D5566D5

Output:
Code:
0000/12345678  566  @(#)@0000/12345678  566 
FFFF6FFFFFFFF44FFF44B475BFFFF6FFFFFFFF02FFF02
000011234567800566005DBD50000112345678D5566D5
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Mon Mar 15, 2021 11:20 pm
Reply with quote

If its a constant position to be scanned and replaced then simple IFTHEN with OVERLAY would do. FINDREP is needed to replace if it occurs between 5-20 anywhere, n times as that is the expectation from the original post.
Back to top
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1015

PostPosted: Tue Mar 16, 2021 12:15 am
Reply with quote

Rohit Umarjikar wrote:
If its a constant position to be scanned and replaced then simple IFTHEN with OVERLAY would do. FINDREP is needed to replace if it occurs between 5-20 anywhere, n times as that is the expectation from the original post.

DO= is in effect when there are more than one occurrence of required value to be changed.
DO=99 is specified to guarantee ANY possible number of occurrences between positions 5 and 25. E.g., "more than enough".
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Tue Mar 16, 2021 5:50 pm
Reply with quote

Saying the same thing over again. Let us close it out.
Back to top
View user's profile Send private message
Sebin89

New User


Joined: 14 Dec 2020
Posts: 10
Location: Germany

PostPosted: Tue Mar 16, 2021 6:39 pm
Reply with quote

Many thanks for the suggestions. Slightly modified CNTL worked.

Code:

OPTION COPY                                                   
OUTREC FINDREP=(INOUT=(X'0D25',X'4040'),STARTPOS=5,ENDPOS=24) 
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 How to replace a string dynamically i... CLIST & REXX 16
No new posts Need to split single line into two li... DFSORT/ICETOOL 7
No new posts Hex Value - vb file replace old date ... DFSORT/ICETOOL 14
No new posts IEBCOPY - Not replace a existing PDS ... JCL & VSAM 15
No new posts How to copy\replace the members in pr... JCL & VSAM 6
Search our Forums:

Back to Top