Avatar of Drew Stephens
Drew Stephens

asked on 

Unable to write ASCII to IFS from RPGLE program

I am creating and writing to an IFS File and want the file to be written in ASCII format.  I am using the C "open" and "write" APIs.  Here is the text I am using to create the file.

                 + O_TRUNC + O_TEXT_CREAT;
         mode = S_IRWXU;                  // Grant the Owner full rights
         mode += S_IRGRP + S_IWGRP;       // Grant Owner's Group Read and Exec rights
         mode += S_IROTH + S_IWOTH;       // Grant all others Read and Exec rights

         // Create the IFS File...
         fd = open(%trim(scriptPath):
                         CP_WINDOWS);    // Important for CCSID to be Windows Compliant.
          if fd >= *ZEROS;
           callp close(fd);                // Save to the folder
           scriptIsOpen = *OFF;
           // Now that the file is created, open it for processing.
           flags = O_WRONLY + O_TEXTDATA + O_CCSID;
           fd = open(%trim(scriptPath):
                           CP_WINDOWS);    // Important for CCSID to be Windows Commpliant.

Unfortunately, when I write to the file,  The text is being written as EBCDIC (CCSID = 37)  even though the file is defined with the CCSID set to 1252.

Is it possible to write ASCII text to an IFS file via RPGLE?  I found some articles about some UNIX APIs (fopen, fwrite, etc.) that sounded interesting but I couldn't find any examples of how to use them.

Any suggestions?
* RPGLEIBM System i

Avatar of undefined
Last Comment
Gary Patterson, CISSP

8/22/2022 - Mon