SAPGUI Edit "Bad Length" error message when setting a value
When you try to set a value in a SAPGUI Edit object, QTP throws an error message about the length of the string you are providing.
Seems the issue is reproducible for specific versions of the SAP Server and caused by SAP.
SAP Server provides to QTP the Max Length value based on the default value on the SAP EditBox, this way if the default value has a maxlength of 4 characters, this will be the value that QTP will use in the validation when you are setting a new value in the SAP EditBox.
For example if by default you have the value: “.xls” it will provide to QTP the max length value = 4. This way, when QTP is trying to use the Set method, the internal validation of QTP fails because the value provided its mayor than the MaxLength got from the SAP Server and this way you get the popup message.
The Workaround to prevent this problem is to assign the text using the SAP Object Directly, this way you bypass the QTP verification of the string length and you won’t get the error message: