Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Reformat charcter fields

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
oerdgie

New User


Joined: 22 Nov 2007
Posts: 55
Location: Germany

PostPosted: Tue Jun 19, 2012 7:37 pm    Post subject: Reformat charcter fields
Reply with quote

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
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Jun 19, 2012 7:56 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Tue Jun 19, 2012 8:00 pm    Post subject:
Reply with quote

Use DECIMAL-POINT IS COMMA in the Configuration Section and NUMVAL to convert the PIC X(6) data to numeric?
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 19, 2012 8:03 pm    Post subject:
Reply with quote

I believe the TS wants a DFSORT solution, not a COBOL solution.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


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

PostPosted: Tue Jun 19, 2012 8:47 pm    Post subject:
Reply with quote

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 icon_smile.gif
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Jun 19, 2012 9:21 pm    Post subject:
Reply with quote

oerdgie,

what would be the output if the data is like this?
Code:

123456
1,2345
12,345
Back to top
View user's profile Send private message
oerdgie

New User


Joined: 22 Nov 2007
Posts: 55
Location: Germany

PostPosted: Tue Jun 19, 2012 10:33 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Jun 19, 2012 11:14 pm    Post subject:
Reply with quote

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
View user's profile Send private message
oerdgie

New User


Joined: 22 Nov 2007
Posts: 55
Location: Germany

PostPosted: Tue Jun 19, 2012 11:28 pm    Post subject:
Reply with quote

Thank you very much for help ! icon_biggrin.gif
Back to top
View user's profile Send private message
oerdgie

New User


Joined: 22 Nov 2007
Posts: 55
Location: Germany

PostPosted: Wed Jun 20, 2012 1:44 pm    Post subject:
Reply with quote

Unfortunately it doesn't work, if there is another field in the record containing a comma...
Back to top
View user's profile Send private message
Pandora-Box

Moderator


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

PostPosted: Wed Jun 20, 2012 1:55 pm    Post subject:
Reply with quote

Can you paste some simulated records from Input file and what is the output that you would expect for those records??
Back to top
View user's profile Send private message
oerdgie

New User


Joined: 22 Nov 2007
Posts: 55
Location: Germany

PostPosted: Wed Jun 20, 2012 2:17 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Pandora-Box

Moderator


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

PostPosted: Wed Jun 20, 2012 2:36 pm    Post subject:
Reply with quote

Try this
All needed was inclusion of two more parse icon_smile.gif 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
View user's profile Send private message
oerdgie

New User


Joined: 22 Nov 2007
Posts: 55
Location: Germany

PostPosted: Wed Jun 20, 2012 3:14 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Naish

New User


Joined: 07 Dec 2006
Posts: 82
Location: UK

PostPosted: Wed Jun 20, 2012 4:51 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Pandora-Box

Moderator


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

PostPosted: Wed Jun 20, 2012 5:03 pm    Post subject:
Reply with quote

This might help icon_smile.gif

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
View user's profile Send private message
oerdgie

New User


Joined: 22 Nov 2007
Posts: 55
Location: Germany

PostPosted: Wed Jun 20, 2012 7:34 pm    Post subject:
Reply with quote

Hi Naish,

it works, thanks !
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 20, 2012 9:42 pm    Post subject:
Reply with quote

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
View user's profile Send private message
oerdgie

New User


Joined: 22 Nov 2007
Posts: 55
Location: Germany

PostPosted: Wed Jun 20, 2012 10:29 pm    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
No new posts OUTREC FILELDS FAILS WITH ICE126A 2 ... balaji81_k DFSORT/ICETOOL 8 Sat Jul 02, 2016 1:22 am
No new posts Need Help to Define 36 Input Fields (... satish.ms10 CLIST & REXX 2 Sat May 07, 2016 3:08 pm
No new posts FileAid to compare(logical operations... anand1204 Compuware & Other Tools 3 Wed Apr 06, 2016 2:55 am
No new posts Fields in File-Aid Browse menu screen boyti ko Compuware & Other Tools 5 Mon Apr 04, 2016 4:51 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us