View previous topic :: View next topic |
Author |
Message |
yadav2005 Intermediate
Joined: 10 Jan 2005 Posts: 348 Topics: 144
|
Posted: Wed Aug 08, 2007 3:49 pm Post subject: need to refer an element within an array |
|
|
Hai all,
I have an internal table as below and i would like to access the field WS-EARN-NUM each item with index.How can i achive it?
If i want to achive WS-DESC 5 th element i can use WS-DESC(WS-IDX) but how to refer WS-NUM.Please help me out ?
Code: |
05 WS-ENTRY OCCURS 10 TIMES
INDEXED BY WS-IDX.
10 WS-KEY.
15 WS-DATE PIC X(10) VALUE SPACES.
15 WS-NUM PIC X(03) VALUE SPACES.
10 WS-DESC PIC X(10) VALUE SPACES.
10 WS-HRS PIC S9(03)V99 COMP-3 VALUE 0.
|
|
|
Back to top |
|
|
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Wed Aug 08, 2007 4:02 pm Post subject: |
|
|
since WS-EARN-NUM is not defined as part of the table, you can't.
Quote: |
If i want to achive WS-DESC 5 th element i can use WS-DESC(WS-IDX)
|
you can access the 5th occurance of WS-DESC by SETting WS-IDX to 5.
If in your carelessness writing this post you meant WS-NUM and not WS-EARN-NUM, you can access any occurance with the syntax WS-NUM(WS-IDX) after SETting WS-IDX to the appropriate occurance.
To the left of the 'Submit' button on the bottom of the page is a 'Preview' button, which is like 'desk-checking'. _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
|
yadav2005 Intermediate
Joined: 10 Jan 2005 Posts: 348 Topics: 144
|
Posted: Wed Aug 08, 2007 4:20 pm Post subject: |
|
|
Thanks dbzTHEdinosauer for the help and i am able to understand and i carelessly mentioned WS-EARN-NUM it should have been WS-NUM and from my next posts i will be careful before posting. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Thu Aug 09, 2007 8:10 am Post subject: |
|
|
yadav2005,
There is nothing special about accessing WS-NUM. It is just the same as any other table element
Code: |
SET WS-IDX TO 5
DISPLAY WS-NUM(WS-IDX)
|
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
|
|