04-17-2007 7:56 PM
hi all,
i have a program which works fine in ECC5. in that program i have used some XML related classes and interfaces. but when i try to execute this in 4.6c version its showing lot of all errors saying that so and so class or so and so interface is not supported in 4.6c version like that.
how to overcome these errors, means how to make the classes and interfaces which work fine in ECC5 to work well in 4.6c version.
04-17-2007 8:22 PM
So here is a sample program showing how to convert an internal table into XML and downloading it to xml file.
report zrich_0001.
type-pools: truxs.
data: it001 type table of t001 with header line.
data: ixml type truxs_xml_table.
data: xxml like line of ixml.
data: size type i.
select * into table it001 from t001.
call function 'SAP_CONVERT_TO_XML_FORMAT'
importing
pe_bin_filesize = size
tables
i_tab_sap_data = it001
changing
i_tab_converted_data = ixml
exceptions
conversion_failed = 1
others = 2.
data: file_str type string.
file_str = 'C:test.xml'.
call function 'GUI_DOWNLOAD'
exporting
bin_filesize = size
filename = file_str
filetype = 'BIN'
tables
data_tab = ixml
exceptions
others = 22.
Regards,
Rich Heilman
04-17-2007 8:00 PM
04-17-2007 8:22 PM
So here is a sample program showing how to convert an internal table into XML and downloading it to xml file.
report zrich_0001.
type-pools: truxs.
data: it001 type table of t001 with header line.
data: ixml type truxs_xml_table.
data: xxml like line of ixml.
data: size type i.
select * into table it001 from t001.
call function 'SAP_CONVERT_TO_XML_FORMAT'
importing
pe_bin_filesize = size
tables
i_tab_sap_data = it001
changing
i_tab_converted_data = ixml
exceptions
conversion_failed = 1
others = 2.
data: file_str type string.
file_str = 'C:test.xml'.
call function 'GUI_DOWNLOAD'
exporting
bin_filesize = size
filename = file_str
filetype = 'BIN'
tables
data_tab = ixml
exceptions
others = 22.
Regards,
Rich Heilman
04-19-2007 2:22 PM
Hello Mr. Rich,
the coding which u provided was very helpful it almost solved my problem,but at
the the last iam stuck up with a small problem. i wrote the coding like this for my
program
tables:mara.
type-pools: truxs.
parameters: p_matnr like mara-matnr.
data: ixml type truxs_xml_table.
data: xxml like line of ixml.
data: size type i.
data: file_str type string.
file_str = 'C:\simp.xml'.
data: begin of itab_mara occurs 0,
matnr like mara-matnr,
ernam like mara-ernam,
aenam like mara-aenam,
vpsta like mara-vpsta,
end of itab_mara.
select matnr ernam aenam vpsta from mara into table itab_mara up to 5
rows where matnr = p_matnr.
CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER =
I_FILENAME =
I_APPL_KEEP = ' '
I_XML_DOC_NAME =
IMPORTING
PE_BIN_FILESIZE = size
TABLES
I_TAB_SAP_DATA = itab_mara
CHANGING
I_TAB_CONVERTED_DATA = ixml
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = size
FILENAME = file_str
FILETYPE = 'BIN'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = ixml
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
but when i try to open the XML file into which the data has to be downloaded it shows the following error.
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
-
A name was started with an invalid character. Error processing resource 'file:///C:/simp.xml'. Line 1, Position 23
<?xml version="1.0"?><%_TYPE0000000019><%_TYPE0000000019><MATNR Datatype="C" Length="18">00000000008...
help me to resolve this problem.
thanks,
anil.
04-19-2007 4:14 PM
Boy, that is a little picky. I have made changes to the way you are defining the internal table. It is really picky.
report zrich_0001 .
type-pools: truxs.
data: ixml type truxs_xml_table.
data: xxml like line of ixml.
data: size type i.
data: file_str type string.
types: begin of type_mara,
matnr type mara-matnr,
ernam type mara-ernam,
aenam type mara-aenam,
vpsta type mara-vpsta,
end of type_mara.
data: itab_mara type table of type_mara.
parameters: p_matnr like mara-matnr.
start-of-selection.
file_str = 'C:simp.xml'.
select matnr ernam aenam vpsta
from mara
into table itab_mara
up to 5 rows
where matnr = p_matnr.
call function 'SAP_CONVERT_TO_XML_FORMAT'
importing
pe_bin_filesize = size
tables
i_tab_sap_data = itab_mara
changing
i_tab_converted_data = ixml
exceptions
conversion_failed = 1
others = 2.
call function 'GUI_DOWNLOAD'
exporting
bin_filesize = size
filename = file_str
filetype = 'BIN'
tables
data_tab = ixml
exceptions
others = 22.
Works good now.
Regards,
Rich Heilman
04-19-2007 4:52 PM
Hello Mr.Rich Heilman,
Thank you very much. That coding helped me atmost to resolve my scenario.
Thank you once again.
anil.
04-19-2007 4:55 PM