IF PurchaserCode <>'' THEN BEGIN PurchHead."Buy-from Vendor No." := PurchaserCode; IF NOT Vend.GET(PurchHead."Buy-from Vendor No.") THEN BEGIN Vend.INIT; Vend."No." := PurchHead."Buy-from Vendor No."; Vend.INSERT; END; PurchHead.VALIDATE("Buy-from Vendor No.",PurchaserCode); PurchHead.VALIDATE("Shortcut Dimension 1 Code",Dept); PurchHead.VALIDATE("Shortcut Dimension 2 Code",SBC); PurchHead."Your Reference" := Notes; PurchHead.MODIFY; CurrDataport.SKIP; END ELSE ERROR('Employee has not been specified.');
Comments
then, why do you want to skip a line after you've done modifications?what do you think you'll skip?
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
maybe you can post your dataport and/or a sample of csv file?
anyway, i think that for complex importations, it's better to use a report and FILE functions
"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
40000,ADM,MERCEDES,Testing,Test Proj (Purchase Header)
(Empty Line)
5410,Mileage,115,0.4,GBP,,1,,5,46 (Purchase Lines)
This is the dataport
header
-
line
line
line
--
header
-
line
--
header
-
line
in this way it's difficult to figure out what dataitem you must fill in. for this reason, i suggest you to use a report or codeunit in order to manage the file as you want. (read the first line of the file, detect if it is an header or a line, insert the record in the appropriate table, go to the next line)
If you have the possibility to change the csv to import, you should create something like:
header
header
header
header
...
lastheader
[carriage return x 2]
line
line
line
...
last line
with this layout of the file, you can set the dataitemseparator property, then insert all the headers, and then all the lines
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
-purchase header (put your business logic for header in this dataitem)
-purchase lines (put your business logic for lines here)
set dataitemseparator properly (i think that the standard "<<NewLine><NewLine>>" fits for you) leave to nav the rest...
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
if you want to insert/modify data manually by code, just set "auto" insert, modify, rename properties of the dataport to NO and then manage your code.
"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
header data
(space)
line data
line data
line data
then your dataport will have both dataitems
Purchase Header
Purchase Line (not linked in anyway!)
Fileformat - Variable
Record Seperator <<NewLine>>
DataItemSeperator <<Newline><NewLine>>
I would create variables for the data you are importing.
Put the var's for the header in the purchase header Dataport fields.
put the var's for the lines in the purchase line dataport fields.
Onafterimportrecord for purchase header add your code to match your var's to their proper nav field validate where necessary. (going to need at least "Document type" & "No.")
Onafterimportrecord for purchase lines add your code to match your var's to their proper nav field validate where necessary. (going to need at least "Document Type", "Document no." & "Line no."
http://www.BiloBeauty.com
http://www.autismspeaks.org
2nd..Where are you defining a Purchase header? w/code?
3rd..try just importing a purchase order first before adding all the bells n whistles like skipping & inserting vendor's n stuff.
that can all come later.
Here's a post that I put the simplest of simple dataports.
It's for Sales Order - but easily changed to purchase orders.
You can use it as a guide to get your dataport at least importing. once you get that working then add Inserting new vendors & skipping etc.
viewtopic.php?t=16024
http://www.BiloBeauty.com
http://www.autismspeaks.org
I just had the exact issue with a similar dataport
You need to use CurrDataport.BREAK not CurrDataport.SKIP to go onto the next dataitem, Skip will only go onto the next record, Break will skip the current dataitem onto the next.
Hope that helps 'Tazzy'!!
http://www.BiloBeauty.com
http://www.autismspeaks.org