Hi,
I need to consume a web-service which provides a text return in CSV format (comma separated). I was thinking of doing this using an XMLPort.
The data will contain an ID linked to a Nav table, which will then modify the records in the table, with two or more other fields. This will be a daily process, so the amount of data may be quite large at times.
Has anyone ever implemented this? In the XMLPort, there are properties which allow text format so I assume it is possible to do so.
Thanks in advance.
0
Comments
the first one i have done by saving the result to a csv file. Then reading the csv file manually.
The Web-Service will return a string/text which will contain 3 fields (ID, and 2 other fields). The fields will be comma separated and each "record" will be filtered by a semi-colon;.
E.g.
ID Field1 Field2
1 20/09/2012 A
2 20/09/2012 B
3 20/09/2012 C
1,20/09/2012,A;2,20/09/2012,B;3,20/09/2012,C
NAV will then need to modify the records of a particular table for each "record".
You can do this by using the XmlPort import by designing the XmlPort using the temporary Integer table and then use RecordRef and FieldRef to point to the table and fields you want to insert values for.
Below is an sample xmlport object that can insert into a given table identified by the ID and then a couple of date and time fields.
OBJECT XMLport 50000 Sample code
{
PROPERTIES
{
Format=Variable Text;
}
ELEMENTS
{
{ [{0C6358F9-D6FF-46EA-84E4-C1A93947B2EC}]; ;Root ;Element ;Text }
{ [{1BD9C664-3DF7-490E-93A1-F62814E501CD}];1 ;Records ;Element ;Table ;
SourceTable=Table2000000026;
Temporary=Yes;
AutoSave=No;
Import::OnBeforeInsertRecord=VAR
VarDate@1000 : Date;
VarTime@1001 : Time;
VarID@1002 : Integer;
BEGIN
EVALUATE(VarID,ID);
RecRef.OPEN(VarID);
FieldRef1 := RecRef.FIELD(2);
EVALUATE(VarDate,Field1);
FieldRef1.VALUE(VarDate);
FieldRef2 := RecRef.FIELD(3);
EVALUATE(VarTime,Field2);
FieldRef2.VALUE(VarTime);
RecRef.INSERT;
RecRef.CLOSE;
END;
}
{ [{5EDA8113-81CD-4C26-A9F8-547655C1F450}];2 ;ID ;Element ;Text }
{ [{194DB95E-5A59-4E89-B7FB-60BA2896E8E1}];2 ;Field1 ;Element ;Text }
{ [{30DD09E5-445B-4406-8E0E-743A55981524}];2 ;Field2 ;Element ;Text }
}
CODE
{
VAR
RecRef@1000 : RecordRef;
FieldRef1@1001 : FieldRef;
FieldRef2@1002 : FieldRef;
}
}
Lars-Bo Christensen
Software Developer @ Microsoft