on 08-20-2007 3:38 PM
Hi All,
I am doing an ABAP mapping and I am new to this.
I have a following record structure:
<record>
<field1>
<field2>
..
<fieldn>
</record>
I will receive the multiple records with the above structure in single file.
I have following the Blog from SDN but it is saying only for single record.
Can please someone post the code for handing multiple records (ie. loop structure).
or else please mail me at saileshch@yahoo.com
Regards,
Shylesh
These might be usefull....
/people/ravikumar.allampallam/blog/2005/02/10/different-types-of-mapping-in-xi
/people/alessandro.guarneri/blog/2006/03/05/managing-bulky-flat-messages-with-sap-xi-tunneling-once-again--updated
/people/udo.martens/blog/2006/08/23/comparing-performance-of-mapping-programs
Award points if found usefull......
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thanks for the reply.
But actually these threads do not sufficient for my requriement.
I written the following code and it is working fine for one single record. But I want to change this code to work for multiple records which I am not able to do as I am new to Object Oriented.
method IF_MAPPING~EXECUTE.
initialize iXML
type-pools: ixml.
class cl_ixml definition load.
create main factory
data: ixmlfactory type ref to if_ixml.
ixmlfactory = cl_ixml=>create( ).
create stream factory
data: streamfactory type ref to if_ixml_stream_factory.
streamfactory = ixmlfactory->create_stream_factory( ).
create input stream
data: istream type ref to if_ixml_istream.
istream = streamfactory->create_istream_xstring( source ).
parse input document =================================================
initialize input document
data: idocument type ref to if_ixml_document.
idocument = ixmlfactory->create_document( ).
parse input document
data: iparser type ref to if_ixml_parser.
iparser = ixmlfactory->create_parser( stream_factory = streamfactory
istream = istream
document = idocument ).
iparser->parse( ).
get message content of tag <empno>
data: incode type ref to if_ixml_node_collection.
data: incode1 type ref to if_ixml_node_collection.
data: incode2 type ref to if_ixml_node_collection.
data: incode3 type ref to if_ixml_node_collection.
data: incode4 type ref to if_ixml_node_collection.
data: incode5 type ref to if_ixml_node_collection.
data: incode6 type ref to if_ixml_node_collection.
data: incode7 type ref to if_ixml_node_collection.
data: incode8 type ref to if_ixml_node_collection.
data: incode9 type ref to if_ixml_node_collection.
incode = idocument->get_elements_by_tag_name( 'empno' ).
incode1 = idocument->get_elements_by_tag_name( 'empname' ).
incode2 = idocument->get_elements_by_tag_name( 'address1' ).
incode3 = idocument->get_elements_by_tag_name( 'address2' ).
incode4 = idocument->get_elements_by_tag_name( 'address3' ).
incode5 = idocument->get_elements_by_tag_name( 'zipcode' ).
incode6 = idocument->get_elements_by_tag_name( 'mailid' ).
incode7 = idocument->get_elements_by_tag_name( 'phoneno' ).
incode8 = idocument->get_elements_by_tag_name( 'country' ).
incode9 = idocument->get_elements_by_tag_name( 'city' ).
get XI header data (here: "Sender Service")
data: l_sender_service type string.
l_sender_service = param->get( if_mapping_param=>sender_service ).
add trace (appears in message monitoring)
data: l_trace type string.
concatenate 'Sender Service = ' l_sender_service into l_trace.
trace->trace( level = '1'
message = l_trace ).
build up output document =============================================
create output document
data: odocument type ref to if_ixml_document.
odocument = ixmlfactory->create_document( ).
create element 'SenderService' and add it to the document
data: msgtype type ref to if_ixml_element.
msgtype = odocument->create_simple_element( name = 'record'
parent = odocument ).
create element 'SenderService' and add it to the output document
data: elementsender type ref to if_ixml_element.
elementsender = odocument->create_simple_element( name = 'SenderService'
value = l_sender_service
parent = msgtype ).
add node to the output document
data: outcode type ref to if_ixml_node.
data: outcode1 type ref to if_ixml_node.
data: outcode2 type ref to if_ixml_node.
data: outcode3 type ref to if_ixml_node.
data: outcode4 type ref to if_ixml_node.
data: outcode5 type ref to if_ixml_node.
data: outcode6 type ref to if_ixml_node.
data: outcode7 type ref to if_ixml_node.
data: outcode8 type ref to if_ixml_node.
data: outcode9 type ref to if_ixml_node.
outcode = incode->get_item( index = 0 ).
outcode1 = incode1->get_item( index = 0 ).
outcode2 = incode2->get_item( index = 0 ).
outcode3 = incode3->get_item( index = 0 ).
outcode4 = incode4->get_item( index = 0 ).
outcode5 = incode5->get_item( index = 0 ).
outcode6 = incode6->get_item( index = 0 ).
outcode7 = incode7->get_item( index = 0 ).
outcode8 = incode8->get_item( index = 0 ).
outcode9 = incode9->get_item( index = 0 ).
data irc type i.
irc = msgtype->append_child( outcode ).
irc = msgtype->append_child( outcode1 ).
irc = msgtype->append_child( outcode2 ).
irc = msgtype->append_child( outcode3 ).
irc = msgtype->append_child( outcode4 ).
irc = msgtype->append_child( outcode5 ).
irc = msgtype->append_child( outcode6 ).
irc = msgtype->append_child( outcode7 ).
irc = msgtype->append_child( outcode8 ).
irc = msgtype->append_child( outcode9 ).
render document ======================================================
create output stream
data: ostream type ref to if_ixml_ostream.
ostream = streamfactory->create_ostream_xstring( result ).
create renderer
data: renderer type ref to if_ixml_renderer.
renderer = ixmlfactory->create_renderer( ostream = ostream
document = odocument ).
irc = renderer->render( ).
endmethod.
Can anybody help me making these changes.
Thanks in advance.
Shylesh
Hi,
Did anybody done this before?
shylesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
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.