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

Replacing of character


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Niki

Active User


Joined: 20 Sep 2008
Posts: 106
Location: Bangalore

PostPosted: Thu Feb 19, 2009 7:15 pm
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Feb 19, 2009 8:47 pm
Reply with quote

Review the code in the following link -

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

Moderator Emeritus


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

PostPosted: Thu Feb 19, 2009 9:59 pm
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: 106
Location: Bangalore

PostPosted: Fri Feb 20, 2009 10:06 am
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

Moderator Emeritus


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

PostPosted: Fri Feb 20, 2009 10:24 am
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: 106
Location: Bangalore

PostPosted: Fri Feb 20, 2009 10:35 am
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

Moderator Emeritus


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

PostPosted: Fri Feb 20, 2009 10:38 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Panvalet - 9 Character name - Issue c... CA Products 6
No new posts String has hex character need to conv... COBOL Programming 3
No new posts Output LREC based on specific character DFSORT/ICETOOL 22
No new posts Finding record and replacing with val... DFSORT/ICETOOL 3
Search our Forums:

Back to Top