Reading flat file defined as DBCS

10 pts.
Tags:
AS/400 Subfiles
Data Types
DBCS
RPGLE
Hi Experts,

I have copied an xml file with chinese characters like this one

<COMPANY_NAME>上海百维生物科技有限公司</COMPANY_NAME>

into a flat file with structure below

A          R $PDER                  A            $PDEF       0600O     

upon copying the xml into the flat file using the command CPYFRMIMPF the chinese characters turned into garbage like this one

<COMPANY_NAME>ÚÚ¢XÚÚÚÚÚÚÚÚÚÚ[strong]<[/strong]¬Yñ¡ÚÚéX¢aÚÚñ²ßjÚÚ%W|¾</COMPANY_NAME>

There is an XML parser program that scans for the character '<' to determine the start and end tag (e.g. '<COMPANY_NAME></COMPANY_NAME>'). But during program execution the program scans the character '<' inside the converted chinese characters and assumed that it is the starting position of the Tag Name.

Is there a better way to read data in DBCS format? Is there another way to copy a file with chinese characters into a flat file (in DBCS) without changing the actual values? Will there be another approach given the scenario above.

All the Best,

Dennis

 

 



Software/Hardware used:
RPGLE, AS400

Answer Wiki

Thanks. We'll let you know when a new response is added.

There is an XML parser called EXPAT, which has been ported to the AS/400 (or whatever it is called this week) by Scott Klemens. You can find it here:

<a href=”http://www.scottklement.com/expat/”>http://www.scottklement.com/expat/</a>

I have some sample code showing how to use the parser to bring XML directly from the stream file into my database. (I am at john.blenkinsop@ne.nykline.com)

If your parser can’t work with data in UTF-8 or UTF-16 encodings, then you should try a different parser. But I suspect that it probably can, if it is a reputable one. There should be no need to copy the XML into a ‘native DDS-based’ file in order to process it.

Sloopy

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    No answer from me, just comments from personal opinion. I would only suggest not trying to put XML into a flat database file in the first place. I'd only ever have it stored in the streamfile that it's intended to be in. That would be especially true if the data was ever going to be used on any other system, e.g., by a browser or other function on a PC or by a partner system. (If it was always totally generated and consumed on the single system so that I always had full control of the environment and programming, I might use a physical file for limited purposes.) The effort involved in making the extra steps work for a physical file are usually more than the effort to learn to do it in the natural way. Tom
    125,585 pointsBadges:
    report
  • Itsdineshm
    Hi, Can any one give me sample program which converts double byte XML data to COBOL. Do we need to declare the DBCS field in XML pharser as PIC G ? Pls advice.
    10 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following