View previous topic :: View next topic
|
Author |
Message |
karthikr44
Active User
Joined: 25 Aug 2007 Posts: 235 Location: Chennai
|
|
|
|
Code: |
WORKING-STORAGE SECTION.
01 WK-DETAIL.
05 WK-ADDR-1 PIC X(16) VALUE '123 LD'.
05 WK-ADDR-2 PIC X(16) VALUE 'MECELLON CIRCLE'.
05 WK-CITY PIC X(16) VALUE 'LOS ANGELS'.
05 WK-CODE PIC X(16) VALUE 'LA'.
01 WK-DTL-RECORD.
05 WK-DTL-REC OCCURS 20 TIMES
INDEXED BY WK-SUB2.
10 WK-DTL PIC X(08).
05 WK-SW-EOF PIC X(1) VALUE 'N'.
88 WK-UNTL-EOF VALUE 'Y'.
88 WK-UNTL-NOT-EOF VALUE 'N'.
01 WK-CNT.
05 WK-C1 PIC 9(2).
05 WK-NBR-1 PIC S9(1) VALUE +1.
05 WK-C2 PIC 9(2).
01 WK-POINTER-P.
05 WK-POINTER PIC S9(3).
01 WK-STRING.
05 WK-STR PIC X(10).
******************************************************************
* PROCEDURE DIVISION *
******************************************************************
PROCEDURE DIVISION.
PERFORM 1-INITIALIZATION
GOBACK
.
EJECT
1-INITIALIZATION.
******************************************************************
* 1-INITIALIZATION *
******************************************************************
SET WK-SUB2 TO WK-NBR-1
PERFORM UNTIL WK-UNTL-EOF
UNSTRING WK-DETAIL DELIMITED BY ALL SPACES
INTO WK-DTL-REC(WK-SUB2)
WITH POINTER WK-POINTER
ON OVERFLOW SET WK-UNTL-EOF TO TRUE
END-UNSTRING
SET WK-SUB2 UP BY WK-NBR-1
DISPLAY 'WK-DTL:' WK-DTL(WK-SUB2)
END-PERFORM
.
EJECT
|
While running this program i get SOC7 abend in UNSTRING statement.
I dont know the cause of error.
Anybody help...
Thanks
R KARTHIK |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
From the Language Reference manual:
Quote: |
6.2.39.5 POINTER phrase
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 the sending 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.
When this phrase is specified, the user must initialize the pointer field before execution of the UNSTRING statement begins. |
WK-POINTER is not being initialized. |
|
Back to top |
|
|
karthikr44
Active User
Joined: 25 Aug 2007 Posts: 235 Location: Chennai
|
|
|
|
Hi Robert,
U are correct. After initializing the pointer variable to 1, the abend is removed. But the o/p still doexnt come correctly.
I/p record
Code: |
WK-DETAIL:123 LD MECELLON CIRCLE LOS ANGELS LA
|
O/P i got
Perform loop is occuring only once and WK-DTL(1) has value as spaces.
Regards
R KARTHIK |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
I think you're expecting more from UNSTRING than you get. To quote from the manual:
Quote: |
6.2.39.7 ON OVERFLOW phrases
An overflow condition exists when:
* The pointer value (explicit or implicit) is less than 1.
* The pointer value (explicit or implicit) exceeds a value equal to the length of the sending field.
* All data receiving fields have been acted upon and the sending field still contains unexamined character positions. |
You have exactly one data receiving field -- WK-DTL-REC(WK-SUB2) so after the first field delimited by space is moved, the overflow condition applies since there's still unexamined data in the sending field. You can either do multiple receiving fields
Code: |
INTO FIELD-1 FIELD-2 FIELD-3 |
or you can restructure your logic to handle the one received field at a time. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
If you post how you want your process to work, someone may have a suggestion.
Show some more input and the output you want from that input. The "output" can be fields in working storage. . . |
|
Back to top |
|
|
karthikr44
Active User
Joined: 25 Aug 2007 Posts: 235 Location: Chennai
|
|
|
|
Hi dick scherrer,
U are correct...
My input:
WK-DETAIL:123 LD MECELLON CIRCLE LOS ANGELS LA
Desired o/p:
WK-DTL(1):123
WK-DTL(2):LD
WK-DTL(3):MECELLON
WK-DTL(4):CIRCLE
WK-DTL(5):LOS
WK-DTL(6):ANGELS
WK-DTL(7):LA
For achieving this i tried
SET WK-SUB2 TO WK-NBR-1
PERFORM UNTIL WK-UNTL-EOF
UNSTRING WK-DETAIL DELIMITED BY ALL SPACES
INTO WK-DTL-REC(WK-SUB2)
WITH POINTER WK-POINTER
ON OVERFLOW SET WK-UNTL-EOF TO TRUE
END-UNSTRING
SET WK-SUB2 UP BY WK-NBR-1
DISPLAY 'WK-DTL:' WK-DTL(WK-SUB2)
END-PERFORM
But i got o/p,
WK-DTL(1): spaces
Perform loop is occuring only once.
Hi robert still i dont know how many fields it is not possible to code
INTO FIELD-1 FIELD-2 FIELD-3
Is there any other way?
Regards
R KARTHIK |
|
Back to top |
|
|
karthikr44
Active User
Joined: 25 Aug 2007 Posts: 235 Location: Chennai
|
|
|
|
Hi,
Does anybody know how to acchieve this?
Regards
R KARTHIK |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Your best bet would be
Code: |
MOVE SPACES TO WK-DTL-RECORD.
UNSTRING WK-DETAIL
DELIMITED BY ALL SPACES
INTO WK-DTL-REC (01)
WK-DTL-REC (02)
WK-DTL-REC (03)
WK-DTL-REC (04)
WK-DTL-REC (05)
WK-DTL-REC (06)
WK-DTL-REC (07)
WK-DTL-REC (08)
WK-DTL-REC (09)
WK-DTL-REC (10)
END-UNSTRING .
PERFORM VARYING WK-C1 FROM 1 BY 1
UNTIL WK-DTL-REC (WK-C1) = SPACES
DISPLAY WK-DTL-REC (WK-C1)
END-PERFORM . |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
While running this program i get SOC7 abend in UNSTRING statement. |
Is this still a problem?
Please convert your perform/unstring code to the example Robert posted and post back here if there are questions or problems. |
|
Back to top |
|
|
|