简体   繁体   English

DSNACICS 存储过程 - 在 commarea 参数中传递 comp 和 comp3 字段的方法

[英]DSNACICS stored procedure - Way to pass comp and comp3 fields in commarea parameter

I have a question about passing COMP and COMP-3 field data in DFHCOMMAREA in the context of the DSNACICS stored procedure.我有一个关于在 DSNACICS 存储过程的上下文中在 DFHCOMMAREA 中传递COMPCOMP-3字段数据的问题。

If the field is X(3) , I pass 3 characters with leading spaces in the case that the data is smaller.如果字段是X(3) ,我传递 3 个带前导空格的字符以防数据较小。 However, if the field is say S9(4) COMP , how many characters should I pass in DFHCOMMAREA in case I have to send a value of 2 ?但是,如果该字段是S9(4) COMP ,我应该在 DFHCOMMAREA 中传递多少个字符,以防我必须发送值2

Generally, and not specifically to DSNACICS, a PIC S9(4) COMP field in COBOL is a half word binary field, meaning that it occupies 2 bytes of physical space with the value represented in hexadecimal. COBOL 中的PIC S9(4) COMP字段通常是一个半字二进制字段,这意味着它占用 2 个字节的物理空间,其值以十六进制表示,而不是专门针对 DSNACICS。 A PIC S9(4) COMP field can store a value range from -32,768 (8000 in hex) to +32,767 (7FFF in hex). PIC S9(4) COMP字段可以存储从 -32,768(十六进制为 8000)到 +32,767(十六进制为 7FFF)的值范围。

However be aware of the TRUNC compiler option that you have in use.但是请注意您正在使用的TRUNC编译器选项。 If a program passing the data is compiled as TRUNC(BIN) you can use the range of values above in the field.如果传递数据的程序被编译为TRUNC(BIN) ,您可以在该字段中使用上述值范围。 If however you have the TRUNC(OPT) compiler option specified and you move the value 32767 into the PIC S9(4) COMP field, you are likely to end up with the value 2767 actually placed in the variable, rather than 32767. ie not the value you expected.但是,如果您指定了TRUNC(OPT)编译器选项并将值 32767 移动到PIC S9(4) COMP字段中,则最终可能会得到实际放置在变量中的值 2767,而不是 32767。即不是你期望的价值。 (That one has had me once or twice). (那个人曾经有过我一两次)。

Here is a reference to a page in the doc that might be helpful https://www.ibm.com/docs/en/cobol-zos/6.1?topic=data-examples-numeric-internal-representation这是对文档中可能有帮助的页面的引用https://www.ibm.com/docs/en/cobol-zos/6.1?topic=data-examples-numeric-internal-representation

If you wanted to move the value of 2 into a PIC S9(4) COMP field, internally it would be 2 bytes represented (in hex) as 0002.如果您想将 2 的值移动到PIC S9(4) COMP字段中,则在内部它将以 2 个字节(十六进制)表示为 0002。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM