Page 1 of 1

SPLIT input records based on the given delimiter

PostPosted: Fri May 03, 2013 7:45 am
by gopal_NKP
Hi,

The file is having in the below given format. The characters after CRLF should continue in the next line as next record. The position of CRLF is not constant to any column.

INput File: (in VB format with LRECL=351)
1111111111111111111111111CRLF222222222222222222222222222222222222222222222222222222222222222222222222222222222
22222222222222222222222222222222222CRLF33333333333333333333333333333333333333333333333333333333333333333333333
3333333333333333333333333CRLF444444444444444444444444444444444444444444444444444444444444444CRLF55555555555555


Expected output (in VB format with LRECL=351):
111111111111111111111
222222222222222222222222222222222222222222222222222222
333333333333333333333333333333333333333333333333333333
444444444444444444444444444444444444444444444444444444
5555555555555555555555555

Could you please help me to achieve the expected output?

Re: SPLIT input records based on the given delimiter

PostPosted: Fri May 03, 2013 2:27 pm
by NicC
What have you tried so far? And in what way did these experiments not achieve what you wanted?

Re: SPLIT input records based on the given delimiter

PostPosted: Fri May 03, 2013 3:27 pm
by BillyBoyo
How many CRLFs might you have per record?

Can data for one "output record" be contained on two or more input records?

Re: SPLIT input records based on the given delimiter

PostPosted: Fri May 03, 2013 3:53 pm
by gopal_NKP
Hi,

Once record contains one CRLF character in the input file.

Re: SPLIT input records based on the given delimiter

PostPosted: Fri May 03, 2013 4:15 pm
by BillyBoyo
OK, look at PARSE, with ENDBEFR=X'crlf' and FIXLEN=347. You'll need two PARSEd fields.

You'll need an OUTFIL which will allow you to use the "slash operator", /, to output more than one record from one input record. You'll probably want to use VLTRIM to drop the trailing blanks which would otherwise exist (I'm guessing you won't have any "genuine" trailing blanks due to the way the file has been created).

Re: SPLIT input records based on the given delimiter

PostPosted: Fri May 03, 2013 10:58 pm
by skolusu
Gopal,

You need to fix your process that sent the file. If you FTP'ed the file from open system to mainframe, take a look at the SITE command where you can specify the file DCB properties. Once you specify that you don't even split the records based on the CRLF.


BillyBoyo wrote:OK, look at PARSE, with ENDBEFR=X'crlf' and FIXLEN=347. You'll need two PARSEd fields.

You'll need an OUTFIL which will allow you to use the "slash operator", /, to output more than one record from one input record. You'll probably want to use VLTRIM to drop the trailing blanks which would otherwise exist (I'm guessing you won't have any "genuine" trailing blanks due to the way the file has been created).


Bill,

There is more to just parsing. Look at the records 222222, 33333 and 4444..... They are all spread across 2 records. Along with parsing we need to merge the split records into a single record which will be a difficult task. OP just need to fix his FTP parms which would automatically take care of the issue.

Re: SPLIT input records based on the given delimiter

PostPosted: Sat May 04, 2013 3:16 am
by BillyBoyo
Well, I did ask about that. Although no specific answer, the "one CRLF per record" seemed to indicate that the data was not as shown (two CRLFs on the last sample record).

Yes, much better to get it fixed :-)

Re: SPLIT input records based on the given delimiter

PostPosted: Tue May 07, 2013 7:04 pm
by gopal_NKP
Hi,

Thanks to all of you for your help.
The file is the result of a PGP decryption. We receive file in encrypted format and process it after decryption.

Re: SPLIT input records based on the given delimiter

PostPosted: Tue May 07, 2013 8:03 pm
by BillyBoyo
OK, pretend earch sub-record on a record is a maximum of 10 bytes long, then show some sample input and expected output.