Import more than 1000 Sales credit memo in navision 2009 r2

Hi,

One of my client wants to import 1000 sales credit memo in naviison.Do i have to create 2 separate dataports for sales credit memo hedaer & sales credit memo line.How about the validations of each field for all the two tables.Sometimes the dataport port field property validate doesnt wwork.The client wants this to be an automated thing & upload all the credit memo in one go with proper validations.Like when one enters a manual sales credit memo all validations takes place.If I use a data.port how do i make sure all validations are called.Can anyone throw some light on this scenario.Any examples would be good.

Thanks

naaz

Hi Naaz,

Generally I would never use a dataport to import sales headers and lines. At least not directly.

As you know, then the order in which the fields are entered, when you create sales header/line manually, matters. Like you start by insert(true), then validate the customer no. etc. If you do it in the wrong order, then it doesn’t create it correctly.

The same order of validation must be used when creating the sales header/line automatically.

So when I’m using a dataport/xmlport to import sales orders, then I would never import them directly into table 36/37. Instead I would start by importing them into a “buffer table” (either a copy of table 36/37, without any trigger code, or just the same tables in temporary mode).

This way I can complete the actual import of the files before I start creating the orders. Then with the buffer/temp-table I would create a function, which in the correct order would insert and validate the sales header/lines.

Thanks for the reply.Can you give me an example whcih will act as a guide in development.

If you by example means if I can show you the code, then I’m sorry, I don’t have the time. There is also no example in the standard database.

But I can give you the main structure:

  1. Create the dataport
  2. Import into temp/buffer tables
  3. The in the OnPostDataPort trigger you create the code which actually inserts the credit memo.

I created a dataport on my buffer table.

Onpostdataport i write this code but the number for sales header is not getting generated.

RecSalesHeder.“Document Type”:=BuffertableSC.“Document type” ;//onimort BuffertableSC.documenttype=Credit memo;

RecSalesHeder.VALIDATE(RecSalesHeder.“Sell-to Customer No.”,BuffertableSC.“Sell to customer no”);

RecSalesHeder.VALIDATE(RecSalesHeder.“Posting Date”,“BuffertableSC"Posting Date”);

MESSAGE(RecSalesHeder.“No.”);

RecSalesHeder.INSERT(TRUE);

Any imputs on this.

To create the new header you just have to do this:

[CODE]RecSalesHeader.INIT;

RecSalesHeader.“Document Type” := RecSalesHeader.“Document Type”::“Credit Memo”;

RecSalesHeader.INSERT(TRUE);[/CODE]

Then after this validate your customer no., date etc.

Hi Erik,thanks for the reply

RecSalesHeder.INIT;

RecSalesHeder.“Document Type”:=RecSalesHeder.“Document Type”::“Credit Memo”;

RecSalesHeder.INSERT(TRUE);

RecSalesHeder.VALIDATE(RecSalesHeder.“Sell-to Customer No.”,“BUffertaable”.“Sell to customer no”);

RecSalesHeder.VALIDATE(RecSalesHeder.“Posting Date”,“BUffertaable”.“Posting Date”);

RecSalesHeder.MODIFY(TRUE);

CLEAR(RecSalesLine);

RecSalesLine.“Document Type” := RecSalesHeder.“Document Type”;

RecSalesLine.“Document No.” := RecSalesHeder.“No.”;

RecSalesLine.“Line No.” := 10000;

RecSalesLine.INSERT(TRUE);

RecSalesLine.VALIDATE(RecSalesLine.Type,“BUffertaable”.Type);

RecSalesLine.VALIDATE(RecSalesLine.“No.”,“BUffertaable”.No);

RecSalesLine.VALIDATE(RecSalesLine.Quantity,“BUffertaable”.Quantity);

RecSalesLine.MODIFY(TRUE);

As of now,I am just adding these fields.Can you guide me as what other fields in both table I need to validate.Also when i need to ask the csv file from client how do i differentiate the header & which line is asscoaited with header table.

How to go in case if validation fails?

hi,

I was able to create the sales credit memo but i was wondering how do i catch validation errors if nay field is not validated.

RecSalesHeder.“Document Type”:=RecSalesHeder.“Document Type”::“Credit Memo”;

RecSalesHeder.INSERT(TRUE);

RecSalesHeder.VALIDATE(RecSalesHeder.“Sell-to Customer No.”,“BUffertaable”.“Sell to customer no”);

RecSalesHeder.VALIDATE(RecSalesHeder.“Posting Date”,“BUffertaable”.“Posting Date”);

Here the sales credit memo no is created & lets say the other fields are not validated.I wanna catch the error & also for 1000 credit memo I need to post them automatically.How do i figure out which credit memos were created?

Typically when I do stuff like this, then I start by validating the different fields, without actually using “VALIDATE”, this way I can catch the correct error and display it to the user, or as I typically do, insert the errors on an error log.

The advantage of doing this (instead of ERRORTEXT catching) is that you’re able to perform a full validate of all fields, without stopping the process.