Skip to Content

How BW Customer-Exit Variables are programmed? Usually it is a bunch of nested CASE, IF statements and lots I_T_VAR_RANGE parameter APPEND statements / assignments. Why you need to have tons of I_T_VAR_RANGE parameter APPEND / assignments all over your program code?

In my sample code below I assign I_T_VAR_RANGE parameter only once and code all logic in nested COND statements

METHOD if_rsroa_variables_exit_badi~process.

  TRY.
    c_t_range = COND #( WHEN i_step = 1
                        THEN COND #( WHEN i_vnam = 'AR_FY'
                                     THEN VALUE #( ( sign = 'I'
                                                     opt  = 'EQ'
                                                     low  = COND #( WHEN sy-datum+4(2) BETWEEN '01' AND '03' THEN CONV num4( sy-datum+0(4) - 1 )
                                                                    ELSE sy-datum+0(4) ) ) ) )
                       WHEN i_step = 2
                       THEN COND #( WHEN i_vnam CP 'AR_PSTNG_++'
                                    THEN VALUE #( ( sign = 'I'
                                                    opt  = 'LE'
                                                    low  = COND num6( WHEN i_vnam+9(2) BETWEEN '00' AND '09' THEN |{ i_t_var_range[ vnam = 'AR_FY' ]-low+0(4) }{ CONV num2( i_vnam+9(2) + 3 ) }|
                                                                      WHEN i_vnam+9(2) BETWEEN '10' AND '12' THEN |{ i_t_var_range[ vnam = 'AR_FY' ]-low+0(4) + 1 }{ CONV num2( i_vnam+9(2) - 9 ) }| ) ) )
                                    WHEN i_vnam CP 'AR_CLEAR_++'
                                    THEN VALUE #( ( sign = 'I'
                                                    opt  = 'GT'
                                                    low  =  COND dats( WHEN i_vnam+9(2) BETWEEN '00' AND '08' THEN |{ i_t_var_range[ vnam = 'AR_FY' ]-low+0(4) }{ CONV num2( i_vnam+9(2) + 4 ) }01|
                                                                       WHEN i_vnam+9(2) BETWEEN '09' AND '12' THEN |{ i_t_var_range[ vnam = 'AR_FY' ]-low+0(4) + 1 }{ CONV num2( i_vnam+9(2) - 8 ) }01|
                                                                       WHEN i_vnam+9(2) = '12' THEN || ) ) )
                                    WHEN i_vnam CP 'DD+++++++++'
                                    THEN VALUE #( ( sign = 'I'
                                                    opt  = 'BT'
                                                    low  = COND dats( WHEN i_vnam+7(3) = '999' THEN '00010101'
                                                                      ELSE CONV dats( COND d( WHEN i_vnam+2(2) BETWEEN '09' AND '12' THEN |{ i_t_var_range[ vnam = 'AR_FY' ]-low+0(4) + 1 }{ CONV num2( i_vnam+2(2) - 8 ) }01|
                                                                                      WHEN i_vnam+2(2) BETWEEN '00' AND '08' THEN |{ i_t_var_range[ vnam = 'AR_FY' ]-low+0(4) }{ CONV num2( i_vnam+2(2) + 4 ) }01| ) - i_vnam+7(3) ) )
                                                    high = CONV dats( COND d( WHEN i_vnam+2(2) BETWEEN '09' AND '12' THEN |{ i_t_var_range[ vnam = 'AR_FY' ]-low+0(4) + 1 }{ CONV num2( i_vnam+2(2) - 8 ) }01|
                                                                      WHEN i_vnam+2(2) BETWEEN '00' AND '08' THEN |{ i_t_var_range[ vnam = 'AR_FY' ]-low+0(4) }{ CONV num2( i_vnam+2(2) + 4 ) }01| ) - i_vnam+4(3) ) ) ) ) ).

  CATCH cx_sy_itab_line_not_found.
  ENDTRY.


ENDMETHOD.

Disclaimer: your ultimate goal is to make BW Customer-Exit Variable code more readable and maintainable. Getting all your BW Customer-exit Variables in one statement is secondary. Do not overdo with new ABAP expression syntax.

To report this post you need to login first.

2 Comments

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

  1. Akash Parikh

    Hi Uladzislau,

     

    Nice Blog.

     

    one question, i believe while creating customer exists using BADI, filter value is mandatory.

    so if you are embedding all variable code in one place, what you are using as your filter?

     

    Thanks.

    (0) 
    1. Uladzislau Pralat Post author

      Hi Akash,

      using InfoObject filter with BW Variable BADI is optional, but highly recommend. I have multiple BW Variable BADI implementations (common variables and per specific application area) and limit a scope of each implementation using InfoObject filter.

      Regards, Uladzislau

      (0) 

Leave a Reply