IFS Write fails when using codepage 1208

Discussions relating to writing software in ILE RPG (RPG IV). This includes both fixed and free format RPG.
Post Reply
msddcb
Posts: 32
Joined: Wed Jul 28, 2021 5:12 am

IFS Write fails when using codepage 1208

Post by msddcb »

I have a requirement to create a file in the IFS with ccsid 1208 and the data in 1208.
The reason is I am using a php process file_get_contents that requires the data in 1208.
The following test program should compile easily.
When it runs if fails on the write with the error CPF9897 open(): Conversion error.
If I change the ccsid to 819 it runs fine.
Is it possible to create a file in the IFS with the date in codepage 1208 ?

Code: Select all

H  DatFmt(*ISO)                                                                  
H  Option(*SrcStmt)                                                              
H  ExprOpts(*ResDecPos)                                                          
H  FltDiv(*Yes)                                                                  
H  DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('QC2LE') BNDDIR('IFSTEXT')                 
 * -----------------------------------------------------------------*            
 * -----------------------------------------------------------------*            
                                                                                 
 *****************************************************************  *            
 * DEFINE FILES TO USE                                              *            
 *****************************************************************  *            
                                                                                 
D fd              S             10I 0                                            
D line            S            100A                                              
D len             S             10I 0                                            
D msg             S             52A                                              
D err             S             10I 0                                            
                                                                                 
D/SPACE 3                                                                        
 // =====================================================================//      
 // Program status Data Structure                                                
 // SDSPGM - Program name                                                        
 // SDSPSD - Program status code when error occurred                             
  // SDSRTN - RPG Routine where error occurred                                  
 // SDSWS  - Workstation ID                                                    
 // SDSUSR - User Profile                                                      
 //=====================================================================//     
D SDS            SDS           429                                             
D  SDSPGM           *PROC                                                      
D  SDSPSD           *STATUS                                                    
D  SDSRTN           *ROUTINE                                                   
D  SDSPRM           *PARMS                                                     
D  SDSWS                244    253                                             
D  SDSUSR               254    263                                             
                                                                               
 /include IFSEBOOK/QRPGLESRC,IFSIO_H                                           
 /include IFSEBOOK/QRPGLESRC,ERRNO_H                                           
 /include IFSEBOOK/QRPGLESRC,IFSTEXT_H                                         
                                                                               
c                   eval      *inlr = *on                                      
C* Make sure we don't have an old file that might be in the way                
C* (ENOENT means it didnt exist to begin with)                                 
c                   if        unlink('/home/test1202.txt') < 0                 
c                   eval      err = errno                                      
c                   if        err <> ENOENT                                    
c                   callp     die('unlink(): ' + %str(strerror(err)))          
c                   endif                                                         
c                   endif                                                         
C* Create a new file, and assign it a code page of 1208:                          
c                   eval      fd = open('/home/test1208.txt':                     
c                                  O_CREAT+O_WRONLY+O_CODEPAGE:                   
c                                  S_IWUSR+S_IRUSR+S_IRGRP+S_IROTH:               
c                                  1208)                                          
c                   if        fd < 0                                              
c                   callp     die('open(): ' + %str(strerror(errno)))             
c                   endif                                                         
c                   callp     close(fd)                                           
C* Now re-open the file in text mode.  Since it was assigned a                    
C* code page of 819, and we're opening it in text mode, OS/400                    
C* will automatically translate to/from ASCII for us.                             
c                   eval      fd = open('/home/test1208.txt':                     
c                                  O_WRONLY+O_TEXTDATA        )                   
c                   if        fd < 0                                              
c                   callp     die('open(): ' + %str(strerror(errno)))             
c                   endif                                                         
                                                                                  
c                   eval      line = '<html>  </hml>'                             
c                   eval      len = %len(%trimr(line))                            
c                   callp     writeline(fd: %addr(line): len)                     
c                   callp     close(fd)                             
C*------------------------                                          
                                                                    
 /DEFINE ERRNO_LOAD_PROCEDURE                                       
 /COPY IFSEBOOK/QRPGLESRC,ERRNO_H                                   
Thanks
Don
Post Reply