Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Moving values to a variable of copybook under 01- variable

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

New User


Joined: 04 Sep 2017
Posts: 22
Location: India

PostPosted: Wed Sep 06, 2017 1:04 pm    Post subject: Moving values to a variable of copybook under 01- variable
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: 1922
Location: UK

PostPosted: Wed Sep 06, 2017 1:58 pm    Post subject:
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: 22
Location: India

PostPosted: Wed Sep 06, 2017 2:42 pm    Post subject:
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: 1247
Location: Israel

PostPosted: Wed Sep 06, 2017 7:46 pm    Post subject:
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: 1922
Location: UK

PostPosted: Wed Sep 06, 2017 10:15 pm    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1817
Location: NY,USA

PostPosted: Thu Sep 07, 2017 2:00 am    Post subject:
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: 22
Location: India

PostPosted: Thu Sep 07, 2017 11:36 am    Post subject:
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    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 Move from Comp3 variable to Edited Va... Revathy.nair0485 COBOL Programming 7 Fri Nov 03, 2017 3:30 pm
This topic is locked: you cannot edit posts or make replies. Can a alphanumeric data be moved to a... nico_neoz COBOL Programming 10 Mon Oct 30, 2017 8:28 am
No new posts Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm
No new posts Moving UDB database to Db2 on z/OS Keith Hooley DB2 4 Wed Sep 27, 2017 12:38 am
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us