Hi,
Could any body please tell me if i can redefine X(11) to X(20).
E.g Before change
05 Var-1.
10 Var-2 PIC X(11).
05 Var-3 PIC X(5)
After Change
05 Var-1.
10 Var-2 PIC X(11).
10 Var-4 REDEFINES Var-2 PIC X(20).
05 Var-3 PIC X(5)
But now in this case, is there a chance that i lose my data because of this change.
If my Input file contains "ABCDEFGHIJKLMNOPQRSTUVWXYZ", my variables will contain these values before any change
Var-2 : ABCDEFGHIJK
Var-3 : LMNOP
Now after redefines will i lose the data for Var-3
Var-4 : ABCDEFGHIJKLMNOPQRST
Var-3 : UVWXY
Please let me know.
Thanks,
Sachin.
Redefine with the larger value.
Moderators: dbzTHEdinosauer, Moderator Group
Sachin,
In ur second case i.e after Change still Var-3 will hold : LMNOP only.
If u redefine with greater length than the variable which is being redefined,
the new variable which u redefined will have VALUE as menitoned below
This VALUE can be KLMNOPQRST as u have given, but it cant be guaranteed that it will always hold the value of KLMNOPQRST because what ever data that will be present in the
file is not always stored continously in the memory sequentailly.But in most of the cases u will get the value KLMNOPQRST but under extreeme cases based on the memory usage by other programs the value may vary.
But yes Var-3 will hold : LMNOP only this value doesnot cahnge.
Well we can run a sample test and confirm the same..will update you
on this once i do a test.
Thanks
Veera.
In ur second case i.e after Change still Var-3 will hold : LMNOP only.
If u redefine with greater length than the variable which is being redefined,
the new variable which u redefined will have VALUE as menitoned below
This VALUE can be KLMNOPQRST as u have given, but it cant be guaranteed that it will always hold the value of KLMNOPQRST because what ever data that will be present in the
file is not always stored continously in the memory sequentailly.But in most of the cases u will get the value KLMNOPQRST but under extreeme cases based on the memory usage by other programs the value may vary.
But yes Var-3 will hold : LMNOP only this value doesnot cahnge.
Well we can run a sample test and confirm the same..will update you
on this once i do a test.
Thanks
Veera.
Veera,
Thank you for your reply.
Here i am not clear that why you are saying the VALUE will be "KLMNOPQRST", which variable are you taking about.
Could you please help me understand, what will be the values of Var2, Var3, Var4 specifically after redefining the variables.
Also once you test the programs, please confirm the correct value.
Thanks,
Sachin.
Thank you for your reply.
Here i am not clear that why you are saying the VALUE will be "KLMNOPQRST", which variable are you taking about.
Could you please help me understand, what will be the values of Var2, Var3, Var4 specifically after redefining the variables.
Also once you test the programs, please confirm the correct value.
Thanks,
Sachin.
Sachin,
05 Var-1.
10 Var-2 PIC X(11).
10 Var-4 REDEFINES Var-2 PIC X(20).
05 Var-3 PIC X(5)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
A B C D E F G H I J K L M N O P Q R S T
Sorry it was a typo error the value is "LMNOPQRST" and not KLMNOPQRST
I am referring this value to the partial positions of what u have defined for VAR-4
starting from postion 12 to 20.
The VAR-4 from 1 to 11 will definitely have the same value as 1 to 11 of VAR-2.
But the value of VAR-4 from 12 to 20 can vary it can be "LMNOPQRST" but
we cannot guarantee that it will always be "LMNOPQRST" since the data
in the INPUT file is not always stored continously in the memory.
It depends on how the data is stored in the meomory after 11th postion
i mean 12 to 20 postion of redefined varaible var-4.
As per ur information given in the post
You have given the value LMNOPQRST from postion 12 to 20 of var-4
based on the assumption that the data in the I/P file will be
stored continously "ABCDEFGHIJKLMNOPQRSTUVWXYZ", and since
from postion 12 u have "LMNOPQRST" so we get
1 to 11 from VAR-2 AND
12 TO 20 FROM I/P->FILE POSTIONS
But this is not always true, the data in postions from 12 to 20 can vary depending
on memory usage but most of the case we get the value as "LMNOPQRST" as per the
file data.But it will vary once in n times if we test randomly.
Values in Varaibles
*******************
Var-2 : ABCDEFGHIJK
Var-4 : ABCDEFGHIJK LMNOPQRST -> We cant 100% say for sure that from postion 12 we will
always have this value.
Var-3 : UVWXY
Thanks
Veera.
05 Var-1.
10 Var-2 PIC X(11).
10 Var-4 REDEFINES Var-2 PIC X(20).
05 Var-3 PIC X(5)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
A B C D E F G H I J K L M N O P Q R S T
Sorry it was a typo error the value is "LMNOPQRST" and not KLMNOPQRST
I am referring this value to the partial positions of what u have defined for VAR-4
starting from postion 12 to 20.
The VAR-4 from 1 to 11 will definitely have the same value as 1 to 11 of VAR-2.
But the value of VAR-4 from 12 to 20 can vary it can be "LMNOPQRST" but
we cannot guarantee that it will always be "LMNOPQRST" since the data
in the INPUT file is not always stored continously in the memory.
It depends on how the data is stored in the meomory after 11th postion
i mean 12 to 20 postion of redefined varaible var-4.
As per ur information given in the post
You have given the value LMNOPQRST from postion 12 to 20 of var-4
based on the assumption that the data in the I/P file will be
stored continously "ABCDEFGHIJKLMNOPQRSTUVWXYZ", and since
from postion 12 u have "LMNOPQRST" so we get
1 to 11 from VAR-2 AND
12 TO 20 FROM I/P->FILE POSTIONS
But this is not always true, the data in postions from 12 to 20 can vary depending
on memory usage but most of the case we get the value as "LMNOPQRST" as per the
file data.But it will vary once in n times if we test randomly.
Values in Varaibles
*******************
Var-2 : ABCDEFGHIJK
Var-4 : ABCDEFGHIJK LMNOPQRST -> We cant 100% say for sure that from postion 12 we will
always have this value.
Var-3 : UVWXY
Thanks
Veera.
Hi Sachin,
COBOL will slap you hand if you redefine a variable with a larger variable, but it will compile it. In my case we get a return 12 and will not link edit however.
The code above, that redefines var-2 with a larger var-4 has the same offsets as the code below. Var-3 offset starts at var-1 + the largest data area in var-1.
If you move ?ABCDEFGHIJKLMNOPQRSTUVWXY? to INPUT-RECORD.
In both coding cases above:
Var-1 will contain ?ABCDEFGHIJKLMNOPQRST?
Var-2 will contain ?ABCDEFGHIJK?
Var-4 will contain ?ABCDEFGHIJKLMNOPQRST?
Var-3 will contain ?UVWXY?
Dave
COBOL will slap you hand if you redefine a variable with a larger variable, but it will compile it. In my case we get a return 12 and will not link edit however.
Code: Select all
01 INPUT-RECORD.
05 Var-1.
10 Var-2 PIC X(11).
10 Var-4 REDEFINES Var-2 PIC X(20).
05 Var-3 PIC X(5)
Code: Select all
01 INPUT-RECORD.
05 Var-1.
10 Var-4 PIC X(20).
10 Var-2 REDEFINES Var-4 PIC X(11).
05 Var-3 PIC X(5)
In both coding cases above:
Var-1 will contain ?ABCDEFGHIJKLMNOPQRST?
Var-2 will contain ?ABCDEFGHIJK?
Var-4 will contain ?ABCDEFGHIJKLMNOPQRST?
Var-3 will contain ?UVWXY?
Dave
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page