Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Parsing XML files from application server

Former Member
0 Likes
801

I need to read an XML file from the application server. This can be done using OPEN DATASET in BINARY MODE and reading into internal table of type binary data.

But inorder to parse the document using the iXML library, i need to pass the filesize of the XML file that is read into internal table.

Please let me know how to calculate this filesize ?

3 REPLIES 3
Read only

Ramneek
Product and Topic Expert
Product and Topic Expert
0 Likes
687

I suppose you could use the standard function module GUI_UPLOAD. This would give you the contents of the file in an internal table and also the size of the file. You could use this to create the istream to parse the xml document.

Hope this helps.

Ramneek

Read only

Former Member
0 Likes
687

I think i have mentioned clearly above that i am reading from the Application server and not from the presentation server.

You cannot use GUI_UPLOAD for that my dear friend.

Read only

huseyindereli
Active Contributor
0 Likes
687

Hi ,

Check the FM : /SAPDMC/LSM_F4_SERVER_FILE.

Inside this FM , subroutine below exists.The main program for routine is /SAPDMC/LLSMW_AUX_020F02.

Call this routine from your program. You will get the length in bytes from the field len of table pt_file.

data:
  begin of gs_file,
    directory(75) type c,              " name of directory.
                                       " (possibly truncated.)
    name(75)    type c,                " name of entry.
                                       " (possibly truncated.)
    type(10)    type c,                " type of entry: directory, file
    *len(8)      type p,                " length in bytes*
    owner(8)    type c,                " owner of the entry
    mtime(6)    type p,                " last modification date,
                                       " seconds since 1970
    mode(9)     type c,                " like "rwx-r-x--x":
                                       " protection mode
    errno(3)    type c,
    errmsg(40)  type c,
    mod_date    type d,
    mod_time(8) type c,                " hh:mm:ss
    subrc like sy-subrc,
end of gs_file.

DATA : pt_file LIKE TABLE OF gs_file.

DATa : p_ok.


  PERFORM /sapdmc/llsmw_aux_020f02(directory_contents_get)
  TABLES   pt_file
                            USING    '/TMP' ""!!! Here is your filepath
                                     '*'
                            CHANGING p_ok