Skip to content

Latest commit

 

History

History
125 lines (93 loc) · 3.97 KB

File metadata and controls

125 lines (93 loc) · 3.97 KB

ABAP String Interpreter

ASIS is a String Interpreter that allows to configure RuleSets to find information in Strings coming from e.g. scanning processes/ barcodes / data matrix codes.

Table of Contents

Example

image

Scanned Value: <Start><A7X>MyMaterialNumber<B52H>MyDeliveryNote<End>
Information to be extracted: MyMaterialNumber

Configuration: "Search the Sub-String after Identifier <A7X> within the passed String and return it as so called TargetField with key MaterialNo"

Sample RuleSet Configuration

Result:

[
  {
    "TARGETFIELD": "MaterialNo",
    "INTERPRETATIONRESULT": "MyMaterialNumber"
  }
]

Getting Started

Preconditions

Project is being developed using ABAP Cloud Trial 2022 SP01 that corresponds to ABAP Plattform 2022 04 / SAP BASIS 757 SP0004.

It might run on lower releases but this has not been tested.

Install Repo

Repository can be installed using abapGIT

Activation of external API

To be able to use the external HTTP API create an SICF node and assign Class ZASIS_CL_HTTP_HANDLER as Handler.

Create String Interpretation Variants

For the time being the projects only contains an UI based on the Service Binding Fiori Preview. Create and Publish a OData V4 Service Binding and start the 'RuleSet' Preview to be able to create String Interpretation Variants via Fiori UI.

Sample Usage

Internal/ Local API

Below Example shows how to execute a RuleSet "MySample". "MySample" is configured to extract the "MyMaterialNumber" and "MyDeliveryNote" from a String <Start><A7X>MyMaterialNumber<B52H>MyDeliveryNote<End> based on the Identifiers <A7X> and <B52H>.

  METHOD main.

    DATA(ruleset) = zasis_cl_ruleset_factory=>get_ruleset_by_rulesetid( |MySample| ).

    DATA(interpretation_result_internal) = NEW zasis_cl_interpreter( )->execute(
        ruleset                  = ruleset
        string_to_be_interpreted = |<Start><A7X>MyMaterialNumber<B52H>MyDeliveryNote<End>| ).

    cl_demo_output=>display_json( NEW /ui2/cl_abap2json( )->table2json( it_data = interpretation_result_internal ) ).

  ENDMETHOD.

Result of above sample code:

{
 "data":
 [
  {
   "targetfield":"DeliveryNo",
   "interpretationresult":"MyDeliveryNote"
  },
  {
   "targetfield":"MaterialNo",
   "interpretationresult":"MyMaterialNumber"
  }
 ]
}

External HTTP API

GET a RuleSet Definition

curl -X GET ^
  "https://your_host/zasis_ext_api/ruleSet/MySample?sap-client=001" ^
  --header "Accept: */*" ^
  --header "Content-Type: application/json" ^
  --header "Authorization: Basic abcdefghijklmnopqrstuvwxyz"

Execute a RuleSet

curl -X POST ^
  "https://your_host/zasis_ext_api/ruleSetExecution/MySample?sap-client=001" ^
  --header "Content-Type: application/json" ^
  --header "Authorization: Basic abcdefghijklmnopqrstuvwxyz" ^
  --data-raw "{\"string_to_be_interpreted\" : \"^<Start^>^<A7X^>MyMaterialNumber^<B52H^>MyDeliveryNote^<End^>\"}"

Authorization

Delevopment contains authorization object ZASIS_GRL with the following possible activities per RuleSet

  • 01 Add or Create
  • 02 Change
  • 03 Display
  • 06 Delete
  • 16 Execute