Commit Batch To ERP

The final step for a staging record in a purchase order schedule batch is committing it to ERP.  This process occurs only after the batch has updated the staging record to Receive_Completed, indicating that it has updated the record with transaction results from Repete (see: todo).   

Process

Requirements

The process selects the batch's staging records (PurchaseOrderSchedule_Stage) with the folliwng criteria:

  • Have been received (Receive_Completed = true)

  • Are marked by the user to be included in the process (IncludeInBatch = true)

  • Have not been committed already (Commit_Completed = false)

It then groups these records by purchase order number and received delivery date.  Each distinct grouping results in a new PO receipt.  It's possible for one receipt to include multiple inventory records.   The table updates and mappings are described below in Updates.

Validation

  • Aeros ERP have a user with the user ID SYSTEM_AAI

  • The process must be able to generate a receiver number using the same process as ERP.  If it cannot do so, the update fails

  • The target purchase order must exist

  • Aeros ERP must have a division with the batch's division code.

  • Aeros ERP must have an accounting period for the target delivery date

  • Aeros ERP must have a purchase order line that corresponds to the staging record's purchase order line ID.

  • Aeros ERP must have an itemmaster record that corresponds to the staging record's item master

  • The Aeros ERP division must be configured with a validation default location.

Successful Completion

If a stage record is processed successfully and results in an inventory record, these fields are updated.  After which, the staging record cannot be committed again

  • PurchaseOrderSchedule_Stage.Commit_Completed = true

  • PurchaseOrderSchedule_Stage.Commit_Date = current date and time

Scheduled Process

The Aeros Service endpoint for the commit process will do the following

  • Find all batches with staging records that have been received but not yet committed

  • Execute the commit process for each of these batches

Updates

The commit process creates an Aeros ERP purchase order receipt.  This consists of

Table

Action

Description

Table

Action

Description

InvRecvr

Insert

For every grouping, the process creates a new receiver header

Inventory

Insert

Each processed staging record results in an inventory record

xrefPODelivery

Insert

Association table between the newly created inventory record and the scheduled delivery record from which it was created.  If a staging record has a scheduled delivery ID, the commit process creates a record in this table

InvAudit

Insert

The commit process does not create this record directly.  Rather, it's created through the inventory table insert trigger.

PODelSched

Update

Set the status to completed (C) on the original scheduled delivery

POLine

Update

Set the status to completed (C) on the original purchase order line when all deliveries are complete.

POPurOrd

Update

Set the purchase order status to complated (postatus=C) when all lines have been completed.

Mapping

InvRecvr

Field

Source

Field

Source

acctgprdseqno

AccountingPeriod.AcctgPrdSeqno

brokerseqno

0

cnsgnmnt_flag

"0"

cocd

POPurOrd.cocd

contractno

POPurOrd.contractno

createuserid

UserID

dfltloctnid

DivisionDefaultLocation

directctlno

"0"

divcd

POPurOrd.divcd

editrans_flag

"0"

fin_flag

"O"

FreightAmount

POPurOrd.FreightAmount

FreightDistribution

POPurOrd.FreightDistribution

inrec_flag

"0"

inrecseqno

0

intrans_flag

"0"

lcapplseqno

0

lcrsrvdamt

0

oob_flag

"1"

origacctgprdseqno

0

polcpymntseqno

0

poseqno

POPurOrd.POSeqNo

print_flag

"1"

recptdt

Current date/time

recvrdt

Current date/time

recvrno

Generated by calling ERP stored procedure

sp_fab_get_temp_from_divctl

recvrtype

"P"

rgaauth_flag

"0"

rgaauthdt

Current date/time

rgaauthnounits

0

rgaauthqty

0

rgarecvd_flag

"0"

ShipperSeqNo

POPurOrd.ShipperSeqNo

shipqty

0

shipviaseqno

0

status

"O"

supplrseqno

POPurOrd.supplierseqno

tempcntrlno

POPurOrd.purordno.ToString()

tempinvno

0

totchgamt

0

totintransitallocdqty

0

totintransitqty

0

totintransitunits

0

totinvoicedamt

0

totinvoicedfrtamt

