Page 1 of 6612345678910...2025303540...Last »

DBMS: 12 Microsoft Dynamics GP: 0 error when updating to Microsoft Dynamics GP 2013 R2

Hello all! It’s been quite a while since I’ve actually written anything of remote interest to anyone who follows my blog, but at the same time, you will be pleased to know that I’ve been quite busy in the consulting front, with upgrades, server migrations, complex multi-instance postings involving 10’s of thousands of transactions, wrapping up some Field Service Automation projects, and the list goes on and on.


This time around I want to bring to the forefront, an issue I encountered updating from Microsoft Dynamics GP 2013 SP2 to Microsoft Dynamics GP 2013 R2 plus the latest service pack.

Background

My client requested a server migration to a new environment where they wanted to deploy Dynamics GP 2013 R2 web client (plus the latest service pack) and upgrade their relational database management system to Microsoft SQL Server 2014. This is something I’m absolutely comfortable with (for the most part) given also that my client was sitting at Microsoft Dynamics GP 2013 with Service Pack 2.

As it is customary with these types of request involving a server migration, I followed the very clear instructions outlined in KB article 878449How to transfer an existing Microsoft Dynamics GP, Microsoft Small Business Financials, or Microsoft Small Business Manager installation to a new server that is running Microsoft SQL Server. I have walked through this article more times than I care to mention and can pretty much recite the steps by heart.

During the Dynamics GP Utilities process on the system database, I kept receiving the error message:

“Microsoft Dynamics Utilities Install/Upgrade failed”

This seemed to be a recurring problem on the sySrsReports table during the system database update. Upon further inspection, I noticed the temp table created for the sySrsReports (sySrsReport_T) was still present and that dropping this table would allow Dynamics GP Utilities to continue processing the system database update to completion.

However, the company database updates were failing with the following error messages:

“The stored procedure GetBD_UpgradeStatus() of form duSQL Pass Through SQL returned the following results: DBMS: 12, Microsoft Dynamics GP: 0.”

Upon clicking the OK button, the following error message would appear:

“The stored procedure UpdateDB_Upgrade() of form duSQL Pass Through SQL returned the following result: DMBS: 12, Microsoft Dynamics GP: 0.”

The above two errors would reiterate a few times (5 or 6 to be exact) to finally produce the following error:

“The stored procedure getCompanyID() of form duSQLInstall Pass Trough SQL returned the following results: DBMS: 12, Microsoft Dynamics GP: 0.”

And would come to rest with the error described at first. Now, I’ve done myriads of upgrades in my lifetime, but this one put me on a cliff for a while. The DEXSQL.LOG clearly did not show anything specific and the duinstall.log just showed execution messages (“Message encountered” messages) happening where the problem occurred.

In all fairness, the DEXSQL.LOG kept showing a “[Microsoft][SQL Server Native Client 10.0]Communication link failure” error which lead me to check the version of SQL Server Native Client I was running, which was version 10. I then upgraded to SQL Server Native Client 11.0 and nothing really changed.

I also realized the update was failing while attempting to create the table auto procedures for the wkPostingValidationState table. I then drop this table and its auto procedures and restarted the update in the hopes it would recreate the objects once more, but was not successful.

Suffice to say, I restored the system database and company databases in order to devise a different strategy.

The Solution

After tinkering with the installation, I decided to retrace my steps and realized that during the installation process, I chose to install Web Client Runtime Engine – after all this machine was the web server and would be running a Single Machine instance of Dynamics GP. I then decided to install the Dynamics GP client on the database server without the Web Client Runtime Engine and launch GP Utilities once more. The update process ran flawlessly without any errors!

I still cannot understand why the presence of Web Client Runtime Engine would have caused an error while updating a service pack, however I have to remind everyone of the official Microsoft stance: “the session host must only be used to perform very little administrative work”.

It was good to finally get pass these issues and complete the update process for my client.

Please take a look at my GPUG webinar on upgrades at:

Mariano’s Toolbox: Upgrading to Microsoft Dynamics GP 2015 for dummies 

Until next post!

MG.-
Mariano Gomez, MVP
Intelligent Partnerships, LLC
http://www.intelligentpartnerships.com/

See original article:
DBMS: 12 Microsoft Dynamics GP: 0 error when updating to Microsoft Dynamics GP 2013 R2

May 24, 2015 · Mariano Gomez · No Comments
Tags: , , , , , , , , , ,  · Posted in: Blogs I Follow Total Views: 10

Dynamics GP 2015 eConnect error: There is an active Purchase Order Approval workflow. Use Dynamics GP to enter this data

  This morning I got an issue with one of my customers, they were getting the following error upon integrating Receiving Transactions

Sql procedure error codes returned:

Error Number = 12013  Stored Procedure= taPopRcptLineInsert  Error Description = There is an active Purchase Order Approval workflow. Use Dynamics GP to enter this data
Node Identifier Parameters: taPopRcptLineInsert
PONUMBER = 150686


  1
  PMRR000000004316
  150686
  P-XXXXX
  2042          
  P-XXXX
  UNIT    
  30.500
  7320.000
  240.000
  MAIN      
  32768

This doesn’t make sense, the workflow is activated for the workflow and the Purchase Order used for this receiving is approved!

Nothing on the internet is available explaining this issue, and no place else to look as eConnect Stored Procedures are encrypted.

To get this invistigated, I installed dbFrog SQL Decryptor to decrypt the eConnect procedure and to see whats going on, and found that the procedure is checking if the workflow is activated and if it was activated it checks if the purchase order workflow_status is not equal to “9”, while the purchase order “Completed” status is “6” not “9”:

image

I modified the procedure to reflect my customer change and it worked like a charm, below is the updated procedure after the change if your system database name is DYNAMICS, otherwise you need to change it:

