Skip to Content
avatar image
Former Member

PI 7.11: IDoc Message mapping

Hi there,

I'm currently working on a graphical message mapping using IDoc HRMD_A06 as source structure (HR master data transferred via PFAL).

In my result structure I have to fill a field CostCenter with the following logic:

If field KOSTL (cost center) is filled in node E1P0315, map this field to CostCenter in result structure, otherwise take KOSTL of node E1P0001.

The end date (ENDDA) has to be '99991231' in each case.

This is how the result structure looks like:

<e>                       [1...1]
  <CostCenter>            [1...1]
</e>

This is the simplified source structure:

<E1PLOGI SEGMENT="1">
  <E1PITYP SEGMENT="1">                        [0...n]
     <E1P0001 SEGMENT="1">                     [0...n]
       <INFTY>0001</INFTY>                     [0...1]
       <ENDDA>99991231</ENDDA>                 [0...1]
       <KOSTL>0000012345</KOSTL>               [0...1]
    </E1P0001>
  </E1PITYP>
  <E1PITYP SEGMENT="1">                        [0...n]
    <E1P0315 SEGMENT="1">                      [0...n]
      <INFTY>0315</INFTY>                      [0...1]
      <ENDDA>99991231</ENDDA>                  [0...1]
      <KOSTL>0000024001</KOSTL>                [0...1]
    </E1P0315>
  </E1PITYP>
</E1PLOGI>

How can I do the check if field KOSTL of node E1P0315 is null?

I've tried an existence check for the whole node (E1P0315->exists), but then it fails, because all E1PITYP nodes are processed.

I hope my problem is clear to you.

Would it be better to use another mapping type?

As I'm an ABAP developer, I would of course prefer some lines of code to this graphical drag&drop thing.

Thanks in advance!

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Dec 12, 2011 at 07:33 PM

    Hi

    I think you can use mapWithDefault function.

    Regards.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 12, 2011 at 10:34 PM

    Yes, use of mapWithDefault function would help you.

    pseudo logic

    KOSTL->Mapwithdefault ->equals (String function and compare with "" value) ->(if without else ) ->pass the value KOSTL to output

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Cheers, guys!

      I did it now like that:

      http://www.abload.de/image.php?img=mappingflknz.jpg

      Click on the image to enlarge it!

      The logic is as following (ABAP Pseudo-code 😉 ):

      IF 0315_KOSTL and 0315_ENDDA are populated.
        IF 0315_ENDDA equals '99991231'.
          map 0315_KOSTL to Cost_Center.
        ENDIF.
      ELSE.
        IF 0001_KOSTL and 0001_ENDDA are populated.
          IF 0001_ENDDA equals '99991231'.
            map 0001_KOSTL to Cost_Center.
          ENDIF.
        ENDIF.
      ENDIF.

      Is that a good way to do that mapping?

      Do I also have to use the removeContexts function or is it ok like that?

      Could I also do that with an ABAP mapping program?

      Thanks in advance!