Skip to Content
avatar image
Former Member

Generating ADRNR for notification/equipment/functional location

Hello Experts,

I have developed a custom screen which gets called from Notification and there is option given to add/delete/update email address for objects (Notification/Equipment/Functional Locations).

But if there is no address saved before for any of these objects then ADRNR is not generated already. And in such case it gives dump. Any idea how this can be handled.

Anyone has any idea about generating ADRNR in background? If that is done then i can insert email address without any issue.

Please give your inputs...Thanks!!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Nov 28, 2017 at 12:36 PM
    -1

    Hello

    Please consider the use of FM "ADDR_INSERT" in combination with "ADDR_NUMBER_GET" to retrieve the number ...

    Below sample for adding an Address to PM-Notification :

      CALL FUNCTION 'ADDR_INSERT'
        EXPORTING
          address_data        = ls_address_data
          address_group       = 'PM01'
          address_handle      = 'QMEL                          TM0000000001QM'
          date_from           = '00010101'
          language            = sy-langu
          check_empty_address = abap_true
          check_address       = abap_true
        IMPORTING
          address_data        = ls_address_data
          returncode          = lv_returncode
        TABLES
          error_table         = lt_addr_error
        EXCEPTIONS
          address_exists      = 1
          parameter_error     = 2
          internal_error      = 3
          OTHERS              = 4.
    
    "Do Errorhandling ...
    "If need be, Use FM "ADDR_NUMBER_GET" to fetch the AddressNumber
    

    I trust you will be able to find other Samples for PM-Technical Objects ...

    Hope this helps

    Nic T.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 06, 2017 at 03:20 PM

    Below code resolved issue,

      DATA: lw_addr_c   TYPE szadr_addr1_complete,
            lw_addr_out TYPE szadr_addr1_complete,
            lw_addr_ref TYPE addr_ref,
            lw_adrc     TYPE adrc.
    
      DATA: lw_xaddr    TYPE adsmtp,
            lw_addrline TYPE szadr_adsmtp_line.
    
      DATA: lw_addr      TYPE addr1_data,
            lw_addrline1 TYPE szadr_addr1_line.
    
      DATA: lw_qmel  TYPE qmel,
            lw_vqmel TYPE viqmel,
            lw_equi  TYPE equi,
            lw_iflo2 TYPE iflot,
            lw_iflo1 TYPE iflot.
    
      DATA: ls_riqs5 TYPE riqs5.
      DATA: ls_vqmel TYPE viqmel.
      DATA: ls_qmel  TYPE qmel.
    
      DATA:lv_addrno     TYPE adrc-addrnumber,
           lv_retcode    TYPE szad_field-returncode,
           lv_updateflag TYPE szad_field-updateflag.
    
      IF i_noti IS NOT INITIAL.
        SELECT SINGLE * FROM qmel INTO lw_qmel WHERE qmnum = i_noti.
        IF sy-subrc = 0.
          lw_addr_ref-appl_table = 'QMEL'.
          lw_addr_ref-appl_field = 'QMNUM'.
          lw_addr_ref-owner      = 'X'.
          lw_addr_ref-addr_group = 'PM01'.
          lw_addr_ref-appl_key   = i_noti.
          lw_addr_c-addrhandle = lw_qmel-handle.
        ENDIF.
      ENDIF.
    
    * get name city etc details
      SELECT SINGLE * FROM adrc INTO lw_adrc WHERE addrnumber = i_adrnr.
      IF sy-subrc = 0.
        lw_addr-date_from   = '00010101'.
        lw_addr-date_to     = '99991231'.
        lw_addr-name1       = lw_adrc-name1.
        lw_addr-city1       = lw_adrc-city1.
        lw_addr-post_code1  = lw_adrc-post_code1.
        lw_addr-country     = lw_adrc-country.
        lw_addrline1-data   = lw_addr.
        APPEND lw_addrline1 TO lw_addr_c-addr1_tab.
      ENDIF.
    
      lw_xaddr-flgdefault = 'X'.
    *  lw_xaddr-home_flag  = 'X'.
      lw_xaddr-smtp_addr  = i_email.
      lw_xaddr-smtp_srch  = i_email.
      lw_xaddr-remark     = 'Notification Standard'.
      lw_xaddr-valid_from = '00010101'.
      lw_xaddr-updateflag = 'I'.
      lw_addrline-adsmtp  = lw_xaddr.
      APPEND lw_addrline TO lw_addr_c-adsmtp_tab.
    
      CALL FUNCTION 'ADDR_MAINTAIN_COMPLETE'
        EXPORTING
          updateflag               = 'I'
          addr1_complete           = lw_addr_c
          address_group            = 'PM01'
          substitute_all_comm_data = 'X'
          check_address            = ' '
    *     BLK_EXCPT                =
        IMPORTING
          returncode               = lv_retcode
          addr1_complete_out       = lw_addr_out
    *   TABLES
    *     ERROR_TABLE              =
        EXCEPTIONS
          parameter_error          = 1
          address_not_exist        = 2
          handle_exist             = 3
          internal_error           = 4
          address_blocked          = 5
          OTHERS                   = 6.
    
      IF  sy-subrc EQ 0.
    
        CALL FUNCTION 'ADDR_NUMBER_GET'
          EXPORTING
            address_handle           = lw_addr_c-addrhandle
            address_reference        = lw_addr_ref
          IMPORTING
            address_number           = lv_addrno
          EXCEPTIONS
            address_handle_not_exist = 1
            internal_error           = 2
            parameter_error          = 3
            OTHERS                   = 4.
    
        IF sy-subrc = 0.
    
          CALL FUNCTION 'ADDR_MEMORY_SAVE'
            EXPORTING
              execute_in_update_task = ' '
            EXCEPTIONS
              address_number_missing = 1
              person_number_missing  = 2
              internal_error         = 3
              database_error         = 4
              reference_missing      = 5
              OTHERS                 = 6.
          IF sy-subrc = 0.
            CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
          ENDIF.
    
    
          SELECT SINGLE * FROM viqmel INTO ls_vqmel WHERE qmnum = i_noti.
          IF sy-subrc = 0.
            MOVE-CORRESPONDING ls_vqmel TO ls_riqs5.
          ENDIF.
    
    
          IF lv_addrno IS NOT INITIAL.
            e_noti = lv_addrno.
            ls_riqs5-adrnr = lv_addrno.
          ENDIF.
    
          CALL FUNCTION 'IQS0_MODIFY_NOTIFICATION'
            EXPORTING
              i_qmnum       = i_noti
              i_riqs5_new   = ls_riqs5
    *         I_RESET       = 'X'
    *         P_HEAD_NOCHANGE       =
            IMPORTING
              e_viqmel      = ls_vqmel
            EXCEPTIONS
              show_messages = 1
              OTHERS        = 2.
    
          IF sy-subrc <> 0.
    * Implement suitable error handling here
          ENDIF.
    
          CALL FUNCTION 'IQS4_SAVE_NOTIFICATION'
            EXPORTING
              i_qmnum  = i_noti
              i_commit = 'X'
              i_wait   = 'X'
    *         I_REFRESH_COMPLETE       = 'X'
            IMPORTING
              e_viqmel = lw_vqmel.
        ENDIF.
      ENDIF.
    
    
    
    Add comment
    10|10000 characters needed characters exceeded