Problem with signs

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
ShivanoTE
Member
Posts: 7
Joined: Thu Dec 18, 2014 8:26 pm

Problem with signs

Post by ShivanoTE » Thu Dec 18, 2014 9:04 pm

Hi guys, I try to convert a number (ZD without sign) to PD, but the sign is unpacked at the end.

My SORTIN:

Code: Select all

----+----1----+----2----+----3----+----4--
CONV0000089800000002346768+00000000000000+
CONV0000095000000022186672-00000000000000+
CONV0000102600000023887500+00000000000000+
DEPO0017991200000229391190+00000000000000+
DEPO0392080100000131250000-00000000000000+
DEPO0850124300000000000000+00000000000000+
DEPO0899368800000003266668+00000000000000+
DEPO2940102000000000000000+00000000000000+
I0012360002700000000000000+00000000000000+
I0012370004100000000255509+00000000060238+
The first 12 chars I keepit in the same place. The next 15 chars are the number to convert and the last one is the sign '+' or '-' to do that possible. The same with the other number (28 to 42).
I need to keep this 12 chars right there and put, next to that, a length=8 PD, positive o negative (it depends in the sign (last position)).
I try it with a IFTHEN but I have troubles with the 2nd number.

Can you giveme a hand?
Thanks to read!
"No hay fé sin sangre."

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Thu Dec 18, 2014 10:00 pm

why not show us your sort cards, so that they maybe corrected?
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

ShivanoTE
Member
Posts: 7
Joined: Thu Dec 18, 2014 8:26 pm

Post by ShivanoTE » Thu Dec 18, 2014 11:02 pm

OK. I got this:

Code: Select all

//STEP0040 EXEC PGM=SORT                                 
//SYSPRINT DD SYSOUT=*                                   
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD DSN=INFILE,DISP=SHR                
//SORTOUT  DD DSN=OUTFILE,                    
//            DISP=(NEW,CATLG),                          
//            SPACE=(TRK,(10,10),RLSE),                  
//            DCB=(RECFM=FB,DSORG=PS,LRECL=250,BLKSIZE=0)
//SYSIN    DD *                                          
  SORT   FIELDS=COPY                                     
  OUTREC IFTHEN=(WHEN=INIT,BUILD=(1,250)),               
            IFTHEN=(WHEN=(027,1,CH,EQ,C'-'),             
           OVERLAY=(013:13,14,FS,MUL,-1,TO=PD,LENGTH=8)),
            IFTHEN=(WHEN=(027,1,CH,EQ,C'+'),             
           OVERLAY=(013:13,14,FS,TO=PD,LENGTH=8)),       
            IFTHEN=(WHEN=(042,1,CH,EQ,C'-'),             
           OVERLAY=(021:28,14,FS,MUL,-1,TO=PD,LENGTH=8)),
            IFTHEN=(WHEN=(042,1,CH,EQ,C'+'),             
           OVERLAY=(021:28,14,FS,TO=PD,LENGTH=8))        
But it doesn't work correctly. If the signs are distinct between the two 'columns' the signs in the PD number will be wrong.
I'm stuck, maybe I need to use CHANGE or another function, I don't know...
"No hay fé sin sangre."

ShivanoTE
Member
Posts: 7
Joined: Thu Dec 18, 2014 8:26 pm

Post by ShivanoTE » Fri Feb 20, 2015 12:13 am

Finally I made the sort to convert those numeric fields...

Code: Select all

//********************************************************************
//STEP0040 EXEC PGM=ICETOOL                                           
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//SHOWDEF  DD SYSOUT=*                                                 
//ENT1     DD DSN=ENTRADA1
//SAL1     DD DSN=SALIDA1,DISP=(NEW,CATLG),           
//            SPACE=(CYL,(5,5),RLSE),                                 
//            DCB=(RECFM=FB,DSORG=PS,LRECL=250,BLKSIZE=0)             
//ENT2     DD DSN=ENTRADA2,DISP=SHR                         
//SAL2     DD DSN=SALIDA2,DISP=(NEW,CATLG),           
//            SPACE=(CYL,(5,5),RLSE),                                 
//            DCB=(RECFM=FB,DSORG=PS,LRECL=250,BLKSIZE=0)             
//TOOLIN   DD *                                                       
  SUBSET FROM(ENT1) TO(SAL1) REMOVE OUTPUT HEADER TRAILER USING(FOR1) 
  SUBSET FROM(ENT2) TO(SAL2) REMOVE OUTPUT HEADER TRAILER USING(FOR2) 
