Skip to Content
0
Former Member
May 27, 2008 at 05:29 PM

How I copy data after a Sytem Form succesfully processed

12 Views

Hi all,

I want after the Credit Note succesfully processed to run a Delivery Note with copied data from this Credit Note. I tried the following code. However if "before_action = True" I cannot control the "succesful processing of Credit Note". If I turn to "False" then I cannot copy data from Credit Note to DN.

Any Idea?

Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pval As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent

Try

If (pval.FormType = 179) And (pval.ItemUID = "1") And (pval.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) And (pval.Before_Action = True) Then

Dim lretcode As Integer

Dim sErrMsg As String

Dim f As SAPbouiCOM.Form

f = SBO_Application.Forms.Item(FormUID)

'Header Variables

Dim oEditCardcode As SAPbouiCOM.EditText 'Card Code

Dim oEditDocDate As SAPbouiCOM.EditText 'Doc Date

Dim oEditPostDate As SAPbouiCOM.EditText 'Posting Date

'cardcode

Dim strCardcode As String 'Cardcode

oEditCardcode = f.Items.Item("4").Specific

strCardcode = oEditCardcode.Value

'PostingDate

Dim DPostDate As Date

Dim strPostDate As String

oEditPostDate = f.Items.Item("10").Specific

strPostDate = oEditPostDate.Value

DPostDate = (CStr(oEditPostDate.Value).Substring(6, 2) & "/" & CStr(oEditPostDate.Value).Substring(4, 2) & "/" & CStr(oEditPostDate.Value).Substring(0, 4))

'DocDueDate

Dim DDocDate As Date

Dim strDocDate As String

oEditDocDate = f.Items.Item("12").Specific

strDocDate = oEditDocDate.Value

DDocDate = (CStr(oEditDocDate.Value).Substring(6, 2) & "/" & CStr(oEditDocDate.Value).Substring(4, 2) & "/" & CStr(oEditDocDate.Value).Substring(0, 4))

' Line Variables

Dim oEditItemCode As SAPbouiCOM.EditText 'item code

Dim oEditQuantity As SAPbouiCOM.EditText 'quantity

Dim ColCode As SAPbouiCOM.Column 'Item Code

Dim ColQuan As SAPbouiCOM.Column 'Quantity

Dim mInv As SAPbouiCOM.Matrix

mInv = f.Items.Item("38").Specific 'the items matrix

ColCode = mInv.Columns.Item("1")

ColQuan = mInv.Columns.Item("11")

Dim i As Integer 'Nr of Lines

i = 1

Dim y As Integer

y = 0

Dim lines_count As Integer

Dim oDeliveries As SAPbobsCOM.Documents

'Creation of Business Objects

oDeliveries = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes)

' A.CREATE DELIVERY NOTE

' A1. HEADER

oDeliveries.CardCode = strCardcode

oDeliveries.DocDate = DPostDate

oDeliveries.DocDueDate = DDocDate

'A2. LINES

lines_count = mInv.RowCount - 1

Do

Dim strItemCode As String

oEditItemCode = ColCode.Cells.Item(i).Specific

strItemCode = oEditItemCode.Value

'get specific Line Quantity

Dim strQuan As String

oEditQuantity = ColQuan.Cells.Item(i).Specific

strQuan = oEditQuantity.Value

oDeliveries.Lines.ItemCode = strItemCode

oDeliveries.Lines.Quantity = CDbl(strQuan)

If i <> lines_count Then

'Add Document Lines at the Document Object

oDeliveries.Lines.Add()

End If

y += 1

i += 1

Loop Until y = lines_count

lretcode = oDeliveries.Add()

If lretcode <> 0 Then

oCompany.GetLastError(lErrCode, sErrMsg)

SBO_Application.MessageBox(lErrCode & " " & sErrMsg)

Else

SBO_Application.MessageBox("u03A4u03BF u03A0u03B9u03C3u03C4u03C9u03C4u03B9u03BAό u0391u03BEu03B9ώu03BD u0394u03B7u03BCu03B9u03BFu03C5u03C1u03B3ήu03B8u03B7u03BAu03B5 u03BCu03B5 u0395u03C0u03B9u03C4u03C5u03C7ίu03B1")

SBO_Application.Menus.Item("520").Activate()

End If

End If

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

End Sub

Thanks in Advance,

Vangelis