Selected purchline records should pass to inventjournaltrans form

Hi All,

From last few days i’m stuck with one task.Can anyone please give the solutions for this issue.Advance Thank you…

Actually I created a form which will have only OPEN orders of purchlines.In that form i will have different purchlines with different ITEM’s Id Ex.Item1,Item2,Item3 like this.and i have checkbox in the grid.If i select this checkbox in purchlines of multiple records and click Update Post(second form).The UpdatePost form will open and i click OK button in second form**.**The selected records should go to inventjournalstrans form(i.e Inventjournal lines).**NOTE:**here if the Item1 has 10 records with qty different that should pass only one 1 record to inventjournaltrans with item1 and with sum of quantity of 10 records…

If anyone did’nt understand the abouve logic please tell i will explain it again…[:)]

Hi,

void CreateJournalMovement()
{

InventJournalTable journalTable;
InventJournalTrans journalTrans;
JournalTableData journalTableData;

InventJournalId journalId;
InventJournalName journalName;

;
ttsbegin;
journalName = InventJournalName::find([MyJournalName]);
journalTable.clear();
journalTable.JournalNameId=journalName.JournalNameId;

journalTableData = JournalTableData::newTable(journalTable);
journalTableData.initFromJournalName(journalTableData.JournalStatic().findJournalName(journalTable.journalNameId));

journalTable.JournalId = journalTableData.nextJournalId();
journalTable.Reservation = ItemReservation::Automatic;
journalTable.insert();

//=== Journal Trans ===//
journalTrans.clear();
journalTrans.JournalId = journalTable.JournalId;
journalTrans.JournalType = journalName.JournalType;
journalTrans.LedgerAccountIdOffset = journalName.LedgerAccountIdOffset;

journalTrans.ItemId = [MyItemId];
journalTrans.initFromInventTable(InventTable::find([MyItemId]),False,False);

// Importent

journalTrans.InventDimId = [MyInventDimId];

// Importent

journalTrans.TransDate = SystemDateGet();
journalTrans.Qty = [MyQty];
journalTrans.PriceUnit = [MyPriceUnit];
journalTrans.CostPrice = [MyCostPrice];
journalTrans.CostAmount = journalTrans.calcCostAmount();

journalTrans.insert();
ttscommit;

;

}

Based on journalType modify your code.

Hi Saju,

Thank you for the reply.

Yeah saju i already wrote the above code for my req. but the req. is some what tricky. i will explain you with the 1 example here.

i have items like item1,item2 etc. of purchlines in my form

if in my form i have 5 item1 records and 10 item2 record of purchline in a form then i should pass only 2 records in inventjournaltrans

1st record should be item1 with total or sum quantity of 5 records of item1 of purchlines in inventjournaltrans

2nd record should be item2 with total or sum quatity of 10 records of item2 of purchlines in inventjournaltrans

use group by keyword in select statement.