Using pointers in Cobol
Moderators: dbzTHEdinosauer, Moderator Group
Using pointers in Cobol
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?
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?
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
Using pointers in Cobol
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.
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.
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
Using pointers in Cobol
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).
(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).
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
Using pointers in Cobol
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.
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
Using pointers in Cobol
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.
and ARSRBAN-SQLQUERY-PTR is one of the elementary item under ARSBAN-PARAMETER-LIST group item.
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
Using pointers in Cobol
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';....
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';....
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 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.
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.
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
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page