SAPGUI Edit “Bad Length” error message when setting a value

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:

SAPGuiSession("…").SAPGuiWindow("…").SAPGuiEdit("…").Object.Text "abcdefg.xls"

Advertisements

One thought on “SAPGUI Edit “Bad Length” error message when setting a value

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s