cancel
Showing results for 
Search instead for 
Did you mean: 

Transfer custom fields to ECC with diferent names

Former Member
0 Kudos

Hi all,

We have several custom fields with the same name in SRM and ECC and with these there aren't problems. Its values are transfered automatically.

But we have two fields with diferent names and for these fields we are having problems.

I've tried to implement the badi BBP_ECS_PO_OUT_BADI in SRM with this code:

DATA: ls_cust_fields LIKE LINE OF ct_bapi_customer_fields.
  READ TABLE ct_bapi_customer_fields INTO ls_cust_fields WITH KEY fieldname = 'ZZ_DOCPRED'.
  IF sy-subrc EQ 0.
    ls_cust_fields-fieldname = 'ZZ_DOCPRE'.
    MODIFY ct_bapi_customer_fields FROM ls_cust_fields INDEX sy-tabix.
  ENDIF.
  READ TABLE ct_bapi_customer_fields INTO ls_cust_fields WITH KEY fieldname = 'ZZ_POSPRED'.
  IF sy-subrc EQ 0.
    ls_cust_fields-fieldname = 'ZZ_POSPRE'.
    MODIFY ct_bapi_customer_fields FROM ls_cust_fields INDEX sy-tabix.
  ENDIF.

But doesn't work, so I've commented this code and I've created an implementation of the badi BBP_PO_INBOUND_BADI in ECC with the following code;

DATA: lt_customer_fields TYPE bbpt_if_customer_fields,
         wa_customer_fields TYPE bbps_if_customer_fields.
  DATA : wa_bapi_te_mepoitem TYPE bapi_te_mepoitem,
         wa_bapi_te_mepoitemx TYPE bapi_te_mepoitemx.
  DATA wa_extensionin TYPE bapiparex.
  DATA txt_960(960) TYPE c.

  DATA: lv_pos TYPE bbp_if_refvalue VALUE '0000000001'.
  FIELD-SYMBOLS: <campo> TYPE ANY.

  lt_customer_fields[] = bbp_customer_fields[].
  SORT lt_customer_fields BY reffield1 refval1.
  LOOP AT lt_customer_fields INTO wa_customer_fields WHERE refobject EQ 'POITEM'
                                                        AND fieldname(1) EQ 'Z'.
*   If this is a new position append the previous
    IF wa_customer_fields-refval1 NE lv_pos.
      wa_bapi_te_mepoitem-po_item = lv_pos.
      wa_bapi_te_mepoitemx-po_item = lv_pos.
      CLEAR txt_960. CLEAR wa_extensionin.
      WRITE wa_bapi_te_mepoitem TO txt_960 LEFT-JUSTIFIED.
      wa_extensionin-structure = 'BAPI_TE_MEPOITEM'.
      wa_extensionin-valuepart1 = txt_960(240).
      wa_extensionin-valuepart2 = txt_960+240(240).
      wa_extensionin-valuepart3 = txt_960+480(240).
      wa_extensionin-valuepart4 = txt_960+720(240).
      APPEND wa_extensionin TO bapi_extensionin.
      CLEAR txt_960. CLEAR wa_extensionin.
      WRITE wa_bapi_te_mepoitemx TO txt_960 LEFT-JUSTIFIED.
      wa_extensionin-structure = 'BAPI_TE_MEPOITEMX'.
      wa_extensionin-valuepart1 = txt_960(240).
      wa_extensionin-valuepart2 = txt_960+240(240).
      wa_extensionin-valuepart3 = txt_960+480(240).
      wa_extensionin-valuepart4 = txt_960+720(240).
      APPEND wa_extensionin TO bapi_extensionin.
*      new position;
      lv_pos = wa_customer_fields-refval1.
      CLEAR: wa_bapi_te_mepoitem, wa_bapi_te_mepoitemx.
    ENDIF.

*   Assign;
    IF wa_customer_fields-fieldname EQ 'ZZ_DOCPRED'.
      wa_bapi_te_mepoitem-zz_docpre = wa_customer_fields-container.
      wa_bapi_te_mepoitemx-zz_docpre = 'X'.
    ELSEIF wa_customer_fields-fieldname EQ 'ZZ_POSPRED'.
      wa_bapi_te_mepoitem-zz_pospre = wa_customer_fields-container.
      wa_bapi_te_mepoitemx-zz_pospre = 'X'.
    ELSE.
