on 05-28-2011 3:36 PM
Hi,
I am trying to get my head around ABAP mappings and have a few questions.
In the below code sample which I find in every example and blog it talks about specific steps -
*initialize iXML, * create iXML factory object, * create streamfactory object, * create input stream object, * initialize the input xml document, * parse the input xml document
In these steps the code is always exactly the same so my question is are these just standard steps that are implemented every single time an abap mapping is used and hence only standard lines that never have to be changed or will they be different depending on the mapping.
I am trying to work out where I will begin my coding.
So would somebody be so kind as to give me a brief explanation of the above mentioned steps.
Thank you
METHOD if_mapping~execute.
* initialize iXML
TYPE-POOLS: ixml.
CLASS cl_ixml DEFINITION LOAD.
* create iXML factory object
DATA: ixmlfactory TYPE REF TO if_ixml.
ixmlfactory = cl_ixml=>create( ).
* create streamfactory object
DATA: streamfactory TYPE REF TO
if_ixml_stream_factory.
streamfactory = ixmlfactory->create_stream_factory( ).
* create input stream object
DATA: istream TYPE REF TO if_ixml_istream.
istream = streamfactory->create_istream_xstring( source ).
* initialize the input xml document
DATA: idocument TYPE REF TO if_ixml_document.
idocument = ixmlfactory->create_document( ).
* parse the input xml document
DATA: iparser TYPE REF TO if_ixml_parser.
iparser = ixmlfactory->create_parser(
stream_factory = streamfactory
istream = istream
document = idocument ).
iparser->parse( ).
Hi,
The above lines you mentioned deal with initialization of the iXML parser for parsing through the XML payload, so they would remain the same for all mapping where you are parsing the input payload.
The coding for you specific mapping will begin after this, something like :
* Implements the DOM generating interface to the parser
iparser->parse( ).
emp_node_collection = idocument->get_elements_by_tag_name_ns( name = 'Order' ).
emp_node_length = emp_node_collection->get_length( ).
emp_node_iterator = emp_node_collection->create_iterator( ).
where you start reading the xml node values.
Hope this helps.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.