cancel
Showing results for 
Search instead for 
Did you mean: 

CRM_COPY_BADI_EXTERN - Multiple document links

dvaccher
Discoverer
0 Kudos

Hi,

We're facing a limiting factor by using CRM_COPY_BADI_EXTERN.

To be more precise, method PREPARE_DOC_FLOW of this BAdI is the one that's causing the problem.

This method is called 2 times after you hit the `Create complaint`.

- The first time is called to save header data into the Document Flow structure

- The second time is called to save the item data into the Document Flow structure

(You can see an example by opening implementation CRM_COPY_BADI_BILLDO).

In our case, the doc flow must contain Headers and Items of the following Documents: Invoice, Delivery and Order.

The complaint is related to the Invoice, so the Number and Position of the Invoice document is easily stored in the Document Flow.

The problem though, is for the other two.

Order and Delivery data is stored in the ECC system and to get it we're calling a Z function module remote-enabled that wraps a call to SD_DOCUMENT_FLOW_GET.

Here's the call to it:

    CALL FUNCTION 'ZSD_DOCUMENT_FLOW_GET' DESTINATION ls_rfc_conn_details-rfcdest
      EXPORTING
        input_vbeln         = lv_vbeln         " Invoice Number
        input_posnr         = lv_posnr         " Invoice Item Position
        input_allitems      = abap_false       "
        input_self_if_empty = abap_false       "
      TABLES
        et_docflow          = lt_erp_doc_flow. " Document Flow

Now, the issue with this function is that without the Item Position, it'll fetch ALL documents and position related to the given Invoice Number.

The first time PREPARE_DOC_FLOW is called, the position/item number of the Invoice is `INITIAL`.

Meaning tThough, this is a problem for us becase we need the position in order to get the needed documents from the RFC FM.

As of my knowledge, populating the document flow structure on the second call of PREPARE_DOC_FLOW it's not possible as the second call is made to populate Item and not Header documents.

- - -

So: is there a way to get the Item Number of the document on the first call instead of the second?

If not, is there any method we could use in order to modify the document flow by adding the remaining Document Links to it?

- - -

Kind regards.

Accepted Solutions (0)

Answers (0)