насколько мне известно, в текущем Net Connector 3 теперь есть помощник по idoc. Но если у вас есть файл, содержащий действительный idoc, у вас уже есть вся необходимая информация.
Основы отправки Idoc в систему SAP уже описаны здесь, поэтому я не буду вдаваться в подробности. в этом ответе. Чтобы отправить файл idoc, вам необходимо вручную заполнить контрольную запись (первая строка вашего idoc) и записи данных.
Контрольный стол требует некоторого ручного труда. К счастью, контрольная запись одинакова для всех idoc, так что вам не нужно учитывать тип idoc, который вы отправляете.
var fileStream = System.IO.File.OpenRead(fullFilepath);
var streamReader = new System.IO.StreamReader(fileStream);
string control = streamReader.ReadLine();
controlTable.Append();
controlTable.CurrentRow.SetValue("TABNAM", control.Substring(0, 10));
controlTable.CurrentRow.SetValue("MANDT", control.Substring(10, 3));
controlTable.CurrentRow.SetValue("DOCNUM", control.Substring(13, 16));
controlTable.CurrentRow.SetValue("DOCREL", control.Substring(29, 4));
controlTable.CurrentRow.SetValue("STATUS", control.Substring(33, 2));
controlTable.CurrentRow.SetValue("DIRECT", control.Substring(35, 1));
controlTable.CurrentRow.SetValue("OUTMOD", control.Substring(36, 1));
controlTable.CurrentRow.SetValue("EXPRSS", control.Substring(37, 1));
controlTable.CurrentRow.SetValue("TEST", control.Substring(38, 1));
controlTable.CurrentRow.SetValue("IDOCTYP", control.Substring(39, 30));
controlTable.CurrentRow.SetValue("CIMTYP", control.Substring(69, 30));
controlTable.CurrentRow.SetValue("MESTYP", control.Substring(99, 30));
controlTable.CurrentRow.SetValue("MESCOD", control.Substring(129, 3));
controlTable.CurrentRow.SetValue("MESFCT", control.Substring(132, 3));
controlTable.CurrentRow.SetValue("STD", control.Substring(135, 1));
controlTable.CurrentRow.SetValue("STDVRS", control.Substring(136, 6));
controlTable.CurrentRow.SetValue("STDMES", control.Substring(142, 6));
controlTable.CurrentRow.SetValue("SNDPOR", control.Substring(148, 10));
controlTable.CurrentRow.SetValue("SNDPRT", control.Substring(158, 2));
controlTable.CurrentRow.SetValue("SNDPFC", control.Substring(160, 2));
controlTable.CurrentRow.SetValue("SNDPRN", control.Substring(162, 10));
controlTable.CurrentRow.SetValue("SNDSAD", control.Substring(172, 21));
controlTable.CurrentRow.SetValue("SNDLAD", control.Substring(193, 70));
controlTable.CurrentRow.SetValue("RCVPOR", control.Substring(263, 10));
controlTable.CurrentRow.SetValue("RCVPRT", control.Substring(273, 2));
controlTable.CurrentRow.SetValue("RCVPFC", control.Substring(275, 2));
controlTable.CurrentRow.SetValue("RCVPRN", control.Substring(277, 10));
controlTable.CurrentRow.SetValue("RCVSAD", control.Substring(287, 21));
controlTable.CurrentRow.SetValue("RCVLAD", control.Substring(308, 70));
controlTable.CurrentRow.SetValue("REFMES", control.Substring(420, 14));
var dataLine = streamReader.ReadLine();
while (dataLine != null) {
dataTable.Append();
dataTable.CurrentRow.SetValue("SEGNAM", dataLine.SubString(0, 30));
dataTable.CurrentRow.SetValue("MANDT", dataLine.SubString(30, 3));
dataTable.CurrentRow.SetValue("DOCNUM", dataLine.SubString(33, 16));
dataTable.CurrentRow.SetValue("SEGNUM", dataLine.SubString(49, 6));
dataTable.CurrentRow.SetValue("PSGNUM", dataLine.SubString(55, 6));
dataTable.CurrentRow.SetValue("HLEVEL", dataLine.SubString(61, 2));
dataTable.CurrentRow.SetValue("SDATA", dataLine.SubString(63, dataLine.Length - 63));
dataLine = streamReader.ReadLine();
}
этот фрагмент ожидает один idoc в файле. Если у вас есть несколько idoc в одном файле, вам нужно разделить их, выполнив поиск контрольной записи (строка контрольной записи обычно начинается с «EDI_DC40»).
person
Dirk Trilsbeek
schedule
17.02.2016