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 

Need help with formatting a field value

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


Joined: 24 Dec 2008
Posts: 7
Topics: 3
Location: India

PostPosted: Fri Sep 04, 2015 6:39 am    Post subject: Need help with formatting a field value Reply with quote

Hi

I am trying to parse a csv file as below :

Input :
Code:

aaa,6.5,ccc
sssss,0,hhh
ccc,1,fffff
hhhhh,12.45,jjjjjj

I am using :
Code:

OUTREC PARSE=(%01=(ENDBEFR=C’,’,FIXLEN=8),
(%02=(ENDBEFR=C’,’,FIXLEN=10),
%03=(ENDBEFR=C’,’,FIXLEN=8)),
BUILD=(%01,X,%02,X,%03)


Output I got :
Code:

aaa     6.5          ccc
sssss   0             hhh
ccc      1             fffff
hhhhh  12.45      jjjjjj


Output expected :
Code:

aaa       6.5000      ccc
sssss     0.0000      hhh
ccc        1.0000      fffff
hhhhh  12.4500      jjjjjj

Please suggest how can I get it formatted like that.

-AK
_________________
-AK
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Sep 04, 2015 12:20 pm    Post subject: Reply with quote

akash_rgh,

You simply parsed and did not add any edit masks to the parsed variables that it would append zeroes at the end. Secondly you have a mixed bag of numeric values that have a decimal values and others that do not have them.

In such cases you need to re-parse the field once again.

Use the following DFSORT JCL which will give you the desired results
Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                         
AAA,6.5,CCC                                             
SSSSS,0,HHH                                             
CCC,1,FFFFF                                             
HHHHH,12.45,JJJJJJ                                       
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                         
  OPTION COPY                                           
  ALTSEQ  CODE=(40F0)                                   
  INREC IFTHEN=(WHEN=INIT,                               
        PARSE=(%01=(ENDBEFR=C',',FIXLEN=8),             
               %02=(ENDBEFR=C',',FIXLEN=10),             
               %03=(ENDBEFR=C',',FIXLEN=8)),             
        BUILD=(%01,X,                                   
               %02,X,                                   
               %03)),                                   
  IFTHEN=(WHEN=(9,10,SS,EQ,C'.'),                       
         PARSE=(%04=(ABSPOS=9,ENDBEFR=C'.',FIXLEN=5),   
                %05=(FIXLEN=4)),                         
      OVERLAY=(09:%04,UFF,EDIT=(IIIIT),C'.',             
                  %05,TRAN=ALTSEQ)),                     
  IFTHEN=(WHEN=NONE,                                     
      OVERLAY=(09:09,10,UFF,EDIT=(IIIIT),C'.0000'))     
                                                         
//*

_________________
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