View previous topic :: View next topic |
Author |
Message |
krk123 Beginner
Joined: 03 Jun 2003 Posts: 58 Topics: 19
|
Posted: Thu Mar 10, 2005 1:22 pm Post subject: UNSTRING in to a TABLE. |
|
|
Hi,
Could someone please help with this. I am getting errors. I am not sure if this will work or not.
I have declared a table as follows.
05 WS-STRING-TABLE OCCURS 200 TIMES.
10 WS-STRING-DATA PIC X(80).
10 WS-LENGTH PIC 9(06).
I am getting an input file as follows,
MVS,123,TABLE,HTML,12345,999,99 etc..
I am getting a comma delimited file and the file has 200 fields. I am trying to avoid 200 individual fields.
unstring ws-data-record delimited by ','
into ws-string-data(ws-index) varying ws-index from 1 by 1
end-unstring.
I am getting complie error saying Varying is invalid. Could somebody tell me if this is valid. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Thu Mar 10, 2005 3:02 pm Post subject: |
|
|
kr123,
Try this untested version.
Code: |
01 WS-DATA-RECORD PIC X(1600).
01 WS-TABLE.
05 WS-STRING-TABLE OCCURS 200 TIMES.
10 WS-STRING-DATA PIC X(80).
01 WS-SUB PIC S9(04) COMP.
01 WS-PNTR PIC S9(04) COMP VALUE +1.
PROCEDURE DIVISION.
MOVE 'MVS,123,TABLE,HTML,12345,999,99' TO WS-DATA-RECORD
PERFORM VARYING WS-SUB FROM 1 BY 1 UNTIL WS-SUB > 1600
UNSTRING WS-DATA-RECORD DELIMITED BY ','
INTO WS-STRING-DATA(WS-SUB)
WITH POINTER WS-PNTR
END-PERFORM
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
krk123 Beginner
Joined: 03 Jun 2003 Posts: 58 Topics: 19
|
Posted: Thu Mar 10, 2005 8:54 pm Post subject: |
|
|
Thanks Kolusu |
|
Back to top |
|
|
powerhawk Beginner
Joined: 08 Nov 2004 Posts: 28 Topics: 4 Location: Stockholm
|
Posted: Fri Mar 11, 2005 2:16 am Post subject: |
|
|
I'am sorry to blame you Kolusu. But your code open up for a unpredictable adress error. Change to WS-SUB > 200. And the PERFORM statement will be execute for every input record if (I suppose you have more than one record in the file), so you have to initialize WS-PNTR with MOVE 1 TO WS-PNTR before the PERFORM statement.
Cheers
Powerhawk |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Fri Mar 11, 2005 8:46 am Post subject: |
|
|
Powerhawk,
Thanks for pointing the error. As I mentioned earlier it was just an Untested code.
Thanks
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
|
|