ALTER PROCEDURE dbo.taPopRcptLineInsert @I_vPOPTYPE smallint, @I_vPOPRCTNM char(17), @I_vPONUMBER char(17) = ”, @I_vITEMNMBR char(30) = ”, @I_vITEMDESC char(100) = NULL, @I_vVENDORID char(15), @I_vRCPTLNNM int = 0, @I_vVNDITNUM char(30) = ”, @I_vVNDITDSC char(100) = ”, @I_vACTLSHIP datetime = ”, @I_vINVINDX int = 0, @I_vInventoryAccount varchar(75) = ”, @I_vUOFM char(8) = ”, @I_vUNITCOST numeric(19, 5) = NULL, @I_vEXTDCOST numeric(19, 5) = NULL, @I_vNONINVEN smallint = 0, @I_vJOBNUMBR char(17) = ”, @I_vBOLPRONUMBER char(30) = ”, @I_vQTYSHPPD numeric(19, 5), @I_vQTYINVCD numeric(19, 5) = 0, @I_vAUTOCOST int = 0, @I_vPurchase_IV_Item_Taxable smallint = 2, @I_vPurchase_Item_Tax_Schedu char(15) = ”, @I_vPurchase_Site_Tax_Schedu char(15) = ”, @I_vTAXAMNT numeric(19, 5) = 0, @I_vLanded_Cost_Group_ID char(15) = NULL, @I_vLOCNCODE char(10) = ”, @I_vPOLNENUM int = 0, @I_vreceiptdate datetime = ”, @I_vCURNCYID char(15) = ”, @I_vProjNum char(15) = NULL, @I_vCostCatID char(15) = NULL, @I_vAutoAssignBin smallint = 1, @I_vCMMTTEXT varchar(500) = NULL, @I_vRequesterTrx smallint = 0, @I_vUSRDEFND1 char(50) = ”, @I_vUSRDEFND2 char(50) = ”, @I_vUSRDEFND3 char(50) = ”, @I_vUSRDEFND4 varchar(8000) = ”, @I_vUSRDEFND5 varchar(8000) = ”, @O_iErrorState int OUTPUT, @oErrString varchar(255) OUTPUT WITH ENCRYPTION
AS
  SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
  SET NOCOUNT ON
  DECLARE @PACONTNUMBER char(11),
          @LCCOST numeric(19, 5),
          @Total_Landed_Cost_Amount numeric(19, 5),
          @LCLINENUMBER int,
          @Landed_Cost_ID char(15),
          @LOFSGMNT int,
          @LOFSGMNTALL int,
          @LOFSGMNTEND int,
          @ACCNT_STRING char(100),
          @NEW_ACCNT_STRING varchar(100),
          @MAXSEG int,
          @ACTINDX int,
          @ACSGFLOC smallint,
          @Location_Segment char(67),
          @RcptLineNoteIDArray_1 numeric(19, 5),
          @RcptLineNoteIDArray_2 numeric(19, 5),
          @RcptLineNoteIDArray_3 numeric(19, 5),
          @RcptLineNoteIDArray_4 numeric(19, 5),
          @RcptLineNoteIDArray_5 numeric(19, 5),
          @RcptLineNoteIDArray_6 numeric(19, 5),
          @RcptLineNoteIDArray_7 numeric(19, 5),
          @RcptLineNoteIDArray_8 numeric(19, 5),
          @DECPLCUR smallint,
          @DECPLQTY smallint,
          @ODECPLCU smallint,
          @JOBNUMBR char(17),
          @INVINDX int,
          @VCTNMTHD smallint,
          @ITMTRKOP smallint,
          @UOFM char(8),
          @PRCHSUOM char(8),
          @UMQTYINB numeric(19, 5),
          @ITEMNMBR char(30),
          @ITEMDESC char(100),
          @VNDITNUM char(30),
          @VNDITDSC char(100),
          @Capital_Item tinyint,
          @LOCNCODE char(10),
          @LOCNCODEREG char(10),
          @POLNENUM int,
          @POSTATUS smallint,
          @POLNESTA smallint,
          @POTYPE smallint,
          @CURNCYID char(15),
          @PO_CURNCYID char(15),
          @CURRNIDX int,
          @PO_CURRNIDX int,
          @iStatus int,
          @iError int,
          @iCustomState int,
          @iCustomErrString varchar(255),
          @iCursorError int,
          @O_oErrorState int,
          @O_iUpdCrtItemErrState int,
          @O_iPOLineInsrErrState int,
          @O_iPOHdrErrState int,
          @O_iCommentMstErrState int,
          @O_iLineIvcInsrtErrState int,
          @UNITCOST numeric(19, 5),
          @ORUNTCST numeric(19, 5),
          @iGetNextNoteIdxErrState int,
          @sCompanyID smallint,
          @RCPTLNNM smallint,
          @SHIPMTHD char(15),
          @VADCDPAD char(15),
          @PURPVIDX int,
          @Revalue_Inventory int,
          @Tolerance_Percentage int,
          @POPALWOP_2 tinyint,
          @SERLTQTY numeric(19, 5),
          @VENDORID char(15),
          @STNDCOST numeric(19, 5),
          @UPPVIDX int,
          @RUPPVAMT numeric(19, 5),
          @OLDCUCST numeric(19, 5),
          @ACPURIDX int,
          @ISMCTRX tinyint,
          @FUNLCURR char(15),
          @DECPLCURItem smallint,
          @EDITDECPLCUR smallint,
          @FUNDECPLCUR smallint,
          @MCINSTALLED smallint,
          @LandedCostErrState int,
          @LandedCostErrString varchar(255),
          @projectexists smallint,
          @PASTAT smallint,
          @PAcloseProjcosts smallint,
          @costcatexists smallint,
          @PATU smallint,
          @PAinactive smallint,
          @CUSTNMBR char(15),
          @ENABLEMULTIBIN smallint,
          @ITEMTYPE tinyint,
          @count int,
          @PassedExtCost tinyint,
          @PAProjectType smallint,
          @PAAcctgMethod smallint,
          @PACOSTCATID char(15),
          @PATMProfitType int,
          @l_ProjNum char(15),
          @PAbllngtype int,
          @PAOverhead_Amount numeric(19, 5),
          @PAOverheaPercentage numeric(19, 5),
          @PABILRATE numeric(19, 5),
          @PAProfitType smallint,
          @PABaselinePTaxOptions smallint,
          @PAPurchase_Tax_Options smallint,
          @PAProfitAmount numeric(19, 5),
          @PAProfitPercent numeric(19, 5),
          @PA_Variance_QTY_Accrued_ numeric(19, 5),
          @PA_Variance_Accrued_Reve numeric(19, 5),
          @PO_UOMSCHDL char(11),
          @PO_UOFM char(9),
          @PO_ITMTSHID char(15),
          @PO_TRDISAMT numeric(19, 5),
          @PO_PALineItemSeq int,
          @PO_PAIV_Item_Checkbox smallint,
          @PO_PATU smallint,
          @PO_PAPurchase_Tax_Options smallint,
          @PO_PRICELVL char(15),
          @PO_PACHGORDNO char(17),
          @PACOSTCATNME char(31),
          @PA_Variance_Cost tinyint,
          @Status smallint,
          @PABilling_StatusN smallint,
          @PAMARKPERCENT numeric(19, 5),
          @PAviprofittypefrom smallint,
          @use_billing_rate smallint,
          @use_markup_percentage smallint,
          @PAINCPRCHTXPRJCST smallint,
          @PA_Base_Billing_Rate numeric(19, 5),
          @PABaseOvhdCost numeric(19, 5),
          @PAShipmentExtCost numeric(19, 5),
          @tax_amount numeric(19, 5),
          @PAOverhead_IDX int,
          @PATotalProfit numeric(19, 5),
          @PATOTALOVERH numeric(19, 5),
          @PAACREV numeric(19, 5),
          @PA00901_PATMProfitType int,
          @PA01001_PATMProfitType smallint,
          @PAsetupkey smallint,
          @PO_PACogs_Idx integer,
          @PO_PACGBWIPIDX integer,
          @PABase_Unit_Cost numeric(19, 5),
          @PABase_Qty numeric(19, 5),
          @PAPostedBillingsN numeric(19, 5),
          @PACogs_Idx integer,
          @PACGBWIPIDX integer,
          @PAUnbilled_AR_Idx integer,
          @PAUnbilled_Proj_Rev_Idx integer,
          @PAContra_Account_IDX integer,
          @PO_INVINDX integer,
          @PA_MC_Accrued_Revenue numeric(19, 5),
          @PROJECTLOADED integer,
          @PA_MC_Base_Billing_Rate numeric(19, 5),
          @PA_MC_Billing_Rate numeric(19, 5),
          @PA_MC_VarianceAccruedRev numeric(19, 5),
          @UNITPRCE numeric(19, 5),
          @PRICMTHD smallint,
          @LISTPRCE numeric(19, 5),
          @QTYBSUOM numeric(19, 5),
          @UOMSCHDL char(10),
          @UOFMBASE char(8),
          @CURRCOST numeric(19, 5),
          @ROUNDTO smallint,
          @ROUNDHOW smallint,
          @RNDGAMNT numeric(19, 5),
          @PADECPLQTY smallint,
          @NOTEINDX numeric(19, 5),
          @POLNEARY_3 numeric(19, 5),
          @DATE1 datetime,
          @TIME1 datetime,
          @TOOKACCTOFFPOORPASSED tinyint,
          @UserDate datetime,
          @PeriodID int,
          @Closed int,
          @Year int,
          @iCustomGLPeriodErr int,
          @iCustomGLPeriodState int,
          @O_glCalculateGLPeriodErrorState1 int,
          @O_glCalculateGLPeriodErrorState2 int,
          @PA_Create_Periodic_Budget_RecordsErrorState int,
          @PA_IVCreate_Periodic_Budget_RecordsErrorState int,
          @PABBeginDate_Period int,
          @PABEndDate_YEAR int,
          @PAFBeginDate_Period int,
          @PAFEndDate_YEAR int,
          @PABBeginDate_YEAR int,
          @PAFBeginDate_YEAR int,
          @NUMOFPER int,
          @l_fore_ctr int,
          @l_base_ctr int,
          @PABBeginDate datetime,
          @PABEndDate datetime,
          @PAFBeginDate datetime,
          @PAFEndDate datetime,
          @PAFEndDate_Period int,
          @PABEndDate_Period int,
          @i_startyearupdate int,
          @i_endyearupdate int,
          @i_baselinestartyearupdate int,
          @i_forecaststartyearupdate int,
          @ACTIVE tinyint,
          @NOACCTONITEM tinyint,
          @UseQtyOverageTolerance tinyint,
          @QtyOverTolerancePercent int,
          @CurrentQtyShipped numeric(19, 5),
          @QtyOnPO numeric(19, 5),
          @MaxToleranceAmount numeric(19, 5),
          @RemainingQtyOnPO numeric(19, 5),
          @SITEINACTIVE tinyint,
          @ITEMSITEINACTIVE tinyint
  SELECT
    @PACONTNUMBER = ”,
    @LCCOST = 0,
    @Total_Landed_Cost_Amount = 0,
    @LCLINENUMBER = 0,
    @Landed_Cost_ID = ”,
    @LOFSGMNT = 0,
    @LOFSGMNTALL = 0,
    @LOFSGMNTEND = 0,
    @ACCNT_STRING = ”,
    @NEW_ACCNT_STRING = ”,
    @MAXSEG = 0,
    @ACTINDX = 0,
    @ACSGFLOC = 0,
    @Location_Segment = ”,
    @UNITCOST = 0,
    @ORUNTCST = 0,
    @ITMTRKOP = 1,
    @LOCNCODE = ”,
    @DECPLCUR = 0,
    @DECPLQTY = 0,
    @iGetNextNoteIdxErrState = 0,
    @sCompanyID = ”,
    @RcptLineNoteIDArray_1 = 0,
    @RcptLineNoteIDArray_2 = 0,
    @RcptLineNoteIDArray_3 = 0,
    @RcptLineNoteIDArray_4 = 0,
    @RcptLineNoteIDArray_5 = 0,
    @RcptLineNoteIDArray_6 = 0,
    @RcptLineNoteIDArray_7 = 0,
    @RcptLineNoteIDArray_8 = 0,
    @UMQTYINB = 0,
    @UOFM = ”,
    @POLNENUM = 0,
    @POSTATUS = 0,
    @POLNESTA = 0,
    @POTYPE = 0,
    @DECPLQTY = 0,
    @VCTNMTHD = 0,
    @DECPLCUR = 0,
    @JOBNUMBR = ”,
    @INVINDX = 0,
    @VNDITNUM = ”,
    @VNDITDSC = ”,
    @Capital_Item = 0,
    @O_oErrorState = 0,
    @PO_CURNCYID = ”,
    @CURRNIDX = 0,
    @PO_CURRNIDX = 0,
    @O_iErrorState = 0,
    @iStatus = 0,
    @O_iUpdCrtItemErrState = 0,
    @O_iPOLineInsrErrState = 0,
    @O_iPOHdrErrState = 0,
    @O_iCommentMstErrState = 0,
    @O_iLineIvcInsrtErrState = 0,
    @iGetNextNoteIdxErrState = 0,
    @RCPTLNNM = 0,
    @SHIPMTHD = ”,
    @VADCDPAD = ”,
    @PURPVIDX = 0,
    @Revalue_Inventory = 0,
    @Tolerance_Percentage = 0,
    @POPALWOP_2 = 0,
    @SERLTQTY = 0,
    @VENDORID = ”,
    @ITEMNMBR = ”,
    @PRCHSUOM = ”,
    @LOCNCODEREG = ”,
    @ITEMDESC = ”,
    @STNDCOST = 0,
    @UPPVIDX = 0,
    @RUPPVAMT = 0,
    @OLDCUCST = 0,
    @ACPURIDX = 0,
    @ISMCTRX = 0,
    @FUNLCURR = ”,
    @DECPLCURItem = 0,
    @EDITDECPLCUR = 0,
    @FUNDECPLCUR = 0,
    @MCINSTALLED = 1,
    @LandedCostErrState = 0,
    @LandedCostErrString = ”,
    @projectexists = 0,
    @PASTAT = 0,
    @PAcloseProjcosts = 0,
    @costcatexists = 0,
    @PATU = 0,
    @PAinactive = 0,
    @CUSTNMBR = ”,
    @ENABLEMULTIBIN = 0,
    @ITEMTYPE = 0,
    @count = 0,
    @PassedExtCost = 0,
    @PAProjectType = 0,
    @PAAcctgMethod = 0,
    @PACOSTCATID = ”,
    @PATMProfitType = 0,
    @l_ProjNum = ”,
    @PAbllngtype = 0,
    @PAOverhead_Amount = 0,
    @PAOverheaPercentage = 0,
    @PABILRATE = 0,
    @PAProfitType = 0,
    @PABaselinePTaxOptions = 0,
    @PAPurchase_Tax_Options = 0,
    @PAProfitAmount = 0,
    @PAProfitPercent = 0,
    @PA_Variance_QTY_Accrued_ = 0,
    @PA_Variance_Accrued_Reve = 0,
    @PO_UOMSCHDL = ”,
    @PO_UOFM = ”,
    @PO_ITMTSHID = ”,
    @PO_TRDISAMT = 0,
    @PO_PALineItemSeq = 0,
    @PO_PAIV_Item_Checkbox = 0,
    @PO_PATU = 4,
    @PO_PAPurchase_Tax_Options = 0,
    @PO_PRICELVL = ”,
    @PO_PACHGORDNO = ”,
    @PACOSTCATNME = ”,
    @PA_Variance_Cost = 0,
    @Status = 0,
    @PABilling_StatusN = 0,
    @PAMARKPERCENT = 0,
    @PAviprofittypefrom = 0,
    @use_billing_rate = 0,
    @use_markup_percentage = 0,
    @PAINCPRCHTXPRJCST = 0,
    @PA_Base_Billing_Rate = 0,
    @PABaseOvhdCost = 0,
    @PAShipmentExtCost = 0,
    @tax_amount = 0,
    @PAOverhead_IDX = 0,
    @PATotalProfit = 0,
    @PATOTALOVERH = 0,
    @PAACREV = 0,
    @PA00901_PATMProfitType = 0,
    @PA01001_PATMProfitType = 0,
    @PAsetupkey = 0,
    @PO_PACogs_Idx = 0,
    @PO_PACGBWIPIDX = 0,
    @PABase_Unit_Cost = 0,
    @PABase_Qty = 0,
    @PAPostedBillingsN = 0,
    @PACogs_Idx = 0,
    @PACGBWIPIDX = 0,
    @PAUnbilled_AR_Idx = 0,
    @PAUnbilled_Proj_Rev_Idx = 0,
    @PAContra_Account_IDX = 0,
    @PO_INVINDX = 0,
    @PA_MC_Accrued_Revenue = 0,
    @PROJECTLOADED = 0,
    @PA_MC_Base_Billing_Rate = 0,
    @PA_MC_Billing_Rate = 0,
    @PA_MC_VarianceAccruedRev = 0,
    @UNITPRCE = 0,
    @PRICMTHD = 0,
    @LISTPRCE = 0,
    @QTYBSUOM = 1,
    @UOMSCHDL = ”,
    @UOFMBASE = ”,
    @CURRCOST = 0,
    @ROUNDTO = 0,
    @ROUNDHOW = 0,
    @RNDGAMNT = 0,
    @PADECPLQTY = 0,
    @NOTEINDX = 0,
    @POLNEARY_3 = 0,
    @DATE1 = ”,
    @TIME1 = ”,
    @TOOKACCTOFFPOORPASSED = 0,
    @UserDate = CAST(GETDATE() AS varchar(12)),
    @PeriodID = 0,
    @Closed = 0,
    @Year = 0,
    @iCustomGLPeriodErr = 0,
    @iCustomGLPeriodState = 0,
    @O_glCalculateGLPeriodErrorState1 = 0,
    @O_glCalculateGLPeriodErrorState2 = 0,
    @PA_Create_Periodic_Budget_RecordsErrorState = 0,
    @PA_IVCreate_Periodic_Budget_RecordsErrorState = 0,
    @PABBeginDate = ”,
    @PABEndDate = ”,
    @PAFBeginDate = ”,
    @PAFEndDate = ”,
    @PABBeginDate_Period = 0,
    @PABEndDate_YEAR = 0,
    @PAFBeginDate_Period = 0,
    @PAFEndDate_YEAR = 0,
    @PABBeginDate_YEAR = 0,
    @PAFBeginDate_YEAR = 0,
    @NUMOFPER = 0,
    @l_fore_ctr = 0,
    @l_base_ctr = 0,
    @PAFEndDate_Period = 0,
    @PABEndDate_Period = 0,
    @i_startyearupdate = 0,
    @i_endyearupdate = 0,
    @i_baselinestartyearupdate = 0,
    @i_forecaststartyearupdate = 0,
    @ACTIVE = 0,
    @NOACCTONITEM = 0,
    @UseQtyOverageTolerance = 0,
    @QtyOverTolerancePercent = 0,
    @CurrentQtyShipped = 0,
    @SITEINACTIVE = 0,
    @ITEMSITEINACTIVE = 0
  IF (@oErrString IS NULL)
  BEGIN
    SELECT
      @oErrString = ”
  END
  EXEC @iStatus = taPopRcptLineInsertPre @I_vPOPTYPE OUTPUT,
                                         @I_vPOPRCTNM OUTPUT,
                                         @I_vPONUMBER OUTPUT,
                                         @I_vITEMNMBR OUTPUT,
                                         @I_vITEMDESC OUTPUT,
                                         @I_vVENDORID OUTPUT,
                                         @I_vRCPTLNNM OUTPUT,
                                         @I_vVNDITNUM OUTPUT,
                                         @I_vVNDITDSC OUTPUT,
                                         @I_vACTLSHIP OUTPUT,
                                         @I_vINVINDX OUTPUT,
                                         @I_vInventoryAccount OUTPUT,
                                         @I_vUOFM OUTPUT,
                                         @I_vUNITCOST OUTPUT,
                                         @I_vEXTDCOST OUTPUT,
                                         @I_vNONINVEN OUTPUT,
                                         @I_vJOBNUMBR OUTPUT,
                                         @I_vBOLPRONUMBER OUTPUT,
                                         @I_vQTYSHPPD OUTPUT,
                                         @I_vQTYINVCD OUTPUT,
                                         @I_vAUTOCOST OUTPUT,
                                         @I_vPurchase_IV_Item_Taxable OUTPUT,
                                         @I_vPurchase_Item_Tax_Schedu OUTPUT,
                                         @I_vPurchase_Site_Tax_Schedu OUTPUT,
                                         @I_vTAXAMNT OUTPUT,
                                         @I_vLanded_Cost_Group_ID OUTPUT,
                                         @I_vLOCNCODE OUTPUT,
                                         @I_vPOLNENUM OUTPUT,
                                         @I_vreceiptdate OUTPUT,
                                         @I_vCURNCYID OUTPUT,
                                         @I_vProjNum OUTPUT,
                                         @I_vCostCatID OUTPUT,
                                         @I_vAutoAssignBin OUTPUT,
                                         @I_vCMMTTEXT OUTPUT,
                                         @I_vRequesterTrx OUTPUT,
                                         @I_vUSRDEFND1 OUTPUT,
                                         @I_vUSRDEFND2 OUTPUT,
                                         @I_vUSRDEFND3 OUTPUT,
                                         @I_vUSRDEFND4 OUTPUT,
                                         @I_vUSRDEFND5 OUTPUT,
                                         @O_iErrorState = @iCustomState OUTPUT,
                                         @oErrString = @iCustomErrString OUTPUT
  SELECT
    @iError = @@error
  IF ((@iStatus = 0)
    AND (@iError <> 0))
  BEGIN
    SELECT
      @iStatus = @iError
  END
  IF ((@iStatus <> 0)
    OR (@iCustomState <> 0))
  BEGIN
    SELECT
      @oErrString = RTRIM(@oErrString) + ‘ ‘ + LTRIM(RTRIM(@iCustomErrString))
    SELECT
      @O_iErrorState = 149
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
    RETURN (@O_iErrorState)
  END
  IF (@I_vACTLSHIP IS NULL
    OR @I_vBOLPRONUMBER IS NULL
    OR @I_vINVINDX IS NULL
    OR @I_vInventoryAccount IS NULL
    OR @I_vITEMNMBR IS NULL
    OR @I_vJOBNUMBR IS NULL
    OR @I_vNONINVEN IS NULL
    OR @I_vPONUMBER IS NULL
    OR @I_vPOPRCTNM IS NULL
    OR @I_vRCPTLNNM IS NULL
    OR @I_vUOFM IS NULL
    OR @I_vVNDITDSC IS NULL
    OR @I_vVNDITNUM IS NULL
    OR @I_vPOPTYPE IS NULL
    OR @I_vCURNCYID IS NULL
    OR @I_vAutoAssignBin IS NULL)
  BEGIN
    SELECT
      @O_iErrorState = 2050
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
    RETURN (@O_iErrorState)
  END
  IF (@I_vPOPRCTNM = ”
    OR (@I_vITEMNMBR = ”
    AND @I_vVNDITNUM = ”))
  BEGIN
    SELECT
      @O_iErrorState = 2051
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
    RETURN (@O_iErrorState)
  END
  SELECT
    @I_vPONUMBER = UPPER(@I_vPONUMBER),
    @I_vITEMNMBR = UPPER(@I_vITEMNMBR),
    @I_vVENDORID = UPPER(@I_vVENDORID),
    @I_vPOPRCTNM = UPPER(@I_vPOPRCTNM),
    @I_vCURNCYID = UPPER(@I_vCURNCYID)
  SELECT
    @POPALWOP_2 = POPALWOP_2
  FROM POP40100(nolock)
  WHERE INDEX1 = 1
  IF (@I_vCostCatID IS NOT NULL)
  BEGIN
  BEGIN
    SELECT
      @PAINCPRCHTXPRJCST = PAINCPRCHTXPRJCST
    FROM PA41701(nolock)
    WHERE PAsetupkey = 1
    SELECT
      @PROJECTLOADED = 1
    SELECT
      @PAsetupkey = PAsetupkey,
      @PAviprofittypefrom = PAviprofittypefrom
    FROM PA42201(nolock)
  END
    IF (@PAsetupkey <> 1)
    BEGIN
      SELECT
        @O_iErrorState = 8181
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
  END
  IF EXISTS (SELECT
      1
    FROM POP10300(nolock)
    WHERE POPRCTNM = @I_vPOPRCTNM)
    OR EXISTS (SELECT
      1
    FROM POP30300(nolock)
    WHERE POPRCTNM = @I_vPOPRCTNM)
  BEGIN
    SELECT
      @O_iErrorState = 8053
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF @I_vINVINDX <> 0
  BEGIN
    SELECT
      @TOOKACCTOFFPOORPASSED = 1
  END
  IF ((@I_vAUTOCOST = 1)
    AND ((@I_vUNITCOST > 0)
    OR (@I_vEXTDCOST > 0)))
  BEGIN
    SELECT
      @O_iErrorState = 594
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF (@I_vPOPTYPE NOT IN (1, 3))
  BEGIN
    SELECT
      @O_iErrorState = 5455
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF (@I_vPONUMBER <> ”)
  BEGIN
    IF NOT EXISTS (SELECT
        1
      FROM POP10100(nolock)
      WHERE PONUMBER = @I_vPONUMBER)
    BEGIN
      SELECT
        @O_iErrorState = 2052
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
  END
  IF EXISTS (SELECT
      1
    FROM POP10170(nolock)
    WHERE PONUMBER = @I_vPONUMBER)
  BEGIN
    SELECT
      @O_iErrorState = 11971
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
    RETURN (@O_iErrorState)
  END
  SELECT
    @POSTATUS = POSTATUS,
    @CUSTNMBR = CUSTNMBR
  FROM POP10100(nolock)
  WHERE PONUMBER = @I_vPONUMBER
  IF (@POSTATUS IN (4, 5, 6))
  BEGIN
    SELECT
      @O_iErrorState = 589
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF (@I_vPOLNENUM < 0)
  BEGIN
    SELECT
      @O_iErrorState = 3810
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  SELECT
    @FUNLCURR = FUNLCURR
  FROM MC40000(nolock)
  IF (@O_iErrorState <> 0)
  BEGIN
    RETURN (@O_iErrorState)
  END
  IF (@I_vNONINVEN = 0)
  BEGIN
    IF (@I_vVNDITNUM = ”)
    BEGIN
      SELECT
        @I_vVNDITNUM = VNDITNUM
      FROM IV00103(nolock)
      WHERE ITEMNMBR = @I_vITEMNMBR
      AND VENDORID = @I_vVENDORID
    END
    IF (@I_vITEMNMBR = ”)
    BEGIN
      SELECT
        @count = COUNT(ITEMNMBR)
      FROM IV00103(nolock)
      WHERE VNDITNUM = @I_vVNDITNUM
      AND VENDORID = @I_vVENDORID
      IF (@count > 1)
      BEGIN
        SELECT
          @O_iErrorState = 9008
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
        RETURN (@O_iErrorState)
      END
      ELSE
      BEGIN
        SELECT
          @I_vITEMNMBR = ITEMNMBR
        FROM IV00103(nolock)
        WHERE VNDITNUM = @I_vVNDITNUM
        AND VENDORID = @I_vVENDORID
      END
    END
  END
  IF ((@I_vNONINVEN = 1)
    AND (@I_vVNDITNUM = ”))
  BEGIN
    SELECT
      @I_vVNDITNUM = @I_vITEMNMBR
  END
  IF (@I_vPONUMBER <> ”)
  BEGIN
    IF (@I_vPOLNENUM <> 0)
    BEGIN
      IF NOT EXISTS (SELECT
          1
        FROM POP10110(nolock)
        WHERE PONUMBER = @I_vPONUMBER
        AND ORD = @I_vPOLNENUM)
      BEGIN
        SELECT
          @O_iErrorState = 3808
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
      END
      SELECT
        @ITEMDESC = ITEMDESC,
        @VNDITDSC = VNDITDSC,
        @VNDITNUM = VNDITNUM,
        @UOFM = UOFM,
        @INVINDX = INVINDX,
        @JOBNUMBR = JOBNUMBR,
        @Capital_Item = Capital_Item,
        @DECPLCUR = DECPLCUR,
        @DECPLQTY = DECPLQTY,
        @ODECPLCU = ODECPLCU,
        @LOCNCODE = LOCNCODE,
        @UMQTYINB = UMQTYINB,
        @UNITCOST = UNITCOST,
        @ORUNTCST = ORUNTCST,
        @POLNESTA = POLNESTA,
        @POTYPE = POTYPE,
        @VENDORID = VENDORID,
        @ITEMNMBR = ITEMNMBR,
        @I_vLanded_Cost_Group_ID =
                                  CASE
                                    WHEN @I_vLanded_Cost_Group_ID IS NULL THEN Landed_Cost_Group_ID
                                    ELSE @I_vLanded_Cost_Group_ID
                                  END,
        @I_vProjNum =
                     CASE
                       WHEN @I_vProjNum IS NULL THEN ProjNum
                       ELSE @I_vProjNum
                     END,
        @I_vCostCatID =
                       CASE
                         WHEN @I_vCostCatID IS NULL THEN CostCatID
                         ELSE @I_vCostCatID
                       END,
        @POLNEARY_3 = POLNEARY_3
      FROM POP10110(nolock)
      WHERE PONUMBER = @I_vPONUMBER
      AND ORD = @I_vPOLNENUM
      IF @I_vCostCatID <> ”
      BEGIN
        SELECT
          @PROJECTLOADED = 1
      END
      IF (@I_vITEMNMBR <> @ITEMNMBR)
      BEGIN
        SELECT
          @O_iErrorState = 3809
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
      END
      IF (@I_vUOFM <> ”)
      BEGIN
        IF (@I_vUOFM <> @UOFM)
        BEGIN
          SELECT
            @O_iErrorState = 6663
          EXEC @iStatus = taUpdateString @O_iErrorState,
                                         @oErrString,
                                         @oErrString OUTPUT,
                                         @O_oErrorState OUTPUT
        END
      END
      IF (@I_vVENDORID <> @VENDORID)
      BEGIN
        SELECT
          @O_iErrorState = 6662
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
      END
    END
    ELSE
    BEGIN
      IF (@I_vLOCNCODE <> ”)
        AND (@POPALWOP_2 = 0)
      BEGIN
        SELECT
          @count = COUNT(ORD)
        FROM POP10110(nolock)
        WHERE PONUMBER = @I_vPONUMBER
        AND ITEMNMBR = @I_vITEMNMBR
        AND VNDITNUM = @I_vVNDITNUM
        AND VENDORID = @I_vVENDORID
        AND LOCNCODE = @I_vLOCNCODE
        SELECT
          @ITEMDESC = ITEMDESC,
          @VNDITDSC = VNDITDSC,
          @VNDITNUM = VNDITNUM,
          @UOFM = UOFM,
          @INVINDX = INVINDX,
          @JOBNUMBR = JOBNUMBR,
          @Capital_Item = Capital_Item,
          @DECPLCUR = DECPLCUR,
          @DECPLQTY = DECPLQTY,
          @ODECPLCU = ODECPLCU,
          @POLNENUM = ORD,
          @LOCNCODE = LOCNCODE,
          @UMQTYINB = UMQTYINB,
          @UNITCOST = UNITCOST,
          @ORUNTCST = ORUNTCST,
          @POLNESTA = POLNESTA,
          @POTYPE = POTYPE,
          @VENDORID = VENDORID,
          @I_vLanded_Cost_Group_ID =
                                    CASE
                                      WHEN @I_vLanded_Cost_Group_ID IS NULL THEN Landed_Cost_Group_ID
                                      ELSE @I_vLanded_Cost_Group_ID
                                    END,
          @I_vProjNum =
                       CASE
                         WHEN @I_vProjNum IS NULL THEN ProjNum
                         ELSE @I_vProjNum
                       END,
          @I_vCostCatID =
                         CASE
                           WHEN @I_vCostCatID IS NULL THEN CostCatID
                           ELSE @I_vCostCatID
                         END,
          @POLNEARY_3 = POLNEARY_3
        FROM POP10110(nolock)
        WHERE PONUMBER = @I_vPONUMBER
        AND ITEMNMBR = @I_vITEMNMBR
        AND VNDITNUM = @I_vVNDITNUM
        AND VENDORID = @I_vVENDORID
        AND LOCNCODE = @I_vLOCNCODE
        IF @I_vCostCatID <> ”
        BEGIN
          SELECT
            @PROJECTLOADED = 1
        END
      END
      ELSE
      BEGIN
        SELECT
          @count = COUNT(ORD)
        FROM POP10110(nolock)
        WHERE PONUMBER = @I_vPONUMBER
        AND ITEMNMBR = @I_vITEMNMBR
        AND VNDITNUM = @I_vVNDITNUM
        AND VENDORID = @I_vVENDORID
        SELECT
          @ITEMDESC = ITEMDESC,
          @VNDITDSC = VNDITDSC,
          @VNDITNUM = VNDITNUM,
          @UOFM = UOFM,
          @INVINDX = INVINDX,
          @JOBNUMBR = JOBNUMBR,
          @Capital_Item = Capital_Item,
          @DECPLCUR = DECPLCUR,
          @DECPLQTY = DECPLQTY,
          @ODECPLCU = ODECPLCU,
          @POLNENUM = ORD,
          @LOCNCODE = LOCNCODE,
          @UMQTYINB = UMQTYINB,
          @UNITCOST = UNITCOST,
          @ORUNTCST = ORUNTCST,
          @POLNESTA = POLNESTA,
          @POTYPE = POTYPE,
          @VENDORID = VENDORID,
          @I_vLanded_Cost_Group_ID =
                                    CASE
                                      WHEN @I_vLanded_Cost_Group_ID IS NULL THEN Landed_Cost_Group_ID
                                      ELSE @I_vLanded_Cost_Group_ID
                                    END,
          @I_vProjNum =
                       CASE
                         WHEN @I_vProjNum IS NULL THEN ProjNum
                         ELSE @I_vProjNum
                       END,
          @I_vCostCatID =
                         CASE
                           WHEN @I_vCostCatID IS NULL THEN CostCatID
                           ELSE @I_vCostCatID
                         END,
          @POLNEARY_3 = POLNEARY_3
        FROM POP10110(nolock)
        WHERE PONUMBER = @I_vPONUMBER
        AND ITEMNMBR = @I_vITEMNMBR
        AND VNDITNUM = @I_vVNDITNUM
        AND VENDORID = @I_vVENDORID
        IF @I_vCostCatID <> ”
        BEGIN
          SELECT
            @PROJECTLOADED = 1
        END
      END
      IF (@count = 1)
      BEGIN
        SELECT
          @I_vPOLNENUM = @POLNENUM
      END
      ELSE
      BEGIN
        IF (@count > 1)
        BEGIN
          SELECT
            @O_iErrorState = 9344
          EXEC @iStatus = taUpdateString @O_iErrorState,
                                         @oErrString,
                                         @oErrString OUTPUT,
                                         @O_oErrorState OUTPUT
        END
        IF (@count = 0)
        BEGIN
          SELECT
            @O_iErrorState = 9343
          EXEC @iStatus = taUpdateString @O_iErrorState,
                                         @oErrString,
                                         @oErrString OUTPUT,
                                         @O_oErrorState OUTPUT
        END
      END
      IF (@PROJECTLOADED = 1)
      BEGIN
        SELECT
          @INVINDX = PACGBWIPIDX
        FROM PA10601(nolock)
        WHERE PApurordnum = @I_vPONUMBER
        AND ORD = @I_vPOLNENUM
      END
    END
  END
  ELSE
  BEGIN
    SELECT
      @POTYPE =
               CASE
                 WHEN (@PROJECTLOADED = 1) AND
                   (@I_vPOPTYPE = 3) THEN 1
                 WHEN (@PROJECTLOADED = 1) AND
                   (@I_vPOPTYPE = 3) AND
                   (@I_vNONINVEN = 1) THEN 0
                 ELSE 0
               END,
      @I_vUOFM =
                CASE
                  WHEN (@I_vNONINVEN = 1) AND
                    (@I_vUOFM = ”) THEN ‘Each’
                  ELSE @I_vUOFM
                END,
      @UMQTYINB =
                 CASE
                   WHEN @I_vNONINVEN = 1 THEN 1
                   ELSE 0
                 END,
      @I_vLanded_Cost_Group_ID =
                                CASE
                                  WHEN @I_vLanded_Cost_Group_ID IS NULL THEN ”
                                  ELSE @I_vLanded_Cost_Group_ID
                                END,
      @I_vProjNum =
                   CASE
                     WHEN @I_vProjNum IS NULL THEN ”
                     ELSE @I_vProjNum
                   END,
      @I_vCostCatID =
                     CASE
                       WHEN @I_vCostCatID IS NULL THEN ”
                       ELSE @I_vCostCatID
                     END
  END
  IF (@POLNEARY_3 = 0)
  BEGIN
    SELECT
      @I_vCMMTTEXT = ”
  END
  IF (@I_vProjNum <> ”)
    AND (@I_vCostCatID = ”)
  BEGIN
    SELECT
      @O_iErrorState = 8173
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF (@I_vProjNum = ”)
    AND (@I_vCostCatID <> ”)
  BEGIN
    SELECT
      @O_iErrorState = 8174
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  SELECT
    @sCompanyID = CMPANYID
  FROM DYNAMICS..SY01500(nolock)
  WHERE INTERID = DB_NAME()
  IF (@I_vProjNum <> ”)
    AND (@I_vCostCatID <> ”)
  BEGIN
    EXEC @iStatus = DYNAMICS..tasmGetNextNoteIndex @I_sCompanyID = @sCompanyID,
                                                @I_iSQLSessionID = 0,
                                                @I_noteincrement = 1,
                                                @O_mNoteIndex = @NOTEINDX OUTPUT,
                                                @O_iErrorState = @iGetNextNoteIdxErrState OUTPUT
    SELECT
      @iError = @@error
    IF ((@iStatus <> 0)
      OR (@iGetNextNoteIdxErrState <> 0)
      OR (@iError <> 0))
    BEGIN
      SELECT
        @oErrString = RTRIM(@oErrString) + ‘ ‘ + @iGetNextNoteIdxErrState
      SELECT
        @O_iErrorState = 8239
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
      RETURN (@O_iErrorState)
    END
  END
  IF (@I_vProjNum <> ”)
    AND (@I_vProjNum <> ‘‘)
  BEGIN
    IF (@I_vPOPTYPE IN (1, 3))
    BEGIN
      SELECT
        @projectexists = 1,
        @PASTAT = PASTAT,
        @PAcloseProjcosts = PAcloseProjcosts,
        @PACONTNUMBER = PACONTNUMBER,
        @PAProjectType = PAProjectType,
        @PAAcctgMethod = PAAcctgMethod,
        @CUSTNMBR =
                   CASE
                     WHEN @CUSTNMBR = ” AND
                       @I_vPONUMBER = ” THEN CUSTNMBR
                     ELSE ”
                   END
      FROM PA01201(nolock)
      WHERE PAPROJNUMBER = @I_vProjNum
    END
    IF (@projectexists <> 1)
    BEGIN
      SELECT
        @O_iErrorState = 8095
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
    IF (@PASTAT > 1
      AND @PASTAT < 5)
    BEGIN
      SELECT
        @O_iErrorState = 8096
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
    IF (@PAcloseProjcosts = 1)
    BEGIN
      SELECT
        @O_iErrorState = 8097
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
    SELECT
      @PASTAT = PASTAT,
      @PAcloseProjcosts = PAcloseProjcosts,
      @PACONTNUMBER = PACONTNUMBER
    FROM PA01101(nolock)
    WHERE PACONTNUMBER = @PACONTNUMBER
    IF (@PASTAT > 1
      AND @PASTAT < 5)
    BEGIN
      SELECT
        @O_iErrorState = 8098
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
    IF (@PAcloseProjcosts = 1)
    BEGIN
      SELECT
        @O_iErrorState = 8099
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
    IF EXISTS (SELECT
        1
      FROM PA00501(nolock)
      WHERE CUSTNMBR = @CUSTNMBR
      AND PAcloseProjcosts = 1)
    BEGIN
      SELECT
        @O_iErrorState = 8100
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
  END
  IF (@I_vCostCatID <> ”)
    AND (@I_vCostCatID <> ‘‘)
  BEGIN
    SELECT
      @costcatexists = 1,
      @PATU = PATU,
      @PAinactive = PAinactive,
      @PACOSTCATID = PACOSTCATID,
      @PATMProfitType = PATMProfitType,
      @PAPurchase_Tax_Options = PAPurchase_Tax_Options,
      @PACOSTCATNME = PACOSTCATNME
    FROM PA01001(nolock)
    WHERE PACOSTCATID = @I_vCostCatID
    IF (@costcatexists <> 1)
    BEGIN
      SELECT
        @O_iErrorState = 8101
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
    IF (@PATU <> 4)
    BEGIN
      SELECT
        @O_iErrorState = 8102
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
    IF (@PAinactive = 1)
    BEGIN
      SELECT
        @O_iErrorState = 8103
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
  END
  IF (@I_vProjNum <> ‘‘)
    AND (@I_vProjNum <> ”)
    AND (@I_vPONUMBER <> ”)
  BEGIN
    IF (EXISTS (SELECT
        1
      FROM POP10110(nolock)
      WHERE PONUMBER = @I_vPONUMBER
      AND ORD = @I_vPOLNENUM
      AND ProjNum = ”)
      )
    BEGIN
      SELECT
        @O_iErrorState = 8193
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
  END
  IF (@I_vProjNum <> ‘‘)
    AND (@I_vProjNum <> ”)
    AND (@I_vPONUMBER <> ”)
  BEGIN
    IF (NOT EXISTS (SELECT
        1
      FROM POP10110(nolock)
      WHERE PONUMBER = @I_vPONUMBER
      AND ORD = @I_vPOLNENUM
      AND ProjNum = @I_vProjNum)
      )
    BEGIN
      SELECT
        @O_iErrorState = 8696
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
  END
  IF (@PROJECTLOADED = 1)
  BEGIN
    IF (@I_vProjNum <> ‘‘)
      AND (@I_vProjNum <> ”)
    BEGIN
      IF (@I_vCostCatID <> ‘‘)
      BEGIN
        SELECT
          @l_ProjNum = ISNULL(PAPROJNUMBER, ”),
          @PASTAT = ISNULL(PASTAT, 0),
          @PAbllngtype = ISNULL(PAbllngtype, 0),
          @PAOverhead_Amount = ISNULL(PAForecastOvrhdAmtPerUnt, 0),
          @PAOverheaPercentage = ISNULL(PAForecastOvrhdPct, 0),
          @PABILRATE = ISNULL(PAForecastBaseProfitAmt, 0),
          @PAProfitType = ISNULL(PAProfitType, 0),
          @PABaselinePTaxOptions = ISNULL(PABaselinePTaxOptions, 0),
          @PO_CURNCYID = PAMCCURNCYID
        FROM PA01301(nolock)
        WHERE PAPROJNUMBER = @I_vProjNum
        AND PACOSTCATID = @I_vCostCatID
        AND PATU = @PATU
        SELECT
          @PO_CURRNIDX = CURRNIDX
        FROM DYNAMICS..MC40200(nolock)
        WHERE CURNCYID = @PO_CURNCYID
        IF (@l_ProjNum = ”)
        BEGIN
          SELECT
            @O_iErrorState = 8177
          EXEC @iStatus = taUpdateString @O_iErrorState,
                                         @oErrString,
                                         @oErrString OUTPUT,
                                         @O_oErrorState OUTPUT
        END
        ELSE
        BEGIN
          IF (@PASTAT IN (2, 3, 4, 5))
          BEGIN
            SELECT
              @O_iErrorState = 8178
            EXEC @iStatus = taUpdateString @O_iErrorState,
                                           @oErrString,
                                           @oErrString OUTPUT,
                                           @O_oErrorState OUTPUT
          END
        END
      END
    END
  END
  SELECT
    @FUNDECPLCUR = DECPLCUR – 1
  FROM MC40000 a (NOLOCK),
       DYNAMICS..MC40200 b (NOLOCK)
  WHERE a.FUNCRIDX = b.CURRNIDX
  AND a.FUNLCURR = b.CURNCYID
  IF (@PROJECTLOADED = 1)
  BEGIN
    IF (@I_vPONUMBER <> ”)
      AND (@I_vProjNum <> ”)
      AND (@I_vCostCatID <> ”)
      AND (@I_vVNDITNUM <> ”)
    BEGIN
      IF (@I_vPOLNENUM <> ”)
      BEGIN
        SELECT
          @PO_UOMSCHDL = UOMSCHDL,
          @PO_PATU = PATU,
          @PO_PAPurchase_Tax_Options = PAPurchase_Tax_Options,
          @PO_ITMTSHID = ITMTSHID,
          @PO_TRDISAMT = TRDISAMT,
          @PO_PAIV_Item_Checkbox = PAIV_Item_Checkbox,
          @PO_PALineItemSeq = PALineItemSeq,
          @PO_PRICELVL = PRICELVL,
          @PO_PACHGORDNO = PACHGORDNO
        FROM PA10601(nolock)
        WHERE PApurordnum = @I_vPONUMBER
        AND ORD = @I_vPOLNENUM
      END
      ELSE
      BEGIN
        SELECT
          @PO_UOMSCHDL = UOMSCHDL,
          @PO_PATU = PATU,
          @PO_PAPurchase_Tax_Options = PAPurchase_Tax_Options,
          @PO_ITMTSHID = ITMTSHID,
          @PO_TRDISAMT = TRDISAMT,
          @PO_PAIV_Item_Checkbox = PAIV_Item_Checkbox,
          @PO_PALineItemSeq = PALineItemSeq,
          @PO_PRICELVL = PRICELVL,
          @PO_PACHGORDNO = PACHGORDNO
        FROM PA10601(nolock)
        WHERE PApurordnum = @I_vPONUMBER
        AND PAPROJNUMBER = @I_vProjNum
        AND VNDITNUM = @I_vVNDITNUM
        AND PACOSTCATID = @I_vCostCatID
      END
      IF @PAPurchase_Tax_Options = 0
      BEGIN
        SELECT
          @PAPurchase_Tax_Options = @PO_PAPurchase_Tax_Options
      END
      SELECT TOP 1
        @PO_PRICELVL = PRICELVL
      FROM PA01303(nolock)
      WHERE PAPROJNUMBER = @I_vProjNum
      AND PACOSTCATID = @I_vCostCatID
      AND ITEMNMBR = @I_vITEMNMBR
    END
    ELSE
    BEGIN
      SELECT
        @PO_PAIV_Item_Checkbox = ISNULL(PAIV_Item_Checkbox, 0)
      FROM PA01301(nolock)
      WHERE PAPROJNUMBER = @I_vProjNum
      AND PACOSTCATID = @I_vCostCatID
      AND PATU = @PO_PATU
      SELECT TOP 1
        @PO_PRICELVL = ISNULL(PRICELVL, ”),
        @PO_PALineItemSeq = ISNULL(PALineItemSeq, 0)
      FROM PA01303(nolock)
      WHERE PAPROJNUMBER = @I_vProjNum
      AND PACOSTCATID = @I_vCostCatID
      AND ITEMNMBR = @I_vITEMNMBR
    END
    IF (@I_vreceiptdate = ”)
    BEGIN
      SELECT
        @O_iErrorState = 21042
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
    EXEC @iStatus = glCalculateGLPeriod @I_sSeries = 7,
                                        @I_cOrigin = ‘PA Receivings Trx Entry’,
                                        @I_dDate = @I_vreceiptdate,
                                        @I_dUserDate = @UserDate,
                                        @O_sPeriodID = @PABBeginDate_Period OUTPUT,
                                        @O_tClosed = @Closed OUTPUT,
                                        @O_sYear = @PABBeginDate_YEAR OUTPUT,
                                        @O_iOUTErr = @iCustomGLPeriodErr OUTPUT,
                                        @O_iErrorState = @O_glCalculateGLPeriodErrorState1 OUTPUT
    SELECT
      @iError = @@error
    IF ((@iStatus <> 0)
      OR (@O_glCalculateGLPeriodErrorState1 <> 0)
      OR (@iError <> 0))
    BEGIN
      SELECT
        @oErrString = RTRIM(@oErrString) + ‘ ‘ + LTRIM(RTRIM(@O_glCalculateGLPeriodErrorState1))
      SELECT
        @O_iErrorState = 21043
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
      RETURN (@O_iErrorState)
    END
    EXEC @iStatus = glCalculateGLPeriod @I_sSeries = 7,
                                        @I_cOrigin = ‘PA Receivings Trx Entry’,
                                        @I_dDate = @I_vreceiptdate,
                                        @I_dUserDate = @UserDate,
                                        @O_sPeriodID = @PABEndDate_Period OUTPUT,
                                        @O_tClosed = @Closed OUTPUT,
                                        @O_sYear = @PABEndDate_YEAR OUTPUT,
                                        @O_iOUTErr = @iCustomGLPeriodErr OUTPUT,
                                        @O_iErrorState = @O_glCalculateGLPeriodErrorState2 OUTPUT
    SELECT
      @iError = @@error
    IF ((@iStatus <> 0)
      OR (@O_glCalculateGLPeriodErrorState2 <> 0)
      OR (@iError <> 0))
    BEGIN
      SELECT
        @oErrString = RTRIM(@oErrString) + ‘ ‘ + LTRIM(RTRIM(@O_glCalculateGLPeriodErrorState2))
      SELECT
        @O_iErrorState = 20144
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
      RETURN (@O_iErrorState)
    END
    SELECT
      @PAFBeginDate_Period = @PABBeginDate_Period,
      @PAFBeginDate_YEAR = @PABBeginDate_YEAR,
      @PAFEndDate_Period = @PABEndDate_Period,
      @PAFEndDate_YEAR = @PABEndDate_YEAR,
      @i_startyearupdate = @PABBeginDate_YEAR,
      @i_endyearupdate = @PABEndDate_YEAR,
      @i_baselinestartyearupdate = @PABEndDate_YEAR,
      @i_forecaststartyearupdate = @PABEndDate_YEAR
    SELECT
      @NUMOFPER = NUMOFPER
    FROM SY40101(nolock)
    WHERE YEAR1 = @PABEndDate_YEAR
    IF (@PABEndDate_YEAR – @PABBeginDate_YEAR) = 1
    BEGIN
      SET @l_base_ctr = (@NUMOFPER – @PABBeginDate_Period) + (@PABEndDate_Period) + 1
    END
    ELSE
    IF (@PABEndDate_YEAR = @PABBeginDate_YEAR)
    BEGIN
      SET @l_base_ctr = (@PABEndDate_Period – @PABBeginDate_Period) + 1
    END
    ELSE
    BEGIN
      SET @l_base_ctr = (((@PABEndDate_YEAR – @PABBeginDate_YEAR) * @NUMOFPER) + (@NUMOFPER – @PABBeginDate_Period) + (@NUMOFPER – @PABBeginDate_Period))
    END
    IF (@PABEndDate_YEAR <> @PABBeginDate_YEAR)
    BEGIN
      SET @l_fore_ctr = (@NUMOFPER – @PAFBeginDate_Period) + (@PAFEndDate_Period) + 1
    END
    ELSE
    IF (@PABEndDate_YEAR = @PABBeginDate_YEAR)
    BEGIN
      SET @l_fore_ctr = (@PAFEndDate_Period – @PAFBeginDate_Period) + 1
    END
    ELSE
    BEGIN
      SET @l_fore_ctr = (((@PAFEndDate_YEAR – @PAFBeginDate_YEAR – 1) * @NUMOFPER) + (@NUMOFPER – @PAFBeginDate_Period) + (@NUMOFPER – @PABBeginDate_Period))
    END
    IF (@costcatexists = 1
      AND @CUSTNMBR <> ”)
    BEGIN
      IF (@PO_PAIV_Item_Checkbox = 1)
      BEGIN
        EXEC @iStatus = PA_IVCreate_Periodic_Budget_Records @I_projectnumber = @I_vProjNum,
                                                            @I_transactionusage = @PATU,
                                                            @I_costcategory = @I_vCostCatID,
                                                            @I_contractnumber = @PACONTNUMBER,
                                                            @I_customernumber = @CUSTNMBR,
                                                            @I_sourcefileID = 0,
                                                            @I_basestartdate = @PABBeginDate,
                                                            @I_baseenddate = @PABEndDate,
                                                            @I_forestartdate = @PAFBeginDate,
                                                            @I_foreenddate = @PAFEndDate,
                                                            @I_actualstartdate = @I_vreceiptdate,
                                                            @I_actualenddate = ”,
                                                            @I_userdate = @UserDate,
                                                            @I_deciqty = @DECPLQTY,
                                                            @I_functionaldeciglobals = @FUNDECPLCUR,
                                                            @I_create = 0,
                                                            @I_change_baseline = 1,
                                                            @I_change_forecast = 1,
                                                            @i_firstdate = ”,
                                                            @i_lastdate = ”,
                                                            @i_year_start = 0,
                                                            @i_year_end = 0,
                                                            @i_startyearupdate = @i_startyearupdate,
                                                            @i_endyearupdate = @i_endyearupdate,
                                                            @i_baselinestartyearupdate = @i_baselinestartyearupdate,
                                                            @i_baseline_period = @PABEndDate_Period,
                                                            @i_forecaststartyearupdate = @i_forecaststartyearupdate,
                                                            @i_forecast_period = @PAFEndDate_Period,
                                                            @l_base_ctr = @l_base_ctr,
                                                            @l_fore_ctr = @l_base_ctr,
                                                            @I_err = @PA_IVCreate_Periodic_Budget_RecordsErrorState OUTPUT
        SELECT
          @iError = @@error
        IF ((@iStatus <> 0)
          OR (@PA_IVCreate_Periodic_Budget_RecordsErrorState <> 0)
          OR (@iError <> 0))
        BEGIN
          SELECT
            @oErrString = RTRIM(@oErrString) + ‘ ‘ + LTRIM(RTRIM(@PA_IVCreate_Periodic_Budget_RecordsErrorState))
          SELECT
            @O_iErrorState = 20145
          EXEC @iStatus = taUpdateString @O_iErrorState,
                                         @oErrString,
                                         @oErrString OUTPUT,
                                         @O_oErrorState OUTPUT
          RETURN (@O_iErrorState)
        END
      END
      ELSE
      BEGIN
        EXECUTE @iStatus = PA_Create_Periodic_Budget_Records @I_projectnumber = @I_vProjNum,
                                                             @I_transactionusage = @PATU,
                                                             @I_costcategory = @I_vCostCatID,
                                                             @I_contractnumber = @PACONTNUMBER,
                                                             @I_customernumber = @CUSTNMBR,
                                                             @I_sourcefileID = 0,
                                                             @I_basestartdate = @PABBeginDate,
                                                             @I_baseenddate = @PABEndDate,
                                                             @I_forestartdate = @PAFBeginDate,
                                                             @I_foreenddate = @PAFEndDate,
                                                             @I_actualstartdate = @I_vreceiptdate,
                                                             @I_actualenddate = ”,
                                                             @I_userdate = @UserDate,
                                                             @I_deciqty = @DECPLQTY,
                                                             @I_functionaldeciglobals = @FUNDECPLCUR,
                                                             @I_create = 0,
                                                             @I_change_baseline = 1,
                                                             @I_change_forecast = 1,
                                                             @i_firstdate = ”,
                                                             @i_lastdate = ”,
                                                             @i_year_start = 0,
                                                             @i_year_end = 0,
                                                             @i_startyearupdate = @i_startyearupdate,
                                                             @i_endyearupdate = @i_endyearupdate,
                                                             @i_baselinestartyearupdate = @i_baselinestartyearupdate,
                                                             @i_baseline_period = @PABEndDate_Period,
                                                             @i_forecaststartyearupdate = @i_forecaststartyearupdate,
                                                             @i_forecast_period = @PAFEndDate_Period,
                                                             @l_base_ctr = @l_base_ctr,
                                                             @l_fore_ctr = @l_base_ctr,
                                                             @I_err = @PA_Create_Periodic_Budget_RecordsErrorState OUTPUT
        SELECT
          @iError = @@error
        IF ((@iStatus <> 0)
          OR (@PA_Create_Periodic_Budget_RecordsErrorState <> 0)
          OR (@iError <> 0))
        BEGIN
          SELECT
            @oErrString = RTRIM(@oErrString) + ‘ ‘ + LTRIM(RTRIM(@PA_Create_Periodic_Budget_RecordsErrorState))
          SELECT
            @O_iErrorState = 20146
          EXEC @iStatus = taUpdateString @O_iErrorState,
                                         @oErrString,
                                         @oErrString OUTPUT,
                                         @O_oErrorState OUTPUT
          RETURN (@O_iErrorState)
        END
      END
    END
  END
  SELECT TOP 1
    @LOCNCODEREG = LOCNCODE
  FROM IV40700(nolock)
  WHERE LOCNCODE <> ”
  IF ((@LOCNCODEREG = ”)
    AND (@I_vLOCNCODE <> ”))
  BEGIN
    SELECT
      @O_iErrorState = 4605
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF ((@LOCNCODEREG <> ”)
    AND (@I_vLOCNCODE <> ”))
  BEGIN
    IF ((@I_vPONUMBER <> ”)
      AND (NOT EXISTS (SELECT
        1
      FROM IV40700(nolock)
      WHERE LOCNCODE = @I_vLOCNCODE)
      ))
    BEGIN
      SELECT
        @O_iErrorState = 1277
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
    IF ((@I_vNONINVEN = 0)
      AND (NOT EXISTS (SELECT
        1
      FROM IV00102(nolock)
      WHERE ITEMNMBR = @I_vITEMNMBR
      AND LOCNCODE = @I_vLOCNCODE)
      ))
    BEGIN
      SELECT
        @O_iErrorState = 4604
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
  END
  IF (@I_vNONINVEN = 0)
  BEGIN
    IF (@I_vPONUMBER = ”)
    BEGIN
      IF (NOT EXISTS (SELECT
          1
        FROM IV00103(nolock)
        WHERE ITEMNMBR = @I_vITEMNMBR
        AND VNDITNUM = @I_vVNDITNUM
        AND VENDORID = @I_vVENDORID)
        )
      BEGIN
        SELECT
          @O_iErrorState = 1779
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
      END
    END
    ELSE
    BEGIN
      IF (@I_vPOLNENUM <> 0)
        AND (NOT EXISTS (SELECT
          1
        FROM POP10110(nolock)
        WHERE ITEMNMBR = @I_vITEMNMBR
        AND VNDITNUM = @I_vVNDITNUM
        AND VENDORID = @I_vVENDORID
        AND PONUMBER = @I_vPONUMBER
        AND ORD = @I_vPOLNENUM)
        )
      BEGIN
        SELECT
          @O_iErrorState = 7922
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
      END
    END
  END
  IF (@I_vPONUMBER = ”)
  BEGIN
    IF (@I_vNONINVEN = 0)
    BEGIN
      SELECT
        @DECPLCUR = ((DECPLCUR – 1) + 7),
        @ODECPLCU = (DECPLCUR – 1),
        @DECPLQTY = ((DECPLQTY – 1) + 1)
      FROM IV00101(nolock)
      WHERE ITEMNMBR = @I_vITEMNMBR
      IF (@I_vUOFM <> ”)
      BEGIN
        IF NOT EXISTS (SELECT
            1
          FROM IV00106(nolock)
          WHERE ITEMNMBR = @I_vITEMNMBR
          AND UOFM = @I_vUOFM)
        BEGIN
          SELECT
            @O_iErrorState = 9373
          EXEC @iStatus = taUpdateString @O_iErrorState,
                                         @oErrString,
                                         @oErrString OUTPUT,
                                         @O_oErrorState OUTPUT
        END
        SELECT
          @UOFM = @I_vUOFM
      END
      ELSE
      BEGIN
        SELECT
          @PRCHSUOM = PRCHSUOM
        FROM IV00103(nolock)
        WHERE VENDORID = @I_vVENDORID
        AND ITEMNMBR = @I_vITEMNMBR
        AND VNDITNUM = @I_vVNDITNUM
        IF (@PRCHSUOM = ”)
        BEGIN
          SELECT
            @PRCHSUOM = PRCHSUOM
          FROM IV00101(nolock)
          WHERE ITEMNMBR = @I_vITEMNMBR
        END
        IF (@PRCHSUOM = ”)
        BEGIN
          SELECT
            @O_iErrorState = 9374
          EXEC @iStatus = taUpdateString @O_iErrorState,
                                         @oErrString,
                                         @oErrString OUTPUT,
                                         @O_oErrorState OUTPUT
        END
        SELECT
          @UOFM = @PRCHSUOM
      END
      SELECT
        @UMQTYINB = QTYBSUOM
      FROM IV00106(nolock)
      WHERE ITEMNMBR = @I_vITEMNMBR
      AND UOFM = @UOFM
      IF (@I_vVNDITDSC = ”)
      BEGIN
        SELECT
          @I_vVNDITDSC = VNDITDSC
        FROM IV00103(nolock)
        WHERE VENDORID = @I_vVENDORID
        AND ITEMNMBR = @I_vITEMNMBR
      END
    END
    ELSE
    BEGIN
      SELECT
        @DECPLQTY = DECPLQTY,
        @DECPLCUR = ((DECPLCUR – 1) + 7),
        @ODECPLCU = (DECPLCUR – 1)
      FROM POP40100(nolock)
      WHERE INDEX1 = 1
      SELECT
        @UOFM = @I_vUOFM
    END
    IF (@I_vCURNCYID = ”)
    BEGIN
      SELECT
        @I_vCURNCYID = ISNULL(CURNCYID, ”)
      FROM PM00200(nolock)
      WHERE VENDORID = @I_vVENDORID
    END
    IF (@I_vCURNCYID <> ”)
    BEGIN
      SELECT
        @CURRNIDX = ISNULL(CURRNIDX, 0)
      FROM DYNAMICS..MC40200(nolock)
      WHERE CURNCYID = @I_vCURNCYID
    END
    ELSE
    BEGIN
      SELECT
        @I_vCURNCYID = ISNULL(FUNLCURR, ”),
        @CURRNIDX = ISNULL(FUNCRIDX, 0)
      FROM MC40000(nolock)
    END
    IF ((@I_vLOCNCODE = ”)
      AND (@LOCNCODEREG <> ”))
    BEGIN
      SELECT
        @O_iErrorState = 4601
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
    IF (@I_vAUTOCOST = 1)
    BEGIN
      SELECT
        @ORUNTCST = Last_Originating_Cost
      FROM IV00103(nolock)
      WHERE VENDORID = @I_vVENDORID
      AND ITEMNMBR = @I_vITEMNMBR
      AND Last_Currency_ID = @I_vCURNCYID
    END
  END
  IF (@POLNESTA IN (4, 5, 6))
  BEGIN
    SELECT
      @O_iErrorState = 591
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF (@POTYPE = 2)
  BEGIN
    SELECT
      @O_iErrorState = 590
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF ((@VENDORID <> @I_vVENDORID)
    AND (@I_vPONUMBER <> ”))
  BEGIN
    SELECT
      @O_iErrorState = 3799
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF (@I_vJOBNUMBR = ”)
  BEGIN
    SELECT
      @I_vJOBNUMBR = @JOBNUMBR
  END
  IF (@I_vUOFM = ”)
  BEGIN
    SELECT
      @I_vUOFM = @UOFM
  END
  IF (@I_vPOLNENUM = 0)
  BEGIN
    SELECT
      @I_vPOLNENUM = @POLNENUM
  END
  IF (@I_vLOCNCODE = ”)
  BEGIN
    SELECT
      @I_vLOCNCODE = @LOCNCODE
  END
  ELSE
  BEGIN
    IF ((@I_vLOCNCODE <> @LOCNCODE)
      AND (@I_vPONUMBER <> ”))
    BEGIN
      IF (@POPALWOP_2 = 0)
      BEGIN
        SELECT
          @O_iErrorState = 1276
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
      END
    END
  END
  IF ((@I_vPONUMBER <> ”)
    AND (@I_vUOFM <> ”))
  BEGIN
    IF (@I_vUOFM <> @UOFM)
    BEGIN
      SELECT
        @O_iErrorState = 4606
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
  END
  IF (((@VNDITNUM = ”)
    OR (@VNDITNUM IS NULL))
    AND (@I_vPONUMBER <> ”))
  BEGIN
    SELECT
      @O_iErrorState = 2053
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF ((@I_vNONINVEN = 0)
    AND (NOT EXISTS (SELECT
      1
    FROM IV00101(nolock)
    WHERE ITEMNMBR = @I_vITEMNMBR)
    ))
  BEGIN
    SELECT
      @O_iErrorState = 2054
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF (@I_vPONUMBER <> ”)
  BEGIN
    SELECT
      @CURNCYID = ISNULL(CURNCYID, 0)
    FROM POP10100(nolock)
    WHERE PONUMBER = @I_vPONUMBER
    SELECT
      @CURRNIDX = ISNULL(CURRNIDX, 0)
    FROM DYNAMICS..MC40200(nolock)
    WHERE CURNCYID = @CURNCYID
    IF ((@I_vCURNCYID <> ”)
      AND (@I_vCURNCYID <> @CURNCYID))
    BEGIN
      SELECT
        @O_iErrorState = 7320
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
    IF (@I_vCURNCYID = ”)
    BEGIN
      SELECT
        @I_vCURNCYID = @CURNCYID
    END
  END

  IF (EXISTS (SELECT
      1
    FROM WF100001
    WHERE FormID = 829)
    )
    AND (EXISTS (SELECT
      1
    FROM WF100002
    WHERE WF100002.ACTIVE = 1)
    )
  BEGIN
    IF (EXISTS (SELECT
        1
      FROM POP10100
      WHERE Workflow_Status <> 6
      AND PONUMBER = @I_vPONUMBER)
      )
    BEGIN
      SELECT
        @O_iErrorState = 12013
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
  END
  IF ((@I_vCURNCYID <> ”)
    AND (@I_vCURNCYID <> @FUNLCURR))
  BEGIN
    SELECT
      @ISMCTRX = 1
  END
  IF @I_vNONINVEN = 0
  BEGIN
    SELECT
      @I_vITEMDESC =
                    CASE
                      WHEN @I_vITEMDESC IS NULL THEN ITEMDESC
                      ELSE @I_vITEMDESC
                    END,
      @ITMTRKOP = ITMTRKOP,
      @ITEMTYPE = ITEMTYPE,
      @VCTNMTHD = VCTNMTHD,
      @INVINDX = IVIVINDX,
      @STNDCOST = STNDCOST,
      @PURPVIDX = PURPVIDX,
      @UPPVIDX = UPPVIDX,
      @Revalue_Inventory = Revalue_Inventory,
      @Tolerance_Percentage = Tolerance_Percentage,
      @PO_UOMSCHDL = UOMSCHDL,
      @PRICMTHD = PRICMTHD,
      @UOMSCHDL = UOMSCHDL,
      @CURRCOST = CURRCOST
    FROM IV00101(nolock)
    WHERE ITEMNMBR = @I_vITEMNMBR
    IF (@VCTNMTHD NOT IN (4, 5))
    BEGIN
      SELECT
        @UPPVIDX = 0
    END
    ELSE
    BEGIN
      IF (@UPPVIDX = 0)
      BEGIN
        SELECT
          @UPPVIDX = ACTINDX
        FROM SY01100(nolock)
        WHERE SERIES = 5
        AND SEQNUMBR = 1250
      END
    END
    IF @I_vVNDITDSC = ”
    BEGIN
      SELECT
        @I_vVNDITDSC = @VNDITDSC
    END
    IF @I_vINVINDX = 0
    BEGIN
      IF @I_vINVINDX = 0
      BEGIN
        SELECT
          @I_vINVINDX = INVINDX
        FROM POP10110(nolock)
        WHERE PONUMBER = @I_vPONUMBER
        AND ORD = @I_vPOLNENUM
        IF @I_vINVINDX <> 0
        BEGIN
          SELECT
            @TOOKACCTOFFPOORPASSED = 1
        END
      END
      IF @I_vINVINDX = 0
      BEGIN
        SELECT
          @I_vINVINDX = @INVINDX
      END
      IF @I_vINVINDX = 0
      BEGIN
        SELECT
          @I_vINVINDX = ACTINDX
        FROM SY01100(nolock)
        WHERE SERIES = 5
        AND SEQNUMBR = 100
      END
    END
  END
  ELSE
  BEGIN
    IF @I_vITEMDESC IS NULL
    BEGIN
      SELECT
        @I_vITEMDESC = @ITEMDESC
    END
    IF @I_vITEMDESC = ”
    BEGIN
      SELECT
        @I_vITEMDESC = @I_vVNDITDSC
    END
    IF @I_vVNDITDSC = ”
    BEGIN
      SELECT
        @I_vVNDITDSC = @VNDITDSC
    END
    IF @I_vINVINDX = 0
    BEGIN
      SELECT
        @I_vINVINDX = @INVINDX
      IF (@I_vINVINDX = 0)
        AND (@I_vCostCatID = ”)
      BEGIN
        SELECT
          @I_vINVINDX = PMPRCHIX
        FROM PM00200(nolock)
        WHERE VENDORID = @I_vVENDORID
      END
      ELSE
      BEGIN
        IF (@PROJECTLOADED = 1)
        BEGIN
          IF (@I_vPOLNENUM <> ”)
          BEGIN
            SELECT
              @I_vINVINDX = INVINDX
            FROM POP10110(nolock)
            WHERE PONUMBER = @I_vPONUMBER
            AND ORD = @I_vPOLNENUM
          END
          ELSE
          BEGIN
            IF (@PAProjectType = 3)
            BEGIN
              SELECT
                @I_vINVINDX = PAACTINDX
              FROM PA43001(nolock)
              WHERE PAsfid = 26
              AND PArecordid = @I_vCostCatID
              AND PAaccttype = 30
            END
            ELSE
            BEGIN
              SELECT
                @I_vINVINDX = PAACTINDX
              FROM PA43001(nolock)
              WHERE PAsfid = 26
              AND PArecordid = @I_vCostCatID
              AND PAaccttype = 1
            END
          END
        END
      END
    END
  END
  IF (@ITEMTYPE = 3)
  BEGIN
    SELECT
      @O_iErrorState = 9337
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  SELECT
    @SITEINACTIVE = INACTIVE
  FROM IV40700(nolock)
  WHERE LOCNCODE = @I_vLOCNCODE
  SELECT
    @ITEMSITEINACTIVE = INACTIVE
  FROM IV00102(nolock)
  WHERE (ITEMNMBR = @I_vITEMNMBR
  AND LOCNCODE = @I_vLOCNCODE)
  IF (@I_vLOCNCODE <> ”
    AND @SITEINACTIVE = 1)
  BEGIN
    SELECT
      @O_iErrorState = 11819
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF (@I_vLOCNCODE <> ”
    AND @I_vITEMNMBR <> ”
    AND @ITEMSITEINACTIVE = 1)
  BEGIN
    SELECT
      @O_iErrorState = 11820
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF (@I_vInventoryAccount <> ”)
  BEGIN
    SELECT
      @I_vINVINDX = 0
    SELECT
      @I_vINVINDX = ACTINDX
    FROM GL00105(nolock)
    WHERE ACTNUMST = @I_vInventoryAccount
    IF (@I_vINVINDX = 0)
    BEGIN
      SELECT
        @O_iErrorState = 446
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
  END
  IF NOT EXISTS (SELECT
      1
    FROM GL00105(nolock)
    WHERE ACTINDX = @I_vINVINDX)
  BEGIN
    SELECT
      @O_iErrorState = 4612
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF (@I_vUNITCOST < 0)
    OR (@I_vUNITCOST IS NULL
    AND @I_vAUTOCOST = 0)
  BEGIN
    SELECT
      @O_iErrorState = 8052
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF (@ISMCTRX = 0)
  BEGIN
    IF (EXISTS (SELECT DISTINCT
        1
      FROM IV00105(nolock)
      WHERE ITEMNMBR = @I_vITEMNMBR)
      )
    BEGIN
      IF (NOT EXISTS (SELECT
          1
        FROM IV00105(nolock)
        WHERE ITEMNMBR = @I_vITEMNMBR
        AND CURNCYID <> ”)
        )
      BEGIN
        SELECT
          @MCINSTALLED = 0
      END
    END
    ELSE
    BEGIN
      IF ((NOT EXISTS (SELECT TOP 1
          CURNCYID
        FROM IV00105(nolock)
        WHERE CURNCYID <> ”)
        )
        AND (NOT EXISTS (SELECT TOP 1
          CURNCYID
        FROM CM00100(nolock)
        WHERE CURNCYID <> ”)
        ))
      BEGIN
        SELECT
          @MCINSTALLED = 0
      END
    END
  END
  IF (@I_vNONINVEN = 0)
  BEGIN
    IF (@ISMCTRX = 1)
    BEGIN
      SELECT
        @DECPLCURItem = DECPLCUR – 1,
        @ODECPLCU = DECPLCUR – 1,
        @LISTPRCE = LISTPRCE
      FROM IV00105(nolock)
      WHERE ITEMNMBR = @I_vITEMNMBR
      AND CURNCYID = @I_vCURNCYID
    END
    ELSE
    BEGIN
      SELECT
        @DECPLCURItem = DECPLCUR – 1,
        @ODECPLCU = DECPLCUR – 1,
        @LISTPRCE = LISTPRCE
      FROM IV00105(nolock)
      WHERE ITEMNMBR = @I_vITEMNMBR
      AND (CURNCYID = ”
      OR CURNCYID = @I_vCURNCYID)
    END
  END
  ELSE
  BEGIN
    IF (@MCINSTALLED = 0)
    BEGIN
      SELECT
        @DECPLCURItem = DECPLCUR – 1
      FROM POP40100(nolock)
      WHERE INDEX1 = 1
    END
    ELSE
    BEGIN
      SELECT
        @DECPLCURItem = DECPLCUR – 1
      FROM POP40600(nolock)
      WHERE CURNCYID = @I_vCURNCYID
    END
  END
  IF (@ISMCTRX = 1)
  BEGIN
    SELECT
      @EDITDECPLCUR = DECPLCUR – 1
    FROM DYNAMICS..MC40200(nolock)
    WHERE CURNCYID = @I_vCURNCYID
  END
  ELSE
  BEGIN
    SELECT
      @EDITDECPLCUR = @FUNDECPLCUR
  END
  IF (@I_vPONUMBER = ”)
  BEGIN
    SELECT
      @ORUNTCST = ROUND((@ORUNTCST * @UMQTYINB), @DECPLCURItem)
  END
  IF (@I_vUNITCOST IS NULL
    OR @I_vUNITCOST = 0)
    AND (@I_vAUTOCOST = 1)
  BEGIN
    SELECT
      @I_vUNITCOST = @ORUNTCST
  END
  IF (@I_vAUTOCOST = 0)
  BEGIN
    IF @I_vEXTDCOST IS NULL
    BEGIN
      SELECT
        @I_vEXTDCOST =
                      CASE
                        WHEN @I_vPOPTYPE = 1 THEN ROUND((@I_vUNITCOST) * @I_vQTYSHPPD, @EDITDECPLCUR)
                        ELSE ROUND((@I_vUNITCOST) * @I_vQTYINVCD, @EDITDECPLCUR)
                      END
    END
    ELSE
    BEGIN
      SELECT
        @PassedExtCost = 1
    END
    IF ((@I_vQTYSHPPD = 0)
      AND (@I_vPOPTYPE = 1))
    BEGIN
      IF (@I_vEXTDCOST > 0)
      BEGIN
        SELECT
          @O_iErrorState = 5446
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
      END
    END
    IF ((@I_vQTYINVCD = 0)
      AND (@I_vPOPTYPE = 3))
    BEGIN
      IF (@I_vEXTDCOST > 0)
      BEGIN
        SELECT
          @O_iErrorState = 7993
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
      END
    END
    IF ((@I_vPOPTYPE = 1)
      AND (@I_vQTYSHPPD <> 0))
    BEGIN
      IF ((ROUND(ABS((@I_vUNITCOST) – ROUND((@I_vEXTDCOST / @I_vQTYSHPPD), @DECPLCURItem)) * @I_vQTYSHPPD, @EDITDECPLCUR)) <> 0)
      BEGIN
        IF ((ROUND(ABS(ROUND((@I_vUNITCOST) * @I_vQTYSHPPD, @EDITDECPLCUR) – @I_vEXTDCOST) * @I_vQTYSHPPD, @EDITDECPLCUR)) <> 0)
        BEGIN
          SELECT
            @O_iErrorState = 2057
          EXEC @iStatus = taUpdateString @O_iErrorState,
                                         @oErrString,
                                         @oErrString OUTPUT,
                                         @O_oErrorState OUTPUT
        END
      END
    END
    IF ((@I_vPOPTYPE = 3)
      AND (@I_vQTYINVCD <> 0))
    BEGIN
      IF ((ROUND(ABS((@I_vUNITCOST) – ROUND((@I_vEXTDCOST / @I_vQTYINVCD), @DECPLCURItem)) * @I_vQTYINVCD, @EDITDECPLCUR)) <> 0)
      BEGIN
        IF ((ROUND(ABS(ROUND((@I_vUNITCOST) * @I_vQTYINVCD, @EDITDECPLCUR) – @I_vEXTDCOST) * @I_vQTYINVCD, @EDITDECPLCUR)) <> 0)
        BEGIN
          SELECT
            @O_iErrorState = 8051
          EXEC @iStatus = taUpdateString @O_iErrorState,
                                         @oErrString,
                                         @oErrString OUTPUT,
                                         @O_oErrorState OUTPUT
        END
      END
    END
  END
  IF (@I_vRCPTLNNM = 0)
  BEGIN
    SELECT
      @I_vRCPTLNNM = ISNULL(MAX(RCPTLNNM), 0) + 16384
    FROM POP10310(nolock)
    WHERE POPRCTNM = @I_vPOPRCTNM
  END
  IF EXISTS (SELECT
      1
    FROM POP10310(nolock)
    WHERE POPRCTNM = @I_vPOPRCTNM
    AND RCPTLNNM = @I_vRCPTLNNM)
  BEGIN
    SELECT
      @O_iErrorState = 2061
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF ((@I_vQTYINVCD > @I_vQTYSHPPD)
    AND (@I_vPOPTYPE = 3))
  BEGIN
    SELECT
      @O_iErrorState = 2062
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF ((@I_vQTYINVCD > 0)
    AND (@I_vPOPTYPE = 1))
  BEGIN
    SELECT
      @O_iErrorState = 734
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF ((@I_vPurchase_IV_Item_Taxable < 1)
    OR (@I_vPurchase_IV_Item_Taxable > 3))
  BEGIN
    SELECT
      @O_iErrorState = 2045
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF EXISTS (SELECT
      1
    FROM POP10360(nolock)
    WHERE POPRCTNM = @I_vPOPRCTNM
    AND RCPTLNNM = @I_vRCPTLNNM)
  BEGIN
    SELECT
      @I_vPurchase_IV_Item_Taxable = 1
  END
  IF (@I_vPurchase_IV_Item_Taxable <> 1)
  BEGIN
    SELECT
      @I_vPurchase_Item_Tax_Schedu = ”
  END
  IF (@I_vPurchase_Item_Tax_Schedu <> ”)
  BEGIN
    IF (NOT EXISTS (SELECT
        1
      FROM TX00101(nolock)
      WHERE TAXSCHID = @I_vPurchase_Item_Tax_Schedu)
      )
    BEGIN
      SELECT
        @O_iErrorState = 833
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
  END
  IF (@I_vPurchase_Site_Tax_Schedu <> ”)
  BEGIN
    IF (NOT EXISTS (SELECT
        1
      FROM TX00101(nolock)
      WHERE TAXSCHID = @I_vPurchase_Site_Tax_Schedu)
      )
    BEGIN
      SELECT
        @O_iErrorState = 834
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
  END
  IF (@I_vLanded_Cost_Group_ID <> ”)
  BEGIN
    IF (NOT EXISTS (SELECT
        1
      FROM IV41101(nolock)
      WHERE Landed_Cost_Group_ID = @I_vLanded_Cost_Group_ID)
      )
    BEGIN
      SELECT
        @O_iErrorState = 837
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
  END
  IF (@I_vPONUMBER <> ”)
  BEGIN
    SELECT
      @SHIPMTHD = ISNULL(SHIPMTHD, ”)
    FROM POP10100(nolock)
    WHERE PONUMBER = @I_vPONUMBER
  END
  ELSE
  BEGIN
    SELECT
      @VADCDPAD = ISNULL(VADCDPAD, ”)
    FROM PM00200(nolock)
    WHERE VENDORID = @I_vVENDORID
    SELECT
      @SHIPMTHD = ISNULL(SHIPMTHD, ”)
    FROM PM00300(nolock)
    WHERE VENDORID = @I_vVENDORID
    AND ADRSCODE = @VADCDPAD
  END
  IF (@I_vNONINVEN = 1)
  BEGIN
    SELECT
      @PURPVIDX = ISNULL(PURPVIDX, 0)
    FROM PM00200(nolock)
    WHERE VENDORID = @I_vVENDORID
    IF (@PURPVIDX = 0)
    BEGIN
      SELECT
        @PURPVIDX = ACTINDX
      FROM SY01100(nolock)
      WHERE SERIES = 4
      AND SEQNUMBR = 1400
    END
  END
  ELSE
  BEGIN
    SELECT
      @PURPVIDX = ISNULL(PURPVIDX, 0)
    FROM IV00101(nolock)
    WHERE ITEMNMBR = @I_vITEMNMBR
    IF (@PURPVIDX = 0)
    BEGIN
      SELECT
        @PURPVIDX = ACTINDX,
        @NOACCTONITEM = 1
      FROM SY01100(nolock)
      WHERE SERIES = 5
      AND SEQNUMBR = 1200
    END
  END
  IF (@I_vNONINVEN = 1)
  BEGIN
    IF (EXISTS (SELECT
        ITEMNMBR
      FROM IV00101(nolock)
      WHERE ITEMNMBR = @I_vITEMNMBR)
      )
    BEGIN
      SELECT
        @O_iErrorState = 8162
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
      RETURN (@O_iErrorState)
    END
  END
  IF (ROUND(@I_vUNITCOST, @DECPLCURItem) <> (@I_vUNITCOST))
  BEGIN
    SELECT
      @O_iErrorState = 7321
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF (ROUND(@I_vEXTDCOST, @EDITDECPLCUR) <> (@I_vEXTDCOST))
  BEGIN
    SELECT
      @O_iErrorState = 7322
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF (@POTYPE IN (1, 3))
  BEGIN
    IF (@I_vNONINVEN = 1)
    BEGIN
      SELECT
        @UseQtyOverageTolerance = UseQtyOverageTolerance,
        @QtyOverTolerancePercent = QtyOverTolerancePercent
      FROM POP40100(nolock)
      IF (@UseQtyOverageTolerance = 1
        AND @QtyOverTolerancePercent > 0)
      BEGIN
        SELECT
          @CurrentQtyShipped = ISNULL(SUM(QTYSHPPD), 0)
        FROM POP10500(nolock)
        WHERE PONUMBER = @I_vPONUMBER
        AND POLNENUM = @I_vPOLNENUM
        SELECT
          @QtyOnPO = QTYORDER – QTYCANCE
        FROM POP10110(nolock)
        WHERE PONUMBER = @I_vPONUMBER
        AND ORD = @I_vPOLNENUM
        SELECT
          @MaxToleranceAmount = CEILING((CAST(@QtyOverTolerancePercent AS decimal(8, 3)) / 100000 * @QtyOnPO) * POWER(10, @DECPLQTY – 1)) / POWER(10, @DECPLQTY – 1) + @QtyOnPO
        SELECT
          @RemainingQtyOnPO = @QtyOnPO – @CurrentQtyShipped
        IF (@I_vQTYSHPPD + (@QtyOnPO – @RemainingQtyOnPO) >= @MaxToleranceAmount)
        BEGIN
          SELECT
            @O_iErrorState = 11780
          EXEC @iStatus = taUpdateString @O_iErrorState,
                                         @oErrString,
                                         @oErrString OUTPUT,
                                         @O_oErrorState OUTPUT
        END
      END
    END
    ELSE
    IF (@I_vNONINVEN = 0)
    BEGIN
      SELECT
        @UseQtyOverageTolerance = UseQtyOverageTolerance,
        @QtyOverTolerancePercent = QtyOverTolerancePercent
      FROM IV00101(nolock)
      WHERE ITEMNMBR = @I_vITEMNMBR
      IF (@UseQtyOverageTolerance = 1
        AND @QtyOverTolerancePercent > 0)
      BEGIN
        SELECT
          @CurrentQtyShipped = ISNULL(SUM(QTYSHPPD), 0)
        FROM POP10500(nolock)
        WHERE PONUMBER = @I_vPONUMBER
        AND POLNENUM = @I_vPOLNENUM
        SELECT
          @QtyOnPO = QTYORDER – QTYCANCE
        FROM POP10110(nolock)
        WHERE PONUMBER = @I_vPONUMBER
        AND ORD = @I_vPOLNENUM
        SELECT
          @MaxToleranceAmount = CEILING((CAST(@QtyOverTolerancePercent AS decimal(8, 3)) / 100000 * @QtyOnPO) * POWER(10, @DECPLQTY – 1)) / POWER(10, @DECPLQTY – 1) + @QtyOnPO
        SELECT
          @RemainingQtyOnPO = @QtyOnPO – @CurrentQtyShipped
        IF (@I_vQTYSHPPD + (@QtyOnPO – @RemainingQtyOnPO) >= @MaxToleranceAmount)
        BEGIN
          SELECT
            @O_iErrorState = 11781
          EXEC @iStatus = taUpdateString @O_iErrorState,
                                         @oErrString,
                                         @oErrString OUTPUT,
                                         @O_oErrorState OUTPUT
        END
      END
    END
  END
  IF (@POTYPE = 1)
    AND (@PROJECTLOADED = 1)
    AND (@I_vNONINVEN = 0)
  BEGIN
    SELECT
      @PAbllngtype = 3,
      @PABilling_StatusN = 4
  END
  ELSE
  BEGIN
    IF (@POTYPE = 2)
    BEGIN
      IF (@I_vProjNum <> ‘‘)
      BEGIN
        SELECT
          @PAbllngtype = PAbllngtype
        FROM PA01303(nolock)
        WHERE PAPROJNUMBER = @I_vProjNum
        AND PACOSTCATID = @I_vCostCatID
        AND ITEMNMBR = @I_vITEMNMBR
        AND PALineItemSeq = @PO_PALineItemSeq
        SELECT
          @PABilling_StatusN =
                              CASE
                                WHEN @PAbllngtype = 3 THEN 4
                                ELSE 1
                              END
        IF (@PAProjectType <> 1)
        BEGIN
          SELECT
            @PAbllngtype = 1,
            @PABilling_StatusN = 5
        END
      END
      ELSE
      BEGIN
        SELECT
          @PASTAT = 4,
          @PAbllngtype = 3,
          @PABILRATE = 0,
          @PAMARKPERCENT = 0,
          @PAACREV = 0
      END
    END
  END
  IF (@I_vPOPTYPE <> 1)
  BEGIN
    SELECT
      @PATOTALOVERH = ROUND((@PAOverhead_Amount + (@PABase_Unit_Cost * (@PAOverheaPercentage / 100))) * @PABase_Qty, 2)
  END
  IF (@POTYPE IN (0, 1))
    AND (@PROJECTLOADED = 1)
    AND (@I_vNONINVEN = 1)
  BEGIN
    IF (@PAProjectType <> 1)
    BEGIN
      SELECT
        @PAbllngtype = 1,
        @PABilling_StatusN = 5
    END
    ELSE
    BEGIN
      SELECT
        @PAbllngtype = 1,
        @PABilling_StatusN = 1
    END
  END
  IF (@I_vNONINVEN = 1)
    AND (@PROJECTLOADED = 1)
  BEGIN
    IF NOT EXISTS (SELECT
        1
      FROM PA10702(nolock)
      WHERE POPTYPE = @I_vPOPTYPE
      AND PAVIDN = @I_vPOPRCTNM
      AND RCPTLNNM = @I_vRCPTLNNM)
    BEGIN
      IF (@PAviprofittypefrom = 1)
        AND (@I_vProjNum <> ‘‘)
      BEGIN
        IF @PAProjectType = 1
        BEGIN
          IF @PAProfitType = 1
          BEGIN
            SELECT
              @use_billing_rate = 1
            SELECT
              @PABILRATE = PAFProfitAmt,
              @PAbllngtype = PAbllngtype
            FROM PA01301(nolock)
            WHERE PAPROJNUMBER = @I_vProjNum
            AND PACOSTCATID = @I_vCostCatID
            AND PATU = @PATU
          END
          ELSE
          IF @PAProfitType = 2
          BEGIN
            SELECT
              @use_markup_percentage = 1
            SELECT
              @PAMARKPERCENT = PAFProfitPcnt,
              @PAbllngtype = PAbllngtype
            FROM PA01301(nolock)
            WHERE PAPROJNUMBER = @I_vProjNum
            AND PACOSTCATID = @I_vCostCatID
            AND PATU = @PATU
          END
          ELSE
          IF @PAProfitType = 8
          BEGIN
            SELECT
              @use_markup_percentage = 0
            SELECT
              @PAbllngtype = PAbllngtype
            FROM PA01301(nolock)
            WHERE PAPROJNUMBER = @I_vProjNum
            AND PACOSTCATID = @I_vCostCatID
            AND PATU = @PATU
          END
        END
      END
      ELSE
      IF (@PAviprofittypefrom = 2)
      BEGIN
        SELECT
          @PA00901_PATMProfitType = PATMProfitType,
          @PABILRATE = PATMProfitAmount,
          @PAMARKPERCENT = PATMProfitPercent
        FROM PA00901(nolock)
        WHERE VENDORID = @I_vVENDORID
        IF (@PA00901_PATMProfitType <> 0)
        BEGIN
          IF @PAProjectType = 1
          BEGIN
            IF (@PA00901_PATMProfitType = 1)
            BEGIN
              SELECT
                @use_billing_rate = 1,
                @PAMARKPERCENT = 0
              SELECT
                @PAbllngtype = PAbllngtype
              FROM PA01301(nolock)
              WHERE PAPROJNUMBER = @I_vProjNum
              AND PACOSTCATID = @I_vCostCatID
              AND PATU = @PATU
              IF (@PAProfitType = 8
                AND @PA00901_PATMProfitType = 1
                AND @PAAcctgMethod = 2)
              BEGIN
                SELECT
                  @PABILRATE = 0,
                  @PAProfitType = 1
              END
              ELSE
              BEGIN
                IF (@PAProfitType = 8
                  AND @PA00901_PATMProfitType = 1
                  AND @PAAcctgMethod = 1)
                BEGIN
                  SELECT
                    @PAProfitType = 1
                END
              END
            END
            ELSE
            IF (@PA00901_PATMProfitType = 2)
            BEGIN
              SELECT
                @use_markup_percentage = 1,
                @PABILRATE = 0
            END
            ELSE
            IF (@PA00901_PATMProfitType = 8)
            BEGIN
              SELECT
                @use_markup_percentage = 0
              SELECT
                @PAbllngtype = PAbllngtype
              FROM PA01301(nolock)
            END
          END
        END
      END
      ELSE
      BEGIN
        SELECT
          @PA01001_PATMProfitType = PATMProfitType,
          @PABILRATE = PATMProfitAmount,
          @PAMARKPERCENT = PATMProfitPercent
        FROM PA01001(nolock)
        WHERE PACOSTCATID = @I_vCostCatID
        IF @PAProjectType = 1
        BEGIN
          SELECT
            @PAbllngtype = PAbllngtype
          FROM PA01301(nolock)
          WHERE PAPROJNUMBER = @I_vProjNum
          AND PACOSTCATID = @I_vCostCatID
          AND PATU = @PATU
          IF @PA01001_PATMProfitType = 1
          BEGIN
            SELECT
              @use_billing_rate = 1,
              @PAMARKPERCENT = 0
          END
          ELSE
          IF @PA01001_PATMProfitType = 2
          BEGIN
            SELECT
              @use_markup_percentage = 1,
              @PABILRATE = 0
          END
          ELSE
          IF @PA01001_PATMProfitType = 8
          BEGIN
            SELECT
              @use_markup_percentage = 0
          END
        END
      END
    END
  END
  IF (@PAbllngtype = 1)
    AND (@PROJECTLOADED = 1)
  BEGIN
    IF (@use_billing_rate = 1)
      AND (@use_markup_percentage = 0)
    BEGIN
      IF (@I_vNONINVEN = 1)
        OR (@POTYPE = 2)
      BEGIN
        SELECT
          @PAMARKPERCENT = 0
        SELECT
          @PAACREV = (@PABILRATE * @I_vQTYSHPPD)
      END
    END
    ELSE
    IF (@use_billing_rate = 0)
      AND (@use_markup_percentage = 1)
    BEGIN
      IF (@I_vNONINVEN = 1)
        OR (@POTYPE = 2)
      BEGIN
        SELECT
          @PABILRATE = 0
        IF (@I_vEXTDCOST IS NOT NULL)
        BEGIN
          SELECT
            @PAACREV = ROUND(@I_vEXTDCOST * (1 + (@PAMARKPERCENT / 100)), @DECPLCUR)
        END
        ELSE
        BEGIN
          IF (@I_vPOPTYPE = 1)
          BEGIN
            SELECT
              @I_vEXTDCOST = ROUND(@ORUNTCST * @I_vQTYSHPPD, @EDITDECPLCUR)
            SELECT
              @PAACREV = ROUND(@I_vEXTDCOST * (1 + (@PAMARKPERCENT / 100)), @DECPLCUR)
          END
          ELSE
          BEGIN
            SELECT
              @I_vEXTDCOST = ROUND(@ORUNTCST * @I_vQTYINVCD, @EDITDECPLCUR)
            SELECT
              @PAACREV = ROUND(@I_vEXTDCOST * (1 + (@PAMARKPERCENT / 100)), @DECPLCUR)
          END
        END
      END
    END
  END
  ELSE
  BEGIN
    SELECT
      @PAACREV = 0
  END
  IF (@PAACREV <> 0)
    AND (@PROJECTLOADED = 1)
  BEGIN
    IF (@PAINCPRCHTXPRJCST = 1)
    BEGIN
      SELECT
        @tax_amount = @I_vTAXAMNT
    END
    SELECT
      @PATotalProfit = @PAPostedBillingsN – (@PAShipmentExtCost + @tax_amount)
  END
  IF (@PROJECTLOADED = 1)
  BEGIN
    SELECT
      @PA_Base_Billing_Rate =
                             CASE
                               WHEN @I_vUOFM <> ” AND
                                 (@PABILRATE = 0 OR
                                 @UMQTYINB = 0) THEN 0
                               WHEN @I_vUOFM <> ” AND
                                 @PABILRATE <> 0 AND
                                 @UMQTYINB <> 0 THEN (@PABILRATE / @UMQTYINB)
                               ELSE @PABILRATE
                             END,
      @PABaseOvhdCost =
                       CASE
                         WHEN @I_vUOFM <> ” AND
                           (@PAOverhead_Amount = 0 OR
                           @UMQTYINB = 0) THEN 0
                         WHEN @I_vUOFM <> ” AND
                           @PAOverhead_Amount <> 0 AND
                           @UMQTYINB <> 0 THEN (@PAOverhead_Amount / @UMQTYINB)
                         ELSE @PAOverhead_Amount
                       END,
      @PAShipmentExtCost =
                          CASE
                            WHEN (@I_vPOPTYPE = 1 OR
                              @I_vPOPTYPE = 3) THEN (@I_vQTYSHPPD * @I_vUNITCOST)
                            ELSE 0
                          END
  END
  IF (@I_vCostCatID <> ‘‘)
    AND (@PROJECTLOADED = 1)
  BEGIN
    IF (@PAProjectType = 1)
      OR (@I_vProjNum = ‘‘)
    BEGIN
      IF ((@I_vPOPTYPE = 1)
        AND (@PO_PAIV_Item_Checkbox = 0))
        OR ((@I_vPOPTYPE <> 1)
        AND (@PO_PAIV_Item_Checkbox = 0))
        OR ((@I_vPOPTYPE <> 1)
        AND (@PO_PAIV_Item_Checkbox = 1)
        AND (@POTYPE = 2))
      BEGIN
        IF (@PAAcctgMethod = 1)
        BEGIN
          EXEC @iStatus = taPAAuxAcctsGetIdx @I_vPAPROJNUMBER = @I_vProjNum,
                                             @I_vPACOSTCATID = @I_vCostCatID,
                                             @I_vEMPLOYID = @I_vVENDORID,
                                             @I_vPATU = 4,
                                             @I_vPAcosttrxid = ‘VI’,
                                             @I_vTYPE = 2,
                                             @I_vCUSTNMBR = @CUSTNMBR,
                                             @I_vPACONTNUMBER = @PACONTNUMBER,
                                             @O_iINDEX = @PO_PACogs_Idx OUTPUT,
                                             @O_iErrorState = @O_oErrorState OUTPUT
          SELECT
            @iError = @@error
          IF @iStatus = 0
            AND @iError <> 0
            SELECT
              @iStatus = @iError
          IF (@iStatus <> 0)
            OR (@O_oErrorState <> 0)
          BEGIN
            SELECT
              @O_iErrorState = 8184
            EXEC @iStatus = taUpdateString @O_iErrorState,
                                           @oErrString,
                                           @oErrString OUTPUT,
                                           @O_oErrorState OUTPUT
          END
        END
        ELSE
        IF (@PAAcctgMethod = 2)
        BEGIN
          EXEC @iStatus = taPAAuxAcctsGetIdx @I_vPAPROJNUMBER = @I_vProjNum,
                                             @I_vPACOSTCATID = @I_vCostCatID,
                                             @I_vEMPLOYID = @I_vVENDORID,
                                             @I_vPATU = 4,
                                             @I_vPAcosttrxid = ‘VI’,
                                             @I_vTYPE = 1,
                                             @I_vCUSTNMBR = @CUSTNMBR,
                                             @I_vPACONTNUMBER = @PACONTNUMBER,
                                             @O_iINDEX = @PACGBWIPIDX OUTPUT,
                                             @O_iErrorState = @O_oErrorState OUTPUT
          SELECT
            @iError = @@error
          IF @iStatus = 0
            AND @iError <> 0
            SELECT
              @iStatus = @iError
          IF (@iStatus <> 0)
            OR (@O_oErrorState <> 0)
          BEGIN
            SELECT
              @O_iErrorState = 8185
            EXEC @iStatus = taUpdateString @O_iErrorState,
                                           @oErrString,
                                           @oErrString OUTPUT,
                                           @O_oErrorState OUTPUT
          END
          IF (@PACGBWIPIDX = 0)
          BEGIN
            EXEC @iStatus = taPAAuxAcctsGetIdx @I_vPAPROJNUMBER = @I_vProjNum,
                                               @I_vPACOSTCATID = @I_vCostCatID,
                                               @I_vEMPLOYID = @I_vVENDORID,
                                               @I_vPATU = 4,
                                               @I_vPAcosttrxid = ‘VI’,
                                               @I_vTYPE = 2,
                                               @I_vCUSTNMBR = @CUSTNMBR,
                                               @I_vPACONTNUMBER = @PACONTNUMBER,
                                               @O_iINDEX = @PO_PACogs_Idx OUTPUT,
                                               @O_iErrorState = @O_oErrorState OUTPUT
            SELECT
              @iError = @@error
            IF @iStatus = 0
              AND @iError <> 0
              SELECT
                @iStatus = @iError
            IF (@iStatus <> 0)
              OR (@O_oErrorState <> 0)
            BEGIN
              SELECT
                @O_iErrorState = 8186
              EXEC @iStatus = taUpdateString @O_iErrorState,
                                             @oErrString,
                                             @oErrString OUTPUT,
                                             @O_oErrorState OUTPUT
            END
          END
        END
      END
      IF (@PO_PACogs_Idx = 0)
      BEGIN
        EXEC @iStatus = taPAAuxAcctsGetIdx @I_vPAPROJNUMBER = @I_vProjNum,
                                           @I_vPACOSTCATID = @I_vCostCatID,
                                           @I_vEMPLOYID = @I_vVENDORID,
                                           @I_vPATU = 4,
                                           @I_vPAcosttrxid = ‘VI’,
                                           @I_vTYPE = 2,
                                           @I_vCUSTNMBR = @CUSTNMBR,
                                           @I_vPACONTNUMBER = @PACONTNUMBER,
                                           @O_iINDEX = @PO_PACogs_Idx OUTPUT,
                                           @O_iErrorState = @O_oErrorState OUTPUT
        SELECT
          @iError = @@error
        IF @iStatus = 0
          AND @iError <> 0
          SELECT
            @iStatus = @iError
        IF (@iStatus <> 0)
          OR (@O_oErrorState <> 0)
        BEGIN
          SELECT
            @O_iErrorState = 8187
          EXEC @iStatus = taUpdateString @O_iErrorState,
                                         @oErrString,
                                         @oErrString OUTPUT,
                                         @O_oErrorState OUTPUT
        END
      END
      IF (@PAAcctgMethod <> 2)
      BEGIN
        EXEC @iStatus = taPAAuxAcctsGetIdx @I_vPAPROJNUMBER = @I_vProjNum,
                                           @I_vPACOSTCATID = @I_vCostCatID,
                                           @I_vEMPLOYID = @I_vVENDORID,
                                           @I_vPATU = 4,
                                           @I_vPAcosttrxid = ‘VI’,
                                           @I_vTYPE = 4,
                                           @I_vCUSTNMBR = @CUSTNMBR,
                                           @I_vPACONTNUMBER = @PACONTNUMBER,
                                           @O_iINDEX = @PAUnbilled_AR_Idx OUTPUT,
                                           @O_iErrorState = @O_oErrorState OUTPUT
        SELECT
          @iError = @@error
        IF @iStatus = 0
          AND @iError <> 0
          SELECT
            @iStatus = @iError
        IF (@iStatus <> 0)
          OR (@O_oErrorState <> 0)
        BEGIN
          SELECT
            @O_iErrorState = 8188
          EXEC @iStatus = taUpdateString @O_iErrorState,
                                         @oErrString,
                                         @oErrString OUTPUT,
                                         @O_oErrorState OUTPUT
        END
        IF (@PAUnbilled_AR_Idx <> 0)
        BEGIN
          EXEC @iStatus = taPAAuxAcctsGetIdx @I_vPAPROJNUMBER = @I_vProjNum,
                                             @I_vPACOSTCATID = @I_vCostCatID,
                                             @I_vEMPLOYID = @I_vVENDORID,
                                             @I_vPATU = 4,
                                             @I_vPAcosttrxid = ‘VI’,
                                             @I_vTYPE = 5,
                                             @I_vCUSTNMBR = @CUSTNMBR,
                                             @I_vPACONTNUMBER = @PACONTNUMBER,
                                             @O_iINDEX = @PAUnbilled_Proj_Rev_Idx OUTPUT,
                                             @O_iErrorState = @O_oErrorState OUTPUT
          SELECT
            @iError = @@error
          IF @iStatus = 0
            AND @iError <> 0
            SELECT
              @iStatus = @iError
          IF (@iStatus <> 0)
            OR (@O_oErrorState <> 0)
          BEGIN
            SELECT
              @O_iErrorState = 8189
            EXEC @iStatus = taUpdateString @O_iErrorState,
                                           @oErrString,
                                           @oErrString OUTPUT,
                                           @O_oErrorState OUTPUT
          END
          IF (@PAUnbilled_Proj_Rev_Idx = 0)
            SELECT
              @PAUnbilled_AR_Idx = 0
        END
      END
      IF (@PO_PAIV_Item_Checkbox <> 1)
      BEGIN
        IF (@I_vPOPTYPE <> 1)
        BEGIN
          EXEC @iStatus = taPAAuxAcctsGetIdx @I_vPAPROJNUMBER = @I_vProjNum,
                                             @I_vPACOSTCATID = @I_vCostCatID,
                                             @I_vEMPLOYID = @I_vVENDORID,
                                             @I_vPATU = 4,
                                             @I_vPAcosttrxid = ‘VI’,
                                             @I_vTYPE = 3,
                                             @I_vCUSTNMBR = @CUSTNMBR,
                                             @I_vPACONTNUMBER = @PACONTNUMBER,
                                             @O_iINDEX = @PAContra_Account_IDX OUTPUT,
                                             @O_iErrorState = @O_oErrorState OUTPUT
          SELECT
            @iError = @@error
          IF @iStatus = 0
            AND @iError <> 0
            SELECT
              @iStatus = @iError
          IF (@iStatus <> 0)
            OR (@O_oErrorState <> 0)
          BEGIN
            SELECT
              @O_iErrorState = 8190
            EXEC @iStatus = taUpdateString @O_iErrorState,
                                           @oErrString,
                                           @oErrString OUTPUT,
                                           @O_oErrorState OUTPUT
          END
        END
      END
    END
    ELSE
    BEGIN
      IF (@PACGBWIPIDX = 0)
      BEGIN
        EXEC @iStatus = taPAAuxAcctsGetIdx @I_vPAPROJNUMBER = @I_vProjNum,
                                           @I_vPACOSTCATID = @I_vCostCatID,
                                           @I_vEMPLOYID = @I_vVENDORID,
                                           @I_vPATU = 4,
                                           @I_vPAcosttrxid = ‘VI’,
                                           @I_vTYPE = 30,
                                           @I_vCUSTNMBR = @CUSTNMBR,
                                           @I_vPACONTNUMBER = @PACONTNUMBER,
                                           @O_iINDEX = @PACGBWIPIDX OUTPUT,
                                           @O_iErrorState = @O_oErrorState OUTPUT
        SELECT
          @iError = @@error
        IF @iStatus = 0
          AND @iError <> 0
          SELECT
            @iStatus = @iError
        IF ((@O_oErrorState = 2055)
          OR (@iStatus = 2055))
          AND (@PO_PAIV_Item_Checkbox = 1)
          SELECT
            @O_oErrorState = 0,
            @iStatus = 0
        IF (@iStatus <> 0)
          OR (@O_oErrorState <> 0)
        BEGIN
          SELECT
            @O_iErrorState = 8191
          EXEC @iStatus = taUpdateString @O_iErrorState,
                                         @oErrString,
                                         @oErrString OUTPUT,
                                         @O_oErrorState OUTPUT
        END
      END
      IF ((@I_vPOPTYPE <> 1)
        AND (@PO_PAIV_Item_Checkbox = 0))
      BEGIN
        IF (@PACGBWIPIDX <> 0)
        BEGIN
          IF (@PAContra_Account_IDX = 0)
          BEGIN
            EXEC @iStatus = taPAAuxAcctsGetIdx @I_vPAPROJNUMBER = @I_vProjNum,
                                               @I_vPACOSTCATID = @I_vCostCatID,
                                               @I_vEMPLOYID = @I_vVENDORID,
                                               @I_vPATU = 4,
                                               @I_vPAcosttrxid = ‘VI’,
                                               @I_vTYPE = 31,
                                               @I_vCUSTNMBR = @CUSTNMBR,
                                               @I_vPACONTNUMBER = @PACONTNUMBER,
                                               @O_iINDEX = @PAContra_Account_IDX OUTPUT,
                                               @O_iErrorState = @O_oErrorState OUTPUT
            SELECT
              @iError = @@error
            IF @iStatus = 0
              AND @iError <> 0
              SELECT
                @iStatus = @iError
            IF (@iStatus <> 0)
              OR (@O_oErrorState <> 0)
            BEGIN
              SELECT
                @O_iErrorState = 8192
              EXEC @iStatus = taUpdateString @O_iErrorState,
                                             @oErrString,
                                             @oErrString OUTPUT,
                                             @O_oErrorState OUTPUT
            END
          END
        END
      END
    END
  END
  IF (@PO_PACGBWIPIDX = 0)
    AND (@PROJECTLOADED = 1)
  BEGIN
    SELECT
      @PO_PACGBWIPIDX = @PACGBWIPIDX
  END
  IF (@I_vNONINVEN = 1)
    AND (@PROJECTLOADED = 1)
  BEGIN
    IF (@I_vProjNum <> ‘‘)
      AND (@I_vCostCatID <> ‘‘)
    BEGIN
      IF (@PAAcctgMethod = 1)
      BEGIN
        SELECT
          @PO_INVINDX = @PO_PACogs_Idx
      END
      ELSE
      BEGIN
        IF (@PACGBWIPIDX = 0)
        BEGIN
          SELECT
            @PO_INVINDX = @PACGBWIPIDX
        END
        ELSE
        BEGIN
          SELECT
            @PO_INVINDX = @PO_PACogs_Idx
        END
      END
    END
    ELSE
    BEGIN
      SELECT
        @PO_INVINDX = PMPRCHIX
      FROM PM00200(nolock)
      WHERE VENDORID = @I_vVENDORID
    END
  END
  IF (@PROJECTLOADED = 1)
    AND (@I_vCostCatID <> ”)
    AND (@I_vNONINVEN = 1)
  BEGIN
    SELECT
      @PADECPLQTY = DECPLQTY
    FROM PA01001(nolock)
    WHERE PACOSTCATID = @I_vCostCatID
  END
  IF (@PROJECTLOADED = 1)
    AND (@I_vNONINVEN = 0)
  BEGIN
    IF ((@PAContra_Account_IDX = 0)
      AND (@I_vPOPTYPE = 3))
    BEGIN
      SELECT
        @PAContra_Account_IDX = PMAPINDX
      FROM PM00200(nolock)
      WHERE VENDORID = @I_vVENDORID
    END
    IF ((@PAContra_Account_IDX = 0)
      AND (@I_vPOPTYPE = 3))
    BEGIN
      SELECT
        @PAContra_Account_IDX = ACTINDX
      FROM SY01100(nolock)
      WHERE SERIES = 5
      AND SEQNUMBR = 200
    END
  END
  IF (@PROJECTLOADED = 1)
  BEGIN
    SELECT
      @UOFMBASE = BASEUOFM
    FROM IV40201(nolock)
    WHERE UOMSCHDL = @UOMSCHDL
    SELECT
      @QTYBSUOM = QTYBSUOM
    FROM IV40202(nolock)
    WHERE UOMSCHDL = @UOMSCHDL
    AND EQUIVUOM = @UOFMBASE
    AND UOFM = @I_vUOFM
    SELECT
      @PABILRATE =
                  CASE
                    WHEN @PRICMTHD = 1 THEN ISNULL(UOMPRICE, 0)
                    WHEN @PRICMTHD = 2 THEN ISNULL(ROUND((@LISTPRCE * @QTYBSUOM) * (UOMPRICE / 100), @DECPLCURItem), 0)
                    WHEN @PRICMTHD = 3 THEN ISNULL(ROUND((@CURRCOST * @QTYBSUOM) * (1 + (UOMPRICE / 100)), @DECPLCURItem), 0)
                    WHEN @PRICMTHD = 4 THEN ISNULL(ROUND((@STNDCOST * @QTYBSUOM) * (1 + (UOMPRICE / 100)), @DECPLCURItem), 0)
                    WHEN @PRICMTHD = 5 THEN ISNULL(ROUND((@CURRCOST * @QTYBSUOM) / (1 – (UOMPRICE / 100)), @DECPLCURItem), 0)
                    WHEN @PRICMTHD = 6 THEN ISNULL(ROUND((@STNDCOST * @QTYBSUOM) / (1 – (UOMPRICE / 100)), @DECPLCURItem), 0)
                    ELSE 0
                  END
    FROM IV00108(nolock)
    WHERE ITEMNMBR = @I_vITEMNMBR
    AND CURNCYID = @CURNCYID
    AND PRCLEVEL = @PO_PRICELVL
    AND UOFM = @I_vUOFM
    AND QTYBSUOM = @QTYBSUOM
    AND FROMQTY <= @I_vQTYSHPPD
    AND TOQTY >= @I_vQTYSHPPD
  END
  SELECT
    @RNDGAMNT = ISNULL(RNDGAMNT, 0),
    @ROUNDHOW = ISNULL(ROUNDHOW, 0),
    @ROUNDTO = ISNULL(ROUNDTO, 0)
  FROM IV00107(nolock)
  WHERE ITEMNMBR = @I_vITEMNMBR
  AND CURNCYID = @CURNCYID
  AND PRCLEVEL = @PO_PRICELVL
  AND UOFM = @I_vUOFM
  AND QTYBSUOM = @QTYBSUOM
  IF (@ROUNDTO > 1
    AND @ROUNDTO < 5)
  BEGIN
    EXEC @iStatus = taPricingGetRoundPrice @ROUNDTO,
                                           @ROUNDHOW,
                                           @RNDGAMNT,
                                           @PABILRATE OUTPUT
    SELECT
      @iError = @@error
    IF (@iError <> 0)
      OR (@iStatus <> 0)
    BEGIN
      IF (@iStatus <> 0)
      BEGIN
        SELECT
          @oErrString = RTRIM(@oErrString) + ‘ ‘ + @iStatus
      END
      SELECT
        @O_iErrorState = 8182
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
  END
  IF (@I_vRequesterTrx = 0)
  BEGIN
    EXEC @iStatus = eConnectOutVerify @I_vDOCTYPE = ‘PO_Receiving_Transaction’,
                                      @I_vINDEX1 = @I_vPOPRCTNM,
                                      @I_vINDEX2 = ”,
                                      @I_vINDEX3 = ”,
                                      @I_vINDEX4 = ”,
                                      @I_vINDEX5 = ”,
                                      @I_vINDEX6 = ”,
                                      @I_vINDEX7 = ”,
                                      @I_vINDEX8 = ”,
                                      @I_vINDEX9 = ”,
                                      @I_vINDEX10 = ”,
                                      @I_vINDEX11 = ”,
                                      @I_vINDEX12 = ”,
                                      @I_vINDEX13 = ”,
                                      @I_vINDEX14 = ”,
                                      @I_vINDEX15 = ”,
                                      @I_vDelete = 0,
                                      @O_iErrorState = @iCustomState OUTPUT
    SELECT
      @iError = @@error
    IF ((@iStatus = 0)
      AND (@iError <> 0))
    BEGIN
      SELECT
        @iStatus = @iError
    END
    IF ((@iStatus <> 0)
      OR (@iCustomState <> 0))
    BEGIN
      SELECT
        @O_iErrorState = 1289
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
    END
  END
  SELECT
    @MAXSEG = MAX(SGMTNUMB)
  FROM SY00300(nolock)
  SELECT
    @Location_Segment = ISNULL(Location_Segment, ”)
  FROM IV40700(nolock)
  WHERE LOCNCODE = @I_vLOCNCODE
  SELECT
    @ACSGFLOC = ACSGFLOC,
    @ENABLEMULTIBIN = ENABLEMULTIBIN
  FROM IV40100(nolock)
  WHERE SETUPKEY = 1
  IF ((@I_vINVINDX <> 0)
    AND (@Location_Segment <> ”)
    AND (@ACSGFLOC <> 0)
    AND (@TOOKACCTOFFPOORPASSED = 0))
  BEGIN
    SELECT
      @ACCNT_STRING = ”
    SELECT
      @ACCNT_STRING = ACTNUMST
    FROM GL00105(nolock)
    WHERE ACTINDX = @I_vINVINDX
    IF (@ACSGFLOC < @MAXSEG)
    BEGIN
      SELECT
        @LOFSGMNT = SUM(LOFSGMNT) + (@MAXSEG – @ACSGFLOC)
      FROM SY00300(nolock)
      WHERE SGMTNUMB >= @ACSGFLOC
      SELECT
        @LOFSGMNTEND = SUM(LOFSGMNT) + (@MAXSEG – @ACSGFLOC)
      FROM SY00300(nolock)
      WHERE SGMTNUMB > @ACSGFLOC
    END
    ELSE
    BEGIN
      SELECT
        @LOFSGMNT = SUM(LOFSGMNT)
      FROM SY00300(nolock)
      WHERE SGMTNUMB = @ACSGFLOC
    END
    SELECT
      @LOFSGMNTALL = SUM(LOFSGMNT) + (@MAXSEG – 1)
    FROM SY00300(nolock)
    IF (@ACSGFLOC = @MAXSEG)
    BEGIN
      SELECT
        @NEW_ACCNT_STRING = SUBSTRING(@ACCNT_STRING, 1, @LOFSGMNTALL – @LOFSGMNT) + RTRIM(LTRIM(@Location_Segment))
    END
    ELSE
    BEGIN
      SELECT
        @NEW_ACCNT_STRING = SUBSTRING(@ACCNT_STRING, 1, @LOFSGMNTALL – @LOFSGMNT) + RTRIM(LTRIM(@Location_Segment)) + SUBSTRING(@ACCNT_STRING, @LOFSGMNTALL – @LOFSGMNTEND + 1, @LOFSGMNTALL)
    END
    SELECT
      @ACTINDX = ISNULL(ACTINDX, 0)
    FROM GL00105(nolock)
    WHERE ACTNUMST = @NEW_ACCNT_STRING
    IF (@ACTINDX <> 0)
    BEGIN
      SELECT
        @ACTIVE = ACTIVE
      FROM GL00100(nolock)
      WHERE ACTINDX = @ACTINDX
    END
    IF (@ACTINDX <> 0)
      AND (@ACTIVE = 1)
    BEGIN
      SELECT
        @I_vINVINDX = @ACTINDX
    END
  END
  IF ((@PURPVIDX <> 0)
    AND (@Location_Segment <> ”)
    AND (@ACSGFLOC <> 0)
    AND (@TOOKACCTOFFPOORPASSED = 1)
    AND (@NOACCTONITEM = 0))
  BEGIN
    SELECT
      @ACCNT_STRING = ”
    SELECT
      @ACTINDX = 0
    SELECT
      @ACCNT_STRING = ACTNUMST
    FROM GL00105(nolock)
    WHERE ACTINDX = @PURPVIDX
    IF (@ACSGFLOC < @MAXSEG)
    BEGIN
      SELECT
        @LOFSGMNT = SUM(LOFSGMNT) + (@MAXSEG – @ACSGFLOC)
      FROM SY00300(nolock)
      WHERE SGMTNUMB >= @ACSGFLOC
      SELECT
        @LOFSGMNTEND = SUM(LOFSGMNT) + (@MAXSEG – @ACSGFLOC)
      FROM SY00300(nolock)
      WHERE SGMTNUMB > @ACSGFLOC
    END
    ELSE
    BEGIN
      SELECT
        @LOFSGMNT = SUM(LOFSGMNT)
      FROM SY00300(nolock)
      WHERE SGMTNUMB = @ACSGFLOC
    END
    SELECT
      @LOFSGMNTALL = SUM(LOFSGMNT) + (@MAXSEG – 1)
    FROM SY00300(nolock)
    IF (@ACSGFLOC = @MAXSEG)
    BEGIN
      SELECT
        @NEW_ACCNT_STRING = SUBSTRING(@ACCNT_STRING, 1, @LOFSGMNTALL – @LOFSGMNT) + RTRIM(LTRIM(@Location_Segment))
    END
    ELSE
    BEGIN
      SELECT
        @NEW_ACCNT_STRING = SUBSTRING(@ACCNT_STRING, 1, @LOFSGMNTALL – @LOFSGMNT) + RTRIM(LTRIM(@Location_Segment)) + SUBSTRING(@ACCNT_STRING, @LOFSGMNTALL – @LOFSGMNTEND + 1, @LOFSGMNTALL)
    END
    SELECT
      @ACTINDX = ISNULL(ACTINDX, 0)
    FROM GL00105(nolock)
    WHERE ACTNUMST = @NEW_ACCNT_STRING
    IF (@ACTINDX <> 0)
    BEGIN
      SELECT
        @PURPVIDX = @ACTINDX
    END
  END
  IF ((@UPPVIDX <> 0)
    AND (@Location_Segment <> ”)
    AND (@ACSGFLOC <> 0)
    AND (@TOOKACCTOFFPOORPASSED = 1)
    AND (@NOACCTONITEM = 0))
  BEGIN
    SELECT
      @ACCNT_STRING = ”
    SELECT
      @ACTINDX = 0
    SELECT
      @ACCNT_STRING = ACTNUMST
    FROM GL00105(nolock)
    WHERE ACTINDX = @UPPVIDX
    IF (@ACSGFLOC < @MAXSEG)
    BEGIN
      SELECT
        @LOFSGMNT = SUM(LOFSGMNT) + (@MAXSEG – @ACSGFLOC)
      FROM SY00300(nolock)
      WHERE SGMTNUMB >= @ACSGFLOC
      SELECT
        @LOFSGMNTEND = SUM(LOFSGMNT) + (@MAXSEG – @ACSGFLOC)
      FROM SY00300(nolock)
      WHERE SGMTNUMB > @ACSGFLOC
    END
    ELSE
    BEGIN
      SELECT
        @LOFSGMNT = SUM(LOFSGMNT)
      FROM SY00300(nolock)
      WHERE SGMTNUMB = @ACSGFLOC
    END
    SELECT
      @LOFSGMNTALL = SUM(LOFSGMNT) + (@MAXSEG – 1)
    FROM SY00300(nolock)
    IF (@ACSGFLOC = @MAXSEG)
    BEGIN
      SELECT
        @NEW_ACCNT_STRING = SUBSTRING(@ACCNT_STRING, 1, @LOFSGMNTALL – @LOFSGMNT) + RTRIM(LTRIM(@Location_Segment))
    END
    ELSE
    BEGIN
      SELECT
        @NEW_ACCNT_STRING = SUBSTRING(@ACCNT_STRING, 1, @LOFSGMNTALL – @LOFSGMNT) + RTRIM(LTRIM(@Location_Segment)) + SUBSTRING(@ACCNT_STRING, @LOFSGMNTALL – @LOFSGMNTEND + 1, @LOFSGMNTALL)
    END
    SELECT
      @ACTINDX = ISNULL(ACTINDX, 0)
    FROM GL00105(nolock)
    WHERE ACTNUMST = @NEW_ACCNT_STRING
    IF (@ACTINDX <> 0)
    BEGIN
      SELECT
        @UPPVIDX = @ACTINDX
    END
  END
  SELECT
    @RcptLineNoteIDArray_1 = NOTEINDX
  FROM IV00101(nolock)
  WHERE ITEMNMBR = @I_vITEMNMBR
  SELECT
    @RcptLineNoteIDArray_2 = NOTEINDX
  FROM IV40700(nolock)
  WHERE LOCNCODE = @I_vLOCNCODE
  SELECT
    @RcptLineNoteIDArray_3 = ISNULL(NOTEINDX, 0)
  FROM GL00100(nolock)
  WHERE ACTINDX = @I_vINVINDX
  SELECT
    @RcptLineNoteIDArray_4 = 0
  SELECT
    @RcptLineNoteIDArray_5 = 0
  SELECT
    @RcptLineNoteIDArray_6 = NOTEINDX
  FROM TX00101(nolock)
  WHERE TAXSCHID = @I_vPurchase_Item_Tax_Schedu
  SELECT
    @RcptLineNoteIDArray_7 = NOTEINDX
  FROM TX00101(nolock)
  WHERE TAXSCHID = @I_vPurchase_Site_Tax_Schedu
  SELECT
    @RcptLineNoteIDArray_8 = NOTEINDX
  FROM IV41101(nolock)
  WHERE Landed_Cost_Group_ID = @I_vLanded_Cost_Group_ID
  IF (@O_iErrorState <> 0)
  BEGIN
    RETURN (@O_iErrorState)
  END
  WHILE (1 = 1)
  BEGIN
    IF (@I_vPONUMBER <> ”)
    BEGIN
      UPDATE POP10100
      SET REMSUBTO = ROUND(OREMSUBT – ROUND((@ORUNTCST * @I_vQTYINVCD), @EDITDECPLCUR), @EDITDECPLCUR),
          OREMSUBT = ROUND(OREMSUBT – ROUND((@ORUNTCST * @I_vQTYINVCD), @EDITDECPLCUR), @EDITDECPLCUR)
      WHERE PONUMBER = @I_vPONUMBER
      IF (@@error <> 0)
      BEGIN
        SELECT
          @O_iErrorState = 9379
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
        RETURN (@O_iErrorState)
      END
    END
    INSERT POP10310 (POPRCTNM, RCPTLNNM, PONUMBER, ITEMNMBR, ITEMDESC, VNDITNUM, VNDITDSC, UMQTYINB, ACTLSHIP, COMMNTID, INVINDX, UOFM, UNITCOST, EXTDCOST, LOCNCODE, RcptLineNoteIDArray_1, RcptLineNoteIDArray_2, RcptLineNoteIDArray_3, RcptLineNoteIDArray_4, RcptLineNoteIDArray_5, RcptLineNoteIDArray_6, RcptLineNoteIDArray_7, RcptLineNoteIDArray_8, NONINVEN, DECPLCUR, DECPLQTY, ITMTRKOP, VCTNMTHD, TRXSORCE, JOBNUMBR, COSTCODE, COSTTYPE, CURNCYID, CURRNIDX, RATETPID, XCHGRATE, RATECALC, DENXRATE, ORUNTCST, OREXTCST, ODECPLCU, BOLPRONUMBER, Capital_Item, Product_Indicator, Purchase_IV_Item_Taxable, Purchase_Item_Tax_Schedu, Purchase_Site_Tax_Schedu, BSIVCTTL, TAXAMNT, ORTAXAMT, BCKTXAMT, OBTAXAMT, Revalue_Inventory, Tolerance_Percentage, PURPVIDX, Remaining_AP_Amount, SHIPMTHD, Landed_Cost_Group_ID, Landed_Cost_Warnings, BackoutTradeDiscTax, OrigBackoutTradeDiscTax, Landed_Cost, Invoice_Match, RCPTRETNUM, RCPTRETLNNUM, INVRETNUM, INVRETLNNUM, ISLINEINTRA, ProjNum, CostCatID)
      SELECT
        @I_vPOPRCTNM,
        @I_vRCPTLNNM,
        @I_vPONUMBER,
        @I_vITEMNMBR,
        @I_vITEMDESC,
        @I_vVNDITNUM,
        @I_vVNDITDSC,
        @UMQTYINB,
        @I_vACTLSHIP,
        ”,
        @I_vINVINDX,
        @I_vUOFM,
        CASE
          WHEN (@I_vAUTOCOST = 0) THEN @I_vUNITCOST
          ELSE @ORUNTCST
        END,
        CASE
          WHEN (@I_vAUTOCOST = 0 AND
            @I_vPOPTYPE = 1) OR
            (@PassedExtCost = 1) THEN @I_vEXTDCOST
          WHEN (@I_vAUTOCOST = 1 AND
            @I_vPOPTYPE = 1) THEN ROUND(@ORUNTCST * @I_vQTYSHPPD, @EDITDECPLCUR)
          WHEN (@I_vAUTOCOST = 0 AND
            @I_vPOPTYPE = 3) THEN ROUND(@I_vUNITCOST * @I_vQTYINVCD, @EDITDECPLCUR)
          WHEN (@I_vAUTOCOST = 1 AND
            @I_vPOPTYPE = 3) THEN ROUND(@ORUNTCST * @I_vQTYINVCD, @EDITDECPLCUR)
          ELSE 0
        END,
        @I_vLOCNCODE,
        @RcptLineNoteIDArray_1,
        @RcptLineNoteIDArray_2,
        @RcptLineNoteIDArray_3,
        @RcptLineNoteIDArray_4,
        @RcptLineNoteIDArray_5,
        @RcptLineNoteIDArray_6,
        @RcptLineNoteIDArray_7,
        @RcptLineNoteIDArray_8,
        @I_vNONINVEN,
        @DECPLCUR,
        CASE
          WHEN (@I_vNONINVEN = 1) AND
            (@PROJECTLOADED = 1) THEN @PADECPLQTY
          ELSE @DECPLQTY
        END,
        @ITMTRKOP,
        @VCTNMTHD,
        ”,
        @I_vJOBNUMBR,
        ”,
        0,
        CASE
          WHEN @MCINSTALLED = 1 THEN @I_vCURNCYID
          ELSE ”
        END,
        CASE
          WHEN @MCINSTALLED = 1 THEN @CURRNIDX
          ELSE 0
        END,
        ”,
        0,
        0,
        0,
        CASE
          WHEN (@I_vAUTOCOST = 0) THEN @I_vUNITCOST
          ELSE @ORUNTCST
        END,
        CASE
          WHEN (@I_vAUTOCOST = 0 AND
            @I_vPOPTYPE = 1) OR
            (@PassedExtCost = 1) THEN @I_vEXTDCOST
          WHEN (@I_vAUTOCOST = 1 AND
            @I_vPOPTYPE = 1) THEN ROUND(@ORUNTCST * @I_vQTYSHPPD, @EDITDECPLCUR)
          WHEN (@I_vAUTOCOST = 0 AND
            @I_vPOPTYPE = 3) THEN ROUND(@I_vUNITCOST * @I_vQTYINVCD, @EDITDECPLCUR)
          WHEN (@I_vAUTOCOST = 1 AND
            @I_vPOPTYPE = 3) THEN ROUND(@ORUNTCST * @I_vQTYINVCD, @EDITDECPLCUR)
          ELSE 0
        END,
        @ODECPLCU,
        @I_vBOLPRONUMBER,
        @Capital_Item,
        0,
        @I_vPurchase_IV_Item_Taxable,
        @I_vPurchase_Item_Tax_Schedu,
        @I_vPurchase_Site_Tax_Schedu,
        0,
        @I_vTAXAMNT,
        @I_vTAXAMNT,
        0,
        0,
        @Revalue_Inventory,
        @Tolerance_Percentage,
        @PURPVIDX,
        CASE
          WHEN (@I_vAUTOCOST = 0) THEN @I_vEXTDCOST
          WHEN (@I_vAUTOCOST = 1 AND
            @I_vPOPTYPE = 1) THEN ROUND(@ORUNTCST * @I_vQTYSHPPD, @EDITDECPLCUR)
          WHEN (@I_vAUTOCOST = 1 AND
            @I_vPOPTYPE = 3) THEN ROUND(@ORUNTCST * @I_vQTYINVCD, @EDITDECPLCUR)
          ELSE 0
        END,
        @SHIPMTHD,
        @I_vLanded_Cost_Group_ID,
        0,
        0,
        0,
        0,
        0,
        ”,
        0,
        ”,
        0,
        0,
        @I_vProjNum,
        @I_vCostCatID
    IF (@@error <> 0)
    BEGIN
      SELECT
        @O_iErrorState = 2075
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
      BREAK
    END
    INSERT POP10500 (PONUMBER, POLNENUM, POPRCTNM, RCPTLNNM, QTYSHPPD, QTYINVCD, QTYREJ, QTYMATCH, QTYRESERVED, QTYINVRESERVE, Status, UMQTYINB, OLDCUCST, JOBNUMBR, COSTCODE, COSTTYPE, ORCPTCOST, OSTDCOST, APPYTYPE, POPTYPE, VENDORID, ITEMNMBR, UOFM, TRXLOCTN, DATERECD, RCTSEQNM, SPRCTSEQ, PCHRPTCT, SPRCPTCT, OREXTCST, RUPPVAMT, ACPURIDX, INVINDX, UPPVIDX, NOTEINDX, CURNCYID, CURRNIDX, XCHGRATE, RATECALC, DENXRATE, RATETPID, EXGTBLID, Capital_Item, Product_Indicator, Total_Landed_Cost_Amount, QTYTYPE, Posted_LC_PPV_Amount, QTYREPLACED, QTYINVADJ)
      SELECT
        @I_vPONUMBER,
        CASE
          WHEN (@I_vPONUMBER = ”) THEN 0
          ELSE @I_vPOLNENUM
        END,
        @I_vPOPRCTNM,
        @I_vRCPTLNNM,
        @I_vQTYSHPPD,
        @I_vQTYINVCD,
        0,
        0,
        0,
        0,
        0,
        @UMQTYINB,
        @OLDCUCST,
        @JOBNUMBR,
        ”,
        0,
        CASE
          WHEN (@I_vAUTOCOST = 0) THEN @I_vUNITCOST
          ELSE @ORUNTCST
        END,
        @STNDCOST,
        1,
        @I_vPOPTYPE,
        @I_vVENDORID,
        @I_vITEMNMBR,
        @UOFM,
        @I_vLOCNCODE,
        ”,
        0,
        0,
        0,
        0,
        CASE
          WHEN (@I_vAUTOCOST = 0) THEN ROUND(@I_vUNITCOST * (@I_vQTYSHPPD – @I_vQTYINVCD), @EDITDECPLCUR)
          WHEN (@I_vAUTOCOST = 1) THEN ROUND(@ORUNTCST * (@I_vQTYSHPPD – @I_vQTYINVCD), @EDITDECPLCUR)
          ELSE 0
        END,
        @RUPPVAMT,
        @ACPURIDX,
        @I_vINVINDX,
        @UPPVIDX,
        0,
        CASE
          WHEN @MCINSTALLED = 1 THEN @I_vCURNCYID
          ELSE ”
        END,
        CASE
          WHEN @MCINSTALLED = 1 THEN @CURRNIDX
          ELSE 0
        END,
        0,
        0,
        0,
        ”,
        ”,
        @Capital_Item,
        0,
        0,
        1,
        0,
        0,
        0
    IF (@@error <> 0)
    BEGIN
      SELECT
        @O_iErrorState = 2076
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
      BREAK
    END
    IF (@I_vProjNum <> ”)
    BEGIN
      INSERT PA10702 (PAVIDN, RCPTLNNM, PApurordnum, ITEMNMBR, CURRNIDX, DATEVAL, DENXRATE, EXCHDATE, XCHGRATE, EXGTBLID, ITMTSHID, MCTRXSTT, ORD, ORTDISAM, PAAcctgMethod, PAACREV, PA_Base_Billing_Rate, PABaseOvhdCost, PABase_Qty, PABase_Unit_Cost, PAbillnoteidx, PABILRATE, PABilling_StatusN, PAbllngtype, PACBADDFRMFLY, PACHGORDNO, PACogs_Idx, PAContra_Account_IDX, PACONTNUMBER, PACOSTCATID, PACOSTCATNME, PAIV_Item_Checkbox, PALineItemSeq, PAMARKPERCENT, PA_MC_Accrued_Revenue, PA_MC_Base_Billing_Rate, PA_MC_Billing_Rate, PAMCCURNCYID, PA_MC_VarianceAccruedRev, PAORIACCRREV, PAORIGBASEOVRHCST, PAORIGBILLRATE, PAORIGOVHDAMT, PAORIGPROFAMT, PAOrigSEC, PAORIGTOTOVRHD, PAORIGTOTPROF, PAOrigVarExt, PAOverhead_Amount, PAOverhead_IDX, PAOverheaPercentage, PAPO_Line_Errors, PAProfitAmount, PAProfitPercent, PAProfitType, PAPROJNUMBER, PAProjectType, PAPurchase_Tax_Options, PAShipmentExtCost, PATOTALOVERH, PATotalProfit, PATU, PAUnbilled_AR_Idx, PAUnbilled_Proj_Rev_Idx, PAUD1, PAUD2, PA_Variance_Cost, PA_Variance_Accrued_Reve, PA_Variance_QTY_Accrued_, PACGBWIPIDX, POTYPE, POPTYPE, PRICELVL, RATECALC, RATETPID, receiptdate, TIME1, TRDISAMT, UOMSCHDL, VENDORID)
        SELECT
          @I_vPOPRCTNM,
          @I_vRCPTLNNM,
          @I_vPONUMBER,
          @I_vITEMNMBR,
          @PO_CURRNIDX,
          CASE
            WHEN @I_vreceiptdate = ” THEN CONVERT(varchar(12), GETDATE())
            ELSE @I_vreceiptdate
          END,
          0,
          ”,
          0,
          ”,
          CASE
            WHEN @PAPurchase_Tax_Options <> 1 THEN ”
            ELSE @PO_ITMTSHID
          END,
          0,
          @I_vPOLNENUM,
          @PO_TRDISAMT,
          @PAAcctgMethod,
          @PAACREV,
          @PA_Base_Billing_Rate,
          @PABaseOvhdCost,
          @I_vQTYSHPPD,
          CASE
            WHEN (@I_vAUTOCOST = 0) THEN @I_vUNITCOST
            ELSE @ORUNTCST
          END,
          @NOTEINDX,
          @PABILRATE,
          CASE
            WHEN @PAbllngtype = 3 THEN 4
            ELSE @PABilling_StatusN
          END,
          @PAbllngtype,
          0,
          @PO_PACHGORDNO,
          CASE
            WHEN @I_vNONINVEN = 1 THEN @PO_PACogs_Idx
            ELSE @PACogs_Idx
          END,
          @PAContra_Account_IDX,
          @PACONTNUMBER,
          @I_vCostCatID,
          @PACOSTCATNME,
          @PO_PAIV_Item_Checkbox,
          @PO_PALineItemSeq,
          @PAMARKPERCENT,
          @PA_MC_Accrued_Revenue,
          @PA_MC_Base_Billing_Rate,
          @PA_MC_Billing_Rate,
          @PO_CURNCYID,
          @PA_MC_VarianceAccruedRev,
          @PAACREV,
          @PABaseOvhdCost,
          @PABILRATE,
          @PAOverhead_Amount,
          @PAProfitAmount,
          CASE
            WHEN (@I_vAUTOCOST = 0) THEN ROUND(@I_vUNITCOST * @I_vQTYSHPPD, @EDITDECPLCUR)
            WHEN (@I_vAUTOCOST = 1) THEN ROUND(@ORUNTCST * @I_vQTYSHPPD, @EDITDECPLCUR)
            ELSE 0
          END,
          @PATOTALOVERH,
          @PATotalProfit,
          @PA_Variance_Accrued_Reve,
          @PAOverhead_Amount,
          @PAOverhead_IDX,
          @PAOverheaPercentage,
          0,
          @PAProfitAmount,
          @PAProfitPercent,
          @PAProfitType,
          @I_vProjNum,
          @PAProjectType,
          @PAPurchase_Tax_Options,
          CASE
            WHEN (@I_vAUTOCOST = 0) THEN ROUND(@I_vUNITCOST * @I_vQTYSHPPD, @EDITDECPLCUR)
            WHEN (@I_vAUTOCOST = 1) THEN ROUND(@ORUNTCST * @I_vQTYSHPPD, @EDITDECPLCUR)
            ELSE 0
          END,
          @PATOTALOVERH,
          @PATotalProfit,
          @PO_PATU,
          @PAUnbilled_AR_Idx,
          @PAUnbilled_Proj_Rev_Idx,
          ”,
          ”,
          @PA_Variance_Cost,
          @PA_Variance_Accrued_Reve,
          @PA_Variance_QTY_Accrued_,
          @PO_PACGBWIPIDX,
          @POTYPE,
          @I_vPOPTYPE,
          @PO_PRICELVL,
          0,
          ”,
          CASE
            WHEN @I_vreceiptdate = ” THEN CONVERT(varchar(12), GETDATE())
            ELSE @I_vreceiptdate
          END,
          ”,
          @PO_TRDISAMT,
          @PO_UOMSCHDL,
          @I_vVENDORID
      IF @@error <> 0
      BEGIN
        SELECT
          @O_iErrorState = 8175
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
        BREAK
      END
      INSERT PA10721 (PApurordnum, POLNENUM, PAVIDN, RCPTLNNM, VENDORID, Status, ITEMNMBR, UOFM, APPYTYPE, EXTDCOST, ORUNTCST, PACOSTCATID, PAPROJNUMBER, RCPTCOST, UNITCOST)
        SELECT
          @I_vPONUMBER,
          CASE
            WHEN (@I_vPONUMBER = ”) THEN 0
            ELSE @I_vPOLNENUM
          END,
          @I_vPOPRCTNM,
          @I_vRCPTLNNM,
          @I_vVENDORID,
          @Status,
          @I_vITEMNMBR,
          @I_vUOFM,
          1,
          CASE
            WHEN (@I_vAUTOCOST = 0) THEN @I_vEXTDCOST
            WHEN (@I_vAUTOCOST = 1 AND
              @I_vPOPTYPE = 1) THEN ROUND(@ORUNTCST * @I_vQTYSHPPD, @EDITDECPLCUR)
            WHEN (@I_vAUTOCOST = 1 AND
              @I_vPOPTYPE = 3) THEN ROUND(@ORUNTCST * @I_vQTYINVCD, @EDITDECPLCUR)
            ELSE 0
          END,
          CASE
            WHEN (@I_vAUTOCOST = 0) THEN @I_vUNITCOST
            ELSE @ORUNTCST
          END,
          @I_vCostCatID,
          @I_vProjNum,
          0,
          CASE
            WHEN (@I_vAUTOCOST = 0) THEN @I_vUNITCOST
            ELSE @ORUNTCST
          END
      IF @@error <> 0
      BEGIN
        SELECT
          @O_iErrorState = 8176
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
        BREAK
      END
    END
    IF (@I_vProjNum <> ”)
      AND (@I_vCostCatID <> ”)
      AND (@I_vNONINVEN = 1)
    BEGIN
      UPDATE PA01301
      SET PAUnpostedQty = PAUnpostedQty + @I_vQTYSHPPD,
          PAUnpostedTotalCostN = PAUnpostedTotalCostN + ROUND(@I_vUNITCOST * @I_vQTYSHPPD, @EDITDECPLCUR),
          PAUnpostAccrRevN = PAUnpostAccrRevN + @PAACREV
      WHERE PAPROJNUMBER = @I_vProjNum
      AND PACOSTCATID = @I_vCostCatID
      AND PATU = @PO_PATU
      IF @@error <> 0
      BEGIN
        SELECT
          @O_iErrorState = 10408
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
        BREAK
      END
      UPDATE PA01201
      SET PAUnpostedQty = PAUnpostedQty + @I_vQTYSHPPD,
          PAUnpostedTotalCostN = PAUnpostedTotalCostN + ROUND(@I_vUNITCOST * @I_vQTYSHPPD, @EDITDECPLCUR),
          PAUnpostAccrRevN = PAUnpostAccrRevN + @PAACREV
      WHERE PAPROJNUMBER = @I_vProjNum
      IF @@error <> 0
      BEGIN
        SELECT
          @O_iErrorState = 10417
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
        BREAK
      END
      UPDATE PA01101
      SET PAUnpostedQty = PAUnpostedQty + @I_vQTYSHPPD,
          PAUnpostedTotalCostN = PAUnpostedTotalCostN + ROUND(@I_vUNITCOST * @I_vQTYSHPPD, @EDITDECPLCUR),
          PAUnpostAccrRevN = PAUnpostAccrRevN + @PAACREV
      WHERE PACONTNUMBER = @PACONTNUMBER
      IF @@error <> 0
      BEGIN
        SELECT
          @O_iErrorState = 10418
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
        BREAK
      END
      UPDATE PA00501
      SET PAUnpostedQty = PAUnpostedQty + @I_vQTYSHPPD,
          PAUnpostedTotalCostN = PAUnpostedTotalCostN + ROUND(@I_vUNITCOST * @I_vQTYSHPPD, @EDITDECPLCUR)
      WHERE CUSTNMBR = @CUSTNMBR
      IF @@error <> 0
      BEGIN
        SELECT
          @O_iErrorState = 10419
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
        BREAK
      END
    END
    IF ((@ENABLEMULTIBIN = 1)
      AND (@ITMTRKOP = 1)
      AND (@I_vAutoAssignBin = 1)
      AND (@I_vNONINVEN = 0))
    BEGIN
      IF EXISTS (SELECT
          1
        FROM POP10340(nolock)
        WHERE POPRCTNM = @I_vPOPRCTNM
        AND ITEMNMBR = @I_vITEMNMBR
        AND RCPTLNNM = @I_vRCPTLNNM)
      BEGIN
        SELECT
          @O_iErrorState = 9335
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
      END
      IF (@I_vQTYSHPPD > 0)
      BEGIN
        EXEC @iStatus = taPopRcptMultiBin @I_vPOPRCTNM = @I_vPOPRCTNM,
                                          @I_vRCPTLNNM = @I_vRCPTLNNM,
                                          @I_vITEMNMBR = @I_vITEMNMBR,
                                          @I_vBIN = ”,
                                          @I_vQUANTITY = @I_vQTYSHPPD,
                                          @I_vUOFM = @I_vUOFM,
                                          @I_vCreateBin = 0,
                                          @I_vRequesterTrx = 1,
                                          @O_iErrorState = @iCustomState OUTPUT,
                                          @oErrString = @iCustomErrString OUTPUT
        SELECT
          @iError = @@error
        IF ((@iStatus <> 0)
          OR (@iCustomState <> 0)
          OR (@iError <> 0))
        BEGIN
          SELECT
            @oErrString = RTRIM(@oErrString) + ‘ ‘ + @iCustomErrString
          SELECT
            @O_iErrorState = 9336
          EXEC @iStatus = taUpdateString @O_iErrorState,
                                         @oErrString,
                                         @oErrString OUTPUT,
                                         @O_oErrorState OUTPUT
        END
      END
    END
    IF (@ITMTRKOP IN (2, 3))
    BEGIN
      SELECT
        @SERLTQTY = ISNULL(SUM(SERLTQTY), 0)
      FROM POP10330(nolock)
      WHERE POPRCTNM = @I_vPOPRCTNM
      AND RCPTLNNM = @I_vRCPTLNNM
      IF (ROUND((@I_vQTYSHPPD * @UMQTYINB), (@DECPLQTY – 1)) <> @SERLTQTY)
      BEGIN
        SELECT
          @O_iErrorState = 3389
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
        BREAK
      END
    END
    SELECT
      @I_vEXTDCOST =
                    CASE
                      WHEN (@I_vAUTOCOST = 0 AND
                        @I_vPOPTYPE = 1) THEN @I_vEXTDCOST
                      WHEN (@I_vAUTOCOST = 1 AND
                        @I_vPOPTYPE = 1) THEN ROUND(@ORUNTCST * @I_vQTYSHPPD, @EDITDECPLCUR)
                      WHEN (@I_vAUTOCOST = 0 AND
                        @I_vPOPTYPE = 3) THEN ROUND(@I_vUNITCOST * @I_vQTYINVCD, @EDITDECPLCUR)
                      WHEN (@I_vAUTOCOST = 1 AND
                        @I_vPOPTYPE = 3) THEN ROUND(@ORUNTCST * @I_vQTYINVCD, @EDITDECPLCUR)
                      ELSE 0
                    END
    IF (@I_vLanded_Cost_Group_ID <> ”)
    BEGIN
      IF (@I_vreceiptdate = ”)
      BEGIN
        SELECT
          @O_iErrorState = 9339
        EXEC @iStatus = taUpdateString @O_iErrorState,
                                       @oErrString,
                                       @oErrString OUTPUT,
                                       @O_oErrorState OUTPUT
        BREAK
      END
      DECLARE LCIDS INSENSITIVE CURSOR FOR
      SELECT
        Landed_Cost_ID
      FROM IV41102(nolock)
      WHERE Landed_Cost_Group_ID = @I_vLanded_Cost_Group_ID
      ORDER BY Landed_Cost_ID
      SET NOCOUNT ON
      OPEN LCIDS
      SELECT
        @iCursorError = @@cursor_rows
      IF @iCursorError = 0
      BEGIN
        DEALLOCATE LCIDS
      END
      ELSE
      BEGIN
        FETCH NEXT FROM LCIDS INTO @Landed_Cost_ID
        WHILE (@@FETCH_STATUS <> -1)
        BEGIN
          IF (@@fetch_status = -2)
          BEGIN
            SELECT
              @O_iErrorState = 9235
            EXEC @iStatus = taUpdateString @O_iErrorState,
                                           @oErrString,
                                           @oErrString OUTPUT,
                                           @O_oErrorState OUTPUT
            BREAK
          END
          SELECT
            @LCCOST =
                     CASE
                       WHEN (@I_vAUTOCOST = 0) THEN ROUND(@I_vUNITCOST * @I_vQTYSHPPD, @EDITDECPLCUR)
                       WHEN (@I_vAUTOCOST = 1) THEN ROUND(@ORUNTCST * @I_vQTYSHPPD, @EDITDECPLCUR)
                       ELSE 0
                     END
          SELECT
            @LCLINENUMBER = @LCLINENUMBER + 16384
          EXEC @iStatus = taPopRcptLandedCost @I_vPOPRCTNM = @I_vPOPRCTNM,
                                              @I_vLanded_Cost_ID = @Landed_Cost_ID,
                                              @I_vRCPTLNNM = @I_vRCPTLNNM,
                                              @I_vLCLINENUMBER = @LCLINENUMBER,
                                              @I_vQTYSHPPD = @I_vQTYSHPPD,
                                              @I_vEXTDCOST = @LCCOST,
                                              @I_vreceiptdate = @I_vreceiptdate,
                                              @I_vRequesterTrx = 1,
                                              @O_iErrorState = @LandedCostErrState OUTPUT,
                                              @oErrString = @LandedCostErrString OUTPUT
          SELECT
            @iError = @@error
          IF ((@iStatus <> 0)
            OR (@LandedCostErrState <> 0)
            OR (@iError <> 0))
          BEGIN
            SELECT
              @oErrString = RTRIM(@oErrString) + ‘ ‘ + @LandedCostErrString
            SELECT
              @O_iErrorState = 8050
            EXEC @iStatus = taUpdateString @O_iErrorState,
                                           @oErrString,
                                           @oErrString OUTPUT,
                                           @O_oErrorState OUTPUT
            BREAK
          END
          FETCH NEXT FROM LCIDS INTO @Landed_Cost_ID
        END
        DEALLOCATE LCIDS
      END
    END
    IF (@I_vPONUMBER <> ”)
    BEGIN
      IF (@I_vCMMTTEXT <> ”)
      BEGIN
        IF (EXISTS (SELECT
            NOTEINDX
          FROM SY03900(nolock)
          WHERE NOTEINDX = @POLNEARY_3)
          )
        BEGIN
          UPDATE SY03900
          SET TXTFIELD = @I_vCMMTTEXT,
              DATE1 = CONVERT(varchar(12), GETDATE()),
              TIME1 = SUBSTRING(CONVERT(varchar(25), GETDATE()), 12, 12)
          WHERE NOTEINDX = @POLNEARY_3
          IF (@@error <> 0)
          BEGIN
            SELECT
              @O_iErrorState = 8272
            EXEC @iStatus = taUpdateString @O_iErrorState,
                                           @oErrString,
                                           @oErrString OUTPUT,
                                           @O_oErrorState OUTPUT
            BREAK
          END
        END
        ELSE
        BEGIN
          INSERT SY03900 (NOTEINDX, DATE1, TIME1, TXTFIELD)
            SELECT
              @POLNEARY_3,
              CONVERT(varchar(12), GETDATE()),
              SUBSTRING(CONVERT(varchar(25), GETDATE()), 12, 12),
              @I_vCMMTTEXT
          IF (@@error <> 0)
          BEGIN
            SELECT
              @O_iErrorState = 8271
            EXEC @iStatus = taUpdateString @O_iErrorState,
                                           @oErrString,
                                           @oErrString OUTPUT,
                                           @O_oErrorState OUTPUT
            BREAK
          END
        END
      END
      ELSE
      BEGIN
        IF (@I_vCMMTTEXT = ”)
        BEGIN
          DELETE SY03900
          WHERE NOTEINDX = @POLNEARY_3
          IF (@@error <> 0)
          BEGIN
            SELECT
              @O_iErrorState = 8273
            EXEC @iStatus = taUpdateString @O_iErrorState,
                                           @oErrString,
                                           @oErrString OUTPUT,
                                           @O_oErrorState OUTPUT
            BREAK
          END
        END
      END
    END
    BREAK
  END
  EXEC @iStatus = taPopRcptLineInsertPost @I_vPOPTYPE,
                                          @I_vPOPRCTNM,
                                          @I_vPONUMBER,
                                          @I_vITEMNMBR,
                                          @I_vITEMDESC,
                                          @I_vVENDORID,
                                          @I_vRCPTLNNM,
                                          @I_vVNDITNUM,
                                          @I_vVNDITDSC,
                                          @I_vACTLSHIP,
                                          @I_vINVINDX,
                                          @I_vInventoryAccount,
                                          @I_vUOFM,
                                          @I_vUNITCOST,
                                          @I_vEXTDCOST,
                                          @I_vNONINVEN,
                                          @I_vJOBNUMBR,
                                          @I_vBOLPRONUMBER,
                                          @I_vQTYSHPPD,
                                          @I_vQTYINVCD,
                                          @I_vAUTOCOST,
                                          @I_vPurchase_IV_Item_Taxable,
                                          @I_vPurchase_Item_Tax_Schedu,
                                          @I_vPurchase_Site_Tax_Schedu,
                                          @I_vTAXAMNT,
                                          @I_vLanded_Cost_Group_ID,
                                          @I_vLOCNCODE,
                                          @I_vPOLNENUM,
                                          @I_vreceiptdate,
                                          @I_vCURNCYID,
                                          @I_vProjNum,
                                          @I_vCostCatID,
                                          @I_vAutoAssignBin,
                                          @I_vCMMTTEXT,
                                          @I_vRequesterTrx,
                                          @I_vUSRDEFND1,
                                          @I_vUSRDEFND2,
                                          @I_vUSRDEFND3,
                                          @I_vUSRDEFND4,
                                          @I_vUSRDEFND5,
                                          @O_iErrorState = @iCustomState OUTPUT,
                                          @oErrString = @iCustomErrString OUTPUT
  SELECT
    @iError = @@error
  IF ((@iStatus = 0)
    AND (@iError <> 0))
  BEGIN
    SELECT
      @iStatus = @iError
  END
  IF ((@iStatus <> 0)
    OR (@iCustomState <> 0))
  BEGIN
    SELECT
      @oErrString = RTRIM(@oErrString) + ‘ ‘ + LTRIM(RTRIM(@iCustomErrString))
    SELECT
      @O_iErrorState = 150
    EXEC @iStatus = taUpdateString @O_iErrorState,
                                   @oErrString,
                                   @oErrString OUTPUT,
                                   @O_oErrorState OUTPUT
  END
  IF (@I_vRequesterTrx = 0)
  BEGIN
    EXEC @iStatus = eConnectOutVerify @I_vDOCTYPE = ‘PO_Receiving_Transaction’,
                                      @I_vINDEX1 = @I_vPOPRCTNM,
                                      @I_vINDEX2 = ”,
                                      @I_vINDEX3 = ”,
                                      @I_vINDEX4 = ”,
                                      @I_vINDEX5 = ”,
                                      @I_vINDEX6 = ”,
                                      @I_vINDEX7 = ”,
                                      @I_vINDEX8 = ”,
                                      @I_vINDEX9 = ”,
                                      @I_vINDEX10 = ”,
                                      @I_vINDEX11 = ”,
                                      @I_vINDEX12 = ”,
                                      @I_vINDEX13 = ”,
                                      @I_vINDEX14 = ”,
                                      @I_vINDEX15 = ”,
                                      @I_vDelete = 1,
                                      @O_iErrorState = @iCustomState OUTPUT
    SELECT
      @iError = @@error
    IF ((@iStatus = 0)
      AND (@iError <> 0))
    BEGIN
      SELECT
        @iStatus = @iError
    END
    IF ((@iStatus <> 0)
      OR (@iCustomState <> 0))
    BEGIN
      SELECT
        @O_iErrorState = 1290
      EXEC @iStatus = taUpdateString @O_iErrorState,
                                     @oErrString,
                                     @oErrString OUTPUT,
                                     @O_oErrorState OUTPUT
      RETURN (@O_iErrorState)
    END
  END
  RETURN (@O_iErrorState)
