how to display the value of the index variable in cobol

Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS
dhiviya
Posts: 4
Joined: Mon Oct 29, 2007 4:57 pm
Skillset: beginner of mainframe
Referer: browsing

how to display the value of the index variable in cobol

Postby dhiviya » Mon Oct 29, 2007 5:48 pm

hi,

can any body say the answer fot this question?

how to display the value of the index variable?

CICS Guy
Posts: 246
Joined: Wed Jun 20, 2007 4:08 am

Re: how to display the value of the index variable in cobol

Postby CICS Guy » Mon Oct 29, 2007 6:43 pm

dhiviya wrote:how to display the value of the index variable?
Have you tried to just display it? My manual doesn't forbid it.....
You could always set a numeric integer to the index and display that.....

abkumarch
Posts: 21
Joined: Tue Oct 30, 2007 3:14 am
Skillset: cobol,jcl,vsam, db2
Referer: google

Re: how to display the value of the index variable in cobol

Postby abkumarch » Tue Oct 30, 2007 7:03 pm

ok i guess, u ve to define the index variable in the ws-section using INDEXED BY clause, now u can display it.. i ve not trird

u plz tr this and tell me.

kiran_ragam
Posts: 5
Joined: Sun Dec 09, 2007 3:27 pm
Skillset: cobol,jcl,vsam,cics,db2
Referer: google search

Re: how to display the value of the index variable in cobol

Postby kiran_ragam » Sun Dec 09, 2007 4:29 pm

WE CAN'T DISLAY INDEX VARIABLE VALUE

User avatar
dick scherrer
Global moderator
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am

Re: how to display the value of the index variable in cobol

Postby dick scherrer » Mon Dec 10, 2007 12:21 am

Hello,

Turn off your CAPS. . .

Yes, we can. Simply set some ws variable to the index and display that.
Hope this helps,
d.sch.

sureshbabu
Posts: 7
Joined: Tue Dec 18, 2007 12:39 pm
Skillset: cobol
jcl
db2
cics
Referer: from friend

Re: how to display the value of the index variable in cobol

Postby sureshbabu » Fri Jan 04, 2008 2:16 pm

index variable can be displayed by using
set clsause
try this

qykong1986
Posts: 10
Joined: Thu Mar 19, 2009 11:28 am
Skillset: jcl,cobol,cics.
Referer: it is very famous
Location: Shanghai.

Re: how to display the value of the index variable in cobol

Postby qykong1986 » Mon Mar 23, 2009 7:11 pm

I think you can't dipaly index variable. Index variable is S9(8) comp, takes up one word, it means the physical address in the main storage.Use set index-variable to integer, set index-variable up (down) by integer to assign value to index-variable.
I think what you can display is script, script is an integer, can be displayed.
--------------------------------------------------------------------------------------------------------------
Thanks ^_^
Hubery.

User avatar
dick scherrer
Global moderator
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am

Re: how to display the value of the index variable in cobol

Postby dick scherrer » Tue Mar 24, 2009 12:55 am

Hello,

I think you can't dipaly index variable.
Why do you believe this? To repeat:
Yes, we can. Simply set some ws variable to the index and display that.

Index variable is S9(8) comp, takes up one word, it means the physical address in the main storage.
How does this relate to the question?
I think what you can display is script, script is an integer, can be displayed.
This surely needs clarification. . . :?
Hope this helps,
d.sch.

qykong1986
Posts: 10
Joined: Thu Mar 19, 2009 11:28 am
Skillset: jcl,cobol,cics.
Referer: it is very famous
Location: Shanghai.

Re: how to display the value of the index variable in cobol

Postby qykong1986 » Tue Mar 24, 2009 10:21 am

Simply set some ws variable to the index and display that.

I follow the scentence and code such program.

05-ws-num1 pic s9(4) comp-3.
05 ws-num2 pic s9(4) comp.
05 ws-num3 pic s9(4).
05 ws-num4 pic 9(4).
SET index to 1.
SET index up by 2.
MOVE index TO WS-NUM1 WS-NUM2 WS-NUM3 WS-NUM4.
DISPLAY' INDEX-VARIABLE' WS-NUM1 WS-NUM2 WS-NUM3 WS-NUM4.
The SYSOUT is 'INDEX-VARIABLE 00030003000B0003'

But still i believe this is not the internal value of the INDEX-VARIABLE, this value is just like subscript.
Index variable is S9(8) comp, takes up one word, it means the physical address in the main storage.
How does this relate to the question?

I think the internal value of INDEX variable is physical address, so how can we display the physical address :cry:
though, to a COBOL PROGRAMMER, the knowledge of internal representation of of an index is of no importance.
--------------------------------------------------------------------------------------------------------------
Thanks ^_^
Hubery.

User avatar
dick scherrer
Global moderator
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am

Re: how to display the value of the index variable in cobol

Postby dick scherrer » Wed Mar 25, 2009 12:19 am

Hello,

Code: Select all

       01  ZZ-STUFF.                                             
           05  ZZ PIC XXX OCCURS 100 TIMES INDEXED BY ZZ-INX.     
       01  ZZ-N PIC 9(8) COMP VALUE ZEROS.                       

           SET ZZ-INX TO 1.               
           MOVE '111' TO ZZ(ZZ-INX).     
           DISPLAY ZZ(ZZ-INX).           
           SET ZZ-N TO ZZ-INX.           
           DISPLAY ZZ-N.                 
           SET ZZ-INX UP BY 50.           
           MOVE 'U51' TO ZZ(ZZ-INX).     
           DISPLAY ZZ(ZZ-INX).           
           SET ZZ-N TO ZZ-INX.           
           DISPLAY ZZ-N.                 


gives:

Code: Select all

111       
00000001   
U51       
00000051   

This

Code: Select all

                MOVE ZZ-INX TO ZZ-N.

generates this error

Code: Select all

IGYPS2074-S   "ZZ-INX" WAS DEFINED AS A TYPE THAT WAS INVALID IN THIS CONTEXT.
so i don't know how your posted example successfully compiled. . .
Hope this helps,
d.sch.