Hello Everyone,
I have a serious problem.
I have a text file(field delimiter= '|') that i have to import it to NAV.
I import this text file in to Sales Header(as order), and all the validation are ok. But if i trie to delete this order
it quits(navision closes) me out from NAVISION without any warning. Below are the strucure of text file and codeunit that i have done to import that text file. I can post the order without any problem. I also have made a dataport to import this text file into NAV, and it is importet and you can delete it without any problem.
Can some body tell me when i am wrong, or making mistake.
Thanks.
Sales Header text file whith to rows
D10|30|D10|19/11/2010||1||5
D10|31|D10|19/11/2010||1||10
IF FileCreated.OPEN(Path+'Headers.txt') THEN
BEGIN
FileCreated.CREATEINSTREAM(InstreamObj);
//InstreamObj.READTEXT(Rreshtitxt,1024);
WHILE NOT (InstreamObj.EOS) DO
BEGIN
MaxLength:=InstreamObj.READTEXT(Rreshtitxt,1024);
PikeOccurence:=STRPOS(Rreshtitxt,'|');
SalesHeader.RESET;
SalesHeader.INIT;
SalesHeader."Document Type":=2;
// GET e lokacionit - jo real
SHLocations:=COPYSTR(Rreshtitxt,1,PikeOccurence-1);
Rreshtitxt:=DELSTR(Rreshtitxt,1,PikeOccurence);
//GET No te fatures
PikeOccurence:=STRPOS(Rreshtitxt,'|');
SHNo:=FORMAT(COPYSTR(Rreshtitxt,1,PikeOccurence-1));
Rreshtitxt:=DELSTR(Rreshtitxt,1,PikeOccurence);
IF SHNo<>'' THEN
BEGIN
SalesHeader."Document Type":=1;
SalesHeader.VALIDATE(SalesHeader."Document Type");
SalesHeader."No.":=SHNo;
SalesHeader.VALIDATE(SalesHeader."No.");
SalesHeader."No. Series":='SO';
SalesHeader."Posting No. Series":='SI';
SalesHeader."Shipping No. Series":='SS';
END;
//GET Lokacionit real
PikeOccurence:=STRPOS(Rreshtitxt,'|');
SHLocations:=COPYSTR(Rreshtitxt,1,PikeOccurence-1);
Rreshtitxt:=DELSTR(Rreshtitxt,1,PikeOccurence);
//GET Dates se fatures
PikeOccurence:=STRPOS(Rreshtitxt,'|');
EVALUATE(SHPostingDate,COPYSTR(Rreshtitxt,1,PikeOccurence-1));
Rreshtitxt:=DELSTR(Rreshtitxt,1,PikeOccurence);
IF SHPostingDate<>0D THEN
BEGIN
SalesHeader."Posting Date":=SHPostingDate;
SalesHeader.VALIDATE(SalesHeader."Posting Date");
SalesHeader."Document Date":=SHPostingDate;
SalesHeader.VALIDATE(SalesHeader."Document Date");
SalesHeader."Order Date":=SHPostingDate;
SalesHeader.VALIDATE(SalesHeader."Order Date");
SalesHeader."Shipment Date":= SHPostingDate;
SalesHeader.VALIDATE(SalesHeader."Shipment Date");
END;
SalesHeader."Sell-to Customer No.":=Klienti;
SalesHeader.VALIDATE(SalesHeader."Sell-to Customer No.");
SalesHeader."Location Code":=Lokacioni;
SalesHeader.VALIDATE(SalesHeader."Location Code");
// GET Sales Person-it
PikeOccurence:=STRPOS(Rreshtitxt,'|');
SHSalesPerson:=FORMAT(COPYSTR(Rreshtitxt,1,PikeOccurence-1));
Rreshtitxt:=DELSTR(Rreshtitxt,1,PikeOccurence);
IF SHSalesPerson<> '' THEN
BEGIN
SalesHeader."Salesperson Code":=SHSalesPerson;
SalesHeader.VALIDATE(SalesHeader."Salesperson Code");
END;
//GET Sell To Customer No
PikeOccurence:=STRPOS(Rreshtitxt,'|');
SHSelltoCustomer:=COPYSTR(Rreshtitxt,1,PikeOccurence-1);
Rreshtitxt:=DELSTR(Rreshtitxt,1,PikeOccurence);
//GET User Code Loged In
PikeOccurence:=STRPOS(Rreshtitxt,'|');
SHUserCodeLogedIn:=FORMAT(COPYSTR(Rreshtitxt,1,PikeOccurence-1));
Rreshtitxt:=DELSTR(Rreshtitxt,1,PikeOccurence);
SalesHeader."User Code Loged in":=FORMAT(SHUserCodeLogedIn);
//GET Invoice Discount %
//PikeOccurence:=STRPOS(Rreshtitxt,'|');
EVALUATE(SHInvoiceDiscount,Rreshtitxt);
Rreshtitxt:=DELSTR(Rreshtitxt,1,PikeOccurence);
IF SHInvoiceDiscount<>0 THEN
BEGIN
SalesHeader."Invoice Discount Calculation":=1;
SalesHeader.VALIDATE(SalesHeader."Invoice Discount Calculation");
SalesHeader."Invoice Discount Value":=SHInvoiceDiscount;
SalesHeader.VALIDATE(SalesHeader."Invoice Discount Value");
END;
IF NOT SalesHeader.INSERT THEN SalesHeader.MODIFY;
END;
FileCreated.CLOSE;
END;
0
Answers
And when i pres F5 it closes the NAV.
GetMfgSetUp()
IF NOT HasGotMfgSetUp THEN
HasGotMfgSetUp := MfgSetup.GET;
I have created a codeunit in NAV, and it can delete orders imported from text file.
In Sales Order form i can delete only the orders that are created in Sales Order form, or imported from dataport.
But still i can not delete those orders imported by codeunit.
Salesheader.DELETE;
this doesn't fire the ondelete trigger in the table (but you must run it!).
If you instead correctly wrote Salesheader.DELETE(TRUE) there can be something written in the ondelete trigger of the FORM (that is not run from the codeunit, because you're firing the ondelete of the table with delete(true).
anyway, you have to investigate your debugger with the use of the "call stack", too
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
This situation is geting harder, and i am been confused now. Why to quit NAVISION without any warning, without stoping at some points.
It seem to be my problem, so i solved by my self.
Thanks. \:D/
but the for each of line must end with ";"
example :
but my sample data is like this
how to solve this problem? thanks
If your line in .txt file does not end with ';' than for the last field you don't have to use delstr, but just get the value of that field.
my code already block 1 line like this
but still have error message
please take a look at my attachment
Here is the syntax:
NewString := DELSTR(String, Position [, Length])
And this should be like this.
vString:=DELSTR(vString,PosCode,1);
TestImport.Address:=FORMAT(vString);
as you told me, i already reversed it
but the error message is still the same
Code :
New error
just use:
String:=DELSTR(vString,1,PosCode);
instead of
String:=DELSTR(vString,PosCode,1);
#-o
hi bekio
now it works
thanks a lot for your help
the final code is like this
Glad to help you,