EDIFACT SMDG BAPLIE Bayplan/Stowage Plan Occupied and Empty Locations

BAPLIE is the bayplan/stowage plan message. Shipping lines, terminals and vessel planners exchange it to describe where every container is stowed on a vessel. SMDG maintains the implementation - this sample follows SMDG 3.1 on D13B.

Each stowage location group gives the cell in bay-row-tier format, with the container's EQD details, weight, ports of loading and discharge, and dangerous goods or reefer settings.

At a glance

Standard
EDIFACT SMDG
Version
D13B (SMDG 3.1)
Sent by
Shipping line or terminal to terminal, line or vessel
Responses
CONTRL, APERAK
ediFabric .NET template
TSBAPLIE in EdiFabric.Templates.Edifact
OpenEDI definition
View BAPLIE in the spec library

BAPLIE structure

The full EDIFACT SMDG BAPLIE layout from its OpenEDI definition, the same model ediFabric uses to parse, validate and generate it: 10 loops and 35 segment positions, in file order. Loops are shaded and their segments indented; Max use is how many times a segment or loop may repeat.

Segment / loop Name Usage Max use
UNHMessage headerMandatory1
BGMBeginning of messageOptional1
DTMDate/time/periodOptional>1
RFF loopReferenceOptional>1
RFFReferenceOptional1
DTMDate/time/periodOptional>1
NAD loopName and addressOptional>1
NADName and addressOptional1
CTA loopContact informationOptional>1
CTAContact informationOptional1
COMCommunication contactOptional>1
TDT loopDetails of transportOptional>1
TDTDetails of transportOptional1
RFFReferenceOptional1
FTXFree textOptional1
LOC loopPlace/location identificationOptional>1
LOCPlace/location identificationOptional1
DTMDate/time/periodOptional>1
UNSSection controlOptional1
LOC loopPlace/location identificationOptional>1
LOCPlace/location identificationOptional1
FTXFree textOptional>1
RFFReferenceOptional1
EQD loopEquipment detailsOptional>1
EQDEquipment detailsOptional1
NADName and addressOptional>1
MEAMeasurementsOptional>1
HANHandling instructionsOptional>1
DIMDimensionsOptional>1
RFFReferenceOptional>1
GDSNature of cargoOptional>1
FTXFree textOptional>1
LOC loopPlace/location identificationOptional>1
LOCPlace/location identificationOptional1
TSRTransport service requirementsOptional1
TDTDetails of transportOptional1
TMP loopTemperatureOptional>1
TMPTemperatureOptional1
RNGRange detailsOptional1
DTMDate/time/periodOptional1
EQA loopAttached equipmentOptional>1
EQAAttached equipmentOptional1
NADName and addressOptional1
CNTControl totalOptional1
UNTMessage trailerMandatory1

Mandatory segments must be sent, Optional ones only when the data applies. Trading partners often add their own rules in companion guides - ediFabric templates can be adjusted to match. Open the element-level definition in the EdiNation spec library.

Sample BAPLIE file

An SMDG 3.1 bayplan with occupied stowage locations. Paste it into EdiNation to see every element named and validated.

UNB+UNOA:2+SID+RID+20130430:1159+I-EX1/1+++++T01'
UNH+M-EX1/1+BAPLIE:D:13B:UN:SMDG31'
BGM+659::LOADONLY+M-EX1/1++38'
DTM+137:201304130959:203'
NAD+WZ+HNE:TERMINALS:306'
TDT+20+123W45+++HLC:LINES:306++9354351:11:ANINA'
RFF+VON:123E38'
LOC+5+BEANR'
DTM+136:201304301048:203'
LOC+61+FRLEH'
DTM+178:201305012100:203'
UNS+D'
LOC+147+0200688:9711:5'
EQD+CN+SUDU1234569:6346:5+42U0:6346:5+++5'
NAD+CF+HSD:LINES:306'
MEA+AAE+AET+KGM:22600'
DIM+13+CMT:::92'
CNT+8:1'
LOC+147+0200690:9711:5'
FTX+AGW++LOST:STOWLOC:306'
RFF+EQ:SUDU123459'
CNT+8:0'
UNT+21+M-EX1/1'
UNZ+1+I-EX1/1'

