cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP Mapping

Former Member
0 Kudos

Hi all

Is it possible to use ABAP mapping to pass a value back to an IDOC? OR do you have to build the whole IDOC again in the mapping to add the new value or can you just add for example: field PLU = '234'?

Im able to read the idoc and get the values with the ABAP mapping i just want to fill one field with a value I read from a table.

Thx in advance

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

Thx for the reply, the idoc is send to the xi system in the xi system I created a class to do mapping,

and store the values in table. A difrend idoc will be send to get certain values from the table, then we have to fill the field read from the table into the idoc.

code sample i have so far:

  • Create main factory

ixml_factory = cl_ixml=>create( ).

  • Create stream factory

stream_factory = ixml_factory->create_stream_factory( ).

  • Create input stream

istream = stream_factory->create_istream_xstring( source ).

*initialize parser

idocument = ixml_factory->create_document( ).

*Parse the input document

iparser = ixml_factory->create_parser( stream_factory = stream_factory

istream = istream

document = idocument ).

  • parse the xml document into DOM tree

iparser->parse( ).

  • Create Node

node ?= idocument.

  • create a node iterator

iterator = node->create_iterator( ).

  • get current node

node = iterator->get_next( ).

  • loop over all nodes

WHILE NOT node IS INITIAL.

indent = node->get_height( ) * 2.

indent = indent + 20.

CASE node->get_type( ).

WHEN if_ixml_node=>co_node_element.

  • element node

name = node->get_name( ).

nodemap = node->get_attributes( ).

IF NOT nodemap IS INITIAL.

CASE name.

WHEN 'E1BPE1MEANRT'.

  • attributes

elementname = 'E1BPE1MEANRT'.

count = nodemap->get_length( ).

DO count TIMES.

index = sy-index - 1.

attr = nodemap->get_item( index ).

attrbname = attr->get_name( ).

prefix = attr->get_namespace_prefix( ).

value = attr->get_value( ).

ENDDO.

ENDCASE.

ENDIF.

WHEN if_ixml_node=>co_node_text OR

if_ixml_node=>co_node_cdata_section.

IF elementname = 'E1BPE1MEANRT' AND attrbname = 'SEGMENT'.

CASE name.

WHEN 'MATERIAL'.

  • text node

value = node->get_value( ).

wa_zmapping_table-material = value.

WHEN 'UNIT'.

  • text node

value = node->get_value( ).

wa_zmapping_table-unit = value.

WHEN 'EAN_UPC'.

  • text node

value = node->get_value( ).

wa_zmapping_table-ean_upc = value.

WHEN 'EAN_CAT'.

  • text node

value = node->get_value( ).

wa_zmapping_table-ean_cat = value.

  • Insert values into table

posnr = posnr + 1.

wa_zmapping_table-posnr = posnr.

MODIFY zmapping_table FROM wa_zmapping_table.

CLEAR wa_zmapping_table.

ENDCASE.

ENDIF.

ENDCASE.

  • advance to next node

node = iterator->get_next( ).

How would I go about filling the IDOC with the value and send it back?

Thx

MichalKrawczyk
Active Contributor
0 Kudos

hi,

>>Thx for the reply, the idoc is send to the xi system in the xi system I created a class to do mapping,

>>and store the values in table. A difrend idoc will be send to get certain values from the table, then we have to >>fill the field read from the table into the idoc.

don't do it like that!

you should not fill any tables in mappings

do it like that:

send IDOC that fills the table directly to XI but with the use of WE20 (standard partner profiles)

there is a possiblity to put the idoc name in exception table and it will not be handled by

integration engine but as a normal we20 idoc

then send the second one and only there use abap mapping to get the values from the tables

but don't use mappings to put anything to any table... mappings should only be used for reading

Regards,

Michal Krawczyk

Edited by: Michal Krawczyk on Oct 30, 2008 9:32 AM

Former Member
0 Kudos

Hi stephan ,

you just have to read the approriate node in the IDOC then modify it (the source IDOC).

Than write back the source-IDOC. When you write back the IDOC it automatically will be the target message-interface.

Thats all