Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cobol/ksh script API

Status
Not open for further replies.

jmanj

Programmer
May 20, 2003
298
US
Hi all,

I have asked this question in the unix scripting forum but this might be the appropriate forum to ask.

We are using micro focus cobol netexpress(unix/solaris) and some of my pgms has calls to unix .ksh script and they do ran perfectly well. One thing I have not done is to test for the return code from the script.

I would really appreciate if someone in this group had done such kind of functionality(like an api). I can do this in java but I was told to use .ksh scripting.

Thanks very much.
 
A quick look through the Micro Focus docs doesn't come up with anything.

Have you looked in the RETURN-CODE special register after the call? Also, possibly a GIVING parameter? Seeing a code example might be helpful.

Tom Morrison
 
Tom,

Thanks for your quick reply. Due to lack of available documentation, I have not looked at the special registers.
Can you explain where the special register is? I know I have encountered this before but that was more than 20yra ago with IBM mainframes(totally forgotten). Perhaps, what I really need to know is how the RETURN-CODE handling works between cobol and non-cobol programs.

Here's a sample calls that I usually create within cobol program. This is just a call to the script but I don't know how to handle the return codes if any:

STRING "ftp_to_server.ksh"
DELIMITED BY SIZE
INTO FTP-SYS-COMMAND.

CALL "SYSTEM" USING FTP-SYS-COMMAND.


Thanks for any help.
 
All it usually takes is just accessing the variable RETURN-CODE, as in IF RETURN-CODE > 0 THEN DISPLAY "YOU GOT A PROBLEM.
 
Glenn,

Thanks very much!! I did'nt know that RETURN-CODE is a cobol
verb. I will try to use that code and see if it works. I'm hoping the precompiler to micro-focus(Bizmark creates the shell) will recognize the verb.
 
jmanj said:
what I really need to know is how the RETURN-CODE handling works between cobol and non-cobol programs

It is a characteristic of Micro Focus COBOL, and others (ahem!), that the RETURN-CODE special register in the CALLing program is set to the value of the RETURN-CODE set in the CALLed program. For nonCOBOL programs, it may be true (as Glenn indicates) that the interface glue of CALL "SYSTEM" places the shell's return status in RETURN-CODE before exiting.

jmanj said:
Due to lack of available documentation...

Micro Focus documentation is online. However, I could not determine from the online docs, in a very short amount of time, the CALL "SYSTEM" interface specification.

Tom Morrison
 
You guys are all terrific! Maybe it's time for me to retire after all!!.. I've been browsing my old program archives and found out that I have been using the return-codes functionality after all... I've been invoking a lot of other programs and I'm using it intensively. The only exception is I have not used it in a ksh script. I'm hoping the return function in the script will work as per unix documentation.

Thanks all. I will post whatever the outcome of my testing.
 
Re: Non-COBOL sub program

Depending on how the language for the sub-program works, you might need to set the OS error code for the program before exit. This would be what the main COBOL program is picking up through RETURN-CODE.
 
Glenn, all,

Yes you are right. I did sent a return code from the ksh script and cobol was able to get it. This is after recompiling
another cobol pgm in an old cobol version(tandem). However in the unix platform the precompiler application(Bizmark) did not
like RETURN-CODE at all. I called bizmark and asked them why their program do uses RETURN-CODE but not for other user programs. They don't have a direct answer either???
 
One way to avoid the issue your program generator/precompiler has with RETURN-CODE would be to wrap your CALL "SYSTEM" in another COBOL program similar to:
Code:
    linkage section.
    01  sys-command   pic x(100).
    01  ret-status    pic S9(8).
    procedure division using sys-command
                       returning ret-status.
    a.
        call "SYSTEM" using sys-command.
        move return-code to ret-status.
        exit program.
[small]Your compiler version may require GIVING rather than RETURNING.[/small]

Tom Morrison
 
Tom,

Thanks Tom that's basically what I need(forgive my being forgetful). But I think there should be a x"00" at the end
of sys-command for it work or maybe not(it's been so long).

I was redoing the program and already using linkage section but I can't seem to remember the functionality.

Thanks again and more STAR to you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top