Posted: Tue Feb 24, 2009 4:53 pm Post subject: Display Inbox Content
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
*----------------------------------------------*
* 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.
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.
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.