GO

Hope that this helps.


Regards,


Mohammad R. Daoud MVP – MCT
MCP, MCBMSP, MCTS, MCBMSS
+962 – 79 – 999 65 85
me@mohdaoud.com
http://www.di.jo

View article:
Dynamics GP 2015 eConnect error: There is an active Purchase Order Approval workflow. Use Dynamics GP to enter this data

May 20, 2015 ·  · No Comments
Tags: , , , , , , , , , ,  · Posted in: Blogs I Follow Total Views: 15

Perth, Australia GPUG Chapter Inaugural Meeting

David Meego - Click for blog homepagegpug-logo

Please join us for the first meeting of the Perth GPUG Chapter.

This is a start of a new chapter (pun intended) for the Microsoft Dynamics GP community in Perth.

When:   10th June 2015 from 5:00 pm to 7:30 pm

Where:
Microsoft Office Perth
Microsoft, Seminar Room, Level 3, ENEX 100
100 St. Georges Terrace
Perth  WA  6000

Please register using the link below:

http://www.gpug.com/widgets/generic?cobaltsrc=https://dciportal.cobaltsaas.com/Meetings/Registration/MeetingDetails.aspx?mid=49fc4432-b295-4880-bcd0-08d73b7770d1

More details will be posted on the Perth Chapter’s Collaborate forum, so please join:

