Ansicht
Dokumentation

ABENAMDP_HDB_GRAPH - AMDP HDB GRAPH

ABENAMDP_HDB_GRAPH - AMDP HDB GRAPH

General Material Data   RFUMSV00 - Advance Return for Tax on Sales/Purchases  
This documentation is copyright by SAP AG.
SAP E-Book

- Graph Processing

AMDP supports two SAP HANA artifacts for processing graphs:

Graph workspaces can be consumed by graph procedures using GraphScript which is the implementation language of an AMDP method that specifies the addition FOR HDB LANGUAGE GRAPH in the METHOD statement. In contrast to AMDP procedures and AMDP functions, methods in this context operate on non-procedural database objects (DDL object).

SAP HANA Graph Reference

Graph Workspace

Graph workspaces are created in AMDP methods that declare a vertex table and an edge table as sources for a graph model.

The declaration consists of the key column of a vertex table (vertex key) and the key column of an edge table (edge key), as well as a source and a target column of an edge table. Currently, graph workspaces are restricted to one key column, and one source and destination column.

Graph workspaces cannot be mocked during a syntax check. There is no separate signature available. Instead, the complete database object must be created. It might be defined in a different AMDP class and user other AMDP objects. Hence, a special handling is needed, and implementation details from other classes must be used (transitive syntax check).

Definition and implementation of a graph workspace

The following code snippets are taken from the example - Graph processing.

Definition:

The method definition must include the addition FOR DDL OBJECT.

CLASS-METHODS graph_workspace FOR DDL OBJECT
        OPTIONS CDS SESSION CLIENT REQUIRED.

Implementation:

The METHOD statement includes the addition BY DATABASE GRAPH WORKSPACE. Currently, only CDS views are allowed after the addition USING. It includes the declaration of vertex table and edge table. The declaration consists of the key column of a vertex table (vertex key) and the key column of an edge table (edge key), as well as a source and a target column of an edge table. Currently, graph workspaces are restricted to one key column, and one source and destination column.

Graph Procedure

Graph procedures are methods that refer to graph workspaces and operate on graph models. Graph procedures may have scalar input parameters and scalar or tabular output parameters. Inconsistencies in the underlying vertex and edge tables may result in runtime errors (CX_AMDP_EXECUTION_FAILED), for example, if the edge source or target do not exist in the vertex table.

Definition and implementation of a graph procedure

The following code snippets are taken from the example - Graph processing.

Definition:

The example shows scalar-only importing parameters. The exporting parameters are both scalar and tabular.

CLASS-METHODS get_shortest_path
      AMDP OPTIONS CDS SESSION CLIENT current
      IMPORTING VALUE(im_city_from) TYPE demo_cds_spfli4graph-cityfrom
                VALUE(im_city_to)   TYPE demo_cds_spfli4graph-cityto
      EXPORTING VALUE(ex_weight)    TYPE int8
                VALUE(ex_route)     TYPE tt_conn
      RAISING   cx_amdp_execution_failed.

Implementation:

The METHOD statement includes the addition FOR HDB LANGUAGE GRAPH to denote that the implementation contains GraphScript code. The READ-ONLY addition is mandatory. The USING addition must be followed by a graph workspace.

The example - Graph processing demonstrates graph processing using a graph workspace and a graph procedure.






BAL Application Log Documentation   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.

Length: 7106 Date: 20240512 Time: 114320     sap01-206 ( 70 ms )