Skip to Content

Issue:

In integration between GW and hana view, hana view will provide input parameter as filter for one field, normally the input parameter accept one value. Issue is how to handle the filter has multiple values. For example, we need to count customer age distribution based on multiple branches customer belongs to.

Solution:

1. AMDP:

Define/implement method in AMDP class.

agedistribution

        IMPORTING

          VALUE(branch)              TYPE string

        EXPORTING

          VALUE(et_agedistribution)  TYPE tt_output_agedistribution,

et_agedistribution = SELECT “AGE”, “AGERATE”

                         FROM “_SYS_BIC”.”ZOUI5_CV_CUSTOMERAGE_SQL”

                         (PLACEHOLDER.”$$ZBRANCH$$”=> :branch)

                         GROUP BY “AGE”, “AGERATE”, “ZCOUNT”;

2. ABAP Class:

Combine filters and call AMDP method

DATA lt_partner TYPE RANGE OF bu_partner.
DATA ls_partner LIKE LINE OF lt_partner.
DATA: o_cond       TYPE REF TO cl_lib_seltab,
h_handle    
TYPE REF TO cl_abap_tabledescr,
branch_cond
TYPE string.

ls_partner-sign = ‘I’.
ls_partner
option = ‘EQ’.
ls_partner
low = ‘1000000001’.
APPEND ls_partner TO lt_partner.

ls_partner-sign = ‘I’.
ls_partner
option = ‘EQ’.
ls_partner
low = ‘1000000002’.
APPEND ls_partner TO lt_partner.

CALL METHOD cl_lib_seltab=>new
EXPORTING
it_sel
= lt_partner
RECEIVING
rr_ref
= o_cond.

CALL METHOD o_cond->sql_where_condition
EXPORTING
iv_field
= ‘BRANCH’
RECEIVING
rv_cond 
= comm_bp_cond.
CONCATENATE ‘( ‘ branch_cond ‘ )’ INTO branch_cond.

Branch_cond is like below:

(BRANCH = ‘1000000001’ OR BRANCH = ‘1000000002’)

Call AMDP Class:

               TRY.
           cl_admp_customer
=>agedistribution(
               
EXPORTING
                     branch      
= branch_cond
               
IMPORTING
                     et_agedistribution  
= lt_agedistribution
          
).
          
CATCH cx_amdp_execution_failed INTO DATA(lxage).
       
ENDTRY.

3. Stored Procedure:

Update stored procedure of ‘ZOUI5_CV_CUSTOMERAGE_SQL’ to adopt filter

var_filter =

apply_filter(“_SYS_BIC”.”ZOUI5_CV_CUSTOMER”,:ZBRANCH)

;

var_int =

  select distinct

    BRANCH,

    CUSTOMER,

    AGE

  from

:var_filter;

Calculate Age distribution based on var_int.

Output is “AGE”, “AGERATE”

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply