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

COPY Replacing to replace a variable prefix


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

New User


Joined: 07 Aug 2007
Posts: 27
Location: chennai

PostPosted: Wed Aug 27, 2008 12:09 pm
Reply with quote

We have copybook variables prefixed as (PFX).

Ex: (PFX)-OCC-SEC X(05).

We need to have the replaced variable as OCC-SEC.

We tried giving, COPY XXXXXXXX REPALCING ==(PFX)-== BY ====

This did not work. It threw a compilation error due to the presence of "-". Please advise.

Thanks.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Wed Aug 27, 2008 12:15 pm
Reply with quote

Thilak,

Quote:
It threw a compilation error due to the presence of "-".


what was the error? Post the description please

Quote:
COPY XXXXXXXX REPALCING ==(PFX)-== BY ====


Btw, Change "REPALCING" to "REPLACING"
Back to top
View user's profile Send private message
thilakvs
Warnings : 1

New User


Joined: 07 Aug 2007
Posts: 27
Location: chennai

PostPosted: Wed Aug 27, 2008 12:25 pm
Reply with quote

*** Sorry that was a mistake

It is COPY XXXXXXXX REPLACING ==(PFX)-== BY ====

Error description:

Code:
01  (PFX)-OCC-SEC

"01" was invalid.  Scanning was resumed at the next area "A" item,
level-number, or the start of the next clause.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Wed Aug 27, 2008 12:32 pm
Reply with quote

Thilak,

Few more points.

Do you have a 01 level before the COPY statement. Like


Code:
01 WS-AREA
     COPY XXXXXXXX REPALCING ......



If yes, Do you have a 01 level in your COPYBOOK which is replaced???
Back to top
View user's profile Send private message
thilakvs
Warnings : 1

New User


Joined: 07 Aug 2007
Posts: 27
Location: chennai

PostPosted: Wed Aug 27, 2008 12:37 pm
Reply with quote

The copybook is like this

Code:
01  (PFX)-OCC-RECORD.
    05  (PFX)-OCC-RECID                        PIC X(03).
    05  (PFX)-OCC-CLEARING-NUM                 PIC X(05).


I need to have the replaced variable as,

Code:
01   OCC-RECORD.
    05  OCC-RECID                        PIC X(03).
    05  OCC-CLEARING-NUM                 PIC X(05).
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Wed Aug 27, 2008 12:44 pm
Reply with quote

Thilak,

You answered my second question.

Answer this one too.

Quote:
Do you have a 01 level before the COPY statement. Like


Post those two lines(COPY statement line and the line above that) from your COBOL code.
Back to top
View user's profile Send private message
thilakvs
Warnings : 1

New User


Joined: 07 Aug 2007
Posts: 27
Location: chennai

PostPosted: Wed Aug 27, 2008 12:49 pm
Reply with quote

It doesnt have 01 variable.

the code is as follows.

Code:
01  HOLD-NEQ-DATE               PIC 9(6).

COPY OPSOCCAL REPLACING ==(PFX)== BY ====.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Wed Aug 27, 2008 1:40 pm
Reply with quote

Thilak,

Quote:
01 HOLD-NEQ-DATE PIC 9(6).

COPY OPSOCCAL REPLACING ==(PFX)== BY ====.


You have a 01 level variable here and then a 01 level again in a copybook.

Hence after the execution of this statement you will have 2 01 levels and this might be an issue.

Remove the foll statement from the code and try

Quote:
01 HOLD-NEQ-DATE PIC 9(6).


Let us know the findings.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Aug 27, 2008 2:31 pm
Reply with quote

??????????????????????????? <<<<(sarcasm deleted)

a previous 01 level has no effect on a copybook which starts with an 01 level.

dont think you can remove the prefix and the hypen.

you are going to have to generate with a prefix of sometype.

if you read the documentation, the idea behind a prefix was to allow for different prefixes, not a 'NO PREFIX' situation.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Aug 27, 2008 6:09 pm
Reply with quote

If you created the copybook or you can change it, you can do the following: Change all occurrances of PFX:
Code:
05  (PFX)-OCC-RECID                        PIC X(03).
to
Code:
05  (PFX-)OCC-RECID                        PIC X(03).

In the pgm code:
Code:
COPY XXXXXXXX REPLACING ==(PFX-)== BY ====
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Aug 27, 2008 6:21 pm
Reply with quote

Hi,

Hypen is not permitted in RELACING..or should I say they dont' get replaced. I usuall use this -

Code:
COPY XXRPTSUM REPLACING ==:TAG:== BY == ==.


Where XXRPTSUM is like-
Code:
05 :TAG:SUMMARY-DATA.                               
  07 :TAG:SUM-COUNT           PIC S9(03)    COMP-3.


Hope it conveys the message..
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Aug 28, 2008 6:07 am
Reply with quote

You're right, Anju. It's been a while since I used it, and I'm getting old. icon_sad.gif
To get a prefix, code:
Code:
COPY XXRPTSUM REPLACING ==:TAG:== BY ==ABC-==.


You can use hyphens as above. You'll wind upwith:
Code:
05 ABC-SUMMARY-DATA.                               
  07 ABC-SUM-COUNT           PIC S9(03)    COMP-3.
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: Thu Aug 28, 2008 6:56 am
Reply with quote

Quote:
and I'm getting old.
Beats the alternative. . .
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Aug 28, 2008 11:33 am
Reply with quote

Quote:
You're right, Anju
But you spelled my name incorrectly ..grin...
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 Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top