Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Pointers in Cobol

Pointers in Cobol

Pointers in Cobol

I am making a small driver program to call another program. I just realized that I need to use pointers. I have been using the following variables:

01  RET-VAL            PIC 9(02) VALUE 00.
01  IO-AREA            PIC X(3200)  VALUE '02501BE7436561    /101546945ALLALL000021183577'.     

In the driver program, how do I set up some variables as pointers and put some valid info in them prior to sending them off to a called program? I need three pointers. The first one should point to an address which holds a module name like "acmpw022". The second pointer should point to an address which holds a return code... and I want to start it out as 00, which is for successful. The last pointer is for an IO area... the info we want brought back. It will be a mixed string of characters, up to 32000 bytes.

Here's a snippet of the called program:

LINKAGE SECTION.                                          
01  LNK-IO-AREA-POINTER          USAGE POINTER.           

Any help would be greatly appreciated.

RE: Pointers in Cobol

You need not use POINTER at all in this situation.  COBOL uses call-by-name (USING ... BY REFERENCE in COBOL terms), so modify your called program:

LINKAGE SECTION.                                          
01  LNK-MODULE-NAME              pic x(8)
01  LNK-COMPLETION-CODE          pic 9(02).           
01  LNK-IO-AREA                  x(3200).           

(Some confusion:  in the code sample you use 3200, but your description says 32000.)

Most implementations pass an address/pointer across the calling boundary, but that is invisible to the COBOL programmer.

Tom Morrison

RE: Pointers in Cobol

Hi Rusty,

A point of confusion on my part:

You show the called pgm name both in the caller and the called pgm. Why?

Should the call stmt be:
and the LINKAGE area be:

01  LNK-COMPLETION-CODE     pic 9(02).           
01  LNK-IO-AREA             pic x(3200).

or is the sub-pgm going to call the pgm in

Another fine point: you may want to define RET-VAL as
pic xx val '00' in the CALLer. Reason: If the sub-pgm fills RET-VAL with a non-DISPLAY data type, it can cause your CALLer pgm to abend if the field is referenced after the return from the CALL.

HTH, Jack.



RE: Pointers in Cobol

Thanks Tom and Jack, your responses helped a lot!

Tom, after following your suggestion, things seem to work better. I have compiled each project to INT code. (Did I tell you that I'm using Micro Focus Net Express?) However, when I try to step through my trigger program to the called program, I get two message boxes: The first tells me that "The IDY file (of the same name as the CBL file I'm trying to step into) does not contain any info for debugging GNT or OBJ code. You cannot step through this program..." This message has two buttons, one to Run Thru the code, the other to Stop Animating. When I click the Run Thru button, I get the second message box, which says: "Execution of the program EASLBRDG has been interupted. This program is not animatable, but you can view the call stack. The cause of the interrupt was: 114 Attempt to access item beyond bounds of memory."

When I recompile the called program to GNT code and start again to step through from my trigger program, I get the second of the two message boxes mentioned above.

Should I have the trigger program and the called program compiled to the same type code? I don't think you can animate with OBJ code?

Again, thanks for your help,

RE: Pointers in Cobol


I am not familiar enough with the Micro Focus product to be able to help.

I would suggest starting another thread now that you are having a debug problem rather than something that has to do with pointers.  Make sure you mention Net Express in the title, so that appropriate experts will be able to find it.

Best regards,
Tom Morrison

RE: Pointers in Cobol

I believe that you will still need to use pointers, because the arguments are defined as pointers.  To create a pointer, code something like this:


then you should be able to fill it in the PROCEDURE DIVISION with this code:


Hope this helps,

Betty Scherber
Brainbench MVP for COBOL II

RE: Pointers in Cobol

Thanks, Betty. That was right on the mark.

Did you have any thoughts on the '114 Attempt to access item beyond bounds of memory' warning? Am I doing something wrong which is not allowing me to call the function in the external DLL?


RE: Pointers in Cobol

Well, I'll wade back into this.

Betty's suggestion sets the pointer to point at itself.  An out of bounds reference seems to me to be an expected result.

Rusty, a better approach to solving this problem would be for you to describe what you are trying to accomplish, rather than you so-far-unsuccessful solution.  Using pointers in COBOL is rarely called for in normal programming.  Sometimes there is a better way...

Tom Morrison

RE: Pointers in Cobol


I was at first hesitant to respond to this post because my experience with MicroFocus was over two lifetimes ago.

Anyway, I think I will agree with Tom's initial reaction to your query in that you probably do not need pointers in this case.

And then I will agree with Tom again: give us more info - what are you trying to accomplish - and then perhaps we can be of better help.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close