Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

Order loses freight when transferred to invoice.

Posted on by 280

We do all our shipping from one GP company called Windy.  We have a few other companies where the orders get copied over to Windy, shipped, and then the original order in the source company is updated.

We have 2 companies where this works perfectly.  A third company, however has a problem.  The order comes back from Windy and the freight does get added into the document, and the document amount is increased by the freight amount.  But, when transferred to invoice, the freight dissapears.

Am I missing some other field that needs the freight populated or something?

Here is a copy of the SP that brings back the shipped order info:

ALTER PROCEDURE [dbo].[Nextec_UpdateWebOrders_SAM]
AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
        SET NOCOUNT ON ;
       
        -- Process all cross database queries in one transaction so that if errors arise, all can be rolled back.
        BEGIN TRANSACTION
       
        -- =============================================
        -- Add batch if it doesn't exist
        -- =============================================
        DECLARE @strdate CHAR(20)
        DECLARE @noteindex NUMERIC(19, 5)
        DECLARE @newbachnumb CHAR(15)
 
        -- Set batch number variable
        SELECT  @newbachnumb = 'SAMTIN SHIPPED'
       
        -- Check if new batch number exists in batch table
        -- if not, insert a dummy row which we'll later update
        -- with actual values
        IF NOT EXISTS ( SELECT  bachnumb
                        FROM    SAMTI.dbo.sy00500
                        WHERE   bachnumb = @newbachnumb )
            BEGIN
                -- To satisfy check constraints, GLPOSTDT, MODIFDT, and CREATDDT cannot include time (hour, minute, second,
                -- millisecond must be 0); therefore, convert the date returned by GETDATE function.
                SET @strdate = CONVERT(CHAR(20), GETDATE(), 101)
 
                -- get next note index to assign to the new batch
                SELECT  @noteindex = noteindx
                FROM    dynamics..sy01500
                WHERE   interid = DB_NAME()
                UPDATE  dynamics..sy01500
                SET     noteindx = noteindx + 1
                WHERE   interid = DB_NAME()
 
                INSERT  INTO SAMTI.dbo.SY00500
                        (
                          GLPOSTDT,
                          BCHSOURC,
                          BACHNUMB,
                          SERIES,
                          BACHFREQ,
                          BCHCOMNT,
                          CHEKBKID,
                          MODIFDT,
                          CREATDDT,
                          NOTEINDX,
                          BCHSTTUS,
                          ORIGIN
                        )
                VALUES  (
                          @strdate,
                          'Sales Entry',
                          @newbachnumb,
                          3,
                          1,
                          'Shipped or partially shipped from Windy Hill',
                          'CHARTER ONE',
                          @strdate,
                          @strdate,
                          @noteindex,
                          0,
                          1
                        )
            END
                  
        -- =============================================
        -- Check for existing tracking info in SAMTI
        -- for each order, if none exists, insert
        -- info from WINDY
        -- =============================================
        INSERT  INTO SAMTI.dbo.SOP10107
                (
                  SOPNUMBE,
                  SOPTYPE,
                  Tracking_Number
                       
                )
                SELECT  W1.SOPNUMBE,
                        W1.SOPTYPE,
                        W1.Tracking_Number
                FROM    WINDY.dbo.Nextec_WebOrder_TrackingInfo_SAM W1
                        LEFT OUTER JOIN SAMTI.dbo.SOP10107 P1 ON W1.SOPNUMBE = P1.SOPNUMBE
                                                              AND W1.SOPTYPE = P1.SOPTYPE
                                                              AND W1.Tracking_Number = P1.Tracking_Number
                WHERE   P1.SOPNUMBE IS NULL
       
        -- =============================================
        -- Update SAMTI Line Items with WINDY Data
        -- =============================================
        UPDATE  SAMTI.dbo.SOP10200
        SET     QTYTBAOR = W1.QTYUNFF,
                QTYFULFI = W1.QTYFULFI,
                QTYTOINV = W1.QTYTOINV,
                ACTLSHIP = W1.ACTLSHIP
        FROM    SAMTI.dbo.SOP10200 P1
                INNER JOIN ( SELECT T1.SOPTYPE,
                                    T1.SOPNUMBE,
                                    T1.ITEMNMBR,
                                    T1.LNITMSEQ,
                                    T1.QTYUNFF,
                                    T1.QTYFULFI,
                                    T1.QTYTOINV,
                                    T1.ACTLSHIP
                             FROM   WINDY.dbo.Nextec_WebOrders_SAM T1
                           ) W1 ON P1.SOPTYPE = W1.SOPTYPE
                                   AND P1.SOPNUMBE = W1.SOPNUMBE
                                   AND P1.ITEMNMBR = W1.ITEMNMBR
                                   AND P1.LNITMSEQ = W1.LNITMSEQ
                                  
        -- =============================================
        -- Update SAMTI Order Headers with WINDY Data
        -- =============================================
        UPDATE  SAMTI.dbo.SOP10100
        SET     ACTLSHIP = W1.ACTLSHIP,
                BACHNUMB = @newbachnumb,
                FRTAMNT = W1.FRTAMNT,
                /* SUBTOTAL = W1.SUBTOTAL + W1.FRTAMNT, */
                DOCAMNT = P1.DOCAMNT + W1.FRTAMNT

        FROM    SAMTI.dbo.SOP10100 P1
                INNER JOIN ( SELECT DISTINCT
                                    T1.SOPTYPE,
                                    T1.SOPNUMBE,
                                    T1.ACTLSHIP,
                                    T1.BACHNUMB,
                                    T1.FRTAMNT,
                                    T1.SUBTOTAL,
                                    T1.DOCAMNT
                             FROM   WINDY.dbo.Nextec_WebOrders_SAM T1
                           ) W1 ON P1.SOPTYPE = W1.SOPTYPE
                                   AND P1.SOPNUMBE = W1.SOPNUMBE
       

        -- =============================================
        -- Ensure the transaction returns no errors,
        -- otherwise undo changes and return error
        -- =============================================
        IF @@ERROR <> 0
            BEGIN
                ROLLBACK TRANSACTION
                RETURN @@ERROR
            END
        ELSE
            BEGIN
                COMMIT TRANSACTION
            END
    END


*This post is locked for comments

  • Scott Emick Profile Picture
    Scott Emick 280 on at
    Re: Order loses freight when transferred to invoice.

    Thanks so much! I just had to update the ORFRTAMT as you suggested and it works perfectly!

    Scott

  • Verified answer
    Tim Foster Profile Picture
    Tim Foster 8,515 on at
    Re: Order loses freight when transferred to invoice.

    I checked the Integration guide for SOP_HDR_WORK (SOP10100) from the SDK....

    You might look at the column SOP HDR Flags (SOPHDRFL).  It indicated whether amount have already been transferred

    1=Freight Transferred

    2=Misc Transferred

    3=Trade Discount Transferred

    You should be setting the Originating version of the monetary field you are updating as well.

    Before transferring to an Invoice use the Sales Reconcile feature to reconcile the order and see if anything is updated by the routine - this will be what you're missing.

    Tim

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans