WRKAPIMTH (DSPAPIMTH) - Work With API Methods

The Work With API Mathods (WRKPAPIMTH) command is used to maintani API metadata. In API matadata panel You can describe API program interface. Attributes can be defined either on general or method level.

NOTE: The (DSPAPIMTH) Display API Methods command shows the same data as WRKAPIMTH command but only with ability to display data. No possobility to maintain data.

NOTE: There is one parameter to this command: Subset selection (SUBSET). Following values are suported:

SUBSETDescription
*TOP(default) Each method is dieplayed only once regardless how many version of the same method are defined across subsets. Only methods defined for the highest (top) subsed are displayed.
*ALLAll methods defined for all subsed are displayed.

On the main panel the API method, sequence and program are displayed. The sequence is the numeric equivalent of subset. Following subsets are by default preloaded to Aperio:

SubsetSequenceDescription
*CUSTLOCAL1Customer dev, single sites
*CUSTCORP2Customer dev, multiple sites
*IBSLOCAL3Iptor dev, signle site (Reserved for Iptor development)
*IBSCORP4Iptor dev, multiple sites (Reserved for Iptor development)
*COUNDELTA5Country dev, delta release (Reserved for Iptor development)
*COUNTRY6Country dev, base release (Reserved for Iptor development)
*INTDEV7International development (Reserved for Iptor development)
*STDDELTA8Iptor standard, delta release (Reserved for Iptor development)
*STANDARD9Iptor standard, base release (Reserved for Iptor development)
*APIBASE99Base API level (Reserved only for internal Aperio API methods)

Note: Only *CUSTLOCAL and *CUSTCORP can be used by customers to define their own methods.

Form the main panel You can maintain the API method definition. Api method (program) parameters. It actualy describes the program interface. There is also possibility to maintain atributes defined on header level of method. Function keys leads You to the additional panels.

Funstion keyDescription of panel
F7=General ConfigGeneral configuration of Aperio. See WRKAPICFG command
F8=InfoMain information about current installation of Aperio backend. You can see there list of all elements of Aperio backend with their current location and version. Additionally there are statistics (Number of requests issud last day, month and year)
F9=General AttributesList of general attributes supported by all methods by default. Support of these attributes are incorporated inside Aperio backend and is not depend on program
F10=Common ParametersDefinition of common parameters which can be supported API program. Programer of RPG program can decide which of these parameters will be supported by RPG program. Each of common parameter is supported in Aperio frontend (mobile application generator). See common parameters description.

The Work with API Methods commands shows the datail description of RPG program interface. The program interface is retrieven on the fly dirrectly from RPG source code of program. There is general rule of showing data on WRKAPIMTH panels. The values can be displayed normaly or highlithed. If the value is highlited it means is retrieven from metadata files. Then it can be deleted or manualy changed. If the value is not highlited then it comes dirrctly from RPG source…. It still can be overwritten but can not be deleted. The main reccomendation is to not overwrite data which comes form RPG source. The best way is to change RPG source if needed. There are sometimes some cases where You have to overwite ptogram definition manually in metadata. It is allowed but not reccomended. Following options are available:

OptionDescription
1=AddAdd new API method
2=ChangeChange API Method
4=DeleteDelete API method. Note: Delete option will also delete all security set up connected to this method
5=DisplayDisplay API method
6=ParametersWork with parameters
7=AttributesWork with method attributes
8=Generate meta pseudo sourceGenerate meta pseudo source
9=Export methodsExports marked methods as objects to library or as save file. See Export chosen methods. See also EXPAPIDTA and IMPAPIDTA commands description

Work with method attributes

The attributes defined on method level are used in runtime. For this reason all attributes on method header level are kept in metadata in files even it hey orginates from RPG source. Note, all attributes on method header level are highlited. Following attributes are supported:

