View a markdown version of this page

AWS Glue esempi di utilizzo dell'SDK per SAP ABAP - AWS Esempi di codice SDK

Sono disponibili altri esempi di AWS SDK nel repository AWS Doc SDK Examples. GitHub

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à.

AWS Glue esempi di utilizzo dell'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. AWS Glue

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

L’esempio di codice seguente mostra come utilizzare CreateCrawler.

SDK per SAP ABAP
Nota

C'è altro su. GitHub Trova l’esempio completo e scopri di più sulla configurazione e l’esecuzione nel repository di esempi di codice AWS.

TRY. " iv_crawler_name = 'my-crawler' " iv_role_arn = 'arn:aws:iam::123456789012:role/AWSGlueServiceRole-Test' " iv_database_name = 'my-database' " iv_table_prefix = 'test_' " iv_s3_target = 's3://example-bucket/data/' DATA(lt_s3_targets) = VALUE /aws1/cl_glus3target=>tt_s3targetlist( ( NEW /aws1/cl_glus3target( iv_path = iv_s3_target ) ) ). DATA(lo_targets) = NEW /aws1/cl_glucrawlertargets( it_s3targets = lt_s3_targets ). lo_glu->createcrawler( iv_name = iv_crawler_name iv_role = iv_role_arn iv_databasename = iv_database_name iv_tableprefix = iv_table_prefix io_targets = lo_targets ). MESSAGE 'Crawler created successfully.' TYPE 'I'. CATCH /aws1/cx_glualreadyexistsex. MESSAGE 'Crawler already exists.' TYPE 'E'. CATCH /aws1/cx_gluinvalidinputex INTO DATA(lo_invalid_ex). DATA(lv_invalid_error) = lo_invalid_ex->if_message~get_longtext( ). MESSAGE lv_invalid_error TYPE 'E'. CATCH /aws1/cx_gluoperationtimeoutex INTO DATA(lo_timeout_ex). DATA(lv_timeout_error) = lo_timeout_ex->if_message~get_longtext( ). MESSAGE lv_timeout_error TYPE 'E'. CATCH /aws1/cx_gluresrcnumlmtexcdex INTO DATA(lo_limit_ex). DATA(lv_limit_error) = lo_limit_ex->if_message~get_longtext( ). MESSAGE lv_limit_error TYPE 'E'. ENDTRY.
  • Per i dettagli sulle API, consulta CreateCrawler la sezione AWS SDK for SAP ABAP API Reference.

L’esempio di codice seguente mostra come utilizzare CreateJob.

SDK per SAP ABAP
Nota

C'è altro su. GitHub Trova l’esempio completo e scopri di più sulla configurazione e l’esecuzione nel repository di esempi di codice AWS.

TRY. " iv_job_name = 'my-etl-job' " iv_description = 'ETL job for data transformation' " iv_role_arn = 'arn:aws:iam::123456789012:role/AWSGlueServiceRole-Test' " iv_script_location = 's3://example-bucket/scripts/my-script.py' DATA(lo_command) = NEW /aws1/cl_glujobcommand( iv_name = 'glueetl' iv_scriptlocation = iv_script_location iv_pythonversion = '3' ). lo_glu->createjob( iv_name = iv_job_name iv_description = iv_description iv_role = iv_role_arn io_command = lo_command iv_glueversion = '3.0' ). MESSAGE 'Job created successfully.' TYPE 'I'. CATCH /aws1/cx_glualreadyexistsex. MESSAGE 'Job already exists.' TYPE 'E'. CATCH /aws1/cx_gluinvalidinputex INTO DATA(lo_invalid_ex). DATA(lv_invalid_error) = lo_invalid_ex->if_message~get_longtext( ). MESSAGE lv_invalid_error TYPE 'E'. CATCH /aws1/cx_gluinternalserviceex INTO DATA(lo_internal_ex). DATA(lv_internal_error) = lo_internal_ex->if_message~get_longtext( ). MESSAGE lv_internal_error TYPE 'E'. CATCH /aws1/cx_gluoperationtimeoutex INTO DATA(lo_timeout_ex). DATA(lv_timeout_error) = lo_timeout_ex->if_message~get_longtext( ). MESSAGE lv_timeout_error TYPE 'E'. CATCH /aws1/cx_gluresrcnumlmtexcdex INTO DATA(lo_limit_ex). DATA(lv_limit_error) = lo_limit_ex->if_message~get_longtext( ). MESSAGE lv_limit_error TYPE 'E'. ENDTRY.
  • Per i dettagli sulle API, consulta CreateJob la sezione AWS SDK for SAP ABAP API Reference.

