A quick program does confirm it works. Sorry for doubting you Chris...
Hoption(*nodebugio:*srcstmt)
d testevalr pr
d pi
d rc s 10i 0
d fielda s 20a
d fieldb s 6a
d message s 50a
* Program
Variables
********************
*
/free
*inlr = *on ;
fielda = '1234';
message = 'Fielda = ' + fielda;
Dsply message;
Evalr fieldb = '000000' + %Trim(fielda);
message = 'Fieldb = ' + fieldb;
Dsply message;
fielda = '12345';
message = 'Fielda = ' + fielda;
Dsply message;
Evalr fieldb = '000000' + %Trim(fielda);
message = 'Fieldb = ' + fieldb;
Dsply message;
Return;
/end-free
Robert Rogerson
On 2012-09-25 3:27 PM, Hiebert, Chris wrote:
You can do this without any decimal conversion.
EVALR field_b = '000000' + %TRIM(field_a);
Chris Hiebert
Programmer/Analyst
Disclaimer: Any views or opinions presented are solely those of the
author and do not necessarily represent those of the company.
-----Original Message-----
From: [1]rpg400-l-bounces@xxxxxxxxxxxx
[[2]mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Jeff Young
Sent: Tuesday, September 25, 2012 9:27 AM
To: RPG programming on the IBM i / System i
Subject: Right adjust zero fill character field
All,
I am having a brain freeze moment today.
I have a 20 byte character field that will contain up to 6 bytes of data
left adjusted.
I need to take the data from the first field and load it to a 6 byte
field padded with leading zeros.
ie: field a = '1234 '
I want field b to be '001234'
when field a = '12345'
field b = '012345;
Thanks,
--
Jeff Young
Sr. Programmer Analyst
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
list To post a message email: [3]RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: [4]
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: [5]RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
[6]
http://archive.midrange.com/rpg400-l.
References
Visible links
1. mailto:rpg400-l-bounces@xxxxxxxxxxxx
2. mailto:rpg400-l-bounces@xxxxxxxxxxxx
3. mailto:RPG400-L@xxxxxxxxxxxx
4.
http://lists.midrange.com/mailman/listinfo/rpg400-l
5. mailto:RPG400-L-request@xxxxxxxxxxxx
6.
http://archive.midrange.com/rpg400-l
As an Amazon Associate we earn from qualifying purchases.