Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to perform Unstring verb in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: How to perform Unstring verb in cobol
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: 3158
Location: Tucson AZ

PostPosted: Tue Feb 20, 2007 5:00 pm    Post subject:
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    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Tue Feb 20, 2007 6:02 pm    Post subject:
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    Post subject: Re: Unstring verb
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    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Wed Feb 21, 2007 6:31 pm    Post subject:
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    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Thu Feb 22, 2007 4:40 pm    Post subject:
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    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Thu Feb 22, 2007 5:19 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts COBOL Programming Sandpit? jodrisco COBOL Programming 6 Wed Apr 12, 2017 3:47 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us