AWSSDK を使用して Amazon Textract ドキュメント分析を始めましょう - AWSSDK コードサンプル

AWSDocAWS SDKGitHub サンプルリポジトリには、さらに多くの SDK サンプルがあります

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

AWSSDK を使用して Amazon Textract ドキュメント分析を始めましょう

次のコード例は、以下の操作方法を示しています。

  • 非同期分析を開始します。

  • 文書分析を取得します。

SAP ABAP
SDK for SAP ABAP
注記

これはデベロッパープレビューリリースの SDK に関するドキュメントです。SDK は変更される場合があるため、本稼働環境での使用はお勧めできません。

注記

他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

DATA lo_documentlocation TYPE REF TO /aws1/cl_texdocumentlocation. DATA lo_s3object TYPE REF TO /aws1/cl_texs3object. DATA lo_featuretypes TYPE REF TO /aws1/cl_texfeaturetypes_w. DATA lt_featuretypes TYPE /aws1/cl_texfeaturetypes_w=>tt_featuretypes. "Create ABAP objects for feature type." "Add TABLES to return information about the tables." "Add FORMS to return detected form data." "To perform both types of analysis, add TABLES and FORMS to FeatureTypes." CREATE OBJECT lo_featuretypes EXPORTING iv_value = 'FORMS'. INSERT lo_featuretypes INTO TABLE lt_featuretypes. CREATE OBJECT lo_featuretypes EXPORTING iv_value = 'TABLES'. INSERT lo_featuretypes INTO TABLE lt_featuretypes. "Create an ABAP object for the Amazon Simple Storage Service (Amazon S3) object." CREATE OBJECT lo_s3object EXPORTING iv_bucket = iv_s3bucket iv_name = iv_s3object. "Create an ABAP object for the document." CREATE OBJECT lo_documentlocation EXPORTING io_s3object = lo_s3object. "Start document analysis." TRY. DATA(lo_start_result) = lo_tex->startdocumentanalysis( EXPORTING io_documentlocation = lo_documentlocation it_featuretypes = lt_featuretypes ). MESSAGE 'Document analysis started.' TYPE 'I'. CATCH /aws1/cx_texaccessdeniedex . MESSAGE 'You do not have permission to perform this action.' TYPE 'E'. CATCH /aws1/cx_texbaddocumentex . MESSAGE 'Amazon Textract is not able to read the document.' TYPE 'E'. CATCH /aws1/cx_texdocumenttoolargeex . MESSAGE 'The document is too large.' TYPE 'E'. CATCH /aws1/cx_texidempotentprmmis00 . MESSAGE 'Idempotent parameter mismatch exception.' TYPE 'E'. CATCH /aws1/cx_texinternalservererr . MESSAGE 'Internal server error.' TYPE 'E'. CATCH /aws1/cx_texinvalidkmskeyex . MESSAGE 'AWS KMS key isn't valid.' TYPE 'E'. CATCH /aws1/cx_texinvalidparameterex . MESSAGE 'Request has non-valid parameters.' TYPE 'E'. CATCH /aws1/cx_texinvalids3objectex . MESSAGE 'Amazon S3 object isn't valid.' TYPE 'E'. CATCH /aws1/cx_texlimitexceededex . MESSAGE 'An Amazon Textract service limit was exceeded.' TYPE 'E'. CATCH /aws1/cx_texprovthruputexcdex . MESSAGE 'Provisioned throughput exceeded limit.' TYPE 'E'. CATCH /aws1/cx_texthrottlingex . MESSAGE 'The request processing exceeded the limit.' TYPE 'E'. CATCH /aws1/cx_texunsupporteddocex . MESSAGE 'The document is not supported.' TYPE 'E'. ENDTRY. "Get job ID from the output." DATA(lv_jobid) = lo_start_result->get_jobid( ). "Wait for job to complete." oo_result = lo_tex->getdocumentanalysis( EXPORTING iv_jobid = lv_jobid ). " oo_result is returned for testing purposes. " WHILE oo_result->get_jobstatus( ) <> 'SUCCEEDED'. IF sy-index = 10. EXIT. "Maximum 300 seconds." ENDIF. WAIT UP TO 30 SECONDS. oo_result = lo_tex->getdocumentanalysis( EXPORTING iv_jobid = lv_jobid ). ENDWHILE.