The same BAPLIE as JSON

ediFabric turns every loop, segment and element into a named field. This is the transaction from the sample, in the JSON that ediFabric Native and Cloud return and accept.

{
  "UNH": {
    "MessageReferenceNumber_01": "M-EX1/1",
    "MessageIdentifier_02": {
      "MessageType_01": "BAPLIE",
      "MessageVersionNumber_02": "D",
      "MessageReleaseNumber_03": "13B",
      "ControllingAgencyCoded_04": "UN",
      "AssociationAssignedCode_05": "SMDG31"
    }
  },
  "BGM": {
    "DOCUMENTMESSAGENAME_01": {
      "Documentnamecode_01": "659",
      "Codelistresponsibleagencycode_03": "LOADONLY"
    },
    "DOCUMENTMESSAGEIDENTIFICATION_02": {
      "Documentidentifier_01": "M-EX1/1"
    },
    "Responsetypecode_04": "38"
  },
  "DTM": [
    {
      "DATETIMEPERIOD_01": {
        "Dateortimeorperiodfunctioncodequalifier_01": "137",
        "Dateortimeorperiodtext_02": "201304130959",
        "Dateortimeorperiodformatcode_03": "203"
      }
    }
  ],
  "NADLoop": [
    {
      "NAD": {
        "Partyfunctioncodequalifier_01": "WZ",
        "PARTYIDENTIFICATIONDETAILS_02": {
          "Partyidentifier_01": "HNE",
          "Codelistidentificationcode_02": "TERMINALS",
          "Codelistresponsibleagencycode_03": "306"
        }
      }
    }
  ],
  "TDTLoop": [
    {
      "TDT": {
        "Transportstagecodequalifier_01": "20",
        "Meansoftransportjourneyidentifier_02": "123W45",
        "CARRIER_05": {
          "Carrieridentifier_01": "HLC",
          "Codelistidentificationcode_02": "LINES",
          "Codelistresponsibleagencycode_03": "306"
        },
        "EXCESSTRANSPORTATIONINFORMATION_07": {
          "Excesstransportationreasoncode_01": "9354351",
          "Excesstransportationresponsibilitycode_02": "11",
          "Customershipmentauthorisationidentifier_03": "ANINA"
        }
      },
      "RFF": {
        "REFERENCE_01": {
          "Referencecodequalifier_01": "VON",
          "Referenceidentifier_02": "123E38"
        }
      },
      "LOCLoop": [
        {
          "LOC": {
            "Locationfunctioncodequalifier_01": "5",
            "LOCATIONIDENTIFICATION_02": {
              "Locationidentifier_01": "BEANR"
            }
          },
          "DTM": [
            {
              "DATETIMEPERIOD_01": {
                "Dateortimeorperiodfunctioncodequalifier_01": "136",
                "Dateortimeorperiodtext_02": "201304301048",
                "Dateortimeorperiodformatcode_03": "203"
              }
            }
          ]
        },
        {
          "LOC": {
            "Locationfunctioncodequalifier_01": "61",
            "LOCATIONIDENTIFICATION_02": {
              "Locationidentifier_01": "FRLEH"
            }
          },
          "DTM": [
            {
              "DATETIMEPERIOD_01": {
                "Dateortimeorperiodfunctioncodequalifier_01": "178",
                "Dateortimeorperiodtext_02": "201305012100",
                "Dateortimeorperiodformatcode_03": "203"
              }
            }
          ]
        }
      ]
    }
  ],
  "UNS": {
    "Sectionidentification_01": "D"
  },
  "LOCLoop": [
    {
      "LOC": {
        "Locationfunctioncodequalifier_01": "147",
        "LOCATIONIDENTIFICATION_02": {
          "Locationidentifier_01": "0200688",
          "Codelistidentificationcode_02": "9711",
          "Codelistresponsibleagencycode_03": "5"
        }
      },
      "EQDLoop": [
        {
          "EQD": {
            "Equipmenttypecodequalifier_01": "CN",
            "EQUIPMENTIDENTIFICATION_02": {
              "Equipmentidentifier_01": "SUDU1234569",
              "Codelistidentificationcode_02": "6346",
              "Codelistresponsibleagencycode_03": "5"
            },
            "EQUIPMENTSIZEANDTYPE_03": {
              "Equipmentsizeandtypedescriptioncode_01": "42U0",
              "Codelistidentificationcode_02": "6346",
              "Codelistresponsibleagencycode_03": "5"
            },
            "Fulloremptyindicatorcode_06": "5"
          },
          "NAD": [
            {
              "Partyfunctioncodequalifier_01": "CF",
              "PARTYIDENTIFICATIONDETAILS_02": {
                "Partyidentifier_01": "HSD",
                "Codelistidentificationcode_02": "LINES",
                "Codelistresponsibleagencycode_03": "306"
              }
            }
          ],
          "MEA": [
            {
              "Measurementpurposecodequalifier_01": "AAE",
              "MEASUREMENTDETAILS_02": {
                "Measuredattributecode_01": "AET"
              },
              "VALUERANGE_03": {
                "Measurementunitcode_01": "KGM",
                "Measure_02": "22600"
              }
            }
          ],
          "DIM": [
            {
              "Dimensiontypecodequalifier_01": "13",
              "DIMENSIONS_02": {
                "Measurementunitcode_01": "CMT",
                "Heightmeasure_04": "92"
              }
            }
          ]
        }
      ],
      "CNT": {
        "CONTROL_01": {
          "Controlqualifier_01": "8",
          "Controlvalue_02": "1"
        }
      }
    },
    {
      "LOC": {
        "Locationfunctioncodequalifier_01": "147",
        "LOCATIONIDENTIFICATION_02": {
          "Locationidentifier_01": "0200690",
          "Codelistidentificationcode_02": "9711",
          "Codelistresponsibleagencycode_03": "5"
        }
      },
      "FTX": [
        {
          "Textsubjectcodequalifier_01": "AGW",
          "TEXTREFERENCE_03": {
            "Freetextdescriptioncode_01": "LOST",
            "Codelistidentificationcode_02": "STOWLOC",
            "Codelistresponsibleagencycode_03": "306"
          }
        }
      ],
      "RFF": {
        "REFERENCE_01": {
          "Referencecodequalifier_01": "EQ",
          "Referenceidentifier_02": "SUDU123459"
        }
      },
      "CNT": {
        "CONTROL_01": {
          "Controlqualifier_01": "8",
          "Controlvalue_02": "0"
        }
      }
    }
  ],
  "UNT": {
    "NumberofSegmentsinaMessage_01": "21",
    "MessageReferenceNumber_02": "M-EX1/1"
  }
}

