Developer

Implementing a Filter for BUSINESSPARTNERS_GET_ENTITYSET

Implement the OData $filter system query option for BUSINESSPARTNERS_GET_ENTITYSET.

Procedure

  1. From the Class Builder screen for class ZCL_Z_EPM_RKT_DPC_EXT, open the implementation of the method BUSINESSPARTNERS_GET_ENTITYSET.
  2. Reimplement the method with the following code that filters before calling the BAPI_EPM_BP_GET_LIST BAPI function. New code is highlighted.
    method BUSINESSPARTNERS_GET_ENTITYSET.
    
      DATA:ls_filter_select_options   TYPE /iwbep/s_mgw_select_option,
           ls_mgw_select_options      TYPE /iwbep/s_mgw_select_option,
           ls_mgw_range_options       TYPE /iwbep/s_cod_select_option,
           ls_range_bpid              TYPE BAPI_EPM_BP_ID_RANGE,
           lt_range_bpid              TYPE TABLE OF BAPI_EPM_BP_ID_RANGE,
           ls_range_companyname       TYPE BAPI_EPM_COMPANY_NAME_RANGE,
           lt_range_companyname       TYPE TABLE OF BAPI_EPM_COMPANY_NAME_RANGE.
      DATA:lv_bpid_low(10)            TYPE N,
           lv_bpid_high(10)           TYPE N,
           ls_max_rows                TYPE BAPI_EPM_MAX_ROWS.
    
    * Process filters
      LOOP AT it_filter_select_options INTO ls_filter_select_options.
        LOOP AT ls_filter_select_options-select_options INTO ls_mgw_range_options.
          TRANSLATE ls_filter_select_options-property TO UPPER CASE.
          CASE ls_filter_select_options-property.
            WHEN 'BPID'.
              lv_bpid_low = ls_mgw_range_options-low.  "Workaround for adding leading zeros
              if ls_mgw_range_options-high is not initial.
                lv_bpid_high = ls_mgw_range_options-high.
              endif.
    
              MOVE-CORRESPONDING ls_mgw_range_options TO ls_range_bpid.
    
              ls_range_bpid-low = lv_bpid_low.
              if ls_range_bpid-high is not initial.
                ls_range_bpid-high = lv_bpid_high.
              endif.
    
              APPEND ls_range_bpid TO lt_range_bpid.
            WHEN 'COMPANYNAME'.
              MOVE-CORRESPONDING ls_mgw_range_options TO ls_range_companyname.
              APPEND ls_range_companyname TO lt_range_companyname.
          ENDCASE.
        ENDLOOP.
      ENDLOOP.
    
      ls_max_rows-bapimaxrow = is_paging-top.
    
      CALL FUNCTION 'BAPI_EPM_BP_GET_LIST'
       EXPORTING
         MAX_ROWS                  = ls_max_rows
       TABLES
         SELPARAMBPID              = lt_range_bpid
         SELPARAMCOMPANYNAME       = lt_range_companyname
         BPHEADERDATA              = et_entityset
    *     BPCONTACTDATA             =
    *     RETURN                    =
                .
    
    endmethod.
    
  3. Click the Activate icon.

  4. If you see any warnings, recheck the code, correct any mistakes, then click Activate again.
  5. Click Back to return to the Class Interface screen.