View previous topic :: View next topic |
Author |
Message |
moulisea Beginner
Joined: 18 Nov 2007 Posts: 9 Topics: 3
|
Posted: Thu Nov 22, 2007 11:43 pm Post subject: indexing |
|
|
can we comapre an index to a numeric value
eg:
a is a index
can i compare
if (a=1)
is it right? |
|
Back to top |
|
 |
vivek1983 Intermediate

Joined: 20 Apr 2006 Posts: 222 Topics: 24
|
Posted: Fri Nov 23, 2007 12:47 am Post subject: |
|
|
moulisea,
Are u referring to internal table index?
If yes, then yes... you can compare the index with numeric field.
Find below an example:
Code: |
05 WS-TBL-ENTRIES OCCURS 08 TIMES
INDEXED BY INDEX-TAB.
10 WS-TBL-FLD-1 PIC X(10) VALUE SPACES.
10 WS-TBL-FLD-2 PIC S9(6) PACKED-DECIMAL.
10 WS-TBL-FLD-3 PIC S9(6) PACKED-DECIMAL.
IF INDEX-TAB = 2
----
---
END-IF.
|
_________________ Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay) |
|
Back to top |
|
 |
moulisea Beginner
Joined: 18 Nov 2007 Posts: 9 Topics: 3
|
Posted: Fri Nov 23, 2007 1:33 am Post subject: INDEX |
|
|
CAN WE define a index like below:
05 ws-sub usage is index |
|
Back to top |
|
 |
warp5 Intermediate

Joined: 02 Dec 2002 Posts: 429 Topics: 18 Location: Germany
|
Posted: Fri Nov 23, 2007 1:57 am Post subject: |
|
|
Yes, the compiler will take care of your compare. Why don't you try it out? |
|
Back to top |
|
 |
moulisea Beginner
Joined: 18 Nov 2007 Posts: 9 Topics: 3
|
Posted: Fri Nov 23, 2007 7:32 am Post subject: |
|
|
how do we initialize an index.
i used
initialize ws-var-a
where ws-var-a is an index.
it didnt work. |
|
Back to top |
|
 |
Sreejith Intermediate
Joined: 02 Dec 2002 Posts: 155 Topics: 25 Location: N.Ireland
|
Posted: Fri Nov 23, 2007 9:35 am Post subject: |
|
|
SET ws-var-a to 1
Or If you want to set it to zero
SET ws-var-a to WS-ZERO where WS-ZERO is defined as PIC 9 VALUE ZERO |
|
Back to top |
|
 |
Terry_Heinze Supermod
Joined: 31 May 2004 Posts: 391 Topics: 4 Location: Richfield, MN, USA
|
Posted: Fri Nov 23, 2007 3:17 pm Post subject: |
|
|
moulisea,
You are asking very basic questions that are easily looked up in the COBOL Language Reference Manual. _________________ ....Terry |
|
Back to top |
|
 |
|
|