View previous topic :: View next topic
Author
Message
oerdgie New User Joined: 22 Nov 2007Posts: 64 Location: Germany
Hi Folks,
my input file has a 6 bytes long character field like this (b means blank) :
bbb123
bb77,0
b88,04
bbb0,4
I need the field reformated like this :
123,00
077,00
088,04
000,40
Could anybody help me to solve the (little) problem ?
Back to top
dbzTHEdinosauer Global Moderator Joined: 20 Oct 2006Posts: 6966 Location: porcelain throne
to all member of the forum,
in germany, the comma , is a decimal point...
so provide a solution that would generate
123.00
077.00
088.04
000.40
then change to
123,00
077,00
088,04
000,40
Back to top
Robert Sample Global Moderator Joined: 06 Jun 2008Posts: 8697 Location: Dubuque, Iowa, USA
Use DECIMAL-POINT IS COMMA in the Configuration Section and NUMVAL to convert the PIC X(6) data to numeric?
Back to top
dbzTHEdinosauer Global Moderator Joined: 20 Oct 2006Posts: 6966 Location: porcelain throne
I believe the TS wants a DFSORT solution, not a COBOL solution.
Back to top
Pandora-Box Global Moderator Joined: 07 Sep 2006Posts: 1592 Location: Andromeda Galaxy
Try this
I have assumed you need to convert 1-6 as 3,2 with leading zeroes
Code:
//SORTIN DD *
123
3
23
77,0
8,04
0,4
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
PARSE=(%01=(ABSPOS=1,ENDBEFR=C',',FIXLEN=6),
%02=(FIXLEN=2)),
BUILD=(1:%01,UFF,EDIT=(TTTTTT),C',',%02)),
IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=4,IN=C' ',OUT=C'0'))
OUTREC FIELDS=(1:4,6)
Output
Code:
123,00
003,00
023,00
077,00
008,04
000,40
000,00
Hope it helps
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
oerdgie,
what would be the output if the data is like this?
Code:
123456
1,2345
12,345
Back to top
oerdgie New User Joined: 22 Nov 2007Posts: 64 Location: Germany
Skolusu,
yes.... your input file doesn't work for me.
Well, what do I want...
I need to parse a csv-formated file (SEMI is defined as ';') :
//SYSIN DD *
OPTION COPY
INREC PARSE=(%00=(FIXLEN=2,ENDBEFR=SEMI),
%01=(FIXLEN=3,ENDBEFR=SEMI),
%02=(FIXLEN=8,ENDBEFR=SEMI),
%03=(FIXLEN=2,ENDBEFR=SEMI)),
BUILD=(%00,JFY=(SHIFT=LEFT),
%01,JFY=(SHIFT=LEFT),
%02,JFY=(SHIFT=RIGHT)
%03,JFY=(SHIFT=RIGHT))
/*
The %02 field is an amount field.
If the amount in the field has the maximum length (8 bytes), it always included two decimal places and a comma (12345,78 never 12345678).
And I always have no, one or two decimal places.
So, the solution of Pandora-Box would work for me.
But... how to include his solution into my statement ?
Or, maybe is there another solution to solve the problem...?
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
oerdgie,
Use the following DFSORT JCL which will give you the desired results
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD *
SEMI,C';'
COMA,C','
//SORTIN DD *
LL;AAA;12345,78;BB
MM;AAA; 1,23;C
NN;AAA; 12,34;DD
PP;AAA; 123;E
QQ;AAA; 77,0;FF
RR;AAA; 88,04;G
SS;AAA; 0,4;HH
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
PARSE=(%00=(FIXLEN=2,ENDBEFR=SEMI),
%01=(FIXLEN=3,ENDBEFR=SEMI),
%02=(FIXLEN=8,ENDBEFR=SEMI),
%03=(FIXLEN=2,ENDBEFR=SEMI)),
BUILD=(%00,JFY=(SHIFT=LEFT),
%01,JFY=(SHIFT=LEFT),
%02,JFY=(SHIFT=LEFT),
%03,JFY=(SHIFT=RIGHT))),
IFTHEN=(WHEN=INIT,
PARSE=(%04=(ABSPOS=6,ENDBEFR=COMA,FIXLEN=5),
%05=(FIXLEN=2)),
OVERLAY=(6:%04,UFF,EDIT=(TTTTT),C',',%05)),
IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=6,ENDPOS=13,IN=C' ',OUT=C'0'))
//*
The output from this job is
Code:
LLAAA12345,78BB
MMAAA00001,23 C
NNAAA00012,34DD
PPAAA00123,00 E
QQAAA00077,00FF
RRAAA00088,04 G
SSAAA00000,40HH
Back to top
oerdgie New User Joined: 22 Nov 2007Posts: 64 Location: Germany
Thank you very much for help !
Back to top
oerdgie New User Joined: 22 Nov 2007Posts: 64 Location: Germany
Unfortunately it doesn't work, if there is another field in the record containing a comma...
Back to top
Pandora-Box Global Moderator Joined: 07 Sep 2006Posts: 1592 Location: Andromeda Galaxy
Can you paste some simulated records from Input file and what is the output that you would expect for those records??
Back to top
oerdgie New User Joined: 22 Nov 2007Posts: 64 Location: Germany
My input file :
BB;AAA;12345,78;BB;10,00;BBB
MM;AAA;1,23;C;0;MMM
NN;AAA;12,34;DD;1,23;NNN
PP;AAA;123;E;0,4;PPP
QQ;AAA;77,0;FF;567;QQQ
RR;AAA;88,04;G;1,00;RRR
SS;AAA;0,4;HH;0,01;SSS
I expect this :
BBAAA12345,78BB00010,00BBB
MMAAA00001,23 C00000,00MMM
NNAAA00012,34DD00001,23NNN
PPAAA00123,00 E00000,04PPP
QQAAA00077,00FF00567,00QQQ
RRAAA00088,04 G00001,00RRR
SSAAA00000,40HH00000,01SSS
Back to top
Pandora-Box Global Moderator Joined: 07 Sep 2006Posts: 1592 Location: Andromeda Galaxy
Try this
All needed was inclusion of two more parse I just editted Kolusu's code
Code:
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
PARSE=(%00=(FIXLEN=2,ENDBEFR=SEMI),
%01=(FIXLEN=3,ENDBEFR=SEMI),
%02=(FIXLEN=8,ENDBEFR=SEMI),
%03=(FIXLEN=2,ENDBEFR=SEMI),
%06=(FIXLEN=8,ENDBEFR=SEMI),
%07=(FIXLEN=3,ENDBEFR=SEMI)),
BUILD=(%00,JFY=(SHIFT=LEFT),
%01,JFY=(SHIFT=LEFT),
%02,JFY=(SHIFT=LEFT),
%03,JFY=(SHIFT=RIGHT),
%06,JFY=(SHIFT=LEFT),
%07,JFY=(SHIFT=LEFT))),
IFTHEN=(WHEN=INIT,
PARSE=(%04=(ABSPOS=6,ENDBEFR=COMA,FIXLEN=5),
%05=(FIXLEN=2)),
OVERLAY=(6:%04,UFF,EDIT=(TTTTT),C',',%05)),
IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=6,ENDPOS=13,IN=C' ',OUT=C'0')),
IFTHEN=(WHEN=INIT,
PARSE=(%08=(ABSPOS=16,ENDBEFR=COMA,FIXLEN=5),
%09=(FIXLEN=2)),
OVERLAY=(16:%08,UFF,EDIT=(TTTTT),C',',%09)),
IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=16,ENDPOS=23,IN=C' ',OUT=C'0'))
//*
Back to top
oerdgie New User Joined: 22 Nov 2007Posts: 64 Location: Germany
I tried... but it doesn't work correctly.
The problem is an amount field without decimal places (the third field in my example). It takes the decimal places from the next amount field, not '00' for the decimal places.
Example :
PP;AAA;123;E;3,68;PPP
This is the result :
PP;AAA;00123,68 ;E;00003,68 ;PP
But it should be :
PP;AAA;00123,00 ;E;00003,68 ;PP
Back to top
Naish New User Joined: 07 Dec 2006Posts: 82 Location: UK
Hello oerdgie,
Try this:
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD *
SEMI,C';'
COMA,C','
//SORTIN DD *
BB;AAA;12345,78;BB;10,00;BBB
MM;AAA;1,23;C;0;MMM
NN;AAA;12,34;DD;1,23;NNN
PP;AAA;123;E;3,68;PPP
QQ;AAA;77,0;FF;567;QQQ
RR;AAA;88,04;G;1,00;RRR
SS;AAA;0,4;HH;0,01;SSS
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
PARSE=(%00=(FIXLEN=2,ENDBEFR=SEMI),
%01=(FIXLEN=3,ENDBEFR=SEMI),
%02=(FIXLEN=8,ENDBEFR=SEMI),
%03=(FIXLEN=2,ENDBEFR=SEMI),
%06=(FIXLEN=8,ENDBEFR=SEMI),
%07=(FIXLEN=3,ENDBEFR=SEMI)),
BUILD=(%00,JFY=(SHIFT=LEFT),
%01,JFY=(SHIFT=LEFT),
%02,JFY=(SHIFT=LEFT),
%03,JFY=(SHIFT=RIGHT),
%06,JFY=(SHIFT=LEFT),
%07,JFY=(SHIFT=LEFT))),
IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=6,ENDPOS=13,IN=C' ',OUT=C',',
DO=1)),
IFTHEN=(WHEN=INIT,
PARSE=(%04=(ABSPOS=6,ENDBEFR=COMA,FIXLEN=5),
%05=(FIXLEN=2,ENDBEFR=COMA)),
OVERLAY=(6:%04,UFF,EDIT=(TTTTT),C',',%05)),
IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=6,ENDPOS=13,IN=C' ',OUT=C'0')),
IFTHEN=(WHEN=INIT,
PARSE=(%08=(ABSPOS=16,ENDBEFR=COMA,FIXLEN=5),
%09=(FIXLEN=2)),
OVERLAY=(16:%08,UFF,EDIT=(TTTTT),C',',%09)),
IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=16,ENDPOS=23,IN=C' ',OUT=C'0'))
//*
O/P:
Code:
BBAAA12345,78BB00010,00BBB
MMAAA00001,23 C00000,00MMM
NNAAA00012,34DD00001,23NNN
PPAAA00123,00 E00003,68PPP
QQAAA00077,00FF00567,00QQQ
RRAAA00088,04 G00001,00RRR
SSAAA00000,40HH00000,01SSS
Hope this helps.
Back to top
Pandora-Box Global Moderator Joined: 07 Sep 2006Posts: 1592 Location: Andromeda Galaxy
This might help
Code:
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
PARSE=(%00=(FIXLEN=2,ENDBEFR=SEMI),
%01=(FIXLEN=3,ENDBEFR=SEMI),
%02=(FIXLEN=8,ENDBEFR=SEMI),
%03=(FIXLEN=2,ENDBEFR=SEMI),
%06=(FIXLEN=8,ENDBEFR=SEMI),
%07=(FIXLEN=3,ENDBEFR=SEMI)),
BUILD=(%00,JFY=(SHIFT=LEFT),
%01,JFY=(SHIFT=LEFT),
%02,JFY=(SHIFT=LEFT),
%03,JFY=(SHIFT=RIGHT),
%06,JFY=(SHIFT=LEFT),
%07,JFY=(SHIFT=LEFT))),
IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=16,ENDPOS=23,IN=C',',OUT=C'#')),
IFTHEN=(WHEN=INIT,
PARSE=(%04=(ABSPOS=6,ENDBEFR=COMA,FIXLEN=5),
%05=(FIXLEN=2)),
OVERLAY=(6:%04,UFF,EDIT=(TTTTT),C',',%05)),
IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=6,ENDPOS=13,IN=C' ',OUT=C'0')),
IFTHEN=(WHEN=INIT,
PARSE=(%08=(ABSPOS=16,ENDBEFR=C'#',FIXLEN=5),
%09=(FIXLEN=2)),
OVERLAY=(16:%08,UFF,EDIT=(TTTTT),C',',%09)),
IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=16,ENDPOS=23,IN=C' ',OUT=C'0'))
//*
Back to top
oerdgie New User Joined: 22 Nov 2007Posts: 64 Location: Germany
Hi Naish,
it works, thanks !
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
oerdgie,
You need to do a better job of explaining the complete details instead of bits and pieces. It is just hard to keep working on the same issue for n different scenarios.
Back to top
oerdgie New User Joined: 22 Nov 2007Posts: 64 Location: Germany
Skolusu,
yes, I'm sorry...
In this case I didn't know, when one problem is fixed, I get the next one.
Next time, I will give you all details I have. I promise !
Thanks anyway for your help !!
Back to top
Please enable JavaScript!