Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

EDITing numeric values

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
senthilnathanj

New User


Joined: 31 Jul 2007
Posts: 47
Location: chennai

PostPosted: Fri Nov 16, 2012 10:31 pm    Post subject: EDITing numeric values
Reply with quote

Hi,

The input is like below in UFF format of 7 bytes (decimal point upto 3 bytes and whole number upto 3 bytes)

Code:
5     
4.2   
10.66
10.66
11.81
11.81


I want to convert that into below format... like 9(3)V9(3) format.

Expected output:

Code:
005000
004200
010660
010660
011810
011810


Tried with the below code.

Code:
 OPTION COPY                                   
 INREC BUILD=(1,7,UFF,EDIT=(TTTTTT),LENGTH=6) 


I got the below result.

Code:
000005
000042
001066
001066
001181
001181


Please advise on how to adjust SORT card.
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Nov 16, 2012 10:42 pm    Post subject:
Reply with quote

Hello,

Why the trailing zero?

To get what you want, you could MULtiply by 10?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Fri Nov 16, 2012 10:43 pm    Post subject: Reply to: EDITing numeric values
Reply with quote

Have a look at this.
Back to top
View user's profile Send private message
senthilnathanj

New User


Joined: 31 Jul 2007
Posts: 47
Location: chennai

PostPosted: Sun Nov 18, 2012 12:05 am    Post subject: Reply to: EDITing numeric values
Reply with quote

Hi Dick,

I have tried with MULTIPLY by 10 in Sort card.

My Output:

Code:

005000
000420
010660
010660
011810
011810


Excepted Output :
Code:

005000
004200
010660
010660
011810
011810


Please Advise...
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sun Nov 18, 2012 1:03 am    Post subject:
Reply with quote

Hello,

It may help if you post your new sort control statements.

When i first read your data, i missed some of the expected output and got hung up on the trailing zero icon_redface.gif

Suspect you will be ahead if you review the link Bill provided and try that approach.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Sun Nov 18, 2012 5:30 am    Post subject: Reply to: EDITing numeric values
Reply with quote

The Sort products do not know about decimal places in any data definitions.

If you want to use assumed, or actual, decimal places, then you have to cater for them yourself.

In your case, you have a "floating" decimal place, which at times is absent - caused by the removal of trailing zeros by whatever has generated the data.

The easiest thing is if whatever that is can be changed to produce the format you want instead.

If that is not possible, then you have to do the processing to deal with the 0, 1, 2 (or 3?) decimal places following the decimal point. Kolusu has already provided (in the link) code to do this which you should be able to adapt for your specific situation.

If you have problems with that, post the full sysout from the step in the Code tags, please, and explain what is wrong, showing your sample input which covers all possible cases (does the three places exits?) and expected and received output. RECFM and LRECL of files.
Back to top
View user's profile Send private message
senthilnathanj

New User


Joined: 31 Jul 2007
Posts: 47
Location: chennai

PostPosted: Mon Nov 19, 2012 12:22 pm    Post subject: Reply to: EDITing numeric values
Reply with quote

Hi ,

My Input File:
Code:

1023654,Y30,04/01/2012,11.81,BV,,Q,
1023654,Y42,04/01/2012,5.00,BV,,Q,
1023654,Y43,04/01/2012,0.5,BV,,Q, 
1023654,Y45,04/01/2012,0.81,BV,,Q,
1023654,Y46,04/01/2012,4.2,BV,,Q, 
1023654,Y47,04/01/2012,11.81,BV,,Q,
1023654,Y48,04/01/2012,5.97,BV,,Q,


Sort card:

Code:

