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
 

 

Replacing of character

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Niki

Active User


Joined: 20 Sep 2008
Posts: 102
Location: Bangalore

PostPosted: Thu Feb 19, 2009 7:15 pm    Post subject: Replacing of character
Reply with quote

I have an input file of length=200.

Code:

String">%header01%</Data>%Jindegi%</Data>Data>%header02%</Data>


I need to replace the value that is present between first occourance of % and second occourance of % by some value. Similarlly for 3rd and fourth and 5th, 6th.

So my output should be like below,

Code:

String">555</Data>8594</Data>Data>995846</Data>



My input file has around 40, %. So I cannot directly move the values.

Is there any other technique to do the same like using INSPECT.
Back to top
View user's profile Send private message

Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Feb 19, 2009 8:47 pm    Post subject: Reply to: Replacing of character
Reply with quote

Review the code in the following link -

http://ibmmainframes.com/viewtopic.php?p=143786&highlight=#143786

Here's an easy method of defining a 256-Byte Translate-Table in Assembler for all byte-values of X'00' through X'FF'. By having this Static Table pre-defined, it's not necessary to dynamically build one every time (as what's done in the above link).

Code:

HEXTBL   CSECT                                                           
         DC    256AL1(*-HEXTBL)    CREATE ALL 256-BYTE HEXTBL-ENTRIES     
HEXTBL   AMODE 31                                                         
HEXTBL   RMODE ANY                                                       
         END                                                             


Regards,
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Feb 19, 2009 9:59 pm    Post subject:
Reply with quote

Hello,

I may be reading the requirement incorrectly, but i believe considerably more than a byte-translate is needed. . .

To do what i believe is needed, i'd not use inspect other than to tally the number of %s found (it must be an even number or the code should terminate). Next, i'd ensure that there was a replacement value for each pair of %s. (Where are the "new" replacement string values? In some file, or hardcoded or?).

I'd create an array of 2-element entries (length, and replacement value) for the "new" values.

Then i'd loop thru (parse) the input moving each byte to an output work area and when the first % was found, move the first entry in the array by length to that positon of the output area. I would then continue to advance thru the input until the next % is encountered and return to moving indivudual bytes until the next % is found. This would repeat until the input had been parsed and the values between the %s were replaced.
Back to top
View user's profile Send private message
Niki

Active User


Joined: 20 Sep 2008
Posts: 102
Location: Bangalore

PostPosted: Fri Feb 20, 2009 10:06 am    Post subject:
Reply with quote

Hi Dick Scherrer,

You are absolutely correct.

There will be always even number of %s and the replacement values will be present in a file.



1) I am having an mainframe file of LRECL= 50 which will have (let) 4 records of (let) 3 fields.

Code:

----+----1----+----2----+----3----+----4----+----5
Sanjeet;12345;Sample
Sameeer;45689;Jindegee
harishh;96584;Enjoy feeling
samyaak;65895;Lovely Style


2) The following code will be present in a WS veriable.

Code:

String">%header01%</Data>%header02%</Data>Data>%header03%</Data>


3 ) I am having a table by querrying that table with parameter = HEADER1, it will give me the start and end position of the input record from where i need to copy the data. Similarly for Header2 and 3.

4) As there are 4 records in the input file, my output file ( Lrecl=80 ) will also need to have four records, and it should look like below,


Code:

String">Sanjeet</Data>12345</Data>Data>Sample</Data>
String">Sameeer</Data>45689</Data>Data>Jindegee</Data>
String">harishh</Data>96584</Data>Data>Enjoy feeling</Data>
String">samyaak</Data>65895</Data>Data>Lovely Style</Data>



Could you please help me by giving some of sample programs to achieve the 4th step i.e after getting the positions of the data.

Thanks in advance
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Feb 20, 2009 10:24 am    Post subject:
Reply with quote

Hello,

Unfortunately, i don't have any code that is the same as your requirement.

Suggest you read the lrecl50 file and build the 2-element array i mentioned (UNSTRING with COUNT IN should do nicely).

Then write code to do what i mentioned above - if there are problems, post code snippets here and we will be able to help.
Back to top
View user's profile Send private message
Niki

Active User


Joined: 20 Sep 2008
Posts: 102
Location: Bangalore

PostPosted: Fri Feb 20, 2009 10:35 am    Post subject:
Reply with quote

Thank you veru much.

i ll try and let you know if i face some isses.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Feb 20, 2009 10:38 am    Post subject: Reply to: Replacing of character
Reply with quote

Quote:
ll try and let you know if i face some isses.
I suspect it will go well. We'll be here . . .

Good luck icon_smile.gif

d
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts the use of 'B3'x character in a panel Pedro TSO/ISPF 1 Thu Feb 16, 2017 3:09 am
This topic is locked: you cannot edit posts or make replies. DSList (3.4) cannot display Chinese c... jacobdng TSO/ISPF 4 Wed Oct 05, 2016 2:51 pm
No new posts Continuation Character ballaswaroop SYNCSORT 8 Thu Aug 25, 2016 4:46 pm
No new posts Adding a descending character to a file Steve Ironmonger DFSORT/ICETOOL 3 Fri Jul 15, 2016 4:57 pm


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