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



It isn't difficult if you understand what BinDec is all about. It is an effectively deprecated data type that due to the need to maintain compatibility still exists.

But to answer your question directly.

When a four byte binary is represented as type B(inDec) in RPG it is defined as having a length of 9 digits. Before any processing is performed on it, it is copied to a packed temporary of length 9. But an int(10) can contain values up to 2,147,483,647 and that won't fit - so you get the overflow exception you were seeing whenever the value in the field exceeds 999,999,999.

This is why EXTBININT(*Yes) cures the problem. It says to treat integers as real integers and not the stupid legacy B(indec) type. Older releases of RPG could not offer this option as B(indec) was the only "binary" format supported.

It is all part of the blessing/curse of IBM i. The BEST thing about the platform is I can compile and run 30+ year old code without changing a thing. The WORST thing about the platform is I can compile and run 30+ year old code without changing a thing.


Jon Paris

On Oct 27, 2021, at 10:49 AM, C H <christopherholko@xxxxxxxxx> wrote:

I did find a solution, adding EXTBININT(*Yes) to my CTL-OPT line gets the
%CHAR to work on the field.

but honestly I am not sure why this should be so difficult to move a BINDEC
around

On Wed, Oct 27, 2021 at 9:33 AM Charles Wilt <charles.wilt@xxxxxxxxx> wrote:

When you look at the compile list, how are the DS subfields defined in the
X-Ref?

Honestly, sounds like it is time to call IBM support.

Charles

On Wed, Oct 27, 2021 at 5:45 AM Chris Holko <christopherholko@xxxxxxxxx>
wrote:

Please note, autocorrect was driving me insane


So in a file there is a field defined as

EDROW INT NOT NULL GENERATED AWAYS AS IDENTIFY
(START WITH 1 INCREMENT BY 1 MINVALUE 1 NO MAXVALUE NO CYCLE NO
CACHE
ORDER),


Anyway… the SQLRPGLE program is straightforward
Define an data structure with external name keyword to that file
Declare a cursor with each field selected from that file to load
in the data structure
Fetch it.

then try to %char it into a string and voila, MCH1210 Receiver to small.

You can move the field into a BINDEC(9:0) and use that with %trim but not
the field itself.

So why cannot I get the %Char over the data structure field to work? Is
that not allowed?

V7R3 TR10



Error File

Create of Replace Table ErrorFile(
EDROW INT NOT NULL GENERATED AWAYS AS IDENTIFY (START WITH 1 INCREMENT
BY 1 MINVALUE 1 NO MAXVALUE NO CYCLE NO CACHE ORDER)
Error_Identification for column ERRID CHAR(8),
Error_Text for column ERRTXT CHAR(500),
Sequence_Number for column ERRCOL dec(10,0),
Primary Key Key(ERRCOL)
)
RcdFmt ErrRcv;


Example. (auto correct is killing me)

dcl-s error string char(500);
dcl-ds errorfile_ds extname(‘ERRORFILE’) Prefix(Err_) Qualified End-Ds;
dcl-s errbin bindec(9:0);
dcl-s myerr char(8);

errbin=errorfile_ds.err_edrow;

error = ’The Error was ‘ + %trim(%char(errbin));

error = ’The Error was ‘ + %trim(%char(errorfile_ds.err_edrow)); <- that
will MCH1210


sql to load is similar to

exec sql declare cursor mycursor for
select edrow, erred,errtxt,errcol
from errorfile
where errid=:myerr;

exec sql fetch next from mycursor into :errorfile_ds;






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

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

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

This thread ...

Follow-Ups:
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.