cancel
Showing results for 
Search instead for 
Did you mean: 

Mandatory Fields & Transaction Notifications

Former Member
0 Kudos

Hi,

I've been reading various other threads about stopping the Form ADD process if a field is empty on the form - hence making the user enter data.

I have read various examples none of which make sense to me, if anyon has any full subroutine examples I would appreciate it.

Going to search the rest of the forums........

Private Sub oApplication_FormDataEvent(ByRef BusinessObjectInfo As SAPbouiCOM.BusinessObjectInfo, ByRef BubbleEvent As Boolean) Handles oApp.FormDataEvent
        If BusinessObjectInfo.FormTypeEx = "149" And BusinessObjectInfo.BeforeAction = True And BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD Then
            Try
                Dim oform As SAPbouiCOM.Form
                oform = oApp.Forms.GetForm("149", 1)
              
                '***************************
                '
                'add code to make certain fields mandatory
                '
                '***************************
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End If

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

For that i use the Item Event. I check on the Button click if the fields required by me are empty or not.

Then i show the error msg, Check the following sample which i use...

Public Sub SBO_Appln_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean)

   If pVal.BeforeAction = True Then
       Select Case pVal.EventType
                   Case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED
                             If pVal.FormMode = 3 And pVal.ItemUID = "1" Then 'Add Mode
                            objMatrix = objForm.Items.Item("matIndent").Specific
                            If ValidateHeaderData(objForm) = False Then
                                objUtility.ShowErrorMessage("Please fill all the header details.")
                                BubbleEvent = False
                                Exit Sub
                            End If
End IF    
   End If

End Sub

And for the ValidateHeaderData the following is the code..

Public Function ValidateHeaderData(ByVal oForm As SAPbouiCOM.Form) As Boolean
        Dim strReqDate, strReqester, strApprover, strClosingDate As String
        objEdit = oForm.Items.Item("txtReqDate").Specific
        strReqDate = objEdit.String
        objEdit = oForm.Items.Item("txtDocClD").Specific
        strClosingDate = objEdit.String
        objEdit = oForm.Items.Item("txtReqUser").Specific
        strReqester = objEdit.String
        objEdit = oForm.Items.Item("txtAppro").Specific
        strApprover = objEdit.String

        If strReqDate = "" Or strClosingDate = "" Or strReqester = "" Or strApprover = "" Then
            Return False
        Else
            Return True
        End If

    End Function

Hope it helps u..

Vasu Natari.

Answers (2)

Answers (2)

Former Member
0 Kudos

Many Thanks Vasu & Binita

I didn't realise it was that simple i was almost there!

The only thing is I was trying to use the status bar for the error msg

oApp.SetStatusBarMessage("Status Reasons has not been entered", SAPbouiCOM.BoMessageTime.bmt_Long, True)

But now it has "Action Stopped by Addon UI_API........" which cannot be replaced.

I will settle for msg boxes.

Dave.

Edited by: David Alexander on Sep 25, 2008 3:18 PM

Former Member
0 Kudos

David,

bubbleevent false has never worked in FormData event. atleast with me. because I think, that event fires when the data is added after clearing all validations test.

so the right place to place user validation would be to either catch click event of item '1' (add button) with before action true and set bubbleevent to false if something is missing or use transaction notification process if you do not want to create addon for that.

something like this :



 If pVal.FormType = "139" And pVal.ItemUID = "1" And pVal.EventType = SAPbouiCOM.BoEventTypes.et_CLICK And pVal.Before_Action = True Then
            Try
                oform = oApp.Forms.ActiveForm
                If oform.Items.Item("16").Specific.value = "" Then
                    MsgBox("remarks not there")
                    BubbleEvent = False

                End If

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End If

regards,

Binita

Edited by: Binita Joshi on Sep 25, 2008 2:46 PM

Edited by: Binita Joshi on Sep 25, 2008 2:50 PM