MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Decimal values validation using DFSORT

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
ponnagantiln
Beginner


Joined: 13 May 2009
Posts: 7
Topics: 1

PostPosted: Wed Aug 19, 2015 11:57 am    Post subject: Decimal values validation using DFSORT Reply with quote

Hi,

I am trying to validate the decimal values which is amount . My validation in the file is that should be numeric values. Can you please help on this.

input file
----------
Code:

ABC 999.99
DEF 99.99
GHI 9.9
JKL 0.09
MNO 0.9
PQR 99.999
STU 9999.9
VWX 9.9999

Output Valid records are
---------------------------
Code:

ABC 999.99
DEF 99.99
GHI 9.9
JKL 0.09
MNO 0.9

INVALID
-----------
Code:
 
PQR 99.999
STU 9999.9
VWX 9.9999

Can you you help on DFSORT to validate the input file that its coming correct? The amount is 9(3).9(2). Output will have both valid and invalid files.

Thanks,
Lakshmi
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12384
Topics: 75
Location: San Jose

PostPosted: Wed Aug 19, 2015 1:09 pm    Post subject: Reply with quote

ponnagantiln,

Assuming your input file has an LRECL=80 and RECFM=FB and the numeric values start from position 5 use the folowing DFSORT JCL which will give you the desired results
Code:

//STEP0200 EXEC PGM=SORT                             
//SYSOUT   DD SYSOUT=*                               
//SORTIN   DD *                                       
----+----1----+----2----+----3----+----4----+----5----
ABC 999.99                                           
DEF 99.99                                             
GHI 9.9                                               
JKL 0.09                                             
MNO 0.9                                               
PQR 99.999                                           
STU 9999.9                                           
VWX 9.9999                                           
//SORTOUT  DD SYSOUT=*                               
//BAD      DD SYSOUT=*                               
//SYSIN    DD *                                       
  OPTION COPY                                         
  INREC PARSE=(%01=(ABSPOS=5,ENDBEFR=C'.',FIXLEN=4), 
               %02=(FIXLEN=3)),                       
     OVERLAY=(81:%01,%02)       
   
  OUTFIL BUILD=(1,80),                         
  OMIT=(84,1,CH,GT,C' ',OR,                     
        87,1,CH,GT,C' ')                       
                                               
  OUTFIL FNAMES=BAD,SAVE,BUILD=(1,80)           
//*                                             


SORTOUT will have
Code:
                                                   
ABC 999.99
DEF 99.99 
GHI 9.9   
JKL 0.09   
MNO 0.9   


and BAD will have
Code:

PQR 99.999
STU 9999.9
VWX 9.9999

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ponnagantiln
Beginner


Joined: 13 May 2009
Posts: 7
Topics: 1

PostPosted: Wed Aug 19, 2015 3:41 pm    Post subject: Reply with quote

Thank you for quick response.

Thanks,
Back to top
View user's profile Send private message
ponnagantiln
Beginner


Joined: 13 May 2009
Posts: 7
Topics: 1

PostPosted: Wed Aug 19, 2015 4:07 pm    Post subject: Decimal values validation using DFSORT Reply with quote

Hi,

Thank you for quick response. However I am quite confused to code this. can you pleasehelp me on this. below is my JCL and I am able to validate upto 46th byte. the Amount field is like 9(10).9(10) and that starts from 47th position till 67. The maximun value is 10 digits before decimal and 10 deigits decimal. From the file that is from 47th position to 67th. How to check for valid and invalid records. From the input first 10 records are valid and from 11th onwards the amount is invalid. Can you please help this.

Code:

 =COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
 ****** ***************************** Top of Data ******************************
 000001 00001111111                   8 S    20150529 256.42863                 
 000002 00002222222                   8 S    20150529 256423.63                 
 000003 00003333333                   8 S    20150529 25.642863                 
 000004 00004444444                   8 S    20150529 2564.28631111             
 000005 00005555555                   9 S    20150529 255555.974               
 000006 00006666666                   9 S    20150529 25534444.4444             
 000007 00007777777                   8 S    20150529 2554444444.5555555       
 000008 00008888888                   8 S    20150529 2553333333.4597455       
 000009 00009999999                   8 S    20150514 5.11045                   
 000010 00009999999                   8 S    20150514 0.1                       
 000011 00001111222                   8 S    20150514 5.110451111111           
 000012 00001111222                   8 S    20150514 6.1104511111111111       
 000013 00001111222                   8 S    20150514 61111111111.111111       
 000014 00001111222                   8 S    20150514 6.A123 

//*******************************************************************


Code:

