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

UNSTRING WITH POINTER


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
raghav08
Currently Banned

New User


Joined: 03 Jun 2008
Posts: 94
Location: Bangalore

PostPosted: Thu Sep 23, 2010 3:16 pm
Reply with quote

Hello,

The below UNSTRING WITH POINTER extracts only 'ORDER', please let me know what went wrong to extarct remianing fields.

Code:


MOVE 'ORDER NUMBER D7890' TO WS-NAME.
MOVE 'N' TO WS-END.
MOVE 1 TO WS-PTR.
PERFORM UNTIL WS-END = 'Y'
UNSTRING WS-NAME DELIMITED BY ALL SPACES
         INTO WS-TEMP
         WITH POINTER WS-PTR
         ON OVERFLOW MOVE 'Y' TO WS-END
END-UNSTRING
DISPLAY WS-TEMP
END-PERFORM.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Sep 23, 2010 3:33 pm
Reply with quote

Maybe you should update WS-PTR.
Back to top
View user's profile Send private message
raghav08
Currently Banned

New User


Joined: 03 Jun 2008
Posts: 94
Location: Bangalore

PostPosted: Thu Sep 23, 2010 3:43 pm
Reply with quote

Hi,

I tried that too, still not working. During first iteration ON OVERFLOW condition satisfies.

Thanks.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Sep 23, 2010 4:07 pm
Reply with quote

An overflow condition exists when:
v The pointer value (explicit or implicit) is less than 1.
v The pointer value (explicit or implicit) exceeds a value equal to the length of the sending field.
v All data receiving fields have been acted upon and the sending field still
contains unexamined character positions.

When the POINTER phrase is specified, the value of the pointer field, identifier-7, behaves as if it were increased by 1 for each examined character position in thesending field. When execution of the UNSTRING statement is completed, the pointer field contains a value equal to its initial value plus the number of character positions examined in the sending field.
Back to top
View user's profile Send private message
raghav08
Currently Banned

New User


Joined: 03 Jun 2008
Posts: 94
Location: Bangalore

PostPosted: Thu Sep 23, 2010 4:16 pm
Reply with quote

Hi.

Sorry I have already referred the manual, but could not rectify why ON OVERFLOW condition satisfies on first iteration itself.

Could you please.
Back to top
View user's profile Send private message
raghav08
Currently Banned

New User


Joined: 03 Jun 2008
Posts: 94
Location: Bangalore

PostPosted: Thu Sep 23, 2010 4:52 pm
Reply with quote

Hi,

An abstract from net:

If the UNSTRING operation causes the scan to move past the rightmost position of the sending item (thus exhausting it), the compiler does not execute the OVERFLOW phrase.

This code working fine if I code

Code:


NOT ON OVERFLOW MOVE 'Y' TO WS-END

Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Sep 23, 2010 4:56 pm
Reply with quote

Quote:
Sorry I have already referred the manual, but could not rectify why ON OVERFLOW condition satisfies on first iteration itself.
Because that's the way the command is constructed?

Peter's quote from the manual on the overflow condition specifies as the third possibility that all data receiving fields have been acted upon and there are unexamined data bytes in the sending variable. So let's look at what happens. The UNSTRING starts at position 1 and moves ORDER into WS-TEMP. The space is reached and this is the delimiter you specified. So the UNSTRING stops. All receiving fields (WS-TEMP in your case) have been acted upon. There are still unexamined characters in the sending field. You have met all conditions for the ON OVERFLOW to be triggered, so the ON OVERFLOW phrase is executed.
Back to top
View user's profile Send private message
raghav08
Currently Banned

New User


Joined: 03 Jun 2008
Posts: 94
Location: Bangalore

PostPosted: Thu Sep 23, 2010 5:10 pm
Reply with quote

Hi,

Yes you are right

Quote:

There are still unexamined characters in the sending field.


1) At the end of first UNSTRING the pointer WS-PTR points (to NUMBER in this example) one character beyond the delimiter this causes ON OVERFLOW condition

2) At the end of last UNSTRING the clause ON OVERFLOW does not satisfy, because there is no more character beyond sending field.

Thanks All
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 Moving Or setting POINTER to another ... COBOL Programming 2
No new posts Handling the numeric data in unstring... COBOL Programming 18
No new posts Can we pass cobol pointer to cobol-db... DB2 4
No new posts Unstring COBOL Programming 4
No new posts UNSTRING problem COBOL Programming 3
Search our Forums:

Back to Top