In RPG :
If you can change the RPG parameter to character you can use:
D charCounter 4a
D Counter 4s 0
CharCounter = %char(counter);
That will make give you a charCounter without leading 0's.
Not sure why you need your parameter in RPG to be numeric.
Paul
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Patrik Schindler
Sent: Wednesday, June 9, 2021 6:00 AM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: [V4, positional]: Converting decimal to string without leading zeros
Hello,
I've created a CL program declaring a 4 char string variable. This is passed to an RPGLE program to fill in how many records have been processed. In it's D-specs I declare this as "4S 0", and MOVE a counter variable's contents to there before the program ends. After the RPG program is finished, I'm using SNDPGMMSG with a custom *MSGF to output the number of records processed. (This circuitous way is to my knowledge the only way to output a messages which stay in the message line even after the program itself has ended and the command line is appearing again.)
The MOVE creates a string with leading zeros. What would be the easiest/least-code/correct way to get rid of these?
I can't pass the number as number, because the CL compiler complains when the call to SNDPGMMSG is done using *DEC instead of *CHAR.
Thanks for your opinions!
:wq! PoC
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.