I have a bunch of applications in positional RPGLE who need some rework to be adapted to a new database table layout.
Before, said application opened an LF readonly and did a CHAIN with a given customer number ("KUNR") to look up the customer name ("FIRMA"). The LF pointed to an export of customer master data being copied via ODBC to a PF, DDS derived. Nothing fancy, just the usual character field (no VARYING!) in the native charset of IBM i (1141, German with €).
Because of ongoing issues with national characters, a decision was agreed upon to migrate all the data to SQL created tables, using "modern" features like varchar fields, and CSSID 1208, UTF-8. This should enable transparent passthrough of textual data for ODBC based clients, and transparent conversion for local 5250 based applications. The database layout is now handled by other people, and I agreed to rewrite the applications so they are compatible with the new database definitions. Looking at the new database data with interactive SQL works fine, and umlaut conversion is taking place as expected.
I have created a DDS based logical file pointing to the new database tables, just renaming the fields from their new-database-names to the old ones (KUNR, and FIRMA), and adding a key to be able to CHAIN by KUNR. No other definitions are taking place. A test run with interactive SQL successfully worked. Dspffd for the LF shows a field length of 128 chars, and a buffer length of 130 for the customer name field. I guess to leave space for the zero termination if the string reaches maximum length?
I'm referring the described LF in the F specs:
FCUSBYCUSNOIF E K DISK
I know that I need to convert C strings to fixed length by stating
EVAL FIRMA$=%STR(FIRMA).
Note: FIRMA$ is the field definition from the display file.
Compilation of this fails with RNF0343: The first parameter for %STR is not valid; %STR is ignored. The first parameter for built-in function %STR must be of type basing pointer.
Okay, input variable somewhat bonkers. I defined FIRMA# as 130 characters string and gave this to %STR, with the same compilation error.
Finally I decided to just use EVAL FIRMA$=FIRMA. This compiled and works. But I'm not sure what happens with the binary zero. Does EVAL convert the C string to fixed length? If yes, what is %STR good for?
I'm not very fluent with pointers in RPGLE, but I presume that even a string variable has an address. Google doesn't really know about RNF0343. Anyone cares to shed some light on this? Thank you!
Note: I'm using positional syntax.
:wq! PoC
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.