0

totinvoicedqty

0

totinvoicedunit

0

totlcpayamt

0

totmdseamt

0

totposhipamt

0

totrecvdqty

Total received from all inventory records

transfer_addon_cost

0

user_cpu_key

User ID + Web server machine name

userid

SYSTEM_AAI

vinvntyqty

0

vinvtotchgamt

0

vinvtotunits

0

vinvtotwght

0

vmdseamt

0

woseqno

0

xfermemoseqno

0

Inventory

Field

Source

Field

Source

alloordlineseqno

0

allowoseqno

0

altqty

0

billhold_flag

"0"

billrls_flag

"0"

blrlsseqno

0

cnsgmnt_flag

"0"

cocd

InvRecvr.cocd

crapprvlseqno

0

custseqno

0

defectcat

"0"

dispacctgprd

0

disptype

"0"

divcd

InvRecvr.divcd

dtf_flag

"0"

fmtcd

POLine.fmtcd

FreightPerLine

PurchaseSchedule_Stage.Receive_DeliveryQuantity * POLine.unitcst

FreightPerUnit

inventory.FreightPerLine / inventory.wght

hig_flag

"0"

higunitseqno

0

iavailcd

0

icporecseqno

0

icsporecseqno

0

icsrecacctgprdseqno

0

icsrecskuseqno

0

ilineseqno

0

inseqno

0

intrans_flag

"0"

intransfer_flag

"0"

invclscd

ItemMaster.invclscd

invsource

"P-" + PurchaseSchedule_Stage.PurchaseOrderNumber

IsFirmPrice

POLine.IsFirmPrice

isortseq

1

ispectype

1

istatus

1

itemcd

ItemMaster.itemcd

itemuofmcd

ItemMaster.uofmcd

itrancd

110

itype

1

iubnhrlsseqno

0

iwiinputseqno

0

iwoseqno

0

lcapplseqno

0

loctnlocid

  • Ist try: ICSInventoryLocation.DefaultLoc. 

  • 2rd try: DivIntryPrcssr for the division and item.default_loc

  • 3rd try: DivICS

merchcst

POLine.unitcst.Value

merge

" "

mowrefno

refNo

ordshiptoseqno

0

origqty

PurchaseSchedule_Stage.Receive_DeliveryQuantity

origunitno

0

overflowbin

  • Ist try: ICSInventoryLocation.DefaultLoc. 

  • 2nd try: ItemMaster.default_loc

  • 3rd try: DivIntryPrcssr for the division (first match).

pcs

1

poaddtnlcst

0

poallo_flag

"0"

polineseqno

POLine.POLineSeqNo

polineuofmcd

POLine.uofmcd

poorigqty

inventory.origqty

poseqno

PurchaseSchedule_Stage.PurchaseOrderID

poshipmentseqno

0

poshipmentseqno

POShipment.POShipmentSeqNo

prebilled_flag

"0"

procsscst

0

received_flag

"0"

recmerchcst

0

recon_flag

"0"

recothercst

0

recprcsscst

0

recptacctgprd

InvRecvr.acctgprdseqno

recunitadjamt

0

recvddt

PurchaseSchedule_Stage.Receive_DeliveryDate.Value

refno

refNo

release_bnhqty

0

release_bnhwght

0

removed_flag

"0"

repack_flag

"0"

reusable_flag

"0"

RowCreateDate

Current date/time

RowModifyDate

Current date/time

rsrvdordineseqno

0

shiporderprint_flag

"0"

shiprls_flag

"0"

shpmntrack_flag

"0"

sku2

POLine.sku2

sku3

POLine.sku3

sku4

POLine.sku4

sku5

POLine.sku5

skucode

TODO

splitrpt_flag

"0"

subitemattached_flag

"0"

supplbnh_flag

"0"

supplrseqno

PurchaseSchedule_Stage.VendorID

totaccumcstamt

0

totbeamwght

0

totends

0

totusedqty

0.0m

trancd

122

userid

SYSTEM_AAI

vendoritemno

POLine.vendoritemno

wght

TODO

wonseqno

0

wrhsebinid

Default bin code

xferunitseqno

0