130 pts.
 Remove extra spaces from a graphic or UCS2 field in RPGLE
I am working on a requirement where I have to trim Graphic ('G') or UCS2 ('C') field in RPG program. %TRIMR is not working for these fields. A Graphic or UCS2 field is declared with a length of 15000. However, it only contains 258 character (graphic/ucs2 type). But, using TRIMR does not remove the remaining spaces (15000-258). Please let me know if anyone has any idea on how to remove extra spaces from a graphic or UCS2 field in rpgle.

Software/Hardware used:
as400
ASKED: May 18, 2012  9:52 AM
UPDATED: May 19, 2012  1:04 PM

Answer Wiki:
I'm not sure what problem you are running into, but the following sample code uses trimr to successfully determine the blank trimmed length of a UCS2 field and to concatentate a blank trimmed UCS2 field with a space and then another UCS2 field. <pre> dUCSField1 s 15000c dUCSField2 s 15000c dSpace s 1c dTargetField s 100c dLength s 10i 0 /free UCSField1 = 'Bruce'; UCSField2 = 'Vining'; Length = %len(%trimr(UCSField1)); TargetField = %trimr(UCSField1) + Space + UCSField2; *inlr = *on; return; /end-free </pre> I hope this helps, Bruce Vining
Last Wiki Answer Submitted:  May 19, 2012  1:04 pm  by  bvining   6,055 pts.
All Answer Wiki Contributors:  bvining   6,055 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _