Page 1 of 1

Imposible PARSE ????

PostPosted: Thu Feb 20, 2014 2:32 pm
by javivi
Hi.

I need to convert a input fields to numeric edited fields.
I have the hext file:
121,1234567; 121,34;
333,12367; 2,34;
,03367; 12,12;
5000; 1,1;
,1; 20,2;
1,4562345; 15;
735;,24

I need to conver to:
0000000121,1234567;0000000121,34
0000000333,1236700;0000000002,34
0000000000,0336700;0000000012,12
0000005000,0000000;0000000001,10
0000000000,1000000;0000000020,20
0000000001,4562345;0000000015,00
0000000735,0000000;0000000000,24

It is possible with Parse?

Thanks

Re: Imposible PARSE ????

PostPosted: Thu Feb 20, 2014 3:32 pm
by NicC
Have you tried? I presume that the commas represent decimal points in other languages and that the semi-colons delimit the fields.

Re: Imposible PARSE ????

PostPosted: Thu Feb 20, 2014 3:38 pm
by javivi
Sorry, Yes, commas decimal point (I'm asking from Madrid, Spain).

And yes, I tried bur the problem is in fiels that I spect decimal buy they aren't, as the 4th register (5000)

Re: Imposible PARSE ????

PostPosted: Thu Feb 20, 2014 3:46 pm
by NicC
Well, we need to see your code and results from that code. Without looking I do not know if DFSort will recognise ',' as '.'. If it cannot then you will have to replace them doing the parse before cretaing your output record and switch them back again after creating the record. But I may be overly complicating things.

Re: Imposible PARSE ????

PostPosted: Thu Feb 20, 2014 4:10 pm
by javivi
Here it is: (i can' see how tt paste a screen hard-copy)

//SORTIN   DD *                                                         
       121,1234567;   121,34;                                           
         333,12367;    2,34;                                           
            ,03367;  12,12;                                             
              5000; 1,1;                                               
                ,1; 20,2;                                               
         1,4562345; 15;                                                 
               735;,24;                                                 
//SORTOUT  DD DSN=PRYY.LSQ.SORTMIO.SALIDA,DISP=(NEW,CATLG,CATLG),       
//            UNIT=SYSDA,SPACE=(CYL,(10,10),RLSE),                     
//            DCB=(LRECL=175,BLKSIZE=0,RECFM=FB)                       
//SYSIN DD *                                                           
  OPTION COPY                                                           
  SORT FIELDS=COPY                                                     
  INREC  PARSE=(%10=(ABSPOS=1,ENDBEFR=C',',ENDBEFR=C';',FIXLEN=18),     
                %11=(ABSPOS=1,STARTAFT=C',',ENDBEFR=C';',FIXLEN=18),   
                %20=(ABSPOS=20,ENDBEFR=C',',ENDBEFR=C';',FIXLEN=18),   
                %21=(ABSPOS=20,STARTAFT=C',',ENDBEFR=C';',FIXLEN=18)), 
         BUILD=(%10,JFY=(SHIFT=RIGHT),                                 
                %11,JFY=(SHIFT=LEFT),                                   
                %20,JFY=(SHIFT=RIGHT),                           
                %21,JFY=(SHIFT=LEFT))                           
                                                                 
  OUTREC BUILD=(01,18,UFF,EDIT=(TTTTTTTTTT),C',',               
                19,18,UFF,EDIT=(TTTTTTT),C'  ',                 
                37,18,UFF,EDIT=(TTTTTTTTTT),C',',               
                55,18,UFF,EDIT=(TT))                             


and the output file:
0000000121,1234567  0000000121,34
0000000333,0012367  0000000002,34
0000000000,0003367  0000000012,12
0000005000,0000001  0000000001,01
0000000000,0000001  0000000020,02
0000000001,4562345  0000000015,00
0000000735,0000024  0000000000,24


Code'd

Re: Imposible PARSE ????

PostPosted: Thu Feb 20, 2014 11:38 pm
by skolusu
javivi,

Use the following DFSORT JCL which will give you the desired results.

//STEP0100 EXEC PGM=SORT                     
//SYSOUT   DD SYSOUT=*                       
//SORTIN   DD *                             
----+----1----+----2----+----3----+----4----+
       121,1234567;   121,34;               
         333,12367;    2,34;                 
            ,03367;  12,12;                 
              5000; 1,1;                     
                ,1; 20,2;                   
         1,4562345; 15;                     
               735;,24;                     
//SORTOUT  DD SYSOUT=*                       
//SYSIN DD *                                 
  OPTION COPY                               
  INREC IFTHEN=(WHEN=(1,19,SS,EQ,C',',AND,20,19,SS,EQ,C','),
  PARSE=(%01=(ENDBEFR=C',',FIXLEN=18),                       
         %02=(ENDBEFR=C';',FIXLEN=07),                       
         %03=(ENDBEFR=C',',FIXLEN=18),                       
         %04=(ENDBEFR=C';',FIXLEN=02)),                     
  BUILD=(%01,UFF,M11,LENGTH=18,C',',                         
         %02,TRAN=ALTSEQ,C';',                               
         %03,UFF,M11,LENGTH=18,C',',                         
         %04,TRAN=ALTSEQ)),                     
           
  IFTHEN=(WHEN=(1,19,SS,NE,C',',AND,20,19,SS,EQ,C','),       
  PARSE=(%05=(STARTAT=C'0',STARTAT=C'1',STARTAT=C'2',STARTAT=C'3',
            STARTAT=C'4',STARTAT=C'5',STARTAT=C'6',STARTAT=C'7',
            STARTAT=C'8',STARTAT=C'9',ENDBEFR=C';',FIXLEN=07),       
         %06=(ENDBEFR=C',',FIXLEN=18),                       
         %07=(ENDBEFR=C';',FIXLEN=02)),                     
  BUILD=(18C'0',C',',                                       
         %05,TRAN=ALTSEQ,C';',                               
         %06,UFF,M11,LENGTH=18,C',',                         
         %07,TRAN=ALTSEQ)),                                 
                                                             
  IFTHEN=(WHEN=(1,19,SS,EQ,C',',AND,20,19,SS,NE,C','),       
  PARSE=(%08=(ENDBEFR=C',',FIXLEN=18),                       
         %09=(ENDBEFR=C';',FIXLEN=07),                       
         %10=(ENDBEFR=C';',FIXLEN=18)),                     
  BUILD=(%08,UFF,M11,LENGTH=18,C',',                         
         %09,TRAN=ALTSEQ,C';',                               
         %10,UFF,M11,LENGTH=18,C',',                         
         2C'0'))                                             
                                                             
  ALTSEQ CODE=(40F0)                                         
//*     


The output from this job is
000000000000000121,1234567;000000000000000121,34
000000000000000333,1236700;000000000000000002,34
000000000000000000,0336700;000000000000000012,12
000000000000000000,0000000;000000000000000001,10
000000000000000000,1000000;000000000000000020,20
000000000000000001,4562345;000000000000000015,00
000000000000000000,0000000;000000000000000000,24

Re: Imposible PARSE ????

PostPosted: Fri Feb 21, 2014 12:50 pm
by javivi
Thanks a lot, but record 4 and record 7 don't work, they 5000 and 735 , they desappear.

Re: Imposible PARSE ????

PostPosted: Fri Feb 21, 2014 2:19 pm
by BillyBoyo
Sorry, that may have been me. Kolusu posted a later fix, which I tried to apply to the original (and then deleted the fix). I may have borken it. Can you post the input, output you received and the full sysout from the step you used to produce the output please?

Re: Imposible PARSE ????

PostPosted: Fri Feb 21, 2014 11:14 pm
by skolusu
javivi wrote:Thanks a lot, but record 4 and record 7 don't work, they 5000 and 735 , they desappear.


I guess you copied the control cards before Bill edited my post. Please copy the updated control cards you will get the correct results for the records 4 and 7.