/// <summary> /// Builds freight invoice. /// Original from https://ps.extra.chrysler.com/sites/itb-ebus/Documents/210FreightPaymentInvoice.pdf /// </summary> static TS210 BuildFreightInvoice(string controlNumber) { var result = new TS210(); // Transaction Set Identifier Code = “210” // (Motor Carrier Freight Details and Invoice) // Transaction Set Control Number = 00000001 result.ST = new ST(); result.ST.TransactionSetIdentifierCode_01 = "210"; result.ST.TransactionSetControlNumber_02 = controlNumber.PadLeft(9, '0'); // Invoice Number = 3410889 // Shipment Identification Number = 545930791T // Shipment Method of Payment // = “TP” (Third Party) // Weight Unit Code = “L” (Pounds) // Date = 10 / 31 / 2007 // Net Amount Due = 51.65 // Delivery Date = 10 / 29 / 2007 // Date / Time Qualifier = “035” (Delivered) // Standard Carrier Alpha Code = NLMI result.B3 = new B3(); result.B3.InvoiceNumber_02 = "3410889"; result.B3.ShipmentIdentificationNumber_03 = "545930791T"; result.B3.ShipmentMethodofPayment_04 = "TP"; result.B3.WeightUnitCode_05 = "L"; result.B3.Date_06 = "20071031"; result.B3.NetAmountDue_07 = "5165"; result.B3.DeliveryDate_09 = "20071029"; result.B3.DateTimeQualifier_10 = "035"; result.B3.StandardCarrierAlphaCode_11 = "NLMI"; // Currency Code = USD (U.S.) result.C3 = new C3(); result.C3.CurrencyCode_01 = "USD"; // Repeating N9 result.N9 = new List <N9>(); // Reference Identification Qualifier = “AE” // (Authorization for Expense<AFE> Number) // Reference Identification = 260451 var n91 = new N9(); n91.ReferenceIdentificationQualifier_01 = "AE"; n91.ReferenceIdentification_02 = "260451"; result.N9.Add(n91); // Reference Identification Qualifier // = “OP” (Original Purchase Order) // Reference Identification = 3410889 var n92 = new N9(); n92.ReferenceIdentificationQualifier_01 = "OP"; n92.ReferenceIdentification_02 = "3410889"; result.N9.Add(n92); // Repeating G62 result.G62 = new List <G62>(); // Date Qualifier = “86” (Actual Pickup Date) // Date = 10 / 31 / 2007 var g62 = new G62(); g62.DateQualifier_01 = "86"; g62.Date_02 = "20071031"; result.G62.Add(g62); // Repeating R3 result.R3 = new List <R3>(); // Standard Carrier Alpha Code = EXEM // Routing Sequence Code // = “B” (Origin / Delivery Carrier < Any Mode >) // Transportation Method/ Type Code // = “AE” (Air Express) // Date = 10 / 31 / 2007 // Amount = 379.05 var r3 = new R3(); r3.StandardCarrierAlphaCode_01 = "EXEM"; r3.RoutingSequenceCode_02 = "B"; r3.TransportationMethodTypeCode_04 = "AE"; r3.Date_07 = "20071031"; r3.Amount_08 = "37905"; result.R3.Add(r3); // Repeating N1 Loops result.N1Loop = new List <Loop_N1_210>(); // Begin N1 Loop 1 var n1Loop1 = new Loop_N1_210(); // Entity Identifier Code = “SH” (Shipper) // Name = SIEMENS VDO S A DE C V – // SIEMENS AUTOMOTIVE // Identification Code Qualifier // = “94” (Code assigned by the organization that is // the ultimate destination of the transaction set) // Identification Code = 99999 n1Loop1.N1 = new N1(); n1Loop1.N1.EntityIdentifierCode_01 = "SH"; n1Loop1.N1.Name_02 = "SIEMENS VDO S A DE C V - SIEMENS AUTOMOTIVE"; n1Loop1.N1.IdentificationCodeQualifier_03 = "94"; n1Loop1.N1.IdentificationCode_04 = "99999"; // Repeating N3 n1Loop1.N3 = new List <N3>(); // Address Information // = PERIFERICO SUR 7999D COMPLEJO IND var n31 = new N3(); n31.AddressInformation_01 = "PERIFERICO SUR 7999D COMPLEJO IND"; n1Loop1.N3.Add(n31); // City Name = TLAQUEPAQUE // State or Province Code = MX // Postal Code = 99999 // Country Code = MX n1Loop1.N4 = new N4(); n1Loop1.N4.CityName_01 = "TLAQUEPAQUE"; n1Loop1.N4.StateorProvinceCode_02 = "MX"; n1Loop1.N4.PostalCode_03 = "99999"; n1Loop1.N4.CountryCode_04 = "MX"; // End N1 Loop 1 result.N1Loop.Add(n1Loop1); // Begin N1 Loop 2 var n1Loop2 = new Loop_N1_210(); // Entity Identifier Code = “CN” (Consignee) // Name = BRAMPTON ASSEMBLY – COLLINS // AND AIKMAN // Identification Code Qualifier // = “94” (Code assigned by the organization that is // the ultimate destination of the transaction set) // Identification Code = 09126B n1Loop2.N1 = new N1(); n1Loop2.N1.EntityIdentifierCode_01 = "CN"; n1Loop2.N1.Name_02 = "BRAMPTON ASSEMBLY - COLLINS AND AIKMAN"; n1Loop2.N1.IdentificationCodeQualifier_03 = "94"; n1Loop2.N1.IdentificationCode_04 = "09126B"; // Repeating N3 n1Loop2.N3 = new List <N3>(); // Address Information // = 500 LAIRD ROAD~GUELPH PRODUCTS var n32 = new N3(); n32.AddressInformation_01 = "500 LAIRD ROAD"; n32.AddressInformation_02 = "GUELPH PRODUCTS"; n1Loop2.N3.Add(n32); // City Name = GUELPH // State or Province Code = ON // Postal Code = 99999 // Country Code = CA n1Loop2.N4 = new N4(); n1Loop2.N4.CityName_01 = "GUELPH"; n1Loop2.N4.StateorProvinceCode_02 = "ON"; n1Loop2.N4.PostalCode_03 = "99999"; n1Loop2.N4.CountryCode_04 = "CA"; // End N1 Loop 2 result.N1Loop.Add(n1Loop2); // Begin N1 Loop 3 var n1Loop3 = new Loop_N1_210(); // Entity Identifier Code = “BT” (Bill-to-Party) // Name = BRAMPTON ASSEMBLY - MAIN // Identification Code Qualifier // = “94” (Code assigned by the organization that is // the ultimate destination of the transaction set) // Identification Code = 09126 n1Loop3.N1 = new N1(); n1Loop3.N1.EntityIdentifierCode_01 = "BT"; n1Loop3.N1.Name_02 = "BRAMPTON ASSEMBLY - MAIN"; n1Loop3.N1.IdentificationCodeQualifier_03 = "94"; n1Loop3.N1.IdentificationCode_04 = "09126"; // Repeating N3 n1Loop3.N3 = new List <N3>(); // Address Information // = 2000 WILLIAMS PARKWAY EAST var n33 = new N3(); n33.AddressInformation_01 = "2000 WILLIAMS PARKWAY EAST"; n1Loop3.N3.Add(n33); // City Name = BRAMPTON // State or Province Code = ON // Postal Code = 99999 // Country Code = CA n1Loop3.N4 = new N4(); n1Loop3.N4.CityName_01 = "BRAMPTON"; n1Loop3.N4.StateorProvinceCode_02 = "ON"; n1Loop3.N4.PostalCode_03 = "99999"; n1Loop3.N4.CountryCode_04 = "CA"; // End N1 Loop 3 result.N1Loop.Add(n1Loop3); // Begin N1 Loop 4 var n1Loop4 = new Loop_N1_210(); // Entity Identifier Code = “CA” (Carrier) // Name // = NATIONAL LOGISTICS MANAGEMENT // Identification Code Qualifier // = “94” (Code assigned by the organization that is // the ultimate destination of the transaction set) // Identification Code = 45795 n1Loop4.N1 = new N1(); n1Loop4.N1.EntityIdentifierCode_01 = "CA"; n1Loop4.N1.Name_02 = "NATIONAL LOGISTICS MANAGEMENT"; n1Loop4.N1.IdentificationCodeQualifier_03 = "94"; n1Loop4.N1.IdentificationCode_04 = "45795"; // Repeating N3 n1Loop4.N3 = new List <N3>(); // Address Information = 14320 JOY RD. var n34 = new N3(); n34.AddressInformation_01 = "14320 JOY RD."; n1Loop4.N3.Add(n34); // City Name = DETROIT // State or Province Code = MI // Postal Code = 48228 // Country Code = US n1Loop4.N4 = new N4(); n1Loop4.N4.CityName_01 = "DETROIT"; n1Loop4.N4.StateorProvinceCode_02 = "MI"; n1Loop4.N4.PostalCode_03 = "48228"; n1Loop4.N4.CountryCode_04 = "US"; // End N1 Loop 4 result.N1Loop.Add(n1Loop4); // Begin N1 Loop 5 var n1Loop5 = new Loop_N1_210(); // Entity Identifier Code = “ZZ” (Mutually Defined) // Name = EXPEDITORS / EMERY WORLDWIDE // Identification Code Qualifier // = “94” (Code assigned by the organization that is // the ultimate destination of the transaction set) // Identification Code = 37905 n1Loop5.N1 = new N1(); n1Loop5.N1.EntityIdentifierCode_01 = "ZZ"; n1Loop5.N1.Name_02 = "EXPEDITORS/EMERY WORLDWIDE"; n1Loop5.N1.IdentificationCodeQualifier_03 = "94"; n1Loop5.N1.IdentificationCode_04 = "37905"; // Repeating N3 n1Loop5.N3 = new List <N3>(); // Address Information = 10881 LOWELL AVENUE var n35 = new N3(); n35.AddressInformation_01 = "10881 LOWELL AVENUE"; n1Loop5.N3.Add(n35); // City Name = OVERLANDPARK // State or Province Code = KS // Postal Code = 66201 // Country Code = US n1Loop5.N4 = new N4(); n1Loop5.N4.CityName_01 = "OVERLANDPARK"; n1Loop5.N4.StateorProvinceCode_02 = "KS"; n1Loop5.N4.PostalCode_03 = "66201"; n1Loop5.N4.CountryCode_04 = "US"; // Repeating N9 n1Loop5.N9 = new List <N9>(); // Reference Identification Qualifier // = “IK” (Invoice Number) // Reference Identification = 545930791T var n9 = new N9(); n9.ReferenceIdentificationQualifier_01 = "IK"; n9.ReferenceIdentification_02 = "545930791T"; n1Loop5.N9.Add(n9); // End N1 Loop 5 result.N1Loop.Add(n1Loop5); // Repeating N7 Loops result.N7Loop = new List <Loop_N7_210>(); // Begin N7 Loop var n7Loop1 = new Loop_N7_210(); // Equipment Number = 53456 // Equipment Description Code // = “TL” (Trailer < not otherwise specified>) // Equipment Length = 53 Feet // Equipment Type // = “53ST” (53 Foot Standard Trailer) n7Loop1.N7 = new N7(); n7Loop1.N7.EquipmentNumber_02 = "53456"; n7Loop1.N7.EquipmentDescriptionCode_11 = "TL"; n7Loop1.N7.EquipmentLength_15 = "5300"; n7Loop1.N7.EquipmentType_22 = "53ST"; // End N7 Loop result.N7Loop.Add(n7Loop1); // Repeating LX Loops result.LXLoop = new List <Loop_LX_210>(); // Begin LX Loop var lxLoop1 = new Loop_LX_210(); // Assigned Number = 1 lxLoop1.LX = new LX(); lxLoop1.LX.AssignedNumber_01 = "1"; // Repeating L5 lxLoop1.L5 = new List <L5>(); // Lading Line Item Number= 1 // Commodity Code = “2” (Auto Parts) // Commodity Code Qualifier // = “Z” (Mutually defined) var l5 = new L5(); l5.LadingLineItemNumber_01 = "1"; l5.CommodityCode_03 = "2"; l5.CommodityCodeQualifier_04 = "Z"; lxLoop1.L5.Add(l5); // Repeating L0 lxLoop1.L0 = new List <L0>(); // Lading Line Item Number = 1 // Billed / Rated -as Quantity = 1499 // Billed / Rated -as Qualifier = “FR” (Flat Rate) // Weight = 1499 // Weight Qualifier = “G” (Gross) // Weight Unit Code = “L” (Pounds) var l0 = new L0(); l0.LadingLineItemNumber_01 = "1"; l0.BilledRatedasQuantity_02 = "1499"; l0.BilledRatedasQualifier_03 = "FR"; l0.Weight_04 = "1499"; l0.WeightQualifier_05 = "G"; l0.WeightUnitCode_11 = "L"; lxLoop1.L0.Add(l0); // Repeating L0 lxLoop1.L1 = new List <L1>(); // Lading Line Item Number = 1 // Freight Rate = 51.65 // Rate / Value Qualifier = “FR” (Flat Rate) // Charge = 51.65 // Special Charge or Allowance Code // = “400” (Freight) var l1 = new L1(); l1.LadingLineItemNumber_01 = "1"; l1.FreightRate_02 = "51.65"; l1.RateValueQualifier_03 = "FR"; l1.Charge_04 = "5165"; l1.SpecialChargeorAllowanceCode_08 = "400"; lxLoop1.L1.Add(l1); // End LX Loop result.LXLoop.Add(lxLoop1); // Weight = 2619 // Weight Qualifier = “G” (Gross Weight) // Charge = 51.65 result.L3 = new L3(); result.L3.Weight_01 = "2619"; result.L3.WeightQualifier_02 = "G"; result.L3.Charge_05 = "5165"; return(result); }
/// <summary> /// Builds warehouse shipping advice. /// Original from http://techsheets.simplot.com/EDI/945_FG_4010.pdf /// </summary> static TS945 BuildWarehouseShippingAdvice(string controlNumber) { var result = new TS945(); // Transaction Set Identifier Code = "945" // (Receiving Advice / Acceptance Certificate) // Transaction Set Control Number = 0002 result.ST = new ST(); result.ST.TransactionSetIdentifierCode_01 = "945"; result.ST.TransactionSetControlNumber_02 = controlNumber.PadLeft(9, '0'); // Warehouse Shipment Identification // X = Reporting Code // F = Full Detail // 12345 = Mfg.Order No. // CCYYMMDD = Shipment Date // 123456 = PRO No. // 1234 = Bill of Lading No. // 01 = Stop Number // 9999 = Mfg.Master Order Number // Z = Action Code // 1 = Add // 2 = Change result.W06 = new W06(); result.W06.ReportingCode_01 = "X"; result.W06.DepositorOrderNumber_02 = "12345"; result.W06.Date_03 = "CCYYMMDD"; result.W06.ShipmentIdentificationNumber_04 = "123456"; result.W06.AgentShipmentIDNumber_05 = "1234"; result.W06.MasterReferenceLinkNumber_07 = "01"; result.W06.LinkSequenceNumber_08 = "9999"; result.W06.ActionCode_12 = "Z"; // Repeating N1 Loops result.N1Loop = new List <Loop_N1_945>(); // Begin N1 Loop var n1Loop1 = new Loop_N1_945(); // Name // WH = Warehouse // Warehouse Name = Actual Name // XX = Warehouse Code Qualifier // 9 = DUNS + 4 // 91 = Code assigned by Manufacturer // 123456 = Actual DUNS # or Code n1Loop1.N1 = new N1(); n1Loop1.N1.EntityIdentifierCode_01 = "WH"; n1Loop1.N1.Name_02 = "Warehouse Name"; n1Loop1.N1.IdentificationCodeQualifier_03 = "9"; n1Loop1.N1.IdentificationCode_04 = "123456"; // End N1 Loop result.N1Loop.Add(n1Loop1); // Begin N2 Loop var n1Loop2 = new Loop_N1_945(); // Name n1Loop2.N1 = new N1(); n1Loop2.N1.EntityIdentifierCode_01 = "DE"; n1Loop2.N1.Name_02 = "Depositor Name"; n1Loop2.N1.IdentificationCodeQualifier_03 = "9"; n1Loop2.N1.IdentificationCode_04 = "0123456789000"; // End N1 Loop result.N1Loop.Add(n1Loop2); // Repeating N9 result.N9 = new List <N9>(); // Reference Identification 1 // SN = Reference Number Qualifier // Seal Number = actual id number var n91 = new N9(); n91.ReferenceIdentificationQualifier_01 = "SN"; n91.ReferenceIdentification_02 = "Seal Number"; result.N9.Add(n91); // Reference Identification 2 var n92 = new N9(); n92.ReferenceIdentificationQualifier_01 = "ZZ"; n92.ReferenceIdentification_02 = "Temperature Recording Device Number"; result.N9.Add(n92); // Carrier detail result.W27 = new W27(); result.W27.TransportationMethodTypeCode_01 = "H"; result.W27.StandardCarrierAlphaCode_02 = "TRUK"; result.W27.Routing_03 = "TRUCKING"; result.W27.ShipmentMethodofPayment_04 = "CC"; result.W27.EquipmentNumber_07 = "Equipment ID"; // Details result.LXLoop = new List <Loop_LX_945>(); // Begin LX Loop 1 var lxLoop1 = new Loop_LX_945(); // Line number 1 lxLoop1.LX = new LX(); lxLoop1.LX.AssignedNumber_01 = "1"; // Repeating W12 Loops lxLoop1.W12Loop = new List <Loop_W12_945>(); // Begin W12 Loop var w12Loop1 = new Loop_W12_945(); // Item detail w12Loop1.W12 = new W12(); w12Loop1.W12.ShipmentOrderStatusCode_01 = "CC"; w12Loop1.W12.QuantityOrdered_02 = "72"; w12Loop1.W12.NumberofUnitsShipped_03 = "72"; w12Loop1.W12.UnitorBasisforMeasurementCode_05 = "CA"; w12Loop1.W12.UPCCaseCode_06 = "007117901645"; w12Loop1.W12.ProductServiceIDQualifier_07 = "UK"; w12Loop1.W12.ProductServiceID_08 = "10071179016458"; w12Loop1.W12.WarehouseLotNumber_09 = "40550"; w12Loop1.W12.Weight_10 = "799"; w12Loop1.W12.WeightQualifier_11 = "G"; w12Loop1.W12.WeightUnitCode_12 = "L"; // Repeating G69 w12Loop1.G69 = new List <G69>(); // Line item 1 detail description var g691 = new G69(); g691.FreeformDescription_01 = "Some description"; w12Loop1.G69.Add(g691); // Repeating N9 w12Loop1.N9 = new List <N9>(); // Reference Identification 1 var n93 = new N9(); n93.ReferenceIdentificationQualifier_01 = "LI"; n93.ReferenceIdentification_02 = "1000"; w12Loop1.N9.Add(n93); // Reference Identification 2 var n94 = new N9(); n94.ReferenceIdentificationQualifier_01 = "PC"; n94.ReferenceIdentification_02 = "989JAN281301"; w12Loop1.N9.Add(n94); // Reference Identification 3 var n95 = new N9(); n95.ReferenceIdentificationQualifier_01 = "LV"; n95.ReferenceIdentification_02 = "00100752782101847618"; n95.FreeformDescription_03 = "36"; w12Loop1.N9.Add(n95); // Reference Identification 4 var n96 = new N9(); n96.ReferenceIdentificationQualifier_01 = "LV"; n96.ReferenceIdentification_02 = "00100752782101847619"; n96.FreeformDescription_03 = "36"; w12Loop1.N9.Add(n96); // End W12 Loop lxLoop1.W12Loop.Add(w12Loop1); // End LX Loop 1 result.LXLoop.Add(lxLoop1); // Begin LX Loop 2 var lxLoop2 = new Loop_LX_945(); // Line number 1 lxLoop2.LX = new LX(); lxLoop2.LX.AssignedNumber_01 = "2"; // Repeating W12 Loops lxLoop2.W12Loop = new List <Loop_W12_945>(); // Begin W12 Loop var w12Loop2 = new Loop_W12_945(); // Item detail w12Loop2.W12 = new W12(); w12Loop2.W12.ShipmentOrderStatusCode_01 = "CC"; w12Loop2.W12.QuantityOrdered_02 = "72"; w12Loop2.W12.NumberofUnitsShipped_03 = "72"; w12Loop2.W12.UnitorBasisforMeasurementCode_05 = "CA"; w12Loop2.W12.UPCCaseCode_06 = "007117901645"; w12Loop2.W12.ProductServiceIDQualifier_07 = "UK"; w12Loop2.W12.ProductServiceID_08 = "10071179016458"; w12Loop2.W12.WarehouseLotNumber_09 = "40551"; w12Loop2.W12.Weight_10 = "884"; w12Loop2.W12.WeightQualifier_11 = "G"; w12Loop2.W12.WeightUnitCode_12 = "L"; // Repeating G69 w12Loop2.G69 = new List <G69>(); // Line item 1 detail description var g697 = new G69(); g697.FreeformDescription_01 = "Some description"; w12Loop2.G69.Add(g697); // Repeating N9 w12Loop2.N9 = new List <N9>(); // Reference Identification 1 var n98 = new N9(); n98.ReferenceIdentificationQualifier_01 = "LI"; n98.ReferenceIdentification_02 = "1000"; w12Loop2.N9.Add(n98); // Reference Identification 2 var n99 = new N9(); n99.ReferenceIdentificationQualifier_01 = "PC"; n99.ReferenceIdentification_02 = "989JAN291301"; w12Loop2.N9.Add(n99); // Reference Identification 3 var n910 = new N9(); n910.ReferenceIdentificationQualifier_01 = "LV"; n910.ReferenceIdentification_02 = "00100752782101847620"; n910.FreeformDescription_03 = "72"; w12Loop2.N9.Add(n910); // End W12 Loop lxLoop2.W12Loop.Add(w12Loop2); // End LX Loop 2 result.LXLoop.Add(lxLoop2); // Total shipment information result.W03 = new W03(); result.W03.NumberofUnitsShipped_01 = "240"; // Number of Units Shipped result.W03.Weight_02 = "15360"; // Total Weight result.W03.UnitorBasisforMeasurementCode_03 = "LB"; // Weight Unit of Measure return(result); }
/// <summary> /// Builds Rail Carrier Shipment. /// Original from https://ps.nafta.extra.fcagroup.com/sites/itb-ebus/shared%20Documents/404RailCarrierShipmentInformation.pdf /// </summary> static TS404 BuildRailCarrierShipment(string controlNumber) { var result = new TS404(); // Transaction Set Identifier Code // = “404” (Rail Carrier Shipment Information) // Transaction Set Control Number = 0001 result.ST = new ST(); result.ST.TransactionSetIdentifierCode_01 = "404"; result.ST.TransactionSetControlNumber_02 = controlNumber.PadLeft(9, '0'); // Transaction Set Purpose Code = “00” (Original) // Transportation Method/ Type Code = “R” (Rail) // Shipment Method of Payment // = “11” (Rule 11 Shipment) // Standard Carrier Alpha Code = NS // Weight Unit Code = ”L” (Pounds) // Shipment Qualifier // = “B” (Bill of Lading for Individual Shipment) // Section Seven Code = “N” (Not in Effect) result.BX = new BX(); result.BX.TransactionSetPurposeCode_01 = "00"; result.BX.TransportationMethodTypeCode_02 = "R"; result.BX.ShipmentMethodofPayment_03 = "11"; result.BX.StandardCarrierAlphaCode_05 = "NS"; result.BX.WeightUnitCode_06 = "L"; result.BX.ShipmentQualifier_07 = "B"; result.BX.SectionSevenCode_08 = "N"; // Shipment Weight Code // = “A” (Shipper's Weight Agreement) // Billing Code = “S” (Single Shipment Billing) result.BNX = new BNX(); result.BNX.ShipmentWeightCode_01 = "A"; result.BNX.BillingCode_03 = "S"; // Release Code = “R” (Released with Billing Data) // Date = 03 / 01 / 2000 // Time = 11:16 // Time Code = “LT” (Local Time) result.M3 = new M3(); result.M3.ReleaseCode_01 = "R"; result.M3.Date_02 = "20000301"; result.M3.Time_03 = "1116"; result.M3.TimeCode_04 = "LT"; // Repeating N9 result.N9 = new List <N9>(); // Reference Identification Qualifier // = “BM” (Bill of Lading Number) // Reference Identification = 2041247 // Date = 03 / 01 / 2000 // Time = 11:16 // Time Code = “LT” (Local Time) var n9 = new N9(); n9.ReferenceIdentificationQualifier_01 = "BM"; n9.ReferenceIdentification_02 = "2041247"; n9.Date_04 = "20000301"; n9.Time_05 = "1116"; n9.TimeCode_06 = "LT"; result.N9.Add(n9); // Repeating N7 Loops result.N7Loop = new List <Loop_N7_404>(); // Begin N7 Loop var n7Loop1 = new Loop_N7_404(); // Equipment Initial = CR // Equipment Number = 237522 // Weight = 80,503 // Weight Qualifier = “N” (Actual Net Weight) // Equipment Description Code = “RR” (Rail Car) n7Loop1.N7 = new N7(); n7Loop1.N7.EquipmentInitial_01 = "CR"; n7Loop1.N7.EquipmentNumber_02 = "237522"; n7Loop1.N7.Weight_03 = "80503"; n7Loop1.N7.WeightQualifier_04 = "N"; n7Loop1.N7.EquipmentDescriptionCode_11 = "RR"; // Repeating M7 n7Loop1.M7 = new List <M7>(); // Seal Number = 582127 // Seal Number = 582128 var m7 = new M7(); m7.SealNumber_01 = "582127"; m7.SealNumber_02 = "582128"; n7Loop1.M7.Add(m7); // End N7 Loop result.N7Loop.Add(n7Loop1); // City Name = WARREN // State or Province Code = MI result.F9 = new F9(); result.F9.CityName_02 = "WARREN"; result.F9.StateorProvinceCode_03 = "MI"; // City Name = VALLEY PARK // State or Province Code = MO result.D9 = new D9(); result.D9.CityName_02 = "VALLEY PARK"; result.D9.StateorProvinceCode_03 = "MO"; // Repeating N1 Loops result.N1Loop = new List <Loop_N1_404_3>(); // Begin N1 Loop 1 var n1Loop1 = new Loop_N1_404_3(); // Entity Identifier Code = “11” // (Party to be billed < AAR Accounting Rule 11 >) // Name = CORPAY SOLUTIONS n1Loop1.N1 = new N1(); n1Loop1.N1.EntityIdentifierCode_01 = "11"; n1Loop1.N1.Name_02 = "CORPAY SOLUTIONS"; // Repeating N3 n1Loop1.N3 = new List <N3>(); // Address Information // = PO BOX 195199 / 2065 S CENTER RD var n31 = new N3(); n31.AddressInformation_01 = "PO BOX 195199/2065 S CENTER RD"; n1Loop1.N3.Add(n31); // City Name = BURTON // State or Province Code = MI // Postal Code = 48519 n1Loop1.N4 = new N4(); n1Loop1.N4.CityName_01 = "BURTON"; n1Loop1.N4.StateorProvinceCode_02 = "MI"; n1Loop1.N4.PostalCode_03 = "48519"; // End N1 Loop 1 result.N1Loop.Add(n1Loop1); // Begin N1 Loop 2 var n1Loop2 = new Loop_N1_404_3(); // Entity Identifier Code = “CN” (Consignee) // Name = ST LOUIS ASSEMBLY I // Identification Code Qualifier // = “93” (Code assigned by the organization // originating the transaction set) // Identification Code = 04087 n1Loop2.N1 = new N1(); n1Loop2.N1.EntityIdentifierCode_01 = "CN"; n1Loop2.N1.Name_02 = "ST LOUIS ASSEMBLY I"; n1Loop2.N1.IdentificationCodeQualifier_03 = "93"; n1Loop2.N1.IdentificationCode_04 = "04087"; // Repeating N3 n1Loop2.N3 = new List <N3>(); // Address Information // = 1001 N HIGHWAY DRIVE var n32 = new N3(); n32.AddressInformation_01 = "1001 N HIGHWAY DRIVE"; n1Loop2.N3.Add(n32); // City Name = FENTON // State or Province Code = MO // Postal Code = 63026 n1Loop2.N4 = new N4(); n1Loop2.N4.CityName_01 = "FENTON"; n1Loop2.N4.StateorProvinceCode_02 = "MO"; n1Loop2.N4.PostalCode_03 = "63026"; // End N1 Loop 2 result.N1Loop.Add(n1Loop2); // Begin N1 Loop 3 var n1Loop3 = new Loop_N1_404_3(); // Entity Identifier Code // = “UC” (Ultimate Consignee) // Name = ST LOUIS ASSEMBLY I // Identification Code Qualifier // = “93” (Code assigned by the organization // originating the transaction set) // Identification Code = 04087 n1Loop3.N1 = new N1(); n1Loop3.N1.EntityIdentifierCode_01 = "UC"; n1Loop3.N1.Name_02 = "ST LOUIS ASSEMBLY I"; n1Loop3.N1.IdentificationCodeQualifier_03 = "93"; n1Loop3.N1.IdentificationCode_04 = "04087"; // Repeating N3 n1Loop3.N3 = new List <N3>(); // Address Information // = 1001 N HIGHWAY DRIVE var n33 = new N3(); n33.AddressInformation_01 = "1001 N HIGHWAY DRIVE"; n1Loop3.N3.Add(n33); // City Name = FENTON // State or Province Code = MO // Postal Code = 63026 n1Loop3.N4 = new N4(); n1Loop3.N4.CityName_01 = "FENTON"; n1Loop3.N4.StateorProvinceCode_02 = "MO"; n1Loop3.N4.PostalCode_03 = "63026"; // End N1 Loop 3 result.N1Loop.Add(n1Loop3); // Begin N1 Loop 4 var n1Loop4 = new Loop_N1_404_3(); // Entity Identifier Code = “SH” (Shipper) // Name = STERLING STAMPING // Identification Code Qualifier // = “93” (Code assigned by the organization // originating the transaction set) // Identification Code = 06215 n1Loop4.N1 = new N1(); n1Loop4.N1.EntityIdentifierCode_01 = "SH"; n1Loop4.N1.Name_02 = "STERLING STAMPING"; n1Loop4.N1.IdentificationCodeQualifier_03 = "93"; n1Loop4.N1.IdentificationCode_04 = "06215"; // Repeating N3 n1Loop4.N3 = new List <N3>(); // Address = 35777 VAN DYKE RD var n34 = new N3(); n34.AddressInformation_01 = "35777 VAN DYKE RD"; n1Loop4.N3.Add(n34); // City Name = STERLING HEIGHTS // State or Province Code = MI // Postal Code = 48312 n1Loop4.N4 = new N4(); n1Loop4.N4.CityName_01 = "STERLING HEIGHTS"; n1Loop4.N4.StateorProvinceCode_02 = "MI"; n1Loop4.N4.PostalCode_03 = "48312"; // End N1 Loop 4 result.N1Loop.Add(n1Loop4); // Repeating R2 result.R2 = new List <R2>(); // Standard Carrier Alpha Code = NS // Routing Sequence Code // = “R” (Origin Carrier, Rule 11 Shipment) // City Name = ESTL var r21 = new R2(); r21.StandardCarrierAlphaCode_01 = "NS"; r21.RoutingSequenceCode_02 = "R"; r21.CityName_03 = "ESTL"; result.R2.Add(r21); // Standard Carrier Alpha Code = BNSF // Routing Sequence Code // = “1” (1st Carrier after Origin Carrier) var r22 = new R2(); r22.StandardCarrierAlphaCode_01 = "BNSF"; r22.RoutingSequenceCode_02 = "1"; result.R2.Add(r22); // Repeating LX Loops result.LXLoop = new List <Loop_LX_404>(); // Begin LX Loop var lxLoop1 = new Loop_LX_404(); // Assigned Number = 1 lxLoop1.LX = new LX(); lxLoop1.LX.AssignedNumber_01 = "1"; // Repeating L5 lxLoop1.L5 = new List <L5>(); // Lading Line Item Number = 1 // Lading Description = AUTO PARTS // Commodity Code = 3714993 // Commodity Code Qualifier // = “T” (Standard Transportation Commodity // Code<STCC>) var l5 = new L5(); l5.LadingLineItemNumber_01 = "1"; l5.LadingDescription_02 = "AUTO PARTS"; l5.CommodityCode_03 = "3714993"; l5.CommodityCodeQualifier_04 = "T"; lxLoop1.L5.Add(l5); // Repeating L0 Loops lxLoop1.L0Loop = new List <Loop_L0_404>(); // Begin L0 Loop var l0Loop1 = new Loop_L0_404(); // Lading Line Item Number = 1 // Weight = 80,503 // Weight Qualifier = “N” (Actual Net Weight) // Lading Quantity = 42 // Packaging Form Code = “RCK” (Rack) l0Loop1.L0 = new L0(); l0Loop1.L0.LadingLineItemNumber_01 = "1"; l0Loop1.L0.Weight_04 = "80503"; l0Loop1.L0.WeightQualifier_05 = "N"; l0Loop1.L0.LadingQuantity_08 = "42"; l0Loop1.L0.PackagingFormCode_09 = "RCK"; // End L0 Loop lxLoop1.L0Loop.Add(l0Loop1); // End LX Loop result.LXLoop.Add(lxLoop1); return(result); }
/// <summary> /// Parse the message from EDI_Message and insert into entities. /// </summary> /// <param name="msg_type">Hard coded as "315"</param> /// <param name="msg_body">Message body that needs to be parsed</param> /// <param name="msg_idnum"></param> /// <returns></returns> public bool ParseMessage(string msg_type, string msg_body, int msg_idnum) { bool result = false; #region Initialize Variables string msgType = msg_type; string msgBody = msg_body; int msgIdnum = msg_idnum; string[] msgArr = null; string[] currentRowTemp = null; string[] currentRow = new string[30]; string header = ""; string logMsg = ""; int convertToInt = 0; decimal convertToDecimal = 0; EDI_Messages messages = new EDI_Messages(); Container container = new Container(); #endregion msgBody = Regex.Replace(msg_body, @"^\s+$[\r\n]*", "", RegexOptions.Multiline); msgArr = msgBody.Split(new[] { Environment.NewLine }, StringSplitOptions.None); foreach (string row in msgArr) { string msg; // Clear array before insert new row into array if (currentRowTemp != null) { Array.Clear(currentRowTemp, 0, currentRowTemp.Length); } if (currentRow != null) { Array.Clear(currentRow, 0, currentRow.Length); } // Insert data into dynamically allocated memory array, and // copy to statically allocated memory array. msg = row.Trim(); currentRowTemp = msg.Split(new[] { "*" }, StringSplitOptions.None); Array.Copy(currentRowTemp, 0, currentRow, 0, currentRowTemp.Length); // Begin to parse engine. header = ""; // Check whether the message header is valid or not. if (EDI315_headers.Any(x => x.ToUpper() == currentRow[0])) { header = currentRow[0]; } else { logMsg = util.buildLogMsg("ParseMessage", "Invalid format message."); util.insertLog_text(logMsg); result = false; break; } //Add parsed message into entity lists. if (row != null && row.Length > 0) { convertToInt = 0; convertToDecimal = 0; switch (header) { case "ISA": break; case "GS": break; case "ST": #region ST if (currentRow[1] == "315") { b4 = new B4(); q2 = new Q2(); n9_list = new List <N9>(); r4_list = new List <R4>(); } else { logMsg = util.buildLogMsg("ParseMessage", "ST: Invalid Transaction Set Identifier Code (ST01/143)."); util.insertLog_text(logMsg); } #endregion break; case "B4": #region b4.special_handling_code = currentRow[1]; Int32.TryParse(currentRow[2], out convertToInt); b4.inquiry_request_number = convertToInt; b4.shipment_status_code = currentRow[3]; b4.date = currentRow[4]; b4.status_time = currentRow[5]; b4.status_location = currentRow[6]; b4.equipment_initial = currentRow[7]; b4.equipment_number = currentRow[8]; b4.equipment_status_code = currentRow[9]; b4.equipment_type = currentRow[10]; b4.location_identifier = currentRow[11]; b4.location_qualifier = currentRow[12]; b4.equipment_number_check_digit = currentRow[13]; #endregion break; case "N9": #region N9 N9 n9 = new N9(); n9.reference_identification_qualifier = currentRow[1]; n9.reference_identification = currentRow[2]; n9.free_form_description = currentRow[3]; n9.date = currentRow[4]; n9.time = currentRow[5]; n9.time_code = currentRow[6]; n9_list.Add(n9); #endregion break; case "Q2": #region Q2 q2.vessel_code = currentRow[1]; q2.country_code = currentRow[2]; q2.date = currentRow[3]; q2.scheduled_sailing_date = currentRow[4]; q2.scheduled_discharge_date = currentRow[5]; Int32.TryParse(currentRow[6], out convertToInt); q2.landing_quantity = convertToInt; Decimal.TryParse(currentRow[7], out convertToDecimal); q2.weight = convertToDecimal; q2.weight_qualifier = currentRow[8]; q2.voyage_number = currentRow[9]; q2.reference_identification_qualifier = currentRow[10]; q2.reference_identification = currentRow[11]; q2.vessel_code_qualifier = currentRow[12]; q2.vessel_name = currentRow[13]; Decimal.TryParse(currentRow[7], out convertToDecimal); q2.volume = convertToDecimal; q2.volume_unit_qualifier = currentRow[15]; q2.weight_unit_code = currentRow[16]; #endregion break; case "R4": #region R4 R4 r4 = new R4(); r4.port_terminal_function_code = currentRow[1]; r4.location_qualifier = currentRow[2]; r4.location_identifier = currentRow[3]; r4.port_name = currentRow[4]; r4.country_code = currentRow[5]; r4.state_province_code = currentRow[6]; r4.dtm = new DTM(); r4_list.Add(r4); #endregion break; case "DTM": #region DTM DTM dtm = r4_list.Last().dtm; Int32.TryParse(currentRow[1], out convertToInt); dtm.date_time_qualifier = convertToInt; dtm.date = currentRow[2]; dtm.time = currentRow[3]; dtm.time_code = currentRow[4]; #endregion break; case "SE": #region SE UpdateDB(msg_idnum); #endregion break; case "GE": break; case "IEA": break; default: logMsg = util.buildLogMsg("ParseMessage", "Invalid header"); util.insertLog_text(logMsg); break; } } if (header == "IEA") { result = true; break; } } return(result); }