Page 1 of 1

Get rid of blanks and compress records

PostPosted: Sat Nov 23, 2019 1:03 am
by Mickes
Hi,

I've a fixed sequential file with LRECL=23.

Layout is:
Customer pos 1-6
Text pos 7-11
Filler pos 12-13
Status pos 14-18
Flag pos 19-23

It contains following records:
ABC123TEST1..OK false
BBB222HI ..OTHERtrue
CBA321WHY ..NICE false

I want to put a ';' direct after the last letter between the fields so I get rid of the fields all spaces to the right.
I also want to OMIT field Filler.

So the output file should be as follow:
ABC123;TEST1;OK;false;
BBB222;HI;OTHER;true;
CBA321;WHY;NICE;false;

Hopefully someone can help me.

Regards,

Mikael
BBB257113 ;0000010000005289;0000;000001581693;OK ; ;ALWAYS;00000;fal

Re: Get rid of blanks and compress records

PostPosted: Sat Nov 23, 2019 2:43 am
by Terry Heinze
Please use Code tags for readability:
ABC123TEST1..OK false
BBB222HI ..OTHERtrue
CBA321WHY ..NICE false


ABC123;TEST1;OK;false;
BBB222;HI;OTHER;true;
CBA321;WHY;NICE;false;


BBB257113 ;0000010000005289;0000;000001581693;OK ; ;ALWAYS;00000;fal

Re: Get rid of blanks and compress records

PostPosted: Sat Nov 23, 2019 3:06 am
by Mickes
Here comes an attached file and it contains in/out file with fixed font so it's easier to read

[Attacment deleted - Terry has already edited the data display.]

Re: Get rid of blanks and compress records

PostPosted: Sat Nov 23, 2019 3:08 am
by Robert Sample
Attached files are not often downloaded on this site due to the inherent dangers they pose. Use Code tags and put your data in your posts, or your odds of getting an answer will go WAY down if you expect someone to download your attachment.

Re: Get rid of blanks and compress records

PostPosted: Sat Nov 23, 2019 4:38 am
by Mickes
Infile:

----+----1----+----2---
ABC123TEST1..OK   false
BBB222HI   ..OTHERtrue
CBA321WHY  ..NICE false
DDD333TEST2..HOMERfalse


Outfile variable:

----+----1----+----2---
ABC123;TEST1;OK;false;
BBB222;HI;OTHER;true;
CBA321;WHY;NICE;false;
DDD333;TEST2;HOMER;false;

Re: Get rid of blanks and compress records

PostPosted: Sat Nov 23, 2019 3:40 pm
by NicC
Use PARSE to split your record into its component fields and build to join them up again with ';' separators. Use SQZ to remove spaces. There was a requirement similar to this just a few weeks ago.