cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Implementing BAPI_CONTRACT_CHANGE

mtepe
Newcomer
0 Likes
2,248

Hello,

I have a small issue by implementing BAPI_CONTRACT_CHANGE to modify my custom fields in the ekko table. My three custom fields locate on the header level in me32k transaction. ZM04_E206_MASS_CHG is my transfer structure consisting of ebeln and my 3 zz1 fields. The reason why I created a transfer structure is, the BAPI_TE_MEOUTHEADER does not include my zz1 fields. I also tried to implement the method "IF_EX_MEOUT_BAPI_MAP2I_EXT_IN~MAP2I_EXTENSIONIN" However, I could not use the ch_header and ch_headerx in the method. Because MMPUR_OUTLINE_BAPI_TE_MEOUTHDR does not include my zz1 fields. I also tried to extend CI_EKKODB, but the extension caused dumps in the system.

I would be very thankful, if someone could give me a hint regarding my problem. Here are the steps I followed.

SELECT ebeln
    FROM ekko
    INTO CORRESPONDING FIELDS OF TABLE lt_contracts
    WHERE ebeln IN s_ebeln.


  LOOP AT lt_contracts ASSIGNING FIELD-SYMBOL(<ls_contracts>).
    CLEARls_ctrheader_ext,lt_extensionings_ekko.
    MOVE-CORRESPONDING ls_ekko_incl_eew_ps TO ls_ctrheader_ext.
    ls_ctrheader_ext-ebeln <ls_contracts>-ebeln.
    ls_ctrheader_ext-zz1_ab   so_ab-low.
    ls_ctrheader_ext-zz1_cd so_cd-low.
    ls_ctrheader_ext-zz1_ef p_ef.

    IF ls_ctrheader_ext IS NOT INITIAL.
      APPEND INITIAL LINE TO lt_extensionin ASSIGNING FIELD-SYMBOL(<ls_ext>).
      <ls_ext>-structure 'ZM04_E206_MASS_CHG'"BAPI_TE_MEOUTHEADER
   
      cl_abap_container_utilities=>fill_container_c(
        EXPORTING
          im_value               ls_ctrheader_ext            " Daten zum Füllen des Containers
        IMPORTING
          ex_container           <ls_ext>+30             " Container
        EXCEPTIONS
          illegal_parameter_type 1                " Unzulässiger Typ für den Parameter IM_VALUE
          OTHERS                 2    ).
    ENDIF.

 

<ls_ext>-valuepart1 = ls_ctrheader_ext-zz1_ab.

 <ls_ext>-valuepart1 = abap_true.

CALL FUNCTION 'BAPI_CONTRACT_CHANGE' "DESTINATION 'NONE'
      EXPORTING
        purchasingdocument = <ls_contracts>-ebeln
        header             = ls_header
        headerx            = ls_headerx
*       IMPORTING
*       EXP_HEADER         = ls_header_exp
      TABLES
        extensionin        = lt_extensionin
*       EXTENSIONOUT       =
        return             = lt_return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.

Accepted Solutions (0)

Answers (1)

Answers (1)

A_Ramesh
Explorer

This is old but adding information here because we went through the same.

The answer is in function module documentation for EXTENSIONIN parameter.

The fields added by Fiori Custom fields app are added to a different structure.

A_Ramesh_0-1740060088919.png

Example, to populate item customer fields

DATA: 
  lt_extensionin TYPE bapiparex_tab, 
  lt_ctitem_custfields TYPE STANDARD TABLE OF mmpur_oa_bapi_item_ext, 
  lwa_ctitem_custfields TYPE mmpur_oa_bapi_item_ext. 

* After filling LT_CTITEMCUSTFIELDS 

*Set data of item custom fields in extensionin 
TRY. 
  cl_cfd_bapi_mapping=>get_instance( )->map_to_bapiparex_multi( 
     EXPORTING ir_source_table = REF #( lt_poitem_custfields ) 
     CHANGING ct_bapiparex = lt_extensionin ). 
CATCH cx_cfd_bapi_mapping. 
  CLEAR lt_extensionin[]. 
ENDTRY.

Pass LT_EXTENSIONIN to the BAPI

 

FabioMendona
Discoverer
0 Likes
FabioMendona
Discoverer
0 Likes
Hello, I created a Custom Field using the Fiori Custom Fields app. It's located in the EKPO table, and I need to populate it when executing the BAPI BAPI_CONTRACT_CHANGE. I followed your example of populating it using the mmpur_oa_bapi_item_ext structure, but it didn't work. Do you know if it's necessary to implement any BADI so that the value of lt_extensionin is transferred to the correct Custom field in EKPO?
A_Ramesh
Explorer
0 Likes

@FabioMendona

Fabio,

We did this change for BAPI_PO_CHANGE

We did not implement any other BADIs or Exits, but, an existing user exit was posing a problem. EXIT_SAPMM06E_016

It was not a problem in ECC but in S4 it was. Had to add this as first block in user exit.

IF i_no_screen EQ abap_true "Called by Function ( BAPI )
   OR i_aktyp EQ 'A'.

  " This is being called by a Function module ( BAPI ) or Called in Dialog in Display mode
  " During display, data derivation should not happen

  ekpo_ci = CORRESPONDING ekpo_ci( i_ekpo ).

  RETURN.

ENDIF.