cancel
Showing results for 
Search instead for 
Did you mean: 

Validating UDF Field

Former Member
0 Kudos

Dear All,

How can I validate a UDF field in Business Partner screen? As I don't want to set any default value for that UDF, I could not make it as Mandatory also. Please help me to resolve this problem.

Thanks in advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Or u can also check for the value of the UDF of the Button Press in Add and Update mode....

Vasu Natari.

Former Member
0 Kudos

Hi Vasu,

How can I get the Value of the UDF? Can you give me the Code Snippet for that?

Former Member
0 Kudos

Well u can get the value of the UDF with a Edit Text. Just chekc the code snippet...

Dim oEdit as SAPboUI.EditText
Dim strUDFVal as String
oEdit = oForm.Items.Item("UDF").Specific
strUDFVal = oEdit.String
If strUDFVal = ""
    MsgBox("Plz enter the correct value")
EndIF

And for the form object, to get the value of the UDF form its the negative of the form ID,

So for BP Master its "134" so for the UDF its "-134".

Hope it helps,

Vasu Natari.

Former Member
0 Kudos

Hi Vasu,

If I give the formid like this


objform=objapplication.forms.item("-134")

I got an error message " Invalid formid'

Former Member
0 Kudos

Where did u execute this, is the UDF form open at the time of execution..??

Vasu Natari.

former_member201110
Active Contributor
0 Kudos

Hi,

The SBO_sp_TransactionNotification proc can be used for this type of validation but you could also use code in your addon. The benefit of using the proc is that this will work with BPs created using the DI API (eg DTW import or another addon).

As you are only trying to read data on a system form, you can use the DBDataSources already attached to it to check the UDF value. This is a better solution because it does not rely on the UDF tab being open. You cannot use this method to write to the UDF due to the restrictions on a system form.

You could add something like the following to the item pressed event (when BeforeAction is true) of the Add button on the BP form:


SAPbouiCOM.DBDataSource sboDS = (SAPbouiCOM.DBDataSource)sboForm.DataSources.DBDataSources.Item("OCRD");

string sValue = sboDS.GetValue("U_MYUDF", 0).TrimEnd();

if(sValue == "")
{
      BubbleEvent = false;
      _sboApp.SetStatusBarMessage("You must enter a value in the UDF", SAPbouiCOM.BoMessageTime.bmt_Long, true);
}

You'll also need to check the form mode to make sure you only validate the field when the form is in Add or Update mode.

Kind Regards,

Owen

Former Member
0 Kudos

Hi Owen and Vasu,

Your answers solved my problem. Thank you.

With Regards,

Tamil

Former Member
0 Kudos

The easiest way is use transaction notification stored procedure. Try to search in history of this forum and youll see many code examples how to do it.