cancel
Showing results for 
Search instead for 
Did you mean: 

populating a table with bapi

Former Member
0 Kudos

Hi all,

I have a small doubt. In my application I have two screens.

1st Screen have the drop downs which will be populated by BAPIONE.

2nd Screen is having a table which will be populated by BAPITWO.

I am populating screen 1 with the help of BAPI ONE and after selecting the values in the dropdowns, these values in the dropdowns will go to input (import parameters) of BAPI TWO and screen will navigate to 2nd screen, where table should be populated by out put of BAPI TWO.

Now my doubt is, I am able to populate the drop downs, and getting the values of drop downs and setting it in ONACTION SEARCH() method (search is the button in first screen)

String  str=wdcontext.currentXXX1.getXXX();  // getting the selected values from     dropdown
wdcontext.currentXXX2.setXXX(str);    //setting it to bapi 2 (table)

wdThis.wdgetXXcontroller.excuteXXX();

But I am not able to populate the table. Is it correct what I am doing? or else please guide me how to populate the table

Accepted Solutions (1)

Accepted Solutions (1)

arun_srinivasan
Contributor
0 Kudos

Hi

1) Create a context mapping between view and component controller for value attribute XXX

2) In the controller

xx mthd

{

String getvalue=wdcontext.currentcontextelement.getXXX();

Z<bapi name> zb=new Z<bapi name>();

wdContext.nodeZ<bapi name>. bind(zb);

Zb.set<import parameters>=xxx;

.... execute the model

// codes for populating the data to the table from export

}

Thanks and Regards,

Arun

Former Member
0 Kudos

thanks for your reply, I have written that code already, and mapping also done.

Where I need to write getter and setters in onActionSearch() or domodifyview()?

and one more thing, Is my code is OK or I need to populate the table by taking a loop (for loop) and retrieving the values??

arun_srinivasan
Contributor
0 Kudos

hi

1) If the export is a <b>table structure</b> you can directly bind it to table UI

2) write the execute the setting code in component ctrl execute mthd or else

map the component ctrl xxx va to view 2 . write the code in inbound plug method of view 2

Thanks and Regards,

arun

Former Member
0 Kudos

Thanks guys,

As of now it is working fine with the same old code, may be there was no data in the BAPI 2 itself. So sorry for taking your precious time.

I am not closing the post now because i think I may need more clarifications on same issue in next 1-2 days. If it solved permanently then I will close the post and give rewards to you.

Thank you very much....

Former Member
0 Kudos

Hi Pradeep,

The getter and setter can be written in the component controller method just before executing the BAPI. domodifyview is for entirely different purposes.

Are you binding the model node directly to the table? If yes, you wont have to loop through for retreiving the values. Check the following:

1. Have you created element for the Node properly before executing the Bapi?

2. Have you invalidated the output node after executing the Bapi?

3. Have you missed any mandatory parameters for executing the particular Bapi?

You can also try to debug the application by inserting an external debugger in the particular RFC in the backend.

Add the following piece of code in the catch part of the method that executes the Bapi:

catch (WDDynamicRFCExecuteException ce) {

MessageManager manager = wdComponentAPI.getMessageManager();

IWD

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

}

Regards,

Shyam.

Answers (3)

Answers (3)

Former Member
0 Kudos

problem was with BAPI data.

former_member751941
Active Contributor
0 Kudos

Hi Pradeep,

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

Former Member
0 Kudos

can I add custom (my own) attributes or node in bapi structure?? I have a Bapi struture and i want to add some attributes under it and want to use those. Can I do that??

Former Member
0 Kudos

Yes Pradeep,

You can do that ....In the Bapi Node create Value Node add attributes to Value Node accroding to your requirement and Development Business logic accroding to you.

Example:

BapiNode

---OutPutNode

<b>-----CreateValueNode

-


attribute1

-


attribute2</b>

Rgds

-SS

former_member751941
Active Contributor
0 Kudos

Hi Pradeep,

Yes you can add.Option is there but if you want to a custom structure it is better to use a "ValueNode" instead of modifying the "ModelNode" that you are getting from "BAPI".using "ValueNode" you create your own structure with required attribute.

Regards,

Mithu

Former Member
0 Kudos

ok... thank you

Former Member
0 Kudos

Hi,

if u want to fire some value from 1 view to other view,u have to create parameter for particular outbound plug.....

for eg. u creating Value as parameter to outbound plug

write code like this,

wdThis.wdgetXXcontroller.excuteXXX(Value);