Focal Point
Remove Trailing Spaces from data in HOLD/SAVE file

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5611009331

September 26, 2005, 01:35 PM
Francis Mariani
Remove Trailing Spaces from data in HOLD/SAVE file
I'd like to create a HOLD or SAVE file where the data rows do not have any trailing spaces.

I've tried SQUEEZ and TRIMV but neither do the trick - the HOLD file is filled with trailing spaces.

Any ideas?

SET HOLDFORMAT = ALPHA
SET ASNAMES = ON
SET HOLDLIST = PRINTONLY

TABLE FILE EQ_DATA1
PRINT
COMPUTE EQ_DATAS/A400 = SQUEEZ(1000, SQL_COMMAND, 'A400'); NOPRINT
COMPUTE EQ_DATAT/A400V = TRIMV('T', EQ_DATAS, 400, ' ', 1, EQ_DATAT);
ON TABLE HOLD AS EQ_DATA
END
September 26, 2005, 01:41 PM
susannah
and you've tried fiddling with the RECFM in the output filedef? making it V for VARiable length records, not F? I'm not suggesting that this will work, tho, Francis, just adding it to the list of tinkerables. and then there's the output csv file.. it's compacted...no trailing spaces on any of the fields...If your output file has only 1 field, maybe try FORMAT COMMA
September 26, 2005, 02:03 PM
Francis Mariani
FILEDEF EQ_DATA DISK data_20050926.sql RECFM V

I tried RECFM V and get an error - it seems that is not valid syntax.

FORMAT COMMA did not do it - in fact it put quotes around the data.

I have a feeling this is not possible - I don't think there's a variable format hold file.
September 26, 2005, 04:03 PM
j.gross
Try casting it to AnV format, and trimming the length.
September 26, 2005, 04:25 PM
susannah
as i recall, parms to a filedef are preceeded by a left paren
FILEDEF mastername DISK D:\IBI\...\filename.txt (RECFM V LRECL 80
totally inelegant, but works:
FILEDEF TRYTHAT DISK D:\IBI\APPS\AS400\TRYTHAT.FTM (RECFM V
TABLE FILE somesourcefile
PRINT field ON TABLE HOLD AS TRYTHIS FORMAT ALPHA
END
-RUN
-SET &KOUNTER = 0 ;
-TOPLOOP
-READ TRYTHIS &NAME1.A26
-SET &KOUNTER = &KOUNTER + 1 ;
-SET &NAME2 = TRIM('T', &NAME1, 26 , ' ' , 1 , A26 );
-WRITE TRYTHAT &NAME1
-IF &KOUNTER EQ 10 GOTO ENDLOOP ;
-GOTO TOPLOOP;
-ENDLOOP
September 26, 2005, 04:28 PM
Mickey
Francis,

I came across the following link on the techsupport site.

http://techsupport.informationbuilders.com/ibase/master...eports20.htm#1037814

I tried the
ON TABLE HOLD AS HOLDCAR FORMAT COMT and it looks like it works.

M
September 26, 2005, 04:40 PM
codermonkey
FORMAT COM should remove leading zeros on numerics and trailing blanks on alphanumerics but does put alphanumeric fields in quotes.

What about holding it in COM format then tabling that and holding/saving as FORMAT ALPHA?

I have no idea if this will work but it might be worth a try. Good luck.
September 26, 2005, 04:54 PM
susannah
COM and COMT don't truncate the field width.
They look like they do, but then when you open the file in textpad, you'll see that the field is still the same width.
i thought they did, too.
but , alas. t'was wishful coding.
Triming the field in dialog manager and -WRITEing it does works, when you open the file in textpad, each record is only as long as it needs to be. But what an inelegant solution! As much help as Francis gives all of us, i wish we could come up with something cooler for him.
September 26, 2005, 05:30 PM
Francis Mariani
In my particular case, the trailing blanks are harmless, but there should be an elegant way to do this, withour resorting to Dialog Manager.

By the way, when I use an AnV formatted field, the resulting HOLD file has the length of the data as the first six characters of each row, but the data is still not trimmed.

Susannah, thanks for trying, I appreciate the suggestions.
September 26, 2005, 06:18 PM
j.gross
Francis -

Did you try TRIMV()?


"If the [output] format is AnV, the length is set equal to the number of characters left after trimming."


(http://techsupport.ibi.com/ibase/masterindex/html/html_iway71/dmfunctions_71/var_chara6.htm)

This message has been edited. Last edited by: <Maryellen>,


- Jack Gross
WF through 8.1.05
September 26, 2005, 06:25 PM
Francis Mariani
I assume TRIMV requires an AnV field as output. WHen I try that, the length of the data is prepended to the beginning of the data - this is worse than having the trailing blanks.

TABLE FILE EQ_DATA1
PRINT
COMPUTE EQ_DATAS/A400 = SQUEEZ(1000, SQL_COMMAND, 'A400'); NOPRINT
COMPUTE EQ_DATAT/A400V = TRIMV('T', EQ_DATAS, 400, ' ', 400, EQ_DATAT);
ON TABLE SAVE AS EQ_DATA
END
September 26, 2005, 07:27 PM
Håkan
Francis,

what about this?

FILEDEF EQ_DATA DISK C:\IBI\APPS\EQ_DATA.FTM
TABLE FILE CAR
PRINT COUNTRY
ON TABLE SAVE AS EQ_DATA FORMAT TAB
END

/H�kan
September 26, 2005, 08:22 PM
Francis Mariani
That did it!

Thank you Stockholm!
September 26, 2005, 09:11 PM
susannah
applause!