cancel
Showing results for 
Search instead for 
Did you mean: 

How can we pass Dynamic values through variable to a subgraph

0 Kudos

Hello,

We are extracting data from BW and staging data in DI data lake(I know that this is not a good idea while using SAP DI but we had to due to the fact that data transfer operator cannot send data directly to ADLV2).

We need to extract 176 millions of data from source packet wise. So I want to create one graph and reuse it.

I have followed the below blog but couldn't successfully pass the variable value to the DI graph which is using pipeline operator to pass the variable.

SAP DI Structure File Consumers; specifying dynamic input filename/url for S3 retrieval | SAP Commun...

Could anyone help me on this?

----------------------------------

$.addGenerator(gen)

var graphName = "Test_pipeline_with_dynamicvariable" //Your subgraph name

var ZDATPAKID = "000001"

function gen(ctx) {

// start subgraph

var g

try {

g = $.instantiateGraph(graphName,

{"ZDATPAKID": ZDATPAKID}

)

} catch(e) {

$.fail(e.message)

return

}

// wait for graph execution is finished

status = g.wait()

// check graph status

if (status != $.graphStatus.completed) {

$.fail("Subgraph is failed")

} else {

$.done()

}

}

------------------------------------------


Error:

MessageGroup messages: Group: default; Messages: error building graph: configuration substitution failed for subengine operator subengineOperator0: for process "1_2019" ("pipeline1"): for configuration "configurationSubstitutions[0].value": missing value for "ZDATPAKID" Process(es) terminated with error(s). restartOnFailure==false
Thanks,Sirisha


View Entire Topic
michal_majer
Active Participant
0 Kudos

Hey nsirisha,

You can try to use my custom operator for that.

https://blogs.sap.com/2022/09/26/how-to-start-a-graph-from-another-graph-use-my-custom-operator-%f0%...

I also explained a bit other possibilities in this post blog.
I guess I did mistake in the short code from this answer - please check the full code from the post blog.

$.addGenerator(gen)

// This example shows basic usage of a subgraph
// It calls a graph with a parameter, provides input to a port,
// checks a port's output and stops the graph

var graphName = "com.sap.demo.subgraph.call-and-wait.sub"
var subgraphInput = "subgraph-input "
var paramValue = "value1"
function gen(ctx) {
  // start subgraph
  var g
  try {
    g = $.instantiateGraph(graphName,
      {"param1": paramValue},
      // handle subgraph output port with name 'output'
      {"output":function(ctx,s){
          // check subgraph output
          if (s != subgraphInput + paramValue) {
              $.fail("Unexpected subgraph output: " + s + " Expected: " + prefix+paramValue)
          }
          // stop subgraph
          g.stop()
      }}
    )
  } catch(e) {
    $.fail(e.message)
    return
  }
  // write string in subraph input port with name 'input'
  g.input(subgraphInput)
  // wait for graph execution is finished
  status = g.wait()
  // check graph status
  if (status != $.graphStatus.completed) {
    $.fail("Subgraph is failed")
  } else {
    $.done()
  }
}