View previous topic :: View next topic
|
Author |
Message |
simham
New User
Joined: 29 Sep 2005 Posts: 12
|
|
|
|
Can we assign some initial value to comp-3 field which is used as part of a table declaration.
Eg:
01 T2.
05 T OCCURS 5 TIMES
DEPENDING ON T-OBJ.
10 Z PIC XX VALUE "BB".
[i] 10 W PIC S9(5) COMP-3 VALUE 123.[/i]
10 V PIC S9(5) VALUE 123.
when i display the above T2 variable, the comp-3 field has a value spaces.
Is there any way to assign some initial value ? |
|
Back to top |
|
|
priya
Moderator
Joined: 24 Jul 2003 Posts: 568 Location: Bangalore
|
|
|
|
Have you tried this:
01 T2 VALUE ZEROES.
05 T ...... |
|
Back to top |
|
|
simham
New User
Joined: 29 Sep 2005 Posts: 12
|
|
|
|
I have,
but throws a compilation error stating value clause is discarded on the group variable as it has comp-3(usage display) field.
even it would be great if i can assign diff values to the each varible(as i mentined in the query), rather having a single value to the total table. |
|
Back to top |
|
|
Hames
New User
Joined: 03 Oct 2005 Posts: 49
|
|
|
|
Hi Simham,
OCCURS clause & VALUE clause both should not be used in the same statement.
You can verify this with the same example, delete the second line and compile it now. Check it again it will give error.
The solution for this will be: First you have to define the array variables with Value clause (initializing) and then you can rename it with the Occurs Clause.
Check with this, Let me know whether you got the result as correct or not. |
|
Back to top |
|
|
Sridevi_C
Active User
Joined: 22 Sep 2005 Posts: 104 Location: Concord, New Hampshire, USA.
|
|
|
|
Hi,
Correction in Hames solution: After initializing the array/table with VALUE clause, REDEFINES can be used with OCCURS clause and "NOT RENAMES"
Regards,
Sridevi. |
|
Back to top |
|
|
Hames
New User
Joined: 03 Oct 2005 Posts: 49
|
|
|
|
Hi Simham,
OCCURS clause & VALUE clause both should not be used in the same statement.
You can verify this with the same example, delete the second line and compile it now. Check it again it will give error.
The solution for this will be: First you have to define the array variables with Value clause (initializing) and then you can rename it with the Occurs Clause.
Check with this, Let me know whether you got the result as correct or not. |
|
Back to top |
|
|
simham
New User
Joined: 29 Sep 2005 Posts: 12
|
|
|
|
Hames,
I believe thats(valus clause) not a problem though, i have tested the same.
Here is the code:
01 T2.
05 T-OBJ PIC 9 VALUE 5.
05 T OCCURS 5 TIMES
DEPENDING ON T-OBJ.
10 X PIC XX VALUE "AA".
10 Y PIC 99 VALUE 19.
10 Z PIC XX VALUE "BB".
* 10 W PIC S9(5) COMP-3.
10 V PIC S9(5) VALUE ZEROS.
and the result is:
T2: 5AA19BB0000{AA19BB0000{AA19BB0000{AA19BB0000{AA19BB0000{
you are correct on the statement, value clause can't be on the occurs clause, but here i believe it is fine as the value clause is not on the same variable using occurs clause.(if i am not wrong)
Thanks & Regards,
Narasimha |
|
Back to top |
|
|
Sridevi_C
Active User
Joined: 22 Sep 2005 Posts: 104 Location: Concord, New Hampshire, USA.
|
|
|
|
Hi,
I guess,there shouldn't be problem in initializing COMP-3 data name within table. Can you double check the code? Experts,help!
Thanks in advance!
Sridevi. |
|
Back to top |
|
|
simham
New User
Joined: 29 Sep 2005 Posts: 12
|
|
|
|
FYI,
Here is the code:
01 T2.
05 T-OBJ PIC 9 VALUE 5.
05 T OCCURS 5 TIMES
DEPENDING ON T-OBJ.
10 X PIC XX VALUE "AA".
10 Y PIC 99 VALUE 19.
10 Z PIC XX VALUE "BB".
10 W PIC S9(5) COMP-3 VALUE 123.
10 V PIC S9(5) VALUE ZEROS.
and the result:
T2: 5AA19BB 0000{AA19BB 0000{AA19BB 0000{AA19BB 0000{AA19BB 0000{ |
|
Back to top |
|
|
amolsun
New User
Joined: 06 Aug 2005 Posts: 4 Location: pune
|
|
|
|
hi guys
myself amolrao
i liked ur questions
i think we cant write value clause in occuers but in group item we can write value clause.like
01 s value abc
02 a pic x(3) occurs 5 times
02 y pic 9(4) occurs 3 times
then all values of a will be abc.
if anything wrong pls rectify n rply.
thnks n regard. |
|
Back to top |
|
|
Sridevi_C
Active User
Joined: 22 Sep 2005 Posts: 104 Location: Concord, New Hampshire, USA.
|
|
|
|
Hi amolsun,
Value clause is not the problem here,as stated by simham.Discussion is about initializing COMP-3 dataname within a table
Regards,
Sridevi. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Simham,
Try this:
When you view the display of the table entry, enter "hex on" in the cmd line (I assume you're using ISPF). I think that the "spaces" you see are unprintable chars and what's being displayed is X'00123C'.
Another way to verify this is to display the W variable only, e.g.:
DISPLAY W(1)
It should display "0012C". The reason: DISPLAY converts COMP-3 digits to display format (except the low-ord digit) for elementary items (W), but doesn't do it for group items (T2). |
|
Back to top |
|
|
simham
New User
Joined: 29 Sep 2005 Posts: 12
|
|
|
|
Sorry for the late reply,
Hi Mmwife,
i have checked the same, infact i realized that comp-3 field(of the table item) is not properly initialized when the program has abended with S0C-7, later i have moved zeros to each occurance of the field( only of that comp-3 field), it went fine.
then to verify the same i wrote a sample program, which i had given in the query.
solution can be moving / initializing each occurance, but the only problem is if the occurances are more( like in hundreds and thousandas), it will be tough, that why i am looking forward for the opt solution for this,
it will be great, if some one finds it out.
Thanks,
Simha |
|
Back to top |
|
|
simham
New User
Joined: 29 Sep 2005 Posts: 12
|
|
|
|
Correction from my side,
it is working as givem by mmwife.
Thanks to all!!
Regards,
Simha |
|
Back to top |
|
|
|