IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to perform Unstring verb in cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vishal kumar gupta
Warnings : 1

New User


Joined: 18 Feb 2007
Posts: 11
Location: bhubaneswar

PostPosted: Tue Feb 20, 2007 4:54 pm
Reply with quote

hi,
can any body suggest me how can how to perform Unstring verb in cobol if i dont know the exact number of tokens after unstring is performed. ie if i dont want to use a fixed number of working storage variable in the "INTO" clause of Unstring verb ,

like

unstring abc delimited by all spaces into ws-patterns end unstring,

problem is i dont know the number of vlaues coming in ws-patterns, is there any way to know that
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Feb 20, 2007 5:00 pm
Reply with quote

Use an array for the targets.
Back to top
View user's profile Send private message
vishal kumar gupta
Warnings : 1

New User


Joined: 18 Feb 2007
Posts: 11
Location: bhubaneswar

PostPosted: Tue Feb 20, 2007 5:16 pm
Reply with quote

1)how to know whether the string has ended

2) if i write

unstring abc-shpr(sub) delimited by all spaces into ws-pattern(sub)

this is what ur saying then will all the delimited tokens be stored?reply
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Feb 20, 2007 6:02 pm
Reply with quote

You can unstring each field in a perform loop until overflow using the pointer function of the unstring to maintain position.

And because you are going to ask, something like this:
Code:
move 1 to P
perform varying sub from 1 by 1
             until UOVER
  unstring field delimited by thingy
      into area(sub)
      with pointer P
      on overflow set UOVER to true
  end-unstring
end-perform
Back to top
View user's profile Send private message
vishal kumar gupta
Warnings : 1

New User


Joined: 18 Feb 2007
Posts: 11
Location: bhubaneswar

PostPosted: Tue Feb 20, 2007 6:42 pm
Reply with quote

thanks a lot
Back to top
View user's profile Send private message
vishal kumar gupta
Warnings : 1

New User


Joined: 18 Feb 2007
Posts: 11
Location: bhubaneswar

PostPosted: Wed Feb 21, 2007 5:27 pm
Reply with quote

HI ,
A small problem , how to declare a pointer ,
either usage as pointer in this case its showing severe errors
or as any numeric variable
suggest
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed Feb 21, 2007 6:31 pm
Reply with quote

I'm sorry, I had assumed you had access to the Fine Manual icon_rolleyes.gif
Enterprise COBOL for z/OS and OS/390
Language Reference

6.2.39.3 POINTER phrase
Back to top
View user's profile Send private message
vishal kumar gupta
Warnings : 1

New User


Joined: 18 Feb 2007
Posts: 11
Location: bhubaneswar

PostPosted: Thu Feb 22, 2007 4:10 pm
Reply with quote

Code:

PERFORM VARYING WS-SUB2 FROM 1 BY 1                     
                 UNTIL WS-UNTIL-OVER-SW = 'Y'                           
      UNSTRING CMBL16M1-CMBL16M1-LINE(SUB)   
                                  DELIMITED BY ALL SPACES               
                 INTO WS-DELIMITED-PATTERN-NEW(WS-SUB2)       
                 WITH POINTER WS-POINTER                                 
             ON OVERFLOW  MOVE  'Y' TO WS-UNTIL-OVER-SW                     
      END-UNSTRING                                               
END-PERFORM


see the whole code is exploding , here the program is copying only the first element of the field in pattern-new array.But i want to copy the whole broken tokens into the array ,
:-(
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Feb 22, 2007 4:40 pm
Reply with quote

I'm sorry, but I don't see the "exploding"?
It looks like it should work, why is it exiting the perform?
Back to top
View user's profile Send private message
vishal kumar gupta
Warnings : 1

New User


Joined: 18 Feb 2007
Posts: 11
Location: bhubaneswar

PostPosted: Thu Feb 22, 2007 5:05 pm
Reply with quote

i have declared ws-pointer as

01 WS-POINTER-P.
05 WS-POINTER PIC S9(3).

array
WS-DELIMITED-PATTERN-NEW as


01 WS-DELIMITED-TABLE-NEW .
05 WS-TABLE-PATTERN-NEW OCCURS 20.
10 WS-DELIMITED-PATTERN-NEW PIC X(40).
i dont know why it is not working . suggest what could go wrong?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Feb 22, 2007 5:19 pm
Reply with quote

Code:

display 'limit ' WS-UNTIL-OVER-SW
display '>>>' CMBL16M1-CMBL16M1-LINE(SUB) '<<<'
PERFORM VARYING WS-SUB2 FROM 1 BY 1                     
                 UNTIL WS-UNTIL-OVER-SW = 'Y'                           
      display 'limit in ' WS-UNTIL-OVER-SW
      display 'pointer in ' WS-POINTER
      UNSTRING CMBL16M1-CMBL16M1-LINE(SUB)   
                                  DELIMITED BY ALL SPACES               
                 INTO WS-DELIMITED-PATTERN-NEW(WS-SUB2)       
                 WITH POINTER WS-POINTER                                 
             ON OVERFLOW
                 display 'overflow ' WS-POINTER
                 MOVE  'Y' TO WS-UNTIL-OVER-SW                     
      END-UNSTRING       
      display 'unstrung ' WS-SUB2                                     
      display 'pointer out ' WS-POINTER
      display 'limit in ' WS-UNTIL-OVER-SW
END-PERFORM
Let's see what this shows....
Back to top
View user's profile Send private message
vishal kumar gupta
Warnings : 1

New User


Joined: 18 Feb 2007
Posts: 11
Location: bhubaneswar

PostPosted: Thu Feb 22, 2007 5:44 pm
Reply with quote

sorry its a cobio (idms dc) display doesnt work here ,
sorry i didnt tell u earlier,
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top