Hi there,
I'm trying to find out how I could write information about shipments (one line per address) to a CSV file. This file then needs to be imported into the shipping program of the customer. What I can find out is that I can not use dataports because you are not able to setup a grouping level. What would be the most elegant solution? I am thinking along two possible ways to go:
1. just creating a custom tabel and retrieve all information from the Sales order / shipping lines that I need and generate the shipping lines I need to export (then I could use a dataport I think);
2. or using a temporary table to hold the data and export this table in some way....
What is the best course to follow? Any suggestions?
CANE Microsoft Solutions BV
Prins Hendrikplein 14
2518 JC DEN HAAG
The Netherlands
http://www.cane.nl0
Comments
Why not just use a processing report and write the lines to a text file using the TEXTFILE.WRITE command ? At least then you can use multiple data items and group accordingley.
Dean.
So you have to create real table anyway unless you can use some existing table as base for custom table.
Instead of Dataport, you could just create the file in C/AL code and fill the file manually with needed data...
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
This is the code that manages the export:
Declarations: MyOutStream As OutStream
SHIPExportFile As FILE
ExportString As Text(250)
SHIPExportFile.CREATE('O:\SHIP\Zendingen.TXT');
SHIPExportFile.CREATEOUTSTREAM(MyOutStream);
IF SHIPLines.FIND('-') THEN REPEAT
ExportString := '';
ExportString := ExportString + PADSTR(SHIPLines.ShipToCustomer, 10, ' ');
ExportString := ExportString + PADSTR(SHIPLines.Name, 30, ' ');
ExportString := ExportString + PADSTR(SHIPLines.Address1, 30, ' ');
ExportString := ExportString + PADSTR(SHIPLines.ZipCode, 8, ' ');
ExportString := ExportString + PADSTR(SHIPLines.City, 30, ' ');
ExportString := ExportString + PADSTR(SHIPLines.Country, 2, ' ');
ExportString := ExportString + PADSTR(SHIPLines.Attn, 30, ' ');
ExportString := ExportString + PADSTR(SHIPLines.WhsShipCode, 10, ' ');
ExportString := ExportString + PADSTR(SHIPLines.SalesOrderNr, 10, ' ');
ExportString := ExportString + PADSTR(STRSUBSTNO('%1', SHIPLines.Collo), 10, ' ');
ExportString := ExportString + PADSTR(STRSUBSTNO('%1', SHIPLines.Weight), 10, ' ');
ExportString := ExportString + PADSTR(SHIPLines.Packing, 10, ' ');
MyOutStream.WRITETEXT(ExportString);
UNTIL SHIPLines.NEXT = 0;
SHIPExportFile.CLOSE;
Just one more problem to tackle... and that is that all lines are written in one long first export line. If anybody could give me a pointer on how to insert a CR/LF as the last character in the outputstring, I would be greatfull. I think I am going to experiment with the ArrayIndex and just put the 10 and 13 Char's in there... A bit ackward... but it seams to be the only way...? :-k
Prins Hendrikplein 14
2518 JC DEN HAAG
The Netherlands
http://www.cane.nl
ExportString[10+30+30+8+30+2+30+10+10+10+10+10+1] := 13;
ExportString[10+30+30+8+30+2+30+10+10+10+10+10+2] := 10;
Prins Hendrikplein 14
2518 JC DEN HAAG
The Netherlands
http://www.cane.nl
I want to export data in a text file in a format where i would have on the first line 6 characters and on the second line of the text file some more descriptions and on the third line something and then repeating the whole thing in a similar way. I am trying to do it with a codeunit.
Can somebody pls tell me how should i break the line on text file that it should go on the next line. Please help
Regards,
Toshita
Do It Yourself is they key. Standard code might work - your code surely works.
Thanks for the reply. I got few more questions related to it. Now in the spreadhseet format i got a field lines which is of type integer and its length in the spreadsheet is 4. How shud i write it on the text file
format(lines,4) is that correct ? and secondly gota decimal field whose length is defined as 5(7).5(2). How should that be written on text file.?
please advise
regards
toshita
Moving it up a bit
Cheers,
Toshita