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

Header in GUI_UPLOAD

Former Member
0 Likes
2,183

Hi everyone,

I am trying to read XML file with function module GUI_UPLOAD.

There are some Parameters about Header that I can't understand.

e.g.[IMPORTING] header_length TYPE I

    [EXPORTING] header TYPE XSTRING

A XML file have element, node, attribute. How should I the Header understand.

thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,250

HI Liang,

Instead of gui_upload fm  use IMPORT_FROM_FILE method of CL_XML_DOCUMENT to upload XML document.


DATA: gcl_xml TYPE REF TO cl_xml_document.

DATA: gv_subrc TYPE sy-subrc.



START-OF-SELECTION.

  CREATE OBJECT gcl_xml.

*Upload XML File
  CALL METHOD gcl_xml->import_from_file
  EXPORTING

  filename = 'c:\test.xml'

  RECEIVING

  retcode = gv_subrc.

  IF gv_subrc = 0.

*Display XML

  CALL METHOD gcl_xml->display.

  ENDIF.




Regards,

Vineesh B.

6 REPLIES 6
Read only

Former Member
0 Likes
1,250

Hi,

can you please refer this one

GUI_UPLOAD - SAP Documentation

Thanks,

Ashok.

Read only

0 Likes
1,250

I have read the document, Unfortunately, it is only a simple explanation without example code.

Thank you for your kind reply,

Read only

Former Member
0 Likes
1,250

Hi Yinxiao,

Import parameter HEADER_LENGTH and export parameter HEADER is applicable only when you are reading Binaries (Binary File)  . That is file type BIN and file data will be hexadecimal. The binary files some times have header section, to read this information you need above two parameter

Example -If you mention file type as BIN and HEADER_LENGTH as 30 then FM return first 30 chars of file into HEADER  as header details(hexadecimal values).

This is nothing do with xml file and these 2 parameters are optional

Thanks & Regards,

Arun

Read only

0 Likes
1,250

Hi Aruna,

thank you for kind reply, I have some questions about the Binay and ASCII in GUI_UPLOAD.

my code is as follows.

1. get the XML files from my PC. The structure of intern table lt_itab is file_table type char64. 

1. I use this static method to get the content from the XML file. lv_path is the name of the file. at first I used the filetype as 'ASC' and the structure type of table lt_data_tab is char256.

But an error came up: I/O error: source exhaused and EOF!

Then I replace the filetype with 'BIN' and change the structure type as x length 256. After that I get the correct result.

CALL METHOD cl_gui_frontend_services=>gui_upload

  EXPORTING

    filename               = lv_path

    filetype                 = 'BIN'

  IMPORTING

      filelength            = lv_table_length 

  CHANGING

      data_tab            = lt_data_tab

Could you tell me what I do wrong and why?

thanks again.

Yinxiao

Read only

Former Member
0 Likes
1,251

HI Liang,

Instead of gui_upload fm  use IMPORT_FROM_FILE method of CL_XML_DOCUMENT to upload XML document.


DATA: gcl_xml TYPE REF TO cl_xml_document.

DATA: gv_subrc TYPE sy-subrc.



START-OF-SELECTION.

  CREATE OBJECT gcl_xml.

*Upload XML File
  CALL METHOD gcl_xml->import_from_file
  EXPORTING

  filename = 'c:\test.xml'

  RECEIVING

  retcode = gv_subrc.

  IF gv_subrc = 0.

*Display XML

  CALL METHOD gcl_xml->display.

  ENDIF.




Regards,

Vineesh B.

Read only

0 Likes
1,250

hi vineesh,

thanks for ur kind replay. It's a very good way to display the xml file. I just read the document about cl_xml_document, and I don't find a method to create a Parser, which can generates a DOM, so that I can travel the DOM Tree.

I use the gui_upload fm to generate a input Stream to create Parser,

data: parser type ref to if_ixml_parser.

parser = g_ixml->create_parser(  stream_factory = streamFactory

                                                   istream             = iStream

                                                   document         = document ).


Thanks again for sharing.

Yinxiao