|
View previous topic :: View next topic
|
| Author |
Message |
rajatbagga
Active User

Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
I need to convert the Comma Separated Values format to FB format. The requirement :-
Input file :-
| Code: |
439991735,11160,1
479819099,11218,1
209043099,11408,1.39
16256299,12001,3.19
16320799,12001,10.96 |
Expected output :-
| Code: |
011160 439991735 0000000000100
011218 479819099 0000000000100
011408 209043099 0000000000139
012001 016256299 0000000000319
012001 016320799 0000000001096 |
I have coded the below code :-
| Code: |
//SYSIN DD *
OPTION COPY
OUTREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=10),
%02=(ENDBEFR=C',',FIXLEN=06),
%03=(ENDBEFR=C',',FIXLEN=13)),
BUILD=(1:%02,SFF,EDIT=(TTTTTT),
08:%01,SFF,EDIT=(TTTTTTTTT),
018:%03,SFF,EDIT=(TTTTTTTTTTTTT),
80:X)
/* |
I have getting the below output which is not correct
| Code: |
011160 439991735 0000000000001 -- WRONG
011218 479819099 0000000000001 -- WRONG
011408 209043099 0000000000139
012001 016256299 0000000000319
012001 016320799 0000000001096 |
Please let me know how do i get the expected output.
Thank You,
Rajat |
|
| Back to top |
|
 |
dbzTHEdinosauer
Global Moderator

Joined: 20 Oct 2006 Posts: 6965 Location: porcelain throne
|
|
|
|
| you are going to have to perform some type of inrec overlay to add a '.00' to any record that does not have a '.'. |
|
| Back to top |
|
 |
rajatbagga
Active User

Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
Hello,
Thank's for the suggestion, this would work but please let me know how do i achieve this as the position of '.' is variable, how do i search my third column of the below Input file and then overlay '.00' if '.' is not present at the end.
Input :-
| Code: |
439991735,11160,1
479819099,11218,1
209043099,11408,1.39
16256299,12001,3.19
16320799,12001,10.96 |
Expected output :-
| Code: |
439991735,11160,1.00 >> corrected
479819099,11218,1.00 >> corrected
209043099,11408,1.39
16256299,12001,3.19
16320799,12001,10.96 |
Thank You,
Rajat |
|
| Back to top |
|
 |
rajatbagga
Active User

Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
Hello,
I just figured out a solution myself as per the initial requirement, i coded below to achieve it.
| Code: |
//SYSIN DD *
OPTION COPY
OUTREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=10),
%02=(ENDBEFR=C',',FIXLEN=06),
%03=(ENDBEFR=C'.',FIXLEN=11),
%04=(ENDBEFR=C',',FIXLEN=02)),
BUILD=(1:%02,SFF,EDIT=(TTTTTT),
08:%01,SFF,EDIT=(TTTTTTTTT),
018:%03,SFF,EDIT=(TTTTTTTTTTT),29:%04,ZD,EDIT=(TT),
80:X)
/* |
But would definately like to know how to achieve what dbzTHEdinosauer
mentioned in his above post.
Thank You,
Rajat |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| rajatbagga wrote: |
[...]
| Code: |
439991735,11160,1
479819099,11218,1
209043099,11408,1.39
16256299,12001,3.19
16320799,12001,10.96 |
Expected output :-
| Code: |
011160 439991735 0000000000100
011218 479819099 0000000000100
011408 209043099 0000000000139
012001 016256299 0000000000319
012001 016320799 0000000001096 |
I have coded the below code :-
| Code: |
//SYSIN DD *
OPTION COPY
OUTREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=10),
%02=(ENDBEFR=C',',FIXLEN=06),
%03=(ENDBEFR=C',',FIXLEN=13)),
BUILD=(1:%02,SFF,EDIT=(TTTTTT),
08:%01,SFF,EDIT=(TTTTTTTTT),
018:%03,SFF,EDIT=(TTTTTTTTTTTTT),
80:X)
/* |
[...]
|
Why 9 T's for %1 when you have said FIXLEN=10?
I'm looking at a manual. Searching for "Middle=Quincy" gets you to an example which might help. Application Guide "book" for DFSORT, following link from STICKY at top of forum. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Rajat,
The problem you actually have with your field is that it can contain two different types of data. One type is a numeric type, an integer with no decimal places. The other is an alphanumeric representation of a number with two decimal places. Although this can obviously happen on files, and has many millions of times, to my mind there should be something external to this actual piece of data which tells you which is which. Otherwise, you have a self-referential validation/use of the data, which is asking for trouble.
The easiest way for you to get around this is to get your input file changed (corrected) by whoever produced it. However, the very existence of the file like this shows that whoever produced it is either: lazy; lacks technical skills; has no pride in their own work/system. Or some combination thereof.
If the file is external to your group, there should have been some "sign-off" of the format of the data. So, maybe you have already accepted that it is like that. But, worth a try at getting it changed. Might depend on whose manager has the most clout.
I am sure that on Monday you will get solutions for the existing data. It will be worth understanding those solutions in their own right. I'd try first, though, for your actual solution, to get the data changed so that it is consistent.
Also, is there no possibility of any negative values on your file? Possible. Just wondering. |
|
| Back to top |
|
 |
rajatbagga
Active User

Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
| Quote: |
| Why 9 T's for %1 when you have said FIXLEN=10? |
Thank You Bill, Yes it should be FIXLEN=09, i corrected it.
| Quote: |
| Also, is there no possibility of any negative values on your file? |
Nope, the data will not have negative values.
And the CSV file is produced from the process which runs in a UNIX system , i have notified them, but not sure if they can do something
on formating the data in CSV file.
Thank You,
Rajat |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|