Using pointers in Cobol

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
pradi24
Member
Posts: 6
Joined: Wed Jun 11, 2014 9:50 am

Using pointers in Cobol

Post by pradi24 » Wed Jun 11, 2014 10:16 am

I am trying to receive a Pointer in a called program and want to use the content of Pointer and extract a portion of it. Typically my pointer gives a string which looks like below, From this semi-colon delimited string I want to extract the report-id.
1;system;reportid;....

What I did is defined a WS data item which is a Pointer and SET Receiving pointer to Sending Pointer. Now I am trying to apply UNSTRING operation on the receiving pointer (WS data item) but it is not working.

SET WS-SQLOUT TO ARSRBAN-SQLQUERY-PTR
UNSTRING WS-SQLOUT DELIMITED BY ';' INTO PART1, PART2,
PART3
INSPECT PART3 REPLACING ALL "'" BY ''
MOVE PART3 TO BANNER-TITLE

---------------------------------------------
It failing in compilation and getting below error,
IGYPS2074-S "WS-SQLOUT" was defined as a type that was invalid in this context. The statement was discarded.

Can somebody help me with this?

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Jun 11, 2014 11:52 am

You can't SET ADDRESS OF .... in the WORKING-STORAGE.

You need your data definition of your field in the LINKAGE SECTION.

Then SET ADDRESS OF your-new-data-definition TO your-pointer.

Then you can reference the data in the LINKAGE SECTION.

pradi24
Member
Posts: 6
Joined: Wed Jun 11, 2014 9:50 am

Using pointers in Cobol

Post by pradi24 » Wed Jun 11, 2014 9:02 pm

Thanks William, I have two pointers one is a sending data item and the other is a receiving data item, Sending data item in defined in linkage section where as the receiving data item is defined as Working storage item.
and I am not setting address, instead the content itself. below is how my SET statement looks like,

"SET WS-SQLOUT TO ARSRBAN-SQLQUERY-PTR"

WS-SQLOUT is the receiving pointer which is a working storage item
ARSBAN-SQLQUERY-PTR is linkage section data item.

I am not able to apply unstring on that. getting below error

"IGYPS2074-S "WS-SQLOUT" was defined as a type that was invalid in this context. The statement was discarded.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Thu Jun 12, 2014 12:18 am

The content of a POINTER is an address. What do you want to UNSTRING from an address?

I think you really do want to UNSTRING the data at the address.

So re-read the previous post.

pradi24
Member
Posts: 6
Joined: Wed Jun 11, 2014 9:50 am

Using pointers in Cobol

Post by pradi24 » Fri Jun 13, 2014 12:08 am

I tried that, this is how my code looks,

(New data definition)
LINKAGE SECTION.
01 WS-SQLOUT.
05 WS-SQLOUT-XX PIC X(32000).


-------------------------
SET ADDRESS OF WS-SQLOUT TO ARSRBAN-SQLQUERY-PTR
UNSTRING WS-SQLOUT-XX DELIMITED BY ';' INTO PART1, PART2, PART3

But the program is failing at SET statement with a SOC4.

Error message - CEE0198S The termination of a thread was signaled due to an unhandled condition.
CEE3204S The system detected a protection exception (System Completion Code=0C4).

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Fri Jun 13, 2014 2:16 am

Traditionally fields prefixed WS- are in the WORKING-STORAGE SECTION.

Your ARSRBAN-SQLQUERY-PTR has no addressability. It has not been "passed" from the program CALLing yours.

pradi24
Member
Posts: 6
Joined: Wed Jun 11, 2014 9:50 am

Using pointers in Cobol

Post by pradi24 » Fri Jun 13, 2014 6:56 am

I thought I mentioned about ARSRBAN-SQLQUERY-PTR, it is a pointer to a SQL Query which passed to my program., It is the sending pointer and WS-SQLOUT is the receiving field. But the SET ADDRESS OF WS-SQLOUT to Pointer is not working, It is giving SOC4 abend.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Fri Jun 13, 2014 10:02 am

You are getting a S0C4 when you use it. So it is not passed to your program.

pradi24
Member
Posts: 6
Joined: Wed Jun 11, 2014 9:50 am

Using pointers in Cobol

Post by pradi24 » Fri Jun 13, 2014 10:27 am

Sorry I dont get it. It is passed to the program as I have a USING Clause on PROCEDURE DIVISION USING ARSRBAN-PARAMETER-LIST

and ARSRBAN-SQLQUERY-PTR is one of the elementary item under ARSBAN-PARAMETER-LIST group item.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Fri Jun 13, 2014 5:17 pm

