Purpose
The BGM (Beginning of Message) segment appears near the start of most EDIFACT messages, immediately after the UNH header. It tells the receiving system what kind of business document this message represents, what the document number is, and what function the message serves. For example, the BGM segment distinguishes an original invoice from a credit note, or a new purchase order from a cancellation of an existing one.
While the UNH segment identifies the message type at the EDIFACT level (e.g., INVOIC), the BGM segment provides the business-level identification. A single message type like INVOIC can represent multiple document types (commercial invoice, credit note, debit note), and BGM is where this distinction is made.
Data Elements
The BGM segment contains the following key data elements:
- C002 - Document/Message Name: A composite identifying the document type.
- 1001 - Document Name Code: A coded value specifying the document type. Common values include 380 (Commercial Invoice), 381 (Credit Note), 220 (Purchase Order), 351 (Despatch Advice), and 231 (Self-billed Invoice).
- 1131 - Code List Qualifier (conditional): Identifies the code list used.
- 3055 - Code List Responsible Agency (conditional): The agency responsible for the code list.
- C106 - Document/Message Identification: Contains the document number.
- 1004 - Document Identifier: The unique document number assigned by the sender, such as an invoice number or order number.
- 1225 - Message Function Code: Indicates the function of the message. Common values include 9 (Original), 5 (Replacement), 1 (Cancellation), 31 (Copy), and 43 (Additional).
- 4343 - Response Type Code (conditional): Indicates whether acknowledgement is requested.
Format and Syntax
The general format of a BGM segment is:
BGM+documentNameCode+documentNumber+messageFunctionCode' When using composite elements with additional components:
BGM+documentNameCode:codeListQualifier:agency+documentNumber+functionCode' Messages That Use BGM
The BGM segment appears in virtually every business-level EDIFACT message. Key messages include:
- INVOIC - Invoice (document codes 380, 381, 383, 386)
- ORDERS - Purchase Order (document codes 220, 221, 224)
- DESADV - Despatch Advice (document code 351)
- RECADV - Receiving Advice (document code 632)
- PRICAT - Price/Sales Catalogue
- REMADV - Remittance Advice
Example
An original commercial invoice with invoice number INV-2024-0042:
BGM+380+INV-2024-0042+9' Here, 380 is the document name code for a commercial invoice, INV-2024-0042 is the document number, and 9 indicates this is an original message (not a replacement or cancellation).
A cancellation of a previously sent purchase order:
BGM+220+PO-2024-1500+1' The code 220 identifies a purchase order, PO-2024-1500 is the order number, and 1 marks this as a cancellation of that order.