Home      Mainframe Forum      Mainfarme Tutorials      IBM Manuals      Mainframe Interview Questions      Mainframe Books      IT News     SiteMap     Downloads


     
 
MAINFRAME - TIP OF THE DAY : All available storage is assigned to the job or jobstep, If REGION is coded 0K or 0M

Google
 
Web mainframegurukul.com

Using pointers in Cobol

 
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> COBOL
  View previous topic :: View next topic  
Author Message
pradi24
Member


Joined: 11 Jun 2014
Posts: 6

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Jun 11, 2014 10:16 am    Post subject: Using pointers in Cobol Reply with quote

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?
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.

William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Jun 11, 2014 11:52 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
pradi24
Member


Joined: 11 Jun 2014
Posts: 6

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Jun 11, 2014 9:02 pm    Post subject: Using pointers in Cobol Reply with quote

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.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Jun 12, 2014 12:18 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
pradi24
Member


Joined: 11 Jun 2014
Posts: 6

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Jun 13, 2014 12:08 am    Post subject: Using pointers in Cobol Reply with quote

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).
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Jun 13, 2014 2:16 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
pradi24
Member


Joined: 11 Jun 2014
Posts: 6

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Jun 13, 2014 6:56 am    Post subject: Using pointers in Cobol Reply with quote

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.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Jun 13, 2014 10:02 am    Post subject: Reply with quote

You are getting a S0C4 when you use it. So it is not passed to your program.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
pradi24
Member


Joined: 11 Jun 2014
Posts: 6

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Jun 13, 2014 10:27 am    Post subject: Using pointers in Cobol Reply with quote

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.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Jun 13, 2014 5:17 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
pradi24
Member


Joined: 11 Jun 2014
Posts: 6

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Jun 13, 2014 9:55 pm    Post subject: Using pointers in Cobol Reply with quote

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(Cool.
05 ARSRBAN-HEADER-LENGTH COMP PIC S9(Cool.
05 ARSRBAN-SEQUENCE-NUMBER COMP PIC S9(Cool.
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(Cool.
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(0Cool.
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';....
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Sat Jun 14, 2014 11:38 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
academyindia4
Guest





Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Jan 15, 2016 9:03 pm    Post subject: Topic deleted by Admin Reply with quote

<< Content deleted By Admin >>
Back to top
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Display posts from previous:   
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> COBOL All times are GMT + 5 Hours
Page 1 of 1



 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Related topics
 Topics   Replies   Author   Views   Last Post 
No new posts Query For IEBPTPCH 3 padmajeet.gaikwad 13445 Mon Feb 01, 2016 10:56 pm
academyindia4 View latest post
No new posts Unable to achieve below scenario using ICETOOL 27 sirianangel 33683 Mon Feb 01, 2016 10:01 pm
academyindia4 View latest post
No new posts Need to put records a Sorting order as mentioned below. 14 Yash1911 12634 Mon Jan 25, 2016 9:50 pm
academyindia4 View latest post
No new posts how to deal with the below scenario using iebgener 7 mainframes_6002 11170 Wed Dec 07, 2011 10:34 am
DikDude View latest post
No new posts Coulu someone explain the parameters in the below code? 1 lovely sweety 11352 Thu Jun 09, 2011 3:50 pm
dbzTHEdinosauer View latest post
 


Cobol Tutorial
This cobol tutorial covers most of the important topics like STRING, UNSTRING, COMP, COMP-3.....
DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. Explains in simple language. Some Chapters are locked, Forum members have free access to these chapters
CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming...
JCL Tutorial
This is most popular JCL tutorial from mainframegurukul. It does contain important jcl ....
SORT Tutorial
This Tutorial covers all important aspects of DFSORT. Has more SORT examples
INTERVIEW Questions
This page covers important interview questions
Mainframe Jobs
Mainframe Jobs posted by members of mainframegurukul forum
FaceBook Page
MainframeGurukul FaceBook Page
LinkedIn Page
MainframeGurkul Linkedin Page

This widget requires Flash Player 9 or better







Go to top of the page
 

Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  DB2 INTERVIEW QUESTIONS ||  COBOL INTERVIEW QUESTIONS  ||  JCL INTERVIEW QUESTIONS ||  JCL2 INTERVIEW QUESTIONS ||  VSAM INTERVIEW QUESTIONS ||  CICS INTERVIEW QUESTIONS  ||  Online tutorials ||  Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  SiteMap  ||  Expeditor Tutorial  ||  FILE-AID Tutorial  ||  Changeman Tutorial  ||  COBOL   ||  DB2   ||  JCL  ||  CICS  ||  VSAM  ||  DB2 Interview Questions ( 110 )   || Simple JCL Tutorials  || JCL Tutorial from MainframeGurukul.com   || Simple JCL Tutorial - Chapter1 ;|| Mainframe Forum - Tutorials  || Mainframe Tutorials || Mainframe CICS tutorial|| Mainframe COBOL Tutorial

Drona Educational Forums - Mainframe Cobol DB2 CICS Board
Powered by phpBB

mainframetopic-7601.html