L’esempio di codice seguente mostra come utilizzare DeleteCrawler.

SDK per SAP ABAP
Nota

C'è altro su. GitHub Trova l’esempio completo e scopri di più sulla configurazione e l’esecuzione nel repository di esempi di codice AWS.

TRY. " iv_crawler_name = 'my-crawler' lo_glu->deletecrawler( iv_name = iv_crawler_name ). MESSAGE 'Crawler deleted successfully.' TYPE 'I'. CATCH /aws1/cx_glucrawlerrunningex. MESSAGE 'Crawler is currently running.' TYPE 'E'. CATCH /aws1/cx_gluentitynotfoundex. MESSAGE 'Crawler does not exist.' TYPE 'E'. CATCH /aws1/cx_gluoperationtimeoutex INTO DATA(lo_timeout_ex). DATA(lv_timeout_error) = lo_timeout_ex->if_message~get_longtext( ). MESSAGE lv_timeout_error TYPE 'E'. CATCH /aws1/cx_gluschdrtransingex. MESSAGE 'Scheduler is transitioning.' TYPE 'E'. ENDTRY.
  • Per i dettagli sulle API, consulta DeleteCrawler la sezione AWS SDK for SAP ABAP API Reference.

L’esempio di codice seguente mostra come utilizzare DeleteDatabase.

SDK per SAP ABAP
Nota

C'è altro su. GitHub Trova l’esempio completo e scopri di più sulla configurazione e l’esecuzione nel repository di esempi di codice AWS.

TRY. " iv_database_name = 'my-database' lo_glu->deletedatabase( iv_name = iv_database_name ). MESSAGE 'Database deleted successfully.' TYPE 'I'. CATCH /aws1/cx_gluentitynotfoundex. MESSAGE 'Database does not exist.' TYPE 'E'. CATCH /aws1/cx_gluinvalidinputex INTO DATA(lo_invalid_ex). DATA(lv_invalid_error) = lo_invalid_ex->if_message~get_longtext( ). MESSAGE lv_invalid_error TYPE 'E'. CATCH /aws1/cx_gluinternalserviceex INTO DATA(lo_internal_ex). DATA(lv_internal_error) = lo_internal_ex->if_message~get_longtext( ). MESSAGE lv_internal_error TYPE 'E'. CATCH /aws1/cx_gluoperationtimeoutex INTO DATA(lo_timeout_ex). DATA(lv_timeout_error) = lo_timeout_ex->if_message~get_longtext( ). MESSAGE lv_timeout_error TYPE 'E'. ENDTRY.
  • Per i dettagli sulle API, consulta DeleteDatabase la sezione AWS SDK for SAP ABAP API Reference.

L’esempio di codice seguente mostra come utilizzare DeleteJob.

SDK per SAP ABAP
Nota

C'è altro su. GitHub Trova l’esempio completo e scopri di più sulla configurazione e l’esecuzione nel repository di esempi di codice AWS.

TRY. " iv_job_name = 'my-etl-job' lo_glu->deletejob( iv_jobname = iv_job_name ). MESSAGE 'Job deleted successfully.' TYPE 'I'. CATCH /aws1/cx_gluinvalidinputex INTO DATA(lo_invalid_ex). DATA(lv_invalid_error) = lo_invalid_ex->if_message~get_longtext( ). MESSAGE lv_invalid_error TYPE 'E'. CATCH /aws1/cx_gluinternalserviceex INTO DATA(lo_internal_ex). DATA(lv_internal_error) = lo_internal_ex->if_message~get_longtext( ). MESSAGE lv_internal_error TYPE 'E'. CATCH /aws1/cx_gluoperationtimeoutex INTO DATA(lo_timeout_ex). DATA(lv_timeout_error) = lo_timeout_ex->if_message~get_longtext( ). MESSAGE lv_timeout_error TYPE 'E'. ENDTRY.
  • Per i dettagli sulle API, consulta DeleteJob la sezione AWS SDK for SAP ABAP API Reference.

L’esempio di codice seguente mostra come utilizzare DeleteTable.

SDK per SAP ABAP
Nota

C'è altro su. GitHub Trova l’esempio completo e scopri di più sulla configurazione e l’esecuzione nel repository di esempi di codice AWS.

