cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass hard coded value to R/3 using BAPI

Former Member
0 Kudos

Hi Experts,

I have created Web Dynpro form. Using this form, I have to pass value to R/3. Based on the passed values, we will get data from R/3. Now my problem is like this: I have to send hard coded value to R/3. How we can do it?

Regards,

Brian

Accepted Solutions (0)

Answers (2)

Answers (2)

luciano_leitedasilva
Contributor
0 Kudos

Hi Brian,

You can do it setting these values in the context node before send to the RFC.

How can you do this?

...

wdcontext.currentCustomer().setCode("0001");

...

At the node Customer you are setting the value 0001 tho the field code.

Is it clear?

Regards,

Luciano

Former Member
0 Kudos

Thanks Luciano,

I am able to hard value at Component Controller. The value is being passed and I am getting correct output from BAPI.

My problem is like this. I have created two buttons on the view. When the user will press one button, present date should be passed to RFC. When the user selects other button, present date + 7 should be passed to RFC.

However it is not happening. Correct dates are not being passed from view to component controller.

The code is like this in view:

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

}

I am trying to pass the value from view to Component Controller and then to RFC. However by doing bp.setInputdate(dt1) the value is not being passed to RFC.

Can you please let me know what is going wrong here.

Regards,

Brian

sridhar_k2
Active Contributor
0 Kudos

Hello Brian,

Make use of the below code for adding days to your Current Date in the second button action method.

<b>One way</b>

java.util.Date today = new java.util.Date();

java.sql.Date currDate =new java.sql.Date(today.getTime());

java.util.Calendar curDateCal = Calendar.getInstance();

java.util.Date selectedDate=//code get the selected date

java.util.Calendar selectedDateCal = Calendar.getInstance();

selectedDateCal.add(Calendar.DATE, 7);

<b>Other way</b>

java.util.Date today = new java.util.Date();

java.sql.Date nextDate =new java.sql.Date( today.getTime() * ( (2436001000) * 7) );

wdComponentAPI.getMessageManager().reportSuccess ("Next Date " + nextDate);

this give after 7 days from current date.

Write me back, if you still have problems with this code.

Regards,

Sridhar

Former Member
0 Kudos

Hi Sridhar,

I am able to generate the values of dates correctly. My question is that we have 2 buttons in view. In case user clicks on first button, first set of values should be passed to component controller. In case the user clicks on second button, second set of values should pass to the controller. How we can do it?

Regards,

Brian

Former Member
0 Kudos

Hai,

Add a parameter date to Action in the component controller,

pass the value form the view.

Regards,

Naga

sridhar_k2
Active Contributor
0 Kudos

Hello Brian,

If you question is just passing values to the component controller, Create a variable in Component Controller ( date1) and assign value in the view like this.

wdThis.wdGet****ControllerName**().wdGetContext().currentContextElement().setDate1("DATE HERE");

This automatically pass value to the controller.

Or

If you want to send values to the BAPI, use the sample code.

Ztest_Function_Input input = new Ztest_Function_Input();

for (int i=0; i<5;i++){

Zhr_Ear_Cclist cc =new Zhr_Ear_Cclist();

cc.setFi_User("test@sap.com");

input.addIcc_List(cc);

}

wdContext.nodeZtest_Function_Input().bind(input);

wdContext.currentZtest_Function_InputElement().modelObject().execute();

go thru <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/wd%20java/wd%20tutorials/creating%20a%20web%20dynpro%20application%20accessing%20abap%20functions.pdf">RFC Model in Web Dynpro</a> example from. Passing parameters to BAPI - Page no 23.

Regards,

Sridhar

Former Member
0 Kudos

What do you mean by hard coded value? could you be more clear?

Are you trying to pass this hard coded values to a function module?