Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
Showing results forย 
Search instead forย 
Did you mean:ย 

IDoc Inbound: add dynamically new segment

0 Kudos

Good morning,

I receive an Inbound IDoc in my SAP system in which I have classifications of an article. A very specific classification is not part of the IDoc data and I would like to be able to calculate it (from other classifications present in the IDoc) in order to update my article.

In my opinion, the ideal would be to dynamically modify the content of the incoming IDoc, but if I can just calculate and modify my article with this new classification that would already be very good.

I wanted to use the BADI IDOC_DATA_MAPPER but the segment must already exist.

I also wanted to use the EXIT_SAPLCLFM_002 (Customer Exit for Changing Classification Data Before Saving) enhancement but surprisingly it is not triggered when I use WE19.

I need clarification ๐Ÿ™‚

Thank you in advance for your help.


Active Contributor

Hello @tafkap95 

Assuming you use standard CLFMAS ALE message type to distribute classification data, you can use the CLF00200 Business Transaction Event to manipulate the IDoc data. The BTE has been introduced by the note 388356 - ALE : BTE for ALE distribution unit (CLFMAS)

CLFMAS IDocs are processed by the IDOC_INPUT_CLFMAS function, that calls the BTE at the very beginning, line 43:

*    BUSINESS TRANSACTION EVENT (header / data)             "note0388228
    call function 'OPEN_FI_PERFORM_CLF00200_E'             "note0388356
         exporting                                         "note0388356
             idoc_header       = idoc_contrl               "note0388356
             flg_append_status = 'X'                       "note0388356
         tables                                            "note0388356
             idoc_data         = idoc_data                 "note0388356
             idoc_status       = idoc_status               "note0388356
         exceptions                                        "note0388356
             others       = 1.                             "note0388356
    if sy-subrc = 1.                                       "note0388356
      continue.                                            "note0388356
    endif.                                                 "note0388356

However, you don't really need to modify the IDocs to automatically calculate characteristic values based on other characteristics. In my opinion a better approach is to use Object Dependencies from Variant Configuration (LO-VC). This way your dependent characteristics will be automatically recalculated whenever the source characteristics change. Thus the characteristics will always stay consistent. 

In contrast, if you modify the IDoc, the dependent characteristics will be calculated only during the IDoc processing.

Best regards

Dominik Tylczynski

0 Kudos

Hi Dominik, thank you very much for your detailed response, BTE is a fantastic feature ๐Ÿ™‚

To make sure I understand correctly... Is it possible to add a segment in the function module that I am going to create by modifying the IDOC_DATA table? I tried to do it in debug but without success, perhaps other information needs to be updated?

Best regards



Hi @tafkap95 

From what I see in the code, an implementation of the CLF00200 BTE is able to modify IDOC_DATA table, that contains IDoc segments. So yes, you could add a new segment with the BTE.

However, reconsider your approach and look at the object dependencies. The implementation effort is pretty much the same and you'll have much better solution that would always keep the characteristics values consistent.

Best regards

Dominik Tylczynski