cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic context

Former Member
0 Kudos

How can I update the value note with the output of a BAPI?

Yisr_Special_Data_Get_Input

OutputSDG

Special_DataSDG

Fieldname

FieldValue

Fieldindex

Input parameter Notification_No and bolean Do_Not_Read_Linked

The fieldnames needs to update in NWDS in the node mappedfields

Code I have now for the PAI call is, what is missing to:

try {

IPublicUWL_Form_Cust.IMappedFieldsElement field =

wdContext.createMappedFieldsElement();

Yisr_Special_Data_Get_Input inputIsr = new Yisr_Special_Data_Get_Input();

String isrNr =

wdContext.currentOutputGIsrElement().getIsr_Number();

inputIsr.setNotification_No(isrNr);

inputIsr.setDo_Not_Read_Linked(true);

inputIsr.execute();

Iterator it = inputIsr.getResult().iterator();

while (it.hasNext()) {

Yisr_Special_Data_Get_Output output =

(Yisr_Special_Data_Get_Output) it.next();

Iterator records = output.getSpecial_Data().iterator();

while (records.hasNext()) {

Object obj = records.next();

System.out.println(obj);

com.shell.teamflow.wd.uwlintegration.model.specialdataget.Qisrsspecial_Param record =

(com.shell.teamflow.wd.uwlintegration.model.specialdataget.Qisrsspecial_Param) obj;

String fieldname = record.getFieldname();

String fieldvalue = record.getFieldvalue();

try {

Method method =

field.getClass().getMethod(

"set" + fieldname,

new Class[] { String.class });

method.invoke(field, new Object[] );

} catch (SecurityException e) {

logger.catching(e);

} catch (IllegalArgumentException e) {

logger.catching(e);

} catch (NoSuchMethodException e) {

logger.catching(e);

} catch (IllegalAccessException e) {

logger.catching(e);

} catch (InvocationTargetException e) {

logger.catching(e);

}

}

}

this.wdContext.nodeMappedFields().bind(field);

} catch (Exception e) {

wdComponentAPI.getMessageManager().reportException(e.toString(), false);

}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

There are excellent wizards for doing what you describe.

Apply the "service controller" template for creating the call to the BAPI. (=model execution)

Apply the "relate context attributes" to the controller and select the model that imports your BAPI.

Before using the wizard however, it is wise to create a method in which to place the generated code.

better even is to create custom controllers for each BAPI and apply the templates for each custom controller.

Also, you must have created value context structure with the right cardinality for importing exporting parameters/tables.

Only when your model imports or exports table, you need additional programming.

After applying the templates in my project my code looks like this:

[code]

wdContext.nodeModelName_Input().bind(new ModelName_Input());

IPrivateControllerNameCust.IValueNodeElement valueElement = wdContext.currentValueNodeElement();

IPrivateControllerNameCust.IModelNameElement modelElement = wdContext.currentModelNameElement();

if ((valueElement != null) && (modelElement != null)) {

modelElement.setPropX(valueElement.getPropX);

// etc for importing parameters

}

//$$begin Service Controller(372528353)

IWDMessageManager manager = wdComponentAPI.getMessageManager();

try{

wdContext.currentModelNameElement().modelObject().execute();

} catch(WDDynamicRFCExecuteException ce) {

manager.reportException(ce.getMessage(), false);

}

//$$end

//$$begin Relate Context Attributes(-965883762)

IPrivateControllerNameCust.IModelResultNode modelNode = wdContext.nodeModelResult();

IPrivateControllerNameCust.IValueResultNode valueNode = wdContext.nodeValueResultElement();

for (int i=0; i < modelNode.size(); i++) {

IPrivateControllerNameCust.IModelResultElement modelResultElement = modelNode.getModelResultElementAt(i);

IPrivateControllerNameCust.IValueResultElement valueElement = wdContext.nodeValueResult().createValueResultElement();

valueElement.setPropY(modelElement.getPropY());

//etc for other properties.

valueNode.addElement(valueElement);

}

//$$end

[/code]

Message was edited by: R. Knibbe

Message was edited by: R. Knibbe

Former Member
0 Kudos

Knibbe, can you explain what that steps are. I am facing the same challenges.

Former Member
0 Kudos

First of all, the above describes how to map model node data to value node data. If you use model nodes in your view, it is not required.

The steps describe how to map the models input parameters (if present) to model input parameters prior to executing the model; and how to map the model's result (stored in model nodes) to your value nodes after executing the model.

These steps are performed with the relate attributes template.

Before applying these templates, you should apply the service controller template, this wizard creates a method in which the model is called.

As I said, it is even better practice to create a custom controller for each model you use. In that case apply all templates described before to this custom controller.

The result should look like the code posted.

With regard to value nodes: I usually create a 'ModelName' node for each model (card. 1:1) with a subnode 'ModelNameInputParameters' (card. 1:1, or 0:n for importing table). For the resultnode I create a 'ModelNameResult' node, cardinality depends on return type, which can be a collection (or table, card. 0:n) or simply a return code (card 1:1 or 0:1).

The value nodes can be dragged to the Controller Component (when Custom controllers are used) and subsequently to the View.

Hope this helps

Good luck.

Roelof

Answers (0)