Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
oerdgie

New User

Joined: 22 Nov 2007
Posts: 55
Location: Germany

 Posted: Tue Jun 19, 2012 7:37 pm    Post subject: Reformat charcter fields 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 ?

dbzTHEdinosauer

Global Moderator

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

 Posted: Tue Jun 19, 2012 7:56 pm    Post subject: 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
Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8344
Location: Dubuque, Iowa, USA

 Posted: Tue Jun 19, 2012 8:00 pm    Post subject: Use DECIMAL-POINT IS COMMA in the Configuration Section and NUMVAL to convert the PIC X(6) data to numeric?
dbzTHEdinosauer

Global Moderator

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

 Posted: Tue Jun 19, 2012 8:03 pm    Post subject: I believe the TS wants a DFSORT solution, not a COBOL solution.
Pandora-Box

Moderator

Joined: 07 Sep 2006
Posts: 1555
Location: Andromeda Galaxy

Posted: Tue Jun 19, 2012 8:47 pm    Post subject:

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
Skolusu

Senior Member

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

Posted: Tue Jun 19, 2012 9:21 pm    Post subject:

oerdgie,

what would be the output if the data is like this?
 Code: 123456 1,2345 12,345
oerdgie

New User

Joined: 22 Nov 2007
Posts: 55
Location: Germany

 Posted: Tue Jun 19, 2012 10:33 pm    Post subject: 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...?
Skolusu

Senior Member

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

Posted: Tue Jun 19, 2012 11:14 pm    Post subject:

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
oerdgie

New User

Joined: 22 Nov 2007
Posts: 55
Location: Germany

 Posted: Tue Jun 19, 2012 11:28 pm    Post subject: Thank you very much for help !
oerdgie

New User

Joined: 22 Nov 2007
Posts: 55
Location: Germany

 Posted: Wed Jun 20, 2012 1:44 pm    Post subject: Unfortunately it doesn't work, if there is another field in the record containing a comma...
Pandora-Box

Moderator

Joined: 07 Sep 2006
Posts: 1555
Location: Andromeda Galaxy

 Posted: Wed Jun 20, 2012 1:55 pm    Post subject: Can you paste some simulated records from Input file and what is the output that you would expect for those records??
oerdgie

New User

Joined: 22 Nov 2007
Posts: 55
Location: Germany

 Posted: Wed Jun 20, 2012 2:17 pm    Post subject: 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
Pandora-Box

Moderator

Joined: 07 Sep 2006
Posts: 1555
Location: Andromeda Galaxy

Posted: Wed Jun 20, 2012 2:36 pm    Post subject:

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')) //*
oerdgie

New User

Joined: 22 Nov 2007
Posts: 55
Location: Germany

 Posted: Wed Jun 20, 2012 3:14 pm    Post subject: 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
Naish

New User

Joined: 07 Dec 2006
Posts: 82
Location: UK

Posted: Wed Jun 20, 2012 4:51 pm    Post subject:

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.
Pandora-Box

Moderator

Joined: 07 Sep 2006
Posts: 1555
Location: Andromeda Galaxy

Posted: Wed Jun 20, 2012 5:03 pm    Post subject:

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')) //*
oerdgie

New User

Joined: 22 Nov 2007
Posts: 55
Location: Germany

 Posted: Wed Jun 20, 2012 7:34 pm    Post subject: Hi Naish, it works, thanks !
Skolusu

Senior Member

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

 Posted: Wed Jun 20, 2012 9:42 pm    Post subject: 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.
oerdgie

New User

Joined: 22 Nov 2007
Posts: 55
Location: Germany

 Posted: Wed Jun 20, 2012 10:29 pm    Post subject: 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 !!
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Reformat clause in joinkeys sortcard ... Mounika Nemani DFSORT/ICETOOL 2 Thu May 31, 2018 5:35 pm Sort numeric fields with trailing spaces sancraig16 SYNCSORT 7 Tue Apr 03, 2018 1:21 am SORT 3 files,extract specific fields ... Kiransr DFSORT/ICETOOL 13 Fri Mar 23, 2018 10:54 am Sum the fields in particular format f... sharana64 DFSORT/ICETOOL 9 Fri Jan 05, 2018 1:11 am SORT BUT RETAIN HIGHEST VALUE ON NON-... leondan22 DFSORT/ICETOOL 2 Thu Dec 14, 2017 8:13 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us