View previous topic :: View next topic
|
Author |
Message |
bhaskar_kanteti
Active User
Joined: 01 Feb 2007 Posts: 123 Location: Hyderabad
|
|
|
|
Hi,
I had a query.
I had two dimentional array as follows.
05 array-name occurs 4 times.
10 ws-name-1 pic x(4).
10 ws-name-2 pic x(4).
I want to initialise the following values into this two dimentional array.
The values are
name-1 name-1
0001 9996
0002 9999
0015 9995
0004 9997
Could any one of them will help me how to initialse the above values in the two dimentional array. |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Bhaskar,
Quote: |
05 array-name occurs 4 times.
10 ws-name-1 pic x(4).
10 ws-name-2 pic x(4). |
Are you sure the above is a two dimensional table declaration? |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi bhaskar,
Its one dimensional array
Code: |
05 array-name occurs 4 times.
10 ws-name-1 pic x(4).
10 ws-name-2 pic x(4). |
You can initialize it by using
Code: |
PERFORM VARYING I FROM 1 BY UNTIL I>4
INITIALIZE WS-NAME-1(I)
INITIALIZE WS-NAME-2(I)
END-PERFORM |
|
|
Back to top |
|
|
monga
New User
Joined: 18 Apr 2006 Posts: 13
|
|
|
|
Well..this is a 1 dimensional array that you have declared.
You can move the values to the array using the perform statement as Ekta has mentioned.
If in case you want to initialize this array to the values at the declaration stage then you can follow this:
Code: |
05 NAME-LIST.
10 WS-NAME1 PIC X(16) VALUE '0001000200150004'.
10 WS-NAME2 PIC X(16) VALUE '9996999999959997'.
05 NAME-ARRAY REDEFINES NAME-LIST.
10 WS-NAME-1 OCCURS 4 TIMES PIC X(04).
10 WS-NAME-2 OCCURS 4 TIMES PIC X(04).
|
or you can even modify this to have the values stored in the same order as in the original array
Thanks,
monga |
|
Back to top |
|
|
venosol Warnings : 1 New User
Joined: 16 Nov 2006 Posts: 43 Location: Bangalore
|
|
|
|
bhaskar_kanteti wrote: |
Hi,
I had a query.
I had two dimentional array as follows.
05 array-name occurs 4 times.
10 ws-name-1 pic x(4).
10 ws-name-2 pic x(4).
I want to initialise the following values into this two dimentional array.
The values are
name-1 name-1
0001 9996
0002 9999
0015 9995
0004 9997
Could any one of them will help me how to initialse the above values in the two dimentional array. |
That is one dimensional array.
See the below two dimensional array.
01 X PIC 9
01 Y PIC 9
01 WS-GROUP-NAME
05 WS-ARRAY OCCURS 7 TIMES
10 WS-NAME PIC X(10)
10 WS-DTLS OCCURS 5 TIMES
15 WS-ID PIC X(5)
15 WS-DEPT PIC X(6)
PROCEDURE DIVISION
1000-PARA.
PERFORM VARYING X FROM 1 BY 1 UNTIL X > 7
AFTER VARYING Y FROM 1 BY 1 UNTIL Y > 5
ACCEPT WS-NAME(X)
ACCEPT WS-ID(X,Y)
ACCEPT WS-DEPT (X,Y)
END-PERFORM.
STOP RUN.
This will suite your requirement. |
|
Back to top |
|
|
bhaskar_kanteti
Active User
Joined: 01 Feb 2007 Posts: 123 Location: Hyderabad
|
|
|
|
Thank You so much friends......
Sorry for writing it as two dimentional array.
Yes, you all are right......
It is one dimentional ARRAY......
And i got my answer from all of you....
thank you so much... |
|
Back to top |
|
|
|