EventBridge Esempi di scheduler che utilizzano SDK per SAP ABAP - AWS SDK per SAP ABAP

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

EventBridge Esempi di scheduler che utilizzano SDK per SAP ABAP

I seguenti esempi di codice mostrano come eseguire azioni e implementare scenari comuni utilizzando l' AWS SDK per SAP ABAP con Scheduler. EventBridge

Le azioni sono estratti di codice da programmi più grandi e devono essere eseguite nel contesto. Sebbene le azioni mostrino come richiamare le singole funzioni del servizio, è possibile visualizzarle contestualizzate negli scenari correlati.

Ogni esempio include un link al codice sorgente completo, in cui vengono fornite le istruzioni su come configurare ed eseguire il codice nel contesto.

Argomenti

Azioni

Il seguente esempio di codice mostra come utilizzare. CreateSchedule

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. " Constants for time calculations DATA lv_start_date TYPE /aws1/scdstartdate. DATA lv_end_date TYPE /aws1/scdenddate. DATA lv_start_timestamp TYPE timestamp. DATA lv_end_timestamp TYPE timestamp. DATA lv_hours_to_run TYPE i VALUE 1. " Get current timestamp GET TIME STAMP FIELD lv_start_timestamp. " Add 1 hour to the current timestamp using CL_ABAP_TSTMP lv_end_timestamp = cl_abap_tstmp=>add( tstmp = lv_start_timestamp secs = lv_hours_to_run * 3600 ). " Convert timestamps to decimal format for AWS API lv_start_date = lv_start_timestamp. lv_end_date = lv_end_timestamp. " Prepare flexible time window configuration DATA lo_flexible_time_window TYPE REF TO /aws1/cl_scdflexibletimewindow. IF iv_use_flexible_time_win = abap_true. " iv_use_flexible_time_win = ABAP_TRUE " Example: Set MaximumWindowInMinutes to 10 for flexible window lo_flexible_time_window = NEW /aws1/cl_scdflexibletimewindow( iv_mode = 'FLEXIBLE' iv_maximumwindowinminutes = 10 ). ELSE. lo_flexible_time_window = NEW /aws1/cl_scdflexibletimewindow( iv_mode = 'OFF' ). ENDIF. " Prepare target configuration " Example iv_target_arn = 'arn:aws:sqs:us-east-1:123456789012:my-queue' " Example iv_role_arn = 'arn:aws:iam::123456789012:role/SchedulerRole' " Example iv_input = '{"message": "Hello from EventBridge Scheduler"}' DATA(lo_target) = NEW /aws1/cl_scdtarget( iv_arn = iv_target_arn iv_rolearn = iv_role_arn iv_input = iv_input ). " Set action after completion if needed DATA lv_action_after_completion TYPE /aws1/scdactionaftercompletion. IF iv_delete_after_completion = abap_true. " iv_delete_after_completion = ABAP_TRUE lv_action_after_completion = 'DELETE'. ELSE. lv_action_after_completion = 'NONE'. ENDIF. " Create the schedule " Example iv_name = 'my-schedule' " Example iv_schedule_expression = 'rate(15 minutes)' " Example iv_schedule_group_name = 'my-schedule-group' DATA(lo_result) = lo_scd->createschedule( iv_name = iv_name iv_scheduleexpression = iv_schedule_expression iv_groupname = iv_schedule_group_name io_target = lo_target io_flexibletimewindow = lo_flexible_time_window iv_startdate = lv_start_date iv_enddate = lv_end_date iv_actionaftercompletion = lv_action_after_completion ). ov_schedule_arn = lo_result->get_schedulearn( ). MESSAGE 'Schedule created successfully.' TYPE 'I'. CATCH /aws1/cx_scdconflictexception INTO DATA(lo_conflict_ex). DATA(lv_error) = |Conflict creating schedule: { lo_conflict_ex->if_message~get_text( ) }|. MESSAGE lv_error TYPE 'I'. CATCH /aws1/cx_rt_generic INTO DATA(lo_generic_ex). DATA(lv_generic_error) = |Error creating schedule: { lo_generic_ex->if_message~get_text( ) }|. MESSAGE lv_generic_error TYPE 'I'. ENDTRY.
  • Per i dettagli sulle API, CreateScheduleconsulta AWS SDK for SAP ABAP API reference.

Il seguente esempio di codice mostra come utilizzare. CreateScheduleGroup

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. " Example iv_name = 'my-schedule-group' DATA(lo_result) = lo_scd->createschedulegroup( iv_name = iv_name ). ov_schedule_group_arn = lo_result->get_schedulegrouparn( ). MESSAGE 'Schedule group created successfully.' TYPE 'I'. CATCH /aws1/cx_scdconflictexception INTO DATA(lo_conflict_ex). DATA(lv_error) = |Conflict creating schedule group: { lo_conflict_ex->if_message~get_text( ) }|. MESSAGE lv_error TYPE 'I'. CATCH /aws1/cx_rt_generic INTO DATA(lo_generic_ex). DATA(lv_generic_error) = |Error creating schedule group: { lo_generic_ex->if_message~get_text( ) }|. MESSAGE lv_generic_error TYPE 'I'. ENDTRY.

Il seguente esempio di codice mostra come utilizzare. DeleteSchedule

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. " Example iv_name = 'my-schedule' " Example iv_schedule_group_name = 'my-schedule-group' lo_scd->deleteschedule( iv_name = iv_name iv_groupname = iv_schedule_group_name ). MESSAGE 'Schedule deleted successfully.' TYPE 'I'. CATCH /aws1/cx_scdresourcenotfoundex INTO DATA(lo_not_found_ex). DATA(lv_error) = |Schedule not found: { lo_not_found_ex->if_message~get_text( ) }|. MESSAGE lv_error TYPE 'I'. CATCH /aws1/cx_rt_generic INTO DATA(lo_generic_ex). DATA(lv_generic_error) = |Error deleting schedule: { lo_generic_ex->if_message~get_text( ) }|. MESSAGE lv_generic_error TYPE 'I'. ENDTRY.
  • Per i dettagli sulle API, DeleteScheduleconsulta AWS SDK for SAP ABAP API reference.

Il seguente esempio di codice mostra come utilizzare. DeleteScheduleGroup

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. " Example iv_name = 'my-schedule-group' lo_scd->deleteschedulegroup( iv_name = iv_name ). MESSAGE 'Schedule group deleted successfully.' TYPE 'I'. CATCH /aws1/cx_scdresourcenotfoundex INTO DATA(lo_not_found_ex). DATA(lv_error) = |Schedule group not found: { lo_not_found_ex->if_message~get_text( ) }|. MESSAGE lv_error TYPE 'I'. CATCH /aws1/cx_rt_generic INTO DATA(lo_generic_ex). DATA(lv_generic_error) = |Error deleting schedule group: { lo_generic_ex->if_message~get_text( ) }|. MESSAGE lv_generic_error TYPE 'I'. ENDTRY.