在ILE COBOL计划中获得返回的价值

发布于 2025-01-22 14:26:49 字数 689 浏览 5 评论 0 原文

我正在尝试从COBOL程序中的C程序中获取返回的值。但是,他们提到了这一点:

返回短语

“对于带有链接类型的程序的程序,不允许给予/返回短语。”

那么什么是替代方案?如何在COBOL程序中获得返回的值?找不到。 谢谢。 - 编辑 我发现这个 https://www.ibm.com/docs/en/rdfi/9.6.0?topic = sssae4w_9.6.6.6.0/com.ib.m.thools.iseries.iseries.ielecbl.ilecbl.ilecbl.doc/lnc2762.htm 他们表明“更改所谓程序的链接”,但我不知道该怎么做。

I am trying to get the returned value from a C program in a cobol program. However, they mention this:

returning phrase

"The GIVING/RETURNING phrase is not allowed for programs called with a linkage type of program."

So what is the alternative? how can I obtained the returned value in a cobol program? Cannot find it.
Thanks.
-- EDIT
I found this https://www.ibm.com/docs/en/rdfi/9.6.0?topic=SSAE4W_9.6.0/com.ibm.etools.iseries.ilecbl.doc/LNC2762.htm
They indicate "change the linkage of the called program" but i don't know how to do that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

西瑶 2025-01-29 14:26:49

简短答案
IBM上的ILE程序我不支持返回值。
您需要使用输出参数。

长答案
offset 108


文档说:

用户返回代码字段是任何最新的返回代码
工作中的线程。许多操作系统功能运行C代码,并且
更改用户返回代码的值。发生对此领域的变化
有时无法通过用户编程预测或控制的
即使工作是单线程。接收一个由一个返回的值
称为程序,最好提供一个参数以接收该参数
价值比依靠此作业分割的用户返回代码字段。

IBM的芭芭拉·莫里斯(Barbara Morris),RPG编译器开发团队的一部分,在线线程中提到的

操作系统必须从呼叫堆栈中取下程序,并且
如果是一个新程序,则操作系统必须收回激活组。如果
该工作的一部分涉及OS中的C或C ++程序,它可能
更改Ile返回代码。

扩展的答案
如您的编辑中所述,“更改链接”是否会怀疑将C代码从 *pgm对象移动到 *srvpgm对象(用于绑定逐个参考使用)或 *模块对象(by-by-copy)。

ILE过程(又称功能)可以返回值。

对于ILE C/C ++致电C/C ++ PGM
ile c/c ++程序员指南 ..

extern“ os” int pgmname(void);呼叫上返回的值是
动态程序调用的返回代码。如果程序被调用
是C ++程序,可以使用该返回代码访问此返回代码
_language_return_code宏观在标题文件中定义< milib.h>。 C ++程序返回_language_return_code中的四个字节。如果是
正在称为EPM或OPM程序的程序,此返回代码可以是
使用iSeries检索作业属性(RTVJOBA)命令访问。

但是我认为这不会有助于COBOL调用C/C ++。

Short answer
ILE Programs on the IBM i don't support return values.
You'd need to use a output parameter.

Long Answer
In the JOBI0600 format of the Retrieve Job Information (QUSRJOBI) API there's a 4byte integer field "User Return Code" at offset 108.

However
The documentation says:

The user return code field is the most recent return code set by any
thread within the job. Many operating system functions run C code and
change the value of the user return code. Changes to this field occur
at times that cannot be predicted or controlled by user programming,
even when the job is single-threaded. To receive a value returned by a
called program, it is better to provide a parameter to receive that
value than to rely on this job-scoped user return code field.

IBM's Barbara Morris, part of the RPG compiler development team, mentioned in an online thread

the operating system has to take the program off the call stack, and
if it's a *NEW program, the OS has to reclaim the activation group. If
part of that work involves a C or C++ program in the OS, it might
change the ILE return code.

Expanded Answer
"Changing Linkage" as mentioned in your edit would I suspect be moving the C code from a *PGM object into a *SRVPGM object (for bind-by-reference use) or *MODULE object (bind-by-copy).

ILE Procedures (aka Functions) can return values.

For ILE C/C++ calling C/C++ PGM
The following is mentioned in the ILE C/C++ Programmer's Guide..

extern "OS" int PGMNAME(void); The value returned on the call is the
return code for the dynamic program call. If the program being called
is a C++ program, this return code can be accessed using the
_LANGUAGE_RETURN_CODE macro defined in the header file <milib.h>. A C++ program returns four bytes in the _LANGUAGE_RETURN_CODE. If the
program being called is an EPM or OPM program, this return code can be
accessed using the iSeries Retrieve Job Attributes (RTVJOBA) command.

But I don't think that will help with COBOL calling C/C++.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文