Dear All,
I have heard that in order to open a form from a code I have o user the commit Function before I call the form. which its working.
The problem is that Iam importing 5 lines from an excel tabel in the Gen. Journal Form. At the end of the code I commit the code and I call the form.
Now the problem is when I commit It take only the last line from the excel!!!
If I use the code without COMMIT, and I run my code hen I open the form manually I can see all lines!
I know my problem is in the commit function and with calling the form, how can I just open the form without commiting? ](*,) ](*,) ](*,) ](*,) ](*,)
Code:
// 13.01.15 ZD >>>>>>>>>>>>>>>>>>> HRS002
HotelTotalOpenEntries:=0;
ExcelTotalAmount:=0;
"Apply&PostedTotal":=0;
PostedTotal:=0;
CustLedgEntryLines.RESET;
CustLedgEntryLines.SETFILTER("Document Type",'%1',CustLedgEntryLines."Document Type"::Invoice);
CustLedgEntryLines.SETFILTER("Customer No.",'%1',CustomerNoPAR); // Hotel Number come from Excel lines
CustLedgEntryLines.SETFILTER(CustLedgEntryLines.Open,'%1',TRUE); // Only open Invoicses
IF (CustLedgEntryLines.FINDSET) THEN
IF (CustLedgEntryLines."Entry No." <> 0) THEN
// Getting Hotel Open entries total Sum fom Cust Ledger Entry:
REPEAT
CustLedgEntryLines.CALCFIELDS("Remaining Amt. (LCY)");
HotelTotalOpenEntries += CustLedgEntryLines."Remaining Amt. (LCY)";
UNTIL CustLedgEntryLines.NEXT=0;
//MESSAGE('Cust. Open Entries SUM TOTAL %1',HotelTotalOpenEntries);
// Getting Excel Total Amount for cutomer
"Import Gen. Journal Line".SETFILTER("Account No.",'%1',CustomerNoPAR);
"Import Gen. Journal Line".FINDSET; // To go to First line in the imported General Journal
REPEAT
ExcelTotalAmount +="Import Gen. Journal Line"."Credit Amount";
UNTIL "Import Gen. Journal Line".NEXT=0;
//MESSAGE('TOTAL EXCEL %1',ExcelTotalAmount);
// ! ! ! ! ! Case 1 , Total Hotel Open Entries are equal to Payment in Excel -- > Set ID THE POST ! ! ! ! !:
//***********************************************************************
"Import Gen. Journal Line".FIND('-'); // To go to First line in the imported General Journal
IF (HotelTotalOpenEntries=ExcelTotalAmount) AND (CustLedgEntryLines."Currency Code"="8_Currency Code") THEN
BEGIN
//MESSAGE('Case 1 Both total = "Apply Payment"');
TimeID:= TIME;
IF CustLedgEntryLines.FINDSET (TRUE,FALSE) THEN
REPEAT
"Apply&PostedTotal":="Apply&PostedTotal"+1; // Counter
"Import Gen. Journal Line"."Applies-to ID":= COPYSTR(FORMAT(TimeID) + 'T',1,20);
"Import Gen. Journal Line".MODIFY;
UNTIL "Import Gen. Journal Line".NEXT=0;
REPEAT
CustLedgEntryLines."Applies-to ID":= COPYSTR(FORMAT(TimeID) + 'T',1,20);
CustLedgEntryLines.MODIFY;
UNTIL CustLedgEntryLines.NEXT=0;
END
// Case 2:Payment in Excel <> Hotel Open Invoice---- > Just Post (Without setting ID);
// ************************************************************************
ELSE BEGIN
//MESSAGE('Case 2 Direct Post');
PostedTotal:=PostedTotal+1; // Counter
CODEUNIT.RUN(CODEUNIT::"Gen. Jnl.-Post","Import Gen. Journal Line"); //XXXXXXXXXXXX
END;
// RUN Form Gen. Journal;
// **********************
//Commit;
//"Import Gen. Journal Line".SETFILTER("Journal Template Name",'%1',JournalTemplateName);
//"Import Gen. Journal Line".SETFILTER("Import Gen. Journal Line"."Journal Batch Name",'%1',JournalBatchName);
//FormGJ.SETTABLEVIEW("Import Gen. Journal Line");
//FormGJ.RUNMODAL;[/color][/color][/color]
0
Comments
I think that there are remaining filters on "Import Gen. Journal Line" variable. Try to reset "Import Gen. Journal Line" after COMMIT;
COMMIT;
"Import Gen. Journal Line".RESET;
"Import Gen. Journal Line".SETFILTER("Journal Template Name",'%1',JournalTemplateName);
"Import Gen. Journal Line".SETFILTER("Import Gen. Journal Line"."Journal Batch Name",'%1',JournalBatchName);
FormGJ.SETTABLEVIEW("Import Gen. Journal Line");
FormGJ.RUNMODAL;
Dam I swear Iam trying since today morning and I didnot solve it. now its solved! Thanks 1000000000000 times \:D/ \:D/ \:D/ \:D/
With out the commit function I see all my lines in Gen. Journal form. But when I try to open the form from my code (what you just wrote to me). I see the Gen Journal form and I see all my entries but the Applied to ID is set only to the first two lines. Its as iff the Commit line insert the ID to the first line that its found and then it stops.
Again as I said without the commit function code works perfect! but with it I the code is not working correct. Hope you get what I mean