Sometimes your client needs to add new functionality like add new mobile phone number to the BP data. You can do it like that:

  1. Create new FM

FUNCTION zisu_update_telephone.

*”———————————————————————-

*”*”Local Interface:

*”  IMPORTING

*”     VALUE(I_PARTNER) TYPE  BU_PARTNER

*”     VALUE(I_TELNR) TYPE  AD_TLNMBR

*”     VALUE(I_EXTENS) TYPE  AD_TLXTNS DEFAULT ‘ ‘

*”     VALUE(I_TYPE) TYPE  AD_FLGMOB DEFAULT ‘1’

*”     VALUE(I_NOCOMMIT) TYPE  NOCOMMIT OPTIONAL

*”     VALUE(I_WEB) TYPE  XFELD DEFAULT ‘ ‘

*”  EXPORTING

*”     VALUE(E_RC) TYPE  SUBRC

*”———————————————————————-

   DATA: lv_title(50) TYPE c.

   DATA: lv_return(10) TYPE c.

   DATA: lv_flag(2)    TYPE c.

   DATA: lv_tabix      TYPE sytabix.

   DATA: lt_sval TYPE TABLE OF sval WITH HEADER LINE.

   DATA: lv_type_1     TYPE ad_flgmob,

         lv_type_2     TYPE ad_flgmob.

   DATA: ls_std_address TYPE bapibus1006_address,

         lv_update     TYPE xfeld.

   REFRESH: gt_bapiadtel, gt_bapiadtelx, gt_bapiret2.

   CLEAR lv_update.

   IF i_type = ‘2’.

     i_type = ‘3’.

   ENDIF.

   IF i_type <> ‘3’.

     i_type = ‘1’.

   ENDIF.

   IF i_type = ‘1’.

     lv_type_1 = ‘1’.

     lv_type_2 = space.

   ELSEIF i_type = ‘3’.

     lv_type_1 = ‘3’.

     lv_type_2 = ‘2’.

   ENDIF.

   CALL FUNCTION ‘BAPI_BUPA_ADDRESS_GETDETAIL’

     EXPORTING

       businesspartner = i_partner

     IMPORTING

       addressdata     = ls_std_address

     TABLES

       bapiadtel       = gt_bapiadtel

       return          = gt_bapiret2.

   LOOP AT gt_bapiadtel INTO gv_bapiadtel.

     CLEAR gv_bapiadtelx.

     APPEND gv_bapiadtelx TO gt_bapiadtelx.

   ENDLOOP.

   IF i_telnr IS INITIAL AND i_web EQ ‘X’” delete all numbers of this type which we have on this BP  – only for self-service

     LOOP AT gt_bapiadtel INTO gv_bapiadtel

            WHERE r_3_user = lv_type_1

                OR r_3_user = lv_type_2.

       lv_tabix = sytabix.

       READ TABLE gt_bapiadtelx INTO gv_bapiadtelx INDEX lv_tabix.

       gv_bapiadtelxupdateflag = ‘D’.

       MODIFY gt_bapiadtelx FROM gv_bapiadtelx INDEX lv_tabix.

     ENDLOOP.

     lv_update = abap_true.

   ELSEIF i_telnr IS INITIAL AND i_web IS INITIAL.

     lv_update = abap_false.

   ELSE.

     LOOP AT gt_bapiadtel INTO gv_bapiadtel    “delete all primary/secondary mobile/landline numbers

           WHERE r_3_user = lv_type_1

              OR r_3_user = lv_type_2.

       lv_tabix = sytabix.

       READ TABLE gt_bapiadtelx INTO gv_bapiadtelx INDEX lv_tabix.

       gv_bapiadtelxupdateflag = ‘D’.

       MODIFY gt_bapiadtelx FROM gv_bapiadtelx INDEX lv_tabix.

     ENDLOOP.

     CLEAR gv_bapiadtel.

     gv_bapiadtelcountry = ‘DK’.

     gv_bapiadtelcountryiso = ‘DK’.

     gv_bapiadteltelephone = TELEPHONE NUMBER.

     gv_bapiadteltel_no(3) = ‘+45’.

     gv_bapiadteltel_no+3 = TELEPHONE NUMBER.

     gv_bapiadtelcaller_no = TELEPHONE NUMBER.

     gv_bapiadtelextension = i_extens.

     gv_bapiadtelstd_no = ‘X’.

     gv_bapiadtelhome_flag = ‘X’.

     gv_bapiadtelr_3_user = lv_type_1.

     APPEND gv_bapiadtel TO gt_bapiadtel.

     CLEAR gv_bapiadtelx.

     gv_bapiadtelxupdateflag = ‘I’.

     APPEND gv_bapiadtelx TO gt_bapiadtelx.

     lv_update = abap_true.

   ENDIF.

   IF lv_update EQ abap_true.

     CALL FUNCTION ‘BAPI_BUPA_ADDRESS_CHANGE’

       EXPORTING

         businesspartner = i_partner

         accept_error    = ‘X’

       TABLES

         bapiadtel       = gt_bapiadtel

         bapiadtel_x     = gt_bapiadtelx

         return          = gt_bapiret2.

     IF i_nocommit EQ ‘X’.

     ELSE.

       CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’

         EXPORTING

           wait          = ‘X’

*       IMPORTING

*         RETURN        =

               .

     ENDIF.

     LOOP AT gt_bapiret2 INTO gv_bapiret2

                 WHERE type = ‘E’ OR type = ‘A’.

       EXIT.

     ENDLOOP.

     IF sysubrc = 0.

       e_rc = 8.

     ELSE.

       e_rc = 0.

     ENDIF.

   ENDIF.

ENDFUNCTION.

  1. and you can test by this:

  CALL FUNCTION ‘ZISU_UPDATE_TELEPHONE’

    EXPORTING

      i_partner = bp number

      i_telnr   = TELEPHONE NUMBER

      i_type    = ‘3’.

i_type:

Telephone is Landline Telephone
1 Telephone is Default Under Landline Telephones
2 Telephone is Mobile Telephone but Not Default Mobile Phone
3 Telephone is Default Mobile Telephone
X Obsolete – No Longer Valid


To report this post you need to login first.

3 Comments

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

  1. Ricky Shaw

    Hi,

    Nice blog.

    But what’s challenging about it. Its a known fact that we can update mobile phone# using the BAPI_BUPA_ADDRESS_CHANGE.

    (0) 

Leave a Reply