MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Remove commas from input file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
bindu
Beginner


Joined: 05 Jan 2003
Posts: 17
Topics: 7

PostPosted: Tue Mar 25, 2003 2:43 am    Post subject: Remove commas from input file Reply with quote

Hello all,
I Would like to create a output dataset with fixed structure from a input file which has fields separated by Comma.
Example Input: 12,5678,78,

Output File structure is fixed (Each field is 5 Chars):
000120567800078

How can we do this using JCL or INSYNC ?
Regards,
Bindu
Back to top
View user's profile Send private message Send e-mail
dalaly
Beginner


Joined: 29 Nov 2002
Posts: 56
Topics: 23

PostPosted: Tue Mar 25, 2003 3:39 pm    Post subject: Reply with quote

Bindu,

If you have eazytrieve at your shop then you can use the following job to achieve the desired results.The beauty of this program is that it can work for any file whose length is less than or equal to 9999.

Code:

//STEP0100 EXEC PGM=EZTPA00                       
//STEPLIB  DD DSN=EASYTREV.LOADLIB,     
//            DISP=SHR                             
//SYSPRINT DD SYSOUT=*                             
//SYSOUT   DD SYSOUT=*                             
//SYSSNAP  DD SYSOUT=*                             
//SYSUDUMP DD SYSOUT=*     
//FILEIN   DD DSN=YOUR COMMA DELIMITED FILE,
//            DISP=SHR                                   
//FILEOUT  DD DSN=YOUR OUTPUT FILE WITH PADDED ZEROES,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y,),RLSE),                           
//            DCB=(RECFM=FB,LRECL=ZZZ,BLKSIZE=0)   
//SYSIN    DD *
  FILE FILEIN                                             
     FILEIN-REC            01 01 A  OCCURS 9999           
                                                           
  FILE FILEOUT                                             
     O-REC                 01 01 A  OCCURS 9999           
                                                           
  W-SUB        W 08 N 0                                   
  W-IN-START   W 08 N 0 VALUE 1                           
  W-IN-END     W 08 N 0 VALUE 0                           
  W-PAD-QTY    W 08 N 0 VALUE 0                           
  W-START      W 08 N 0 VALUE 1                           
  W-DELIM-IND  W 08 N 0 VALUE 5                           
  W-LIT-COUNT  W 08 N 0 VALUE 0                           
  W-OUT-START  W 08 N 0 VALUE 0                           
  W-VAR        W 05 N                                     
                                                           
                                                           
  JOB INPUT FILEIN                                         
                                                           
   W-SUB = 1                                               
                                                           
   DO UNTIL  W-SUB > FILEIN:RECORD-LENGTH                 
      IF FILEIN-REC (W-SUB) = ','                         
         PERFORM PAD-PROC                                 
         PERFORM FIELD-MOVE                               
      ELSE                                                 
        W-LIT-COUNT = W-LIT-COUNT + 1                     
      END-IF                                               
                                                           
      W-SUB   = W-SUB + 1                                 
   END-DO                                                 
                                                           
   PUT FILEOUT 
                             
PAD-PROC. PROC                                             
                                                           
   W-PAD-QTY = 5 - W-LIT-COUNT                             
                                                           
   CASE W-PAD-QTY                                           
        WHEN 1                                             
             MOVE '0'    TO O-REC (W-START) W-PAD-QTY       
        WHEN 2                                             
             MOVE '00'   TO O-REC (W-START) W-PAD-QTY       
        WHEN 3                                             
             MOVE '000'  TO O-REC (W-START) W-PAD-QTY       
        WHEN 4                                             
             MOVE '0000' TO O-REC (W-START) W-PAD-QTY       
   END-CASE                                                 
                                                           
 END-PROC                                                   
                                                           
 FIELD-MOVE. PROC                                           
                                                           
   W-IN-END     = W-SUB - 1                                 
   W-OUT-START  = (W-DELIM-IND - W-LIT-COUNT) + 1           
   MOVE  FILEIN-REC (W-IN-START) W-IN-END     +             
                TO O-REC (W-OUT-START) W-LIT-COUNT         
   W-START      = W-DELIM-IND + 1                           
   W-DELIM-IND  = W-DELIM-IND + 5                           
   W-IN-START   = W-SUB + 1                                 
   W-LIT-COUNT  = 0                                         
                                                           
 END-PROC                                                   

