Skip to Content
Technical Articles

SAP IS-U (Abap): Add mobile phone number to the central data

Sometimes your client needs to add new functionality like add a unique 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 sy-tabix.
    
       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 = sy-tabix.
    
           READ TABLE gt_bapiadtelx INTO gv_bapiadtelx INDEX lv_tabix.
    
           gv_bapiadtelx-updateflag = '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 WHERE r_3_user = lv_type_1 OR r_3_user = lv_type_2.
           lv_tabix = sy-tabix.
    
           READ TABLE gt_bapiadtelx INTO gv_bapiadtelx INDEX lv_tabix.
    
           gv_bapiadtelx-updateflag = 'D'.
    
           MODIFY gt_bapiadtelx FROM gv_bapiadtelx INDEX lv_tabix.
         ENDLOOP.
    
         CLEAR gv_bapiadtel.
    
         gv_bapiadtel-country = 'DK'.
         gv_bapiadtel-countryiso = 'DK'.
         gv_bapiadtel-telephone = TELEPHONE NUMBER.
         gv_bapiadtel-tel_no(3) = '+45'.
         gv_bapiadtel-tel_no+3 = TELEPHONE NUMBER.
         gv_bapiadtel-caller_no = TELEPHONE NUMBER.
         gv_bapiadtel-extension = i_extens.
         gv_bapiadtel-std_no = 'X'.
         gv_bapiadtel-home_flag = 'X'.
         gv_bapiadtel-r_3_user = lv_type_1.
    
         APPEND gv_bapiadtel TO gt_bapiadtel.
    
         CLEAR gv_bapiadtelx.
    
         gv_bapiadtelx-updateflag = '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 sy-subrc = 0.
           e_rc = 8.
    
         ELSE.
           e_rc = 0.
    
         ENDIF.
       ENDIF.
    ENDFUNCTION.​
  2. and you can test by this:
      CALL FUNCTION 'ZISU_UPDATE_TELEPHONE'
        EXPORTING
          i_partner = 'BP Number'
          i_telnr   = 'SAMPLE 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

 

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