Depending on the complexity or your source data, potentially in UTF8 be aware that is a variable encoding, i.e. single code points can be coded with 1 byte up to 4 bytes.Also, multiple code points can express what you normally call "a character". A simple character like à can be potentially expressed as a + 'i.e. a plus a modifying characterso it is advisable to set the database column hosting unicode as *NORMALIZE (to get a normalized form of the string).Also get a CCSID conversion listing after compilation, to really check what happens.Then look at the variable in memory with STRDBG to see what really happens.Don't use vanilla "byte wise" operators, there are no "characters", *NATURAL can be an option to subset.
ciao
On Tuesday, February 24, 2026 at 02:56:37 PM GMT+1, Gad Miron <gadmiron@xxxxxxxxx> wrote:
Hello sages
I would greatly appreciate advice regarding the following CCSID issus:
We have lately added a 128 long, CCID(1208) description field to an
existing CCID(424) "mapping file" that maps external SKUs to our SKUs.
This file comprises mainly of:
EXTID - External entity ID
EXTSKU - External SKU
EXTDESC - External Description
INTSKU - Internal (Our) SKU
and the new
ITEMNAME8 - External description 1208
now,
I need to update the new EXTDESC1208 field using descriptions retrieved from
another file that has a CCID(1208) description field.
I have managed to do it with SQL but I would very much like to
do it in the original RPG program that populates this map-file.
after consulting the enlightening doc by Barabara morris
https://www.ibm.com/support/pages/system/files/inline-files/working_with_unicode_in_rpg.pdf
I came up with a skeleton semi-hard-coded RPG program that should be capable
of updating one specific record, BUT FAILS.
Here comes (forgive the mixed free/fixed format):
H DATEDIT(*YMD) ALWNULL(*USRCTL) CVTOPT(*VARCHAR : *VARGRAPHIC)
F* the source file to retrieve the description from
FNMMLIMPF2 if e k DISK EXTDESC('URPS/NMMLIMPF')
F EXTFILE(*EXTDESC)
F DATA(*NOCVT)
F
RENAME(NMMLIMPR:NMMLIMPR2)
F* The map file to be updated - target
FNMWRKF uf e k DISK DATA(*NOCVT)
dcl-ds ds_NMMLIMP2 likerec(NMMLIMPR2) ccsid(*exact)
dcl-ds ds_NMWRKR likerec(NMWRKR) ccsid(*exact) ;
// Get record to be updated
EXTID = '053' ;
EXTSKU = 'A3507531197482438BTRRtbKgG8' ;
chain (EXTID : EXITSKU) NMWRKF ds_NMWRKR ;
// Get CCID(1208) Description value from source file
SRCFILEID = 36694 ;
CATLOG = '8BTRRtbKgG8' ;
chain (SRCFILEID : CATLOG) NMMLIMPF2 ds_NMMLIMP2 ;
// take first 128 chars of Item Description
ds_NMWRKR.ITEMNAME8 = %subst(ds_NMMLIMP2.ITEMNAME :1 : 128) ;
// Update map file - target
update NMWRKR ds_NMWRKR ;
C eval *INLR = *ON
The update works but the value placed in ITEMNAME8 is erroneous
Now,
(green screen) Debugging this skeleton I suspect that the %subst(xxxx)
fails
but I may be wrong (not my 1st time)
The (source) NMMLIMP2.ITEMNAME field is a 512 long, nullable, CCID(1208)
VARLEN(30)
The (target) NMWRKR.ITEMNAME8 field is a 128 long not nullable
CCID(1208)
Any help will be greatly appreciated.
TIA
Gad
As an Amazon Associate we earn from qualifying purchases.