Há mais exemplos de AWS SDK disponíveis no repositório AWS Doc SDK Examples
As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.
AWS Glue exemplos usando o SDK para SAP ABAP
Os exemplos de código a seguir mostram como realizar ações e implementar cenários comuns usando o AWS SDK para SAP ABAP com. AWS Glue
Ações são trechos de código de programas maiores e devem ser executadas em contexto. Embora as ações mostrem como chamar perfis de serviço individuais, você pode ver as ações no contexto em seus cenários relacionados.
Cada exemplo inclui um link para o código-fonte completo, em que você pode encontrar instruções sobre como configurar e executar o código.
Tópicos
Ações
O código de exemplo a seguir mostra como usar CreateCrawler.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. 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.-
Para obter detalhes da API, consulte a CreateCrawlerreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar CreateJob.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. 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.-
Para obter detalhes da API, consulte a CreateJobreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar DeleteCrawler.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. 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.-
Para obter detalhes da API, consulte a DeleteCrawlerreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar DeleteDatabase.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. 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.-
Para obter detalhes da API, consulte a DeleteDatabasereferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar DeleteJob.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. 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.-
Para obter detalhes da API, consulte a DeleteJobreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar DeleteTable.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. 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.-
Para obter detalhes da API, consulte a DeleteTablereferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar GetCrawler.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. 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.-
Para obter detalhes da API, consulte a GetCrawlerreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar GetDatabase.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. 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.-
Para obter detalhes da API, consulte a GetDatabasereferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar GetJobRun.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. 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.-
Para obter detalhes da API, consulte a GetJobRunreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar GetJobRuns.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. 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.-
Para obter detalhes da API, consulte a GetJobRunsreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar GetTables.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. 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.-
Para obter detalhes da API, consulte a GetTablesreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar ListJobs.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. 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.-
Para obter detalhes da API, consulte a ListJobsreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar StartCrawler.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. 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.-
Para obter detalhes da API, consulte a StartCrawlerreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar StartJobRun.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. 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.-
Para obter detalhes da API, consulte a StartJobRunreferência da API AWS SDK for SAP ABAP.
-