There are a lot of topics on DataSource enhancement, all about R/3, generic DataSource, or table/view. Once I have to enhance the CRM order item DataSource, I dig a while. I can explain the theory by the following diagram.
We have enhanced the table CRMD_ORDERADM_I.
First, enhance the extract structure in RSA6.
Then, go to BWA1, add a line in Mapping.
Now we need to implement it.
DATA:
* Define internal table for the extract structure.
* The type of the Structure is visible in transaction RSA6.
* Also the enhancement of the extract structure will be done
* with transaction rsa6.
* This datasource structure.
LT_DATA TYPE TABLE OF CRMT_BW_SALES_ORDER_I,
WA_DATA LIKE LINE OF LT_DATA .
* define structure for data import.(sbdm)
DATA: LT_DOCUMENTS_XIF TYPE CRMXIF_BT_SALES_T,
LS1_DOCUMENTS_XIF LIKE LINE OF LT_DOCUMENTS_XIF .
DATA: lt_item TYPE CRMXIF_BT_SALES_ITEM_T,
LS_DOCUMENTS_XIF LIKE LINE OF lt_item.
CASE I_DATASOURCE.
WHEN '0CRM_SALES_ORDER_I'.
* copy data from extract structure to internal table.
LT_DATA[] = CT_DATA[].
REFRESH CT_DATA.
* Get the XIF documents.
* Call the callback function.
CALL FUNCTION 'CRM_BADI_GET_XIF'
EXPORTING
I_DATASOURCE = '0CRM_SALES_ORDER_I'
IMPORTING
E_T_RESULT_XIF = LT_DOCUMENTS_XIF.
loop at LT_DOCUMENTS_XIF
into LS1_DOCUMENTS_XIF.
append lines of LS1_DOCUMENTS_XIF-item to lt_item.
endloop.
** Get the data in the internal table for the partners
LOOP at LT_DATA INTO WA_DATA.
Loop at lt_item INTO LS_DOCUMENTS_XIF
WHERE ITEM_GUID = WA_DATA-ITEM_GUID.
WA_DATA-ZMENGE = LS_DOCUMENTS_XIF-ZZORDERADM_I0201.
modify Lt_data from wa_data transporting ZMENGE.
ENDLoop.
ENDLOOP.
CT_DATA = LT_DATA[].
when others.
endcase.
Just notice that
LT_DOCUMENTS_XIF is type of structure CRMXIF_BT_SALES_T.
OK. Then replicate the DataSource to BW and modify the InfoProvider, InfoSource and other objects necessary.
and load the data.