Значение в поле VoucherNumberSequenceTable недопустимо
и
Источник данных InventDim отсутствует в запросе
Я пытаюсь создать C# Служба WCF для добавления движения запасов AX 2012.
Структура AX 2012 — на стороне AX 2012 я создал запрос с помощью:
Код: Выделить всё
InventJournalTable
|->InventJournalTrans (as datasource)
|-->InventDim (as datasource)
|->InventJournalName (as datasource)
Входящий сервис
Axe query
И затем вызываю его из этого кода C#:
Код: Выделить всё
public string AddStock(AxInventoryConnectors Connection, string JournalNameId, string Description,string MainAccount, List items, string JournalId)
{
if (!Connection.IsConnected)
return string.Empty;
try
{
var client = Connection.clientInventJournal;
client.InnerChannel.OperationTimeout = TimeSpan.FromMinutes(30);
var journalHeader = new AxdEntity_InventJournalTable() { };
journalHeader.JournalId = JournalId;
journalHeader.JournalNameId = JournalNameId;
journalHeader.Description = Description;
journalHeader.JournalType = AxdEnum_InventJournalType.Movement;
journalHeader.JournalTypeSpecified = true;
journalHeader.VoucherNumberSequenceTable = new AxdEntityKey_NumberSequenceTable
{
NumberSequence = "Replaceme2",/*"Inve_14" */
NumberSequenceScope_DataArea = Connection.Context.Company,
NumberSequenceScope_LegalEntity_DataArea = Connection.Context.Company,
};
journalHeader.VoucherDraw = AxdEnum_JournalVoucherDraw.Post;
journalHeader.VoucherDrawSpecified = true;
journalHeader.RecId = 0;
journalHeader.RecIdSpecified = true;
journalHeader.action = AxdEnum_AxdEntityAction.create;
journalHeader.RecVersion = 1;
journalHeader.RecVersionSpecified = true;
AxdEntity_InventJournalTrans[] journalLines = new AxdEntity_InventJournalTrans[items.Count];
int i = 0;
foreach (var itm in items)
{
journalLines[i] = BuildLine(itm.itemId, itm.qty, itm.InventDimId, itm.Voucher, itm.Account, itm.TransDate, itm.CostPrice, itm.CostAmount, itm.InventLocationId, itm.InventSiteId, itm.InventSerialId, itm.InventLocationId);
i++;
}
journalHeader.InventJournalTrans = journalLines;
var InventJournalTable = new AxdEntity_InventJournalTable[] { journalHeader };
InventJournalServiceCreateRequest requestmov = new InventJournalServiceCreateRequest
{
CallContext = Connection.Context,
InventJournal = new AxdInventJournal
{
InventJournalTable = InventJournalTable
}
};
client.create(requestmov);
}
catch (Exception ex)
{
Console.WriteLine("Error in AddStock: " + ex.Message);
}
return string.Empty;
}
private AxdEntity_InventJournalTrans BuildLine(string itemId, decimal qty, string InventDimId,string Voucher,string Account, DateTime TransDate, decimal? CostPrice, decimal? CostAmount,string InventLocationId,string InventSiteId,string InventSerialId,string LocationId)//,
{
var line = new AxdEntity_InventJournalTrans
{
ItemId = itemId,
Qty = qty,
QtySpecified = true,
InventDimId = InventDimId,
CostPrice = CostPrice,
CostAmount = CostAmount,
Voucher = Voucher,
LineNum=1,
TransDate = TransDate,
LedgerDimension = new AxdType_DefaultAccount
{
MainAccount = Account//C0036
},
InventDim=new AxdEntity_InventDim1[] {
new AxdEntity_InventDim1() {
InventLocationId =InventLocationId,
InventSiteId=InventSiteId,
inventSerialId=InventSerialId,
wMSLocationId=LocationId
}
}
};
return line;
}
public class Item
{
public string itemId { get; set; }
public decimal qty { get; set; }
public string InventDimId { get; set; }
public decimal? CostPrice { get; set; }
public decimal? CostAmount { get; set; }
public string Voucher { get; set; }
public DateTime TransDate { get; set; }
public string Account { get; set; }
public string InventLocationId { get; set; } = "S28";
public string InventSiteId { get; set; } = "DIS";
public string InventSerialId { get; set; } = "356926093149835";
public string LocationId { get; set; } = "";
public string JournalId { get; set; } = "K01-007924";
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... cf-service