Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
UNSTRING WITH POINTER

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: UNSTRING WITH POINTER
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: 2442
Location: Netherlands, Amstelveen

PostPosted: Thu Sep 23, 2010 3:33 pm    Post subject:
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    Post subject: Reply to: UNSTRING WITH POINTER
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: 2442
Location: Netherlands, Amstelveen

PostPosted: Thu Sep 23, 2010 4:07 pm    Post subject:
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    Post subject: Reply to: UNSTRING WITH POINTER
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    Post subject: Reply to: UNSTRING WITH POINTER
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: 8167
Location: East Dubuque, Illinois, USA

PostPosted: Thu Sep 23, 2010 4:56 pm    Post subject:
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    Post subject:
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    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
No new posts Unstring list of values into an array. Roshnii COBOL Programming 8 Mon Jun 27, 2016 6:25 pm
No new posts READQ TS returning inconsistent addre... moezbud CICS 14 Wed May 04, 2016 1:09 am
No new posts Problem with UNSTRING of CSV data Bill Woodger COBOL Programming 14 Tue Dec 15, 2015 5:32 pm
No new posts Display the hexadecimal address of a ... M_Kaiser COBOL Programming 12 Thu May 28, 2015 5:50 pm
No new posts Usage of pointer nilaksh92 COBOL Programming 2 Mon Mar 16, 2015 12:53 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us