http://www.gpug.com/communities/community-home/digestviewer?communitykey=4411395f-d1de-4038-b685-1b572c2c71ad&tab=digestviewer

Hope to see you there.

David

PS: Snacks and refreshments will be provided (let us know if you have any dietary requirements or allergies).

This article was originally posted on http://www.winthropdc.com/blog.

Filed under: GPUG, News, Public Service Announcement Tagged: GPUG, News

Read More:
Perth, Australia GPUG Chapter Inaugural Meeting

May 12, 2015 · WinthropDC · No Comments
Tags: , , , , , , , , ,  · Posted in: Blogs I Follow Total Views: 22

#StarWarsDay: Star Trek’s Tim Russ Explains Star Wars Day

David Meego - Click for blog homepageFollowing on from yesterday’s post, #StarWarsDay: Star Wars Day 2015, I came across this video that was too good not to share.

This is for those of you who are not “into” Star Wars. Star Trek: Voyager’s Tim Russ explains everything you wanted to know about The Star Wars and the power of The Fourth.

Tim Russ is best know for playing the Vulcan Lieutenant Commander Tuvok on the Star Trek: Voyager series and he answers all your questions in the video below:

Star Trek’s Tim Russ Explains Star Wars Day (direct link)

 

May The Fourth Be With You! …. Happy Birthday The Star Wars.