TRY. " iv_database_name = 'my-database' " iv_table_name = 'my-table' lo_glu->deletetable( iv_databasename = iv_database_name iv_name = iv_table_name ). MESSAGE 'Table deleted successfully.' TYPE 'I'. CATCH /aws1/cx_gluentitynotfoundex. MESSAGE 'Table or database does not exist.' TYPE 'E'. CATCH /aws1/cx_gluinvalidinputex INTO DATA(lo_invalid_ex). DATA(lv_invalid_error) = lo_invalid_ex->if_message~get_longtext( ). MESSAGE lv_invalid_error TYPE 'E'. CATCH /aws1/cx_gluinternalserviceex INTO DATA(lo_internal_ex). DATA(lv_internal_error) = lo_internal_ex->if_message~get_longtext( ). MESSAGE lv_internal_error TYPE 'E'. CATCH /aws1/cx_gluoperationtimeoutex INTO DATA(lo_timeout_ex). DATA(lv_timeout_error) = lo_timeout_ex->if_message~get_longtext( ). MESSAGE lv_timeout_error TYPE 'E'. ENDTRY.
  • Per i dettagli sulle API, consulta DeleteTable la sezione AWS SDK for SAP ABAP API Reference.

L’esempio di codice seguente mostra come utilizzare GetCrawler.

SDK per SAP ABAP
Nota

C'è altro su. GitHub Trova l’esempio completo e scopri di più sulla configurazione e l’esecuzione nel repository di esempi di codice AWS.

TRY. " iv_crawler_name = 'my-crawler' oo_result = lo_glu->getcrawler( iv_name = iv_crawler_name ). DATA(lo_crawler) = oo_result->get_crawler( ). MESSAGE 'Crawler information retrieved.' TYPE 'I'. CATCH /aws1/cx_gluentitynotfoundex. MESSAGE 'Crawler does not exist.' TYPE 'I'. CATCH /aws1/cx_gluoperationtimeoutex INTO DATA(lo_timeout_ex). DATA(lv_timeout_error) = lo_timeout_ex->if_message~get_longtext( ). MESSAGE lv_timeout_error TYPE 'E'. ENDTRY.
  • Per i dettagli sulle API, consulta GetCrawler la sezione AWS SDK for SAP ABAP API Reference.

L’esempio di codice seguente mostra come utilizzare GetDatabase.

SDK per SAP ABAP
Nota

C'è altro su. GitHub Trova l’esempio completo e scopri di più sulla configurazione e l’esecuzione nel repository di esempi di codice AWS.

TRY. " iv_database_name = 'my-database' oo_result = lo_glu->getdatabase( iv_name = iv_database_name ). DATA(lo_database) = oo_result->get_database( ). MESSAGE 'Database information retrieved.' TYPE 'I'. CATCH /aws1/cx_gluentitynotfoundex. MESSAGE 'Database does not exist.' TYPE 'E'. CATCH /aws1/cx_gluinvalidinputex INTO DATA(lo_invalid_ex). DATA(lv_invalid_error) = lo_invalid_ex->if_message~get_longtext( ). MESSAGE lv_invalid_error TYPE 'E'. CATCH /aws1/cx_gluinternalserviceex INTO DATA(lo_internal_ex). DATA(lv_internal_error) = lo_internal_ex->if_message~get_longtext( ). MESSAGE lv_internal_error TYPE 'E'. CATCH /aws1/cx_gluoperationtimeoutex INTO DATA(lo_timeout_ex). DATA(lv_timeout_error) = lo_timeout_ex->if_message~get_longtext( ). MESSAGE lv_timeout_error TYPE 'E'. ENDTRY.
  • Per i dettagli sulle API, consulta GetDatabase la sezione AWS SDK for SAP ABAP API Reference.

L’esempio di codice seguente mostra come utilizzare GetJobRun.

SDK per SAP ABAP
Nota

C'è altro su. GitHub Trova l’esempio completo e scopri di più sulla configurazione e l’esecuzione nel repository di esempi di codice AWS.

TRY. " iv_job_name = 'my-etl-job' " iv_run_id = 'jr_abcd1234567890abcdef1234567890abcdef12345678' oo_result = lo_glu->getjobrun( iv_jobname = iv_job_name iv_runid = iv_run_id ). DATA(lo_job_run) = oo_result->get_jobrun( ). MESSAGE 'Job run information retrieved.' TYPE 'I'. CATCH /aws1/cx_gluentitynotfoundex. MESSAGE 'Job or job run does not exist.' TYPE 'E'. CATCH /aws1/cx_gluinvalidinputex INTO DATA(lo_invalid_ex). DATA(lv_invalid_error) = lo_invalid_ex->if_message~get_longtext( ). MESSAGE lv_invalid_error TYPE 'E'. CATCH /aws1/cx_gluinternalserviceex INTO DATA(lo_internal_ex). DATA(lv_internal_error) = lo_internal_ex->if_message~get_longtext( ). MESSAGE lv_internal_error TYPE 'E'. CATCH /aws1/cx_gluoperationtimeoutex INTO DATA(lo_timeout_ex). DATA(lv_timeout_error) = lo_timeout_ex->if_message~get_longtext( ). MESSAGE lv_timeout_error TYPE 'E'. ENDTRY.
  • Per i dettagli sulle API, consulta GetJobRun la sezione AWS SDK for SAP ABAP API Reference.

