Page 1 of 7612345678910...2025303540...Last »

Announcing Advanced Dexterity Training in Mexico City on 26-30 September 2016

David Meego - Click for blog homepageLast year, between reIMAGINE 2015 and GPUG Summit 2015, I ran Dexterity Fundamentals Training in Mexico City for the Microsoft Partner, Axentit.

So, this year they have asked me to come back and run an Advanced Dexterity Training class for them between reIMAGINE 2016 and GPUG Summit 2016.

The training will run in the week following the reIMAGINE 2016 conference and will be located at the Axentit offices in Mexico City from Monday 26th September 2016 to Friday 30th September 2016.

Dexterity Splash
This gives me another excuse to show the “Exploding Head” Dexterity logo

After this course I will be running the Dexterity Fundamentals Training in Tampa, Florida in the week before GPUG Summit 2016.

Below is some draft information on the training, however, the agenda might change as I will be getting feedback on specific topics that the attendees would like covered.

Dexterity II (Dexterity Advanced Integration Techniques)

Course Synopsis:

The Dexterity II course is designed to build upon the skills acquired from the Dexterity I course. It will provide advanced knowledge necessary to build applications that are tightly integrated with Microsoft Dynamics GP. The class will focus on building integrations associated with maintenance windows, transaction windows, inquiry windows and reports. In addition, topics such as creating SQL data and upgrading applications will also be discussed.

By actively participating in this class, you will learn:

  • Advanced programming techniques used by Microsoft Dynamics GP to develop Dynamics GP modules
  • How to develop add-on applications that will interact with the Dynamics GP products to meet specific customer requests
  • How to develop add-on applications that will “look and feel” like Dynamics GP and provide a seamless interface between the applications to ensure a professional finished product

Who should attend?

Customers or Partners who will be customizing or building applications to integrate with the Dynamics GP products.

Prerequisites:

  • A basic understanding of Dynamics GP is also needed.
  • Hands on development experience with Dexterity, preferably Dexterity I training course.
  • Familiarity with the Dynamics Software Developer Kit.

Agenda

Monday to Friday (5 days) 8:30-5:30 each day

Course Topics

Day 1
Introductions and Overview
Maintenance Window Integration Project
– Using the Great Plains Note object
– Using companion tables
– Implementing triggers to synchronize data

Day 2
Installation Window
– Creating SQL Tables
– Pass through SQL
Transaction Entry Window Integration Project
– Adding fields to an existing scrolling window
– Implementing triggers for data manipulation

Day 3
Inquiry Window Integration Project
– Modify existing inquiry window
– Create a new inquiry window
– Working with temporary tables

Day 4
Reports
– Modifying existing reports to add 3rd party data
– Using calculated fields and Report Writer functions
– Building a Report Options window

Day 5
Reports
– Building a Report Options window (continued)
Upgrading
– Table Conversions
– Installation scripts – adding to a palette, setting security, and adding to the shortcut bar
Error Handling and Debugging

The above agenda is a guideline and might be re-organised to fit additional topics if time allows.

To register your interest, so you are notified once more details are available, please contact Mariano Arias via email marias at axentit dot com dot mx.

Hope to see you there.

David

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

Filed under: Development, Dexterity, Training Tagged: Development, Dexterity, Training

Continue Reading:
Announcing Advanced Dexterity Training in Mexico City on 26-30 September 2016

March 30, 2016 · WinthropDC · No Comments
Tags: , , , , , , , , , , ,  · Posted in: Blogs I Follow Total Views: 109

GP Year-End Update for 2015: Affordable Care Act (ACA)

Terry Heley from Microsoft has a must see video if you are using Dynamics GP for Affordable Care Act. As she says –  “There were MANY changes in the year end update for ACA, so if you are going to track ACA in our system, it is MANDATORY” 

https://www.youtube.com/watch?feature=player_embedded&v=gAeLUjozhUA

See this post for more details – Microsoft Dynamics GP Year-End Release 2015: Affordable Care Act (ACA)

Click HERE for the latest ACA documentation for the 2015 year and all changes in the update in detail.

Read more here:
GP Year-End Update for 2015: Affordable Care Act (ACA)

December 28, 2015 · Jivtesh Singh · No Comments
Tags: , , , , , , , ,  · Posted in: Blogs I Follow Total Views: 166

CRM 2016 On Premise is now out!

At Convergence EMEA last week, Microsoft announced the release of CRM 2016 – “Available both as CRM Online and on-premises in 130 markets and 44 languages, Dynamics CRM 2016 is focused on empowering employees to deliver the optimal experiences to customers, as well as engaging customers across all channels.”

