Skip to Content
Technical Articles
Author's profile photo sakshi sawhney

End to End : Step by Step CFL enablement of Custom Fields of EBAN , EKPO Table – Part 4

In our previous blogs we created CFL enabled custom fields.

Refer blog: “How to prepare and enable your existing custom fields in tables EBAN and EKPO and show on GUI” before going through below for better understanding.

Here we will see – “How to enable BAPI to update the custom fields”.

BAPI to be enabled – ‘BAPI_PO_CREATE1’

Please note: Depending on your Business Context , you may also get option to enable usage of custom fields in BAPI on CFL app itself. However, this option was not available for Business Context: Procurement.

Let’s Begin –

Step 1. Create the append structure in the Extension structures: BAPI_TE_MEPOITEM and BAPI_TE_MEPOITEMX. The append structures hold the custom fields created in previous blog:  Refer below screenshots for clarity

 

Step 2. From here, we have 2 options, in our case we went ahead with option 1 , as there were challenges faced for contract update BAPI (can detail the challenges on request 😊):

Option 1: Create a dummy field in CI_EKKODB and CI_EKKODBX. Refer above screenshots. By this approach no code was needed, and functionality worked by populating the extensions structure during PO creation. Please be aware this may or may not work with further release, however Option 2 will work in all cases

Option 2 : BADI : ME_BAPI_PO_CUST implementation.

Method Implemented: EXTENSIONIN 

Code Snippet for reference:

  CONSTANTS : lc_ext  TYPE te_struc VALUE 'BAPI_TE_MEPOITEM',
              lc_extx TYPE te_struc VALUE 'BAPI_TE_MEPOITEMX'.

  DATA : ls_ext  TYPE bapi_te_mepoitem,
         ls_extx TYPE bapi_te_mepoitemx.

* get codepage handler
  DATA(lo_parex) = cl_mmpur_bapi_po=>get_codepage_handler( ).
*  perform conversion from container to structure
  IF poitem IS SUPPLIED AND poitem-ebelp IS NOT INITIAL.
    LOOP AT extensionin REFERENCE INTO DATA(lr_parex).
      CLEAR ls_ext.
      CHECK lr_parex->structure EQ lc_ext.
      TRY.
          lo_parex->cont_to_struc( EXPORTING cont  = lr_parex->*+30
                                             langu = sy-langu
                                   IMPORTING struc = ls_ext ).
          CHECK poitem-ebelp EQ ls_ext-po_item.
* Fill the custom fields :
          poitem-<fieldname> = ls_ext-<fieldname>.
               EXIT.
        CATCH cx_sy_conversion_codepage.
          CONTINUE.
        CATCH cx_parameter_invalid_range.
          CONTINUE.
      ENDTRY.
    ENDLOOP.
  ENDIF.

  IF poitemx IS SUPPLIED AND poitemx-ebelp_key IS NOT INITIAL.
    LOOP AT extensionin REFERENCE INTO lr_parex.
      CLEAR ls_extx.
      CHECK lr_parex->structure EQ lc_extx.
      TRY.
          lo_parex->cont_to_struc( EXPORTING cont  = lr_parex->*+30
                                             langu = sy-langu
                                   IMPORTING struc = ls_extx ).
          CHECK poitemx-ebelp_key EQ ls_extx-po_item.

* Fill the custom fields X flags :
          poitemx-<fieldname> = ls_extx-<fieldname>.
          EXIT.
        CATCH cx_sy_conversion_codepage.
          CONTINUE.
        CATCH cx_parameter_invalid_range.
          CONTINUE.
      ENDTRY.
    ENDLOOP.
  ENDIF.

 

 

Hope , it was helpful. Suggestions and questions are welcome !! 😊

Thank you !

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Muhammed Abdelaziz
      Muhammed Abdelaziz

      Hi Sakshi ,
      really good example  many thanks , but am facing problem using the code as the below cod the type expected by the method is clike which is not as the type used for ls_ext ? do you know a quick way to fix this ?

      lo_parex->cont_to_struc( EXPORTING cont  = lr_parex->*+30
                                                   langu = sy-langu
                                         IMPORTING struc = ls_ext ).
      Author's profile photo chandra shekar Dasari
      chandra shekar Dasari

      Hi Sakshi,

       

      Appreciate your time & patience in publishing excellent & step2 step blogs.

      Cheers  - Keep going...