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

SOC7 abend while running UNSTRING statement...


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

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Mon Jun 30, 2008 8:21 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Mon Jun 30, 2008 8:32 pm
Reply with quote

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
View user's profile Send private message
karthikr44

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Mon Jun 30, 2008 8:44 pm
Reply with quote

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
Code:

WK-DTL:


Perform loop is occuring only once and WK-DTL(1) has value as spaces.

Regards
R KARTHIK
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: Mon Jun 30, 2008 9:32 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Jun 30, 2008 11:17 pm
Reply with quote

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
View user's profile Send private message
karthikr44

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Tue Jul 01, 2008 11:00 am
Reply with quote

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
View user's profile Send private message
karthikr44

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Tue Jul 01, 2008 4:55 pm
Reply with quote

Hi,

Does anybody know how to acchieve this?

Regards
R KARTHIK
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: Tue Jul 01, 2008 5:57 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jul 01, 2008 9:02 pm
Reply with quote

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
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 Running REXX through JOB CLIST & REXX 13
No new posts ISAM and abend S03B JCL & VSAM 10
No new posts Running a Job with the Default User ID JCL & VSAM 2
No new posts Error while running web tool kit REXX... CLIST & REXX 5
No new posts Abend S0C4 11 (Page Translation Excep... PL/I & Assembler 16
Search our Forums:

Back to Top