InventProfitLossJournalService - Posting the transaction - AIF AX 2012

Hi,

I am using the InventProfitLossJournalService to create a new Stock Adjustment through the AIF and even though I am setting the Posted to Yes, when I look at the transaction in AX, it is still open and not posted. I am wondering what I have missed? Below is my code:

var client = new ProfitLossJournalServiceClient();

var context = new CallContext { Company = “btn” };

var journalHeader = new AxdEntity_InventJournalTable

{

JournalNameId = “COR”,

Description = “GI0001”,

Posted = AxdExtType_JournalPosted.Yes,

PostedSpecified = true,

PostedDateTime = new AxdExtType_JournalPostedDateTime

{

localDateTime = DateTime.Now,

localDateTimeSpecified = true,

timezone = AxdEnum_Timezone.GMT_DUBLIN_EDINBURGH_LISBON_LONDON,

timezoneSpecified = true,

Value = DateTime.Now

},

PostedUserId = “callumv”

};

var inventJournalTrans = new AxdEntity_InventJournalTrans

{

ItemId = “01020-11018”,

InventDim = new[]

{

new AxdEntity_InventDim

{

InventLocationId = “UXB”,

InventSiteId = “OST”,

WMSLocationId = “ZZ002”

}

},

TransDate = DateTime.Now,

TransDateSpecified = true

};

journalHeader.InventJournalTrans = new AxdEntity_InventJournalTrans[1] { inventJournalTrans };

try

{

client.create(context, new[] { journalHeader });

}

catch (Exception e)

{

var error = e.Message;

Console.ReadLine();

}