Page 1 of 1

Trying to add extra field on a .csv parsing job

PostPosted: Tue Sep 10, 2019 3:49 pm
by golemis
Hi team,
I am decomposing a .cvs file into a fixed column length one using the following CNTL:
 OPTION VLSHRT
  RECORD TYPE=V,LENGTH=300
  OUTFIL PARSE=(%01=(ABSPOS=6,ENDBEFR=C'","',FIXLEN=7),
                %02=(ENDBEFR=C'","',FIXLEN=42),
                %03=(ENDBEFR=C'","',FIXLEN=8),
                %04=(ENDBEFR=C'","',FIXLEN=3),
                %05=(ENDBEFR=C'","',FIXLEN=37),
                %06=(ENDBEFR=C'","',FIXLEN=32),
                %07=(ENDBEFR=C'","',FIXLEN=26),
                %08=(ENDBEFR=C'","',FIXLEN=18),
                %09=(ENDBEFR=C'","',FIXLEN=19),
                %10=(ENDBEFR=C'","',FIXLEN=1),
                %11=(ENDBEFR=C'","',FIXLEN=1),
                %12=(ENDBEFR=C'","',FIXLEN=8),
                %13=(ENDBEFR=C'","',FIXLEN=20),
                %14=(ENDBEFR=C'"',FIXLEN=16)),
  VTOF,
  BUILD=(%02,
         %01,
         %04,
         %05,
         %03,
         %09,JFY=(SHIFT=RIGHT),
         %06,
         %07,
         %08,
         %10,
         %11,
         %12,
         %13)

and works fine.

however, i need to add an extra filed at the end, which would be a single character, "R" if the first char of field %04% is "R" and "A" if first char of field %04 is "V"

Tried several options including IFTHEN or CHANGE, but successful. Last attempt was :

OPTION VLSHRT
  RECORD TYPE=V,LENGTH=300
  OUTFIL PARSE=(%01=(ABSPOS=6,ENDBEFR=C'","',FIXLEN=7),
                %02=(ENDBEFR=C'","',FIXLEN=42),
                %03=(ENDBEFR=C'","',FIXLEN=8),
                %04=(ENDBEFR=C'","',FIXLEN=3),
                %05=(ENDBEFR=C'","',FIXLEN=37),
                %06=(ENDBEFR=C'","',FIXLEN=32),
                %07=(ENDBEFR=C'","',FIXLEN=26),
                %08=(ENDBEFR=C'","',FIXLEN=18),
                %09=(ENDBEFR=C'","',FIXLEN=19),
                %10=(ENDBEFR=C'","',FIXLEN=1),
                %11=(ENDBEFR=C'","',FIXLEN=1),
                %12=(ENDBEFR=C'","',FIXLEN=8),
                %13=(ENDBEFR=C'","',FIXLEN=20),
                %14=(ENDBEFR=C'"',FIXLEN=16)),
  VTOF,
  BUILD=(%02,
         %01,
         %04,
         %05,
         %03,
         %09,JFY=(SHIFT=RIGHT),
         %06,
         %07,
         %08,
         %10,
         %11,
         %12,
         %13,
         %04,CHANGE=(1,
             C'R',C'R',
             C'V',C'A'))

but did not work. Any ideas would be appreciated. Thanks, GG

Re: Trying to add extra field on a .csv parsing job

PostPosted: Tue Sep 10, 2019 5:01 pm
by enrico-sorichetti
but did not work.


that' s very sad, we all hope that You will be able to find a solution :mrgreen:

Re: Trying to add extra field on a .csv parsing job

PostPosted: Tue Sep 10, 2019 7:21 pm
by sergeyken
 OUTFIL   VTOF,
    IFTHEN=(WHEN=INIT,
            PARSE=(%01=(ABSPOS=6,ENDBEFR=C'","',FIXLEN=7),
 . . . . . . . . . . . . .
                   %14=(ENDBEFR=C'"',FIXLEN=16)),
            BUILD=(%02,
 . . . . . . . . . . . . .
                   %14)),                 initially use %14 as is
    IFTHEN=(WHEN=(pos,1,CH,EQ,C'V'),      use pos value as real position of %14
            OVERLAY=(pos:C'A'))           replace char 1 of %14 when needed
 

Re: Trying to add extra field on a .csv parsing job

PostPosted: Tue Sep 10, 2019 7:34 pm
by golemis
Thanks sergeyken, will try it.

Re: Trying to add extra field on a .csv parsing job

PostPosted: Wed Sep 11, 2019 1:20 pm
by golemis
sergeyken wrote:
 OUTFIL   VTOF,
    IFTHEN=(WHEN=INIT,
            PARSE=(%01=(ABSPOS=6,ENDBEFR=C'","',FIXLEN=7),
 . . . . . . . . . . . . .
                   %14=(ENDBEFR=C'"',FIXLEN=16)),
            BUILD=(%02,
 . . . . . . . . . . . . .
                   %14)),                 initially use %14 as is
    IFTHEN=(WHEN=(pos,1,CH,EQ,C'V'),      use pos value as real position of %14
            OVERLAY=(pos:C'A'))           replace char 1 of %14 when needed
 


Unfortunately it gave Error:
ICE126A 9 INCONSISTENT REFORMATTING FOR T1 : REASON CODE 05, IFTHEN 1

Reading the manual found out that:
Note: VTOF cannot be used with an IFTHEN or
OVERLAY operand.

Re: Trying to add extra field on a .csv parsing job

PostPosted: Wed Sep 11, 2019 7:17 pm
by sergeyken
golemis wrote:
sergeyken wrote:
 OUTFIL   VTOF,
    IFTHEN=(WHEN=INIT,
            PARSE=(%01=(ABSPOS=6,ENDBEFR=C'","',FIXLEN=7),
 . . . . . . . . . . . . .
                   %14=(ENDBEFR=C'"',FIXLEN=16)),
            BUILD=(%02,
 . . . . . . . . . . . . .
                   %14)),                 initially use %14 as is
    IFTHEN=(WHEN=(pos,1,CH,EQ,C'V'),      use pos value as real position of %14
            OVERLAY=(pos:C'A'))           replace char 1 of %14 when needed
 


Unfortunately it gave Error:
ICE126A 9 INCONSISTENT REFORMATTING FOR T1 : REASON CODE 05, IFTHEN 1

Reading the manual found out that:
Note: VTOF cannot be used with an IFTHEN or
OVERLAY operand.

Move all IFTHENs to statement OUTREC, and leave other parameter(s) with OUTFIL.
Also don't forget to mention RDW field in your BUILD parameters
 OUTREC IFTHEN=(WHEN=INIT,
            PARSE=(%01=(ABSPOS=6,ENDBEFR=C'","',FIXLEN=7),
 . . . . . . . . . . . . .
                   %14=(ENDBEFR=C'"',FIXLEN=16)),
            BUILD=(1,4,                            RDW from RECFM=VB      
                   %02,
 . . . . . . . . . . . . .
                   %14)),                 initially use %14 as is
    IFTHEN=(WHEN=(pos,1,CH,EQ,C'V'),      use pos value as real position of %14 (plus 4 for RDW)
            OVERLAY=(pos:C'A'))           replace char 1 of %14 when needed
  OUTFIL   VTOF