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

Moving values to a variable of copybook under 01- variable


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

New User


Joined: 04 Sep 2017
Posts: 43
Location: India

PostPosted: Wed Sep 06, 2017 1:04 pm
Reply with quote

Let us consider a variable like below:

01 variable1 external.
copybook1.
copybook2.
eject

copybook1
05 var-a pic 9(2).

copybook2
05 var-a pic 9(2).

Now I have to move a value 80 to var-a of copybook 1.

So I did the following:
Move 80 to var-a of copybook1 of variable1

While compiling I am getting the below error:
var-a of copybook1 of variable1 WAS NOT DEFINED AS A DATA-NAME.

Could you please suggest me a way for doing this code?

Thanks in advance!
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2454
Location: Hampshire, UK

PostPosted: Wed Sep 06, 2017 1:58 pm
Reply with quote

'copybook1' and 'copybook2' are not data names. Data names have level numbers. In your example variable1 is a data name (level 1) and both var-a variables are data names (level 5). You are coding var-a of variable1 twice in your example.
You need to put an intermediate level in eg.
Code:
01 variable1.
   02 first.
      copy copybook1.
   02 second.
      copy copybook2.

You can refer as var-a of first or var-a of second.

Or make sure that you only have 1 var-a
Back to top
View user's profile Send private message
Vignesh Sid

New User


Joined: 04 Sep 2017
Posts: 43
Location: India

PostPosted: Wed Sep 06, 2017 2:42 pm
Reply with quote

Thanks Nic. I have made the changes as suggested and the code compilation is good.

Now let us consider the value 80 (length 2) is coming from an external site to this 01 variable1.

In this case 01 variable1 size is 4 as it has two copybooks under it. So while running the program I am getting an information like below:

The length of external data record variable1 in program PGM1 did not match the existing length of the record.

Could you suggest me any way that this check should not be done. This check is not needed because we will hadlink the movement of values to correct copybook.

Thanks in advance!
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Wed Sep 06, 2017 7:46 pm
Reply with quote

Apparently, what you need is:
Code:
01 variable1 external.
    copy copybook1.

01 variable2.
    copy copybook2.

now you can
Code:
    move var-a of variable1 to var-a of variable2
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2454
Location: Hampshire, UK

PostPosted: Wed Sep 06, 2017 10:15 pm
Reply with quote

Or you could redefine the shorter field over the longer one - but you woud need some way of knowing which variable you are processing - maybe if the larger variable was set to low values you could check the last two bytes for low values and process accordingly.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3076
Location: NYC,USA

PostPosted: Thu Sep 07, 2017 2:00 am
Reply with quote

Quote:
In this case 01 variable1 size is 4 as it has two copybooks under it. So while running the program I am getting an information like below:

The length of external data record variable1 in program PGM1 did not match the existing length of the record

Is there any abend? if it's informational then why do you care?
Back to top
View user's profile Send private message
Vignesh Sid

New User


Joined: 04 Sep 2017
Posts: 43
Location: India

PostPosted: Thu Sep 07, 2017 11:36 am
Reply with quote

Yes the info is too informative. The question was defining 2 copybooks under same 01- variable and not different 01- variables.

01 variable1 external.
copy copybook1.

01 variable2.
copy copybook2.
This info made me to go ahead with changes:

01 variable1
05 var-a
copybook 1
eject
05 var-b
copybook 2 redefines copybook1
eject

Now while running the program, the copybook which maches the external data's length is picked up.

Thank you all for helping!
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 REXX/CMS How to place command console... CLIST & REXX 4
No new posts Replacing FILLER with FILLER<SeqNu... DFSORT/ICETOOL 2
No new posts how to eliminate null indicator value... DB2 7
No new posts CA7 count with DATE variable CA Products 0
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
Search our Forums:

Back to Top