In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "what is the method of data format conversion between ABAP and XML". In daily operation, I believe that many people have doubts about the method of conversion between ABAP and XML data formats. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "what is the method of conversion between ABAP and XML data formats". Next, please follow the editor to study!
1. ABAP provides a utility class cl_proxy_xml_transform, through its two methods abap_to_xml_xstring and xml_xstring_to_abap to achieve the interchange of the two formats.
Look at specific examples:
REPORT zxm.DATA: ls_abap TYPE zzcrmost__pro001dotproduct1.DATA: ls_line LIKE LINE OF ls_abap-item.ls_line-logsys = 'AG3'.ls_line-object_family =' 0401'.ls_line-product_id = 'MCF-0001'.ls_line-product_type =' 01'.APPEND ls_line TO ls_abap-item.ls_line-logsys = 'QDD'.ls_line-object_family =' 0402'.ls_line-product_id = 'MCF- 0002'.ls_line-product_type = '02'.APPEND ls_line TO ls_abap-item.DATA (xml) = cl_proxy_xml_transform= > abap_to_xml_xstring (EXPORTING abap_data = ls_abap ddic_type =' ZZCRMOST__PRO001DOTPRODUCT1'). DATA: ls_abap2 LIKE ls_abap Ls_abap3 LIKE ls_abap.cl_proxy_xml_transform= > xml_xstring_to_abap (EXPORTING ddic_type = 'ZZCRMOST__PRO001DOTPRODUCT1' xml = xml IMPORTING abap_data = ls_abap2). ASSERT ls_abap2 = ls_abap.
The last line of the ASSERT statement states that the pre-converted ABAP data is exactly the same as the converted ABAP data when it is converted from ABAP format to XML format and then to ABAP format.
The structure zzcrmost__pro001dotproduct1 type definition used by the above ABAP code is as follows:
If we step into the utility class cl_proxy_xml_transform, there is nothing magical about it.
An ABAP simple transformation is generated internally to convert ABAP and XML formats to and from each other.
Record the generated transformation ID in the debugger, then open it with the transaction code STRANS, and you can see the details.
two。 With the hint that method 1 single-step debugging discovers simple transformation, we can use a simpler method to interchange the two formats, that is, to call simple transformation directly:
DATA: lv_xml TYPE string.CALL TRANSFORMATION id SOURCE b = ls_abap RESULT XML lv_xml.
The root node of the generated XML is called b because the above code calls the parameter SOURCE, and when the ABAP variable ls_abap is passed in, the bound parameter is named "b".
CALL TRANSFORMATION id SOURCE XML lv_xml RESULT b = ls_abap3.
ASSERT ls_abap2 = ls_abap3. You can still get the value of the original ABAP variable by doing ABAP- > XML- > ABAP in this way.
At this point, the study on "what is the method of converting ABAP and XML data formats to each other" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.