How to download XML file?

Andrew2009

Well Known Member
I have a C bsfn that will read a binary object from the database and right now I output the result as an XML string to a MOTEXT field. The problem is this field has only 30000 characters and a lot of time, the xml string is very long so it got cut off.

Here are my alternatives

1) Use a different JDE field that is big enough to contain very long XML string. Maybe I can scroll up and down and that's fine as long as it can contain the whole XML string.
2) After the C bsfn streams the XML string, I can output it as a download so when people click on a link, they can download the whole xml file. I DON'T KNOW HOW TO DO THIS

Any help or suggestion is appreciated.

Thanks
 
First, is this an E1 table with a BLOB field or is this a foreign table?
If E1, what method are you using to 'extract' the data?

If from an E1 table, you should be able to know the size of the blob field after you fetch the record. If this is the case, I would allocate the storage dynamically as opposed to using the MOTEXT field.

Without knowing what and how you are doing this, it's hard to know how to help you.
 
1. When you say you can scroll up and down, what is it you're using to do that? Do you mean that you are retrieving the XML string and passing into a JDE form to display to the user? You could experiment with DD types, a CLOB type 17 like TSTTEXT, a VARCHAR type 20 like TSTTEXT2, or BLOB type 18 like DOCBLOB (XMLDocumentBlob), but they still have defined sizes (99,999 which is max). I'm not sure how they are displayed, but I seem to remember they create a scrollable box. Otherwise, you may have to try manipulating it as a text media object on the form.
If you really need to throw 100k+ on the screen in JDE for a user to review, then you'll need to split into multiple fields/tabs/screens/etc.
2. If you can code C enough to extract the blob from a DB into an XML string, you shouldn't find it difficult to write a second function to write the string to a text file in a location specified by the user.
 
As others have stated a little more info about exactly what you are trying to do might help.

If you are trying to display the XML file somehow to the user, you may want to consider using a temporary or "work file" media object. In other words, save the XML as a media object (custom GT struct, a guid or other unique identifier as the key), return the key to the APPL (if you are using an APPL) so it can be viewed in the media object viewer. When the user is done, delete the media object record. I have done this in several places where I have variably sized text type data that I need to display to the user. In this way you are not restricted by any statically sized buffers/fields like MOTEXT since the media object can be as large as you want.

You can provide a link for users to download stuff, but the implementation of that will really vary depending on exactly what you are trying to do - there are probably numerous ways to do this. There may be a way to do this (serve up content as a download) all within the JDE toolset (especially if you have business services configured and available to you) but when I have needed to do things like this in the past - without the having JDE business services available to me - I have had to employ tools outside of the JDE toolset. Usually something like a java servlet running on an app server to serve up content from links in JDE.
 
Thanks all for your replies. Here's more info.

1) The XML is stored in a BLOB field in a custom table in JDE. I use a bssv object to retrieve the blob field and a c bsfn calls the bssv object to stream it out as a xml string
2) I use APPL right now to present the content of the XML string to users so they can copy and paste it into their own xml editor
3) JMR: what do you mean by "I would allocate the storage dynamically"

Thanks BOster for the idea of using media objec. I'll look into it.

Thanks
 
Back
Top