I want to use SYNCSORT to force all Packed Decimal fields to a negative sign value. The critical requirement is the 2nd nibble must be Hex 'D'. I have a method that works but it seems much too complex. In keeping with the KISS principle, I'm hoping someone has a better method. Perhaps using a bit mask on the last 4 bits? Here is the code I have come up with. Is there a better way?
我想使用SYNCSORT强制将所有已打包的十进制字段强制为负符号值。关键的要求是第二咬口必须是六角“D”。我有一个有效的方法,但是看起来太复杂了。按照KISS原则,我希望有人有更好的方法。或者在最后4位上使用位掩码?这是我想到的代码。有更好的方法吗?
* * This sort logic is intended to force all Packed Decimal amounts to * have a negative sign with a B'....1101' value (Hex 'xD'). * SORT FIELDS=COPY OUTFIL FILES=1, INCLUDE=(8,1,BI,NE,B'....1..1',OR, * POSITIVE PACKED DECIMAL 8,1,BI,EQ,B'....1111'), * UNSIGNED PACKED DECIMAL OUTREC=(1:1,7, * INCLUDING +0 8:(-1,MUL,8,1,PD),PD,LENGTH=1, 9:9,72) OUTFIL FILES=2, INCLUDE=(8,1,BI,EQ,B'....1..1',AND, * NEGATIVE PACKED DECIMAL 8,1,BI,NE,B'....1111'), * NOT UNSIGNED PACKED DECIMAL OUTREC=(1:1,7, * INCLUDING -0 8:(+1,MUL,8,1,PD),PD,LENGTH=1, 9:9,72)
4 个解决方案
#1
1
In the code that processes the VSAM file, can you change the read logic to GET with KEY GTEQ and check for < 0 on the result instead of doing a specific keyed read?
在处理VSAM文件的代码中,是否可以更改读取逻辑以获取关键的GTEQ并检查结果的< 0,而不是执行特定的键控读取?
If you did that, you could accept all three negative packed values xA, xB and xD.
如果你这样做了,你可以接受所有三个负填充值xA xB xD。
#2
1
Have you considered writing an E15 user exit? The E15 user exit lets you manipulate records as they are input to the sort process. In this case you would have a REXX, COBOL or other LE compatible language subroutine patch the packed decimal sign field as it is input to the sort process. No need to split into multiple files to be merged later on.
您是否考虑过编写E15用户退出?E15用户退出允许您操作记录,因为它们是对排序过程的输入。在这种情况下,您将有一个REXX、COBOL或其他与LE兼容的语言子例程,在填充十进制符号字段作为排序过程的输入时对其进行补丁。不需要分割成多个文件以便以后合并。
Here is a link to example JCL for invoking an E15 exit from DFSORT (same JCL for SYNCSORT). Chapter 4 of this reference describes how to develop User Exit routines, again this is a DFSORT manual but I believe SyncSort is fully compatible in this respect. Writing a user exit is no different than writing any other subroutine - get the linkage right and the rest is easy.
这里有一个到示例JCL的链接,用于从DFSORT调用E15出口(与SYNCSORT相同的JCL)。本参考的第4章描述了如何开发用户退出例程,同样这是一个DFSORT手册,但是我认为SyncSort在这方面是完全兼容的。编写用户退出与编写任何其他子例程没有什么不同——正确地获取链接,其余的都很容易。
This is a very general outline, but I hope it helps.
这是一个非常笼统的提纲,但我希望它能有所帮助。
#3
1
Okay, it took some digging but NEALB's suggestion to seek help on MVSFORUMS.COM paid off... here is the final result. The OUTREC logic used with SORT/MERGE replaces OUTFIL and takes advantage of new capabilities (IFTHEN, WHEN and OVERLAY) in Syncsort 1.3 that I didn't realize existed. It pays to have current documentation available!
好吧,这需要一些挖掘,但NEALB的建议寻求帮助在mvsforum。COM付清…这是最终结果。与SORT/MERGE一起使用的OUTREC逻辑替换了OUTFIL,并利用了Syncsort 1.3中我没有意识到的新功能(IFTHEN, WHEN和OVERLAY)。提供当前文档是值得的!
*
* This MERGE logic is intended to assert that the Packed Decimal
* field has a negative sign with a B'....1101' value (Hex X'.D').
*
*
MERGE FIELDS=(27,5.4,BI,A),EQUALS
SUM FIELDS=NONE
OUTREC IFTHEN=(WHEN=(32,1,BI,NE,B'....1..1',OR,
32,1,BI,EQ,B'....1111'),
OVERLAY=(32:(-1,MUL,32,1,PD),PD,LENGTH=1)),
IFTHEN=(WHEN=(32,1,BI,EQ,B'....1..1',AND,
32,1,BI,NE,B'....1111'),
OVERLAY=(32:(+1,MUL,32,1,PD),PD,LENGTH=1))
#4
1
Looking at the last byte of a packed field is possible. You want positive/unsigned to negative, so if it is greater than -1, subtract it from zero.
查看填充字段的最后一个字节是可能的。你想让正/无符号变成负的,所以如果它大于-1,从0减去它。
From a short-lived Answer by MikeC, it is now known that the data contains non-preferred
signs (that is, it can contain A through F in the low-order half-byte, whereas a preferred
sign would be C (positive) or D (negative). F is unsigned, treated as positive.
从MikeC的短期回答中,我们知道数据包含非首选符号(也就是说,它可以在低阶半字节中包含a到F,而首选符号是C(正数)或D(负数)。F是无符号的,被视为阳性。
This is tested with DFSORT. It should work with SyncSORT. Turns out that DFSORT can understand a negative packed-decimal zero, but it will not create a negative packed-decimal zero (it will allow a zoned-decimal negative zero to be created from a negative zero packed-decimal).
这是用DFSORT测试的。它应该与SyncSORT一起工作。事实证明,DFSORT可以理解一个负的packed-decimal 0,但它不会创建一个负的packed-decimal 0(它将允许从负的zero packed-decimal中创建一个带-decimal - zero)。
The idea is that a non-preferred
sign is valid and will be accurately signed for input to a decimal machine instruction, but the result will always be a preferred
sign, and will be correct. So by adding zero first, the field gets turned into a preferred
sign and then the test for -1 will work as expected. With data in the sign-nybble for packed-decimal fields, SORT has some specific and documented behaviours, which just don't happen to help here.
这个想法是,一个非首选的符号是有效的,并且将被精确地签名,以便输入到十进制机器指令,但是结果将永远是一个首选的符号,并且将是正确的。所以通过先加零,字段就变成了首选符号,然后-1的测试就会像预期的一样。对于分组-十进制字段的sign-nybble数据,SORT有一些特定的和文档化的行为,这在这里没有帮助。
Since there is only one value to deal with to become the negative zero, X'0C', after the normalisation of signs already done, there is a simple test and replacement with a constant of X'0D' for the negative zero. Since the negative zero will not work, the second test is changed from the original minus one to zero.
由于只有一个值需要处理才能变成- 0,即X'0C',在符号已经被正常化之后,有一个简单的测试,用X'0D'的常数替换为- 0。因为- 0不起作用,第二个测试从原来的- 1变为0。
With non-preferred signs in the data:
数据中有非首选符号:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(32:+0,ADD,32,1,PD,TO=PD,LENGTH=1)),
IFTHEN=(WHEN=(32,1,CH,EQ,X'0C'),
OVERLAY=(32:X'0D')),
IFTHEN=(WHEN=(32,1,PD,GT,0),
OVERLAY=(32:+0,SUB,32,1,PD,TO=PD,LENGTH=1))
With preferred signs in the data:
数据中有首选符号:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(32,1,CH,EQ,X'0C'),
OVERLAY=(32:X'0D')),
IFTHEN=(WHEN=(32,1,PD,GT,0),
OVERLAY=(32:+0,SUB,32,1,PD,TO=PD,LENGTH=1))
Note: If non-preferred
signs are stuffed through a COBOL program not using compiler option NUMPROC(NOPFD) then results will be "interesting".
注意:如果不使用编译器选项NUMPROC(NOPFD)的COBOL程序填充非首选符号,那么结果将是“有趣的”。
#1
1
In the code that processes the VSAM file, can you change the read logic to GET with KEY GTEQ and check for < 0 on the result instead of doing a specific keyed read?
在处理VSAM文件的代码中,是否可以更改读取逻辑以获取关键的GTEQ并检查结果的< 0,而不是执行特定的键控读取?
If you did that, you could accept all three negative packed values xA, xB and xD.
如果你这样做了,你可以接受所有三个负填充值xA xB xD。
#2
1
Have you considered writing an E15 user exit? The E15 user exit lets you manipulate records as they are input to the sort process. In this case you would have a REXX, COBOL or other LE compatible language subroutine patch the packed decimal sign field as it is input to the sort process. No need to split into multiple files to be merged later on.
您是否考虑过编写E15用户退出?E15用户退出允许您操作记录,因为它们是对排序过程的输入。在这种情况下,您将有一个REXX、COBOL或其他与LE兼容的语言子例程,在填充十进制符号字段作为排序过程的输入时对其进行补丁。不需要分割成多个文件以便以后合并。
Here is a link to example JCL for invoking an E15 exit from DFSORT (same JCL for SYNCSORT). Chapter 4 of this reference describes how to develop User Exit routines, again this is a DFSORT manual but I believe SyncSort is fully compatible in this respect. Writing a user exit is no different than writing any other subroutine - get the linkage right and the rest is easy.
这里有一个到示例JCL的链接,用于从DFSORT调用E15出口(与SYNCSORT相同的JCL)。本参考的第4章描述了如何开发用户退出例程,同样这是一个DFSORT手册,但是我认为SyncSort在这方面是完全兼容的。编写用户退出与编写任何其他子例程没有什么不同——正确地获取链接,其余的都很容易。
This is a very general outline, but I hope it helps.
这是一个非常笼统的提纲,但我希望它能有所帮助。
#3
1
Okay, it took some digging but NEALB's suggestion to seek help on MVSFORUMS.COM paid off... here is the final result. The OUTREC logic used with SORT/MERGE replaces OUTFIL and takes advantage of new capabilities (IFTHEN, WHEN and OVERLAY) in Syncsort 1.3 that I didn't realize existed. It pays to have current documentation available!
好吧,这需要一些挖掘,但NEALB的建议寻求帮助在mvsforum。COM付清…这是最终结果。与SORT/MERGE一起使用的OUTREC逻辑替换了OUTFIL,并利用了Syncsort 1.3中我没有意识到的新功能(IFTHEN, WHEN和OVERLAY)。提供当前文档是值得的!
*
* This MERGE logic is intended to assert that the Packed Decimal
* field has a negative sign with a B'....1101' value (Hex X'.D').
*
*
MERGE FIELDS=(27,5.4,BI,A),EQUALS
SUM FIELDS=NONE
OUTREC IFTHEN=(WHEN=(32,1,BI,NE,B'....1..1',OR,
32,1,BI,EQ,B'....1111'),
OVERLAY=(32:(-1,MUL,32,1,PD),PD,LENGTH=1)),
IFTHEN=(WHEN=(32,1,BI,EQ,B'....1..1',AND,
32,1,BI,NE,B'....1111'),
OVERLAY=(32:(+1,MUL,32,1,PD),PD,LENGTH=1))
#4
1
Looking at the last byte of a packed field is possible. You want positive/unsigned to negative, so if it is greater than -1, subtract it from zero.
查看填充字段的最后一个字节是可能的。你想让正/无符号变成负的,所以如果它大于-1,从0减去它。
From a short-lived Answer by MikeC, it is now known that the data contains non-preferred
signs (that is, it can contain A through F in the low-order half-byte, whereas a preferred
sign would be C (positive) or D (negative). F is unsigned, treated as positive.
从MikeC的短期回答中,我们知道数据包含非首选符号(也就是说,它可以在低阶半字节中包含a到F,而首选符号是C(正数)或D(负数)。F是无符号的,被视为阳性。
This is tested with DFSORT. It should work with SyncSORT. Turns out that DFSORT can understand a negative packed-decimal zero, but it will not create a negative packed-decimal zero (it will allow a zoned-decimal negative zero to be created from a negative zero packed-decimal).
这是用DFSORT测试的。它应该与SyncSORT一起工作。事实证明,DFSORT可以理解一个负的packed-decimal 0,但它不会创建一个负的packed-decimal 0(它将允许从负的zero packed-decimal中创建一个带-decimal - zero)。
The idea is that a non-preferred
sign is valid and will be accurately signed for input to a decimal machine instruction, but the result will always be a preferred
sign, and will be correct. So by adding zero first, the field gets turned into a preferred
sign and then the test for -1 will work as expected. With data in the sign-nybble for packed-decimal fields, SORT has some specific and documented behaviours, which just don't happen to help here.
这个想法是,一个非首选的符号是有效的,并且将被精确地签名,以便输入到十进制机器指令,但是结果将永远是一个首选的符号,并且将是正确的。所以通过先加零,字段就变成了首选符号,然后-1的测试就会像预期的一样。对于分组-十进制字段的sign-nybble数据,SORT有一些特定的和文档化的行为,这在这里没有帮助。
Since there is only one value to deal with to become the negative zero, X'0C', after the normalisation of signs already done, there is a simple test and replacement with a constant of X'0D' for the negative zero. Since the negative zero will not work, the second test is changed from the original minus one to zero.
由于只有一个值需要处理才能变成- 0,即X'0C',在符号已经被正常化之后,有一个简单的测试,用X'0D'的常数替换为- 0。因为- 0不起作用,第二个测试从原来的- 1变为0。
With non-preferred signs in the data:
数据中有非首选符号:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(32:+0,ADD,32,1,PD,TO=PD,LENGTH=1)),
IFTHEN=(WHEN=(32,1,CH,EQ,X'0C'),
OVERLAY=(32:X'0D')),
IFTHEN=(WHEN=(32,1,PD,GT,0),
OVERLAY=(32:+0,SUB,32,1,PD,TO=PD,LENGTH=1))
With preferred signs in the data:
数据中有首选符号:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(32,1,CH,EQ,X'0C'),
OVERLAY=(32:X'0D')),
IFTHEN=(WHEN=(32,1,PD,GT,0),
OVERLAY=(32:+0,SUB,32,1,PD,TO=PD,LENGTH=1))
Note: If non-preferred
signs are stuffed through a COBOL program not using compiler option NUMPROC(NOPFD) then results will be "interesting".
注意:如果不使用编译器选项NUMPROC(NOPFD)的COBOL程序填充非首选符号,那么结果将是“有趣的”。