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
 

 

Parse field level validation from FB file

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

New User


Joined: 25 Oct 2007
Posts: 80
Location: Australia

PostPosted: Fri Aug 07, 2009 9:01 pm    Post subject: Parse field level validation from FB file
Reply with quote

Hi, I have a FB CSV file(Delimiter). I need to parse the fields based on delimiter (which is ;). In the output during parse, for numeric fields i do not want to have blanks but leading zeros.

for example:

input file with 2 records

fgghf;1;234;5345;gghhg;ghsad
1;fsad;2312213;565;hghjs;123

output required

fgghf000000100000234000005345bbbgghhgbbghsad
00001bbbfsad02312213000000565bbbhghjs0000123

where b specifies blank

numeric fields can be at any position in input file and hence i need to put a field level criteria during parsing and have output with leading zeros and not blanks.
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Aug 07, 2009 9:41 pm    Post subject:
Reply with quote

Here's a DFSORT job that will do what you asked for. I assumed from your example that a non-numeric field would NOT start with 0-9 (e.g. you don't have non-numeric fields like 1abc).

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
fgghf;1;234;5345;gghhg;ghsad
1;fsad;2312213;565;hghjs;123
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,
    PARSE=(%01=(ENDBEFR=C';',FIXLEN=5),
           %02=(ENDBEFR=C';',FIXLEN=7),
           %03=(ENDBEFR=C';',FIXLEN=8),
           %04=(ENDBEFR=C';',FIXLEN=9),
           %05=(ENDBEFR=C';',FIXLEN=8),
           %06=(FIXLEN=7)),
    BUILD=(%01,%02,%03,%04,%05,%06)),
   IFTHEN=(WHEN=(1,1,FS,EQ,NUM),
      OVERLAY=(1:1,5,UFF,TO=ZD,LENGTH=5),HIT=NEXT),
   IFTHEN=(WHEN=(1,1,FS,NE,NUM),
      OVERLAY=(1:1,5,JFY=(SHIFT=RIGHT)),HIT=NEXT),
   IFTHEN=(WHEN=(6,1,FS,EQ,NUM),
      OVERLAY=(6:6,7,UFF,TO=ZD,LENGTH=7),HIT=NEXT),
   IFTHEN=(WHEN=(6,1,FS,NE,NUM),
      OVERLAY=(6:6,7,JFY=(SHIFT=RIGHT)),HIT=NEXT),
   IFTHEN=(WHEN=(13,1,FS,EQ,NUM),
      OVERLAY=(13:13,8,UFF,TO=ZD,LENGTH=8),HIT=NEXT),
   IFTHEN=(WHEN=(13,1,FS,NE,NUM),
      OVERLAY=(13:13,8,JFY=(SHIFT=RIGHT)),HIT=NEXT),
   IFTHEN=(WHEN=(21,1,FS,EQ,NUM),
      OVERLAY=(21:21,9,UFF,TO=ZD,LENGTH=9),HIT=NEXT),
   IFTHEN=(WHEN=(21,1,FS,NE,NUM),
      OVERLAY=(21:21,9,JFY=(SHIFT=RIGHT)),HIT=NEXT),
   IFTHEN=(WHEN=(30,1,FS,EQ,NUM),
      OVERLAY=(30:30,8,UFF,TO=ZD,LENGTH=8),HIT=NEXT),
   IFTHEN=(WHEN=(30,1,FS,NE,NUM),
      OVERLAY=(30:30,8,JFY=(SHIFT=RIGHT)),HIT=NEXT),
   IFTHEN=(WHEN=(38,1,FS,EQ,NUM),
      OVERLAY=(38:38,7,UFF,TO=ZD,LENGTH=7),HIT=NEXT),
   IFTHEN=(WHEN=(38,1,FS,NE,NUM),
      OVERLAY=(38:38,7,JFY=(SHIFT=RIGHT)))
/*
Back to top
View user's profile Send private message
charanmsrit

New User


Joined: 25 Oct 2007
Posts: 80
Location: Australia

PostPosted: Fri Aug 07, 2009 9:49 pm    Post subject:
Reply with quote

Thanks a lot frank for the quick reply... I am sorry... a alpha-numeric field can contain or start with numeric integer at any position which has to be with leading blanks.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Aug 07, 2009 10:08 pm    Post subject:
Reply with quote

Please show a better example of input and output with that case and any other cases we have to worry about (for example, values with embedded blanks).
Back to top
View user's profile Send private message
charanmsrit

New User


Joined: 25 Oct 2007
Posts: 80
Location: Australia

PostPosted: Fri Aug 07, 2009 10:13 pm    Post subject:
Reply with quote

Apologies for the confusion Frank. Please find my requirment below.

Input
fg1hf;1;234h;5345;g5h6g;ghsad
1;fsad;a2312213;565;hghjs;123


Output
bfg1hf0000001bbbbb234h000005345bbbg5h6gbbghsad
000001bbbfsadba2312213000000565bbbhghjs0000123

in the above 'b' specifies blanks.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Aug 07, 2009 11:40 pm    Post subject:
Reply with quote

This DFSORT job gave me the output you showed for the new input records.

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
fg1hf;1;234h;5345;g5h6g;ghsad
1;fsad;a2312213;565;hghjs;123
//SORTOUT DD DSN=...  output file (FB/46)
//SYSIN    DD    *
  OPTION COPY
  INREC IFOUTLEN=46,
   IFTHEN=(WHEN=INIT,
    PARSE=(%01=(ENDBEFR=C';',FIXLEN=6),
           %02=(ENDBEFR=C';',FIXLEN=7),
           %03=(ENDBEFR=C';',FIXLEN=9),
           %04=(ENDBEFR=C';',FIXLEN=9),
           %05=(ENDBEFR=C';',FIXLEN=8),
           %06=(FIXLEN=7)),
    BUILD=(%01,JFY=(SHIFT=RIGHT),
           %02,JFY=(SHIFT=RIGHT),
           %03,JFY=(SHIFT=RIGHT),
           %04,JFY=(SHIFT=RIGHT),
           %05,JFY=(SHIFT=RIGHT),
           %06,JFY=(SHIFT=RIGHT))),
   IFTHEN=(WHEN=INIT,OVERLAY=(51:1,46)),
   IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=51,INOUT=(C' ',C'0'))),
   IFTHEN=(WHEN=(51,6,FS,EQ,NUM),OVERLAY=(1:51,6),HIT=NEXT),
   IFTHEN=(WHEN=(57,7,FS,EQ,NUM),OVERLAY=(7:57,7),HIT=NEXT),
   IFTHEN=(WHEN=(64,8,FS,EQ,NUM),OVERLAY=(14:64,9),HIT=NEXT),
   IFTHEN=(WHEN=(73,9,FS,EQ,NUM),OVERLAY=(23:73,9),HIT=NEXT),
   IFTHEN=(WHEN=(82,8,FS,EQ,NUM),OVERLAY=(32:82,8),HIT=NEXT),
   IFTHEN=(WHEN=(90,7,FS,EQ,NUM),OVERLAY=(40:90,7))
/*
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 Extra character appears in file when ... Balu5491 All Other Mainframe Topics 1 Wed Jul 26, 2017 2:39 pm
No new posts SSH - known_hosts file configuration vasanthz All Other Mainframe Topics 2 Wed Jul 26, 2017 2:10 am
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm


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