views:

54

answers:

3

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?

*
* 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)

+1  A: 

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?

If you did that, you could accept all three negative packed values xA, xB and xD.

Joe Zitzelberger
That's possible but there are multiple programs that would need to be modified and no two programs are alike. The SYNCSORT is the focal point where all the data flows through. It makes sense to apply the change there (if possible). I'll give your answer a vote but it's not my preference.
MikeC
+1  A: 

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.

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.

This is a very general outline, but I hope it helps.

NealB
I had considered E15 and that might be the best alternative but not as clean-cut as I'd hope. SYNCSORT is what it is. If there are no better suggestions this would be the approach I'd take.
MikeC
A: 

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!

*                                                                
* 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))  
MikeC