It’s Friday. No mood to work… let’s invite her for tea! So what are the options to inform??
Shall I call her, shall I message her, shall I send her a meeting request??
After all I am a Techie guy..So I decided to write a report which sends a meeting request to her, instead of creating a normal meeting request in Microsoft outlook.
Mission: Send a meeting request before 5 pm asking her for Tea…
To help me in my Mission I have:
1…Class CL_APPOINTMENT (ECC 6.2) -> which helps to send a meeting request to outlook from SAP system.
2… OLE2_OBJECT ->Instead of informing users by normal message statement. Like MESSAGE ‘meeting request send’ type ‘I’.I wanted to make sap system to speak and tell me that .It’s like : Text to Voice conversion.
Let’s start with the Second part: TEXT to speech conversion. If you are not sure what is OLE, then let me tell you in short: it’s used to talk with presentation server. The ABAP processor normally buffers all successive OLE statements and sends them in a bundle to the presentation server and it will be executed there. Like: speech, excel integration etc…
In our example I created the object as below:
create object voice ‘SAPI.SpVoice’.
Check out the Below Source code: while execution enters the “meeting end time” less than meeting start time. A beautiful voice will read the error message for you.
(Create a Report in Se38 name: “ZTST_SCHEDULE_MEETING” and copy past below code)
*&---------------------------------------------------------------------*
*& Report ZTST_SCHEDULE_MEETING
*&
*&---------------------------------------------------------------------*
* copy the text elements
*P_DATE Date
*P_MEND Meeting End
*P_MNAME Meeting name
*P_MST Meeting Start
*&
*&---------------------------------------------------------------------*
report ztst_schedule_meeting.
tables : zmeetings.
include ole2incl.
parameters : p_mname type char20.
parameters : p_date type dats.
parameters : p_mst type sy-uzeit.
parameters : p_mend type sy-uzeit.
data : ole type ole2_object,
voice type ole2_object,
text type string.
data : lv_time type t.
at selection-screen.
create object voice 'SAPI.SpVoice'.
if p_mend < p_mst.
text = 'End Date should be less than start date of meeting.'.
call method of voice 'Speak' = ole
exporting #1 = text.
message 'End Date should be less than start date of meeting' type 'E'.
endif.
Well its 2:30 pm. I had just 2 and half hours left to send a meeting request. After searching on Google and SDN I got my final weapon “class CL_APPOINTMENT”.
Luckily my ERP system was ECC 6.2 and the below OSS notes where already installed (if not try installing it using SNOTE T code.
Number |
Short Text of Note |
1364539 |
Incorrect display of ICS documents |
1353329 |
iCalendar document that is sent is processed incorrectly |
1357483 |
Title of sent appointment is incorrect |
1369864 |
All‐Day Appointment doesn’t appear correctly in Outlook |
Finally, in few mins I was ready with my code: here is the final source code
(Replace the whole source code using below code now for already created report name: “ZTST_SCHEDULE_MEETING)
************************Send a meeting request****************************
*&---------------------------------------------------------------------*
*& Report ZTST_SCHEDULE_MEETING
*&
*&---------------------------------------------------------------------*
* copy the text elements
*P_DATE Date
*P_MEND Meeting End
*P_MNAME Meeting name
*P_MST Meeting Start
*&
*&---------------------------------------------------------------------*
REPORT ZTST_SCHEDULE_MEETING.
tables : zmeetings.
include ole2incl.
include <cntn01>.
type-pools: sccon.
PARAMETERS : p_mname type char40.
PARAMETERS : p_date type dats.
PARAMETERS : p_mst type sy-uzeit.
PARAMETERS : p_mend type sy-uzeit.
"Let's send a meeting request to someone
data: mail type text40.
* Provide select option to enter multiple attendees
SELECTION-SCREEN: BEGIN OF BLOCK org.
select-options: email for mail no intervals default 'raju.borda@sap.com'.
SELECTION-SCREEN: END OF BLOCK org.
data lo_appointment type ref to cl_appointment.
data ls_participant type scspart.
data lv_address type swc_object.
data ls_address_container like swcont occurs 0 with header line.
data lt_text type so_txttab.
data ls_text like line of lt_text.
data lv_location like scsappt-room.
data lo_send_request type ref to cl_bcs.
data lv_sent_to_all type os_boolean.
data : ole type ole2_object,
voice type ole2_object,
text type string.
DATA : LV_TIME TYPE T.
data : lv_title type SC_TXTSHOR.
at SELECTION-SCREEN.
create object voice 'SAPI.SpVoice'.
if p_mend < p_mst.
text = 'End Date should be less than start date of meeting.'.
call method of voice 'Speak' = ole
exporting #1 = text.
message 'End Date should be less than start date of meeting' type 'E'.
endif.
START-OF-SELECTION.
create object lo_appointment.
* Add multiple attendees
loop at email.
clear ls_participant.
swc_create_object lv_address 'ADDRESS' space.
swc_set_element ls_address_container 'AddressString' email-low.
swc_set_element ls_address_container 'TypeId' 'U'.
swc_call_method lv_address 'Create' ls_address_container.
check sy-subrc = 0.
* * get key and type of object
swc_get_object_key lv_address ls_participant-objkey.
check sy-subrc = 0.
swc_get_object_type lv_address ls_participant-objtype.
check sy-subrc = 0.
move sccon_part_sndmail_with_ans to ls_participant-send_mail.
ls_participant-comm_mode = 'INT'.
lo_appointment->add_participant( participant = ls_participant ).
endloop.
* Sample Apppointment for specific date/time
lo_appointment->set_date( date_from = p_date
time_from = p_mst
date_to = p_date
time_to = p_mend
).
* Make appointment appear "busy"
lo_appointment->set_busy_value( sccon_busy_busy ).
* Set Location
lo_appointment->set_location_string( 'Location' ).
* Set Organizer
lo_appointment->set_organizer( sy-uname ).
* "Type of Meeting" (value picked from table SCAPPTTYPE)
lo_appointment->set_type( 'ABSENT' ).
* Make this an all day event
lo_appointment->SET_VIEW_ATTRIBUTES( SHOW_ON_TOP = 'X').
* Set Meeting body text
ls_text = p_mname."'This is the Body Text of the Appointment'.
append ls_text to lt_text.
lv_title = p_mname.
lo_appointment->set_text( lt_text ).
* Set Meeting Subject
lo_appointment->set_title( lv_title ).
* Important to set this one to space. Otherwise SAP will send a not userfriendly e-mail
lo_appointment->save( send_invitation = space ).
* Now that we have the appointment, we can send a good one for outlook by sw
*itching to BCS
lo_send_request = lo_appointment->create_send_request( ).
* don't request read/delivery receipts
lo_send_request->set_status_attributes( i_requested_status = 'N'
i_status_mail = 'N'
).
* Send it to the world
lv_sent_to_all = lo_send_request->send( i_with_error_screen = 'X' ).
commit work and wait.
text = 'Meeting request has been Send Best of luck buddy.'.
call method of voice 'Speak' = ole
exporting #1 = text.
message 'Meeting request has been Send , Best of luck (*=*).' type 'I'.
**************************End of code ****************************
Do copy the text element from the comment section of the report to make it readable.
After execution you can see the information message. Also Text to Speech OLE method converts the message into speech so that you can hear it.
You can see the EMAIL (meeting Request) which is being sent to your Tea partner using Transaction code: SOST .Background job automatically picks the mail and send at regular interval but as I did not have time I Select the request and use Execute button above it to send it immediately.
Now you can see the meeting request in outlook.