troubleshooting Question

Unable to write ASCII to IFS from RPGLE program

Avatar of Drew Stephens
Drew Stephens asked on
* RPGLEIBM System i
4 Comments1 Solution141 ViewsLast Modified:
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.

//
         flags = O_CREAT + O_RDWR + O_TEXTDATA + O_TEXT_CREAT + O_CCSID
                 + 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):
                     flags:
                       mode:
                         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):
                       flags:
                         mode:
                           CP_WINDOWS);    // Important for CCSID to be Windows Commpliant.
          endif;                                                              

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?
ASKER CERTIFIED SOLUTION
Drew StephensContractor

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros