- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: Copy statement in Cobol
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-28-2008 12:35 AM
тАО02-28-2008 12:35 AM
Copy statement in Cobol
I am coding a program where I have to use the same copybook for both input and output layout.
to avoid ambiguity in variable names I have used the replacing statement .
like
COPY RAPCLODT REPLACING ==RAPCLODT== BY ==RAP-IN==.
The original copybook looks like:
01 RAPCLODT.
05 RAPCLODT-DB-AREA PIC S9(04) COMP.
05 RAPCLODT-DB-RAP PIC X(06).
05 RAPCLODT-ACCT-KEY.
.
.
.
But the replace stament is replacing only the first occurence of the literal.
it looks like
01 RAP-IN.
05 RAPCLODT-DB-AREA PIC S9(04) COMP.
05 RAPCLODT-DB-RAP PIC X(06).
05 RAPCLODT-ACCT-KEY.
.
.
.
Kindly tell me how do i solve this issue.
Reply ASAP.
Thanks in advance,
Karthikeyan.
- Tags:
- COBOL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-28-2008 12:58 AM
тАО02-28-2008 12:58 AM
Re: Copy statement in Cobol
move rapclodt-acct-key of rap-in to rapctodt-acct-key of rap-out.
or use move corresponding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-28-2008 01:24 AM
тАО02-28-2008 01:24 AM
Re: Copy statement in Cobol
The comparison operation starts with the leftmost source text text-word and the first text-matching argument. The compiler compares the entire text-matching argument to an equivalent number of consecutive source text text-words.
***
Thus it only replaces words, not strings.
Wim manual reader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-28-2008 02:14 AM
тАО02-28-2008 02:14 AM
Re: Copy statement in Cobol
COPY RAPCLODT REPLACING ==(RAPCLODT)== BY ==(RAP-IN)==.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-28-2008 02:45 AM
тАО02-28-2008 02:45 AM
Re: Copy statement in Cobol
You will have the () in your source then. You can try replacing ==(X)== by ==Y== instead.
I vaguely remember that HP3000 cobol reacted differently and that strings were replaced instead of words. But I can be wrong.
Wim without compiler.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-28-2008 04:37 AM
тАО02-28-2008 04:37 AM
Re: Copy statement in Cobol
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-29-2008 10:16 AM
тАО02-29-2008 10:16 AM
Re: Copy statement in Cobol
I suggest you make an extra copy in your library, give it a different name, open it and use your editor's features to make a global change to the item-name; then your program will contain two COPY statements (as it does now) but both will be more straight-forward and will make future trouble-shooting and maintenance easier due to reduced confusion opportunity.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-29-2008 11:27 PM
тАО02-29-2008 11:27 PM
Re: Copy statement in Cobol
Yes, "()" is the trick you have to use. We had to ask the ANSI Committee about it decades ago.
Note: Using () would mean that copylib member can't be used without REPLACING.
>I vaguely remember that HP3000 COBOL reacted differently and that strings were replaced instead of words. But I can be wrong.
I worked on that compiler for 14 years. Our COBOLII required () since a "-" didn't separate text-words.
http://docs.hp.com/cgi-bin/doc3k/B3150090013.11820/1
>Richard: The REPLACING statement is available for Structured ANS COBOL, but it is compiler-dependent and the recommendation is to avoid its use.
REPLACE or REPLACING?
REPLACE is COBOL 85 Standard.
But REPLACE won't help in this case, the rules for COPY and REPLACE are the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2008 04:49 AM
тАО03-03-2008 04:49 AM
Re: Copy statement in Cobol
Karthikeyan : pls confirm that it works.
Wim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-04-2008 04:38 AM
тАО03-04-2008 04:38 AM
Re: Copy statement in Cobol
looking at all the replies, i would like to have a say.
these are some of the limitations:
1. I cannot create a copy of the copybook and avoid using the replacing statement.
2. I dont have the authority to change the production copybook either from RAPCLODT to (RAPCLODT) or even ::rapclodt:: (some people suggest the second one too).
If the people who replies have a valid MVS login, try reading a QW on copy.
there are few examples there.
just giving a sample:
actual copybook: copybook1
01 A.
05 B PIC 9(1).
05 C OCCURS 1 TO 9 TIMES DEPENDING ON B PIC X(5). (SAY SOMETHING LIKE THIS).
when a copy statement was issued like:
copy copybook1 replacing a by employee
b by emp-id
c by emp-seat.
it replaces all the a's, b's and c's(note - b is there twice in the cpybook).
but in my example the replacing statement replaced only first occurence.
i do accept all your answers, but can anyone justify the qw in mvs?
or tell the author that he is wrong?
thanks,
karthikeyan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-04-2008 05:03 AM
тАО03-04-2008 05:03 AM
Re: Copy statement in Cobol
If you can't change the rapclodt copymember you will not be able to solve this case.
And if you do change it, you will need to add "replacing ==(X)== by ==RAPCLODT==" where there is no replacing clause.
Wim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-04-2008 03:14 PM
тАО03-04-2008 03:14 PM
Re: Copy statement in Cobol
they do thing differently there
The compiler will tell you about any ambiguity in variable names
01 RAP-IN.
05 RAPCLODT-DB-AREA PIC S9(04) COMP.
05 RAPCLODT-DB-RAP PIC X(06).
05 RAPCLODT-ACCT-KEY.
01 RAP-OUT.
05 RAPCLODT-DB-AREA PIC S9(04) COMP.
05 RAPCLODT-DB-RAP PIC X(06).
05 RAPCLODT-ACCT-KEY.
MOVE RAPCLODT-ACCT-KEY TO
will be flagged by the compiler as an error
MOVE RAPCLODT-ACCT-KEY OF RAP-IN
TO RAPCLODT-ACCT-KEY OF RAP-OUT.
will work
Phil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-04-2008 07:21 PM
тАО03-04-2008 07:21 PM
Re: Copy statement in Cobol
karthikeyan