L’esempio di codice seguente mostra come utilizzare GetJobRuns.

SDK per SAP ABAP
Nota

C'è altro su. GitHub Trova l’esempio completo e scopri di più sulla configurazione e l’esecuzione nel repository di esempi di codice AWS.

TRY. " iv_job_name = 'my-etl-job' oo_result = lo_glu->getjobruns( iv_jobname = iv_job_name ). DATA(lt_job_runs) = oo_result->get_jobruns( ). MESSAGE 'Job runs retrieved successfully.' TYPE 'I'. CATCH /aws1/cx_gluentitynotfoundex. MESSAGE 'Job does not exist.' TYPE 'E'. CATCH /aws1/cx_gluinvalidinputex INTO DATA(lo_invalid_ex). DATA(lv_invalid_error) = lo_invalid_ex->if_message~get_longtext( ). MESSAGE lv_invalid_error TYPE 'E'. CATCH /aws1/cx_gluinternalserviceex INTO DATA(lo_internal_ex). DATA(lv_internal_error) = lo_internal_ex->if_message~get_longtext( ). MESSAGE lv_internal_error TYPE 'E'. CATCH /aws1/cx_gluoperationtimeoutex INTO DATA(lo_timeout_ex). DATA(lv_timeout_error) = lo_timeout_ex->if_message~get_longtext( ). MESSAGE lv_timeout_error TYPE 'E'. ENDTRY.
  • Per i dettagli sulle API, consulta GetJobRuns la sezione AWS SDK for SAP ABAP API Reference.

L’esempio di codice seguente mostra come utilizzare GetTables.

SDK per SAP ABAP
Nota

C'è altro su. GitHub Trova l’esempio completo e scopri di più sulla configurazione e l’esecuzione nel repository di esempi di codice AWS.

TRY. " iv_database_name = 'my-database' oo_result = lo_glu->gettables( iv_databasename = iv_database_name ). DATA(lt_tables) = oo_result->get_tablelist( ). MESSAGE 'Tables retrieved successfully.' TYPE 'I'. CATCH /aws1/cx_gluentitynotfoundex. MESSAGE 'Database does not exist.' TYPE 'E'. CATCH /aws1/cx_gluinvalidinputex INTO DATA(lo_invalid_ex). DATA(lv_invalid_error) = lo_invalid_ex->if_message~get_longtext( ). MESSAGE lv_invalid_error TYPE 'E'. CATCH /aws1/cx_gluinternalserviceex INTO DATA(lo_internal_ex). DATA(lv_internal_error) = lo_internal_ex->if_message~get_longtext( ). MESSAGE lv_internal_error TYPE 'E'. CATCH /aws1/cx_gluoperationtimeoutex INTO DATA(lo_timeout_ex). DATA(lv_timeout_error) = lo_timeout_ex->if_message~get_longtext( ). MESSAGE lv_timeout_error TYPE 'E'. ENDTRY.
  • Per i dettagli sulle API, consulta GetTables la sezione AWS SDK for SAP ABAP API Reference.

L’esempio di codice seguente mostra come utilizzare ListJobs.

SDK per SAP ABAP
Nota

C'è altro su. GitHub Trova l’esempio completo e scopri di più sulla configurazione e l’esecuzione nel repository di esempi di codice AWS.

TRY. oo_result = lo_glu->listjobs( ). DATA(lt_job_names) = oo_result->get_jobnames( ). MESSAGE 'Job list retrieved successfully.' TYPE 'I'. CATCH /aws1/cx_gluentitynotfoundex. MESSAGE 'No jobs found.' TYPE 'I'. CATCH /aws1/cx_gluinvalidinputex INTO DATA(lo_invalid_ex). DATA(lv_invalid_error) = lo_invalid_ex->if_message~get_longtext( ). MESSAGE lv_invalid_error TYPE 'E'. CATCH /aws1/cx_gluinternalserviceex INTO DATA(lo_internal_ex). DATA(lv_internal_error) = lo_internal_ex->if_message~get_longtext( ). MESSAGE lv_internal_error TYPE 'E'. CATCH /aws1/cx_gluoperationtimeoutex INTO DATA(lo_timeout_ex). DATA(lv_timeout_error) = lo_timeout_ex->if_message~get_longtext( ). MESSAGE lv_timeout_error TYPE 'E'. ENDTRY.
  • Per i dettagli sulle API, consulta ListJobs la sezione AWS SDK for SAP ABAP API Reference.

