How to update GL posting date on a receivables transaction

Published: Dec 08, 2011
Post Author Written by eOne Solutions

There is nowhere to map a GL posting date when creating a receivables transaction. How can I set the posting date to the current date?

If your posting setup is set so that the posting date is coming from the batch date, you can use the following script to update the GL posting date on the batch. In your “Create Transaction” mapping, hit the Restrictions button to place a script there. Your script should read as follows: 

‘Beginning of script
return true
‘end of script

Replace _BATCHNAME with the name of the column in our source file that contains the batch name. So for example, if the column is named BATCHNUM, then your script should say “GlobalMessage=_BATCHNUM”

You need to create an after map success script to update the batch after the map succeeds. Hit the GoTo button in the main mapping window and select Tasks – Map – After – Success. Add a new task of the “Script” type In the script, place the following text

‘Beginning of script
‘Script Name: UpdatePostingDate
‘ Created On: 01/18/2009
‘ Author: Chris Hanson
‘ Purpose: This script updates the batch posting date in SQL Server.
‘ History:
‘ 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 = “DS-SRV-01”
Dim database As String = “TWO”
Dim user As String = “sa”
Dim password As String = “pass@word1”
Dim sqlQuery As String = “UPDATE SY00500 SET GLPOSTDT = ‘” & DateTime.Now.ToString(“yyyy-MM-dd 00:00:00.000”) & “‘ where BCHSOURC = ‘RM_Sales’ 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) myConn.Open()
‘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) command.ExecuteNonQuery()
‘Close the connection
myConn.Close() Catch ex As Exception Messagebox.Show(ex.Message, “UpdatePostingDate Script Error”)
Return False
End Try
Return True
‘End of script

Feeling stuck? Get the support and guidance you need to help you power through any data challenge

We're on your integration team. Connect with our people and let us know how we can help you.