David

PS: Maybe this is part of the “Revenge of the Fifth”…. who knows….

This article was originally posted on http://www.winthropdc.com/blog.

Filed under: Fun, News Tagged: Fun, News

Read More:
#StarWarsDay: Star Trek’s Tim Russ Explains Star Wars Day

May 5, 2015 · WinthropDC · No Comments
Tags: , , , , , ,  · Posted in: Blogs I Follow Total Views: 24

#StarWarsDay: Star Wars Day 2015

David Meego - Click for blog homepageWhat did Luke Skywalker say to his friends on midnight of May the third?

“May the Fourth be with you!”

Yes, corny jokes aside, it is 04-May-2015 and the geeks and nerds of the world are uniting for Star Wars Day 2015.

This has become a day to celebrate all things Star Wars related and help hype the new movies coming and sell more Star Wars toys and paraphernalia. I am sure that makes George Lucas (and now Disney) quite happy.

StarWarsDay

Now to help you celebrate the day I wanted to combine a number of really geeky things together to amuse you.

Have you heard for Simon Jansen from New Zealand? Maybe not, but you might have come across his project. Started in July 1997 still ongoing (last updated in January 2015), he has be recreating the original Star Wars (Episode IV: A New Hope) movie using text characters. Using ASCII characters his animation, ASCIIMATION now covers about 80% of the movie. You might ask Why? According to his FAQ, “Well, it seemed like a good idea at the time.“.

