cancel
Showing results for 
Search instead for 
Did you mean: 

how to set the tables parameter to a BAPI using adaptive RFC model

Former Member
0 Kudos

Hi,

I have a BAPI ZBAPI that has a tables parameter ZPernr of type ZTable with two elements pernr and name.

I used adaptive RFC model and created model classes for the BAPI.

My question how do i set list of pernr and name to the tables parameter in the webdynpro for java.

I have the following methods available

ZBAPI input = new ZBAPI();

1.ZTable table = new ZTable();

table.setPernr(pernr);

table.setname(name);

input.addZPernr(table);

how do i set the table parameter for multiple pernr and name

2.

add all the pernr and name to list and set that list to input in the following way

input.setZPernr(list) and list of typecom.sap.aii.proxy.framework.core. AbstractList

out of two methods mentioned which one is correct.

Please let me know the solution

Thanks

Bala Duvvuri

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

I am sorry for not framing the question properly.

I have a BAPI ZHRECMFM_002_PERFRAT_WARNING AND TABLES PARAMETERS ARE PERNR_LIST of type HROBJECT and PERNR_PERFRAT of type ZHRECMGLS_002_PERNR_PERFRAT with two data elements pernr and text.

I need to send list of pernr in the first table parameter to BAPI and it will return list of pernr and their performance ratings in that second tables parameter.

Zhrecmfm_002_Perfrat_Warning_Input input = new Zhrecmfm_002_Perfrat_Warning_Input();

wdContext.nodePERFWARN().bind(input);

I am iterating thru pernrs and writing the code as shown below

List pernrList = new ArrayList();

pernrList.add(pernr);

input.setPernr_List(pernrList);

but it is giving syntax error at the last line saying that setPernr_List has an argument of type com.sap.aii.proxy.framework.core. AbstractList

How do i declare a variable of type AbstractList and add all the pernr and send it to BAPI

Once I execute the BAPI how do i iterate thru second table parameter PERNR_PERFRAT to get pernr and performance rating text

Edited by: Bala Duvvuri on Sep 8, 2008 1:20 PM

former_member191569
Active Participant
0 Kudos

Hi Bala,

you cannot use directly AbstractList class, you should use another class Web Dynpro created for you when reimported the RFC model.

Look for the Java class corresponding to your table elements, suppose <element_class>, and then use:

<element_class>.<element_class>_List list = new <element_class>_List();

...

input.setPernr_List(list);

Former Member
0 Kudos

thanks for the reply.But my table parameter PERNR_LIST is of type HROBJECT.

How will i pass a list of pernrs to the BAPI.

former_member191569
Active Participant
0 Kudos

An example:


activities = new __Data_A_001_Input();
wdContext.node<ModelNode>().bind(activities);

__B972__Aci_Actv00 element = new __B972__Aci_Actv00();
activities.addT_Codact(element);

IWDNodeElement e = wdContext.node<InputModelNode>().createElement(element);
wdContext.node<InputModelNode>().addElement(e);



where <InputModelNode> is child of node <ModelNode>


<element_class>.<element_class>_List list = new <element_class>_List();

<element_class> element = new <element_class>();
wdContext.node

...

input.setPernr_List(list);

former_member197348
Active Contributor
0 Kudos

Hi Bala,

In your code:

List pernrList = new ArrayList();

pernrList should be declared as the type of class HROBJECT ( The structure name in the model e.g. the node PERFWARN type is Zhrecmfm_002_Perfrat_Warning_Input )

Try this:


HROBJECT  pernrList = new HROBJECT();
pernrList.setPernr(pernr); 
input.setPernr_List(pernrList);
// call BAPI execute method

If you want to pass list of pernrs, you can pass in alternate way

IPrivate<viewname>.I<nodeame>Node prNode = wdContext.node<node>();
IPrivate<viewname>.I<nodeame>Element prEle;
 for (int i = 0; i < table.size(); i++) {
HROBJECT  pernrList = new HROBJECT();
pernrList.setPernr(pernr); // Set the pernr from current record
prEle = prNode.create<nodeame>Element(pernrList);
prNode.addElement(prEle);	
}
// call BAPI execute method

Once I execute the BAPI how do i iterate thru second table parameter PERNR_PERFRAT to get pernr and performance rating text

Say your node name is PERNR_PERFRAT

for (int i = 0; i < wdContext.nodePERNR_PERFRAT().size(); i++) {
wdContext.nodePERNR_PERFRAT().getPERNR_PERFRATElementAt(i).getPernr();
wdContext.nodePERNR_PERFRAT().getPERNR_PERFRATElementAt(i).getPerfrat();
}

Regards,

Siva

Former Member
0 Kudos

I am posting a new thread with clear eplanation.

so closing this thread.

Former Member
0 Kudos

Hi,

to set multiple data use the following code,

ZBAPI input = new ZBAPI();

wdContext.nodeZBAPI().bind(input);

ZTable table ;

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

table = new ZTable();

table.setPernr(pernr+i);

table.setname(name+i);

input.addZPernr(table);

}

executeBapi.

Regards,

ramesh

Edited by: Ramesh Babu V on Sep 8, 2008 6:33 PM

former_member197348
Active Contributor
0 Kudos

Hi Bala!

You need to loop through the table and in each iteration you have to create an element ,set its attribute and then add the element to the node. Finally execute the BAPI

e.g.

ZBAPI input = new ZBAPI();
for( //loop through table )
{
ZTable table = new ZTable();
table.setPernr(wdContext.node<table>().get<table>ElementAt(i).getPernr());
table.setname(wdContext.node<table>().get<table>ElementAt(i).getName());
input.addZPernr(table);
}

//call execute_BAPI()

Regards

Siva

Edited by: Siva Rama Krushna on Sep 8, 2008 6:34 PM