SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Delete mail in SAP Inbox Folder



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования -> Mail
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Tue Feb 24, 2009 4:47 pm    Post subject: Delete mail in SAP Inbox Folder Reply with quote

This snippet code will show how to delete email from SAP Inbox Folder.
My previous program is display Inbox Folder content and display mail content. Now I add new delete mail function in my previous program.

Code:
*---------------------------------------------------------------------*
*       CLASS LCL_MAIN DEFINITION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*Class Definition
*Adding DELETE_MAIL method.
CLASS lcl_main DEFINITION.
  PUBLIC SECTION.
    METHODS: display_inbox,
    display_mail IMPORTING im_mailid TYPE string,
    delete_mail. " -- added code --
    EVENTS: message EXPORTING value(msg1) TYPE string
    value(msg2) TYPE string OPTIONAL
    value(msg3) TYPE string OPTIONAL
    value(msg4) TYPE string OPTIONAL.
  PRIVATE SECTION.
    METHODS: clear_data,
    get_inbox_content.
*---------------------------------
* L.O.C.A.L D.A.T.A.
*---------------------------------
    DATA: user TYPE soudnamei1,
    udat TYPE soudatai1,
    fdat TYPE sofoldati1,
    it_fdat TYPE TABLE OF sofolenti1,
    wa_fdat TYPE sofolenti1.

    DATA: msg1 TYPE string,
    msg2 TYPE string,
    msg3 TYPE string,
    msg4 TYPE string.

    DATA: fold_id TYPE soodk,
    mail_id TYPE soodk.

    DATA: wa_objcont TYPE soli,
    it_objcont TYPE TABLE OF soli,
    object_hd_display TYPE sood2.

ENDCLASS. "lcl_main DEFINITION

*delete_mail implementation
METHOD delete_mail.
  CALL FUNCTION 'SO_OBJECT_DELETE'
       EXPORTING
            folder_id                  = fold_id
            object_id                  = mail_id
            owner                      = p_uname
       EXCEPTIONS
            folder_not_empty           = 23
            folder_not_exist           = 14
            folder_no_authorization    = 15
            forwarder_not_exist        = 16
            object_not_exist           = 17
            object_no_authorization    = 18
            operation_no_authorization = 19
            OTHERS                     = 1000.


  IF sy-subrc NE 0.
    RAISE EVENT message EXPORTING msg1 = 'Error delete mail.'.
  ELSE.
    RAISE EVENT message EXPORTING msg1 = 'Email Deleted !'.
  ENDIF.
ENDMETHOD. "DELETE_MAIL
display_mail implementation
we have to change display_mail implementation by adding new delete icon
at the top of screen, so user can delete current mail.
METHOD display_mail.
  MOVE im_mailid TO mail_id.

  CALL FUNCTION 'SO_OBJECT_READ'
       EXPORTING
            folder_id                  = fold_id
            object_id                  = mail_id
            owner                      = p_uname
       IMPORTING
            object_hd_display          = object_hd_display
       TABLES
            objcont                    = it_objcont
       EXCEPTIONS
            active_user_not_exist      = 35
            communication_failure      = 71
            component_not_available    = 01
            folder_not_exist           = 06
            folder_no_authorization    = 05
            object_not_exist           = 14
            object_no_authorization    = 13
            operation_no_authorization = 21
            owner_not_exist            = 22
            parameter_error            = 23
            substitute_not_active      = 31
            substitute_not_defined     = 32
            system_failure             = 72
            x_error                    = 1000.

  IF sy-subrc NE 0.
    RAISE EVENT message EXPORTING msg1 = 'Error reading mail content'.
  ELSE.
    WRITE: icon_delete AS ICON HOTSPOT ON, " -- added code --
    'Delete this mail' HOTSPOT ON. " -- added code --

    FORMAT COLOR COL_HEADING.
    ULINE (259).
    WRITE: / '|',(255) object_hd_display-objdes LEFT-JUSTIFIED, '|'.
    ULINE (259).
    FORMAT COLOR OFF.

    LOOP AT it_objcont INTO wa_objcont.
      WRITE: / '|', wa_objcont-line, '|'.
    ENDLOOP.
    ULINE (259).
  ENDIF.

ENDMETHOD. "DISPLAY_MAIL

*at line selection
*to make user enable delete mail we need change at-line-selection code.
AT LINE-SELECTION.
  DATA mail_id TYPE string.

  IF sy-lisel(2) = '11'. "Icon Delete
    CALL METHOD o_main->delete_mail.
  ELSE.
    mail_id = sy-lisel+1(17).
    CALL METHOD o_main->display_mail( mail_id ).
  ENDIF.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования -> Mail All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.