Transforming ABAP internal table to JSON array (rather than object)
Is there an easy way to do this using the standard CALL TRANSFORMATION? Here's what I'm doing:
"ABAP to JSON
writer = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ).
CALL TRANSFORMATION id SOURCE ARRAY = lt_table
RESULT XML writer.
lv_json = writer->get_output( ).
Now this generates JSON with an object named ARRAY in the proper format with sub-objects... but I don't want an object named ARRAY, I just want an unnamed array.
I searched through the documentation, the asJSON documentation seems to imply this should be possible, but doesn't specify any way to accomplish such a thing. Leaving the name blank just generates an error.
Tried a few transformation OPTIONS as well, but none of them seem to accomplish this.
It's not a huge deal to use an object instead (although we're trying to squeeze every microsecond of performance out of this call), or even to just write my own darn transformation, but I guess I'm surprised SAP doesn't seem to support this functionality with CALL TRANSFORMATION. Am I missing something? Please tell me I'm missing something
I honestly can't remember why I asked this question (I think I was just confused about why the object needed a name but that turned out to not really be a problem), but here's what I ended up doing, in case it's helpful:
EDIT: I noticed above someone asked about uppercasing the JSON -- I also had to do this because the REST service I was calling required it. You can see below I actually convert back to string to do this, though there may be a more elegant solution.
*for call to cl_http_client=>create_by_destination
constants: lc_dest TYPE rfcdest value 'MILEMAKER'.
*local structures for handling input/output
DATA: ls_postal_dist type ZST_POSTAL_DIST,
ls_postal_conv type ZST_POSTAL_DIST,
lt_postal_conv type ZTT_POSTAL_DIST,
*for call to cl_http_client=>create_by_destination
lo_CLIENT type ref to IF_HTTP_CLIENT,
ls_RANDMCNALLY_JSON type ZST_RANDMCNALLY_JSON,
lt_RANDMCNALLY_JSON type table of ZST_RANDMCNALLY_JSON,
lv_HTTP_REASON type string,
lv_HTTP_CODE type i,
*JSON conversion
lo_writer TYPE REF TO cl_sxml_string_writer,
lv_json_in TYPE xstring,
lv_json_out TYPE xstring,
lv_json_string type string,
lo_conv type ref to CL_ABAP_CONV_IN_CE,
lo_conv2 type ref to CL_ABAP_CONV_OUT_CE,
*return parameters and error handlers
lo_cxroot TYPE REF TO cx_root,
lv_message type string,
lv_PAR1 LIKE SY-MSGV1,
lv_PAR2 LIKE SY-MSGV2,
lv_PAR3 LIKE SY-MSGV3,
ls_return type bapiret2. "return structure
[snip]
*set request parameters
CALL METHOD lo_client->request->SET_CONTENT_TYPE('application/json').
CALL METHOD lo_client->request->SET_METHOD('POST').
*convert data to JSON
lo_writer = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ).
CALL TRANSFORMATION id SOURCE routes = lt_RANDMCNALLY_JSON initial_components = 'suppress' RESULT XML lo_writer.
lv_json_in = lo_writer->get_output( ).
*attach data to body
CALL METHOD lo_client->request->SET_DATA
EXPORTING
data = lv_json_in.
*get JSON text in string format for testing
CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
EXPORTING
INPUT = lv_json_in
ENCODING = 'UTF-8'
REPLACEMENT = '?'
IGNORE_CERR = ABAP_TRUE
RECEIVING
CONV = lo_conv.
CALL METHOD lo_conv->READ
IMPORTING
DATA = lv_json_string.
*send HTTP POST call to RandMcNally webservice
call method lo_client->send
* exporting timeout = lc_timeout
exceptions http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
others = 4.
if sy-subrc <> 0.
CALL METHOD lo_client->get_last_error
IMPORTING
message = lv_message.
CONCATENATE 'HTTP POST:' lv_message into lv_message.
move lv_message to ls_return-message.
append ls_return to return.
endif.
*receive data back
CALL METHOD lo_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
others = 4.
*pass errors back, if any
if sy-subrc <> 0.
clear ls_return.
ls_return-type = 'E'.
CALL METHOD lo_client->get_last_error
IMPORTING
message = lv_message.
move sy-subrc to lv_json_string.
CONCATENATE 'RECEIVE DATA:' lv_json_string lv_message into ls_return-message SEPARATED BY space.
append ls_return to return.
endif.
*get the data (a table in JSON format) from response object
clear lv_json_out.
lv_json_out = lo_client->response->GET_DATA( ).
*get the status of the response
CALL METHOD lo_client->response->GET_STATUS
IMPORTING
CODE = lv_HTTP_CODE
REASON = lv_HTTP_REASON.
*if response status code not 200 (OK), return error and cease processing
if lv_http_code <> '200'.
clear ls_return.
ls_return-type = 'E'.
move lv_http_code to lv_json_string.
CONCATENATE 'GET STATUS:' lv_json_string lv_HTTP_REASON into ls_return-message SEPARATED BY space.
append ls_return to return.
ENDIF.
catch cx_root into lo_cxroot.
cleanup.
ls_return-message = lo_cxroot->get_text( ).
append ls_return to return.
endtry.
*close channel
CALL METHOD lo_client->close
EXCEPTIONS
http_invalid_state = 1
others = 2.
*trying to process after error sometimes results in short dump because lv_json_out contains something other than JSON
if ls_return is not initial.
return.
endif.
if lv_json_out is not initial.
*convert JSON to string and make it UPPERCASE so that SAP can do transformation
CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
EXPORTING
INPUT = lv_json_out
ENCODING = 'UTF-8'
REPLACEMENT = '?'
IGNORE_CERR = ABAP_TRUE
RECEIVING
CONV = lo_conv.
CALL METHOD lo_conv->READ
IMPORTING
DATA = lv_json_string.
TRANSLATE lv_json_string to UPPER CASE.
*convert JSON back to xstring
CALL METHOD CL_ABAP_CONV_OUT_CE=>CREATE
EXPORTING
ENCODING = 'UTF-8'
REPLACEMENT = '?'
IGNORE_CERR = ABAP_TRUE
RECEIVING
CONV = lo_conv2.
lo_conv2->convert( EXPORTING data = lv_json_string
IMPORTING buffer = lv_json_out ).
*convert our now UPPERCASE xstring to output table (JSON to ABAP)
clear lt_randmcnally_json.
lo_writer = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ).
CALL TRANSFORMATION id OPTIONS value_handling = 'accept_decimals_loss'
SOURCE XML lv_json_out
RESULT routes = lt_RANDMCNALLY_JSON.
[snip]
Similar Messages
-
Xml to abap internal table by using a dynamic internal table at runtime
Hi ,
I have a requirement to convert xml to abap internal table . But the requirement is that i need to create internal table according to the XML .
Ex : If my XML is :
<?xml version="1.0" ?>
- <flights>
- <airline code="AA" name="American Airlines">
- <flight number="0017">
<from airport="JFK">NEW YORK,US</from>
<to airport="SFO">SAN FRANCISCO,US</to>
<departure>110000</departure>
<arrival>140100</arrival>
<type>Scheduled</type>
</flight>
- <flight number="0064">
<from airport="SFO">SAN FRANCISCO,US</from>
<to airport="JFK">NEW YORK,US</to>
<departure>090000</departure>
<arrival>172100</arrival>
<type>Scheduled</type>
</flight>
</airline>
So after conversion my abap internal table shoul have fields as :
airline_code Name flight_number from_airport to_airport departure arrival type
and the field values should be corresponding field values .
Thanks in advance .
Regards .Hi Ujjwal,
use
CALL TRANSFORMATION
Study the online documentation and if required do some search for CALL TRANSFORMATION and/or XML PARSER
And, when coming back here with next question, tell us what searches you did with what results - please always follow the 'search before post' rule, thank you.
Regards,
Clemens -
Xml data to abap internal table
I'm presently working on a interface where data in abap internal table is converted into xml format and placed in the frontend and vice versa.
I'm through with the first part and in secodn part also I'm able to transfer the data from frontend to Document Object Model(DOM) by parsing but finally am not able to put it into an internal table.
Please help (Urgent).
Thanks and regards,
S.K.TripathyHi sitakant,
1. itab --- > xml
xml ---> itab.
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. -
Xml string to abap internal table
HI Experts ,
I want to parse this XML file to abap internal table ,i read as usual the Help and i think
that something is missing on my code.
There is someone can help.
The fields is type string and the value is :
<Containers> <Container workitemid = "00000017" IsParent = "X"><Element name = "_WF" value = "USI029"/><Element name = "_WF_PRIOR" value = "5"/><Element name = "_WF_VERSION" value = "0000"/><Element name = "_WF_NESTING_LEVEL" value = ""/><Element name = "XUBNAME" value = ""/><Element name = "XUACCNT" value = ""/><Element name = "SHORTTEXT" value = ""/><Element name =
i use the call transformation code and there i put this code:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="XML_TAB"/>
<tt:template>
<Containers>
<tt:loop name="a" ref=".XML_TAB">
<Container>
<tt:attribute name="Element name" value-ref="$a.name"/>
<tt:attribute name="value" value-ref="$a.value"/>
</Container>
</tt:loop>
</Containers>
</tt:template>
</tt:transform>
I think that i miss something with the line :<Container workitemid = "0000007" IsParent = "X">
the dump is:
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_ST_MATCH_ATTRIBUTE', was not
caught and
therefore caused a runtime error.
The reason for the exception is:
XML matching error
Expected was attribute: "Elementname" [ ] Read was element-start: "Container" [
Please help
Regards
Chris
Edited by: Chris Teb on Aug 6, 2009 9:57 AMH Siva,
Thanks ,
I try exactly like u tell and i get this dump:
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_ST_MATCH_ELEMENT', was not caught
and
therefore caused a runtime error.
The reason for the exception is:
XML matching error
Expected was element-end: "Containers" [ ] Read was element-start: "Container"
<Containers>
<Container>
<tt:loop name="a" ref=".XML_TAB">
<Element >
<tt:attribute name="name" value-ref="$a.name"/>
<tt:attribute name="value" value-ref="$a.value"/>
</Element>
</tt:loop>
</Container>
</Containers> ->**the dump in the debugger is here .**
</tt:template>
</tt:transform>
Any Idea?
Regards
Chris -
Reading XML file to ABAP internal table
Hi all,
Iam trying to convert a XLM file into abap internal table , am using XSLT transformation to parse the XML file and i am using "CALL METHOD cl_gui_frontend_services=>gui_upload" for reading the XML file.
below is the XML file.
===========================================================================
- <PIXBridge version="2.2" timestamp="2003-04-09T15:27:00">
- <PIX>
<TransactionType>605</TransactionType>
<TransactionCode>98</TransactionCode>
<TransactionNumber>6888965</TransactionNumber>
<SequenceNumber>40001</SequenceNumber>
- <SKUDefinition>
<Company>GZL</Company>
<Division>BMD</Division>
<Season />
<SeasonYear />
<Style>ORT002A</Style>
<StyleSuffix />
<Color>K13</Color>
<ColorSuffix />
<SecDimension />
<Quality />
<SizeRangeCode />
<SizeDesc>M</SizeDesc>
<SkuID>200140577</SkuID>
</SKUDefinition>
</PIX>
</PIXBridge>
=================================================================
and my Transformation code is as below
<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="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<IPIX>
<xsl:apply-templates select="//PIX"/>
</IPIX>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="PIX">
<item>
<TRANSACTIONTYPE>
<xsl:value-of select="TransactionType"/>
</TRANSACTIONTYPE>
<TRANSACTIONCODE>
<xsl:value-of select="TransactionCode"/>
</TRANSACTIONCODE>
<TRANSACTIONNUMBER>
<xsl:value-of select="TransactionNumber"/>
</TRANSACTIONNUMBER>
<SEQUENCENUMBER>
<xsl:value-of select="SequenceNumber"/>
</SEQUENCENUMBER>
<SKUDEFINITION>
<COMPANY>
<xsl:value-of select="Company"/>
</COMPANY>
<DIVISION>
<xsl:value-of select="Division"/>
</DIVISION>
<SEASON/>
<SEASONYEAR/>
<STYLE>
<xsl:value-of select="Style"/>
</STYLE>
<STYLESUFFIX/>
<COLOR>
<xsl:value-of select="Color"/>
</COLOR>
<COLORSUFFIX/>
<SECDIMENSION/>
<QUANTITY/>
<SIZERANGECODE/>
<SIZEDESC>
<xsl:value-of select="SizeDesc"/>
</SIZEDESC>
<SKUID>
<xsl:value-of select="SkuID"/>
</SKUID>
</SKUDEFINITION>
</item>
</xsl:template>
When i run my program i am getting the values only till the sequence number part and im not getting any values that is read in between <SKUDEFINITION> ..... </SKUDEFINITION>
I need help to sort this , kindly help me in this.
regs,
rajaI am not able to get a clue out of that, can Get Durairaj Athavan Raja in to loop for sorting this out.
I made changes to my transformation program , but still not getting the output of the components inside the
<SKUDefinition> , but when i debug the transformation i can able to see the output values for those components but when i get the values in the result table im not getting values of those components.
<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="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<IPIX>
<xsl:apply-templates select="//PIX"/>
</IPIX>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="PIX">
<item>
<TRANSACTIONTYPE>
<xsl:value-of select="TransactionType"/>
</TRANSACTIONTYPE>
<TRANSACTIONCODE>
<xsl:value-of select="TransactionCode"/>
</TRANSACTIONCODE>
<TRANSACTIONNUMBER>
<xsl:value-of select="TransactionNumber"/>
</TRANSACTIONNUMBER>
<SEQUENCENUMBER>
<xsl:value-of select="SequenceNumber"/>
</SEQUENCENUMBER>
<xsl:for-each select="SKUDefinition">
<SKUDEFINITION>
<COMPANY>
<xsl:value-of select="Company"/>
</COMPANY>
<DIVISION>
<xsl:value-of select="Division"/>
</DIVISION>
<SEASON/>
<SEASONYEAR/>
<STYLE>
<xsl:value-of select="Style"/>
</STYLE>
<STYLESUFFIX/>
<COLOR>
<xsl:value-of select="Color"/>
</COLOR>
<COLORSUFFIX/>
<SECDIMENSION/>
<QUANTITY/>
<SIZERANGECODE/>
<SIZEDESC>
<xsl:value-of select="SizeDesc"/>
</SIZEDESC>
<SKUID>
<xsl:value-of select="SkuID"/>
</SKUID>
</SKUDEFINITION>
</xsl:for-each>
</item>
</xsl:template>
</xsl:transform>
==================
Below is my main program
===================
TYPE-POOLS abap.
CONSTANTS gs_file TYPE string VALUE 'C:\XMLABAP1.xml'.
This is the structure for the data from the XML file
TYPES: BEGIN OF ty_text,
TransactionType(3) type n,
TransactionCode(2) type n,
TransactionNumber(7) type n,
SequenceNumber(5) type n,
Company(3) type c,
Division(3) type c,
Season(3) type c,
SeasonYear(4) type c,
Style(8) type c,
Color(3) type c,
SecDimension(3) type c,
Quality(3) type n,
SizeRangeCode(2) type c,
SizeDesc(1) type c,
SkuID(10) type c,
END OF ty_text.
Table for the XML content
DATA: gt_itab TYPE STANDARD TABLE OF char2048.
data: xmlstr TYPE XSTRING.
Table and work ares for the data from the XML file
DATA: gt_person TYPE STANDARD TABLE OF ty_text,
gs_person TYPE ty_text.
Result table that contains references
of the internal tables to be filled
DATA: gt_result_xml TYPE abap_trans_resbind_tab,
gs_result_xml TYPE abap_trans_resbind.
For error handling
DATA: gs_rif_ex TYPE REF TO cx_root,
gs_var_text TYPE string.
Get the XML file from your client
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.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Fill the result table with a reference to the data table.
Within the XSLT stylesheet, the data table can be accessed with
"IPERSON".
GET REFERENCE OF gt_person INTO gs_result_xml-value.
gs_result_xml-name = 'IPIX'.
APPEND gs_result_xml TO gt_result_xml.
Perform the XSLT stylesheet
TRY.
CALL TRANSFORMATION ZAUM_MANH_SYNC_RPT
SOURCE XML XMLSTR
RESULT (gt_result_xml).
CATCH cx_root INTO gs_rif_ex.
gs_var_text = gs_rif_ex->get_text( ).
MESSAGE gs_var_text TYPE 'E'.
ENDTRY.
Now let's see what we got from the file
LOOP AT gt_person INTO gs_person.
WRITE: / 'Transaction Type:', gs_person-TransactionType.
WRITE: / 'Transaction Code :', gs_person-TransactionCode.
WRITE: / 'Transaction Number :', gs_person-TransactionNumber.
WRITE: / 'SequenceNumber :', gs_person-SequenceNumber.
WRITE: / 'Company : ', gs_person-Company.
WRITE : /.
ENDLOOP. "gt_person. -
Read dimension member(master data) to ABAP internal table in BPC 10.0 NW
Hi all,
I manage to read transaction data using this example [replacement for IF_UJ_MODEL~GET_APPL_DATA;
I am now trying to read members(master data) from a dimension to a ABAP internal table but I have no idea how to.
Can anyone advise me on how to read members(master data) from a dimension to a ABAP internal table.
Some sample code would be really appreciated.
Regards
Edited by: HK Kang on Jan 3, 2012 4:26 AMHi Chanaveer,
UJD_ADMIN_RUN_OPTIMIZE can be used only for executing the FULL & LITE OPTIMIZER packages.
Looking at the code of UJD_RUN_OPTIMIZE_PACKAGE it seems this FM can be used to trigger process chain from BW.
Please refer below link on SDN showing how to load Master Data on FLY in SAP BPC 10.
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/2020b522-cdb9-2e10-a1b1-873309454fce?QuickLink=index&overridelayout=true
Thanks,
Rohit -
To convert XML to ABAP internal table can we do it with DOM or we need XSLT
I have a requirement where I need to collect the data from XML file into an internal table.
I need to collect this data into an internal table as I should make use of this data and do Goods Receipt in SAP.
My XML file is very very complex and the child nodes in my XML file may occur ones or 10 times and change dynamically.
I want to know if XML to ABAP internal table is possible with DOM or does it need XSLT too.
I used the blog of Robert which uses DOM, but it I am unable to collect the data in internal table. The blog explains only how to wtite the out put to screen as element and value.
I want to know if XML to ABAP internal table is possible with DOM or do I need XSLT too? I am confused please help.
Any help will be highly appreciated.
Regards,
Jessica SamHello Jessica
Why not using the DOM itself for processing?
Below you see the post-processing coding which I use to add the interchange control number (ICN) into an EDI message (which at this stage is still an XML-EDI stream). This is done on SAP-XI yet on the ABAP stack so you could use this approach on your R/3 system as well.
method POSTPROCESSING.
* Post-Processing of outbound EDI invoices & dispatch advices
me->map_icn( ).
endmethod.
method MAP_ICN.
* define local data
DATA: lo_node TYPE REF TO if_ixml_node,
ld_name TYPE string,
ld_value TYPE string,
ld_error_code type MPG_ERRCODE,
** ld_control_number TYPE char13,
ld_rc TYPE i,
ld_msg TYPE string. " bapi_msg.
DATA: ld_interface TYPE string.
DATA: incode TYPE REF TO if_ixml_node_collection.
LOG-POINT ID zedi
SUBKEY mc_subkey_method_trace.
ld_error_code = md_clsname.
* Get next interchange control number (ICN)
me->md_next_number = me->get_next_number(
id_nrobj = me->md_nrobj " Object (SNRO)
id_nrnr = me->md_nrnr ). " Number Range
CALL METHOD zcl_edi_uk_counter=>calculate_modulo_n09
EXPORTING
id_input = me->md_next_number
receiving
rd_output = me->md_next_number.
* Build ICN according to naming conventions agreed with EDI customer
me->md_icn = me->generate_icn( me->md_next_number ).
ld_value = me->md_icn. " type conversion to string
CLEAR: incode,
lo_node.
incode = me->mo_document->get_elements_by_tag_name( mc_d_0020 ).
lo_node = incode->get_item( index = 0 ).
CALL METHOD lo_node->set_value
EXPORTING
value = ld_value
RECEIVING
rval = ld_rc.
IF ( ld_rc NE 0 ).
CONCATENATE 'Error [' mc_d_0020
']: Method SET_VALUE (IF_IXML_NODE)'
INTO ld_msg.
CONDENSE ld_msg.
me->mif_trace->trace2( message = ld_msg ).
RAISE EXCEPTION TYPE cx_mapping_fault
EXPORTING
* textid =
* previous =
error_code = ld_error_code
error_text = ld_msg.
** MESSAGE ld_msg TYPE 'A'.
ENDIF.
CLEAR: incode,
lo_node.
incode = me->mo_document->get_elements_by_tag_name( mc_d_0020_2 ). " element for ICN
lo_node = incode->get_item( index = 0 ).
CALL METHOD lo_node->set_value
EXPORTING
value = ld_value
RECEIVING
rval = ld_rc.
IF ( ld_rc NE 0 ).
CONCATENATE 'Error [' mc_d_0020_2
']: Method SET_VALUE (IF_IXML_NODE)'
INTO ld_msg.
CONDENSE ld_msg.
me->mif_trace->trace2( message = ld_msg ).
RAISE EXCEPTION TYPE cx_mapping_fault
EXPORTING
* textid =
* previous =
error_code = ld_error_code
error_text = ld_msg.
** MESSAGE ld_msg TYPE 'A'.
ENDIF.
* define local data
DATA: ls_record TYPE mpp_dynamic.
CLEAR: ls_record.
ls_record-namespace = mc_dynamic_namespace.
ls_record-name = mc_icn.
ls_record-value = ld_value.
mif_dynamic->add_record( ls_record ).
endmethod.
In your case you would need to do a DO...ENDDO loop until you parsed all required nodes.
NOTE: ME->MO_DOCUMENT is of TYPE REF TO IF_IXML_DOCUMENT.
Regards
Uwe -
ABAP Internal table cannot be extended dump
Hi,
I am getting the error abap internal table cannot be extended dump for FI program.
If I make use of Hashed table instead of Standard internal table,will it solve the problem.Will the hashed table able to hold more data.
RgdsHi ,
Can you tell me which table you have used for reference to create internal table .
can you show the code for creating internal table .
Problem can be if you have used include structure of any another table and that table have size category such that it can store only that much values which you have set for creating that SAP table .
Regards
Deepak.
Edited by: Deepak Dhamat on Aug 8, 2011 11:18 AM -
XML to ABAP internal table with CALL TRANSFORMATION
I can't create a transformation that allow passing next XML file to an internal table:
Please, I need someone could help me, because I don t have XML knowledge
<< Moderator message - Everyone's problem is important. But the answers in the forum are provided by volunteers. Please do not ask for help quickly. >>
Kind regards,
Edited by: Rob Burbank on Jul 21, 2011 4:02 PMHi Gastón Juarez,
sorry, didn't see your post, you should have linked the previous to this one
If we create a ZZZ transformation of type ST, it would be something like this (I didn't test). Note that I concatenated the date and time, because field operations in ST are not possible (we should use XSLT instead, but it's counter performant):
... (here the usual header)
<tt:root name="ABAP_X"/>
<tt:template>
<corailExport xmlns= " http://www.abc.com/corailExport_Transcou201D
xmlns: xsi= " http://www.w3.org/2001/XMLSchema-instanceu201D
xsi: schemaLocation= " http://www.abc.com/corailExport_Transco corailExport_Transco.xsd u201C>
<exportDate><tt:skip></tt:skip></exportDate>
<tt:loop ref=".ABAP_X" name="line">
<transcodification>
<tt:attribute name="applyingDate" value-ref="$line.APPLYING_DATE"></tt:attribute>
<previousCofor><tt:value ref="$line.OLD_COFOR"></tt:value></previousCofor>
<newCofor><tt:value ref="$line.NEW_COFOR"></tt:value></newCofor>
</transcodification>
</tt:loop>
</corailExport>
</tt:template>
The program:
TYPES : BEGIN OF ty_x,
applying_date TYPE string,
old_cofor TYPE lifnr,
new_cofor TYPE lifnr,
END OF ty_x.
DATA l_xml TYPE string.
DATA lt_x TYPE TABLE OF ty_x.
l_xml = 'your xml'.
CALL TRANSFORMATION zzz
SOURCE XML l_xml
RESULT abap_x = lt_x.
BR
Sandra -
Code to transfer xml file to abap internal table using transformation
Hi friends
Given the following xml file .the requirementis to display and transfer the xml file to internal table usin transformation and gui_upload.If any onehaving simple code on this please send .
Can any one sugest the steps to be followed to write source code using simple transformation.
<?xml version="1.0" encoding="utf-8" ?>
- <Negara>
- <item>
- <COUNTRY>
<MANDT>600</MANDT>
<ZCODE>500</ZCODE>
<ZDESC>Pening Lalat</ZDESC>
<ZSAPCD>T1</ZSAPCD>
</COUNTRY>
</item>
- <item>
- <COUNTRY>
<MANDT>600</MANDT>
<ZCODE>600</ZCODE>
<ZDESC>Pening Lalat2</ZDESC>
<ZSAPCD>T2</ZSAPCD>
</COUNTRY>
</item>
</Negara>
Thaking Youhi..
1. itab --- > xml
xml ---> itab.
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
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[].
<b>Reward points if useful</b>
Regards
Ashu -
Error in xml to abap internal table transformation using xslt_tool
Hi friends,
When i am trying to convert xml data into internal table it is going to dump because of empty elements. Can any body help to delete the empty tags from xml before processing through xslt_tool.
example
<Activity>
<ID>add12095</ID>
<Start>09/01/2014 12:01</Start>
<Type>3</Type>
<Code>99202</Code>
<Quantity>1</Quantity>
<Net>244</Net>
<Clinician>GD16130</Clinician>
<PriorAuthorizationID/> "empty tag
<Gross>294</Gross>
<PatientShare>50</PatientShare>
<PaymentAmount>244</PaymentAmount>
</Activity>
the empty element some times will come in the xml and some times not. so i made a check in xslt. when this empty element tag processed through that condition i am getting the dump. either i need to remove the condition or we should delete the empty tags before processing. Removing of if condition is not possible because that element may or may not come all the time.
Regards,
Rajesh.You can replace all empty tags using regular expression.
REPLACE ALL OCCURRENCES OF REGEX '<\w+/>' IN lv_xml WITH ''. -
Question about XML mapping to ABAP internal table
Hi experts.
I'm trying to XML mapping. But it doesn't work well. Assume there are XML file as below.
<HEADER>
<ITEM>
<FOO>123</FOO>
<BAR>ABC</BAR>
</ITEM>
<ITEM>
<FOO>456</FOO>
<BAR>DEF</BAR>
</ITEM>
<HEADER>
and I want to trasformation it as below.
ITAB
FOO | BAR
123 | ABC
456 | DEF
How could I trasformation using "call transformation"?
Regards.Hi,
REPORT zind_xml_to_sap NO STANDARD PAGE HEADING.
Data Declaration *
DATA: client TYPE REF TO if_http_client, "Interface
host TYPE string,
port TYPE string,
proxy_host TYPE string,
proxy_port TYPE string,
path TYPE string,
scheme TYPE i,
xml TYPE xstring,
response TYPE string.
DATA: t_xml TYPE smum_xmltb OCCURS 0 WITH HEADER LINE. "XML Table structure used
"for retreive and output XML doc
DATA: g_stream_factory TYPE REF TO if_ixml_stream_factory. "Interface
DATA : return LIKE bapiret2 OCCURS 0 WITH HEADER LINE. "XML Table structure used for retreive
"and output XML doc
Parameters *
PARAMETER : p_add TYPE string LOWER CASE ,
p_dfile LIKE rlgrap-filename.
AT Selection-Screen on value-request for file *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dfile.
Get file
PERFORM 100_get_file.
Start-of-Selection *
START-OF-SELECTION.
Perform to upload xml data from URL to SAP internal table
PERFORM 200_xml_upload.
IF t_xml[] IS NOT INITIAL.
Perform to Download data from Internal Table to a text file in local drive
PERFORM 300_download.
write : / 'Data Uploaded to Internal Table Successfully'.
write : / 'XML Data Downloaded to Local path', p_dfile.
else.
write : / 'No Data for upload'.
ENDIF.
*if t_xml[] is INITIAL.
WRITE : address, 'Given URl cannot be Converted' .
else.
LOOP AT t_xml .
WRITE: t_xml-cname, t_xml-cvalue.
ENDLOOP.
endif.
*& Form get_file
Get File
FORM 100_get_file .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
file_name = p_dfile
ENDFORM. " 100_get_file
*& Form 200_xml_upload
form to upload xml data from URL to SAP internal table
FORM 200_xml_upload .
*Check HTTP:// and concatenate
IF p_add NS 'http://' OR p_add NS 'HTTP://'.
CONCATENATE 'http://' p_add
INTO p_add.
ENDIF.
Fetching the address of the URL
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = p_add
IMPORTING
client = client.
*Structure of HTTP Connection and Dispatch of Data
client->send( ).
*Receipt of HTTP Response
CALL METHOD client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
IF sy-subrc = 1.
MESSAGE 'HTTP COMMUNICATION FAILURE' TYPE 'I' DISPLAY LIKE 'E'.
EXIT.
ELSEIF sy-subrc = 2.
MESSAGE 'HTTP INVALID STATE' TYPE 'I' DISPLAY LIKE 'E'.
EXIT.
ELSEIF sy-subrc = 3.
MESSAGE 'HTTP PROCESSING FAILED' TYPE 'I' DISPLAY LIKE 'E'.
EXIT.
ELSE.
MESSAGE 'Problem in HTTP Request' TYPE 'I' DISPLAY LIKE 'E'.
EXIT.
ENDIF.
ENDIF.
Get data of the xml to Response
response = client->response->get_cdata( ).
*FM converting the XML format to abap
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = response
IMPORTING
buffer = xml.
*FM converting XMl to readable format to a internal table.
CALL FUNCTION 'SMUM_XML_PARSE'
EXPORTING
xml_input = xml
TABLES
xml_table = t_xml
return = return.
ENDFORM. " 200_xml_upload
*& Form 300_download
*form to Download data from Internal Table to a text file in local drive
FORM 300_download .
DATA filename TYPE string.
filename = p_dfile.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = filename
WRITE_FIELD_SEPARATOR = 'X'
TABLES
data_tab = t_xml
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.
ENDFORM. -
XML Processing (XML file data to ABAP internal table).
Hi,
I have a an XML file and i need to send the data to internal table. I suppose i have written the program correctly.
But the transformation program may not be correct.
So can one please tell me the transformation program c o d e or guide me to write the transformation code. Below are details of XML file and my program.
XML File
<?xml version="1.0" encoding="UTF-8" ?>
- <aeRequestOutputType>
+ <trackingInfo>
+ <JMSHeaders>
- <ns:__caret_reply_caret_ZBAPI xmlns:ae="http://www.tibco.com/" xsi:type="ns:__caret_reply_caret_ZBAPI_">
+ <RETURN>
- <T__TRADE__DATA>
- <item>
<BUKRS>1111</BUKRS>
<HKONT>22222</HKONT>
</item>
- <item>
<BUKRS>3333</BUKRS>
<HKONT>44444</HKONT>
</item>
</T__TRADE__DATA>
</ns:__caret_reply_caret_ZBAPI__TRADE__ACC__DOC__POST_caret_ZBAPI__TRADE__ACC__DOC__POST>
</aeRequestOutputType>
My Program
REPORT ZTEST13.
DATA : BEGIN OF itab OCCURS 0,
f(255) TYPE c,
END OF itab.
DATA : t001 TYPE TABLE OF ZTEST_ST_UB. "(structure has few variables like hkont,bukrs)
DATA: xmlupl TYPE string .
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'c:\sap_output_xml.txt'
FILETYPE = 'ASC'
tables
data_tab = itab .
LOOP AT itab.
CONCATENATE xmlupl itab-f INTO xmlupl.
ENDLOOP.
CALL TRANSFORMATION ZTEST_ST_UB2
SOURCE XML xmlupl
RESULT root = t001.Hi,
use class cl_xml_document and method import_from_file inorder to read the xml file to internal table.
go trough this [LINK|http://wiki.sdn.sap.com/wiki/display/ABAP/UploadXMLfiletointernal+table] for detial code.
Regards,
Shanmugavel chandrasekaran -
Reading complex file in ABAP internal table.
I have a following XML file. and I want to read it in internal Table with deep structure.
<?xml version="1.0" encoding="utf-16" ?>
- <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
- <asx:values>
- <TAB>
- <item>
<CATALOGUEREQUESTIDID>5</CATALOGUEREQUESTIDID>
<MBRSH>Chemical Industry</MBRSH>
<MTART>Spare Parts</MTART>
<WERKS>Spare Parts Warehouse</WERKS>
<MAKTX>Lubricant,Oil Graphite></MAKTX>
<MEINS>Bottle</MEINS>
<MATKL>Spare parts - General</MATKL>
<BRGEW>10</BRGEW>
<GEWEI>G</GEWEI>
<NTGEW>9</NTGEW>
<VOLUM>1</VOLUM>
<VOLEH>L</VOLEH>
<EKGRP>Buyer 1</EKGRP>
<XCHPF>NO</XCHPF>
<EKWSL>-15, -10, -05</EKWSL>
<WEBAZ>2</WEBAZ>
<INSMK>NO</INSMK>
<KZKRI>NO</KZKRI>
<MFRPN>SHELL</MFRPN>
<MFRNR>WD-40</MFRNR>
- <DRGNUM>
<ZEINR>C-39166</ZEINR>
<ZEIAR>KKK</ZEIAR>
<ZEIVR>3</ZEIVR>
<BLATT>4</BLATT>
<AESZN>12</AESZN>
<ZEIFO>A3</ZEIFO>
<BLANZ>12</BLANZ>
</DRGNUM>
- <DRGNUM>
<ZEINR>C-39167</ZEINR>
<ZEIAR>KKK</ZEIAR>
<ZEIVR>3</ZEIVR>
<BLATT>4</BLATT>
<AESZN>12</AESZN>
<ZEIFO>A3</ZEIFO>
<BLANZ>12</BLANZ>
</DRGNUM>
- <DRGNUM>
<ZEINR>C-39168</ZEINR>
<ZEIAR>KKK</ZEIAR>
<ZEIVR>3</ZEIVR>
<BLATT>4</BLATT>
<AESZN>12</AESZN>
<ZEIFO>A3</ZEIFO>
<BLANZ>12</BLANZ>
</DRGNUM>
</item>
</TAB>
</asx:values>
</asx:abap>
+I for this I have created a internal table as; +
types : begin of DRGNUM,
ZEINR(10),
ZEIAR(5),
ZEIVR(5),
BLATT(5),
AESZN(5),
ZEIFO(5),
BLANZ(5),
end of DRGNUM.
data : begin of item occurs 0,
CATALOGUEREQUESTIDID,
MBRSH(20),
MTART(15),
WERKS(30),
MAKTX(40),
MEINS(10),
MATKL(30),
BRGEW(5),
GEWEI(2),
NTGEW(5),
VOLUM(5),
VOLEH(2),
EKGRP(10),
XCHPF(3),
EKWSL(15),
WEBAZ(2),
INSMK(2),
KZKRI(2),
MFRPN(5),
MFRNR(5).
data : DRGNUM type ZDRGNUM.
data: end of item.
*XML
call transformation ('ID')
source xml xmlupl
result tab = item[]
The problem is that for DRGNUM nodes in XML I can only manage to get last DRGNUM node data in the internal table.
How can I get all the 3 items for DRGNUM in the Internal table ?
Your help is appreciated.
Edited by: Hasan Bin Tariq on May 6, 2009 11:12 AMu need to create three files with 3 different data in DRGNUM.
i.e, in the 1st file give the 1st set of data for drgnum and
in the 2nd file, u will hve 2nd set of data for DRGNUM and the rest will data will be same without any change. simliarly do the 3rd file.
and try to get into the internal table now. -
Defining XSLT from Abap to XML and XML to Abap (Internal Table)
Hi Experts, I need help with this XSLT for call transformation. I have defined an internal table and intend to use it as a source for Call Tranformation. But I have a Problem defining its XSLT and help would be greatly appreciated! I also wonder if this XSLT can be used for XML to internal table? Or do I have to define another XSLT again.... Hope to hear from any of u soon!
CODES->>>
TYPES: BEGIN OF CONTENT,
CONTENT1(20),
CONTENT2(20),
END OF CONTENT.
TYPES: T_CONTENT TYPE TABLE OF CONTENT.
DATA: BEGIN OF I_DATA OCCURS 0,
KEY1(10),
KEY2(10),
CONT TYPE T_CONTENT,
END OF I_DATA.
DATA: WA_TBL TYPE CONTENT.
DATA: LI_TBL TYPE T_CONTENT.
START-OF-SELECTION.
populate data 1
CLEAR I_DATA.
I_DATA-KEY1 = 'AMI'.
I_DATA-KEY2 = 'LEE'.
CLEAR WA_TBL.
REFRESH LI_TBL.
WA_TBL-CONTENT1 = 'PENHAS ROAD'.
WA_TBL-CONTENT2 = 'SG'.
APPEND WA_TBL TO LI_TBL.
WA_TBL-CONTENT1 = 'GILLMAN ROAD'.
WA_TBL-CONTENT2 = 'SG'.
APPEND WA_TBL TO LI_TBL.
I_DATA-CONT = LI_TBL.
APPEND I_DATA.
populate data 1
CLEAR I_DATA.
I_DATA-KEY1 = 'KAI'.
I_DATA-KEY2 = 'LEE'.
CLEAR WA_TBL.
REFRESH LI_TBL.
WA_TBL-CONTENT1 = 'SUNSET WAY'.
WA_TBL-CONTENT2 = 'SG'.
APPEND WA_TBL TO LI_TBL.
WA_TBL-CONTENT1 = 'BEDOK NORTH'.
WA_TBL-CONTENT2 = 'SG'.
APPEND WA_TBL TO LI_TBL.
I_DATA-CONT = LI_TBL.
APPEND I_DATA.
call transformation (xslt)
source i_data = i_data
result xml xmlstr.here is the code sample using ixml library .
just create a report program and copy paste the following code.
if time permits, later on i will post the xslt program which you can use it call transformation.
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.
Hope this is helpful.
do let us know how it goes.
Regards
Raja
Maybe you are looking for
-
Hi, I am use SAP query to build a AP cleared Item report. The report is similar as we can get from FBL1n, but I need a column as group key, which can not be found in FBL1n report. My questions is: 1. When using SAP query, I use table LFA1 and BSAK, e
-
i got the ati drivers installed and i set up xorg to have 2 heads 1 as my reguler display and one for my tv. they both work but some colors show up wierd on the tv. On the tv some of the brighter reds show up green and some of the brightest blues sho
-
Smart Playlists are fixed with iPod Updater 2006-01-10
Hello Podders, Resident Furball here... iPod Updater 2006-01-10 restores dynamic updating of Smart Playlists on the iPod iPod Updater 2005-06-26 disabled the onboard dynamic updating of Smart Playlists on iPods older than the Nano and Gen5. This feat
-
I had to go to Internet Explorer to print an invoice copy from Amazon.com. I've never had to NOT use Firefox before to do this. I lost some of the icons, apparently, and one was the one for print.
-
Dear Sirs, hope question will be new in this forum. I've found out following : select count(*) from TEST_TAB s where hash_key = :hk and( R$APP in (x1, x2, ..., x10 ) or R_CALLS_LOG in ( y1, y2, ..., y756) run time: 380 sec select count(*) from TEST_T