Hi All,
I have written a codeunit with below function whose purpose is to cancel reservations and refresh the firm planned produciton order having source as FamilyNo passed as an argument.
**CancelAndRefreshProdOrder(FamilyNo : Text[30])**
//Purpose: Reserve the stock for the FamilyLines by refreshing the Production Order.
//Input: Family Number
//Output: Stock reserved only for the FamilyLines present in the Family record.
ProductionOrder.RESET;
ProductionOrder.SETRANGE(Status, ProductionOrder.Status::"Firm Planned");
ProductionOrder.SETRANGE("No.", FamilyNo);
IF ProductionOrder.FIND('-') THEN
BEGIN
ReservEntry.RESET;
ReservEntry.SETRANGE(ReservEntry."Source ID", ProductionOrder."No.");
ReservEntry.SETRANGE("Reservation Status", ReservEntry."Reservation Status"::Reservation);
IF ReservEntry.FIND('-') THEN
BEGIN
REPEAT
ReservEngineMgt.CloseReservEntry2(ReservEntry);
COMMIT;
UNTIL ReservEntry.NEXT = 0;
END;
COMMIT;
CURRENTTRANSACTIONTYPE := TRANSACTIONTYPE::Update;
ProdOrder.RESET;
ProdOrder.SETRANGE(Status, ProdOrder.Status::"Firm Planned");
ProdOrder.SETRANGE("No.", ProductionOrder."No.");
REPORT.RUNMODAL(REPORT::"Refresh Production Order",FALSE,TRUE,ProdOrder);
```END;`
When i run NAV 2009 Classic Client, the function is executed properly and the respective Firm Planned Production Order is refreshed to carry out reservation of required stocked components.
However, if i test this function in NAV 2009 RTC, it generates below error :
The error is generated at the line where i change the transaction type
i.e.
COMMIT;
CURRENTTRANSACTIONTYPE := TRANSACTIONTYPE::Update;
Before COMMIT, the transactiontype is UpdateNoLocks, which i change it to Update after the COMMIT so that the report "Refresh Production Order" runs in Update mode.
I am not sure why the error appears in RTC only inspite of the fact that i have changed the transaction type from UpdateNoLocks to Update.
If i do not put the COMMIT and do not set the transaction type then the same error is displayed in both Classic Client and RTC and the report is not executed.
Any idea what is going wrong here?
Is there anything to do with hiding the report request form/page by passing the argument as false when i call the report to run modally?
REPORT.RUNMODAL(REPORT::"Refresh Production Order",FALSE,TRUE,ProdOrder);
The 2nd argument above.
I also noticed that the TransactionType property of the report “Refresh Production Order” is set to Update.
So do i explicitly need to change the transactiontype before running the report?
Regards,
Hemant