× 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.



Hi Tim,

Am 07.09.2023 um 21:26 schrieb tim ken <timk2574@xxxxxxxxx>:

and in the DDS of the display file I should write the field definition like
below:-?

A N70 FLD1 10Y 0O 4 62COLOR(PNK)
EDTWRD(' 0')

In DDS the length of the EDTWRD has to be the same length as the digits of the numeric(!) field.

But if you don't have special needs, it's generally better to use EDTCDE instead of your EDTWRD. In your case EDTCDE(3) would do it.

But this would only display the "pure" edited and right-adjusted number on the screen. No text like "Sum:" - you have to add that as a text constant in front of your field like that:

A N70 4 62'Sum:' COLOR(PNK)
A N70 FLD1 5Y 0O +1COLOR(PNK) EDTCDE(3)

Docs: https://www.ibm.com/docs/en/i/7.5?topic=80-edtcde-edit-code-keyword-display-files

did you mean in my program instead of ' fld1 = 'Sum: ' +
%trim(%editw(fld3:' 0 '))'

i should write it like this :- 'fld1 = 'Sum: ' + %trim(fld3:' 0 '))' ?

With the DSPF field definition above, you only have to write:

fld1 = fld3;

in RPG, because both fields are numeric (!) now.

Also, could you please explain with an example how to use %BIF here ?

With %BIF the built-in-functions of RPG are meant - like %trim, %editc, %EDITW or %char.

You can define your field in DDS like this:

A N70 FLD1 10A O 4 62COLOR(PNK)

And then write your code in RPG like that:

fld1 = 'Sum: ' + %char(fld3);

That's because your target FLD1 is now a char field - and you have to assign a character string value. The %CHAR bif (which I would use instead of %EDITW+%TRIM) is converting your numeric field FLD3 into a string, %TRIM will remove leading and trailing blanks from that string and that it will be concatenated to the string 'Sum: '.

Docs: https://www.ibm.com/docs/en/i/7.5?topic=functions-char-convert-character-data#bbchar

Now the two solutions will result in slightly different screen displays.

1. Using 10Y 0 and a text constant in DDS will result in:

Sum: 815

2. Using 10A in DDS and %EDITW or %EDITC in RPG like you done it originally will result in:

Sum: 815

The difference makes that %CHAR has no leading spaces before concatenation - and this means, your "number" will shift to the left.

It's all about taste and company policy - I generally try to avoid putting text constants into RPG source code - so I would use solution 1 with the 10Y 0 field and the constant in DDS.

HTH
Daniel

P.S.: What programming background do you have? Did you receive a "formal" RPG training?


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.