View previous topic :: View next topic
Author
Message
numr New User Joined: 02 Apr 2005Posts: 4
Hi
Input FILE HAS RECORDS IN as below.
12345,abc,1278,ihu,pppsdd, etc...
I need to take only the first three to the output file.
i.e
12345,abc,1278
Field length is not fixed and the requirement is to have the first three fields only.
Back to top
krisprems Active Member Joined: 27 Nov 2006Posts: 649 Location: India
numr
You are confusing with the terms RECORD and FIELDS....
You havent told the attributes of i/p file - whether its FB or VB?
Quote:
Input FILE HAS RECORDS IN as below.
You said records, but what you have shown is only one record.
Quote:
I need to take only the first three to the output file.
"first three" fields or records?
Back to top
numr New User Joined: 02 Apr 2005Posts: 4
Sorry for the confusion.
Input FILE HAS RECORDS as below.
12345,abc,1278,ihu,pppsdd,
erdfghh,123,tfsdhk,ws,qwerty,
I need to take only the first three fields in each record to the output file.
Field length is not constant.
i.e
12345,abc,1278
erdfghh,123,tfsdhk
Please help
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
I think you're saying you have CSV (comma separated value) records and you only want to keep the first three values in each record. Here's a DFSORT job that will do that. I assumed your input file has RECFM=FB and LRECL=80 and that each field can be a maximum of 20 characters, but you can change the job appropriately as needed.
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
12345,abc,1278,ihu,pppsdd,
erdfghh,123,tfsdhk,ws,qwerty,
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=20),
%02=(ENDBEFR=C',',FIXLEN=20),
%03=(ENDBEFR=C',',FIXLEN=20)),
OVERLAY=(1:%01,%02,%03,
1:1,60,SQZ=(SHIFT=LEFT,MID=C','),80:X)
/*
For more information on DFSORT's PARSE and SQZ functions, see:
Use [URL] BBCode for External Links
Back to top
Please enable JavaScript!