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

INSPECT with PERFORM statement


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

New User


Joined: 25 Apr 2005
Posts: 67
Location: pune

PostPosted: Wed Aug 13, 2008 10:00 pm
Reply with quote

Hi,

Is it possible if inspect with perform stmt.

ex:-

INSPECT TEXT1 TALLYING
CNTR FOR ALL 'my name '

If "my name" string found in TEXT1 then i want to move my control in to another section. using PERFORM stmt or any other.

but dont want to use perform stmt after checkinig CNTR value..

Any one have idea about this ...please..
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed Aug 13, 2008 10:25 pm
Reply with quote

what exectly do you want to achieve ?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Aug 14, 2008 2:22 am
Reply with quote

Hello,

Quote:
Any one have idea about this ...please..
Probably not until you provide some clarification. . .

Quote:
but dont want to use perform stmt after checkinig CNTR value..
Why not? What might you prefer?

If you post some better sample data and how you want the process to operate, we may be better able to offer suggestions.
Back to top
View user's profile Send private message
ssprabhu

New User


Joined: 25 Apr 2005
Posts: 67
Location: pune

PostPosted: Thu Aug 14, 2008 4:26 pm
Reply with quote

Iam sorry, please see the example below...

NOTES-TEXT contains X123ZZZZ

Code below:-

INSPECT NOTES-TEXT TALLYING
CNTR1 FOR ALL 'X123Z'

EVALUATE TRUE
WHEN CNTR1 = 1
PERFORM CREATE-SEC
WHEN OTHER
DISPLAY ' NO note hit '
END-EVALUATE.

Actually what i want is i want to skip the evaluate condition straightly i want to go to CREATE-SEC section

Is it possible ?
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Aug 14, 2008 4:57 pm
Reply with quote

Why do you want to go to the para if the counter is not equal to 1 ... remove the evaluate and just code perform para ...
Back to top
View user's profile Send private message
GrantP

New User


Joined: 12 Aug 2008
Posts: 8
Location: Johannesburg

PostPosted: Thu Aug 14, 2008 5:02 pm
Reply with quote

@ashimer

CREATE-SEC should only be performed when a certain string is found in NOTES-TEXT otherwise an error message is displayed

As far as I know the inspect statement doesn't cater for specific conditions (like when clause in evaluate).
Back to top
View user's profile Send private message
ssprabhu

New User


Joined: 25 Apr 2005
Posts: 67
Location: pune

PostPosted: Thu Aug 14, 2008 5:25 pm
Reply with quote

Iam just asking if INSPECT stmt finds the string, straightly how to pass the control in to another section.
Back to top
View user's profile Send private message
Cristopher

New User


Joined: 31 Jul 2008
Posts: 53
Location: NY

PostPosted: Thu Aug 14, 2008 5:34 pm
Reply with quote

No it can't.... as your cntr1 will only contain a value which needs to be evaluated.
Back to top
View user's profile Send private message
GrantP

New User


Joined: 12 Aug 2008
Posts: 8
Location: Johannesburg

PostPosted: Thu Aug 14, 2008 5:36 pm
Reply with quote

@ssprabhu

The INSPECT can be used to scan a source string from left to right counting, replacing or converting characters. This is achieved using the TALLYING, REPLACING or CONVERTING phrases and related options.

As far as I know there is no way of transferring control to elsewhere in the program directly using the INSPECT verb
Back to top
View user's profile Send private message
ssprabhu

New User


Joined: 25 Apr 2005
Posts: 67
Location: pune

PostPosted: Thu Aug 14, 2008 5:46 pm
Reply with quote

Iam little sad about the inspect but more happy about your replies
Many thanks all for your time...

Cheers,
Sathish
Back to top
View user's profile Send private message
ssprabhu

New User


Joined: 25 Apr 2005
Posts: 67
Location: pune

PostPosted: Thu Aug 14, 2008 5:58 pm
Reply with quote

Guys , i have one more query ..please help

Text is below:-

Set up cancelled by KA123 ; AC1: 88888888, AC2: 77777777

using INSPECT hot to change it as below

Set up cancelled by KA123 ; AC1: XXXXXXXX, AC2: XXXXXXXX
Back to top
View user's profile Send private message
ssprabhu

New User


Joined: 25 Apr 2005
Posts: 67
Location: pune

PostPosted: Thu Aug 14, 2008 5:59 pm
Reply with quote

I want to replace the account details with character "X"
Back to top
View user's profile Send private message
GrantP

New User


Joined: 12 Aug 2008
Posts: 8
Location: Johannesburg

PostPosted: Thu Aug 14, 2008 6:07 pm
Reply with quote

Are the account details always going to be numeric and always only replaced by "X"
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Thu Aug 14, 2008 6:09 pm
Reply with quote

