|
I have a program running for years using writeline, writing an xml
file, and within 1.4 million writes, a single instance of a single
quote (ebcdic hex 7D) did not translate to ascii correctly. I've used
this process for years in writing edi files without having this
issue. This is V7R1. We send this file every day, always building a
new uniquely named file.
This worked (wrklnk display, ascii hex and) the single quote in
ascii is 27
454D504C 4F594545 275320 EMPLOYEE'S
this is ebcdic from file
C5D4D7D3 D6E8C5C5 7DE240C1 D9D440 EMPLOYEE'S ARM
from same file, same column of data
This did not and single quote is now ascii 1A (which blew the
trading partner's process..)
20534149 44205348 45204449 444E1A54 * SAID SHE DIDN T
20464545 * FEE
callp close(fd)
this is the ebcdic where single quote is 7D
40E2C1C9 C440E2C8 C540C4C9 C4D57DE3 * SAID SHE DIDN'T
40C6C5C5 D340E6C5 * FEEL WE
text file is CCSID 819
This writes the one record (it's based on an old set of code, but it
has always worked)
eval @vdata = %trim(CLCMLN)
exsr $valid
eval @dtext=indent2+'<IncidentDesc>' +
%trim(@vdata) +
'</IncidentDesc>'
eval @len = %len(%trimr(@dtext))
callp writeline(fd: %addr(@dtext):@len)
DSPFFD of column
Field Type Length Length Position Usage Heading
CLCMLN CHAR 150 150 324 Both CAUSE xxx
Field text . . . . . . . . . . . . : CAUSE OF INJURY
Referenced information
Referenced file . . . . . . . . . : SREF
Library . . . . . . . . . . . . : MMOD
Referenced record format . . . . : CSREF
Referenced field . . . . . . . . : CMLN
Attributes changed . . . . . . . : Other
Coded Character Set Identifier . . : 37
Text File create
Create a new file, and assign it a code page of 819:
Create this file with "all" permissions *RWX per BTS requirements
eval fd = open(%trim(filename):
O_CREAT+O_WRONLY+O_CODEPAGE:
S_IRWXO+S_IRWXU+S_IRWXG:
819)
if fd< 0
callp die('open(): ' + %str(strerror(errno)))
eval @errflag='Y'
endif
Now re-open the file in text mode. Since it was assigned a
code page of 819, and we're opening it in text mode, OS/400
will automatically translate to/from ASCII for us.
eval fd = open(%trim(filename):
O_WRONLY+O_TEXTDATA)
Have I missed something obvious?
As an Amazon Associate we earn from qualifying purchases.
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.