Show the code of the CALL (or other transfer of control to your program), the full PROCEDURE DIVISION USING and the definitions in the LINKAGE SECTION of your program, and all the relevant code in your program, using the Code Tags to preserve readability.

pradi24
Member
Posts: 6
Joined: Wed Jun 11, 2014 9:50 am

Using pointers in Cobol

Post by pradi24 » Fri Jun 13, 2014 9:55 pm

here is the code with linkage section declaration -
LINKAGE SECTION.
01 WS-SQLOUT.
05 WS-SQLOUT-XX PIC X(32000).
01 ARSRBAN-PARAMETER-LIST.
05 ARSRBAN-HEADER-COUNT COMP PIC S9(8).
05 ARSRBAN-HEADER-LENGTH COMP PIC S9(8).
05 ARSRBAN-SEQUENCE-NUMBER COMP PIC S9(8).
05 ARSRBAN-REQUEST-TYPE PIC X(01).
05 ARSRBAN-LOC PIC X(01).
05 ARSRBAN-RETURN-FLAG PIC X(01).
05 ARSRBAN-DCTRECP PIC X(60).
05 ARSRBAN-RECIPIENT PIC x(60).
05 ARSRBAN-DISTRIBUTION-NAME PIC x(60).
05 ARSRBAN-REPORTID PIC X(60).
05 ARSRBAN-DOC-TYPE PIC X(04).
05 ARSRBAN-REPORT-DATETIME.
10 ARSRBAN-DATE PIC X(10).
10 FILLER PIC X.
10 ARSRBAN-TIME PIC x(8).
10 FILLER PIC X.
10 ARSRBAN-MICROSECONDS PIC X(6).
05 ARSRBAN-REPORT-TITLE PIC X(60).
05 ARSRBAN-HDR1 PIC X(60).
05 ARSRBAN-HDR2 PIC X(60).
05 ARSRBAN-HDR3 PIC X(60).
05 ARSRBAN-HDR4 PIC X(60).
05 ARSRBAN-HDR5 PIC X(60).
05 ARSRBAN-HDR6 PIC X(60).
05 ARSRBAN-HDR7 PIC X(60).
05 ARSRBAN-HDR8 PIC X(60).
05 ARSRBAN-JNAME PIC X(08).
05 ARSRBAN-PPT-FORMDEF PIC X(06).
05 ARSRBAN-PPT-PAGEDEF PIC X(06).
05 ARSRBAN-CUSTOMER-VARIABLES PIC X(55).
05 ARSRBAN-EXITINFO PIC x(400).
05 ARSRBAN-ACCOUNT PIC X(60).
05 ARSRBAN-ADDRESS1 PIC X(60).
05 ARSRBAN-ADDRESS2 PIC X(60).
05 ARSRBAN-ADDRESS3 PIC X(60).
05 ARSRBAN-ADDRESS4 PIC X(60).
05 ARSRBAN-BUILDING PIC X(60).
05 ARSRBAN-DEPT PIC X(60).
05 ARSRBAN-NAME PIC X(60).
05 ARSRBAN-ROOM PIC X(60).
05 ARSRBAN-HEADER OCCURS 100 TIMES.
10 ARSRBAN-HEADER-LINE PIC X(512).
05 ARSRBAN-CC-TYPE PIC X.
05 ARSRBAN-SQLQUERY-PTR POINTER.

PROCEDURE DIVISION USING ARSRBAN-PARAMETER-LIST, WS-SQLOUT.

SET ADDRESS OF WS-SQLOUT TO ARSRBAN-SQLQUERY-PTR
UNSTRING WS-SQLOUT-XX DELIMITED BY ';' INTO PART1, PART2,
PART3
END-UNSTRING


----------------------------------
ARSRBAN-SQLQUERY-PTR is pointing to a SQL Query and it is a ';' delimited string with max length 32000

My goal is to extract the 3rd value from the delimited string. From the below example '112234421'

the string would typically like
'1';'AccountNO';'112234421';....

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Sat Jun 14, 2014 11:38 am

You didn't show the CALL (or whatever other transfer of control). That seems less likely to be the problem now you've shown that what you said originally is not the case.

ARSRBAN-SQLQUERY-PTR is the last item in your 01. If the stiorage for the 01 is "acquired" (CICS GETMAIN or LE Services) check the length of the storage that is acquired. I'd guess it is a few bytes short.

academyindia4

Topic deleted by Admin

Post by academyindia4 » Fri Jan 15, 2016 9:03 pm

<< Content deleted By Admin >>

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others