//JS010   EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DISP=SHR,DSN=INPUT                                     
//*                                                                 
//VALID    DD DSN=FILE1
//            DISP=(New,CATLG,DELETE),UNIT=SYSDA,                   
//            SPACE=(CYL,(200,100),RLSE)                                                     
//*                                                                 
//INVAL    DD DSN=FILE2                                             
//            DISP=(New,CATLG,DELETE),UNIT=SYSDA,                   
//            SPACE=(CYL,(200,100),RLSE)                             
//SYSIN    DD  *                                                     
  OPTION COPY                                                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(1:1,91),HIT=NEXT),               
  IFTHEN=(WHEN=((1,11,FS,EQ,NUM),                                   
         AND,(12,19,CH,EQ,X'40404040404040404040404040404040404040'),
         AND,(31,1,FS,EQ,NUM),                                       
         AND,(32,1,CH,EQ,X'40'),                                     
         AND,(33,1,CH,EQ,C'C',OR,33,1,CH,EQ,C'I')),                 
         OVERLAY=(92:C'1'),HIT=NEXT),                               
  IFTHEN=(WHEN=(92,1,ZD,NE,1),                                       
         OVERLAY=(92:C'0'),HIT=NEXT),                                 
  IFTHEN=(WHEN=(38,8,CH,NE,C'00000000',AND,38,8,FS,EQ,NUM),           
         OVERLAY=(93:38,8,Y4T,TOGREG=Y4T),HIT=NEXT)                   
  OUTFIL FNAMES=VALID,BUILD=(1,91),                                   
  INCLUDE=(92,1,CH,EQ,C'1',AND,                                       
           93,1,CH,NE,C'*'),REMOVECC                                 
  OUTFIL FNAMES=INVAL,BUILD=(1,91),                                   
  INCLUDE=(92,1,CH,NE,C'1',OR,                                       
           93,1,CH,EQ,C'*'),REMOVECC
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12384
Topics: 75
Location: San Jose

PostPosted: Wed Aug 19, 2015 4:42 pm    Post subject: Reply with quote

ponnagantiln,

Please do not waste my time as well as your time. The above shown code is no where near what I suggested. You already have a lot of other validations which is done in the most round about manner and do you want to add the check for numeric along with the other validations?

It is tough to patch up a code without knowing the complete details. Is that an existing code and now you want to add the additional check? or did you code up that as a part of this requirement.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ponnagantiln
Beginner


Joined: 13 May 2009
Posts: 7
Topics: 1

PostPosted: Wed Aug 19, 2015 7:49 pm    Post subject: Reply with quote

Sorry for confusion. Thats existing code and I thought I can add this validation. Now instead of making complicate I like to write new sort fo rthis with two other validations as 1 to 10 as numeric check, 38 to 45 as Valid date check and 47 to 67 as Amount check. Amount is like 9(10).9(10). Can you please help me with this one.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12384
Topics: 75
Location: San Jose

PostPosted: Fri Aug 21, 2015 12:48 pm    Post subject: Reply with quote

ponnagantiln,

Use the following DFSORT JCL which will give you the desired results. I have added all your earlier checks as well as the numeric check for the new field and also the overflow of digits for the new field too.

Code:

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD DISP=SHR,DSN=&&IN                                         
//VALID    DD SYSOUT=*                                                 
//INVAL    DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  OPTION COPY                                                           
  ALTSEQ  CODE=(40F0)                      $ CHANGE ' ' TO '0'         
  INREC IFTHEN=(WHEN=INIT,                                             
        PARSE=(%01=(ABSPOS=47,ENDBEFR=C'.',FIXLEN=11),                 
               %02=(FIXLEN=11)),                                       
      OVERLAY=(092:%01,                                                 
               092:092,10,TRAN=ALTSEQ,     $ CHANGE ' ' TO '0'         
               103:%02,                                                 
               103:103,10,TRAN=ALTSEQ)),   $ CHANGE ' ' TO '0'         
                                                                       
  IFTHEN=(WHEN=(001,11,FS,EQ,NUM,AND,      $ CHECK FLD1 IS NUM         
                012,19,CH,EQ,C' ',AND,     $ CHECK FLD2 IS SPACES       
                031,01,FS,EQ,NUM,AND,      $ CHECK FLD3 IS NUM         
                032,01,CH,EQ,C' ',AND,     $ CHECK FLD4 IS SPACE       
                033,01,SS,EQ,C'C,I',AND,   $ CHECK FLD5 IS 'C' OR 'I'   
                092,10,FS,EQ,NUM,AND,      $ CHECK IF DIGITS ARE NUM   
                103,10,FS,EQ,NUM),         $ CHECK IF DECIMALS ARE NUM 
     OVERLAY=(114:C'V'),HIT=NEXT),                                     
                                                                       
  IFTHEN=(WHEN=(38,8,FS,EQ,NUM),           $ CHECK IF DATE IS NUM       
     OVERLAY=(115:38,8,Y4T,TOGREG=Y4T))    $ VALIDATE THE DATE         
                                                                       
  OUTFIL FNAMES=VALID,BUILD=(1,91),                                     
  OMIT=(102,1,CH,GT,C' ',OR,               $ DIGITS EXCEED 9(10)       
        113,1,CH,GT,C' ',OR,               $ DECIMALS EXCEED V9(10)     
        114,1,CH,EQ,C' ',OR,               $ INVALID FLD1-FLD5 CHECK   
        115,1,CH,EQ,C'*')                  $ INVALID DATE               
                                                                       
  OUTFIL FNAMES=INVAL,BUILD=(1,91),SAVE    $ WRITE ALL INVALID RECORDS 
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ponnagantiln
Beginner