Sten Spans, a Dutch Unix engineer, took Simon’s work and made it available from his Telnet server. Some people believed that this was an “Easter Egg” hidden in the command line of Windows, but it isn’t. It can be accessed from any device or operating system that has a Telnet client installed.

Note: You might need to go to Control Panel >> Programs and Features >> Turn Windows Features on and off and select the Telnet Client, then click OK to install Telnet on Windows.

Finally, there is Minecraft. Now owned by Microsoft, Minecraft is a another world wide phenomenon loved by geeks, nerds and children around the world. So, I present the following video for your pleasure:

Starwars ASCII (via Minecraft) (direct link)

 

Just in case you don’t like the silent treatment, here is a version which has had dialogue and music added:

Star Wars Asciimation With Sound (direct link)

 

For more information about Star Wars Day (and fun), check out the following sites:

Enjoy today, but be careful tomorrow as you could get caught up in the “Revenge of the Fifth”.

David

PS: Did you see the surprise in the first video at 13:59?

This article was originally posted on http://www.winthropdc.com/blog.

Filed under: Fun, News Tagged: Fun, News

Link:
#StarWarsDay: Star Wars Day 2015

May 4, 2015 · WinthropDC · No Comments
Tags: , , , , , , , , , ,  · Posted in: Blogs I Follow Total Views: 61