//SYSIN    DD *                                   
   OPTION COPY                                   
   INREC IFTHEN=(WHEN=INIT,                       
         PARSE=(%01=(ENDBEFR=C',',FIXLEN=09),     
                %02=(ENDBEFR=C',',FIXLEN=03),     
                %03=(ENDBEFR=C',',FIXLEN=10),     
                %04=(ENDBEFR=C',',FIXLEN=06),     
                %05=(ENDBEFR=C',',FIXLEN=02),     
                %06=(ENDBEFR=C',',FIXLEN=11),     
                %07=(ENDBEFR=C',',FIXLEN=01),     
                %08=(ENDBEFR=C',',FIXLEN=10)),   
   BUILD=(1,4,                                   
          %01,UFF,M11,LENGTH=09,X,               
          %02,                                   
          %03,UFF,M11,LENGTH=08,X,               
          %04,UFF,M11,LENGTH=06,X,               
          %08,UFF,M11,LENGTH=08,X,               
          %07,X,                                 
          %05,X,                                 
          %06,UFF,EDIT=(TTTTTTTTTTT),LENGTH=11,X,             
          %03))                                               
        OUTFIL VTOF,BUILD=(5,13,24,2,18,2,20,2,26,1,           
                             27,6,ZD,MUL,+10,TO=ZDF,LENGTH=6, 
                             33,1,38,4,34,2,36,2,42,18,       
                             66,4,60,2,63,2)                   
