in

What’s EDI? Digital Knowledge Interchange


1. Warehouse Operations Simulation Mannequin

In our Python script, we’ll replicate a number of warehousing processes from the angle of EDI message change

  • Inbound cargo messages containing particulars like SKU and amount
  • Putaway confirmations with SKUs and putaway areas

Logistic Operations — (Picture by Writer)

These messages allow the ERP and Warehouse Administration methods (WMS) synchronization, drive effectivity and scale back errors.

  • Message 1: informing the warehouse groups {that a} cargo is coming for inbound through the WMS (ERP -> WMS)
  • Message 2: warehouse groups inform the distribution planning group that the pallet has been put in inventory and is able to be ordered (WMS -> ERP)

2. Construct a simulation mannequin with Python

Let’s simulate these message exchanges utilizing the EDI norm ANSI X12

  1. Inbound: items are obtained on the warehouse
    An EDI message (Warehouse Transport Order — 940) notifies the warehouse of an incoming cargo and its particulars.
  2. Putaway: after receiving, items are saved at a particular location
    A affirmation EDI message (Warehouse Inventory Switch Receipt Recommendation — 944) is returned to the ERP to substantiate the putaway.
  3. Selecting: for an order, objects are picked from storage areas
    This EDI message (Warehouse Transport Order — 940) can be utilized to instruct the warehouse on which objects to select.
  4. Outbound: transport to the shopper
    An EDI message (Warehouse Transport Recommendation — 945) is shipped to the ERP to substantiate that the products have been shipped.

Right here is the simplified model of the Python script,

# Writer: Samir Saci
# Notice: this script has been simplified for instructional functions.

class EDIMessage:
def __init__(self, message_id):
self.message_id = message_id
self.content material = ""

def add_segment(self, phase):
self.content material += phase + "n"

def get_message(self):
return f"ST*{self.message_id}*1n{self.content material}SE*2*1"

class Warehouse:
def __init__(self):
self.stock = {}

def receive_inbound(self, message):
strains = message.content material.break up("n")
for line in strains:
if line.startswith("N1"):
_, _, sku, amount, unit = line.break up("*")
self.stock[sku] = self.stock.get(sku, 0) + int(amount)
print("Obtained Inbound Cargo:n", message.content material)

def process_putaway(self, sku):
message = EDIMessage("944")
if sku in self.stock:
message.add_segment(f"N1*ST*{sku}*{self.stock[sku]}*items")
print("Putaway Affirmation:n", message.get_message())
return message
else:
print("SKU not present in stock.")

def process_picking(self, message):
strains = message.content material.break up("n")
for line in strains:
if line.startswith("N1"):
_, _, sku, amount, unit = line.break up("*")
if self.stock[sku] >= int(amount):
self.stock[sku] -= int(amount)
else:
print(f"Inadequate amount for SKU {sku}")
print("Processed Selecting Order:n", message.content material)

def process_outbound(self, picking_message):
message = EDIMessage("945")
strains = picking_message.content material.break up("n")
for line in strains:
if line.startswith("N1"):
_, _, sku, amount, unit = line.break up("*")
message.add_segment(f"N1*ST*{sku}*{amount}*bins")
print("Outbound Cargo Affirmation:n", message.get_message())
return message

Provoke the mannequin and create your inbound order

  • 2 completely different SKUs obtained in cartons
  • {Qty 1: 50 bins, Qty 2: 40 bins}
# Provoke the mannequin
warehouse = Warehouse()

# Inbound Course of
inbound_message = EDIMessage("940")
inbound_message.add_segment("N1*ST*SKU123*50*bins")
inbound_message.add_segment("N1*ST*SKU124*40*bins")
warehouse.receive_inbound(inbound_message)
print("Stock of {}: {} bins".format("SKU123",warehouse.stock["SKU123"]))
print("Stock of {}: {:,} bins".format("SKU124",warehouse.stock["SKU124"]))

And the output appears like this,

N1*ST*SKU123*50*bins
N1*ST*SKU124*40*bins

Stock of SKU123: 50 bins
Stock of SKU124: 40 bins

  • The 2 messages which were transmitted
  • Inventories of obtained objects have been up to date with the obtained amount

Putaway affirmation

# Putaway Course of
warehouse.process_putaway("SKU123")
  • This message sends a putaway affirmation for “SKU123”
ST*944*1
N1*ST*SKU123*50*items
SE*2*1

Selecting orders and outbound shipments

  • The 2 SKUs are picked with portions under their stock degree
# Selecting Course of (Selecting items for an order)
picking_message = EDIMessage("940")
picking_message.add_segment("N1*ST*SKU123*10*bins")
picking_message.add_segment("N1*ST*SKU124*5*bins")
warehouse.process_picking(picking_message)
print("Stock of {}: {} bins".format("SKU123",warehouse.stock["SKU123"]))
print("Stock of {}: {:,} bins".format("SKU124",warehouse.stock["SKU124"]))

# Outbound Course of (Sending out items)
warehouse.process_outbound()

Output,

N1*ST*SKU123*10*bins
N1*ST*SKU124*5*bins

Stock of SKU123: 40 bins
Stock of SKU124: 35 bins

ST*945*1
N1*ST*SKU123*10*bins
N1*ST*SKU124*5*bins
SE*2*1

  • 2 selecting orders with 10 and 5 bins for “SKU123” and “SKU124”
  • The stock has been up to date
  • The outbound orders are taking the portions picked

Error Detection & Dealing with

We didn’t introduce this mannequin for the only real goal of coding.

The thought is to grasp how we are able to create numerous checks to deal with errors when writing or studying messages.

EDI is just not exempt from information high quality points like

  • Lacking information, incorrect information format, invalid codes, …
  • Logical inconsistencies inflicting vital operational disruptions

Due to this fact, implementing strong information checks and validations is essential for guaranteeing the accuracy and reliability of Digital Knowledge Interchange.

Instance of error dealing with for receiving orders

def receive_inbound(self, message):
strains = message.content material.break up("n")
for line in strains:
if line.startswith("N1"):
strive:
_, _, sku, amount, unit = line.break up("*")

# SKU or amount is lacking
if not sku or not amount:
print("Error: SKU or amount lacking.")
return

# Amount is an integer
amount = int(amount)

# Unfavorable or zero portions
if amount <= 0:
print("Error: Amount have to be constructive.")
return

self.stock[sku] = self.stock.get(sku, 0) + amount
besides ValueError:
print("Error: Incorrect information format.")
return

print("Obtained Inbound Cargo:n", message.content material)

This piece of code is:

  • Checking if portions are lacking or not within the integer format
  • Confirm that each one portions are constructive
  • Increase an error if wanted

With Python, you may assist your infrastructure group in automating testing for the event of latest EDI messages.


How 25,000 Computer systems Skilled ChatGPT | by Jerry Qu | Aug, 2023

Depth-Conscious Object Insertion in Movies Utilizing Python | by Berkan Zorlubas | Aug, 2023