L’esempio di codice seguente mostra come utilizzare StartCrawler.

SDK per SAP ABAP
Nota

C'è altro su. GitHub Trova l’esempio completo e scopri di più sulla configurazione e l’esecuzione nel repository di esempi di codice AWS.

TRY. " iv_crawler_name = 'my-crawler' lo_glu->startcrawler( iv_name = iv_crawler_name ). MESSAGE 'Crawler started successfully.' TYPE 'I'. CATCH /aws1/cx_glucrawlerrunningex. MESSAGE 'Crawler is already running.' TYPE 'I'. CATCH /aws1/cx_gluentitynotfoundex. MESSAGE 'Crawler does not exist.' TYPE 'E'. CATCH /aws1/cx_gluoperationtimeoutex INTO DATA(lo_timeout_ex). DATA(lv_timeout_error) = lo_timeout_ex->if_message~get_longtext( ). MESSAGE lv_timeout_error TYPE 'E'. ENDTRY.
  • Per i dettagli sulle API, consulta StartCrawler la sezione AWS SDK for SAP ABAP API Reference.

L’esempio di codice seguente mostra come utilizzare StartJobRun.

SDK per SAP ABAP
Nota

C'è altro su. GitHub Trova l’esempio completo e scopri di più sulla configurazione e l’esecuzione nel repository di esempi di codice AWS.

TRY. " iv_job_name = 'my-etl-job' " iv_input_database = 'my-database' " iv_input_table = 'my-table' " iv_output_bucket_url = 's3://example-output-bucket/' DATA lt_arguments TYPE /aws1/cl_glugenericmap_w=>tt_genericmap. lt_arguments = VALUE #( ( VALUE /aws1/cl_glugenericmap_w=>ts_genericmap_maprow( key = '--input_database' value = NEW /aws1/cl_glugenericmap_w( iv_value = iv_input_database ) ) ) ( VALUE /aws1/cl_glugenericmap_w=>ts_genericmap_maprow( key = '--input_table' value = NEW /aws1/cl_glugenericmap_w( iv_value = iv_input_table ) ) ) ( VALUE /aws1/cl_glugenericmap_w=>ts_genericmap_maprow( key = '--output_bucket_url' value = NEW /aws1/cl_glugenericmap_w( iv_value = iv_output_bucket_url ) ) ) ). DATA(oo_result) = lo_glu->startjobrun( iv_jobname = iv_job_name it_arguments = lt_arguments ). ov_job_run_id = oo_result->get_jobrunid( ). MESSAGE 'Job run started successfully.' TYPE 'I'. CATCH /aws1/cx_gluconcurrentrunsex00. MESSAGE 'Maximum concurrent runs exceeded.' TYPE 'E'. CATCH /aws1/cx_gluentitynotfoundex. MESSAGE 'Job does not exist.' TYPE 'E'. CATCH /aws1/cx_gluinvalidinputex INTO DATA(lo_invalid_ex). DATA(lv_invalid_error) = lo_invalid_ex->if_message~get_longtext( ). MESSAGE lv_invalid_error TYPE 'E'. CATCH /aws1/cx_gluinternalserviceex INTO DATA(lo_internal_ex). DATA(lv_internal_error) = lo_internal_ex->if_message~get_longtext( ). MESSAGE lv_internal_error TYPE 'E'. CATCH /aws1/cx_gluoperationtimeoutex INTO DATA(lo_timeout_ex). DATA(lv_timeout_error) = lo_timeout_ex->if_message~get_longtext( ). MESSAGE lv_timeout_error TYPE 'E'. CATCH /aws1/cx_gluresrcnumlmtexcdex INTO DATA(lo_limit_ex). DATA(lv_limit_error) = lo_limit_ex->if_message~get_longtext( ). MESSAGE lv_limit_error TYPE 'E'. ENDTRY.
  • Per i dettagli sulle API, consulta StartJobRun la sezione AWS SDK for SAP ABAP API Reference.