GET

LANSA Integrator

GET

The GET command is used to read the data from the inbound document object.

The GET command is integral part of loading data from a JSON document into your program. It must be preceded by the READ and the BIND commands.

 

                                                        Conditional

 

 GET ---------- LIST ---------- value ---------------------------->

 

            >-- FRAGMENT ------ value ----------------------------|

 

 

Keywords

LIST

This keyword is used to get a list from the loaded JSON document.

Refer to the Lists and Variables section below for further details on how to use this keyword.

This keyword is conditional.

FRAGMENT

This keyword is used to get a field fragment from the loaded JSON document.

Refer to the Lists and Variables section below for further details on how to use this keyword.

This keyword is conditional.

Comments / Warnings

You can only use one keyword at a time.

There are two ways in which you can read a list from an JSON document.

1.  You can either define the relevant section of the JSON elements as a list (using the JSON Binding Wizard), and use the LIST keyword in your GET command. This will retrieve the entire list in one go into a working list.

2.  Alternatively, you can define the relevant section as a collection of fragments (using theJSON Binding Wizard) and then use the FRAGMENT keyword in your GET command and place this in a loop.

See the Examples for details of how to do this.

Note: Fragments and Lists

The following points are important when using GET FRAGMENT and GET LIST together.

  • When you issue a GET FRAGMENT, that fragment becomes the current fragment. That is, the fragment pointer moves to the current one.
  • You need to read the fragments in an order that allows all fragments to be accessed. You can only access lists and child fragments once you have positioned the fragment pointer to its parent fragment. So, in a way, fragments are a bit like branches on a tree - to access lists and fragments further down the tree you will need to position the fragment pointer to the parent branch.
  • For example, when you issue a GET FRAGMENT, a GET LIST can only access lists within this current fragment. Therefore, you should read all the lists (using GET LIST) in the current fragment before you move on to another. Once you move onto another fragment, then the lists in the previous fragments will not be accessible. You may access the lists within a specific fragment in any order.
  • When a fragment becomes the current fragment it is marked as used, so once you leave it, it will not become the current fragment again.

Lists and Variables

If you are using the LIST keyword to return a list from the loaded document into your program, you will need to ensure the following steps are taken in your program.

1.  Define a working list that contains the fields that you are expecting from the JSON document.

2.  Use the SERVICE_LIST keyword with the LIST keyword in the GET command. The service list value should include the names of the fields in your working list without the '#'. The order of the fields should be defined here as they appear in the working list.

3.  In the TO_GET portion of the JSM_COMMAND Built-In Function, include the name of the working list that will hold the values returned.

If you are using the FRAGMENT keyword to return a field or group of fields, then you will need to add the SERVICE_EXCHANGE keyword with a value of '*FIELD'.

See the Examples for details on how to do this.

Examples

RDML

 

* Define JSM fields

DEFINE FIELD(#JSMSTS) TYPE(*CHAR) LENGTH(020)

DEFINE FIELD(#JSMMSG) TYPE(*CHAR) LENGTH(256)

DEFINE FIELD(#JSMCMD) TYPE(*CHAR) LENGTH(256)

 

* Define a list to hold the order line details

DEF_LIST NAME(#WRKLINES) FIELDS(#LINNUM #PARTNUM #PARTDSC #PARTAMT #PARTQTY) TYPE(*WORKING)

 

* Get SalesOrder Details

CHANGE FIELD(#JSMCMD) TO('GET FRAGMENT(SALESORDER) SERVICE_EXCHANGE(*FIELD)')

USE BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS #JSMMSG)

 

* Get Lines

CHANGE FIELD(#JSMCMD) TO('GET LIST(LINE) SERVICE_LIST(LINNUM,PARTNUM,PARTDSC,PARTAMT,PARTQTY)')

USE BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS #JSMMSG #WRKLINES)

 

RDMLX

 

* Define the fields used by the JSM Commands

Define FIELD(#JSMSTS) TYPE(*CHAR) LENGTH(020)

Define FIELD(#JSMMSG) TYPE(*CHAR) LENGTH(256)

Define FIELD(#JSMCMD) TYPE(*CHAR) LENGTH(256)

Define FIELD(#JSMHND) TYPE(*CHAR) LENGTH(4)

 

#JSMCMD := 'GET FRAGMENT(CUSTOMER) SERVICE_EXCHANGE(*FIELD)'

Use Builtin(JSMX_COMMAND) With_Args(#JSMHND #JSMCMD) To_Get(#JSMSTS #JSMMSG)