cancel
Showing results for 
Search instead for 
Did you mean: 

Values not getting passed from view to component controller

Former Member
0 Kudos

Hi Experts,

I have to pass value of certain parameters from view to component controller. My problem is like this. I have created two buttons on the view. When the user will press one button, one set of value should be passed to component controller and then to R/3. When the user selects other button other set of values should pass from view to component controller and then to R/3.

The code looks like as below:

public void onActionButton(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionButton(ServerEvent)

Date dt = new Date(System.currentTimeMillis());

bp.setInputdate(dt);

wdThis.wdGetTimesheetCompController().executeZbapi_Cat_Stech00_Getdetail_Input();

//@@end

}

public void onActionNextWeek(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionNextWeek(ServerEvent)

Date dt1 = new Date(System.currentTimeMillis());

long dateMillis = dt1.getTime();

long dayInMillis = 1000 * 60 * 60 247;

dateMillis = dateMillis + dayInMillis;

dt1.setTime(dateMillis);

bp.setInputdate(dt1);

wdThis.wdGetTimesheetCompController().executeZbapi_Cat_Stech00_Getdetail_Input();

//@@end

}

When I am doing this values are NOT getting passed from view to component controller. Can you please let me know what is going wrong here?

Regards,

Brian

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi

try this

Date dt = new Date(System.currentTimeMillis());

Zbapi_Cat_Stech00_Getdetail_Input bp=new Zbapi_Cat_Stech00_Getdetail_Input();

bp.setInputdate(dt);

wdContext.nodeZbapi_Cat_Stech00_Getdetail_Input().bind(bp);

wdThis.wdGetTimesheetCompController().executeZbapi_Cat_Stech00_Getdetail_Input();

Kind Regards

Mukesh

Former Member
0 Kudos

Hi Brain,

see this link,

<b>https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/d352a790-0201-0010-5082-b1a608d22b6c</b>

sridhar_k2
Active Contributor
0 Kudos

Brian,

If you want to check values passing from View to Component, try this way.

- Create a ValueNode (TestNode) and ValueAttribute (TestAttr) from Component Controller Context.

- Create Method (TestMethod) and place this logic in the method

String testAttr = wdContext.createTestNodeElement().getTestAttr();

wdComponentAPI.getMessageManager().reportSuccess("Value Entered in View : "+testAttr );

- Create a link from view to the controller, and drag TestNode to the View.

and assign some value to the attribute.

wdContext.currentTestNode1Element().setTestAttr("Testing Purpose");

And call your controller method (TestMethod) from view, you can see the value from controller also.

wdThis.wdGetTestComponetController().TestMethod();

It will print the same value what you have assigned in the view.

It seems to be tricky, but it is very simple.

Regards,

Sridhar

sridhar_k2
Active Contributor
0 Kudos

Hello Brian,

Passing parameter to the component controller is simple.

After you creating RFC Model, you might have created model node ( I guess that is bp in your code). When you bind values to that (bp) from view, values automatically binded to the component controller and from there to model (R/3) after calling the below method.

wdThis.wdGetTimesheetCompController().executeZbapi_Cat_Stech00_Getdetail_Input();

Use MessageManager to check correct values are going to the back end or not.

IWDMessageManager manager = wdComponentAPI.getMessageManager();

manager.reportSuccess("Value ");

It is good programming practice.

For more information go thru the sample for WebDynpro for JAVA.

https://www.sdn.sap.com/irj/sdn/webdynpro?rid=/library/uuid/49f2ea90-0201-0010-ce8e-de18b94aee2d#15

Accessing ABAP Function at this place.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/wd%20jav...

Regards,

Sridhar