Sales Order Integration–Sales Person and Territory are not populated to Line Items
In one of the old environment GP 10 service pack 5, which is integrated with order-taking system, eConnect showed an abnormal case when importing sales orders into Dynamics GP. It is represented with migrating the sales person assigned to each customer for the SOP header table only without populating the sales person ID into the line item details.
Here is a sample of an imported invoice in which all the details are correct with no issues at all:
Sales Transaction Entry window
Clicking the blue arrow next to the customer, will open up the sales customer detail entry in which the sales person ID is populated correctly according to the setup configured on the customer card level
Sales Customer Detail Entry – Sales Person and Territory
On the other hand, clicking on one of the line item and checking the sales item detail entry shows that no “sales person” no “sales territory” is populated.
Sales Item Detail Entry = Sales Person and Territory
Concern:
And the question is, what are the consequences for such issue, what if the sales person ID is not populated to the detail level and being properly recorded on the header level ?
The sales amount of the sales person will be recorded correctly, since the total of the sales invoice will be added up to the sales of this sales person, and practically commissions are being calculated properly.
>> The problem is, you will not be able to report how much from a specific SKU this sales person has sold, only total numbers. For instance, the sales line items smart list will report nothing for the sales person, as you cannot filter neither by the territory nor the sales person id.
Issue Identification:
The issue is identified on the SQL level as shown below:
SELECT *
FROM ( SELECT SOPNUMBE ,SOPTYPE ,SLPRSNID ,SALSTERRFROM SOP10100) AS ALEFT OUTER JOIN ( SELECT SOPNUMBE ,SOPTYPE ,SLPRSNID ,SALSTERRFROM dbo.SOP10200) AS B ON A.SOPNUMBE = B.SOPNUMBEAND A.SOPTYPE = B.SOPTYPEWHERE ( B.SLPRSNID = ''OR B.SALSTERR = '')AND ( A.SLPRSNID <> ''AND A.SALSTERR <> '')
Matching sales person and territory details – SOP header versus details (SOP10100 and SOP10200)
eConnect is not passing neither the sales person ID nor the territory, leaving the default configuration to take effect once a sales order is imported. The result is having both fields populated in the header only leaving empty sales order details.
Resolution:
Method One
The easy method to get this done is practically to adjust the eConnect and pass both parameters for <taSopHdrIvcInsert> and <taSopLineIvcInsert>
Method Two:
Another method is to get this corrected in the work tables of Dynamics GP before being posted, through SQL jobs that tracks down such issues and correct it accordingly.
This can be done practically by proposing two different scenarios, the first one is to build an SQL solution which will track down the issue, correct every single record individually and keep a log for every single correction. The other scenario is to mass update the whole records once at a time.
Now lets start with the first scenario (Individual correction, with Log)
The first step is to create the views which will retrieve the corrupted records (Sales line item details missing sales person and territory data, while header has them populated correctly)
View Definition
The next step is to create a log table to keep track of every single update, the old and new values of the sales person id and sales territory fields.
Note:
Change the database included under “@database_name = N'TWO'”
The other scenario which comes with a better performance, but yet miss the structured log of the first scenario is to update all mismatched records according to the view mentioned above
Mass update mismatch records
IF EXISTS ( SELECT *FROM V_SalesTransactions_SalesPersonMatching )UPDATE SOP10200SETSLPRSNID =( SELECT HD_SLPRSNIDFROM V_SalesTransactions_SalesPersonMatchingWHEREV_SalesTransactions_SalesPersonMatching.DT_SOPNUMBE = dbo.SOP10200.SOPNUMBEAND V_SalesTransactions_SalesPersonMatching.DT_SOPTYPE = dbo.SOP10200.SOPTYPEAND V_SalesTransactions_SalesPersonMatching.DEX_ROW_ID = dbo.SOP10200.DEX_ROW_ID) ,SALSTERR =( SELECT HD_SALSTERRFROM V_SalesTransactions_SalesPersonMatchingWHEREV_SalesTransactions_SalesPersonMatching.DT_SOPNUMBE = dbo.SOP10200.SOPNUMBEAND V_SalesTransactions_SalesPersonMatching.DT_SOPTYPE = dbo.SOP10200.SOPTYPEAND V_SalesTransactions_SalesPersonMatching.DEX_ROW_ID = dbo.SOP10200.DEX_ROW_ID)WHERE DEX_ROW_ID IN ( SELECT DISTINCTDEX_ROW_IDFROMV_SalesTransactions_SalesPersonMatching )
- The individual records in SOP10200 will be revised and logically tested to check whether an update is required or not.
- An update on SOP10200 is run to match the sales person ID and territory ID with the ones in the SOP10100
- Log is kept accordingly for all the changes.
- View definition , V_SalesTransactions_SalesPersonMatching
- Table log definition, TB_UpdatedSalesPerson_Log
- SQL Job, Jb_Process_SalesPersonMismatching
- The individual records in SOP10200 will be revised and logically tested to check whether an update is required or not
- Mass update is performed on all the lines at once
- No log is kept
- View definition, V_SalesTransactions_SalesPersonMatching
- Mass update, Mass Update
Mahmoud M. AlSaadi
This was originally posted here.

Like
Report
*This post is locked for comments