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
 

 

Inspect using replace

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

New User


Joined: 10 Mar 2011
Posts: 30
Location: india

PostPosted: Fri Aug 16, 2013 10:28 pm    Post subject: Inspect using replace
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: 30
Location: india

PostPosted: Fri Aug 16, 2013 10:29 pm    Post subject:
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: 7904
Location: Bellevue, IA

PostPosted: Fri Aug 16, 2013 11:49 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Sat Aug 17, 2013 2:29 am    Post subject: Reply to: Inspect using replace
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: 30
Location: india

PostPosted: Sat Aug 17, 2013 10:53 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Sat Aug 17, 2013 12:28 pm    Post subject: Reply to: Inspect using replace
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: 30
Location: india

PostPosted: Sat Aug 17, 2013 12:38 pm    Post subject:
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: 7904
Location: Bellevue, IA

PostPosted: Sat Aug 17, 2013 4:51 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Sat Aug 17, 2013 10:24 pm    Post subject: Reply to: Inspect using replace
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

Site Director


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

PostPosted: Mon Aug 19, 2013 2:43 am    Post subject:
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    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 Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
This topic is locked: you cannot edit posts or make replies. Sort card to replace text using cross... Susanta SYNCSORT 32 Tue Sep 13, 2016 4:17 pm
No new posts Replace function abdulrafi COBOL Programming 13 Mon Sep 12, 2016 10:12 am
No new posts Need a help how to replace a string i... gurunath82 CLIST & REXX 12 Tue Jul 26, 2016 11:43 pm
No new posts Inspect statement spoorni COBOL Programming 5 Mon Jun 06, 2016 9:53 pm


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