Generate XML File?

alfredorz

alfredorz

Well Known Member
Hi guys,

I'm starting a new project and I need generate a XML file. I search BSFN's and I found B34A1190 and B0501250, and a report R03B672 use B34A1190. I'm going to study this report and this functions for understand XML functionality.

Can you advise me how I could generate xml file?

Thanks!
Alfre.
 
I've never bothered with them, only for SEPA changes years ago.

I just create the file myself using concats (just like you would a text file) and keeping a track of the element nodes etc. <start> </end> yourself

Example
<On_Payment_Terms_S3>
Then fill in what you need <DateInvoiceJulian_ID9>Invoice Date</DateInvoiceJulian_ID9> etc

Then close with
</On_Payment_Terms_S3>

All those BSFNS do is help you do that
Start your file with this <?xml version="1.0" encoding="UTF-8" standalone="no" ?> and you should be ok to create the file just like a
 
When I query the Object Librarian I find 111 BSFNs with 'XML' in its description.
That's way too many for me to go through (read source, guess what it really does, experiment, etc). The few I looked at seemed to require way too much effort on the programmer's part.

I prefer to use more powerful non-JDE tools for tasks like this. For instance I have to export Item Data (Item #, Description, cost, etc) on a weekly basis as a XML file to be imported into another application. Turns out PL SQL (Oracle's version of SQL) has some nice functions to do this so I don't have to do the drudgery of composing XML myself. Works great and I didn't have to touch JDE. Microsoft has lots of stuff for generating XML also.

The old saying "... it is tempting, if the only tool you have is a hammer, to treat everything as if it were a nail." is still true. Look for the right tool for the job rather than trying to hammer everything with JDE.

Just my opinion.
 
Just to add to what Larry is saying. Be careful trying to roll your own process to output XML. Its not as simple as just some tags with data in between. You have to adhere to the XML Specificaion or you can produce malformed XML. For example, if the source data contains certain characters, etc. you have to make sure they are properly escaped. Much better to find a library/tool that all ready has this all figured out.

If you really need to do this all withing the JDE toolset, I believe JDE has wrapped some XML libraries - I remember using one for parsing at one point (SAX parser I think), they probably have some for outputting as well - or you could bring in some other third party dll. For something like this I have also wondered if it might not be better to do this in a BSSV that is consumed internally. Then you could make use of any one of a number of Java based libraries to produce XML formatted data.
 
Hi,

We use B34A1190 in several solutions and it works well. It employs the Xerces wrapper APIs providing the ability to create elements and attributes. The hierarchy is created by passing the parent element into each call.

Craig
 
Thanks johndante, you are right, finally a XML is a flat file, but working with xml is more easier because you can add tags in differents levels in the tree (for example, you can add tag in a break footer to a opened tags in the header break), and flat files you're adding consecutively.

Thanks Larry_Jones and BOster, I am agree probably it will more easier in other technology, for example java. In other projects I did difficult things with java class in a internal business services, for example BIDI codebar, but this customer is not installed BSSV and also this report has to read a lot of tables.

Thanks craig_welton, finally I'm doing with this BSFN, works very fine but it's very laborious because the XML is huge. But I continue working hard ;)

Regards,
Alfre.
 
Other option could be do it with BI Publisher XSL Template (as SEPA for example). Someone has done it? How it is? Could you send me any reference?

Thanks.

Regards,
Alfre.
 
Hi guys, I have a big big problem with B34A1140 BSFN. The structure generate is fine, but in the header enconding in UTF-16, I need in UTF-8 but I think this shouldn't a problem, the problem is the file is not generated in UTF-8 (neither in UTF-16) because when I open with notepad++ for example the codification is "UCS-2 Big Endian".

I configured P93081 for my report and user in all enviroments to UTF-8 but is not generate.

I open the BSFN but I not found codification in the API's.

Can you help me please? It's very urgent.

Regards.
 
Try using B4303900.WriteXMLDocumentToFile. That uses the XRCS_serializeDocumentToFileWithEncoding API passing UTF_8.

Craig
 
Thanks craig!!!

Finally I created a new bsfn with the same parameters and code than B34A1190 - Write To File and add xmlcStatus = XRCS_serializeDocumentToFileWithEncoding(hDoc, dsDSI74XML01FILE.szXMLFullFileName,_J("UTF-8")); as B74XML01.

Your solution is better but i didn't see before :(

