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

Assigning value clause to comp-3 filed of a table


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

New User


Joined: 29 Sep 2005
Posts: 12

PostPosted: Mon Oct 03, 2005 1:58 pm
Reply with quote

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
View user's profile Send private message
priya

Moderator


Joined: 24 Jul 2003
Posts: 568
Location: Bangalore

PostPosted: Tue Oct 04, 2005 12:30 pm
Reply with quote

Have you tried this:

01 T2 VALUE ZEROES.

05 T ......
Back to top
View user's profile Send private message
simham

New User


Joined: 29 Sep 2005
Posts: 12

PostPosted: Tue Oct 04, 2005 1:58 pm
Reply with quote

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
View user's profile Send private message
Hames

New User


Joined: 03 Oct 2005
Posts: 49

PostPosted: Tue Oct 04, 2005 7:35 pm
Reply with quote

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
View user's profile Send private message
Sridevi_C

Active User


Joined: 22 Sep 2005
Posts: 104
Location: Concord, New Hampshire, USA.

PostPosted: Tue Oct 04, 2005 7:45 pm
Reply with quote

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
View user's profile Send private message
Hames

New User


Joined: 03 Oct 2005
Posts: 49

PostPosted: Tue Oct 04, 2005 8:36 pm
Reply with quote

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
View user's profile Send private message
simham

New User


Joined: 29 Sep 2005
Posts: 12

PostPosted: Tue Oct 04, 2005 9:19 pm
Reply with quote

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
View user's profile Send private message
Sridevi_C

Active User


Joined: 22 Sep 2005
Posts: 104
Location: Concord, New Hampshire, USA.

PostPosted: Tue Oct 04, 2005 11:04 pm
Reply with quote

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
View user's profile Send private message
simham

New User


Joined: 29 Sep 2005
Posts: 12

PostPosted: Wed Oct 05, 2005 9:07 am
Reply with quote

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
View user's profile Send private message
amolsun

New User


Joined: 06 Aug 2005
Posts: 4
Location: pune

PostPosted: Sun Oct 09, 2005 10:28 am
Reply with quote

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. icon_smile.gif
Back to top
View user's profile Send private message
Sridevi_C

Active User


Joined: 22 Sep 2005
Posts: 104
Location: Concord, New Hampshire, USA.

PostPosted: Sun Oct 09, 2005 11:19 am
Reply with quote

Hi amolsun,
Value clause is not the problem here,as stated by simham.Discussion is about initializing COMP-3 dataname within a table icon_cry.gif
Regards,
Sridevi.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Oct 09, 2005 10:44 pm
Reply with quote

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
View user's profile Send private message
simham

New User


Joined: 29 Sep 2005
Posts: 12

PostPosted: Fri Oct 14, 2005 9:52 am
Reply with quote

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
View user's profile Send private message
simham

New User


Joined: 29 Sep 2005
Posts: 12

PostPosted: Fri Oct 14, 2005 3:39 pm
Reply with quote

Correction from my side,

it is working as givem by mmwife.

Thanks to all!!

Regards,
Simha
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 Unload and Load ISPF Table TSO/ISPF 4
No new posts ISPF Table to add a new column TSO/ISPF 1
No new posts Inserting into table while open selec... DB2 1
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top