====== Creating a CSV PlugIn ======
In this HowTo you will learn the necessary conditions for implementing a CSV plug-in. In particular, the structure of the classes (with regard to interface and attributes) must be taken into account. In the following, you can follow the implementation using an ORDER sample csv file.
This csv sample works with following ORDER.CSV, containing a header and positions and a line identification in the first column, in this case SampleOrder for the header and Position for the items.
SampleOrder;1;test01.txt;2016-09-01 12:10:00;Recipient_123;Sender_4711;DocNumber_2
001;1;123456780;0.88;20
001;2;999999999;0.99;10
SampleOrder;2;test02.txt;2016-09-01 13:07:00;Recipient_123;Sender_4711;DocNumber_3
001;1;999999991;0.22;30
001;2;999999992;0.33;33
In order to map a plug-in for the structure shown above, certain prerequisites for the code must be adhered to, otherwise the SDF writer can not handle it correctly.
Let's start with the class **SampleOrderDocument**, which is derived from the interface **IMapObjectRoot**.
Within the code the plug-in always consists of a header and a list of items.
The MapExternalName attribute can be used to adjust the deviating names.
using System.ComponentModel;
using System.Collections.Generic;
using eBiss.Api;
public class SampleOrderDocument : IMapObjectRoot
{
[MapExternalName("SampleOrder")]
[MapTrigger]
public SampleOrder Header;
}
Within the header class, the reference to the **MapObjectRoot** interface is no longer required, instead a reference to the **MapObjectItem** is now made. Finally a list of positions that are passed through is expected.
public class SampleOrder : IMapObjectItem
{
[MapFrameDocumentNumber]
public string AuftragsNummer;
[MapFrameValue(MapFrameKeys.ContainerizationFilename)]
public string ContainerisationFilename;
[MapFrameDocumentDate, MapFormat("dd.MM.yyyy")]
public DateTime AuftragsDatum;
[MapFrameDocumentRecipient]
public string LieferantenNummer;
[MapFrameDocumentSender]
public string HerstellerNummer;
public string LieferantenAuftragsNummer;
[MapExternalName("001")]
public List Positionen;
}
With the [[en:transformation:mappings:objektdefinition:attribute|]] you can define e.g. the maximum length of the value, declare as required, where the document number is, etc.
public class SamplePosition : IMapObjectItem
{
public int Pos;
[MapSize(20)]
public string Ean;
public double EK;
public int Menge;
}
===== Read component setting =====
{{:images:sign_warning.png?nolink|}}**Note:** Processing CSV files with line types requires a specific setting of the read component of the entity type. The main parameters are here:
^parameter name ^ Value^
|Separator|Semicolon|
|RecordTagPosition|0|
|StartAtLine|1|