export data's to file

Hi,

I am deleting some records form one table.

Before I delete it, i need those data’s to be exported to a file called SaleExport located inside C:\Sale export folder.

what I did is, I created one dataport to export the data’s in that table, and I wanted to call that dataport inside this codeunit.

Any body help me to get the syntax for it ?

Regards,

Teeyech.

Hi,

any body please help. Will it work if I called one data port, which exports the data’s, inside the code unit ??

Regards,

Teeyech.

did you try to select the records you are going to delete in the table & copy & paste them into excel?

Hi,

I need it to be done by the code only, not manually…

When I call the dataport in the code unit, it loads the dataport but it does not execute to export the data’s.

it may be because we need to click ‘OK’ button in the data port right, and i do not no how to set the OK click in the POS.

Is it mandatory to use dataport.

You can use Excel Automation or Excel Buffer to export records.

sorry, and i do not no how to set the OK click in the code unit.[:P]

Hi Manish,

Can you advise me what is the function for that? My company is like, giving me project as if I am an expert.

I am a beginner, only 1 months left in codding.

Hi Manish,

Can you advise me what is the function for that? My company is like, giving me project as if I am an expert.

I am a beginner, only 1 months left in codding.

Please guide me how set the OK button click in the codeunit(possible?), so that the data port exports the data’s to file.

If that is done, this project is over.

Can you show your code written in codeunit?

Check Report ID. 6 Trial Balance for using excel buffer to export data in Excel.

Hi,

Now I changed my method, now I wrote codes to create a file inside C:\Transfer Header folder and tries to insert data’s from the Transaction Header table to it.

VTextFileName:=‘C:\Transaction Header\99001472.txt’;

FTextFile.TEXTMODE(TRUE);

FTextFile.WRITEMODE(TRUE);

FTextFile.CREATE(VTextFileName);

and the codes to insert records from the tables looks like below given:

VWriteText:=’"’+THRec.“Store No.”+’"’+’,’;

VWriteText:=’"’+THRec.“POS Terminal No.”+’"’+’,’;

VWriteText:=’"’+FORMAT(THRec.“Transaction No.”)+’"’+’,’;

…etc.

and the last

FTextFile.WRITE(VWriteText);

It creates the files in that location, But, it does not insert records in it, it only insert first one I given( ie, " ", )

why it does not write remaining records into it ?

[:@]

Its not the first line, its last line

Try

VWriteText:=’"’+THRec.“Store No.”+’"’+’,’;

VWriteText+=’"’+THRec.“POS Terminal No.”+’"’+’,’;

VWriteText+=’"’+FORMAT(THRec.“Transaction No.”)+’"’+’,’;

I guess THRec is blank

Simply write Message(’%1’,THRec.“Store No.”); and try…

I tried like that , but It shows blank.

And now, to test, I commented every other codes, and now my code is only as given below:

THRec.RESET;

THRec.GET;

MESSAGE(’%1’,THRec.“Store No.”);

it compiles, when I run it, It shows me ‘break on error’ in debug mode(pointer is at THRec.get), and error message ‘trasaction header does not exists’.

Transaction Header table (THRec) has values in it. It excutes when I try to delete the entries in it in this same code unit.

How many record do you expect in the text file.

You need to set TableNo of Codeunit to trasaction header

and pass deleting record to codeunit while deleting as

CODEUNIT.RUN(,Rec);

you need to use Rec.“Store No.” instead of THRec.“Store No.”);

ok, I will work on it and let you know… tnx.

It show’s as

’The codeunit th NY optimization code must be called with a Transaction Header record’.

Now my code is only as given below:

THRec.RESET;

THRec.GET;

MESSAGE(’%1’,“Store No.”);

CODEUNIT.RUN(59999,Rec);

Where did you write this code?

Did you set TableNo property of codeunit?

Hi,

It shows error when I run it.

The codeunit th NY optimization code must be called with a Transaction Header record.

below is the all code in that code unit.

RESET;

GET;

MESSAGE(’%1’,“Store No.”);

CODEUNIT.RUN(59999,Rec);

it compiles successfully, but when I ran it, it shows above error.

table property set to transaction header table, as you guided.

I given all these codes in OnRun