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

Replace Command in COBOL COPY statement


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

New User


Joined: 20 Sep 2005
Posts: 26

PostPosted: Tue May 29, 2007 7:27 pm
Reply with quote

Hi,

Please anyone help us answering my question regarding the below replace command used in COBOL.

Command is: COPY COPYBOOKNAME REPLACING VALUE-A BY VALUE-B

Que: Should the level at which Value-A and Value-B are defined be same?[/b]
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue May 29, 2007 7:40 pm
Reply with quote

If I understand your question, they do not need to be.
If you posted an example of your question, it might make things clearer.
Back to top
View user's profile Send private message
pankajayee

New User


Joined: 20 Sep 2005
Posts: 26

PostPosted: Wed May 30, 2007 12:23 pm
Reply with quote

Hi,

Thanks for the reply. Please see the example below:

01 VALUE-A
05 VALUE-B
88 VALUE-C .......
88 VALUE-D .......
88 VALUE-E ........
05 ........................
05 ........................

I want to replace the VALUE-D with the values defined in the working storage. As VALUE-D is at 88 level, how can we define the value in working storage.

Could you please provide me the brief explanation on the solution.
Pankaj.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Wed May 30, 2007 12:32 pm
Reply with quote

Pankaj,
It is still not clear. Please make your example more clear.
Back to top
View user's profile Send private message
kussu
Warnings : 1

New User


Joined: 16 May 2007
Posts: 33
Location: India

PostPosted: Wed May 30, 2007 9:26 pm
Reply with quote

As per my understanding, you are asking "can we able to repalce the values of the variables which are declared at different levels" isn't it?

i think it is possible, but not with 88, 66, 77 levels

Thanks
Kussu
Back to top
View user's profile Send private message
Pons

New User


Joined: 25 May 2007
Posts: 61
Location: Coimbatore

PostPosted: Sat Jun 02, 2007 10:09 pm
Reply with quote

I dont think it is not possible.

It is possible for all the levels. What ever present in the copy book with matching charecter that will be replace.

05 :A:-SEARCH-PARMS.
10 :A:-SEARCH-AGENCY OCCURS 300 TIMES
INDEXED BY :A:-AGT-NDX.
15 :A:-SEARCH-OCCURS OCCURS 200 TIMES
INDEXED BY :A:-PS-NDX.
20 :A:-SEARCH-POL-NUMBER.
25 :A:-SEARCH-SYM PIC X(03).
88 :A:-CHECK VALUE '111'.

COPY PW760C REPLACING ==:A:== BY == LK ==.

It will replace all the :A: to LK. there is no constraint for replacing.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Sat Jun 02, 2007 10:43 pm
Reply with quote

This is a bit of example from the Enterprise Programming Guide chapter about "Producing XML output, Example: enhancing XML output".
If this is a line in a copybook:
Code:
15 CDR-LIFE-BASE-TOT-VALUE-LINE.
   20 CDR-LIFE-BASE-TOT-VALUE PIC X(15).
This copy replacing
Code:
   ==CDR-LIFE-BASE-TOT-VALUE-LINE. 20== by ====
   ==CDR-LIFE-BASE-TOT-VALUE== by ==TotalValue==.
Will generate this
Code:
15 TotalValue PIC X(15).
I am suprised that the first line with the trailing "20" works (maybe I should test it.....)....

From what I have seen, you can replace just about anything (except the reserved work COPY), try reading a little about the COPY statement.
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: Sun Jun 03, 2007 1:47 am
Reply with quote

Hello,

Please clarify this
Quote:
I want to replace the VALUE-D with the values defined in the working storage


Do you want to replace 88-level values at run-time with values that were not known when the program was compiled? If that is what you want, you need to implement in a different way.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Sun Jun 03, 2007 2:01 am
Reply with quote

Geez, if he meant at run-time, no way.
I'd hope he can tell the difference between compile-time and run-time..... icon_rolleyes.gif
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 RACF - Rebuild SETROPTS command which... All Other Mainframe Topics 3
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Routing command Address SDSF to other... TSO/ISPF 2
Search our Forums:

Back to Top