View previous topic :: View next topic
|
Author |
Message |
Vignesh Sid
New User
Joined: 04 Sep 2017 Posts: 43 Location: India
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
'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 |
|
|
Vignesh Sid
New User
Joined: 04 Sep 2017 Posts: 43 Location: India
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
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 |
|
|
Vignesh Sid
New User
Joined: 04 Sep 2017 Posts: 43 Location: India
|
|
|
|
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 |
|
|
|