cancel
Showing results for 
Search instead for 
Did you mean: 

Searching in context result values of a BAPI

Former Member
0 Kudos

Hi!!!!

I am calling a BAPI that gets the partner list of a given customer. The function below is used to find the partner with the role "SP", obviusly I give to the BAPI a customer that has a partner with such role. I am debugging the app and I see that I always get the function of the first partner (in variable x) and it doesn't go to the second element and so on. The partner that have the SP role is the fourth element, so I never get it.


  public java.lang.String getP( )
  {
    String funcion = "";
    int sizePartners = wdContext.nodePartners().size(); //It gets the correct size of the result
    for (int i=0; i < sizePartners; i++){
    	wdContext.nodePartners().getPartnersElementAt(i); //Here is where something is wrong
		String x = wdContext.currentPartnersElement().getParvw();
		if (wdContext.currentPartnersElement().getParvw() == "SP"){
			funcion = wdContext.currentPartnersElement().getKunn2(); 
		}
    }
	return funcion;
  }

Can you tell me if something is wrong? Please help me

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Fixed code



public java.lang.String getP( )
  {
    String funcion = "";
    int sizePartners = wdContext.nodePartners().size(); //It gets the correct size of the result
    for (int i=0; i < sizePartners; i++){
    	IPartnersElement element = wdContext.nodePartners().getPartnersElementAt(i); 		String x = element.getParvw();
		if (element.getParvw().equals("SP")){
			funcion = element.getKunn2(); 
		}
    }
	return funcion;
  }

Regards

Ayyapparaj

Answers (2)

Answers (2)

former_member192434
Active Contributor
0 Kudos

Hi

Use ur code in this way

public java.lang.String getP( )

{

String funcion = "";

int sizePartners = wdContext.nodePartners().size(); //It gets the correct size of the result

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

String x = wdContext.nodePartners().getPartnersElementAt(i).getParvw();

if (x.equalgnoreCase("SP")){

funcion = wdContext.currentPartnersElement().getKunn2();

}

}

return funcion;

}

Thanks

former_member182294
Active Contributor
0 Kudos

Hi Miguel,

Yes, you already pointed where it is wrong. Just change the line of code from

wdContext.nodePartners().getPartnersElementAt(i); //Here is where something is wrong

to

wdContext.nodePartners().setLeadSelection(i);

Regards

Abhilash