/*   


Best regards,

-dalaly
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bindu
Beginner


Joined: 05 Jan 2003
Posts: 17
Topics: 7

PostPosted: Tue Mar 25, 2003 10:04 pm    Post subject: Reply with quote

Hello Dalaly,
We don't have eazytrieve ... moreover we are not allowed to write in rexx also .. Sad ..
So the choice is limited Sad
Regards,
Bindu
Back to top
View user's profile Send private message Send e-mail
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Tue Mar 25, 2003 11:01 pm    Post subject: Reply with quote

Bindu,
If you want the JCL way, then you can use ICETOOL with two passes. I will just post the basic idea. The code is not complicated but very voluminous.

Assuming (a) there are only three 5 byte fields (b) no comma is a part of data you can do the following in ICETOOL.

1. Split the input file into 125 datasets. This is because, comma can appear at five places for every field. So, 5^3 = 125. For every combination of comma in three fields, (comma for first place in first field, comma for first place in second field, comma for first place in first third field, etc.), code a OUTREC parameter for dropping comma and formatting.

2. Concatenate those 125 datasets again back to the to-be-uploaded dataset.

For testing the splitting limit, I copied one record from my I/P file and wrote it to around 200 datasets. (I created those OUTFIL FNAMES cards using DFSORT!) I did not face any problem. Hope DFSORT would not complain in your case too.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Fri Mar 28, 2003 1:13 pm    Post subject: Reply with quote

Hi bindu,

If Cogito's sort solution is the only way to go using sort, a simple cobol pgm might do the trick, depending on the complexity of the input.

Just read the rec, unstring it to a series of elementary fields in a group item defined something like this:
Code:

01 op-rec.
    05 num-item-1   pic 9(005).
    05 num-item-2   pic 9(005).
    05 num-item-3   pic 9(005).
etc.

    unstring ip-rec delimited by ','
        into num-item-1
             num-item-2
             num-item-3
             etc.

It's important to look carefully at your input to understand and anticipate any variations that may be present. Like minus signs, decimal pts, etc.

HTH, Jack.
Back to top
View user's profile Send private message
bindu
Beginner


Joined: 05 Jan 2003
Posts: 17
Topics: 7

PostPosted: Sun Mar 30, 2003 9:57 pm    Post subject: Reply with quote

We'll go for the Cobol program ..thanks for all the replies ..
Regards,
Bindu
Back to top
View user's profile Send private message Send e-mail
coolman
Intermediate


Joined: 03 Jan 2003
Posts: 283
Topics: 27
Location: US

PostPosted: Wed Apr 02, 2003 8:31 am    Post subject: Reply with quote

Bindu,
I know Im pretty late on this.But could you please tell me as to what are the possible flavours of input (with commas). Is the comma position fixed for all the records. BTW, I was suprised to see your shop allowing you to code a COBOL pgm rather than a REXX code. Does that still hold good ?

Cheers,
Coolman.
________
Biscayne


Last edited by coolman on Sat Feb 05, 2011 1:20 am; edited 1 time in total
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue May 30, 2006 2:27 pm    Post subject: Reply with quote

With z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006), you can now do this kind of thing quite easily with DFSORT's new PARSE function, as shown by this DFSORT job:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INREC PARSE=(%00=(FIXLEN=5,ENDBEFR=C','),
               %01=(FIXLEN=5,ENDBEFR=C','),
               %02=(FIXLEN=5,ENDBEFR=C',')),
    BUILD=(%00,UFF,TO=ZD,LENGTH=5,
           %01,UFF,TO=ZD,LENGTH=5,
           %02,UFF,TO=ZD,LENGTH=5)
/*


For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTFs, see:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL) All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group