View previous topic :: View next topic
|
Author |
Message |
raghav08 Currently Banned New User
Joined: 03 Jun 2008 Posts: 94 Location: Bangalore
|
|
|
|
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 |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Maybe you should update WS-PTR. |
|
Back to top |
|
|
raghav08 Currently Banned New User
Joined: 03 Jun 2008 Posts: 94 Location: Bangalore
|
|
|
|
Hi,
I tried that too, still not working. During first iteration ON OVERFLOW condition satisfies.
Thanks. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
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 |
|
|
raghav08 Currently Banned New User
Joined: 03 Jun 2008 Posts: 94 Location: Bangalore
|
|
|
|
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 |
|
|
raghav08 Currently Banned New User
Joined: 03 Jun 2008 Posts: 94 Location: Bangalore
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
raghav08 Currently Banned New User
Joined: 03 Jun 2008 Posts: 94 Location: Bangalore
|
|
|
|
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 |
|
|
|