Writing to SY00500 table
The problem I'm having is writing the batch total, which should be in GBP after translation, to the SY00500 table so it shows up in the Batch Entry screen.
Any advice on how make this happen?
Sean, I did this yesterday for updating the Post Date on the Batch in the sy00500. Can you use this methodology – just changing the update statement to your total amount instead of post dating? Restriction on Create Transaction Node – Cambridge is the batch ID; you could also specify a source field.
return true SCRIPT: '—————————————————————————————
' Script Name: UpdatePostingDate
' Created On: 01/18/2009
' Author: Chris Hanson
' Purpose: This script updates the batch posting date in SQL Server.
' Requirements: This script should be located in the Tasks -> Map -> After -> Success
' section of the SmartConnect map setup. In the case of this template,
' the GlobalMessage global variable is being set to the batch number
' in the restriction when the map runs, then this script uses it to
' update the posting date in the SY00500.
' Setup: There are five variables to assign in the configuration section. The
' first four determine which values are used in the connection string.
' Those four variables – the server (data source), database (initial
' catalog), user, and password should be changed to the needed values.
' The last variable, sqlQuery, contains the query message that is going
' to be executed. This needs to be changed to reference an actual table
' and its corresponding columns before the script will run.
'———————————– CONFIGURATION ————————————-
Dim server As String = "SQLINSTANCE"
Dim database As String = "DBNAME"
Dim user As String = "USERID"
Dim password As String = "PASSWORD"
Dim sqlQuery As String = "UPDATE SY00500 SET GLPOSTDT = '" & DateTime.Now.ToString("yyyy-MM-dd 00:00:00.000") & "' where BCHSOURC = 'Sales Entry' and BACHNUMB = '" & GlobalMessage & "'"
Try 'Declare the connection string based on the configuration variables
Dim conString As String = "Data Source=" & server & ";Initial Catalog=" & database & ";User=" & user & ";Password=" & password & ";"
'Define the SQL connection and open it
Dim myConn As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(conString)
'Declare the SQL command as the query string and execute it
Dim command As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(sqlQuery, myConn)
'Close the connection
Catch ex As Exception
Messagebox.Show(ex.Message, "UpdatePostingDate Script Error")
Your reply was quite helpful. I ended up executing a basic SQL command under the Tasks that run if the document succeeds item of the Document Tasks section.
Here is a blog we have on it:
If you would like to submit an answer or comment, please sign in to the eOne portal.