Joined: 13 May 2009
Posts: 7
Topics: 1

PostPosted: Fri Aug 21, 2015 1:35 pm    Post subject: Reply with quote

Thank you for Help!

Thanks
Back to top
View user's profile Send private message
ponnagantiln
Beginner


Joined: 13 May 2009
Posts: 7
Topics: 1

PostPosted: Fri Aug 21, 2015 4:13 pm    Post subject: Reply with quote

SORT worked perfect for me and thanks again. I have one last question on this. would that be possible to format the decimal fields as 0000000256.4286300000 for Valid out put.

Thanks,
Lakshmi
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12384
Topics: 75
Location: San Jose

PostPosted: Fri Aug 21, 2015 5:02 pm    Post subject: Reply with quote

ponnagantiln wrote:
SORT worked perfect for me and thanks again. I have one last question on this. would that be possible to format the decimal fields as 0000000256.4286300000 for Valid out put.

Thanks,
Lakshmi


ponnagantiln,

Why do you have to add the requirements one after the another? How hard is to state the COMPLETE requirement instead of bits and pieces wasting our time as well as your time? You started off with something and then ended with up something else and now you have an additional requirement? Do you think people are working on your requirement all the time? People help out of their spare time and you can't expect them to go back and re-work on YOUR moving target requirement again and again do you? And once again your requirements are clear as dirt.


ponnagantiln wrote:
possible to format the decimal fields as 0000000256.4286300000 for Valid out put.


For the integer portion you decided to left pad with zeros which is the right way of handling numbers, but then for the decimals you started to right pad with zeros. So where is the consistency?

Is this the FINAL requirement or do you comeback once again with a new requirement?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ponnagantiln
Beginner


Joined: 13 May 2009
Posts: 7
Topics: 1

PostPosted: Fri Aug 21, 2015 8:33 pm    Post subject: Reply with quote

I am extremely sorry and its not my intention to waste your time by adding one after another. This is the final one and I am sure I dont give you any trouble. Thank you
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12384
Topics: 75
Location: San Jose

PostPosted: Sat Aug 22, 2015 1:23 pm    Post subject: Reply with quote

ponnagantiln,

You really need to pay attention to what I said. You did NOT answer my question about the inconsistent left and right padding of zeros.

Anyway here are the untested control cards
Code:

//SYSIN    DD *                                                       
  OPTION COPY                                                         
  ALTSEQ  CODE=(40F0)                      $ CHANGE ' ' TO '0'         
  INREC IFTHEN=(WHEN=INIT,                                             
        PARSE=(%01=(ABSPOS=47,ENDBEFR=C'.',FIXLEN=11),                 
               %02=(FIXLEN=11)),                                       
      OVERLAY=(092:%01,                                               
               092:092,10,TRAN=ALTSEQ,     $ CHANGE ' ' TO '0'         
               103:%02,                                               
               103:103,10,TRAN=ALTSEQ,     $ CHANGE ' ' TO '0'         
               124:%01)),                  $ ORIGINAL NUM DATA         
                                                                       
  IFTHEN=(WHEN=(001,11,FS,EQ,NUM,AND,      $ CHECK FLD1 IS NUM         
                012,19,CH,EQ,C' ',AND,     $ CHECK FLD2 IS SPACES     
                031,01,FS,EQ,NUM,AND,      $ CHECK FLD3 IS NUM         
                032,01,CH,EQ,C' ',AND,     $ CHECK FLD4 IS SPACE       
                033,01,SS,EQ,C'C,I',AND,   $ CHECK FLD5 IS 'C' OR 'I' 
                092,10,FS,EQ,NUM,AND,      $ CHECK IF DIGITS ARE NUM   
                103,10,FS,EQ,NUM),         $ CHECK IF DECIMALS ARE NUM
     OVERLAY=(114:C'V'),HIT=NEXT),                                     
                                                                       
  IFTHEN=(WHEN=(38,8,FS,EQ,NUM),           $ CHECK IF DATE IS NUM     
     OVERLAY=(115:38,8,Y4T,TOGREG=Y4T))    $ VALIDATE THE DATE         
                                                                       
                                                                       
  OUTFIL FNAMES=VALID,                                                 
  BUILD=(001,46,                           $ BYTES 01 THRU 46         
         123,10,UFF,M11,LENGTH=11,         $ FORMAT UFF NUM TO ZD     
         C'.',                             $ DECIMAL DOT               
         103,10,                           $ FORMATTED DECIMALS       
         068,23),                          $ BYTES 68 THRU 91         
  OMIT=(102,1,CH,GT,C' ',OR,               $ DIGITS EXCEED 9(10)       
        113,1,CH,GT,C' ',OR,               $ DECIMALS EXCEED V9(10)   
        114,1,CH,EQ,C' ',OR,               $ INVALID FLD1-FLD5 CHECK   
        115,1,CH,EQ,C'*')                  $ INVALID DATE             
                                                                       
  OUTFIL FNAMES=INVAL,BUILD=(1,91),SAVE    $ WRITE ALL INVALID RECORDS
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group