× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



+1

I suspect that SQL is not as efficient - here is what the SET statement does, according to the manual -

"The SET variable statement produces a result table consisting of at most one row and assigns the values in that row to variables."

Besides that, there are 2 or 3 inline function calls.

Cheers
Vern

On 3/26/2023 3:11 PM, Jon Paris wrote:
There's a really simple way to do this in RPG.

EVALR.

Simply code EvalR result = shortField;

Or if shortField has trailing spaces then:

EvalR result = %TrimR(shortField);

I cannot agree with Jonathan about using SQL for tasks like this - SQL is great for what it is designed for. Replacing a perfectly good built-in language feature is not what it was designed for. If you need to right adjust _within_ and SQL operation sure but ...

Just my 10 cents worth.


Jon P.

On Mar 26, 2023, at 3:49 PM, Jonathan Ball<jonball52@xxxxxxxxx> wrote:

I tend to do all of this kind of activity in SQL whenever possible.

dcl-s char_15 char(15);
dcl-s char_30 char(30);
dcl-s char_7 char(7) inz('STUFF'); // char_7 = 'STUFF '

exec sql
set :char_15 = lpad(rtrim(:char_7), length(:char_15)); // char_15 = ' STUFF'

exec sql
set :char_30 = hex(:char_15); // char_30 = '40404040404040404040E2E3E4C6C6'

In find SQL built-in functions intuitively easier to understand and simpler to use than equivalent RPGLE BIFs, and there aren't always equivalents.

On 2/14/2023 1:04 PM,dfreinkel@xxxxxxxxxxxxxxxxx wrote:
What is a good and simple way to right justify a character field?

I would not like to use a do loop to do this.

Thanks

Darryl Freinkel

A4G

Telephone: 770.321.8562 Mobile: 678.355.8562

--
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
athttps://archive.midrange.com/rpg400-l.

Please contactsupport@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.