Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Replacing variable with FILLER in a Copybook

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Keanehelp

New User


Joined: 27 May 2008
Posts: 70
Location: USA, CA.

PostPosted: Wed Jan 02, 2013 6:22 pm    Post subject: Replacing variable with FILLER in a Copybook
Reply with quote

Lets suppose there is a copy book X having following contents :

Code:
01 Out-rec
  05 A                  pic X(1).
  05 B                  pic X(1).
  05 C                  pic X(1).
  05 WS-FILLER1   pic X(1).


I want to replace WS-FILLER1 with FILLER keyword having value 'Y'.Can anyone let me know how can I do this?

code' d
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Wed Jan 02, 2013 6:27 pm    Post subject: Reply to: Replacing variable with FILLER in a Copybook
Reply with quote

the manual link at the top of the page will tell all You might want to know about variable/field iniytialization
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Wed Jan 02, 2013 6:36 pm    Post subject:
Reply with quote

By typing on the keyboard?

Are you asking about the program impact if you make the change? If so, then we do not have the source code and hence cannot tell you -- you would have to read the code and find out if the variable is used anywhere in any program that brings in the copy book.

If you are asking something else, you will need to explain a lot more about what your question really is before you'll get any meaningful answers.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed Jan 02, 2013 7:14 pm    Post subject: Reply to: Replacing variable with FILLER in a Copybook
Reply with quote

You mean you want tot try COPY ... REPLACING ... but can't get it to distinguish one PIC X(1). from another, so can't get the VALUE on?

As Robert has said, you need to explain what you are trying to do. And why. Say you have a "once-off" requirement to add records to a file, all of them with "Y" in that field; you want to use the existing copybook without change; you don't want to use a MOVE statement because it is too much typing.

I'd type the MOVE. Do it once, "up front", so it doesn't "strain" the CPU putting the same value in each time.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


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

PostPosted: Wed Jan 02, 2013 7:57 pm    Post subject:
Reply with quote

I believe you've a simple problem, but a tough description, in hand. WS-FILLER1 is just any other variable in COBOL, calling it as ws-FILLER1 does not make it FILLER.

You said it's a COPY book then why not change the copybook at first place?
Back to top
View user's profile Send private message
Keanehelp

New User


Joined: 27 May 2008
Posts: 70
Location: USA, CA.

PostPosted: Thu Jan 03, 2013 12:57 pm    Post subject:
Reply with quote

Thanks for replying back.

Since the Question above seems to be confusing to most of you, I am providing the detailed description below :

Lets suppose there is a copy book X having following contents :

Code:
01 Out-rec
  05 A                  pic X(1).
  05 B                  pic X(1).
  05 C                  pic X(1).
  05 WS-FILLER1   pic X(1).
  05 D                  pic 9(2).
  05 WS-FILLER1   pic X(3).


code' d

In the COBOL program using Copybook X, we want to move some value (lets say 'Y') in WS-FILLER1 that comes after variable C.

But since same variable name is used twice in the copybook so it gives an error - ' "WS-FILLER1" was not a uniquely defined name' .


If we replace WS-FILLER1 by keyword FILLER in the Cobol program using following statement :
COPY X Replacing ==WS_FILLER1== BY ==FILLER==.
and since we know that keyword FILLER is usually used with VALUES clause to provide specific values, So is there any way of providing some value (like 'Y') to the first FILLER (having PIC X(1) ) without actually modifying the copybook?
Please note that we can’t use reference modification.

Kindly let me know if something is not clear.Thanks in advance
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Jan 03, 2013 1:04 pm    Post subject:
Reply with quote

First thing I strongly recommend you to go through COBOL manual

Second thing why cant you change the copybook so that variable names are unique?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1715
Location: UK

PostPosted: Thu Jan 03, 2013 2:51 pm    Post subject:
Reply with quote

Your copybook has invalid COBOL syntax so fix it NOW. If you do not then one day someone will come along and 'fix' it and screw everything else up. Note that filler fields do not have to have names but all named fields must have unique names.

And use the code tags when posting code - it makes it easier to read.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Thu Jan 03, 2013 4:57 pm    Post subject:
Reply with quote

First, your provided code will not compile due to the missing period after the Out-rec. If you cannot provide the exact code you are working with, how do you expect anyone to help you?

Quote:
So is there any way of providing some value (like 'Y') to the first FILLER (having PIC X(1) ) without actually modifying the copybook?
Please note that we can’t use reference modification.
Second and seriously, you need to spend a LOT of time reading the COBOL manuals -- there's a link at the top of this page to make it easier for you. If you do spend the time reading, you will find that a variable in COBOL cannot be referenced unless it can be uniquely identified. This means that from the 01 level varaible down, there must be a set of unique variable names to allow access to the variable. You do not have this since you have 2 variables with the same name under the 01 level variable. Hence, what you want to do cannot be done in COBOL without using reference modification on the 01 level, or by modifying the structure to make the WS-FILLER1 variables uniquely identifiable.

