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

Inspect using replace


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

New User


Joined: 10 Mar 2011
Posts: 45
Location: india

PostPosted: Fri Aug 16, 2013 10:28 pm
Reply with quote

I am having the following sample records in a file:

record 1 : driver @001 from to @002 to @003
record 2: PB value @002 changed to @001

I need to replace @001, @002 and @0003 with messages and these messages are in the table and these messages are predefined.

05 ws-table occurs 3 times

03 ws-mess pic x(04)
03 ws-message pic (20)


Sample data in a table:

ws-mess ws-message
@001 added
@002 changed
@003 deletes

I need to refer the tables and replace the @ fields in the message . I need to get output message in the following way.

output:

record 1 : driver added from to change to deletes
Back to top
View user's profile Send private message
dharmaraok

New User


Joined: 10 Mar 2011
Posts: 45
Location: india

PostPosted: Fri Aug 16, 2013 10:29 pm
Reply with quote

Could you please let me know how to achieve these
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Aug 16, 2013 11:49 pm
Reply with quote

INSPECT TALLYING and reference modification are probably the easiest way. Since you have to make multiple passes across the data, you'll need to make sure your changes are kept as you make passes across the data.

Tell us where you are having problems and we can help. However, this is not a WRITE-THE-CODE-FOR-YOU forum so we won't just give you code.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Aug 17, 2013 2:29 am
Reply with quote

Please use the Code tags when spacing is important.

You could use UNSTRING, DELIMITED BY SPACE, into seven fields for the first and six for the second record.

Then test the appropriate fields, replacing the @nnn with the correct message.

The use STRING to put them together again DELIMITED BY SPACE for fields and SIZE for a blank separator..
Back to top
View user's profile Send private message
dharmaraok

New User


Joined: 10 Mar 2011
Posts: 45
Location: india

PostPosted: Sat Aug 17, 2013 10:53 am
Reply with quote

Bill,

In record we don't know how many @messages will come. How can we use "unstring operation wit delimited by space into identifier" for every record we cannot change the identifiers
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Aug 17, 2013 12:28 pm
Reply with quote

Well, you knew that, we didn't.

If you explain, fully, your possible data, we can see.

Else, you have byte-by-byte, reference-modification, variable-length data.

One thing that is certain is that you can't use INSPECT ... REPLACING, becasue the to/from have to be the same length.
Back to top
View user's profile Send private message
dharmaraok

New User


Joined: 10 Mar 2011
Posts: 45
Location: india

PostPosted: Sat Aug 17, 2013 12:38 pm
Reply with quote

Yes we can do reference modification for the message but how can we replace the message which is there in the occurs table.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Aug 17, 2013 4:51 pm
Reply with quote

You have an input variable and an output variable. For each table occurrence (you showed us three; who knows how many there really are) start at byte one of the input variable (going to the end of the variable), use reference modification to see if the next 4 bytes match your table element; if so, move the table replacement to the output variable and increment the output location by 7 bytes; if not, move the input byte to the output variable using reference modification and increment the output location by 1. After each table occurrence has been scanned, before starting the next one, move the output variable to the input variable and reset the output location to 1.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Aug 17, 2013 10:24 pm
Reply with quote

Depending on whether you are doing other things in the program, FINDREP, a function of SORT, can do what you want.
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: Mon Aug 19, 2013 2:43 am
Reply with quote

Hello,

No matter how you do this, you will have to make sure the new output length is not longer than lrecl . . .
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts replace word 'MONTH' with current mon... SYNCSORT 11
No new posts To replace jobname in a file with ano... SYNCSORT 12
No new posts Conditional replace values in output ... DFSORT/ICETOOL 3
Search our Forums:

Back to Top