on 2011 Mar 03 1:04 PM
Hello all,
I am using BADI_CRM_BP_UIU_DEFAULTS and method IF_UIU_BP_DEFAULTS~GET_DEFAULT_VALUES to prefill several fields with default values, when creating a business partner or data belonging to the business partner.
Does anybody have a good way to check if the badi is entered in creation mode? (i currently check if the field i want to add the default value in is already filled, but this isn't bulletproof, because the user could have cleared the field) Obviously I don't want the values to be adjusted to default values when I enter the screens in change mode.
Regards,
Martijn.
Hi Martijn,
Try this code:
data: lr_typed_context type REF TO cl_bsp_wd_context,
lr_coll_wrapper TYPE REF TO CL_BSP_WD_COLLECTION_WRAPPER,
lr_node TYPE REF TO CL_BSP_WD_CONTEXT_NODE,
lv_account type string,
lr_current TYPE REF TO CL_BSP_WD_VALUE_NODE.
FIELD-SYMBOLS: <typed_context> TYPE ANY,
<context_node> TYPE ANY.
ASSIGN cr_me->('ZTYPED_CONTEXT') TO <typed_context>.
IF sy-subrc = 0.
TRY.
lr_typed_context ?= <typed_context>.
IF lr_typed_context IS BOUND.
ASSIGN lr_typed_context->('BUILHEADER') TO <context_node>.
IF sy-subrc = 0.
lr_node ?= <context_node>.
IF lr_node IS BOUND.
lr_coll_wrapper ?= lr_node->collection_wrapper.
IF lr_coll_wrapper IS BOUND.
lr_current ?= lr_coll_wrapper->get_current( ).
CHECK lr_current IS BOUND.
lv_account = lr_current->get_property_as_string( 'BP_GUID' ). or BP_NUMBER
ENDIF.
ENDIF.
ENDIF.
ENDIF.
CATCH cx_sy_move_cast_error.
CATCH cx_crm_cic_parameter_error.
ENDTRY.
ENDIF.
Now depending on your requirement you can decide if this is create mode. You can have your own criterion like if BP number is empty then its create or check if this BP number exist in BUT000 if it doesnt then its create as data is not yet commited to DB.
Please let me know if this helps.
Regards,
Bhushan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bushan,
Thanks for you response, but this is my current check. This only works for BP header data. If the bp already exists and i add for instance sales area data, i can't use such check.
I am looking more for some way to determine which event triggers the badi. For instance a NEW event or something similar.
Regards,
Martijn.
Hi Martijin,
See here you are getting BP data at runtime which is not yet reflected to database. So check if you get BP number, if you get it then check if this BP number is present in BUT000.
If this BP number that you are getting is not present in BUT000 then you can treat this as a create mode since every BP which is created will have its entry in BUT000.
There are other weird ways of doing this like setting some static variable when create button is triggered and then clearing it in this badi after reading the value. If this static variable is populated then treat this as create mode etc...But I would stick to checking entry in BUT000 ...
Hope this helps.
Regards,
Bhushan
User | Count |
---|---|
10 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.