MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

UNSTRING in to a TABLE.

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
krk123
Beginner


Joined: 03 Jun 2003
Posts: 58
Topics: 19

PostPosted: Thu Mar 10, 2005 1:22 pm    Post subject: UNSTRING in to a TABLE. Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Mar 10, 2005 3:02 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
krk123
Beginner


Joined: 03 Jun 2003
Posts: 58
Topics: 19

PostPosted: Thu Mar 10, 2005 8:54 pm    Post subject: Reply with quote

Thanks Kolusu
Back to top
View user's profile Send private message
powerhawk
Beginner


Joined: 08 Nov 2004
Posts: 28
Topics: 4
Location: Stockholm

PostPosted: Fri Mar 11, 2005 2:16 am    Post subject: Reply with quote

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 Very Happy
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Fri Mar 11, 2005 8:46 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group