Use reference modification -- find the AC1: and replace the following characters. Unless you have one or a few fixed AC1 fields, INSPECT is not the tool to use.
Back to top
View user's profile Send private message
ssprabhu

New User


Joined: 25 Apr 2005
Posts: 67
Location: pune

PostPosted: Thu Aug 14, 2008 6:16 pm
Reply with quote

Yes the account details always be numeric but i want to change only account deatis.. not all the numeric fields there is a text KA123 is there
i dont want to change

I tried this

INSPECT DATA1 REPLACING
CHARACTERS BY "X" AFTER "AC1: " BEFORE ", AC2: "
CHARACTERS BY "X" AFTER ", AC2: " BEFORE - - - - -

But i dont know how to replace the AC2 details thatz why i given dahsed lines...any one can please fill it up or give me some alternative solutions..
Back to top
View user's profile Send private message
GrantP

New User


Joined: 12 Aug 2008
Posts: 8
Location: Johannesburg

PostPosted: Thu Aug 14, 2008 6:31 pm
Reply with quote

You don't need the "BEFORE" bit of code at the end there...
It seems to works just fine like this:

Code:

INSPECT DATA1                                       
REPLACING                                           
   CHARACTERS BY "X" AFTER "AC1: " BEFORE ", AC2: " 
   CHARACTERS BY "X" AFTER "AC2: "                   
Back to top
View user's profile Send private message
ssprabhu

New User


Joined: 25 Apr 2005
Posts: 67
Location: pune

PostPosted: Thu Aug 14, 2008 7:57 pm
Reply with quote

iam sorry , forgot to say one thing

that text is 100 bytes total if i do like this then it will replace X till 100 bytes .

From AC2 just i want to replace "X" for 8 bytes.
Back to top
View user's profile Send private message
ssprabhu

New User


Joined: 25 Apr 2005
Posts: 67
Location: pune

PostPosted: Thu Aug 14, 2008 7:58 pm
Reply with quote

It s bit tough now...isn't it ??
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Aug 14, 2008 8:19 pm
Reply with quote

Quote:

It s bit tough now...isn't it ??


Individual decision

Code:


INSPECT DATA1                                       
REPLACING                                           
   CHARACTERS BY "X" AFTER "AC1: " BEFORE ", AC2: " 
   CHARACTERS BY "X" AFTER "AC2: "  BEFORE INITIAL "  "     



before 2 spaces ... but this wont work if your last 7 is in 99th position ...
Back to top
View user's profile Send private message
GrantP

New User


Joined: 12 Aug 2008
Posts: 8
Location: Johannesburg

PostPosted: Fri Aug 15, 2008 3:16 pm
Reply with quote

With the additional complication you've added, the INSPECT is not the tool to use. See Robert's post below

Robert Sample wrote:
Use reference modification -- find the AC1: and replace the following characters. Unless you have one or a few fixed AC1 fields, INSPECT is not the tool to use.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Sat Aug 16, 2008 6:51 pm
Reply with quote

Quote:
With the additional complication you've added, the INSPECT is not the tool to use
in this case , at the first place itself you shudnt have recommended this ...and btw how does adding a BEFORE clause to your post increase the complication ? i just gave some value addition ...

For finding the location of AC1 and AC2 either you will have to do a perform checking for the exact value or else you have to use INSPECT ... let the OP decide whether he wants performance or simpler code ...

But i would strongly suggest using PERFORM
Back to top
View user's profile Send private message
GrantP

New User


Joined: 12 Aug 2008
Posts: 8
Location: Johannesburg

PostPosted: Mon Aug 18, 2008 12:11 pm
Reply with quote

@ashimer

Apologies for any misunderstanding. "additional complication" comment was directed at OP with regards

Quote:
iam sorry , forgot to say one thing

that text is 100 bytes total if i do like this then it will replace X till 100 bytes .

From AC2 just i want to replace "X" for 8 bytes.
Back to top
View user's profile Send private message
ssprabhu

New User


Joined: 25 Apr 2005
Posts: 67
Location: pune

PostPosted: Mon Aug 18, 2008 3:51 pm
Reply with quote

Thanks all, this also work isn't it ? please suggest how to reduce the 2 inspect stmt as one .

INSPECT DATA1 CONVERTING
"0123456789" TO "XXXXXXXXXX"
AFTER INITIAL "AC1: " BEFORE ", AC2"
INSPECT DATA1 CONVERTING
"0123456789" TO "XXXXXXXXXX" AFTER ", AC2"
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 Use of Perform Thru Exit COBOL Programming 6
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts Relate COBOL statements to EGL statement All Other Mainframe Topics 0
No new posts process statement for SUPREC, CMPCOLM... TSO/ISPF 4
No new posts SYNCSORT/ICETOOL JOINKEYS SORT Statem... DFSORT/ICETOOL 13
Search our Forums:

Back to Top