MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Replace Option : Setting Dynamic Value....?

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
kris_madras
Beginner


Joined: 07 Apr 2004
Posts: 46
Topics: 29

PostPosted: Mon May 31, 2004 3:11 pm    Post subject: Replace Option : Setting Dynamic Value....? Reply with quote

Hi All.

I need an urgent solution
I have used REPLACE option in COBOL as follows...

Code:


IF WS-STATE-CODE = "IN" THEN             
   REPLACE   == :ST-CODE: == BY ==IN==. 
IF  WS-STATE-CODE NOT EQUAL "IN"         
   REPLACE   == :ST-CODE: == BY ==OK==. 

ADD 1 TO WS-:ST-CODE:-SCRIPT-FLAG-BLANK.



My intention is whenever WS-STATE-CODE IS "IN" then increment WS-IN-SCRIPT-FLAG-BLANK. or else

WS-OK-SCRIPT-FLAG-BLANK.


But the compiler is always assuming :-ST-CODE:- as OK because
of lateral declaration of REPLACE...(compile time) how can I set to run time(IF condition...) any alternatives....?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Jun 01, 2004 5:30 am    Post subject: Reply with quote

kris_madras,


Use 88 level field declarations to set the flags.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Mike Chantrey
Intermediate


Joined: 10 Sep 2003
Posts: 234
Topics: 1
Location: Wansford

PostPosted: Tue Jun 01, 2004 7:01 am    Post subject: Reply with quote

kris, your code seems to show a basic misunderstanding. 'REPLACE' (and COPY) is done at compile time, once only. It cannot be used to dynamically modify the field names in this way.

Why didn't you just code:
Code:

IF WS-STATE-CODE = "IN" THEN             
   ADD 1 TO WS-IN-SCRIPT-FLAG-BLANK
ELSE
   ADD 1 TO WS-OK-SCRIPT-FLAG-BLANK.   


As Kolusu said, you could use 88 levels as well to have a condition name instead of WS-STATE-CODE = "IN" although I'm not that keen on 88 levels personally as it means I have to look in another part of the code to see what the actual test value is.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group