Project file:C:\Users\Demo\Desktop\TechForum2017 Mappningar\Rest\CRUD_Read.EDS
Date and time for documentation: den 7 december 2017 16:26

SOURCE file
File type: SQL
TARGET file
File type: JSON

### table group: SQL

Container type | Name | Data type | Mapping
--- | --- | --- | ---
virtual | Extract Id from metadata | Single occurance |
select | [Order] | Single occurance |
virtual | Check Order Id | Single occurance |
declare | Article | Max occurrences (2) | JSONDoc.Articles

### declare: Article

Parent: SQL

Container type | Name | Data type | Mapping
--- | --- | --- | ---
column | Id | varchar | JSONDoc.Articles.ArticleNr._value_
column | Quantity | bigint | JSONDoc.Articles.quantity._value_
where |  |  |
    WHERE [Order] = : orderid

### virtual: Check Order Id

Parent: SQL

Container type | Name | Data type | Mapping
--- | --- | --- | ---
edi-c code | code |  |
    if(SQLSTATE != "00000")
    {
    	argv[9] = "404";
    	sErrorResponseBody=readfile("C:/Users/Demo/Desktop/TechForum2017 Mappningar/Rest/404.html");
    	sErrorResponseBody = replace(sErrorResponseBody, "$$orderid$$", orderid);
    	//sErrorResponseBody = "404 - Not Found\r\nOrder with ID '" & orderid & "' not found";
    	return 0;
    }

### select: [Order]

Parent: SQL

Container type | Name | Data type | Mapping
--- | --- | --- | ---
column | Sender | varchar | JSONDoc.Sender._value_
column | Received | datetime | JSONDoc.Received._value_
where |  |  |
    WHERE Id = :orderid

### virtual: Extract Id from metadata

Parent: SQL

Container type | Name | Data type | Mapping
--- | --- | --- | ---
edi-c code | code |  |
    integer iTable = tableload ("table1",argv[8] , ":");
    string  url = tablematch (iTable, "X-Inobiz-URL");
    string orderid = filename(url); //Picks up the last section separated by "/"

### element: JSONDoc

Container type | Name | Data type | Mapping
--- | --- | --- | ---
element (_value_) | Sender | Single occurance | SQL.[Order].Sender
element (_value_) | Received | Single occurance | SQL.[Order].Received
element | Articles | Max occurrences (99999) : complex type | SQL.Article

### element: Articles

Parent: JSONDoc

Container type | Name | Data type | Mapping
--- | --- | --- | ---
element (_value_) | ArticleNr | Single occurance | SQL.Article.Id
element (_value_) | quantity | Single occurance | SQL.Article.Quantity

Mappings
- SQL..code
      integer iTable = tableload ("table1",argv[8] , ":");
      string  url = tablematch (iTable, "X-Inobiz-URL");
      string orderid = filename(url); //Picks up the last section separated by "/"
- SQL.[Order].Sender -> JSONDoc.Sender._value_ SQL.[Order].Received -> JSONDoc.Received._value_ SQL.[Order].
      WHERE Id = :orderid
- SQL..code
      if(SQLSTATE != "00000")
      {
      	argv[9] = "404";
      	sErrorResponseBody=readfile("C:/Users/Demo/Desktop/TechForum2017 Mappningar/Rest/404.html");
      	sErrorResponseBody = replace(sErrorResponseBody, "$$orderid$$", orderid);
      	//sErrorResponseBody = "404 - Not Found\r\nOrder with ID '" & orderid & "' not found";
      	return 0;
      }
- - SQL.Article -> JSONDoc.Articles SQL.Article.Id -> JSONDoc.Articles.ArticleNr._value_ SQL.Article.Quantity -> JSONDoc.Articles.quantity._value_ SQL.Article.
        WHERE [Order] = : orderid