I will look into this but I am pretty sure I am going to have problems because for some unknown reason, all of their job CCSIDs are set up to be 66535, not 37.

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Daniel Gross
Sent: Friday, February 7, 2025 3:46 PM
To: rpg400-l@xxxxxxxxxxxxxxxxxx
Subject: Re: variable CCSID for a variable

Hi,

I think that embedded SQL might be the solution.

With IFS_WRITE you can can set the files CCSID when writing.

https://www.ibm.com/docs/en/i/7.5?topic=is-ifs-write-ifs-write-binary-ifs-write-utf8-procedures

Please check with docs, but I mean something like:

exec sql
call ifs_write(
path_name => :pathName,
line => :clob_in_job_ccsid,
file_ccsid => :ccsid,
overwrite => 'APPEND',
end_of_line => 'CRLF'
);

The docs say, that the data should be in the jobs ccsid, and it will automatically converted to the file ccsid.

As I haven't tried that with a host variable for the ccsid, please tell us, whether this works or not.

HTH and kind regards,
Daniel


Am 07.02.2025 um 21:12 schrieb smith5646midrange@xxxxxxxxx:

I have a program that writes data to the IFS.



Strings are concatenated into dataString. Eventually dataString is
written to the IFS. It used to only write UTF-8 so it utilized the
CCSID on the variable as follows.



dcl-s dataString varchar(1048576) ccsid(1208);



Now my client has times they want to write ebcdic instead of utf8. Is
there a way to make the ccsid on the above variable a variable that I
can pass into my program? I would rather not write code like this.
First because it is ugly to have these if statements throughout the
code (I know, I can create a function and it won't be as bad) but
second we are now locked into using only two CCSIDs and I would have
to change the program if they decided that they want a third or fourth
CCSID. With a parm, I can just say give it a try.



dcl-s dataString1208 varchar(1048576) ccsid(1208);

dcl-s dataString37 varchar(1048576) ccsid(37);



if parmCCSID = UTF8

append to dataString1208

else

append to dataString37

endif

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

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

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.