Get Example source ABAP code based on a different SAP table
ABAP_AMDP - Graph Processing AMDP> supports two SAP HANA> artifacts for processing graphs>:
Graph workspaces>
Graph procedures> 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 objects>).
ABAP_FURTHER_INFO 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 target column. ABAP_NOTE 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 use 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 ABAP_AMDP - 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>. The declaration of the vertex table and edge table is included automatically. 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. METH CL_DEMO_AMDP_GRAPH=>GRAPH_WORKSPACE
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 ABAP_AMDP - 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. METH CL_DEMO_AMDP_GRAPH=>GET_SHORTEST_PATH
ABAP_EXAMPLE_ABEXA The example ABAP_AMDP - Graph Processing> demonstrates graph processing using a graph workspace and a graph procedure. ABAP_EXAMPLE_END