Hi Peter,

you have a good eye.

It's completely irrelevant if it's CHAR or VARCHAR - if the source field is longer than 16382 bytes, the compiler complains. It's also irrelevant if the receiver of the FOR-EACH is CHAR or VARCHAR - ans also its size is irrelevant.

The only chance to make it work is to %SPLIT into an array - and then FOR-EACH over that array - in this case, it compiles. And yes - I increased the size up to the possible 16M - no problems.

%SPLIT itself doesn't have a problem at all - only in direct combination with FOR-EACH, it doesn't seem to work.

Thanks for you thoughts.

Regards,
Daniel


Am 10.12.2024 um 18:49 schrieb Peter Dow <petercdow@xxxxxxxxx>:

Hi Daniel,

I notice that in addition to shortening the items variable, you also changed it from varchar to char.

Also, in the code where you %split into an array, you did not increase the items variable back to 32000.

Maybe %split has a problem with varchar?

--
*Peter Dow* /
909 793-9050
petercdow@xxxxxxxxx
/


On 12/10/2024 7:52 AM, daniel@xxxxxxxx wrote:
Hi,

I have a strange problem. I have several programs in production, which use FOR-EACH with %SPLIT. These programs are working since several months.

Now when I try to compile these programs the compiler terminates with CWX9001 and in the job log a MCH4227 message can be found.

This is the construct that worked at least until October this year, and is failing now:

**free
ctl-opt actgrp(*new);
dcl-s items varchar(32000) inz('1,2,3,4,5');
dcl-s item varchar(25) inz;
for-each item in %split(items:',');
dsply item;
endfor;
*inlr = *on;
return;
Now the strange things start.

If I shorten the „list“ variable to VARCHAR(16382) the program compiles:

dcl-s items char(16382) inz('1,2,3,4,5');
dcl-s item char(25) inz;
for-each item in %split(items:',');
If I declare an array and do the %SPLIT into that, the program compiles:

dcl-s items char(16382) inz('1,2,3,4,5');
dcl-s item char(25) inz;
dcl-s array char(25) dim(*auto:32000) inz;
array = %split(items:',');
for-each item in array;
What’s wrong? Any ideas?

Thanks in advance.

Kind regards,
Daniel




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


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.