/*   


My Output dataset:
Code:

001023654 Y30120401 011810 00000000 Q BV 00000000000 20120401
001023654 Y42120401 005000 00000000 Q BV 00000000000 20120401
001023654 Y43120401 000050 00000000 Q BV 00000000000 20120401
001023654 Y45120401 000810 00000000 Q BV 00000000000 20120401
001023654 Y46120401 000420 00000000 Q BV 00000000000 20120401
001023654 Y47120401 011810 00000000 Q BV 00000000000 20120401
001023654 Y48120401 005970 00000000 Q BV 00000000000 20120401


Excepted Output:
Code:

001023654 Y30120401 011810 00000000 Q BV 00000000000 20120401
001023654 Y42120401 005000 00000000 Q BV 00000000000 20120401
001023654 Y43120401 000500 00000000 Q BV 00000000000 20120401
001023654 Y45120401 000810 00000000 Q BV 00000000000 20120401
001023654 Y46120401 004200 00000000 Q BV 00000000000 20120401
001023654 Y47120401 011810 00000000 Q BV 00000000000 20120401
001023654 Y48120401 005970 00000000 Q BV 00000000000 20120401


3th and 5th record is not correct.
Please advise..
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Mon Nov 19, 2012 12:40 pm    Post subject: Reply to: EDITing numeric values
Reply with quote

Did you follow that link? You don't have any code to deal with the "." and the number of decimal places.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 785
Location: Chennai, India

PostPosted: Tue Nov 20, 2012 4:26 pm    Post subject: Reply to: EDITing numeric values
Reply with quote

Hi,

I've changed your SORT card as below.

Code:
//SYSIN    DD *
   OPTION COPY                                 
   INREC IFTHEN=(WHEN=INIT,                               
         PARSE=(%01=(ENDBEFR=C',',FIXLEN=09),             
                %02=(ENDBEFR=C',',FIXLEN=03),             
                %03=(ENDBEFR=C',',FIXLEN=10),             
                %04=(ENDBEFR=C',',FIXLEN=06),             
                %05=(ENDBEFR=C',',FIXLEN=02),             
                %06=(ENDBEFR=C',',FIXLEN=11),             
                %07=(ENDBEFR=C',',FIXLEN=01),             
                %08=(ENDBEFR=C',',FIXLEN=10)),             
   BUILD=(1,4,                                             
          %01,UFF,M11,LENGTH=09,X,                         
          %02,                                             
          %03,UFF,M11,LENGTH=08,X,                         
          %04,X,                                           
          %08,UFF,M11,LENGTH=08,X,                         
          %07,X,                                           
          %05,X,                                           
          %06,UFF,EDIT=(TTTTTTTTTTT),LENGTH=11,X,         
          %03))                                           
        OUTFIL VTOF,BUILD=(5,13,24,2,18,2,20,2,26,1,             
                             27,6,                               
                             33,1,38,4,34,2,36,2,42,18,           
                             66,4,60,2,63,2)                     
/*


Added one more SORT step with the below card, to apply the numeric conversion.

Code:
//SYSIN    DD *                                                         
 OPTION COPY                                                           
  INREC IFTHEN=(WHEN=INIT,PARSE=(%01=(ABSPOS=21,ENDBEFR=C'.',FIXLEN=3),
                 %02=(FIXLEN=3)),                                       
          OVERLAY=(21:%01,UFF,TO=ZD,LENGTH=3,24:%02)),                 
         IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=21,ENDPOS=26,             
          INOUT=(C' ',C'0')))                                           
/*   


Please test and let us know the results. Thank you.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Tue Nov 20, 2012 10:41 pm    Post subject: Reply to: EDITing numeric values
Reply with quote

It doesn't need the 2nd step, can be done in the same step. Only the last three bytes need to be checked for space - in fact, it seems the third byte will always be zero, so on confirmation could be made a literal.
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Wed Nov 21, 2012 11:40 am    Post subject: Reply to: EDITing numeric values
Reply with quote

I did few changes to senthilnathanj's code and got the output...

Code:

//STEP1   EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
1023654,Y30,04/01/2012,11.81,BV,,Q,
1023654,Y42,04/01/2012,5.00,BV,,Q,
1023654,Y43,04/01/2012,0.5,BV,,Q,
1023654,Y45,04/01/2012,0.81,BV,,Q,
1023654,Y46,04/01/2012,4.2,BV,,Q,
1023654,Y47,04/01/2012,11.81,BV,,Q,
1023654,Y48,04/01/2012,5.97,BV,,Q,
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
     INREC IFTHEN=(WHEN=INIT,
           PARSE=(%01=(ENDBEFR=C',',FIXLEN=09),
                  %02=(ENDBEFR=C',',FIXLEN=03),
                  %03=(ENDBEFR=C',',FIXLEN=10),
                  %04=(ENDBEFR=C'.',FIXLEN=04),
                  %05=(ENDBEFR=C',',FIXLEN=04),
                  %06=(ENDBEFR=C',',FIXLEN=03),
                  %07=(ENDBEFR=C',',FIXLEN=11),
                  %08=(ENDBEFR=C',',FIXLEN=01),
                  %09=(ENDBEFR=C',',FIXLEN=10)),
     BUILD=(%01,UFF,M11,LENGTH=09,X,
            %02,
            %03,UFF,M11,LENGTH=08,X,
            %04,UFF,M11,LENGTH=5,         
            %05,JFY=(SHIFT=LEFT),X,         
            %09,UFF,EDIT=(TTTTTTTTTTT),LENGTH=08,X,         
            %08,X,
            %06,X,
            %07,UFF,EDIT=(TTTTTTTTTTT),LENGTH=11,X,
            %03))
    OUTREC BUILD=(1,13,20,2,14,2,16,2,
    20:25,6,ZD,M11,LENGTH=7,28:33,8,X,42,1,X,44,2,X,48,11,X,
    54:66,4,60,2,63,2)



Code:

001023654 Y30120401 011810 00000000 Q BV 00000000000 20120401
001023654 Y42120401 005000 00000000 Q BV 00000000000 20120401
001023654 Y43120401 000500 00000000 Q BV 00000000000 20120401
001023654 Y45120401 000810 00000000 Q BV 00000000000 20120401
001023654 Y46120401 004200 00000000 Q BV 00000000000 20120401
001023654 Y47120401 011810 00000000 Q BV 00000000000 20120401
001023654 Y48120401 005970 00000000 Q BV 00000000000 20120401


Thanks
-3nadh
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Using 'parm' to vary SORTOUT record v... Sysaron DFSORT/ICETOOL 13 Wed Sep 07, 2016 9:24 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us