If you are searching for the download in MSDN on Partnersource, and not finding anything, don’t worry – it’ll be up there in about a week. The 2016 online trials are meanwhile being rolled out by regions.

You can prepare yourself by reviewing the updated documentation on what’s new in CRM 2016

This is a major release for on-premise customers who did not get the CRM 2015 online features, so if you are upgrading from on-premise check out those features as well (CRM Online 2015 Update 1 features now apply to CRM 2016 (on-premises)

Read the original post:
CRM 2016 On Premise is now out!

December 3, 2015 · Jivtesh Singh · No Comments
Tags: , , , , , , , , , , ,  · Posted in: Blogs I Follow Total Views: 189

#GPUGSummit – Pre Conference – Part 1 of 2

David Meego - Click for blog homepageGPUGSummit_Logo

After arriving Saturday afternoon after my road trip with Craig Klapman, I was able to spend the rest of the day writing up some blog posts on the time I spent in Mexico and then getting some sleep.

On Sunday, I decided to see how long it would take to walk from the Peppermill Resort Spa & Casino to the Atlantis Resort Spa & Casino. I was thinking that I could walk to the Atlantis during the week of the conference as it did not look that far.

I was planning to continue past the Atlantis and on to the Meadowood Mall shopping centre. I was told that the Atlantis was about half way and the hotel was easily visible so it should be fine. Looks were very deceptive and it turned out to be quite a long walk, about 25 minutes to the Atlantis and about an hour to get to the mall.

Map1
My short walk, turned out to be 4.1km (2.5 miles)

On the plus side it did give me a chance to get some nice photos of the venues.

Day0-1
Peppermill Resort, Spa & Casino has an Italian theme for the entire complex

Day0-2
Atlantis Resort, Spa & Casino and Reno Sparks Convention Center

As I was walking away from the Atlantis towards the mall, I heard a funny noise behind me. I turned to see that the Atlantis which has a section that crosses the road and has pillars on each side was flaring torches at the top of the pillars.

Day0-3
Flaring the torches on the pillars on each side of the road at the Atlantis.

During the next few days, I asked a local taxi driver about the torches and he said that the don’t light them very often and that I was lucky to see them lit. Anyhow, I continued to the shops and did the shopping that I had planned. For the return trip, I caught the bus back to the Atlantis and went in search of some of my conference buddies (my friends that I only see in person at conferences).

Belinda Allen had left her smartphone at home, but I was able to call John Lowther on his phone and catch up with Belinda, John, and Mark Huff. We went across to the sky bridge to conference center and located the GPUG Academy training rooms where we would be running training of the next couple of days.

As the Summit Conference registration was open, we decided to get registered and pick up the conference name tags and guide, etc. As part of the registration, I was offered a GPUG Summit bag and bottle, which I did not take. There were more GPUG attendees than bags available so this would help those who wanted a bag and bottle get one. Also, I already travel with a bag and water bottle and would not have room in my luggage to take the extras home.


Just a comment here: I don’t want to sound ungrateful, I love branded things but in my opinion conference bags are not the best way to go. Most people already have a bag that they travel with and everyone having the same bag makes it easy to pick up the wrong one. I would prefer a conference shirt or polo. I still have many conference shirts from years ago, including the 1998 Great Plains World Wide Developers Conference in Fargo, ND, USA. You just need to ask sizing during registration and have a few extras of each size for late registrations and size changes. PS: I can’t fit into some of the shirts but keep them any way for the memories.

After registration we decided to head back to the Atlantis for lunch. During lunch we persuaded Belinda to go get a cheap “burner” phone so she was at least contactable.

Day0-4
Clockwise: John Lowther, Mark Huff, Belinda Allen and David Musgrave at the Purple Parrot.

At lunch, John decided that it was my job to organise a dinner for the friends who were already in Reno. So with Mark Huff’s help we organised a dinner for 10 people at the Atlantis Steakhouse. I then decided to head back to the Peppermill (by taxi as John told me I as mad to walk), to drop off my shopping and chill before dinner. On the way out of the Atlantis, I caught up with my friends Mark and Kelli from Rockton Software. It is always great to see Mark’s smiling face. Can you believe that it is 14 years ago that Mark and I presented the “Pushing the Limits with Dexterity” conference session?

Rockton
Rockton Software’s Kelli Sexton and Mark Rockwell

I caught a taxi back to Atlantis and started to locate other friends who were joining us for dinner. The booking had been expanded from 10 to 17 people while I was at the Peppermill. What the hell, the more the merrier! We ended up being 16 as John Lowther counted himself twice (must be an ego thing). Also Leslie Vail could not make it, but I was able to call Thomas Garcia to come and join us (which saved him from eating alone in a strange city… not fun). After dinner, a few of us staying at the Peppermill caught a taxi back to the hotel to crash for the night.

DinnerDinner at Atlantis Steakhouse
Clockwise: Mark Huff, Tanya Henderson, David Musgrave, Belinda Allen, Zubin Gidwani, Michelle Kocher, Kim Peterson, Jay Manley, Craig Klapman, Mike McDowell, Barbara Gavron, John Lowther, Steve Linz, Bob McAdam, Sheila Jefferson-Ross, Thomas Garcia

I had an early start on Monday as I was running two GPUG Academy classes. I caught a shuttle bus from the hotel to the Convention Centre grabbed a light breakfast. I then ran two four hour training sessions for GPUG Academy.

  • Introduction to Support Debugging Tool / GP Power Tools
  • Advanced Support Debugging Tool / GP Power Tools

The sessions were originally labelled as Support Debugging Tool (SDT), but as the SDT has been discontinued, we instead focused on its replacement, GP Power Tools (GPPT) and highlighted where there were differences. Thanks to all the attendees to both sessions, I really enjoyed going through most of the features of the product. Apologies if the advanced session got a little in depth, but hopefully you now at least have an idea of how powerful the multilingual and cross dictionary scripting capabilities are.

After the training I headed back to the Atlantis Steakhouse for the PreGame to Summit Reception. It was great to catch up with many of the partners and sponsors for the PreGame partner event. I caught up with fellow MVP, Beat Bucher who was also there. I think the venue under estimated the demand for the bar as they did not have enough serving staff initially, and people were waiting a while for drinks. There was finger food, but not enough to count as a meal.

After the reception, Sheila Jefferson-Ross and Leslie Vail gave Thomas Garcia, Beat Bucher and I a lift back to the Peppermill and then the six of us grabbed some dinner at Cafe Milano. After dinner, Beat and I said good bye to the others and headed off to the GPUG Chapter Leader Bash which was being held at the Peppermill’s Terrace Lounge.

On arrival, Rose Spitzer grabbed the two of us and asked us to be part of the proceedings. We were involved in a fun activity giving the top ten reasons why it is great to be a GPUG Chapter Leader and work with the GPUG team of Dynamic Communities. There was also some live music and dancing.

GPUGChapterLeadBashKim Peterson and John Lowther tearing up the dance floor

Beat and I left the Bash while some of the others kept going. It was late after a long day and we both had a number of events scheduled for Tuesday.

More to come.

David

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

Filed under: Conference, Dynamics, GP, GPUG, Microsoft Tagged: Conference, GPUG Summit 2015

Read More:
#GPUGSummit – Pre Conference – Part 1 of 2

November 2, 2015 · WinthropDC · No Comments
Tags: , , , , , , ,  · Posted in: Blogs I Follow Total Views: 214

It’s official, say hello to David Musgrave MVP!

David Meego - Click for blog homepageI have been involved with the Great Plains / Microsoft Dynamics GP Community for many years and for much of that time I have been friends with some of the most knowledgeable and helpful people in the community.

A number of these friends have been recognised by Microsoft for their contributions by being awarded Microsoft Most Valuable Professional (MVP) status.

Many people have been surprised to find out that even though I usually hang out with the Dynamics GP MVPs, I was not actually a MVP. That said, I was usually treated as an honourary MVP and invited to MVP events. Thank-you for the unofficial recognition.

The issue was that a Microsoft Employee cannot be a MVP and I had been a Microsoft Employee for 13.5 years starting not long after Microsoft acquired Great Plains.

In October 2014, I left Microsoft and restarted my consulting business as Winthrop Development Consultants.

A number of the MVPs and also people in Microsoft immediately nominated me for MVP status, however as the MVP award is based on the contribution to the community made over the previous 12 months, I was not eligible until I had been out of Microsoft for at least a year.

Today is October 2015 and 12 months have passed since I left Microsoft and I am very proud to say that it is now official. I received the email today confirming that I have been awarded MVP status.

MVP

Dear David Musgrave,

Congratulations! We are pleased to present you with the 2015 Microsoft® MVP Award! This award is given to exceptional technical community leaders who actively share their high quality, real world expertise with others. We appreciate your outstanding contributions in Dynamics GP technical communities during the past year.

Thank you to everyone who nominated me and to the people who approved my nomination. It is great to be recognised for the work I do and I feel very proud to now be able to say that I am part of an elite group of people….

The Microsoft Dynamics GP MVPs

David

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

Filed under: Business, Microsoft, News Tagged: General, MVP, News

Read More:
It’s official, say hello to David Musgrave MVP!

October 1, 2015 · WinthropDC · No Comments
Tags: , , , , , , , , , , ,  · Posted in: Blogs I Follow Total Views: 213

Dynamics GP – Cashbook Bank Management (CBM) vs. Electronic Bank Management (EBM) vs. Bank Reconciliation (BR)

I have been doing a fair bit of explanation around Cashbook Management and Bank Reconciliation modules in GP over the past few weeks. I found the explanation from Brian Wick below was pretty good. To add on to his excellent explanation – here are a few additional items –

Cashbook Management –

  • Cashbook has support for more Multicurrency transactions. They can do bank transfers in as many as four currencies at the same time for instance whereas Bank Rec allows just two
  • Easier to track Tax with Bank Transactions (However, you should typically be using AR/AP modules in GP and let tax flow from there) . I’ve heard the argument from some customers that they have been told that this is the only way to track tax when accounting for GST or VAT. That is NOT correct! 
  • Support for more transaction types such as GL Checks and RM Checks with don’t really have a counterpart in the Ban Rec product
  • No eConnect Import Interface

Bank Reconciliation

  • More commonly Used, better and easier to support 
  • Works well and meets most requirements other than the 4 currency bank transfer requirement discussed above.
  • Has eConnect Import Interface

Cashbook Bank Management (CBM) vs. Electronic Bank Management (EBM) vs. Bank Reconciliation (BR)

(Bank Management (BM) refers to both CBM and EBM)

The major difference between Bank Management and the Bank Reconciliation is that the Bank Reconciliation receives most of it transactions from other modules. Debtors and creditors cash transactions are captured in RM and PM and Bank Reconciliation is updated accordingly.

You can capture all your cash transactions in Bank Management and RM, PM and GL will be updated accordingly. The windows updated in Great Plains are RM Cash Receipts, RM Transaction Entry (payments to debtors), PM Manual Payments, PM Transaction Entry (receipts from creditors) and GL General Entry.

However in the CBM transactions captured in PM transaction entry, RM transaction entry, SOP, invoicing and PM computer cheques also update CBM in the same way that Bank Reconciliation is updated.

The reconcile functions in CBM and Bank Reconciliation are very similar so the major difference between CBM and Bank Reconciliation is that Bank Reconciliation receives transactions from other modules and Bank Management is a single point of entry for all cash transactions. All other differences are in functionality: Batch processing, full multicurrency, Electronic Reconcile Management (Auto Bank Recon), Intercompany Payments and Deposits, Intercompany many to many Bank Transfers, Payments to Debtors and Receipts to Creditors ext.

The difference between the CBM/Bank Reconcile and EBM is due to the fact that in EBM you do not have any source documents (Cheque counterfoils, Deposit slips ext.) as 90% of the transactions are done via electronic transfer. So the first time we find out about a transaction is when it appears on the bank statement.

In CBM and Bank Reconciliation we capture our transactions from source documents (Cheque counterfoils and deposit slips) and then reconcile the transactions that are on the bank statement to the transactions that we have already captured.

In EBM we capture our transactions from the bank statement and then post the transactions to RM, PM and GL. As the source document is the bank statement there is no need to do a separate reconcile so the post and the reconcile is one process.

In EBM we do however allow for transaction that originate form counterfoils and deposit slips. When this happens the user will capture these transactions in RM and PM but instead of posting to the Bank Account the transactions will post to a Holding account. When the transactions appear on the Bank Statement they will be captured as normal and then matched to the original transactions in the Holding Account. Regardless of the type of the transaction (GL, AP or AR) EBM will create GL transactions moving the money from the Holding account to the Bank Account. Thus the Bank Account will only be affected by transactions that have appeared on a bank statement. By doing this the Bank Account will always have a true balance.

So the difference between CBM/Bank Reconcile and EBM is that CBM/Bank Reconcile are driven by source documents and EBM is driven by the Bank Statement.



Best regards,
Brian Wick
Partner Online Technical Community

See the article here:
Dynamics GP – Cashbook Bank Management (CBM) vs. Electronic Bank Management (EBM) vs. Bank Reconciliation (BR)

July 23, 2015 · Jivtesh Singh · No Comments
Tags: , , , , , , , , , ,  · Posted in: Blogs I Follow Total Views: 286

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: 263