IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Reformatting amounts in input file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Tue Jun 07, 2011 9:28 am
Reply with quote

Hi,
I have uploaded notepad into mainframes which is having account number and 3 amounts. I want to reformat the amounts as shown below.

No specific positions between amounts except the space delimeter.
I want to convert each amount to 15 bytes removing decimal and filling zeroes.

Input File:
Code:

100001 2342.34 1221.30 0
100002 423.25 523.12 9.23
100003 78.48 8.75 1.10


Output File:
Code:

100001 000000000234234 000000000122130 000000000000000
100002 000000000042325 000000000052312 000000000000923
100003 000000000007848 000000000000875 000000000000110


Please let me know how to achive the above output.

Thanks,
Bhaskar
Back to top
View user's profile Send private message
sriram.mukundan

New User


Joined: 20 Nov 2007
Posts: 28
Location: chennai

PostPosted: Tue Jun 07, 2011 11:28 am
Reply with quote

these datas are generally delimited by the tab delimiter and postion may vary from record to record ?
Back to top
View user's profile Send private message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Tue Jun 07, 2011 11:37 am
Reply with quote

Hi Sriram,
Yes. What you said is correct. They will be delimited by tab and vary from record to record.

Thanks,
Bhaskar
Back to top
View user's profile Send private message
ajay_diaz
Warnings : 1

New User


Joined: 12 Sep 2005
Posts: 28

PostPosted: Tue Jun 07, 2011 11:50 am
Reply with quote

Try this :
Code:

//STEP01 EXEC PGM=SORT
//SORTIN DD *
100001 2342.34 1221.30 0
100002 423.25 523.12 9.23
100003 78.48 8.75 1.10
//SORTOUT DD SYSOUT = *
//SYSIN DD *
   OUTREC PARSE=(%01=(ENDBEFR=C' ',FIXLEN=6),
                 %02=(ENDBEFR=C' ',FIXLEN=15),
                 %03=(ENDBEFR=C' ',FIXLEN=15),
                 %04=(FIXLEN=15)),
   BUILD=(%01,
          08:%02,SFF,EDIT=(TTTTTTTTTTTTTTT),
          24:%03,SFF,EDIT=(TTTTTTTTTTTTTTT),
          40:%04,SFF,EDIT=(TTTTTTTTTTTTTTT))
   SORT FIELDS=(1,6,CH,A)
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jun 07, 2011 12:00 pm
Reply with quote

Bhaskar,

In your sample data you have a zero which appears as 0 not 0.00. Can you confirm what a whole number (no decimal part) would appear as? So, one, for instance, will it appear as 1 or 1.00? If the former, you can consider rolling with what you have already. If not, then look in forum for quite similar task over last few days.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jun 07, 2011 12:15 pm
Reply with quote

if there are indeed tabs between fields
(as the TS indicated)
then the following will provide the solution to the TS's requirement:
Code:

OUTREC PARSE=(%01=(ENDBEFR=X'05',FIXLEN=6),
              %02=(ENDBEFR=X'05',FIXLEN=15),
              %03=(ENDBEFR=X'05',FIXLEN=15),
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jun 08, 2011 12:03 am
Reply with quote

If you want to pad zeroes for the missing decimals then use the following DFSORT control cards


Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                           
100001 2342.34 1221.30 1                                 
100002 423.25 523.12 9.23                                 
100003 78.48 8.75 1.10                                   
100004 3.43 9.56 2.3                                     
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                       
  INREC PARSE=(%01=(ENDBEFR=C' ',FIXLEN=6),               
               %02=(ENDBEFR=C' ',FIXLEN=15),             
               %03=(ENDBEFR=C' ',FIXLEN=15),             
               %04=(ENDBEFR=C' ',ENDBEFR=C'.',FIXLEN=13),
               %05=(FIXLEN=2)),                           
     BUILD=(%01,X,                                       
            %02,SFF,M11,LENGTH=15,X,                     
            %03,SFF,M11,LENGTH=15,X,                     
            %04,SFF,M11,LENGTH=13,                       
            %05)                                         
                                                         
  OUTREC FINDREP=(STARTPOS=52,INOUT=(C' ',C'0'))         
//*


This will produce

Code:

100001 000000000234234 000000000122130 000000000000100
100002 000000000042325 000000000052312 000000000000923
100003 000000000007848 000000000000875 000000000000110
100004 000000000000343 000000000000956 000000000000230
Back to top
View user's profile Send private message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 123
Location: Hyderabad

PostPosted: Wed Jun 08, 2011 12:46 am
Reply with quote

Hi All,

Thank you so much.
The job ran fine I got the expected output.

Thanks once again.

- Bhaskar
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top