Question Read JSON file to fill 3 temp-tables

NRN114

New Member
Hello All.

I try to read a JSON file from an existing inventory application. In this file I found "Bins", "Content" (section of Bin), and "Items".
The json is like that:
Code:
{
        "Bins": {
                "BinList": [{
                        "Barcode": "BIN0000930DC10",
                        "Rows": 2,
                        "vcolumns": 2,
                        "Content": [{
                                        "RowDivision": 2,
                                        "ColumnDivision": 2,
                                        "Articles": []
                                },
                                {
                                        "RowDivision": 1,
                                        "ColumnDivision": 1,
                                        "Articles": [{
                                                "ArticleId": "FM1317",
                                                "Quantity": 5
                                        }]
                                }
                        ]
                }]
        }
}
I created 3 temp tables, defined the relation. But when I use READ-JSON method, the field Barcode is filled first and second, table but not in the 3rd table. In fact, I think I can only catch the date on 1 level.

How can I fill the Barcode Field in all table ?
Thank you very much !!!

PS : I use OpenEdge 11.7.8, I attach the program and json file.

Code:
DEFINE TEMP-TABLE BinList NO-UNDO
    FIELD Barcode              AS CHARACTER format "x(15)"
    FIELD Rows                 AS CHARACTER
    FIELD vcolumns             AS CHARACTER
index idx1 is PRIMARY UNIQUE Barcode.

DEFINE TEMP-TABLE Content NO-UNDO
    FIELD Barcode              AS CHARACTER format "x(15)"
    FIELD RowDivision          AS CHARACTER format "x" label "Row"
    FIELD ColumnDivision       AS CHARACTER format "x" label "Col"
index indx2 is PRIMARY UNIQUE Barcode RowDivision ColumnDivision.

DEFINE TEMP-TABLE Articles NO-UNDO
    FIELD Barcode              AS CHARACTER format "x(15)"
    FIELD RowDivision          AS CHARACTER format "x" label "Row"
    FIELD ColumnDivision       AS CHARACTER format "x" label "Col"
    FIELD ArticleId            AS CHARACTER format "x(20)"
    FIELD Quantity             AS CHARACTER
index indx3 is PRIMARY UNIQUE Barcode RowDivision ColumnDivision ArticleId.

DEFINE DATASET Bins FOR BinList, Content, Articles
DATA-RELATION FOR BinList, Content
RELATION-FIELDS (BinList.Barcode, Content.Barcode)
DATA-RELATION FOR Content, Articles
RELATION-FIELDS (Content.Barcode, Articles.Barcode,
                 Content.RowDivision, Articles.RowDivision,
                 Content.ColumnDivision, Articles.ColumnDivision).

DATASET Bins:READ-JSON ("file", "testjson.txt", "empty").

Image 1472.png
 

Attachments

  • testjson.p
    1.5 KB · Views: 7
  • testjson.txt
    339 bytes · Views: 3
Last edited by a moderator:

Cecil

19+ years progress programming and still learning.
Interesting. I took your code and tested it in the ABL DoJo and it worked fine.
ProgressAblDojo

Code:
OpenEdge V. 12.5.0
Platform: Linux (x86_64)

Barcode         Rows     vcolumns
--------------- -------- --------
BIN0000930DC10  2        2

Barcode         Row Col
--------------- --- ---
BIN0000930DC10  1   1
BIN0000930DC10  2   2

Barcode         Row Col ArticleId            Quantity
--------------- --- --- -------------------- --------
BIN0000930DC10  1   1   FM1317               5
 
Last edited:

Cecil

19+ years progress programming and still learning.
Must be a bug... 12.2.7 does not display the Barcode.

Code:
OpenEdge V. 12.2.7
Platform: Linux (x86_64)

Barcode         Rows     vcolumns
--------------- -------- --------
BIN0000930DC10  2        2

Barcode         Row Col
--------------- --- ---
BIN0000930DC10  1   1
BIN0000930DC10  2   2

Barcode         Row Col ArticleId            Quantity
--------------- --- --- -------------------- --------
                1   1   FM1317               5
 
Top