AttributeType of valueDescription
controltextList of supported control parameters coma divided. For example if program supports paging it should support following control parameters: offset, limit, total
httpMethodtext (DELETE, GET, PATCH, POST, PUT)One http method can be chosen. This method is used to generate openApi definition
openCrossRefBoolean (true, false)This attribute is strivtly connected to DC1 application. Inside DC1 we use crossref functionality to open files prior call program. This opening files process is also acompanied with security check. Most of DC1 programs require to open crossref befre they are caled. By default all programs which are existing in DC1 has this attribute set to true. If YOu use Aperio without DC1 set this attribute to false. There is exit program which opens files using crossref. (exit program id = S0001001). If in your environment You have any program which opens files prior call your program You can build Your own exit program. Then the openCrossRef can be set to true.
openFilestextThis attribute can be used instead of openCrossRef. You can define list of files coma divided which must be open prior your RPG program is called. NOTE: All files listed here wil be open for maximum access (Read and Write and Add)
structuretext (array, object)Defines the response structure.
tagstextInformational field only. Not connected to any functionality. It can contain list of tags (words) which describes Your API. fr example describe the module DIS, GEN, etc…

Pseudo source

This functionality allows You to generate pseudo source of your RPG program. The pseudo source will contain only metadata information (no any source code). This option is helpfull if You want to deliver Your API to the customer installation without source of program. Then you can generate pseudo source and deliver it. The other option is to speed up the metadata retcrievel process. It may happen that RPG program is long and fetch all information about interface of program dirrectly from source code will take long time. To speed up this process You can generate pseudo source and then use it one as reference to retrieve metadata informaton. The third case is, when You keep sources in format which can’t be for some reason analysed by Aperio metadata retrieval program. You can generate pseudo source and manually store there all description (parameters/attriutes) which are required.

NOTE: The generation of pseudo source will first clear current pseudo source then write information based on original program source. If You can’t access to original source, then do not use this option because it may clear your current pseudo source.

There is Exit program (id = R0034001) which is used to locate RPG program source. The following search order in included in this exit program:

  1. Try to locate program in the same library as RPG object in source file QMETASRC. If exist then leave.
  2. Try to locate program in the same library as RPG object in source file QRPGLESRC. If exist then leave.
  3. Try to retrieve RPG object information form IBMi operating system. If there is information about source file try to locate it. If exist then leave.

NOTE: The first source file searched is QMETASRC. It means if there is pseudo source generated, then it wil be taken into consideration instead of original source.

You can write Your own exit program which will follow your rules of finding RPG program source.

The pseudo source can be generated to any destination location. Before generation the panel is shown where user can choose destination location. The pseudo source can be generated only for documentaton reason.

Export chosen methods

By this opion You can export chosen methods. On the first panel You must confirm Your choice of method list to export. Then window will apear to provide the destination place for exported objects. The methods can be exported in two ways:

DeviceExport description
*LIBThe library need to be provided. The library must exist and must be empty. Exported methods will be placed in chosen library as set of phisical files.
*SAVF(Recommended) The library and save file must be provided. The library must exist. Save file will be created if not exist. The exported methods will be packed into savefile.

NOTE: The exporting process may take some time.

Work with parameters

On this view you can see what are the input parameters and output data suported by RPG program. The information on this panel is retrieven on the fly from RPG program source. If any field is highlited it means tha value was overwitten by user. The overwritten value is stored inside metadata files. Following informatin is presented on main panel:

ColumnDescripton
Parent parameterThis represents the group of parameters in request or response. Usually: “params” to indicate input parameters group, “data” simple response structure, “items” array response structure. See Define structure of response
SequenceSequence of appearing in RPG source code. In most cases it has no impact generate panels. There is only one ussage of this field. Whan You generate general mobile application panel without specifying the sequence of fields on form then this sequence is taken into consgeration by automatic builder.
ParameterInput/Output parameter name
AttrIndicates if parameter has any attribute defined. See Parameter attributes

Define structure of response

Aperio is prepared to handle all kind of structures of json response. But there is reccomendation to follow strict structure to be able to use methods to generate mobile applications. The recomended structure of response should be chosen from following proposales:

  • simple response: The returned information is set of simple values inside “data” object. Example:
 {
     "data":{"warehouse":"MKO", "availableQuntity": 5, "batchControlled":true}
 }
  • array (table) response: In this case all array records are returned as an json array whic is named “items”. The “items” object is put inside “data” object in json response. Example:
{
    "data":{
        "items":[
            {"warehouse":"MKO", "availableQuntity": 5, "batchControlled":true},
            {"warehouse":"MK1", "availableQuntity": 6, "batchControlled":true},
            {"warehouse":"MK2", "availableQuntity": 7, "batchControlled":true}
        ]
    } 
}