Friday Funny: Can you understand Strayan?

David Meego - Click for blog homepageWhile I was originally born in London, England (yep, I’m a Pom*), everyone knows that I come from Australia. My family emigrated to Perth when I was 13 and I have had the operation to naturalise me as an Australian.

Probably due to my English background and the fact that accents in Perth are not strong, I don’t have a strong Australian accent (Not like Paul Hogan’s Crocodile Dundee character – watch trailer or Steve Irwin real character – watch trailer). However, I do use some different words and sometimes use Australian slang or abbreviations.

Today, I came across some videos on YouTube by Queensland filmmaker Kieran Murray who has travelled the world and introduced the inhabitants of other nations (primarily USA) to Australian slang. The confusion he creates is very funny.

G’Day Mate! How You Going? (direct link)

 

G’day Mate: The Sequel (direct link)

 

Aussie Slang (direct link)

 

There are a number of sites online where you can look up Australian slang (sometimes called the Strine* vernacular):

 

So a challenge for you ….

What does the following sentence from the end of one of the videos above mean?

“This arvo I’m gonna go down to the servo get a packet of durries and maybe some grog.”

Post your answers in the comments.

David

* Pom = Actually POHM which stands for Prisoner of His/Her Majesty and harks back to Australia’s beginnings as a British penal colony.

