cancel
Showing results for 
Search instead for 
Did you mean: 

Pass Dynamic Parameters to BADI

Former Member
0 Kudos


Hi Experts,

I have a logic script with a  SCOPE dimension that has a propery called "HCOMPANY" and the  values  needs to be passed to the BADI to make it dynamic.

Below is the logic script:

//*XDIM_MEMBERSET SCOPE = %SCOPE_SET%
//*SELECT (%HOLDING_COMPANY%,"[HCOMPANY]","SCOPE","[ID]='%SCOPE_SET'")

*START_BADI

QUERY = OFF
WRITE = ON

//HCOMPANY = %HOLDING_COMPANY%
*END_BADI

How could the BADi read the values coming from this dimension.

Could you suggest how this could be achieved....

Thanks for your help in advace.

Accepted Solutions (1)

Accepted Solutions (1)

former_member339201
Participant
0 Kudos

Hi,

you could use the following code to read your properties passed via logic script:

**************************

TYPES : BEGIN OF TY_WA,
ID TYPE UJ_DIM_MEMBER,  “ FOR DIMENSION MEMBERS
END OF TY_WA.

DATA : LS_PARAM         TYPE         UJK_S_SCRIPT_LOGIC_HASHENTRY,

            H_COMPANY TYPE STRING,   “ FOR RECEIVING PROPERTY VALUES IN STRING

IT_HCOMPANY TYPE TABLE OF TY_WA.  “ INTERNAL TABLE

LOOP AT IT_PARAM INTO LS_PARAM.  “ IN CASE IF YOU WISH TO PASS MORE THAN 1 “PARAMETERS VARIABLES. HERE IT IS JUST 1 PARAMETER (HCOMPANY) SO IT WILL RUN “JUST ONCE


CASE LS_PARAM-HASHKEY.    “ CASE ENDCASE ON HASH KEY

WHEN 'HCOMPANY'.        “ HCOMPANY IS THE KEY
 
IF LS_PARAM-HASHVALUE IS NOT INITIAL.
  H_COMPANY
= LS_PARAM-HASHVALUE. “ SERIES OF PROPERTY IN STRING   FORM  "SEPARATED BY COMMA

           SPLIT H_COMPANY AT ',' INTO TABLE IT_HCOMPANY. “ YOU GET YOUR  PROPERTY VALUES IN INTERNAL TABLE.

          ENDIF.

     ENDCASE.

  ENDLOOP.



Regards,

SHUBHAM

Answers (1)

Answers (1)

former_member186338
Active Contributor
0 Kudos

Hi,

You have 2 options:

1. The badi can read the scope set before the *START_BADI statement:

*XDIM_MEMBERSET XXXX=YYY

It's useful for the dimension members.

2. If you want to pass some non member value - like property, then simply define badi parameter and analyze it in the ABAP badi code.

*START_BADI

...

HCOMPANY = %HOLDING_COMPANY%

...

Where HCOMPANY is the badi parameter (read ANY document about custom logic badi creation - like help about badi Custom Logic and BADI - SAP Business Planning and Consolidation, version for SAP NetWeaver - SAP Lib...)

Vadim

P.S. Code in the sample:

...

READ TABLE it_param WITH KEY hashkey = 'YEAR' INTO ls_param.

IF sy-subrc NE 0.

l_log = 'You have not specified the parameter ''YEAR'' which is required.'.

cl_ujk_logger=>log( i_object = l_log ).

RAISE EXCEPTION TYPE cx_uj_custom_logic.

EXIT.

ENDIF.

l_year = ls_param-hashvalue.

...

Badi launch in the script:

*START_BADI DECD

QUERY = ON

WRITE = ON

YEAR = 1

PERCENTAGE = 10

*END_BADI

Instead of 1 some %VAR% can be used!

Former Member
0 Kudos

Hi Vadim,

I'm guessing for my scenario, SCOPE will replace YEAR.

Will the internal table l_SCOPE contain both the Dimension ID & Property values?

Thanks for your response in advance.

Former Member
0 Kudos

Nope, it will only contain the value you passing from logic script, if you want the property value then you need to read the master data of that dimension.

Andy

Former Member
0 Kudos

Could this logic below work for reading DIM member data:

Could you suggest whats the best method?

DATA:

      lv_appset_id             TYPE uj_appset_id VALUE 'Consolidation',
     lo_scope                   TYPE REF TO if_uja_dim_data,    

      ls_hier_info               TYPE uja_s_hier,
     lt_hier_name             TYPE uja_t_hier_name,

      ls_attr_list                 TYPE uja_s_attr,

      lt_attr_name_scope  TYPE uja_t_attr_name ,

      lr_data                       TYPE REF TO data.

FIELD-SYMBOLS:

      <lt_SCOPE>           TYPE HASHED TABLE,   

lo_scope = cl_uja_admin_mgr=>create_dim_ref( i_appset_id = lv_appset_id
                                                 i_dim_name = 'SCOPE' ).


former_member186338
Active Contributor
0 Kudos

Please, clearly specify your requirements!

What do you want to pass to the badi - member? member property? what for?

And what is the badi logic?

Vadim

P.S. There are different ways to achieve...