Third, if everyone reading your post is confused, have you thought about what that implies? Perhaps the problem is not with the people reading the post but the way you wrote it?

Fourth, there is a forum for beginners and students at Beginners and Students Forum which might be more suited for your skill level. This forum is for professionals.
Back to top
View user's profile Send private message
Keanehelp

New User


Joined: 27 May 2008
Posts: 70
Location: USA, CA.

PostPosted: Thu Jan 03, 2013 4:59 pm    Post subject:
Reply with quote

Hi Pandora

We are not authorized to change the copybook and this is the reason we are finding an alternate solution to it.

Somehow the Filler names are same in the copybook (where the second filler should have been WS-FILLER2).

Since the programs using this copybook does not actually use WS-FILLER1(it just contains spaces), so no error was found uptill now whenever these programs are executed.Now we want to move some value to this variable but because it is not uniquely defined, it is causing error.

I want to know if we can populate such a variable through COBOL program without modifying the copybook?
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Jan 03, 2013 5:18 pm    Post subject:
Reply with quote

Quote:
We are not authorized to change the copybook and this is the reason we are finding an alternate solution to it.

Somehow the Filler names are same in the copybook (where the second filler should have been WS-FILLER2).


I strictly dont agree with you

If you are not authorised and if some who had created this copybook and on program compilation they would have got the error "AMBIGUOS" variable declaration while compile and as Robert points your copybook 01 level doesnt have a period

Not authorised to modify the copybook or have you been asked not to modify the copybook?

Or what you can do is dont use that copybook create a fresh one and solve the problem at first hand yourself?

Also please try to do good reading and help yourself before posting

Experiencing at first hand is always better
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Thu Jan 03, 2013 5:21 pm    Post subject: Reply to: Replacing variable with FILLER in a Copybook
Reply with quote

Quote:
We are not authorized to change the copybook and this is the reason we are finding an alternate solution to it.


if the copybook is badly written IT MUST BE FIXED

it is pretty inconsiderate to waste everybody' s time because somebody inside Your organization refuses to take the only logical action possible
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Thu Jan 03, 2013 5:40 pm    Post subject:
Reply with quote

Keanehelp wrote:
We are not authorized to change the copybook and this is the reason we are finding an alternate solution to it.

The alternate solution is simple: find out who is authorized to change it, point out to that person the error, and have it changed. If heesh refuses to do so, escalate the matter to your boss.

You have been a member of this board for over four and a half years; you presumably have at least that much work experience. If, after that time, your words have no weight in the case of such a blatant error...
Back to top
View user's profile Send private message
Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Thu Jan 03, 2013 5:46 pm    Post subject:
Reply with quote

I did not test the following code but you could REDEFINE your copy.

Code:
      *--- COPYBOOK CODE CANNOT BE CHANGED ---
       01 OUT-REC.                             
          05 A                  PIC X(1).     
          05 B                  PIC X(1).     
          05 C                  PIC X(1).     
          05 WS-FILLER1   PIC X(1).           
          05 D                  PIC 9(2).     
          05 WS-FILLER1   PIC X(3).           
                                               
      *--- REDEFINE COPY CODE FROM ABOVE   ---
       01 OUT-REC-R  REDEFINES OUT-REC.       
          05 OR-A               PIC X(1).     
          05 OR-B               PIC X(1).     
          05 OR-C               PIC X(1).     
          05 OR-WS-FILLER1   PIC X(1).         
          05 OR-D               PIC 9(2).     
          05 OR-WS-FILLER2   PIC X(3).         
                                         
           MOVE 'Y'     TO OR-WS-FILLER1. 
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Thu Jan 03, 2013 6:45 pm    Post subject: Reply to: Replacing variable with FILLER in a Copybook
Reply with quote

I'd also start the process of getting someone who is "authorised" to change the copybook to do so.

If that, somehow, takes too long, I'd go with REDEFINES like Gary.

I would take precautions:

