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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass data from a cobol program to UNIX korn shell script

Status
Not open for further replies.

amar9

Programmer
Nov 23, 2003
9
US
Hi,

Greetings. I am working on migration project which involves migration of cobol application from VAX/VMS platform to HP UNIX. I have couple of doubts while writing korn shell scripts. Could you let me know if you have information regarding how to handle the following task.

I want to pass return code from a MF COBOL program to unix korn shell script for validation purpose.

For example, RETURN-CODE=105 means ACCOUNT NUMBER MISSING
RETURN-CODE=210 means BANK NUMBER MISSING
based on this I want to write meesage to a error file using unix korn script.

Please share any useful regarding the above.

Thanks in advance for your help.

Regards,
Amar
 
Don't know much about MF Cobol but I think this will work:

Code:
       01  Your-Cmd.
           02             Pic x(..) Value "YourScriptName".
           02             Pic x     Value Spaces.
           02 Return-Code Pic 999.
:
           Move 105 To Return-Code
           Call "system" Using Your-Cmd
:
:
in your script:

Code:
    :
    case $1 in
     105) echo "Acount Number Missing" >> yourlogfile ;;
     210) echo "Bank Number Missing"   >> yourlogfile ;;
    esac
    :
 
Carefull! return code (return-code) is a reserved word.

But:
Code:
move 105 to RETURN CODE.
STOP RUN.
should work
 
Truusvlugindewind,

You're right, but I used it just as an example.

RETURN CODE are 2 words, both reserved !!! Probably you forgot the
Code:
_

Theophilos.
 
Hi theotyflos, Truusvlugindewind,

Thank you for the information.

I tried as given below:

MOVE 105 TO RETURN-CODE.
STOP RUN.

in script:

rc=$?
echo $rc

It is found that it is working correctly when RETURN-CODE less than or equal to 255. I am trying to find out is there any other way to pass a value > 255 to the return-code.

Once again thanks for your reply.

Regards,
Amar



 
You can probably set a shell variable and base your shell script on that. That way, you won't be constrained to an 8-bit integer...or even a number.

Don't know the syntax for setting shell (environment) variables in MF, but think it can be done. Check your manual.

Tom Morrison
 
In Micro Focus COBOL (and any X/Open conforming compiler) one may use

ACCEPT and DISPLAY

to obtain and/or set environment variables (inown to a "unix" OS). Check your Micro Focus documentation for "environment variables" and "Accept/Display" and you should find examples of how to do this.

This will allow for alphanumeric and LARGER numeric values than Return-Code.

Bill Klein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top