[ABAP] SAP: Terminverwaltung

Klassen

CL_APPOINTMENT (Termin der R/3 Terminverwaltung)
CL_ORGANIZER (Terminverwaltung: Oberfläche für die Terminanzeige)
CL_PLANNER (Terminverwaltung: Planungsoberfläche)
CL_RECA_WB_ORGANIZER (Terminkalender innerhalb der Workbench)
CL_CRM_DATES_ORGANIZER_UI (CRM Scheduler (Kalender und Taskliste))

Tabellen

SCAPPTTYPE (Terminart)
SCAPPT (benutzerspezifische Termine)
SCGENAPPT (generierte Termine (regelmäßige bzw. Gruppentermine))

Typgruppen

SCCON (Terminkalender: Definition von Konstanten)

Programme

RSSC_DEMO_CL_APPOINTMENT_SIMPL
RSSC_DEMO_CL_APPOINTMENT_PERIO
RSSC_DEMO_CL_APPOINTMENT_APPL
RSSC_DEMO_CL_APPOINTMENT
RSSC_DEMO_ICAL
RSSC_TEST_CL_APPOINTMENT_REPLY

Beispiel 1 (cl_reca_wb_organizer)

TRY.
    cl_reca_wb_organizer=>initialize( io_custom_control = cl_gui_container=>default_screen ).
    WRITE: / space.
  CATCH cx_root INTO DATA(e_ext).
ENDTRY.

Beispiel 2 (cl_appointment)

TRY.
    DATA(o_app) = NEW cl_appointment( ).

* Terminart
* siehe Tabelle SCAPPTTYPE (Terminart)
    o_app->set_type( 'MEETING' ).

* Organisator
    o_app->set_organizer( organizer = sy-uname ).

* Teilnehmer hinzufügen
    DATA: lv_part TYPE scspart.
    DATA: lv_address TYPE obj_record.
    lv_address-header = 'OBJH'.
    lv_address-type = 'SWO'.

    DATA: lv_err_msg TYPE swotreturn.

    CALL FUNCTION 'SWO_CREATE'
      EXPORTING
        objtype = 'ADDRESS'
        objkey  = space
      IMPORTING
        object  = lv_address-handle
        return  = lv_err_msg.

    DATA: lv_mail TYPE ad_smtpadr VALUE 'test@test.de'.
    DATA: it_address_container TYPE STANDARD TABLE OF swcont.

* Schreiben eines ABAP/4-Feldes in einen Container
    CALL FUNCTION 'SWC_ELEMENT_SET'
      EXPORTING
        element   = 'AddressString'
        field     = lv_mail
      TABLES
        container = it_address_container.

* Schreiben eines ABAP/4-Feldes in einen Container
    CALL FUNCTION 'SWC_ELEMENT_SET'
      EXPORTING
        element   = 'TypeId'
        field     = 'U'
      TABLES
        container = it_address_container.

* Buisness Objekt Metode aufrufen / Attribute setzen
    CALL FUNCTION 'SWO_INVOKE'
      EXPORTING
        access     = 'C'
        object     = lv_address-handle
        verb       = 'Create'
        persistent = ' '
      TABLES
        container  = it_address_container.

    DATA: lv_objkey TYPE swotobjid.
* Buisiness Objekt Superobjekttyp lesen
    CALL FUNCTION 'SWO_OBJECT_ID_GET'
      EXPORTING
        object = lv_address-handle
      IMPORTING
        objid  = lv_objkey.

    lv_part-objkey = lv_objkey-objkey.
    lv_part-objtype = lv_objkey-objtype.
    lv_part-comm_mode = 'INT'.
    lv_part-send_mail = sccon_part_sndmail_with_ans.

    o_app->add_participant( participant = lv_part ).

* Terminüberschrift / Subject
    DATA: lv_title TYPE sc_txtshor VALUE 'wichtiger Termin'.
    o_app->set_title( lv_title ).

* Ort / Locaton (max. 12 Zeichen --> ggf. noch im iCal-Text unter LOCATION: ersetzen)
    DATA: lv_loc TYPE sc_room VALUE 'Raum 100'.
    o_app->set_location( lv_loc ).
*    o_app->set_location_string( ).

* Zeitpunkt
    DATA(lv_date_from) = CONV sc_datefro( sy-datum ).
    DATA(lv_time_from) = sccon_00.
    DATA(lv_date_to) = CONV sc_dateto( '311299' ).
    DATA(lv_time_to) = sccon_235959.

    o_app->set_date( date_from = lv_date_from
                     date_to   = lv_date_to
                     time_from = lv_time_from
                     time_to   = lv_time_to ).

* Priorität
    o_app->set_priority( sccon_prio_very_high ).

* Status
    o_app->set_status( sccon_status_planned ).

* Anzeigeattribute
    o_app->set_view_attributes( show_on_top = abap_true ).

* Busy-Wert (frei, belegt, ...)
    o_app->set_busy_value( sccon_busy_busy ).

* Klassification (1=öffentlich, 2=privat, 3=geheim)
    o_app->set_classification( sccon_public ).

* Beschreibung
    DATA(it_body_text) = VALUE so_txttab( ( line = 'Text1' ) ( line = cl_abap_char_utilities=>cr_lf )
                                          ( line = 'Text2' ) ( line = cl_abap_char_utilities=>cr_lf )
                                          ( line = 'Text3' ) ).

    o_app->set_text( it_body_text ).

* Änderbarkeit (Berechtigung: 1= alle , 2 = nur Organisator)
    o_app->set_text_authority( '2' ).

* Termin auf der DB sichern
* Note:2413122-- save should only be done after BADI call.
    o_app->save( send_invitation = abap_false ). " Important to set this one to space. Otherwise SAP will send a not user-friendly e-mail

* Mailversand
    DATA(o_req) = o_app->create_send_request( ).
    DATA(o_rec) = cl_cam_address_bcs=>create_internet_address( lv_mail ).
    o_req->add_recipient( i_recipient = o_rec ).

    o_req->set_status_attributes( EXPORTING i_requested_status = 'N'    " Requested Status: N - Never
                                            i_status_mail      = 'N'    " Setting for Which Statuses Are Reported by Mail: N - Never
                                           ).

    o_req->set_send_immediately( abap_true ).

*    IF o_req->send( ) = abap_true.
*      COMMIT WORK AND WAIT.
*    ENDIF.

* iCal-Object holen
* hier ggf. 'METHOD:REQUEST' durch 'METHOD:PUBLISH' ersetzen
* hier ggf. 'LOCATION:' ersetzen mit längerem Raumnamen
    DATA(it_ical_soli_tab) = o_app->as_ical_object( ).

    cl_demo_output=>write_data( it_ical_soli_tab ).
    cl_demo_output=>display( ).

  CATCH cx_root INTO DATA(e_ext).
ENDTRY.

Links