Xml To itab
Hi ,
i'm trying extract data from PDF file. (Adobe Offline scenario).
I'm getting this XML runtime error.
could anybody can help me to solve this problem.
This is my code ,
CALL TRANSFORMATION id
SOURCE XML lv_xml_data_string
RESULT zscustomer12 = wa_zcustomer12.
Here is the error
The reason for the exception is:
Either the source document contains invalid XML or it is handled
incorrectly in the ABAP program that called the transformation.
How to correct the error
The most common cause of this error is a conflict between the encoding
specified in the declaration <?xml version="1.0" encoding="..."?> in the
document and the actual encoding of the data.
If the document is held in an ABAP string, the actual encoding is the
system code page. If this does not match the declaration, a parsing
error may occur.
These conflicts are a particular issue when XML documents are produced
in one system and then imported into a system with a different code page
(as strings).
For this reason, XML documents should be held as binary data (X strings)
, if they are extracted from the system or accessed from outside.
If the error occures in a non-modified SAP program, you may be able to
find an interim solution in an SAP Note.
If you have access to SAP Notes, carry out a search with the following
keywords:
"XSLT_BAD_SOURCE_CONTEXT" "CX_XSLT_RUNTIME_ERROR"
"ZFORM_12_RECEIVEPDF" or "ZFORM_12_RECEIVEPDF"
"START-OF-SELECTION"
please help me out.
Regards,
Keerthi
code:
TYPES: BEGIN OF T_ATTACHMENT,
LINE_NO(5),
FILENAME(200),
DESCRIPTION TYPE STRING,
END OF T_ATTACHMENT,
D_ATTACHMENT TYPE T_ATTACHMENT OCCURS 0.
TYPES: BEGIN OF T_ATTACHMENTLIST,
ATTACHMENT TYPE D_ATTACHMENT,
END OF T_ATTACHMENTLIST,
D_ATTACHMENTLIST TYPE T_ATTACHMENTLIST OCCURS 0.
TYPES: BEGIN OF T_HEADER,
NAME(140),
PHONE(23),
EMAIL(100),
ATTACHMENTLIST TYPE D_ATTACHMENTLIST,
END OF T_HEADER,
D_HEADER TYPE T_HEADER OCCURS 0.
TYPES: BEGIN OF T_ITEM,
HEADER TYPE D_HEADER,
END OF T_ITEM.
TYPES:D_ITEM TYPE T_ITEM OCCURS 0.
TYPES: BEGIN OF T_LIST,
ITEM TYPE D_ITEM,
END OF T_LIST,
D_LIST TYPE T_LIST OCCURS 0.
TYPES: BEGIN OF TYPE_DATA,
LIST TYPE D_LIST,
END OF TYPE_DATA.
DATA: ITEMLIST TYPE STANDARD TABLE OF T_LIST INITIAL SIZE 0.
DATA: XMLOUT TYPE STRING.
DATA: ITAB LIKE SOLI OCCURS 0 WITH HEADER LINE.
PERFORM UPLOAD_XML.
*& Form UPLOAD_XML
text
--> p1 text
<-- p2 text
FORM UPLOAD_XML .
REFRESH ITAB.
clear ITEMLIST.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\test11.XML'
filetype = 'BIN'
TABLES
data_tab = ITAB.
LOOP AT ITAB.
CONCATENATE XMLOUT ITAB-LINE INTO XMLOUT.
ENDLOOP.
CALL TRANSFORMATION ('ZTEST11X2A')
SOURCE XML XMLOUT
RESULT ITEMLIST = ITEMLIST.
BREAK-POINT.
ENDFORM.[/code]
Regards
Venkat
Similar Messages
-
Problem in XML to ITAB conversion - Application server files
Hi Friends
Earlier we used FTP concept, so I received XML file and length frpm FTP function modules, but now instead of FTP I am going to use the following function modules
SCMS_BINARY_TO_XSTRING
SMUM_XML_PARSE
for that I need to pass the lenght of the file.But I dont know how to calculate the file length while receiving the files using Open Dateset concept.
Kindly provide your inputs.
Thanks
GowrishankarCould you please tell us how you solve it?
Greetings,
Blag. -
Hi guys,
Before you guys go omg why didnt I search well I did. Hear me out.
I have a XML format which looks like this
<?xml version="1.0"?>
<SndPmtResp>
<Tranx Id=u201D0000000001u201D type= u201CVPu201D status=u201D1u201D/>
</SndPmtResp
I did a quick test program based on previous work:
REPORT ztest_ac_xml.
TYPE-POOLS: abap.
DATA: lt_xml_tab TYPE STANDARD TABLE OF smum_xmltb,
lw_xml_tab LIKE LINE OF lt_xml_tab,
lt_return TYPE STANDARD TABLE OF bapiret2.
DATA: lt_result_xml TYPE abap_trans_resbind_tab,
lw_result_xml TYPE abap_trans_resbind.
DATA: it_tab TYPE zstruct_sendfrombank_tt.
DATA: gs_rif_ex TYPE REF TO cx_root,
gs_var_text TYPE string.
* Table for the XML content
DATA: gt_itab TYPE STANDARD TABLE OF char2048.
CONSTANTS gs_file TYPE string VALUE 'C:\temp\testing.xml'.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = gs_file
CHANGING
data_tab = gt_itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19.
GET REFERENCE OF it_tab INTO lw_result_xml-value.
lw_result_xml-name = 'ITEST'.
APPEND lw_result_xml TO lt_result_xml.
TRY.
CALL TRANSFORMATION z_tab
SOURCE XML gt_itab
RESULT (lt_result_xml).
CATCH cx_root INTO gs_rif_ex.
gs_var_text = gs_rif_ex->get_text( ).
MESSAGE gs_var_text TYPE 'E'.
ENDTRY.
The program will work only if the XML is
<?xml version="1.0" encoding="iso-8859-1" ?>
<SNDPMTRESP>
<TRANX_ID>0000000001</TRANX_ID>
<TYPE>VP</TYPE>
<STATUS>12</STATUS>
</SNDPMTRESP>
The XML format is weird.....Any ideas on how to get the data from
<Tranx Id=u201D0000000001u201D type= u201CVPu201D status=u201D1u201D/>
Thanks alotHowdy,
Not sure it's exactly what you want but you should be able to tweak it from here.
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/SndPmtResp">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ITEST>
<xsl:for-each select="//Tranx">
<xsl:call-template name="Tranx"/>
</xsl:for-each>
</ITEST>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template name="Tranx">
<item>
<ZTXNID>
<xsl:value-of select="@ID"/>
</ZTXNID>
<ZPYTYPE>
<xsl:value-of select="@TYPE"/>
</ZPYTYPE>
<ZREPSTS>
<xsl:value-of select="@STATUS"/>
</ZREPSTS>
</item>
</xsl:template>
</xsl:transform>
Cheers
Alex -
Upload XML file from server to itab
After failed to get a answer about download data from xml file in server to my itab, and searching and searching in hundred of post and threads i try my own solution for this issue.
I read the file with:
OPEN DATASET FICHERO FOR INPUT IN TEXT MODE ENCODING DEFAULT.
In this case the result is a table filled with register type string like this:
#<label>22222</label>
I need a table with this kind of value (example):
label | 22222
label2 | John
label3 | Smith
Therefore i have to parse the data of my table, i try with the FM:
TEXT_CONVERT_XML_TO_SAP
But dont works for me,
I am too new in ABAP.
The code for my report is very simple:
REPORT ZPRUEBA_XML.
DATA: BEGIN OF TABLA OCCURS 1,
TEXTO(256) TYPE C,
END OF TABLA.
DATA: FICHERO LIKE RLGRAP-FILENAME.
OPEN DATASET FICHERO FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC NE 0.
WRITE:/ 'ERROR'.
ENDIF.
FREE TABLA.
DO.
READ DATASET FICHERO INTO TABLA.
IF SY-SUBRC NE 0.
EXIT.
ELSE.
APPEND TABLA.
WRITE: TABLA-TEXTO.
ENDIF.
ENDDO.
CLOSE DATASET FICHERO.
And my ".xml" in the server is very simple too.
<label>222222</label>
<name>John</name>
<street>Smith, 23, NY</street>
Anyone can help me?
ThanksHi,
You could use a transformation to do that, or call FM 'TEXT_CONVERT_XML_TO_SAP'... you also have the class IF_IXML that should help you and a lot of threads on the subject, such as:
convert XML data into ABAP internal table
ABAP Class to convert XML to itab
Upload XML to internal table and vice versa in SAP 4.6C
http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e66701fc-0d01-0010-9c9a-f8a36c4e87ba
Kr,
Manu. -
How to fetch data from XML and store it in internal table
Hi All,
Can anyone help me out, in fetching data from xml and store it in an internal table. Is there any standard function module is there?
Regards,
Karthickto do this you can either develop a XSLT program and use it with CALL TRNSFORMATION key word to tranform the XML into itab .
(search the ABAP General forum, i have posted few samples)
or simply use the following FM which converts your XML into a itab of name value pair (name would holw the element name and value would hold the value of the element) which you can then loop and read it to your itb.
data: xmldata type xstring .
data: result_xml type standard table of smum_xmltb .
data: return type standard table of bapiret2 .
CALL FUNCTION 'SMUM_XML_PARSE'
EXPORTING
xml_input = xmldata
TABLES
xml_table = result_xml
return = return .
Regards
Raja -
Hi All,
I have a requirement to convert XML to itab to be processed further.
I couldn't parse the XML which contains ns0 (namespace?) as following:
<ns0:OrderNo>887140</ns0:OrderNo>
<ns0:CPROD>BD</ns0:CPROD>
<ns0:CURR>USD</ns0:CURR>
I'm able to parse If I remove the namespace ns0 from the file as following:
<OrderNo>887140</OrderNo>
<CPROD>BD</CPROD>
<CURR>USD</CURR>
The thing is the XML file will always come with the namespace ns0.
I'm using IF_IXML, IF_IXML_STREAM_FACTORY, IF_IXML_ISTREAM, IF_IXML_PARSER, IF_IXML_DOCUMENT to parse the XML.
Any idea on how to overcome this?
Thanks,
Victor.Hello Victor,
fine. I am glad, I could help you.
Just one note to XSLT Transformations: When using them, you got even the ability to map directly to internal abap tables:
CALL TRANSFORMATION ZXSLT_YOUR_TRANSFORMATION
SOURCE XML l_xmlstring
RESULT DATA = lt_data.
You just need to transform you xml to the asx:abap name space and that's it
Look at Re: Help needed XML to Internal table and vice versa, where I show a simple example, how this works.
Kind regards,
Hendrik -
XML Transformation error (ABAP -- XML)
Hi,
I'm getting the foll. error while doing a XML Transformation, Can anyone help me in this regard..
<FIN_WT>56.0</FIN_WT>
<FIN_WT_UNIT>KG</FIN_WT_UNIT>
<ZZQMNUM />
<ZZHOLD />
<ZZDUMATNR
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.
The following tags were not closed: asx:abap, asx:values, OUTPUT, item. Error processing resource 'file:///C:/Documents and...
> />
<PSP_NR>U5/0626-HT-193-1-36-344</PSP_NR>
<ZZCRTNAME>ALFI</ZZCRTNAME>
<ZZAPPNAME>ALFI</ZZAPPNAME>
Regards
Jikuare you trying to transform XML to itab?
is the xml well formed one - you can check this by running the xml file in webbrowser, if it doesnt display, then it means the xml is not well formed.
Regards
Raja -
Convert xml into SAP using dataset
Hi All,
How to convert XML into itab using dataset, in this conversion have any function module available? please give me a sample program (having any). and material also.
Thanks,
Suresh maniarasuHi,
First you need to get the XML file Data into SAP using the Function Module and can populate the data into an inernal table.
TEXT_CONVERT_XML_TO_SAP
DMC_CONVERT_XML_TO_TABLE
or you can use the following classes
CL_RSRD_CONVERTER_XML
CL_WDR_XML_CONVERT_UTIL
CL_EXM_IM_ISHCM_CONV_XML_SAP
Thank U,
Jay.... -
Hi,
My requirement is to send an xml document as an attachment to e-mail. I am getting the attachment in mail but when tried to open, the data is missing instead i am getting message as "The XML page cannot be displayed." Cannot view XML input using XSL style sheet. Please correct. I tried using fn. module "SO_DOCUMENT_SEND_API1" as well as using "add_attachment" method. In both the versions i am getting the attachment but not the xml data. Any solution is very much appriciated.
Thank You.
AshokHI,
In order to give exact soulution need to know how you are generating the xml?
1.If you are concatenating the tags for xml into itab and if your data is in readable format..
Make it to string format and use FMs' SCMS_STRING_TO_XSTRING and SCMS_XSTRING_TO_BINARY.
Then pass the binary tab to
DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
I_TYPE = DOCUMENTS_LINE-TYPE
I_HEX = DOCUMENTS_LINE-CONTENT_HEX
I_SUBJECT = DOCUMENTS_LINE-SUBJECT
2. if you are using DOM concept and redering the XML doc, Need to calculate the exact size before creating the attachment and create attachment as beloew: Here l_xml_table is already a Binary table
Preparing contents of attachment with Change Log
l_con_pos = 0.
DESCRIBE FIELD wa_XML LENGTH l_xml_len IN BYTE MODE.
DESCRIBE FIELD wa_attachx LENGTH l_con_len IN BYTE MODE.
LOOP AT l_xml_table INTO wa_xml.
ASSIGN wa_xml TO <fs_con> CASTING.
CHECK sy-subrc EQ 0.
DO l_xml_len TIMES.
l_xml_pos = sy-index - 1.
IF l_con_pos = l_con_len.
APPEND wa_attachx TO i_attachx.
FREE wa_attachx.
l_con_pos = 0.
ENDIF.
MOVE <fs_con>l_xml_pos(1) TO wa_attachx-linel_con_pos(1).
ADD 1 TO l_con_pos.
ENDDO.
ENDLOOP.
Size of XML Document
l_size = L_XML_SIZE.
Adding Attachment
CALL METHOD lv_document->add_attachment
EXPORTING
i_attachment_type = c_ext
i_attachment_size = l_size
i_attachment_subject = C_TITLE
i_att_content_hex = i_attachx[]. -
Mapping corresponding field in the internal table
Hi guys I need help with putting XML value into the appropriate fields in the internal table struc. I attempted to use if else condition to map the element name (cname)over to the fields but those internal table within an internal table post an issue of when to append and so on ... I am using FM SMUM_XML_PARSE and the output in to this table type smum_xmltb (containing all the XML Element and Values) I want to map it to its corresponding field in the internal table (defined below)
Pls pardon this newbie here as this is very new to me. Hope to hear fr u all soon and points will be given! ")
XML->>
<?xml version="1.0" encoding="iso-8859-1"?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<BOOKLIST>
<DATE>2006-09-25</DATE>
<TIME>16:27:20</TIME>
<BOOK_RECORD>
<BOOK_NUM>0012345678</BOOK_NUM>
<SHORT_DESC>OMS BOOK</SHORT_DESC>
<BOOK_GROUP>
<BOOK_CATEGORY>
<CATEGORY_ID>03</CATEGORY_ID>
<CATEGORY_DESC>BOOK group 3</CATEGORY_DESC>
</BOOK_CATEGORY>
<BOOK_CATEGORY>
<CATEGORY_ID>02</CATEGORY_ID>
<CATEGORY_DESC>BOOK group 2</CATEGORY_DESC>
</BOOK_CATEGORY>
</BOOK_GROUP>
</BOOK_RECORD>
<BOOK_RECORD>
<BOOK_NUM>0012345679</BOOK_NUM>
<SHORT_DESC>SAP BOOK</SHORT_DESC>
<BOOK_GROUP>
<BOOK_CATEGORY>
<CATEGORY_ID>01</CATEGORY_ID>
<CATEGORY_DESC>BOOK group 1</CATEGORY_DESC>
</BOOK_CATEGORY>
<BOOK_CATEGORY>
<CATEGORY_ID>09</CATEGORY_ID>
<CATEGORY_DESC>BOOK group 9</CATEGORY_DESC>
</BOOK_CATEGORY>
</BOOK_GROUP>
</BOOK_RECORD>
</BOOKLIST>
</asx:values>
</asx:abap>
INTERNAL TABLE ->>
TYPES: BEGIN OF ADD_CATEGORY,
CATEGORY_ID(10),
CATEGORY_DESC(40),
END OF ADD_CATEGORY,
ADD_T_CATEGORY TYPE ADD_CATEGORY OCCURS 0.
TYPES: BEGIN OF ADD_BOOK_GRP,
BOOK_CATEGORY TYPE ADD_T_CATEGORY,
END OF ADD_BOOK_GRP,
ADD_T_BOOK_GRP TYPE ADD_BOOK_GRP OCCURS 0.
TYPES: BEGIN OF ADD_BOOK,
BOOK_NUM(10) TYPE C,
SHORT_DESC(40) TYPE C,
BOOK_GROUP TYPE ADD_T_BOOK_GRP,
END OF ADD_BOOK,
ADD_T_BOOK TYPE ADD_BOOK OCCURS 0.
TYPES: BEGIN OF TYPE_DATA,
DATE TYPE SY-DATUM,
TIME TYPE SY-TIMLO,
BOOK_RECORD TYPE ADD_T_BOOK,
END OF TYPE_DATA.
DATA: I_DATA TYPE TYPE_DATA OCCURS 0 WITH HEADER LINE.hi,
here is the code sample using ixml library .
just create a report program and copy paste the following code.
REPORT y_test_xml.
DATA: l_ixml TYPE REF TO if_ixml,
l_ixml_sf TYPE REF TO if_ixml_stream_factory,
l_istream TYPE REF TO if_ixml_istream,
l_ostream TYPE REF TO if_ixml_ostream,
l_booklist TYPE REF TO if_ixml_element,
l_document TYPE REF TO if_ixml_document,
l_parser TYPE REF TO if_ixml_parser,
l_root_element TYPE REF TO if_ixml_element,
l_book_record TYPE REF TO if_ixml_element,
l_date TYPE REF TO if_ixml_element ,
l_time TYPE REF TO if_ixml_element ,
l_book_group TYPE REF TO if_ixml_element,
l_book_cat TYPE REF TO if_ixml_element ,
others TYPE REF TO if_ixml_element ,
link TYPE REF TO if_ixml_element ,
description TYPE REF TO if_ixml_element ,
xml TYPE xstring ,
size TYPE i ,
l_xml TYPE REF TO cl_xml_document .
DATA: xml_out TYPE string ,
temp_string TYPE string .
TYPES: BEGIN OF add_category,
category_id(10),
category_desc(40),
END OF add_category,
add_t_category TYPE add_category OCCURS 0 .
TYPES: BEGIN OF add_book_grp,
book_category TYPE add_t_category,
END OF add_book_grp,
add_t_book_grp TYPE add_book_grp OCCURS 0.
TYPES: BEGIN OF add_book,
book_num(10) TYPE c,
short_desc(40) TYPE c,
book_group TYPE add_t_book_grp,
END OF add_book,
add_t_book TYPE add_book OCCURS 0.
TYPES: BEGIN OF type_data,
date TYPE sy-datum,
time TYPE sy-uzeit,
book_record TYPE add_t_book,
END OF type_data.
DATA: i_data TYPE type_data OCCURS 0 WITH HEADER LINE.
DATA: itab LIKE soli OCCURS 0 WITH HEADER LINE.
DATA: cat_wa TYPE add_category ,
bk_gp_wa TYPE add_book_grp ,
bk_rec_wa TYPE add_book ,
bk_wa LIKE LINE OF i_data .
DATA: cat_tab TYPE STANDARD TABLE OF add_category ,
bk_gp_tab TYPE STANDARD TABLE OF add_book_grp ,
bk_rec_tab TYPE STANDARD TABLE OF add_book .
MOVE: '03' TO cat_wa-category_id ,
' BK GP 3' TO cat_wa-category_desc .
APPEND cat_wa TO cat_tab .
MOVE: '02' TO cat_wa-category_id ,
' BK GP 2' TO cat_wa-category_desc .
APPEND cat_wa TO cat_tab .
bk_gp_wa-book_category = cat_tab.
APPEND bk_gp_wa TO bk_gp_tab .
MOVE: '0012345678' TO bk_rec_wa-book_num ,
'OMS book' TO bk_rec_wa-short_desc .
bk_rec_wa-book_group = bk_gp_tab .
APPEND bk_rec_wa TO bk_rec_tab .
CLEAR:bk_gp_tab, cat_tab .
REFRESH :bk_gp_tab, cat_tab .
MOVE: '01' TO cat_wa-category_id ,
' BK GP 1' TO cat_wa-category_desc .
APPEND cat_wa TO cat_tab .
MOVE: '09' TO cat_wa-category_id ,
' BK GP 9' TO cat_wa-category_desc .
APPEND cat_wa TO cat_tab .
bk_gp_wa-book_category = cat_tab.
APPEND bk_gp_wa TO bk_gp_tab .
MOVE: '00123456789' TO bk_rec_wa-book_num ,
'SAP book' TO bk_rec_wa-short_desc .
bk_rec_wa-book_group = bk_gp_tab .
APPEND bk_rec_wa TO bk_rec_tab .
MOVE: sy-datum TO bk_wa-date ,
sy-uzeit TO bk_wa-time .
bk_wa-book_record = bk_rec_tab .
APPEND bk_wa TO i_data .
CLEAR: cat_wa , bk_gp_wa ,bk_rec_wa , bk_wa .
l_ixml = cl_ixml=>create( ).
l_ixml_sf = l_ixml->create_stream_factory( ).
l_document = l_ixml->create_document( ).
l_root_element = l_document->create_element( name = 'asx:abap' ).
l_root_element->set_attribute( name = 'xmlns:asx' value = 'http://www.sap.com/abapxml' ) .
l_root_element->set_attribute( name = 'version' value = '1.0' ).
l_document->append_child( new_child = l_root_element ).
others = l_document->create_simple_element( parent = l_root_element name = 'asx:values' ).
l_booklist = l_document->create_simple_element( parent = others name = 'BOOKLIST' ).
LOOP AT i_data INTO bk_wa .
CLEAR temp_string .
MOVE: bk_wa-date TO temp_string .
l_date = l_document->create_simple_element( parent = l_booklist name = 'DATE' value = temp_string ).
CLEAR temp_string .
MOVE: bk_wa-time TO temp_string .
l_time = l_document->create_simple_element( parent = l_booklist name = 'TIME' value = temp_string ).
LOOP AT bk_wa-book_record INTO bk_rec_wa .
l_book_record = l_document->create_simple_element( parent = l_booklist name = 'BOOK_RECORD' ) .
CLEAR temp_string .
MOVE: bk_rec_wa-book_num TO temp_string .
l_date = l_document->create_simple_element( parent = l_book_record name = 'BOOK_NUM' value = temp_string ).
CLEAR temp_string .
MOVE: bk_rec_wa-short_desc TO temp_string .
l_time = l_document->create_simple_element( parent = l_book_record name = 'SHORT_DESC' value = temp_string ).
l_book_group = l_document->create_simple_element( parent = l_book_record name = 'BOOK_GROUP' ).
LOOP AT bk_rec_wa-book_group INTO bk_gp_wa .
LOOP AT bk_gp_wa-book_category INTO cat_wa .
l_book_cat = l_document->create_simple_element( parent = l_book_group name = 'BOOK_CATEGORY' ).
CLEAR temp_string .
MOVE: cat_wa-category_id TO temp_string .
l_date = l_document->create_simple_element( parent = l_book_cat name = 'CATEGORY_ID' value = temp_string ).
CLEAR temp_string .
MOVE: cat_wa-category_desc TO temp_string .
l_time = l_document->create_simple_element( parent = l_book_cat name = 'CATEGORY_DESC' value = temp_string ).
ENDLOOP .
ENDLOOP .
ENDLOOP .
ENDLOOP .
l_ostream = l_ixml_sf->create_ostream_xstring( xml ).
l_document->render( ostream = l_ostream ).
CREATE OBJECT l_xml.
CALL METHOD l_xml->parse_xstring
EXPORTING
stream = xml.
l_xml->render_2_string(
EXPORTING
pretty_print = 'X'
IMPORTING
RETCODE = RETCODE
stream = xml_out
size = size
CALL METHOD l_xml->display.
to read the xml data to abap itab you could parse node by node or write a XSLT to map it to your itab or use the following method. (add the following code to the earlier program)
data: result_xml type standard table of smum_xmltb .
data: return type standard table of bapiret2 .
after the statement
l_document->render( ostream = l_ostream ).
add
converting xml to itab
call function 'SMUM_XML_PARSE'
exporting
xml_input = xml
tables
xml_table = result_xml
return = return .
now check the result_xml itab.
rgds
anver -
Message mapping hint 1:N in group of 2?
Hi All,
I am looking for message mapping hint to do following:
Source XML.
<itab>
<itab_body>
<a>1</a>
<b>1</b>
</itab_body>
<itab_body>
<a>2</a>
<b>2</b>
</itab_body>
<itab_body>
<a>n</a>
<b>n</b>
</itab_body>
</itab>
Target XML:
<itab>
<itab_body>
<a>1</a>
<b>1</b>
</itab_body>
<itab_body>
<a>2</a>
<b>2</b>
</itab_body>
</itab>
<itab>
<itab_body>
<a>n-1</a>
<b>n-1</b>
</itab_body>
<itab_body>
<a>n</a>
<b>n</b>
</itab_body>
</itab>
ThanksThere are many ways to achieve this. I would use java mapping to get the desired result. You have to loop the source and in the target pick every two nodes as separate. Please follow this link for java mapping. This might provide some idea.
Refer this [link|http://techplay.plozzle.com/?p=21] -
How to downlad a string to the Presentation server
Hi all
How we can download a string to the presentation server <b>without</b> converting it to the internal table.
Am having a XML data as string. I want to bring that to the presentation server without converting it to internal table.
I have tried that by converting to table and downloaded the same as BIN file ......since we are disturbing the string while converting to itab am getting error while executing that XML file.
<b>Error as shown below.
Multiple colons are not allowed in a name. Error processing resource 'file:///D:/XXXXX.xml'. Line 705, Position 588
</w:fldData></w:fldChar></w:r><aml:annotation aml:id="3" w:type="Word.Bookmark.Start" w:name="Text9"/&g...</b>
Kindly help me in this regards.
Thanks in advance
Meikandanus the following code to convert the xml to itab which can then be use with gui_download with file type 'BIN'
data: coutput type string ,
xl_content type xstring ,
binary_content type solix_tab .
call transformation (`ID`)
source flights = flights[]
result xml output.
clear: xl_content .
* xl_content = output .
call function 'SCMS_STRING_TO_XSTRING'
exporting
text = output
* MIMETYPE = ' '
* ENCODING =
importing
buffer = xl_content
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.
refresh binary_content .
call function 'SCMS_XSTRING_TO_BINARY'
exporting
buffer = xl_content
tables
binary_tab = binary_content.
Regards
Raja -
Runtime error while calling transformations
Hello Experts,
while calling
CALL TRANSFORMATION zord1
SOURCE XML g_t_data_records1 "g_t_data_records is a string of xml file
RESULT para = zidoc.
am getting the follwing runtime errorr
XSLT_BAD_SOURCE_CONTEXT
CX_XSLT_RUNTIME_ERROR
here am trying to convert an xml file to abap string. if i execute the XSLT program directly by providing the file am getting the exact result, but when am trying to call from the ABAP program am unable to do it.
will anybody suhhest me how can i solve it.....
thx in advance....Hi
See This Link
xml to itab
XML to ABAP Conversion
I hope that this is helpful.
Regards
Ranga -
AP Workflow Integration to SAP
Hi All,
We are new to SAP.
How to integrate 3rd party AP Workflow output to SAP .
Please let us know any standard procedure, work around, URL.
Thanks in Advance.
Kiran Babuyes you can do that.
1. upload the xml - using gui_upload or thru http protocol into abap variable
2. use call transformation along with XSLT or cl_XML_document class to parase the xml into itab and use the same to call a BAPI/BDC to load the data
which version of R/3 you are using.
Regards
Raja -
How to Create a Simple Transformation code Programatically
I have a requirement to convert an input xml string into a complex ABAP structure. I am thinking of using Simple Transformation (ST).
I want to find out if there is any program / function module which can "generate" the transformation code (ST program) by giving the ABAP structure name (ie, the SE11 name of the ABAP structure). That would save a lot of effort. Any ideas?
thanksHi Janet,
1. XML File -
> Internal table
2. I understand the above is ur requirement.
3. Below is my program.
It does three things :
a) selects data from T001 table
b) Converts into XML and puts it into a file.
c) In second phase,
It reads the file
and Populates the T001 table again (which has been cleareed explicitly)
4. See FIRST PHASE (itab to xml)
SECOND PHASE (xml to itab)
in my program
5.
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 WHERE bukrs = '1000'.
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 .
Maybe you are looking for
-
How to attach multiple files in UTL_MAIL.SEND_ATTACH_VARCHAR2 method
Hi all , I had written a pl/sql where it will write multiple csvs i.e. a.csv,b.csv,c.csv,d.csv to a location using UTL_FILE to reports folder . How do i attach a.csv,b.csv,c.csv,d.csv into a single mail ?? UTL_MAIL.send_attach_raw (sender => '[email
-
Load balancing RDS Licensing for Citrix
Hi all, Currently we are in the middle of upgrading our Citrix farm from 4.5/2003 to 6.5/2008 R2. In relation to TS Licensing, we are using per device CALs. The CALs are split between 2 2003 domain controllers that are published to the forest. Lic
-
Did Not Find Alert Inbox and Alert Configuration Page
Dear All, I if i click on Alert Configuration and Alert Inbox in Runtime Workbench, It is showing 404 NotFound. Please help us Regards Kumar
-
Blackberry Desktop Software Not Working on Windows 7
Dear Fellows, Downloaded and installed Blackberry Desktop Software without any error, but when you click to start the program it says "Blackberry Desktop Software has stopped working" following are the lines shows in detailed information: "Descriptio
-
XSD Validation based on attribute type value
Hi, Can any one tell me how to validate xml element value based on attribute value. Ex:- my xml has the elements like this. <channel> <meta type="VideoTitle">Harding Park Golf Club</meta> <meta type="ReleaseDate">Wed, 03 Jan 2018 15:00:00 GMT</meta>