cancel
Showing results for 
Search instead for 
Did you mean: 

BADI 'PARTNER_UPDATE not working from WEBUI

Former Member
0 Kudos

Hello All,

I have a requirement to update a Z field on save which is being added by AET in table BUT000.

I don't want to do it in WEBUI, I have tried BADI 'PARTNER_UPDATE,its working fine from tcode BP But not from WEBUI .

I tried following FM's but none of them is reflecting any change to Zfield.

BUPA_CENTRAL_CI_CHANGE

BUP_MEMORY_BUT000_FILL

'BUP_BUPA_UPDATE'

BUPA_GENERAL_UPDATE

Pls help me out!

Thanks much.

Priya.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Priya,

I am also paced with same problem, what was your solution ?

Regards
Chan

Former Member
0 Kudos

Hi Chan,

I would be happy to help you. please use the below code. In badi "BUPA_GENERAL_UPDATE" .

  FIELD-SYMBOLS :<fs>  TYPE ANY TABLE,

                             <fs2> TYPE bus000___i,

* business partners

  CALL FUNCTION 'BUPA_GENERAL_CALLBACK'

    TABLES

      et_but000_old = lt_but000_old

      et_but000_new = lt_but000_new

    EXCEPTIONS

      OTHERS        = 0.

  IF lt_but000_old IS NOT INITIAL.

    READ TABLE lt_but000_old ASSIGNING <ls_but000_old> INDEX 1.

    IF <ls_but000_old> IS ASSIGNED.

      ls_partner_guid = <ls_but000_old>-partner_guid.

      ls_partner = <ls_but000_old>-partner.

    ENDIF.

  ELSE.

    READ TABLE lt_but000_new ASSIGNING <ls_but000_new> INDEX 1.

    IF <ls_but000_new> IS ASSIGNED.

      ls_partner_guid = <ls_but000_new>-partner_guid.

      ls_partner = <ls_but000_new>-partner.

    ENDIF.

  ENDIF.

*.. GUI

  IF sy-tcode = 'BP'.

*.. Get Country

    CALL FUNCTION 'BUA_BUPA_MEMORY_ADDRESSES_GET'

      EXPORTING

        i_partner             = ls_partner

      TABLES

        t_address             = lt_address

      EXCEPTIONS

        partner_not_in_memory = 1

        no_address_found      = 2

        date_invalid          = 3

        OTHERS                = 4.

    CHECK sy-subrc = 0.

    READ TABLE lt_address INTO wa_address INDEX 1.

    SELECT SINGLE target1 INTO ls_zone FROM zcountry_zon_map

                          WHERE sour1_from = wa_address-country.

    CHECK sy-subrc = 0.

*.. GUI

  IF sy-tcode = 'BP'.

    ASSIGN ('(SAPLBUD0)MEM_BUT000[]') TO <fs>.

     IF <fs> IS ASSIGNED.

      LOOP AT  <fs> ASSIGNING <fs2>.

        IF <fs2> IS ASSIGNED.

          IF <fs2>-partner_guid = ls_partner_guid.

            <fs2>-zzafld000006 = ls_zone.

          ENDIF.

        ENDIF.

      ENDLOOP.

    ENDIF.

    UNASSIGN : <fs>, <fs2>.

*.. WEBUI

  ELSEIF sy-tcode IS INITIAL.

    IF lt_but020_old IS NOT INITIAL.

      READ TABLE lt_but020_old ASSIGNING <ls_but020_old> INDEX 1.

      IF <ls_but020_old> IS ASSIGNED.

        lv_adrnumber = <ls_but020_old>-addrnumber.

      ENDIF.

    ELSE.

      READ TABLE lt_but020_new ASSIGNING <ls_but020_new> INDEX 1.

      IF <ls_but020_new> IS ASSIGNED.

        lv_adrnumber = <ls_but020_new>-addrnumber.

      ENDIF.

    ENDIF.

*.. Country

    CALL FUNCTION 'BUPA_ADDRESS_GET_DETAIL'

      EXPORTING

        iv_partner_guid = ls_partner_guid

*        iv_addrnumber   = lv_adrnumber

      IMPORTING

        es_address      = ls_address.

    CHECK sy-subrc = 0.

*..Zone

    SELECT SINGLE target1 INTO ls_zone FROM zcountry_zon_map

                          WHERE sour1_from = ls_address-country.

    CHECK sy-subrc = 0.

    ASSIGN ('(SAPLBUD_MEM)gt_but000_mem[]') TO <fs>.

    IF <fs> IS ASSIGNED.

      LOOP AT  <fs> ASSIGNING <fs2>.

        IF <fs2> IS ASSIGNED.

          IF <fs2>-partner_guid = ls_partner_guid.

            <fs2>-zzafld000006 = ls_zone.

          ENDIF.

        ENDIF.

      ENDLOOP.

    ENDIF.

    UNASSIGN : <fs>, <fs2>.

  ENDIF.

Let me know in case o any questions.

Thanks,

Priya

Former Member
0 Kudos

Hi Priya,

Many thanks for your prompt response.  I would just like to check before I procedd further that the FM

CALL FUNCTION 'BUPA_GENERAL_CALLBACK' 

    TABLES

      et_but000_old = lt_but000_old

      et_but000_new = lt_but000_new

does return data in the lt_but000_old and lt_but000_new tables.  I had used this FM in PARTNER_UPDATE and these tables are empty when I save a BP via the CRM WEBUI. 

appreciate your feedback.

Regards

Chan

Former Member
0 Kudos

Yes this FM will return BUT000_old and BUT000_new tables surely in BADI "BUPA_GENERAL_UPDATE" just check it

Thanks,

Priya.

Former Member
0 Kudos

Hi Priya,

In th BADI BUPA_GENERAL UPDATE , there is an implementation

CMS_CM_BUPA_GENERAL   Business Partner Central Block, I set a break point in the Method CHANGE_BEFORE_UPDATE and made a chnage to a BP.  The breakpoint was triggered and when I checked the contents of the BUT000_xxx tables they were empty.

We are on CRM 2007, are you using this same version?

Please see code below in standard implementation.

method IF_EX_BUPA_GENERAL_UPDATE~CHANGE_BEFORE_UPDATE.

  DATA: lt_but000_old TYPE TABLE OF but000,
        lt_but000_new TYPE TABLE OF but000,
        lt_but000_td_new TYPE TABLE OF but000_td,
        lt_but000_td_old TYPE TABLE OF but000_td.

  CALL FUNCTION 'BUPA_GENERAL_CALLBACK' <---- BREAKPOINT HERE
    TABLES
      et_but000_old    = lt_but000_old                     <----   Empty
      et_but000_new    = lt_but000_new                  <------ Empty
*      et_but000_td_new = lt_but000_td_new
*      et_but000_td_old = lt_but000_td_old
            .

  IF lt_but000_new IS NOT INITIAL.
    CALL FUNCTION 'CMS_CM_BUPA_CBLOCK_SAVE'
      EXPORTING
        it_but000_old       =  lt_but000_old
        it_but000_new       =  lt_but000_new
              .
  ENDIF.
endmethod.

Regards
Chan

Former Member
0 Kudos

Hi Priya,

Got it to work... my mistake.  In order for the BUT000_xxx tables to be filled, a field related to this table, has to changed on the WEBUI.  Looks like you have to call the specific CALLBACK function depending on what data is changed.

Many thanks for your help.

Regards

Chan

Former Member
0 Kudos

Glad it worked for you.

Thanks,

Priya.