cancel
Showing results for 
Search instead for 
Did you mean: 

Copy fields when form is saved

Former Member
0 Kudos
109

Very simple one,

When I add a new sales quote I want the Total Value edit box to be copied to my Expected Value edit box, as the data is not added to the table yet I thought it would all be available as stings in the edit boxes, hence the following:

If pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD And pVal.FormType = 149 And pVal.Before_Action = True Then

oApp.Forms.Item("149").Items.Item("oEdit4").String = oApp.Forms.Item("149").Items.Item("29").String

End If

Please excuse any stupidity, its a steep learning curve......

Thanks,

Dave.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I guess that should work fine.. are u getting any errors..??

Vasu Natari.

Former Member
0 Kudos

Hi Vasu, Yes I thought it would work also, no errors just the typical nothing happens......

Nussi
Active Contributor
0 Kudos

David,

EDIT:

ok, you tried it.

if you want to access the Form with the Type try Binitha's code -> use ActiveForm

lg David

Edited by: David Nussböck on Sep 24, 2008 10:51 AM

Former Member
0 Kudos
If pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD And pVal.FormType = 149 And pVal.BeforeAction = True Then
                Dim oform2 As SAPbouiCOM.Form
                oform2 = oApp.Forms.GetForm("149", 1)
                oApp.Forms.Item(oform2).Items.Item("oEdit4").String = oApp.Forms.Item(oform2).Items.Item("29").String
            End If

Bit of everything involved now.....

And still nothing, I apreciate the help though!!!

Nussi
Active Contributor
0 Kudos

Hi,

a correct sample:

.
If pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD And pVal.FormType = 149 And pVal.BeforeAction = True Then
  Dim oform2 As SAPbouiCOM.Form
  oform2 = oApp.Forms.ActiveForm
  oform2.Items.Item("oEdit4").String = oform2.Items.Item("29").String
end if

you're accessing the oform2 object wrong

lg David

Former Member
0 Kudos

Ah yes the paniced test, If i back up the code a little:

Private Sub oApp_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles oApp.ItemEvent
        Try
           If pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD And pVal.FormType = 149 And pVal.BeforeAction = True Then
                Dim oform2 As SAPbouiCOM.Form
                oform2 = oApp.Forms.ActiveForm
                oform2.Items.Item("oEdit4").String = oform2.Items.Item("29").String
            End If
        Catch ex As Exception
            oApp.MessageBox(ex.ToString)
        End Try
    End Sub

This is the extent of the subroutine, and I still get nothing.

My main problem is that due to time constaints I'm panicing and copying rather than thinking about it.....

Former Member
0 Kudos

R u adding any event filters for ur code.. and did u debug line by line....

or just try to 1st show the values in message boxes. Stay Cool.

Vasu Natari.

Former Member
0 Kudos

David,

i think you are catching wrong event altogether,

try this.


If BusinessObjectInfo.FormTypeEx = "149" And BusinessObjectInfo.BeforeAction = True And BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD Then

            Try
                Dim oform2 As SAPbouiCOM.Form
                oform2 = oApp.Forms.GetForm("149", 1)
                'MsgBox(oform2.Items.Item("29").Specific.value)
                oform2.Items.Item("oEdit4").Specific.value = oform2.Items.Item("29").Specific.value
         Catch ex As Exception
                MsgBox(ex.Message)
            End Try
         End If

and this is under FormDataEvent. NOT Itemevent.

Binita

Edited by: Binita Joshi on Sep 24, 2008 11:20 AM

Former Member
0 Kudos
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 oform2 As SAPbouiCOM.Form
                oform2 = oApp.Forms.GetForm("149", 1)
                MsgBox(oform2.Items.Item("29").Specific.value)
                oform2.Items.Item("oEdit4").Specific.value = oform2.Items.Item("29").Specific.value
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End If
    End Sub

ahhhhhhhhh, genious, that msg box is firing, just getting bad value message now, but i can work through that.....

Thankyou very much!

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Try pVal.BeforeAction = True instead of pVal.Before_Action = True

Hope it helps,

Vasu Natari.

Nussi
Active Contributor
0 Kudos

Hi David

in your ItemEvent Handler you should have a variable called FormUID or at least pVal.FormUID

so access it with:

oApp.Forms.Item(FormUID).Items.Item("oEdit4").String = oApp.Forms.Item(FormUID).Items.Item("29").String

lg David

Former Member
0 Kudos

or straightaway initialize the form as


Dim oform As SAPbouiCOM.Form
oform = oApp.Forms.ActiveForm
'or
oform = oApp.Forms.GetForm("149", 1)

Binita

Former Member
0 Kudos

Hi David,

I have tried you suggestion so with the Form_Data_Add event handler on FormUID rather than FormType, Now when I run the program SAP makes a quick exit from my PC.....

I undertstand that FORMUID make alot of sense but FORMTYPE was in all my examples and formtype works with the FORMLOAD event handler.

Theres alot of things that don't make sense and alot of the object definitions are "Undefined"