# Goods Receipt Barcode Batch and Package Label Printing Program

> A custom output program that automatically prints a barcode label with material, batch, quantity, vendor, purchase order and receipt date for each item when a goods receipt is posted, and splits one item into pallets or cartons with a separate label for each package. Scanning the barcode with a handheld makes later transfers, counts and issues to production error-free.

- Type: Program, Custom development, Form
- Module: MM
- Estimated effort: M (4–7 working days)
- Last updated: 2026-11-17
- URL: https://nekuhub.com/en/programs/goods-receipt-barcode-label-printing/


## Why is the standard not enough?

The standard goods receipt output (the GR slip messages in MIGO and MB90) produces the goods receipt slip and a simple label form; it does not split an item into packages, calculate the quantity per package or create barcodes in the command language of thermal label printers. The barcode content cannot be set to the structure the company uses (e.g. GS1-128) either. The custom program determines label count, barcode content and printer according to the company's rules.

### Closest standard alternatives

- MB90: Processes output for material documents in bulk; no split into packages and no thermal printer barcode.
- MIGO: Prints the goods receipt slip and the standard label; does not create one label per package.

## Tables used

| Table | Role | Access | Join | System |
|---|---|---|---|---|
| MKPF | Material document header: posting date and delivery note number | Read | - | ECC + S/4 |
| MSEG | Goods receipt items: material, batch, quantity, vendor, order | Read | MSEG-MBLNR = MKPF-MBLNR AND MSEG-MJAHR = MKPF-MJAHR | ECC + S/4 |
| MAKT | Material description | Read | MAKT-MATNR = MSEG-MATNR AND MAKT-SPRAS = SY-LANGU | ECC + S/4 |
| MARA | EAN code and gross weight | Read | MARA-MATNR = MSEG-MATNR | ECC + S/4 |
| MARM | Pallet and carton conversion factors (quantity per package) | Read | MARM-MATNR = MSEG-MATNR | ECC + S/4 |
| MCHA | Production and expiry date of the batch | Read | MCHA-MATNR = MSEG-MATNR AND MCHA-WERKS = MSEG-WERKS AND MCHA-CHARG = MSEG-CHARG | ECC + S/4 |
| LFA1 | Vendor name | Read | LFA1-LIFNR = MSEG-LIFNR | ECC + S/4 |
| NAST | Output (message) record: print status and reprint check | Read / write | NAST-OBJKY = MKPF-MBLNR + MKPF-MJAHR | ECC + S/4 |

## BAPIs and functions used

- SSF_FUNCTION_MODULE_NAME: Finds the generated function name of the label form

## Selection screen parameters

| Parameter | Description | Type | Reference field | Required |
|---|---|---|---|---|
| P_MBLNR | Material document | Single value | MKPF-MBLNR | Yes |
| P_MJAHR | Material document year | Single value | MKPF-MJAHR | Yes |
| S_ZEILE | Document item | Range / multiple | MSEG-ZEILE | No |
| P_PKQTY | Quantity per package (from MARM if empty) | Single value | - | No |
| P_PRNT | Label printer (output device) | Single value | - | No |
| P_REPRT | Reprint labels already printed (copy) | Checkbox | - | No |

## Result list columns

| Column | Source |
|---|---|
| Material document | MSEG-MBLNR |
| Item | MSEG-ZEILE |
| Material | MSEG-MATNR |
| Batch | MSEG-CHARG |
| Item quantity | MSEG-MENGE |
| Number of packages | Calculated: Round up(item quantity / quantity per package) |
| Quantity per package | Calculated: P_PKQTY or MARM conversion |
| Barcode | Calculated: (01) EAN + (10) batch + (30) quantity |
| Status | Calculated: Printed, copy printed or error |

## How does the program work?

1. The program runs automatically through an output condition at goods receipt, or manually from the selection screen with the material document number.
2. Goods receipt items are read from MKPF/MSEG: material, batch, quantity, unit of measure, storage location, vendor and purchase order. The material description comes from MAKT, the EAN from MARA, and the batch production and expiry dates from MCHA.
3. Number of packages: the user enters the quantity per package, or it is calculated from the pallet or carton conversion in MARM; the last package carries the remaining quantity.
4. The barcode content combines EAN, batch and quantity (e.g. with GS1-128 application identifiers) and every package gets a sequence number.
5. The label is produced with a Smart Form or Adobe Form, or directly in printer commands for thermal printers, and is sent to the default printer of the user or the storage location.
6. Printed labels are tracked through the output record (NAST); when the same document is printed again the user is warned and the label is marked as "copy".

## Authorization objects

- M_MSEG_WMB: Material document display authorization by plant
- S_SPO_DEV: Authorization to print on the label printer (output device)

## Frequently asked questions

### Does it work with thermal label printers?

Yes. The label can be created in the printer's own command language and sent as a raw spool request; this gives the fastest and sharpest barcode. The same design can also be printed on a laser printer with a Smart Form or Adobe Form.

### Can the barcode structure be changed?

Yes. The barcode content (EAN, batch, quantity, expiry date, order) and its order are kept in a settings table. Since the handheld screens decode the same structure, both sides are updated together.

### Does it work on S/4HANA?

Yes. MKPF and MSEG are read as compatibility views in S/4HANA. The output can be triggered by classic message control or by S/4HANA output management; the label design does not change.

---
Let us build this program for your system: https://nekuhub.com/en/request-a-quote/?report=mm-goods-receipt-label
