cancel
Showing results for 
Search instead for 
Did you mean: 

onActionShow gives no result

Former Member
0 Kudos

Hi Experts,

I am creating an application similat to web dynpro example : Accessing ABAP Functions in Web Dynpro. found here [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/28113de9-0601-0010-71a3-c87806865f26?rid=/library/uuid/49f2ea90-0201-0010-ce8e-de18b94aee2d#6 [original link is broken]].

I created an RFM which has import parameters as Date of Type CATSDB-WORKDATE. It has 'Employee_atab' as tables parameters. This is a custom fm, so if the date is given as input, it gives employee's attendence and absences in table 'Employee_atab' . It is working perfectly fine in R/3 system.

I am trying to create a web dynpro UI for this fm: So 'date' will be supplied through Web Dynpro and Table "Employee_atab" output will be seen in Web Dynpro.

I am struck here. when I give the 'date' and press show button, i do not see any thing in the table UI element.

I have a curiosity if the logic here below in wdInit Method of the controller is fine:I am guessing it is the problem with Date conversion.

Z_Hr_Time_Report_2Weeks_Input readInput = new Z_Hr_Time_Report_2Weeks_Input();

wdContext.nodeTimeDataRead().bind(readInput);

Calendar c1 = Calendar.getInstance();

// Date sDate = new Date();

Date d = new Date(c1.getTimeInMillis());

readInput.setStartdate(new Date (c1.getTime().getTime()));

This is the code in Search View controller:

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

{

//@@begin onActionShow(ServerEvent)

wdContext.currentContextElement().setStartdate(wdContext.currentContextElement().getWorkDate());

wdThis.wdGetTimeReport_CustController().executeReadTimeData();

//@@end

}

I can not locate the problem. I am not sure how the RFM is responding to the Date input on web dynpro. I am on ERP2004, I can not create a external break point in my RFC.

Could any body throw some light on the problem. I would really appreicate your help.

Thanks!

Edited by: minisap g on Apr 6, 2008 1:41 PM

Accepted Solutions (1)

Accepted Solutions (1)

nikhil_bose
Active Contributor
0 Kudos

readInput.setStartdate(new Date (c1.getTime().getTime()));

// new Date(c1.getTime()) will give you Date instance

you can set current date by

new Date(System.currentTimeMillis());

try:

1. in onActionShow()

set current date as wdContext.currentContextElement().setStartdate(new Date(System.currentTimeMillis());

2. If still not shows the result, you need to invalidate the node to reflect the new values in the output node of RFC.

- Go to CustController().executeReadTimeData()

- wdContext.node<RFC_OUTPUT>.invalidate();

//make sure that you are invalidating the exact node that gets filled when the RFC is executed.

regards,

nikhil

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi minisap,

I think there is some problem with the format of date.

Hope the following code will work

You can take your date into strDate,

SimpleDateFormat objDateFormat = null;

Date dtDate = null;

String strDate = "31/12/9999";

try

{

objDateFormat = new SimpleDateFormat("dd/MM/yyyy");

dtDate = new Date(objDateFormat.parse(strDate).getTime());

}

catch(Excetion e)

{

IWDMessageManager msgMgr = wdThis.wdGetAPI().getComponent().getMessageManager();

String strMessage = e.getLocalizedMessage();

if((strMessage == null) ||(strMessage.length() == 0))

{

strMessage = e.getMessage();

}

if ((strMessage == null) || (strMessage.length() == 0))

{

strMessage = e.toString();

}

msgMgr.reportException(strMessage,true);

}

dtDate will contain the required format to be sent to backend.

Thanks and Regards

Former Member
0 Kudos

Hi,

First, check with a simple BAPI if you are able to execute successfully and get the output.

Once you get, then go to the RFC you are facing problem. Execute from R3 screen itself by specifying the date.

Once the output comes there, check the date format.

Then follow the same format from webdynpro and check the output. Y

ou can put many print statements to check the node attribute values here and there.

That may help you locate the problem.

Regards,

Harini S

Former Member
0 Kudos

Model: Z_Hr_Time_Report_2Weeks_Input

Code In Custom Controller:

public void wdDoInit()

{

//@@begin wdDoInit()

Z_Hr_Time_Report_2Weeks_Input readInput = new Z_Hr_Time_Report_2Weeks_Input();

wdContext.nodeZ_Hr_Time_Report_2Weeks_Input().bind(readInput);

Calendar c1 = Calendar.getInstance();

// Date sDate = new Date();

Date d = new Date(c1.getTimeInMillis());

readInput.setStartdate(new Date(c1.getTime().getTime()));

//@@end

}

This a Method in Custom Controller:

public void executeReadTimeData( )

{

//@@begin executeReadTimeData()

try {

wdContext.currentZ_Hr_Time_Report_2Weeks_InputElement().modelObject().execute();

} catch (Exception e){

logger.errorT("Error Executing RFC");

wdContext.nodeOutput_Read().invalidate();

}

The Method in View Controller (Search View):

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

{

//@@begin onActionShow(ServerEvent)

//wdContext.cu

//wdContext.currentZ_Hr_Time_Report_2Weeks_InputElement().setStartdate(new Date(System.currentTimeMillis()));

wdThis.wdGetTimeReport_CustController().executeReadTimeData();

//@@end

}

I removed the custom value attribute for the 'startdate', and created bining with element from Model element

Z_Hr_Time_Report_2Weeks_InputElement.StartDate.

Still, I do not see any results. Could any body find some thing wrong in the code.

Harini,

Could you tell me where should I put the print statements to check node attribute values. Could you give me some sample lines.

Thanks!

Former Member
0 Kudos

Hi,

Try to execute it from the backend if it works fine

Check the date format expected at the backend and do accordingly.

Regards

Ayyapparaj

Former Member
0 Kudos

Plz, it is working on R/3 side. '03/01/2008' is an example how i give on R/3 side. how to give in the same format in web dynpro for java?

Former Member
0 Kudos

Hi,

use as follows



//Sys date
Date date = new Date(Calendar.getInstance().getTimeInMillis());
	  Format formatter = new SimpleDateFormat("dd/MM/yyyy");     
	  String s = formatter.format(date);

Regards

Ayyapparaj

Former Member
0 Kudos

Why is the invalidate()-statement inside the catch block?

Armin

snehal_kendre
Active Contributor
0 Kudos

Hi,

Put your date logic in executeReadTimeData( ) or in view controller. instead of wdinit

Former Member
0 Kudos

Hi Experts,

I have tried your suggestions, I have not had any luck with executing the RFC from Web Dynpro Input Date.

please advice on how to debug in ERP2004. I can not set an external break point in ERP2004 system.

I have done bebugging in NWDS by using external break point in ERP2005 system, though. I just would like to see in which format the date is coming into the RFC from Web Dynpro.

I know this web dynpro application is not very complex. I am only supplying date to the RFC through web dynpro and am trying to see the output.

Thanks!

Former Member
0 Kudos

Hello,

I think problem arise at your value binding at your input node element.

Do this way



wdContext.currentZ_Hr_Time_Report_2Weeks_InputElementz().setStartdate( wdContext.currentContextElement().getWorkDate());
wdThis.wdGetTimeReport_CustController().executeReadTimeData();

You have to bind your input value to currentZ_Hr_Time_Report_2Weeks_InputElementz() not with

wdContext.currentContextElement().setStartdate().

You can hardcode a date as the input parameter to check.

Regards

- Vinod

*

Edited by: Vinod V on Apr 7, 2008 10:16 AM