‎2006 Jun 26 4:32 PM
‎2006 Jun 26 5:05 PM
‎2006 Jun 26 5:07 PM
‎2006 Jun 27 10:37 AM
Hi,
I am using SAP4.7 version.
I am having a XML file on my desk top.
So i have to upload data from that XML file to a Z-table in SAP.
Can ny body tell me the procedure clearly..
i have seen some posts..But it is little confusing..
Thanks in Advance.
‎2006 Jun 27 10:40 AM
Hi ravi,
1. itab --- > xml
xml ---> itab.
*----
<b>a) after uploading xml file into your internal table,
just use this logic
LOOP AT ITAB.
MODIFY ZTABLE FROM ITAB.
ENDLOOP
(this modify statement will AUTOMATICALLY take care
of insert/update based upon the primary key combination,
if found/not found in ztable)</b>
2. This program will do both.
(just copy paste in new program)
3.
REPORT abc.
*----
DATA
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
DATA : BEGIN OF itab OCCURS 0,
a(100) TYPE c,
END OF itab.
DATA: xml_out TYPE string .
DATA : BEGIN OF upl OCCURS 0,
f(255) TYPE c,
END OF upl.
DATA: xmlupl TYPE string .
FIRST PHASE
FIRST PHASE
FIRST PHASE
*----
Fetch Data
SELECT * FROM t001 INTO TABLE t001.
*----
XML
CALL TRANSFORMATION ('ID')
SOURCE tab = t001[]
RESULT XML xml_out.
*----
Convert to TABLE
CALL FUNCTION 'HR_EFI_CONVERT_STRING_TO_TABLE'
EXPORTING
i_string = xml_out
i_tabline_length = 100
TABLES
et_table = itab.
*----
Download
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filetype = 'BIN'
filename = 'd:\xx.xml'
TABLES
data_tab = itab.
SECOND PHASE
SECOND PHASE
SECOND PHASE
BREAK-POINT.
REFRESH t001.
CLEAR t001.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:\XX.XML'
filetype = 'BIN'
TABLES
data_tab = upl.
LOOP AT upl.
CONCATENATE xmlupl upl-f INTO xmlupl.
ENDLOOP.
*----
XML
CALL TRANSFORMATION ('ID')
SOURCE XML xmlupl
RESULT tab = t001[]
.
BREAK-POINT.
regards,
amit m.
‎2006 Jun 27 11:31 AM
Hi Amit,
Thanks for the response.
But if it is CRM system can you tell me how to do it?
Becoz..the FM HR_EFI_CONVERT_STRING_TO_TABLE does not exist in CRM.
‎2006 Jun 27 11:33 AM
Hi again,
1. CONVERT_STRING_TO_TABLE
U can use this FM also.
regards,
amit m.
‎2006 Jun 27 11:36 AM
Evn the fm CONVERT_STRING_TO_TABLE does not exist in CRM.
also the FM 'HR_EFI_CONVERT_STRING_TO_TABLE' does not exist in SAP 4.7...
‎2006 Jun 27 11:37 AM
Hi again,
1. we can use this also.
SCMS_STRING_TO_FTEXT
(this FM will be available )
regards,
amit m.
‎2006 Jun 27 12:56 PM
<i>So i have to upload data from that XML file to a Z-table in SAP.</i>
is it the XML file itself into Ztable or you have to parse the XML file and update the Ztable fields with the value from the xml?
here is the complete code sample for uploading/parsing xml file.
report y_xml_upload
no standard page heading.
data: filename type string ,
xmldata type xstring .
data: result_xml type standard table of smum_xmltb .
data: return type standard table of bapiret2 .
constants: line_size type i value 255.
data: begin of xml_tab occurs 0,
raw(line_size) type x,
end of xml_tab,
file type string,
size type i.
* upload the xml file
filename = 'C:rajabw.xml' .
call function 'GUI_UPLOAD'
exporting
filename = filename
filetype = 'BIN'
has_field_separator = ' '
header_length = 0
importing
filelength = size
tables
data_tab = xml_tab
exceptions
others = 1.
************uncomment this and comment the call of SCMS_BINARY_TO_XSTRING if you dont have this fm in your system.
* if sy-subrc <> 0.
* clear: xmldata.
* exit.
* else.
* data: len type i.
* len = size.
* loop at xml_tab.
* if len <= line_size. exit. endif.
* concatenate xmldata xml_tab-raw(line_size)
* into xmldata in byte mode.
* len = len - line_size.
* endloop.
* if len > 0.
* concatenate xmldata xml_tab-raw(len)
* into xmldata in byte mode.
* len = len - size.
* endif.
* endif.
******* end of comment.
call function 'SCMS_BINARY_TO_XSTRING'
exporting
input_length = size
* FIRST_LINE = 0
* LAST_LINE = 0
importing
buffer = xmldata
tables
binary_tab = xml_tab
exceptions
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 'SMUM_XML_PARSE'
exporting
xml_input = xmldata
tables
xml_table = result_xml
return = return .Regards
Raja
‎2007 Oct 29 3:56 AM
hi Ravi,
you can use SMUM_XML_TAB function module also
regards,
Pavan
‎2006 Jun 26 5:11 PM
‎2006 Jun 26 5:56 PM
HI Ravi,
Check this link.
/people/sap.user72/blog/2006/01/19/upload-data-from-multiple-worksheets-within-a-single-excel-file-into-internal-table-from-abap
Regards,
Laxmi.
‎2006 Jun 27 11:36 AM
Hi again,
1. we can use this also.
SCMS_STRING_TO_FTEXT
(this FM will be available )
regards,
amit m.
‎2007 Nov 14 9:16 PM
Upload XML file with "GUI_UPLOAD" function.
Then you need to convert to SAP parser like this fragment of code
DATA: ixml TYPE REF TO if_ixml,
out type ref to if_ixml_document,
str TYPE string.
CLASS cl_ixml DEFINITION LOAD.
*-- create the main factory
ixml = cl_ixml=>create( ).
DATA: streamfactory TYPE REF TO if_ixml_stream_factory,
istream TYPE REF TO if_ixml_istream,
parser TYPE REF TO if_ixml_parser.
out_xml = ixml->create_document( ).
streamfactory = ixml->create_stream_factory( ).
istream = streamfactory->create_istream_string( str ).
parser = ixml->create_parser( stream_factory = streamfactory
istream = istream
document = out_xml ).
IF parser->parse( ) <> 0.
RAISE parse_error.
ENDIF.
At last you operate with this