//FOR1CNTL DD *                                                       
  OUTFIL FNAMES=SAL1,REMOVECC,                                         
          BUILD=(001,12,                                               
                 013,15,SFF,TO=PD,LENGTH=8,                           
                 028,15,SFF,TO=PD,LENGTH=8,                           
                 043,15,SFF,TO=PD,LENGTH=8,                             
                 058,15,SFF,TO=PD,LENGTH=8,                             
                 073,15,SFF,TO=PD,LENGTH=8,                             
                 088,15,SFF,TO=PD,LENGTH=8,                             
                 103,15,SFF,TO=PD,LENGTH=8,                             
                 118,15,SFF,TO=PD,LENGTH=8,                             
                 133,15,SFF,TO=PD,LENGTH=8,                             
                 148,15,SFF,TO=PD,LENGTH=8,                             
                 163,15,SFF,TO=PD,LENGTH=8,                             
                 250:C'*')                                             
//FOR2CNTL DD *                                                         
  OUTFIL FNAMES=SAL2,REMOVECC,                                         
          BUILD=(001,12,                                               
                 013,15,SFF,TO=PD,LENGTH=8,                             
                 028,15,SFF,TO=PD,LENGTH=8,                             
                 043,15,SFF,TO=PD,LENGTH=8,                             
                 058,15,SFF,TO=PD,LENGTH=8,                             
                 073,15,SFF,TO=PD,LENGTH=8,                             
                 088,15,SFF,TO=PD,LENGTH=8,                             
                 103,15,SFF,TO=PD,LENGTH=8,                             
                 118,15,SFF,TO=PD,LENGTH=8,                             
                 133,15,SFF,TO=PD,LENGTH=8,                             
                 148,15,SFF,TO=PD,LENGTH=8,                             
                 163,15,SFF,TO=PD,LENGTH=8,                             
                 250:C'*')                                              
The problem is the inverse (PD to SFF). The problem is the sign, I managed to put it at the start of the field instead in the end. The function "EDIT(TTT....),SIGNS(+,-)" does not work in that case. Any body know why?
This is what I got:

Code: Select all

//********************************************************************
//STEP0040 EXEC PGM=SORT                                               
//SYSPRINT DD SYSOUT=*                                                 
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD DSN=ENTRADA
//SORTOUT  DD DSN=SALIDA,
//            SPACE=(CYL,(5,5),RLSE),                                 
//            DCB=(RECFM=FB,DSORG=PS,LRECL=500,BLKSIZE=0)             
//SYSIN    DD *                                                       
  OPTION COPY                                                         
  OUTFIL FNAMES=SORTOUT,REMOVECC,                                     
        HEADER1=(C'HDR - ',             
                 DATENS=(4MD),            
                 500:C'*'),                 
          BUILD=(001,12,                                               
                 013,08,PD,M26,                                       
                 021,08,PD,M26,                                         
                 029,08,PD,M26,                                         
                 037,08,PD,M26,                                         
                 045,08,PD,M26,                                         
                 053,08,PD,M26,                                         
                 061,08,PD,M26,                                         
                 069,08,PD,M26,                                         
                 077,08,PD,M26,                                         
                 085,08,PD,M26,                                         
                 093,08,PD,M26,                                         
                 101,08,PD,M26,                                         
                 109,08,PD,M26,                                         
                 117,08,PD,M26,                                         
                 125,08,PD,M26,                                         
                 133,08,PD,M26,                                         
                 141,08,PD,M26,                                         
                 149,08,PD,M26,                                         
                 157,08,PD,M26,                                         
                 165,08,PD,M26,                                         
                 173,08,PD,M26,                                         
                 181,08,PD,M26,                                         
                 189,03,                                               
                 500:C'*'),                                             
       TRAILER1=(C'TRL - ',             
                 C'CANT. REG = ',         
                 COUNT(M11,LENGTH=10),  
                 500:C'*')                 
//                                                                      
"No hay fé sin sangre."

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others