Code:
       01  W-LEN-OUT-REC                 COMP PIC S9(4).
       01  W-LEN-A                       COMP PIC S9(4).
       01  W-LEN-B                       COMP PIC S9(4).
       01  W-LEN-C                       COMP PIC S9(4).
       01  W-ADD-A-PLUS-LEN              POINTER.
       01  FILLER REDEFINES W-ADD-A-PLUS-LEN.
           05  W-ADD-A-PLUS-LEN-N        COMP PIC S9(8).
       01  W-ADD-B-PLUS-LEN              POINTER.
       01  FILLER REDEFINES W-ADD-B-PLUS-LEN.
           05  W-ADD-B-PLUS-LEN-N        COMP PIC S9(8).
       01  W-ADD-C-PLUS-LEN              POINTER.
       01  FILLER REDEFINES W-ADD-C-PLUS-LEN.
           05  W-ADD-C-PLUS-LEN-N        COMP PIC S9(8).
       01  W-ADD-Y-PLUS-LEN              POINTER.
       01  FILLER REDEFINES W-ADD-Y-PLUS-LEN.
           05  W-ADD-Y-PLUS-LEN-N        COMP PIC S9(8).
       01  W-ADD-OUT-REC                 POINTER.
       01  W-ADD-A                       POINTER.
       01  W-ADD-B                       POINTER.
       01  W-ADD-C                       POINTER.
       01  W-ADD-D                       POINTER.
       01  W-ADD-OR-DATA-FOR-Y-VALUE     POINTER.
       01 OUT-REC.
            05 A                  PIC X(1).
            05 C                  PIC X(1).
            05 B                  PIC X(1).
            05 WS-FILLER1   PIC X(1).
            05 D                  PIC 9(2).
            05 WS-FILLER1   PIC X(3).
       01  FILLER REDEFINES OUT-REC.
           05  FILLER              X(3).
           05  OR-DATA-FOR-Y-VALUE PIC X.
       PROCEDURE DIVISION.
           MOVE WHEN-COMPILED           TO W-WHEN-COMPILED
           DISPLAY "STUB43 " W-WHEN-COMPILED
                                                                     
           MOVE LENGTH OF OUT-REC       TO W-LEN-OUT-REC
           MOVE LENGTH OF A             TO W-LEN-A
           MOVE LENGTH OF B             TO W-LEN-B
           MOVE LENGTH OF C             TO W-LEN-C
                                                                     
           SET W-ADD-OUT-REC            TO ADDRESS OF OUT-REC
           SET W-ADD-A                  TO ADDRESS OF A
           SET W-ADD-B                  TO ADDRESS OF B
           SET W-ADD-C                  TO ADDRESS OF C
           SET W-ADD-D                  TO ADDRESS OF D
           SET W-ADD-OR-DATA-FOR-Y-VALUE
                                        TO ADDRESS OF
                                            OR-DATA-FOR-Y-VALUE
                                                                     
           SET W-ADD-A-PLUS-LEN         TO W-ADD-A
           ADD W-LEN-A                  TO W-ADD-A-PLUS-LEN-N
           SET W-ADD-B-PLUS-LEN         TO W-ADD-B
           ADD W-LEN-B                  TO W-ADD-B-PLUS-LEN-N
           SET W-ADD-C-PLUS-LEN         TO W-ADD-C
           ADD W-LEN-C                  TO W-ADD-C-PLUS-LEN-N
           SET W-ADD-Y-PLUS-LEN         TO W-ADD-OR-DATA-FOR-Y-VALUE
           ADD 1                        TO W-ADD-Y-PLUS-LEN-N
                                                                     
           IF W-ADD-A NOT EQUAL TO W-ADD-OUT-REC
               CALL "FRED"
           END-IF
                                                                     
           IF W-ADD-A-PLUS-LEN NOT EQUAL TO W-ADD-B
               CALL "FRED"
           END-IF
                                                                     
           IF W-ADD-B-PLUS-LEN NOT EQUAL TO W-ADD-C
               CALL "FRED"
           END-IF
                                                             
           IF W-ADD-C-PLUS-LEN
           NOT EQUAL TO W-ADD-OR-DATA-FOR-Y-VALUE
               CALL "FRED"
           END-IF
                                                             
           IF W-ADD-Y-PLUS-LEN
           NOT EQUAL TO W-ADD-D
               CALL "FRED"
           END-IF
                                                             
           IF LENGTH OF OUT-REC
             NOT EQUAL TO +9
               CALL "FRED"
           END-IF
                                                             
           MOVE "Y"                     TO OR-DATA-FOR-Y-VALUE
                                                             

         


This is to be done "first time only" in the program. The idea is that if someone changes the copybook where it might impact your REDEFINES, at least your program doesn't go trashing anything, instead it fails in testing.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jan 03, 2013 10:52 pm    Post subject:
Reply with quote

Hello,

I suppose there is some offense intended, but what doofus in your organization insists that an error should be "left alone" . . .

While you can put a band-aid on it (reference modification or the out-of-the-copybook redefines, they will corrupt data (or abend) if the copybook is modified someday.

"Someone" is responsible for this copybook and they should change it (or provide a new, correct copybook to replace the incorrect code).
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Copybook structure in Load module Vai123 COBOL Programming 7 Fri Sep 16, 2016 8:29 pm
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts OPC JCL Variable passion_sujesh IBM Tools 5 Fri Jul 01, 2016 4:21 am
No new posts JOINKEYs and Variable files migusd SYNCSORT 8 Fri Jun 17, 2016 3:16 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us