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

Display Inbox Content



 
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:53 pm    Post subject: Display Inbox Content Reply with quote

Description:
There is several folder in our workplace like inbox, outbox, private folder.
This simple program will display mail list in inbox folder.

Code:
*Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK blc01 WITH FRAME TITLE text-s10.
PARAMETERS: p_uname LIKE sy-uname OBLIGATORY DEFAULT sy-uname.
SELECTION-SCREEN END OF BLOCK blc01.
*---------------------------------------------------------------------*
*       CLASS Definition
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*class definition
CLASS lcl_main DEFINITION.
  PUBLIC SECTION.
    METHODS: display_inbox.
* DISPLAY_MAIL IMPORTING IM_MAILID TYPE STRING.
    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.
ENDCLASS. "lcl_main DEFINITION

*---------------------------------------------------------------------*
*       CLASS LCL_HANDLER DEFINITION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
CLASS lcl_handler DEFINITION.
  PUBLIC SECTION.
    METHODS handle_message
    FOR EVENT message OF lcl_main
    IMPORTING msg1 msg2 msg3 msg4.
ENDCLASS. "lcl_handler DEFINITION

*---------------------------------------------------------------------*
*       CLASS Implementation DEFINITION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*class implementation
CLASS lcl_main IMPLEMENTATION.
*----------------------------------------------*
* METHOD clear_data *
*----------------------------------------------*
  METHOD clear_data.
    CLEAR: user,
           udat,
           fdat,
           it_fdat[],
           wa_fdat,
           fold_id.
  ENDMETHOD. "clear_data

*----------------------------------------------*
* METHOD DISPLAY_INBOX *
*----------------------------------------------*
  METHOD display_inbox.
    CALL METHOD clear_data( ).
    CALL METHOD get_inbox_content( ).
    IF it_fdat[] IS INITIAL.
      RAISE EVENT message EXPORTING msg1 = 'No emails in this inbox'.
    ENDIF.

    ULINE AT (114).
    FORMAT COLOR COL_HEADING.
    WRITE: / '|' NO-GAP, (020) 'Object ID' LEFT-JUSTIFIED,
    '|' NO-GAP, (030) 'Subject' LEFT-JUSTIFIED,
    '|' NO-GAP, (015) 'Date Recieved' LEFT-JUSTIFIED,
    '|' NO-GAP, (040) 'Sender ' LEFT-JUSTIFIED,
    '|'.
    ULINE AT /(114).
    FORMAT COLOR OFF.

    LOOP AT it_fdat INTO wa_fdat.
      FORMAT COLOR COL_NORMAL INTENSIFIED ON.
      WRITE: / '|' NO-GAP, (020) wa_fdat-object_id UNDER 'Email ID'
      HOTSPOT ON,
      '|' NO-GAP, (030) wa_fdat-obj_descr LEFT-JUSTIFIED,
      '|' NO-GAP, (015) wa_fdat-rec_date LEFT-JUSTIFIED,
      '|' NO-GAP, (040) wa_fdat-send_fnam LEFT-JUSTIFIED,
      '|'.
    ENDLOOP.
    ULINE AT /(114).
  ENDMETHOD. "DISPLAY_INBOX

*----------------------------------------------*
* METHOD GET_INBOX_CONTENT *
*----------------------------------------------*
  METHOD get_inbox_content.
    MOVE p_uname TO user-sapname.
    CALL FUNCTION 'SO_USER_READ_API1'
    EXPORTING
    user = user
* prepare_for_folder_access = 'X'
    IMPORTING
    user_data = udat
    EXCEPTIONS
    user_not_exist = 1
    parameter_error = 2
    x_error = 3
    OTHERS = 4.

    IF sy-subrc NE 0.
      CASE sy-subrc.
        WHEN 1. msg1 = 'User Does not exist !'.
        WHEN 2. msg1 = 'Parameter Error !'.
        WHEN 3. msg1 = 'X Error!'.
        WHEN 4. msg1 = 'Others Error !'.
      ENDCASE.
      RAISE EVENT message EXPORTING msg1 = msg1.
    ENDIF.

* Select inbox folder
    MOVE udat-inboxfol TO fold_id.

    CALL FUNCTION 'SO_FOLDER_READ_API1'
         EXPORTING
              folder_id                  = fold_id
         IMPORTING
              folder_data                = fdat
         TABLES
              folder_content             = it_fdat
         EXCEPTIONS
              folder_not_exist           = 1
              operation_no_authorization = 2
              x_error                    = 3
              OTHERS                     = 4.

    IF sy-subrc NE 0.
      CASE sy-subrc.
        WHEN 1. msg1 = 'Folder Does not exist !'.
        WHEN 2. msg1 = 'No Authorization !'.
        WHEN 3. msg1 = 'X Error!'.
        WHEN 4. msg1 = 'Others Error !'.
      ENDCASE.
      RAISE EVENT message EXPORTING msg1 = msg1.
    ENDIF.

  ENDMETHOD. "GET_INBOX_CONTENT

ENDCLASS. "lcl_main IMPLEMENTATION

*---------------------------------------------------------------------*
*       CLASS LCL_HANDLER IMPLEMENTATION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
CLASS lcl_handler IMPLEMENTATION.

  METHOD handle_message .
    MESSAGE i398(00) WITH msg1 msg2 msg3 msg4.
    LEAVE LIST-PROCESSING..
  ENDMETHOD. "handle_message

ENDCLASS. "lcl_handler IMPLEMENTATION

*main program
START-OF-SELECTION.
  DATA: o_main TYPE REF TO lcl_main,
  o_handler TYPE REF TO lcl_handler.

  CREATE OBJECT: o_main, o_handler.
  SET HANDLER o_handler->handle_message FOR ALL INSTANCES.

  CALL METHOD o_main->display_inbox.
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.