cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to use page attributes of a view in BSP_WD_CMPWB

ricky_shaw
Contributor
0 Kudos
391

Hi Experts,

I created a Z*enh for BP_ADDR using BSP_WD_CMPWB.

This is to default country & region value fields with 'US' during new BP creation in CRM Web UI for the first time.

I enhanced the STDAddress view.

I see a Z* Impl class & Context node classes also created.

I think i need to use Getter & Setter methods for STRUCT.COUNTRY & STRUCT.CITY to default the values.

Can any one suggest me how to do it?

Accepted Solutions (0)

Answers (3)

Answers (3)

ricky_shaw
Contributor
0 Kudos

Ok., I got this completed by generating the Setter & getter method page attributes and setting the returning value = 'X'.

ricky_shaw
Contributor
0 Kudos

Ok., I got this completed by generating the Setter & getter method page attributes and setting the returning value = 'X'.

FabianJoiris
Active Participant
0 Kudos

Hi Ricky,

This is not the best way to achieve your requirement.

You should rather use the Badi CRM_BP_UIU_DEFAULTS and implement method GET_DEFAULT_VALUES as follows:

  METHOD if_uiu_bp_defaults~get_default_values.

    DATA:
      lr_current        TYPE REF TO if_bol_bo_property_access,
      lr_typed_context  TYPE REF TO cl_bsp_wd_context,
      lr_node           TYPE REF TO cl_bsp_wd_context_node,
      lr_coll_wrapper   TYPE REF TO cl_bsp_wd_collection_wrapper.

    FIELD-SYMBOLS:
      <ls_typed_context> TYPE any,
      <ls_context_node>  TYPE any.

    ASSIGN cr_me->('TYPED_CONTEXT') TO <ls_typed_context>.
    IF sy-subrc = 0.
      lr_typed_context  ?= <ls_typed_context>.
      IF lr_typed_context IS BOUND.
        ASSIGN lr_typed_context->('STANDARDADDRESS') TO <ls_context_node>.
        IF sy-subrc = 0.
          TRY.
              lr_node            ?= <ls_context_node>.
            CATCH cx_sy_move_cast_error.  "EC_NOHANDLER
          ENDTRY.
          IF lr_node IS BOUND.
            lr_coll_wrapper ?= lr_node->collection_wrapper.
            IF lr_coll_wrapper IS BOUND.
              TRY.
                  lr_current ?= lr_coll_wrapper->get_current( ).
                  CHECK lr_current IS BOUND.
                  DATA : lv_country TYPE string.
                  lv_country =  lr_current->get_property_as_string( iv_attr_name = 'COUNTRY' ).
                  IF lv_country is INITIAL.
                  lr_current->set_property( iv_attr_name = 'COUNTRY' iv_value = 'US' ).
                  ENDIF.
                CATCH cx_sy_move_cast_error.
              ENDTRY.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDIF.

  ENDMETHOD.

Kind Regards,

Fabian

ricky_shaw
Contributor
0 Kudos

Thanks Fabian.

I implemented this BADi CRM_BP_UIU_DEFAULTS. But for me, its failing at this stmt.

lr_current ?= lr_coll_wrapper->get_current( ).

lr_current is always initial as its not getting current record.

Any other ways to handle this problem?

FabianJoiris
Active Participant
0 Kudos

What I can advice it that you maintain user parameter WCF_IGNORE_ENHANCEMT = A, and logon again to check if your issue is related to a specific enhancement

ricky_shaw
Contributor
0 Kudos

No that doesn't work.

I need to find a way to fill lr_current with something..

lr_current ?= lr_coll_wrapper->get_current( ).