* Strine = Say “Australian” quickly as a single syllable with your back teeth lightly clenched together… you don’t want to let the flies get in.

This article was originally posted on http://www.winthropdc.com/blog.

Filed under: Fun Tagged: Friday Funny, Fun

See the original article here:
Friday Funny: Can you understand Strayan?

April 24, 2015 · WinthropDC · No Comments
Tags: , , , , , , , , , ,  · Posted in: Blogs I Follow Total Views: 31

Update: Positive Thoughts for Leslie Vail

David Meego - Click for blog homepageJust wanted to post a quick update from my friend Leslie Vail after my original post:

I heard from Leslie today that the surgery went well and she is now resting comfortably.

She wanted to thank everyone for their positive thoughts and lovely comments.

Please keep the positive vibes flowing as Leslie continues on the road to recovery.

We need her well and back at the conferences. No-one else can wear the capes like she does.

MarkCape
Mark Rockwell trying to emulate Leslie

JohnCape
John Lowther playing Leslie when he co-presented with her

LeslieJenniferSheila
Leslie, Jennifer (my wife) and Sheila from Convergence 2012

LeslieCape
Leslie and the famous golden GPUG cape at Convergence 2011

Get well soon.

David

This article was originally posted on http://www.winthropdc.com/blog.

Filed under: News Tagged: General, News

More:
Update: Positive Thoughts for Leslie Vail

April 21, 2015 · WinthropDC · No Comments
Tags: , , , , , , , , , , ,  · Posted in: Blogs I Follow Total Views: 36