*    Other fields
      ASSIGN COMPONENT wa_customer_fields-fieldname  OF STRUCTURE wa_bapi_te_mepoitem TO <campo>.
      IF sy-subrc EQ 0.
        <campo> = wa_customer_fields-container.
        ASSIGN COMPONENT wa_customer_fields-fieldname  OF STRUCTURE wa_bapi_te_mepoitemx TO <campo>.
        <campo> = 'X'.
      ENDIF.
    ENDIF.
  ENDLOOP.
* Last position:
  wa_bapi_te_mepoitem-po_item = lv_pos.
  wa_bapi_te_mepoitemx-po_item = lv_pos.
  CLEAR txt_960. CLEAR wa_extensionin.
  WRITE wa_bapi_te_mepoitem TO txt_960 LEFT-JUSTIFIED.
  wa_extensionin-structure = 'BAPI_TE_MEPOITEM'.
  wa_extensionin-valuepart1 = txt_960(240).
  wa_extensionin-valuepart2 = txt_960+240(240).
  wa_extensionin-valuepart3 = txt_960+480(240).
  wa_extensionin-valuepart4 = txt_960+720(240).
  APPEND wa_extensionin TO bapi_extensionin.
  CLEAR txt_960. CLEAR wa_extensionin.
  WRITE wa_bapi_te_mepoitemx TO txt_960 LEFT-JUSTIFIED.
  wa_extensionin-structure = 'BAPI_TE_MEPOITEMX'.
  wa_extensionin-valuepart1 = txt_960(240).
  wa_extensionin-valuepart2 = txt_960+240(240).
  wa_extensionin-valuepart3 = txt_960+480(240).
  wa_extensionin-valuepart4 = txt_960+720(240).
  APPEND wa_extensionin TO bapi_extensionin.

But also doesn't work...

Do you know how can I do it? or how can i debug the badi BBP_PO_INBOUND_BADI ?

Thanks in advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Solved.

I managed to debug the Badi BBP_PO_INBOUND_BADI. For do it go to the FM B46B_DPO_TRANSFER and put a break-point in the call to the function BBP_PO_INBOUND. If you press F5 a new session will be opened with the user RFC-USER. Then if you open a new session and go to to the badi you can put a break-point and will stop there...

By debuging i can see that the table bapi_extensionin is already filled.

This is my code:

DATA : wa_bapi_te_mepoitem TYPE bapi_te_mepoitem,
         wa_bapi_te_mepoitemx TYPE bapi_te_mepoitemx,
         wa_customer_fields TYPE bbps_if_customer_fields,
         wa_extensionin TYPE bapiparex,
         lv_pos(10) TYPE n,
         lv_tabix   TYPE sy-tabix.
  LOOP AT bapi_extensionin INTO wa_extensionin.
    lv_tabix = sy-tabix.
    IF wa_extensionin-structure EQ 'BAPI_TE_MEPOITEM'.
      wa_bapi_te_mepoitem = wa_extensionin+30.
      lv_pos = wa_bapi_te_mepoitem-po_item.
      READ TABLE bbp_customer_fields INTO wa_customer_fields WITH KEY fieldname = 'ZZ_DOCPRED'
                                                                      reffield1 = 'PO_ITEM'
                                                                      refval1  = lv_pos.
      wa_bapi_te_mepoitem-zz_docpre = wa_customer_fields-container.
      READ TABLE bbp_customer_fields INTO wa_customer_fields WITH KEY fieldname = 'ZZ_POSPRED'
                                                                      reffield1 = 'PO_ITEM'
                                                                      refval1  = lv_pos.
      wa_bapi_te_mepoitem-zz_pospre = wa_customer_fields-container.
      WRITE wa_bapi_te_mepoitem TO wa_extensionin+30(960).
      MODIFY bapi_extensionin FROM wa_extensionin INDEX lv_tabix.
    ELSEIF wa_extensionin-structure EQ 'BAPI_TE_MEPOITEMX'.
      wa_bapi_te_mepoitemx = wa_extensionin+30.
      lv_pos = wa_bapi_te_mepoitem-po_item.
      wa_bapi_te_mepoitemx-zz_docpre = 'X'.
      wa_bapi_te_mepoitemx-zz_pospre = 'X'.
      WRITE wa_bapi_te_mepoitemx TO wa_extensionin+30(960).
      MODIFY bapi_extensionin FROM wa_extensionin INDEX lv_tabix.
    ENDIF.
  ENDLOOP.