Remove extra spaces from a graphic or UCS2 field in RPGLE

130 pts.
Tags:
AS/400
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following