Regards,
Alfre.
 
Hi All, I am trying to use B34A1190 by copying and changing the encoding to UTF-8 as suggested in the above solution. Everything works fine - its adding the tags(elements), attributes perfectly and generating the XML except that its replacing the colon in the tag name by an underscore and its all through the API For e.g.


<cbc:UBEVersionID>1.0</cbc:UBEVersionID> is being written as <cbc_VersionID>1.0</cbc:UBEversionID>


Now since colon is a special character to an XML, with UTF- encoding it should be written in a different way as I read about it. So while writing the element name as a parameter i tried using


ElementName as 'cbc&58#;UBEVersionID' but still doesnt work. Doed anyone has a clue, how can we insert that colon in teh tag name and not getting it replaced it with an underscore. Any help is appreciated.
 
Hi All, I am trying to use B34A1190 by copying and changing the encoding to UTF-8 as suggested in the above solution. Everything works fine - its adding the tags(elements), attributes perfectly and generating the XML except that its replacing the colon in the tag name by an underscore and its all through the API For e.g.


<cbc:UBEVersionID>1.0</cbc:UBEVersionID> is being written as <cbc_VersionID>1.0</cbc:UBEversionID>


Now since colon is a special character to an XML, with UTF- encoding it should be written in a different way as I read about it. So while writing the element name as a parameter i tried using


ElementName as 'cbc&58#;UBEVersionID' but still doesnt work. Doed anyone has a clue, how can we insert that colon in teh tag name and not getting it replaced it with an underscore. Any help is appreciated.

Hi chawla.sheetal,

I didn't use special characters so I don't know. But you should have care because B34A1190 generate xml in UTF-16 and not in UTF-8, you can see it in xml header. Can you try to generate XML File with B4303900 - WriteXMLDocumentToFile? This BSFN generate XML in UTF-8, and it's posible that generate doble dot.

Tell me if this solution works or not, please.

Regards.
 
Try using B4303900.WriteXMLDocumentToFile. That uses the XRCS_serializeDocumentToFileWithEncoding API passing UTF_8.

Craig

Hi Craig,

I'm currently using B74XML01 which is indeed using XRCS_serializeDocumentToFileWithEncoding API, but I noticed the output XML file does not have any CR-LF.

In other words: opening the XML file with Notepad++ I can see just 1 line, even though all validations seems correct (I'm talking about XSD validation).

If I open XML file with XML Notepad and I save it I'm gonna get what I need, thus CR-LF to separation.

Can you help me on that ?

Thanks,

Carlo
 
You could use Microsoft XML Notepad 2007, to view and edit an XML file easily.

From the site

XML Notepad 2007 provides a simple intuitive user interface for browsing and editing XML documents.

Edit: I didn't see that you are already being using XML Notepad, please discard this reply ;)
 
Last edited:
Carlo,

That happens when the file is created on a unix box and viewed on a windows box. We use a simple unix script to convert files from unix to windows.

Unix only uses CR (I think - in any case it's only one value) and windows uses the CR and LF combination.
 
Carlo,

That happens when the file is created on a unix box and viewed on a windows box. We use a simple unix script to convert files from unix to windows.

Unix only uses CR (I think - in any case it's only one value) and windows uses the CR and LF combination.

Thank you Peter,

yes I know Unix behave differently but here I'm not running JDE within a Unix server.

It seems to me the difference is between XRCS APIs and embedded BI-Publisher:
with the first one no CR&LF at all.

In order to add CR&LF I found the following tricks:

1. Use XML Notepad (open and save the file).
2. Use Notepad++ (XML Tool plugin and function "Pretty Print with line breaks").
3. Use XSL transformation with proper command.

Kind regards,

Carlo
 
Hello,

You can use B0000201 BSFN to write the xml file.


Hi,
I am using
Add XML Element String Xerces Wrapper
Source Module : B0000201
Member Description : Add XML Element String Xerces Wrapper
It maximum length is 256 characters.
I need to pass more than that, how could i mange?
help me
 
One option is you can create you own C BSFN to generate the XML document. As the BSFN you referenced indicates, JDE has JDE specific C APIs for generating and parsing XML documents that are really just thin wrappers around the Xerces XML APIs (the underlying implementation may actually be from IBM I think). Regardless, when using the JDE C API wrappers you can pretty much use the documentation from http://xerces.apache.org/.
 
Back
Top