/AWS1/IF_TEX=>ANALYZEEXPENSE()¶
About AnalyzeExpense¶
AnalyzeExpense synchronously analyzes an input document for financially
related relationships between text.
Information is returned as ExpenseDocuments and seperated as
follows:
-
LineItemGroups- A data set containingLineItemswhich store information about the lines of text, such as an item purchased and its price on a receipt. -
SummaryFields- Contains all other information a receipt, such as header information or the vendors name.
Method Signature¶
METHODS /AWS1/IF_TEX~ANALYZEEXPENSE
IMPORTING
!IO_DOCUMENT TYPE REF TO /AWS1/CL_TEXDOCUMENT OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_texanalyzeexpensersp
RAISING
/AWS1/CX_TEXACCESSDENIEDEX
/AWS1/CX_TEXBADDOCUMENTEX
/AWS1/CX_TEXDOCUMENTTOOLARGEEX
/AWS1/CX_TEXINTERNALSERVERERR
/AWS1/CX_TEXINVALIDPARAMETEREX
/AWS1/CX_TEXINVALIDS3OBJECTEX
/AWS1/CX_TEXPROVTHRUPUTEXCDEX
/AWS1/CX_TEXTHROTTLINGEX
/AWS1/CX_TEXUNSUPPORTEDDOCEX
/AWS1/CX_TEXCLIENTEXC
/AWS1/CX_TEXSERVEREXC
/AWS1/CX_RT_TECHNICAL_GENERIC
/AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Required arguments:¶
io_document TYPE REF TO /AWS1/CL_TEXDOCUMENT /AWS1/CL_TEXDOCUMENT¶
The input document, either as bytes or as an S3 object.
You pass image bytes to an Amazon Textract API operation by using the
Bytesproperty. For example, you would use theBytesproperty to pass a document loaded from a local file system. Image bytes passed by using theBytesproperty must be base64 encoded. Your code might not need to encode document file bytes if you're using an AWS SDK to call Amazon Textract API operations.You pass images stored in an S3 bucket to an Amazon Textract API operation by using the
S3Objectproperty. Documents stored in an S3 bucket don't need to be base64 encoded.The AWS Region for the S3 bucket that contains the S3 object must match the AWS Region that you use for Amazon Textract operations.
If you use the AWS CLI to call Amazon Textract operations, passing image bytes using the Bytes property isn't supported. You must first upload the document to an Amazon S3 bucket, and then call the operation using the S3Object property.
For Amazon Textract to process an S3 object, the user must have permission to access the S3 object.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_texanalyzeexpensersp /AWS1/CL_TEXANALYZEEXPENSERSP¶
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->analyzeexpense(
io_document = new /aws1/cl_texdocument(
io_s3object = new /aws1/cl_texs3object(
iv_bucket = |string|
iv_name = |string|
iv_version = |string|
)
iv_bytes = '5347567362473873563239796247513D'
)
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
lo_documentmetadata = lo_result->get_documentmetadata( ).
IF lo_documentmetadata IS NOT INITIAL.
lv_uinteger = lo_documentmetadata->get_pages( ).
ENDIF.
LOOP AT lo_result->get_expensedocuments( ) into lo_row.
lo_row_1 = lo_row.
IF lo_row_1 IS NOT INITIAL.
lv_uinteger = lo_row_1->get_expenseindex( ).
LOOP AT lo_row_1->get_summaryfields( ) into lo_row_2.
lo_row_3 = lo_row_2.
IF lo_row_3 IS NOT INITIAL.
lo_expensetype = lo_row_3->get_type( ).
IF lo_expensetype IS NOT INITIAL.
lv_string = lo_expensetype->get_text( ).
lv_percent = lo_expensetype->get_confidence( ).
ENDIF.
lo_expensedetection = lo_row_3->get_labeldetection( ).
IF lo_expensedetection IS NOT INITIAL.
lv_string = lo_expensedetection->get_text( ).
lo_geometry = lo_expensedetection->get_geometry( ).
IF lo_geometry IS NOT INITIAL.
lo_boundingbox = lo_geometry->get_boundingbox( ).
IF lo_boundingbox IS NOT INITIAL.
lv_float = lo_boundingbox->get_width( ).
lv_float = lo_boundingbox->get_height( ).
lv_float = lo_boundingbox->get_left( ).
lv_float = lo_boundingbox->get_top( ).
ENDIF.
LOOP AT lo_geometry->get_polygon( ) into lo_row_4.
lo_row_5 = lo_row_4.
IF lo_row_5 IS NOT INITIAL.
lv_float = lo_row_5->get_x( ).
lv_float = lo_row_5->get_y( ).
ENDIF.
ENDLOOP.
lv_angle = lo_geometry->get_rotationangle( ).
ENDIF.
lv_percent = lo_expensedetection->get_confidence( ).
ENDIF.
lo_expensedetection = lo_row_3->get_valuedetection( ).
IF lo_expensedetection IS NOT INITIAL.
lv_string = lo_expensedetection->get_text( ).
lo_geometry = lo_expensedetection->get_geometry( ).
IF lo_geometry IS NOT INITIAL.
lo_boundingbox = lo_geometry->get_boundingbox( ).
IF lo_boundingbox IS NOT INITIAL.
lv_float = lo_boundingbox->get_width( ).
lv_float = lo_boundingbox->get_height( ).
lv_float = lo_boundingbox->get_left( ).
lv_float = lo_boundingbox->get_top( ).
ENDIF.
LOOP AT lo_geometry->get_polygon( ) into lo_row_4.
lo_row_5 = lo_row_4.
IF lo_row_5 IS NOT INITIAL.
lv_float = lo_row_5->get_x( ).
lv_float = lo_row_5->get_y( ).
ENDIF.
ENDLOOP.
lv_angle = lo_geometry->get_rotationangle( ).
ENDIF.
lv_percent = lo_expensedetection->get_confidence( ).
ENDIF.
lv_uinteger = lo_row_3->get_pagenumber( ).
lo_expensecurrency = lo_row_3->get_currency( ).
IF lo_expensecurrency IS NOT INITIAL.
lv_string = lo_expensecurrency->get_code( ).
lv_percent = lo_expensecurrency->get_confidence( ).
ENDIF.
LOOP AT lo_row_3->get_groupproperties( ) into lo_row_6.
lo_row_7 = lo_row_6.
IF lo_row_7 IS NOT INITIAL.
LOOP AT lo_row_7->get_types( ) into lo_row_8.
lo_row_9 = lo_row_8.
IF lo_row_9 IS NOT INITIAL.
lv_string = lo_row_9->get_value( ).
ENDIF.
ENDLOOP.
lv_string = lo_row_7->get_id( ).
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
LOOP AT lo_row_1->get_lineitemgroups( ) into lo_row_10.
lo_row_11 = lo_row_10.
IF lo_row_11 IS NOT INITIAL.
lv_uinteger = lo_row_11->get_lineitemgroupindex( ).
LOOP AT lo_row_11->get_lineitems( ) into lo_row_12.
lo_row_13 = lo_row_12.
IF lo_row_13 IS NOT INITIAL.
LOOP AT lo_row_13->get_lineitemexpensefields( ) into lo_row_2.
lo_row_3 = lo_row_2.
IF lo_row_3 IS NOT INITIAL.
lo_expensetype = lo_row_3->get_type( ).
IF lo_expensetype IS NOT INITIAL.
lv_string = lo_expensetype->get_text( ).
lv_percent = lo_expensetype->get_confidence( ).
ENDIF.
lo_expensedetection = lo_row_3->get_labeldetection( ).
IF lo_expensedetection IS NOT INITIAL.
lv_string = lo_expensedetection->get_text( ).
lo_geometry = lo_expensedetection->get_geometry( ).
IF lo_geometry IS NOT INITIAL.
lo_boundingbox = lo_geometry->get_boundingbox( ).
IF lo_boundingbox IS NOT INITIAL.
lv_float = lo_boundingbox->get_width( ).
lv_float = lo_boundingbox->get_height( ).
lv_float = lo_boundingbox->get_left( ).
lv_float = lo_boundingbox->get_top( ).
ENDIF.
LOOP AT lo_geometry->get_polygon( ) into lo_row_4.
lo_row_5 = lo_row_4.
IF lo_row_5 IS NOT INITIAL.
lv_float = lo_row_5->get_x( ).
lv_float = lo_row_5->get_y( ).
ENDIF.
ENDLOOP.
lv_angle = lo_geometry->get_rotationangle( ).
ENDIF.
lv_percent = lo_expensedetection->get_confidence( ).
ENDIF.
lo_expensedetection = lo_row_3->get_valuedetection( ).
IF lo_expensedetection IS NOT INITIAL.
lv_string = lo_expensedetection->get_text( ).
lo_geometry = lo_expensedetection->get_geometry( ).
IF lo_geometry IS NOT INITIAL.
lo_boundingbox = lo_geometry->get_boundingbox( ).
IF lo_boundingbox IS NOT INITIAL.
lv_float = lo_boundingbox->get_width( ).
lv_float = lo_boundingbox->get_height( ).
lv_float = lo_boundingbox->get_left( ).
lv_float = lo_boundingbox->get_top( ).
ENDIF.
LOOP AT lo_geometry->get_polygon( ) into lo_row_4.
lo_row_5 = lo_row_4.
IF lo_row_5 IS NOT INITIAL.
lv_float = lo_row_5->get_x( ).
lv_float = lo_row_5->get_y( ).
ENDIF.
ENDLOOP.
lv_angle = lo_geometry->get_rotationangle( ).
ENDIF.
lv_percent = lo_expensedetection->get_confidence( ).
ENDIF.
lv_uinteger = lo_row_3->get_pagenumber( ).
lo_expensecurrency = lo_row_3->get_currency( ).
IF lo_expensecurrency IS NOT INITIAL.
lv_string = lo_expensecurrency->get_code( ).
lv_percent = lo_expensecurrency->get_confidence( ).
ENDIF.
LOOP AT lo_row_3->get_groupproperties( ) into lo_row_6.
lo_row_7 = lo_row_6.
IF lo_row_7 IS NOT INITIAL.
LOOP AT lo_row_7->get_types( ) into lo_row_8.
lo_row_9 = lo_row_8.
IF lo_row_9 IS NOT INITIAL.
lv_string = lo_row_9->get_value( ).
ENDIF.
ENDLOOP.
lv_string = lo_row_7->get_id( ).
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
LOOP AT lo_row_1->get_blocks( ) into lo_row_14.
lo_row_15 = lo_row_14.
IF lo_row_15 IS NOT INITIAL.
lv_blocktype = lo_row_15->get_blocktype( ).
lv_percent = lo_row_15->get_confidence( ).
lv_string = lo_row_15->get_text( ).
lv_texttype = lo_row_15->get_texttype( ).
lv_uinteger = lo_row_15->get_rowindex( ).
lv_uinteger = lo_row_15->get_columnindex( ).
lv_uinteger = lo_row_15->get_rowspan( ).
lv_uinteger = lo_row_15->get_columnspan( ).
lo_geometry = lo_row_15->get_geometry( ).
IF lo_geometry IS NOT INITIAL.
lo_boundingbox = lo_geometry->get_boundingbox( ).
IF lo_boundingbox IS NOT INITIAL.
lv_float = lo_boundingbox->get_width( ).
lv_float = lo_boundingbox->get_height( ).
lv_float = lo_boundingbox->get_left( ).
lv_float = lo_boundingbox->get_top( ).
ENDIF.
LOOP AT lo_geometry->get_polygon( ) into lo_row_4.
lo_row_5 = lo_row_4.
IF lo_row_5 IS NOT INITIAL.
lv_float = lo_row_5->get_x( ).
lv_float = lo_row_5->get_y( ).
ENDIF.
ENDLOOP.
lv_angle = lo_geometry->get_rotationangle( ).
ENDIF.
lv_nonemptystring = lo_row_15->get_id( ).
LOOP AT lo_row_15->get_relationships( ) into lo_row_16.
lo_row_17 = lo_row_16.
IF lo_row_17 IS NOT INITIAL.
lv_relationshiptype = lo_row_17->get_type( ).
LOOP AT lo_row_17->get_ids( ) into lo_row_18.
lo_row_19 = lo_row_18.
IF lo_row_19 IS NOT INITIAL.
lv_nonemptystring = lo_row_19->get_value( ).
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
LOOP AT lo_row_15->get_entitytypes( ) into lo_row_20.
lo_row_21 = lo_row_20.
IF lo_row_21 IS NOT INITIAL.
lv_entitytype = lo_row_21->get_value( ).
ENDIF.
ENDLOOP.
lv_selectionstatus = lo_row_15->get_selectionstatus( ).
lv_uinteger = lo_row_15->get_page( ).
lo_query = lo_row_15->get_query( ).
IF lo_query IS NOT INITIAL.
lv_queryinput = lo_query->get_text( ).
lv_queryinput = lo_query->get_alias( ).
LOOP AT lo_query->get_pages( ) into lo_row_22.
lo_row_23 = lo_row_22.
IF lo_row_23 IS NOT INITIAL.
lv_querypage = lo_row_23->get_value( ).
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDIF.