Page 1 of 1

Change negative ZD to unsigned.

PostPosted: Wed Mar 24, 2010 12:07 am
by schneiderusa
Hello,

Is it possible to change negative ZD to positive ZD or unsigned in SORT?

For example before sort some number are negative "-1000.00" PIC S9(15)V99.
and after sort I need them to be unsigned "1000.00" PIC 9(15)V99.

Thank you.

Re: Change negative ZD to unsigned.

PostPosted: Wed Mar 24, 2010 12:31 am
by Frank Yaeger
PIC S9(15)V99 would be a 17-byte ZD value.

You can use DFSORT control statements like this. For the example, I assumed your 17 byte ZD value starts in position 11. Adjust appropriately.

    OPTION COPY
    INREC IFTHEN=(WHEN=(11,17,ZD,LT,0),
       OVERLAY=(11:11,17,ZD,MUL,-1,TO=ZDC,LENGTH=17))


If you want an F for the positive sign instead of a C, use TO=ZDF instead of TO=ZDC.

Re: Change negative ZD to unsigned.

PostPosted: Wed Mar 24, 2010 12:59 am
by schneiderusa
Thank you Frank,

This my SORT. I actually have two fields that needs to be unsigned. First I add amounts and then I need to show them unsigned.
Did I code this correctly?

//SYSIN DD *
SORT FIELDS=(9,8,CH,A,22,12,CH,A,42,11,CH,A,484,2,CH,A)
SUM FIELDS=(55,17,ZD,73,15,ZD)
INREC IFTHEN=(WHEN=(55,17,ZD,LT,0),
OVERLAY=(55:55,17,ZD,MUL,-1,TO=ZDC,LENGTH=17))
INREC IFTHEN=(WHEN=(73,15,ZD,LT,0),
OVERLAY=(73:73,15,ZD,MUL,-1,TO=ZDC,LENGTH=15))

//SYSOUT DD SYSOUT=*

Re: Change negative ZD to unsigned.

PostPosted: Wed Mar 24, 2010 1:20 am
by schneiderusa
Hi Frank,
It works for one field, how do I add second "IFTHEN" condition?

//SYSIN DD *
SORT FIELDS=(9,8,CH,A,22,12,CH,A,42,11,CH,A,484,2,CH,A)
SUM FIELDS=(55,17,ZD,73,15,ZD)
OUTREC IFTHEN=(WHEN=(73,15,ZD,LT,0),
OVERLAY=(73:73,15,ZD,MUL,-1,TO=ZDF,LENGTH=15))
IFTHEN=(WHEN=(55,17,ZD,LT,0),
OVERLAY=(55:55,17,ZD,MUL,-1,TO=ZDC,LENGTH=17))
//SYSOUT DD SYSOUT=*

Thanks,
Gary.

Re: Change negative ZD to unsigned.

PostPosted: Wed Mar 24, 2010 1:34 am
by schneiderusa
I got it, just forgot to put comma. Thank you. Nice forum :D

//SYSIN DD *
SORT FIELDS=(9,8,CH,A,22,12,CH,A,42,11,CH,A,484,2,CH,A)
SUM FIELDS=(55,17,ZD,73,15,ZD)
OUTREC IFTHEN=(WHEN=(73,15,ZD,LT,0),
OVERLAY=(73:73,15,ZD,MUL,-1,TO=ZDF,LENGTH=15)),
IFTHEN=(WHEN=(55,17,ZD,LT,0),
OVERLAY=(55:55,17,ZD,MUL,-1,TO=ZDF,LENGTH=17))
//SYSOUT DD SYSOUT=*

Re: Change negative ZD to unsigned.

PostPosted: Wed Mar 24, 2010 2:48 am
by Frank Yaeger
I got it, just forgot to put comma. Thank you. Nice forum


Actually, you should use HIT=NEXT for the first IFTHEN clause to make sure you get to the second one since they involve two different fields.

//SYSIN DD *
   SORT FIELDS=(9,8,CH,A,22,12,CH,A,42,11,CH,A,484,2,CH,A)
  SUM FIELDS=(55,17,ZD,73,15,ZD)
  OUTREC IFTHEN=(WHEN=(73,15,ZD,LT,0),
    OVERLAY=(73:73,15,ZD,MUL,-1,TO=ZDF,LENGTH=15),HIT=NEXT),
   IFTHEN=(WHEN=(55,17,ZD,LT,0),
      OVERLAY=(55:55,17,ZD,MUL,-1,TO=ZDF,LENGTH=17))

Re: Change negative ZD to unsigned.

PostPosted: Wed Mar 24, 2010 11:46 pm
by schneiderusa
I just tried HIT=NEXT and it doesn't work:
            //SYSIN DD *                                                 
            $                                                           
ICE007A 1 SYNTAX ERROR                                                   
               SORT FIELDS=(9,8,CH,A,22,12,CH,A,42,11,CH,A,484,2,CH,A)   
              SUM FIELDS=(55,17,ZD,73,15,ZD)                             
              OUTREC IFTHEN=(WHEN=(73,15,ZD,LT,0),                       
                OVERLAY=(73:73,15,ZD,MUL,-1,TO=ZDF,LENGTH=15),HIT=NEXT),
               IFTHEN=(WHEN=(55,17,ZD,LT,0),                             
                  OVERLAY=(55:55,17,ZD,MUL,-1,TO=ZDF,LENGTH=17))         
ICE751I 0 C5-K47561 C6-K90014 C7-K45047 C8-K46331 E7-K44564             
ICE052I 3 END OF DFSORT

Re: Change negative ZD to unsigned.

PostPosted: Thu Mar 25, 2010 12:25 am
by dick scherrer
Hello,

Does "//SYSIN DD *" begin in position 1?

Is "generated statement" anywhere in the output?

Re: Change negative ZD to unsigned.

PostPosted: Thu Mar 25, 2010 1:15 am
by Frank Yaeger
schneiderusa,

This has nothing to do with HIT=NEXT.

Your //SYSIN DD * statement is being interpreted as a control statement instead of a JCL statement. It appears you have the // starting in position 3 rather than in position 1. Fix that.