[英]Does ABAP CALL statement set SY-SUBRC value?
I'm looking at the description of CALL - System Function Call in the SAP ABAP Keyword Definition.我正在查看 SAP ABAP 关键字定义中的CALL - 系统函数调用的描述。 Such calls have the format
CALL 'xxx' ID 'yyy' FIELD 'zzz'.
此类调用的格式为
CALL 'xxx' ID 'yyy' FIELD 'zzz'.
The ABAP Keyword Definition does not mention that sy-subrc
is set by calling a system function. ABAP 关键字定义没有提到通过调用系统函数来设置
sy-subrc
。 But somehow, I suspect that it is.但不知何故,我怀疑它是。
sy-subrc
not mentioned => not set) sy-subrc
=> 未设置) Note that I'm not an ABAP programmer and I usually handle third-party ABAP programs in Java as text / parse tree.请注意,我不是 ABAP 程序员,我通常将 Java 中的第三方 ABAP 程序作为文本/解析树处理。 I know that one usually should not call system functions, but the ABAP code I look at might have such calls.
我知道通常不应该调用系统函数,但是我查看的 ABAP 代码可能会有这样的调用。 Furthermore, I'm not interested in the actual value a specific system call sets
sy-subrc
to, just in the fact whether system calls set/alter sy-subrc
or not.此外,我对特定系统调用将
sy-subrc
设置为的实际值不感兴趣,只sy-subrc
系统调用是否设置/更改sy-subrc
的事实。
Well, as you are asking this question you are already aware this is NOT recommended approach to use direct SYSTEM calls.好吧,当您问这个问题时,您已经知道这不是使用直接 SYSTEM 调用的推荐方法。 However, if you still want to use them...
但是,如果您仍然想使用它们......
By using CALL
statement SAP kernel C-modules are called and without knowing the source we can not interpret the returning value confidently, either it's 0 or 1.通过使用
CALL
语句CALL
SAP 内核 C 模块,并且在不知道来源的情况下,我们无法自信地解释返回值,无论是 0 还是 1。
Despite there are examples (see line 230 of DYNP_VALUES_READ
FM) where sy-subrc
value is checked after system calls, nobody except SAP knows which value to check in certain case.尽管有一些示例(参见
DYNP_VALUES_READ
FM 的第 230 行)在系统调用后检查sy-subrc
值,但除了 SAP 之外没有人知道在某些情况下要检查哪个值。 Nor we.我们也不。
Also there were reports ( 1 , 2 ) about ambiguous meaning of these values during tests.也有关于这些值在测试过程中含义不明确的报告 ( 1 , 2 )。
So the answer is NO , sy-subrc
in this context brings no meaningful information.所以答案是否定的,在这种情况下
sy-subrc
没有带来任何有意义的信息。
PS Answering your questions: PS回答你的问题:
SYSTEM
function.SYSTEM
函数。 It calls arbitrary Unix command.它调用任意 Unix 命令。
For example, you can move files stored on your ABAP Server like this:例如,您可以像这样移动存储在 ABAP 服务器上的文件:
CALL 'SYSTEM'
ID 'COMMAND'
FIELD 'mv /usr/sap/temporary
/usr/sap/definite'.
Now this should be a safe call that works on any system:现在这应该是一个适用于任何系统的安全调用:
DATA: dbserver TYPE char255.
CALL 'C_SAPGPARAM' ID 'NAME' FIELD 'SAPDBHOST'
ID 'VALUE' FIELD dbserver.
As you probably already know there are some exceptions that can occur.正如您可能已经知道的那样,可能会发生一些例外情况。 As for
sy-subrc
, when a command sets sy-subrc
it is usually explicitly mentioned in the documentation including which values it can hold and their meaning.至于
sy-subrc
,当命令设置sy-subrc
,通常在文档中明确提到它,包括它可以保存哪些值及其含义。 But don't quote me on that.但不要引用我的话。
Simple (harmless) function modules are RH_GET_DATE_DAYNAME
that requires the language and 10 character date (eg. 26.10.2016
) as input fields and DATE_TO_DAY
that only requires the 10 character date as input.简单(无害)功能模块是
RH_GET_DATE_DAYNAME
需要语言和 10 个字符的日期(例如26.10.2016
)作为输入字段和DATE_TO_DAY
只需要 10 个字符的日期作为输入。 The sy-subrc
should be returned as 0
if a valid date is entered.如果输入了有效日期,则
sy-subrc
应返回0
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.