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

Doubt in Replacing in Copy book


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

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Sat Jul 18, 2009 6:34 pm
Reply with quote

Hi all,

I have to replace CTL by WS-CTL in the below copy book.

Code:

10 CTL-NO               PIC S9(9) USAGE COMP.   
10 BNFT-ID-CD           PIC X(5).               
10 PBNF-SEQ-NO          PIC S9(9) USAGE COMP.   
10 PBNF-ORGNLEFF-DT     PIC X(10).               
10 PBNF-CANC-DT         PIC X(10).               
10 PBNF-SRCPSTD-DT      PIC X(10).               


i used below code to replace CTL BY WS-CTL and S9(9) USAGE COMP BY
S9(18). The change i got is achieved for COMP but not with WS-CTL

Code:

10 CTL-NO               PIC S9(18). 
10 BNFT-ID-CD           PIC X(5).   
10 PBNF-SEQ-NO          PIC S9(18). 
10 PBNF-ORGNLEFF-DT     PIC X(10).   
10 PBNF-CANC-DT         PIC X(10).   
10 PBNF-SRCPSTD-DT      PIC X(10).   


Please suggest what changes to be done.

Thanks,
Murali.
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Sat Jul 18, 2009 6:38 pm
Reply with quote

The code used is,

Code:

  COPY D1E7HS05 REPLACING ===CTL=== BY ==WS-CTL==,
                         ==S9(9) USAGE COMP==    BY ==S9(18)==.     



Thanks,

Murali.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Jul 18, 2009 6:52 pm
Reply with quote

==CTL-NO== by ==WS-CTL-NO==
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Sat Jul 18, 2009 7:01 pm
Reply with quote

So no other go????????????? other than using whole variable

==CTL-NO== by ==WS-CTL-NO==

is there any other way to suffix WS- alone?

Thanks,
Murali.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Sat Jul 18, 2009 7:39 pm
Reply with quote

From the COBOL Language Reference manual (link at the top of the page), secdtion 8.1.4.3 on COPY REPLACING rules:
Quote:
The COPY statement with REPLACING phrase can be used to replace parts of words. By inserting a dummy operand delimited by colons into the program text, the compiler will replace the dummy operand with the desired text. Example 3 shows how this is used with the dummy operand :TAG:.

The colons serve as separators and make TAG a stand-alone operand.
It is a common misconception that COPY REPLACING can replace parts of COBOL variables. This is a misconception because COBOL only allows replacement of entire words -- unless a delimiting character such as a colon is used. And COBOL considers the delimiting characters to create a word.

So the answer to your question is the only other way is to change the copy book to include the appropriate tag character around the CTL -- which could adversely affect other programs using the copy book. If you cannot change the copy book, you cannot do what you want other than as Dick suggested.
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 VB to VB copy - Full length reached SYNCSORT 8
No new posts Need COBOL COPY Help in MVS Environment COBOL Programming 4
No new posts Issue after ISPF copy to Linklist Lib... TSO/ISPF 1
No new posts DB2 Table - Image copy unload IBM Tools 2
No new posts How to copy the -1 version of a membe... TSO/ISPF 4
Search our Forums:

Back to Top