In first case, (simple response) all simple values are represented in metadata as parameters which has parent parameter “data”

In second case all columns in array are represented as parameters with parent parameter “items”. Additionaly there is one entry in metadata parameters:

  • parent parameter = “data”, parameter “items”. This definition has one attribute “structure” = “array”. This indicates to mobile application generator that “items” it is an array, and the table should be generated for mobile application panel.

Note: If the response of method do not follow one of two reccomended structures then generator of JForm panels may produce unexpected results.

Parameter attributes

The attributes defined on parameter level are used to generate panels by jforms generator. They are retrieved dirrectly from the source. There is possibility to overwrite the values but it is not reccomended. If something must be adjusted it is better to do it inside RPG program source. Following attributes are supported:

AttributeType of valueInput/OutputAbility to overwritte in JFormDecsription
activeBoolean (true, false)I/OYIndicate if field is active. If field is not active the JForms generator will generate this field as hidden.
allowBlankBoolean (true, false)IYIndicates if blank value is alowed for filed. If the allowBlank is set to false then empty field will not be send in request. If allowBlank is set to true then empty fields will be send in request. Generally this attribute is used for selection fields. The selsction fields are not sent to the requests if they are blank/zero. (Blank or Zero for selection field means no selection ofer this field)
descriptiontextI/ONDescription of field. Not used to generation og JForms panels
editableBoolean (true, false)IYIndicates if field is editable
formattext (date, date-time, float, int, json, time, 3-state)I/ONFormat of field
labeltextI/OYLabel of field
lengthnumberI/ONLength of field in characters or digits
mandatoryBoolean (true, false)INIndicates if imput parameter is mandatory
messageLinkedFieldtextI/ONFor future use.
referenceFieldtextI/ONDc1 related field which point to DC1 fref. By providing reference field most of attributes can be retrieven from DC1 fref database.
scalenumberI/ONValid for numeric fields. Defines number of decimals.
structuretext (array, object)ONDefines structure of output field. Used by JForm generator to render tables
translationcontexttextI/ONFor future use.
typetext (boolean, number, text)I/ONDefines type of field
uppercaseBoolean (true, false)I/OYIndicates if field is uppercase
visibleBoolean (true, false)I/OYindicates if field should be visible or hidden on generated panel
windowContexttextI/ONFor future use.
windowFromKeytextI/ONFor future use.
windowIdtextI/ONFor future use.
windowToKeytextI/ONFor future use.

Note: All attributes can be overwtritten in JForm definiton. The attributes provided in metadata describe the default value/behavior of field. Off course some attributes are strictly connected to field type coded in RPG program. It is pointless to change them. For example, manipulating attributes “type” or “lenght” in JForms is useless as this change do not have corresponding change in RPG source code.

Common parameters

Following common parameters are supported by mobile application generator:

Parent parameterParameterI/OTypeDescription
controlfreeTextSearchInputText (200 chars)Words, space divided, used to search trough database, used by Live search functionality
controllimitInputNumber (9,0)Maximum number of records in one response, used for pageing in table rendering.
controloffsetInputNumber (9,0)Start offset used for paging in table rendering.
controlstatisticsInput/OutputInput Boolean (true/false), Output Json (text)Indicate if statistics should be measured during call. Statistics are send back together with response.
controlfieldsInputText (200 chars)Words, space or coma divided, used to subset (limit) the response fields. To save on network bandwidth client can use this control parameter to receive smaller response.
controlmoreOutputBoolean (true/false)Indicates if there are more records in file, used for pageing in table rendering. If there is no possiblity to count total number of records programmer has possiblity to use this output parameter.
controltotalOutputNumber (9,0)Total number of records in file (array), use for pageing in table rendering.
controlorderByInputText (200 chars)Database fields space divided, which describes order of rows in response. There is possibility to use the response fields names. If the field name provided in this parameter is not supported by program to sort the response, then the apropriate message shoudl be generated by RPG program.