Parse and validate a BAPLIE file

Read the file into typed objects with ediFabric .NET, or post it to the ediFabric Cloud REST API from any language and get JSON back.

using EdiFabric.Templates.EdifactD13B;

License.SetSerial("YOUR_SERIAL_KEY");

using (var stream = File.OpenRead(@"C:\edi\Bayplan.txt"))
using (var reader = new EdifactReader(stream, (unb, ung, unh) => typeof(TSBAPLIE).GetTypeInfo()))
{
    var items = await reader.ReadToEndAsync();
    foreach (var transaction in items.OfType<TSBAPLIE>())
    {
        if (transaction.IsValid(out MessageErrorContext errors))
            Console.WriteLine($"{transaction.UNH.MessageReferenceNumber_01} is valid");
        else
            Console.WriteLine(string.Join(Environment.NewLine, errors.Flatten()));
    }
}
curl -X POST 'https://api.edination.com/v2/edifact/read' \
-H 'Ocp-Apim-Subscription-Key: YOUR_SERIAL_KEY' \
-H 'Content-Type: application/octet-stream' \
--data-binary '@Bayplan.txt'

Generate a BAPLIE file

Populate a TSBAPLIE object in .NET, or post JSON in the shape shown above to ediFabric Cloud, and get a valid BAPLIE file back.

