Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Contoh Amazon Redshift menggunakan SDK untuk SAP ABAP
Contoh kode berikut menunjukkan cara melakukan tindakan dan menerapkan skenario umum dengan menggunakan AWS SDK untuk SAP ABAP dengan Amazon Redshift.
Tindakan merupakan kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.
Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.
Topik
Tindakan
Contoh kode berikut menunjukkan cara menggunakanCreateCluster.
- SDK for SAP ABAP
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS
. Buat cluster.
TRY. " Example values: iv_cluster_identifier = 'my-redshift-cluster' " Example values: iv_node_type = 'ra3.4xlarge' " Example values: iv_master_username = 'awsuser' " Example values: iv_master_password = 'AwsUser1000' " Example values: iv_publicly_accessible = abap_true " Example values: iv_number_of_nodes = 2 oo_result = lo_rsh->createcluster( iv_clusteridentifier = iv_cluster_identifier iv_nodetype = iv_node_type iv_masterusername = iv_master_username iv_masteruserpassword = iv_master_password iv_publiclyaccessible = iv_publicly_accessible iv_numberofnodes = iv_number_of_nodes ). MESSAGE 'Redshift cluster created successfully.' TYPE 'I'. CATCH /aws1/cx_rshclustalrdyexfault. MESSAGE 'Cluster already exists.' TYPE 'I'. CATCH /aws1/cx_rshclstquotaexcdfault. MESSAGE 'Cluster quota exceeded.' TYPE 'I'. ENDTRY.-
Untuk detail API, lihat CreateClusterdi AWS SDK untuk referensi SAP ABAP API.
-
Contoh kode berikut menunjukkan cara menggunakanDeleteCluster.
- SDK for SAP ABAP
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS
. Hapus klaster .
TRY. " Example values: iv_cluster_identifier = 'my-redshift-cluster' lo_rsh->deletecluster( iv_clusteridentifier = iv_cluster_identifier iv_skipfinalclustersnapshot = abap_true ). MESSAGE 'Redshift cluster deleted successfully.' TYPE 'I'. CATCH /aws1/cx_rshclustnotfoundfault. MESSAGE 'Cluster not found.' TYPE 'I'. CATCH /aws1/cx_rshinvcluststatefault. MESSAGE 'Invalid cluster state for deletion.' TYPE 'I'. ENDTRY.-
Untuk detail API, lihat DeleteClusterdi AWS SDK untuk referensi SAP ABAP API.
-
Contoh kode berikut menunjukkan cara menggunakanDescribeClusters.
- SDK for SAP ABAP
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS
. Jelaskan cluster.
TRY. " Example values: iv_cluster_identifier = 'my-redshift-cluster' (optional) oo_result = lo_rsh->describeclusters( iv_clusteridentifier = iv_cluster_identifier ). lt_clusters = oo_result->get_clusters( ). lv_cluster_count = lines( lt_clusters ). MESSAGE |Retrieved { lv_cluster_count } cluster(s).| TYPE 'I'. CATCH /aws1/cx_rshclustnotfoundfault. MESSAGE 'Cluster not found.' TYPE 'I'. ENDTRY.-
Untuk detail API, lihat DescribeClustersdi AWS SDK untuk referensi SAP ABAP API.
-
Contoh kode berikut menunjukkan cara menggunakanDescribeStatement.
- SDK for SAP ABAP
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS
. TRY. " Example values: iv_statement_id = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' oo_result = lo_rsd->describestatement( iv_id = iv_statement_id ). lv_status = oo_result->get_status( ). MESSAGE |Statement status: { lv_status }| TYPE 'I'. CATCH /aws1/cx_rsdresourcenotfoundex. MESSAGE 'Statement not found.' TYPE 'I'. CATCH /aws1/cx_rsdinternalserverex. MESSAGE 'Internal server error.' TYPE 'I'. ENDTRY.-
Untuk detail API, lihat DescribeStatementdi AWS SDK untuk referensi SAP ABAP API.
-
Contoh kode berikut menunjukkan cara menggunakanExecuteStatement.
- SDK for SAP ABAP
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS
. TRY. " Example values: iv_cluster_identifier = 'redshift-cluster-movies' " Example values: iv_database_name = 'dev' " Example values: iv_user_name = 'awsuser' " Example values: iv_sql = 'SELECT * FROM movies WHERE year = :year' " Example values: it_parameter_list - SQL parameters for parameterized queries " Only pass parameters if the list is not empty IF it_parameter_list IS NOT INITIAL. oo_result = lo_rsd->executestatement( iv_clusteridentifier = iv_cluster_identifier iv_database = iv_database_name iv_dbuser = iv_user_name iv_sql = iv_sql it_parameters = it_parameter_list ). ELSE. oo_result = lo_rsd->executestatement( iv_clusteridentifier = iv_cluster_identifier iv_database = iv_database_name iv_dbuser = iv_user_name iv_sql = iv_sql ). ENDIF. lv_statement_id = oo_result->get_id( ). MESSAGE |Statement executed. ID: { lv_statement_id }| TYPE 'I'. CATCH /aws1/cx_rsdexecutestatementex. MESSAGE 'Statement execution error.' TYPE 'I'. CATCH /aws1/cx_rsdresourcenotfoundex. MESSAGE 'Resource not found.' TYPE 'I'. ENDTRY.-
Untuk detail API, lihat ExecuteStatementdi AWS SDK untuk referensi SAP ABAP API.
-
Contoh kode berikut menunjukkan cara menggunakanGetStatementResult.
- SDK for SAP ABAP
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS
. Periksa hasil pernyataan.
TRY. " Example values: iv_statement_id = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' " Handle pagination for large result sets DO. lo_result_page = lo_rsd->getstatementresult( iv_id = iv_statement_id iv_nexttoken = lv_next_token ). " Collect records from this page lt_page_records = lo_result_page->get_records( ). APPEND LINES OF lt_page_records TO lt_all_records. " Check if there are more pages lv_next_token = lo_result_page->get_nexttoken( ). IF lv_next_token IS INITIAL. EXIT. " No more pages ENDIF. ENDDO. " For the last call, set oo_result for return value oo_result = lo_result_page. lv_record_count = lines( lt_all_records ). MESSAGE |Retrieved { lv_record_count } record(s).| TYPE 'I'. CATCH /aws1/cx_rsdresourcenotfoundex. MESSAGE 'Statement not found or results not available.' TYPE 'I'. CATCH /aws1/cx_rsdinternalserverex. MESSAGE 'Internal server error.' TYPE 'I'. ENDTRY.-
Untuk detail API, lihat GetStatementResultdi AWS SDK untuk referensi SAP ABAP API.
-
Contoh kode berikut menunjukkan cara menggunakanListDatabases.
- SDK for SAP ABAP
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS
. TRY. " Example values: iv_cluster_identifier = 'redshift-cluster-movies' " Example values: iv_database_name = 'dev' " Example values: iv_database_user = 'awsuser' oo_result = lo_rsd->listdatabases( iv_clusteridentifier = iv_cluster_identifier iv_database = iv_database_name iv_dbuser = iv_database_user ). lt_databases = oo_result->get_databases( ). lv_db_count = lines( lt_databases ). MESSAGE |Retrieved { lv_db_count } database(s).| TYPE 'I'. CATCH /aws1/cx_rsddatabaseconnex. MESSAGE 'Database connection error.' TYPE 'I'. CATCH /aws1/cx_rsdresourcenotfoundex. MESSAGE 'Cluster not found.' TYPE 'I'. ENDTRY.-
Untuk detail API, lihat ListDatabasesdi AWS SDK untuk referensi SAP ABAP API.
-
Contoh kode berikut menunjukkan cara menggunakanModifyCluster.
- SDK for SAP ABAP
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS
. Memodifikasi cluster.
TRY. " Example values: iv_cluster_identifier = 'my-redshift-cluster' " Example values: iv_pref_maintenance_wn = 'wed:07:30-wed:08:00' lo_rsh->modifycluster( iv_clusteridentifier = iv_cluster_identifier iv_preferredmaintenancewin00 = iv_pref_maintenance_wn ). MESSAGE 'Redshift cluster modified successfully.' TYPE 'I'. CATCH /aws1/cx_rshclustnotfoundfault. MESSAGE 'Cluster not found.' TYPE 'I'. CATCH /aws1/cx_rshinvcluststatefault. MESSAGE 'Invalid cluster state for modification.' TYPE 'I'. ENDTRY.-
Untuk detail API, lihat ModifyClusterdi AWS SDK untuk referensi SAP ABAP API.
-