cancel
Showing results for 
Search instead for 
Did you mean: 

Passing parameter to BAPI while searching

Former Member
0 Kudos

Hi,

I have the following situation :

My view contains two input fields - title number and description.

I want to do a search based on these input values using the "search" button.

This should call the BAPI from R/3 and display the selected records.

1. How will I pass these input fields to the BAPI for search.

2. How can I achieve wild card search.

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

former_member751941
Active Contributor
0 Kudos

Hi Kukku,

Check this code.

According to context structure.

Bapi_Employee_Getdata_Input

|--- Output

| -


Personal_Data(under Output node )

|--- Employee_Id

Take a method say “GetEmployeeDetailsByNo” inside component controller with parameter “empid” of type string.

Use this implementation.

public void GetEmployeeDetailsByNo( java.lang.String empid )

{

//@@begin GetEmployeeDetailsByNo()

IWDMessageManager msg = wdComponentAPI.getMessageManager();

try {

Bapi_Employee_Getdata_Input input = new Bapi_Employee_Getdata_Input();

input.setEmployee_Id(empid);

wdContext.nodeBapi_Employee_Getdata_Input().bind(input);

wdContext.currentBapi_Employee_Getdata_InputElement().modelObject().execute();

wdContext.nodePersonal_Data().invalidate();

} catch (Exception e) {

// TODO Auto-generated catch block

msg.reportSuccess(e.getMessage());

e.printStackTrace();

}

//@@end

}

Now go to the view and bind the Model node (Bapi_Employee_Getdata_Input

) in the view layout.

And inside “on action” event of “Search”button uses this code.

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

{

//@@begin onActionGoEmpSearch(ServerEvent)

wdThis.wdGetEmployeeCompController().GetEmployeeDetailsByNo(wdContext.currentBapi_Employee_Getdata_InputElement().getEmployee_Id());

//@@end

}

public void wdDoInit()

{

//@@begin wdDoInit()

Bapi_Employee_Getdata_Input bapiInput = new Bapi_Employee_Getdata_Input();

wdContext.nodeBapi_Employee_Getdata_Input().bind(bapiInput);

//@@end

}

Use the code according to your BAPI name.

Regards,

Mithu

Answers (1)

Answers (1)

sridhar_k2
Active Contributor
0 Kudos

Kuku,

To Communicate with BAPI, you need to create Adaptive RFC Model. Then you need to send input params (RFC - Request Params - Search fields), then RFC will return the result. You can use those results as you want.

Creating RFC is very Simple.

Go thru the documents about RFC Model (Accessing ABAP Functions)

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/49f2ea90-0201-0010-ce8e-de18b94a...

If you have any doubts in this Model, SDN will definately help you.

Regards,

Sridhar