cancel
Showing results for 
Search instead for 
Did you mean: 

How to Update a Order Sales Document field after Add button is click?

Former Member
0 Kudos

Hello,

I want to update project partner fields in Sales Order form with a project code generate .

I want to update "Project" fields in "ORDR" table with RecordSet when Ok Button fevent click fired.

I want to know how to do this update operation in public virtual void OnAfterClick(ItemEvent pVal) {}

to be sure that the Order is create in the database before this update.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Thank Edy,

I try and i have a good issue.

Regards

Bertrand

edy_simon
Active Contributor
0 Kudos

Hi,

You are not supposed to update system object with recordset.

I suggest to use DI Object as much as you can.

for your current problem, you can trap the FormData_Add event.


        If BusinessObjectInfo.FormTypeEx = "139" And BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD And BusinessObjectInfo.BeforeAction = False And BusinessObjectInfo.ActionSuccess = True Then
            Dim oOrder As SAPbobsCOM.Documents
            oOrder = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)

            oForm = SBO_Application.Forms.Item(BusinessObjectInfo.FormUID)
            oEdit = oForm.Items.Item("8").Specific
            Dim sDocNum As String = oEdit.String

            Dim oRS As SAPbobsCOM.Recordset
            oRS = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

            oRS.DoQuery("Select DocEntry FROM ORDR WHERE DocNum = '" & sDocNum & "'")
            oOrder.GetByKey(oRS.Fields.Item(0).Value)
            oOrder.Project = "TEST"
            oOrder.Update()

        End If

Hope it helps.

Regards

Edy