cancel
Showing results for 
Search instead for 
Did you mean: 

Search Help Issue

Former Member
0 Kudos

Hello Everyone,

I have been developing a Purchase order Application using the BAPI "BAPI_PO_CREATE". For few input fields we needed to give the option of Search help. So, I used the search help method and created a search help button for the "Vendor" inputfield. Now, after searching for the vendor number using the search help and selecting it to get it in to my vendor inputfield, the BAPI is not recognising the Vendor number because it is looking for "zeros" infront of the vendor number. Do you know what I mean?

For example:- My search help returned a Vendor number:- "722". If I send this value to the BAPI it is erroring saying "No master record exists for vendor 722". This is because it is taking the vendor number as "7220000000" instead of "0000000722". How do I resolve this problem.

Let me know, if my explanation is not clear. I'll try to explain in more detail.

Please help me to resolve this problem. I would appreciate your help.

Regards,

Gopal.

Accepted Solutions (1)

Accepted Solutions (1)

former_member205363
Contributor
0 Kudos

Hi Gopal,

I have a doubt whether we need pass a String or int (Vendor No) to the RFC.

If you are able to pass String value to the RFC then you can convert the int value to String and pass to the RFC.

int i = vendorNo; // Vendor Input Field value

String convertedVendorNo = null;

convertedVendorNo = Integer.toString(i);

System.out.println(convertedVendorNo.length());

int size = convertedVendorNo.length();

for(int j=0;j < (10 - size);j++){

convertedVendorNo = "0" + convertedVendorNo;

}

Send the variable "convertedVendorNo" value to the RFC.

please let me know if it wont work

Regards,

Lakshmi Prasad.

Former Member
0 Kudos

Hi Prasad,

FYI

The VendorNo is not "int". It is a "String". I'll try your code and will get back to you if any progress.

Thanks a lot for your help.

Regards,

Gopal.

Answers (2)

Answers (2)

Former Member
0 Kudos

Gopal,

The moment before you execute your RFC call in your custom controller, make sure your vendor attribute has leading zeros like

vendorAtt = LeadingZeros(vendorAtt, 10);

where LeadingZeros() is a private method with the conversion.

Hope this helps.

Regards,

Alain

Former Member
0 Kudos

Hi Alian,

Thanks a lot for your reply. What should I write the code in the Private method to insert "00"'s infront of the Vendor number. Please help me ro resolve this issue. I would appreciate your help.

Regards,

Gopal.

Former Member
0 Kudos

Gopal,

Try this:

private String LeadingZeros(String att, int maxLength) {

	String result = att;
	while (result.length() < maxLength) {
		result = "0" + result;
	}
	return result;
}

Regards,

Alain

Former Member
0 Kudos

Hi Alian,

I have used your code and it doesn't work. Later I have used the code mentioned by Armin in the following link. But, it is still not working. I tried to print the value and it is changing the value before sending it to the BAPI. I dont understand why it is still not working.

Please help me to resolve this issue. I would appreciate your help.

Regards,

Gopal.

Former Member
0 Kudos

Gopal,

Code is working fine in my case and I can't see anything wrong with it. Make sure nothing "happens" to your attribute between conversion and the actual RFC call. Also make sure there are no leading and trailing space in your attribute,

 vendorAtt = LeadingZeros(vendorAtt.trim(), 10);

Hope this helps.

Regards,

Alain

Former Member
0 Kudos

HI,

this looks like a prob with data type in R/3.

may be ucan try taking the vendor number into a string assign it to another attribute and have the search help for that attribute.?

Regards,

Satya.