View previous topic :: View next topic
|
Author |
Message |
Niki
Active User
Joined: 20 Sep 2008 Posts: 106 Location: Bangalore
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Niki
Active User
Joined: 20 Sep 2008 Posts: 106 Location: Bangalore
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Niki
Active User
Joined: 20 Sep 2008 Posts: 106 Location: Bangalore
|
|
|
|
Thank you veru much.
i ll try and let you know if i face some isses. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Quote: |
ll try and let you know if i face some isses. |
I suspect it will go well. We'll be here . . .
Good luck
d |
|
Back to top |
|
|
|