using EdiFabric.Templates.EdifactD13B;

License.SetSerial("YOUR_SERIAL_KEY");

var transaction = new TSBAPLIE();

//  Message header (ref id = M-EX1/1)
transaction.UNH = new UNH();
transaction.UNH.MessageReferenceNumber_01 = "0001";
transaction.UNH.MessageIdentifier_02 = new S009();
transaction.UNH.MessageIdentifier_02.MessageType_01 = "BAPLIE";
transaction.UNH.MessageIdentifier_02.MessageVersionNumber_02 = "D";
transaction.UNH.MessageIdentifier_02.MessageReleaseNumber_03 = "13B";
transaction.UNH.MessageIdentifier_02.ControllingAgencyCoded_04 = "UN";
transaction.UNH.MessageIdentifier_02.AssociationAssignedCode_05 = "SMDG31";

//  Partial BAPLIE(code 659), loaded containers only(LOADONLY), final stage(code 38)
transaction.BGM = new BGM();
transaction.BGM.DOCUMENTMESSAGENAME_01 = new C002();
transaction.BGM.DOCUMENTMESSAGENAME_01.Documentnamecode_01 = "659";
transaction.BGM.DOCUMENTMESSAGENAME_01.Codelistresponsibleagencycode_03 = "LOADONLY";
transaction.BGM.DOCUMENTMESSAGEIDENTIFICATION_02 = new C106();
transaction.BGM.DOCUMENTMESSAGEIDENTIFICATION_02.Documentidentifier_01 = "M-EX1/1";
transaction.BGM.Responsetypecode_04 = "38";

//  Repeating DTM
transaction.DTM = new List<DTM>();

// ... set the remaining loops and segments the same way

// SegmentBuilders is in the Common project of the example repository
using (var stream = new MemoryStream())
{
    using (var writer = new EdifactWriter(stream))
    {
        writer.Write(SegmentBuilders.BuildUnb("1"));
        writer.Write(transaction);
    }
    Console.WriteLine(Encoding.UTF8.GetString(stream.ToArray()));
}
# the JSON returned by /read, edited or produced by your application
curl -X POST 'https://api.edination.com/v2/edifact/write' \
-H 'Ocp-Apim-Subscription-Key: YOUR_SERIAL_KEY' \
-H 'Content-Type: application/json' \
--data-binary '@Bayplan.json' \
-o 'Bayplan.txt'

BAPLIE questions

What is SMDG?

The User Group for Shipping Lines and Container Terminals. It maintains the BAPLIE, MOVINS and COARRI implementation guides the industry uses.

What is the difference between BAPLIE 2.x and 3.x?

Version 3 is based on newer directories (D13B) and describes the vessel, stowage locations and equipment in more detail, including VGM weights and better reefer and dangerous goods data.

How is a stowage position encoded?

LOC+147 carries the cell as bay, row and tier, for example 0120382.

How do I parse and generate EDIFACT SMDG BAPLIE files in .NET?

In .NET, install EdiFabric and EdiFabric.Templates.Edifact, read the file with EdifactReader into TSBAPLIE objects and write them back with EdifactWriter. From any other language, post the file to the ediFabric Cloud REST API, which returns the same structure as JSON and converts JSON back to EDIFACT SMDG.

Parse your first BAPLIE in five minutes

The Community plan is free forever and needs no credit card. It includes ediFabric .NET, Native and Cloud.