Skip to main content

Overview

In this tutorial, you will learn how to create a Micro Executor (ME) in RPGLE, which will expose two services that can be called by FUN. In particular, you will learn the basics of Smeup RPG services. You will learn how they are structured, how they work and how to design one. To complete this training you will try to implement one from scratch starting only from the required specifications. As prerequisites, the following are required:

  • Basic knowledge of IBM RPGLE language in fixed format for the development phase;
  • Ability to run a simple Java application for the database population phase;
  • Have a working Data environment running;

Architecture of standard Smeup Service

Smeup RPG services are programs written in RPGLE (fixed format) that implement the execution flow visible in the following diagram. service_diagram.svg The structure of a generic Smeup Service is composed of the following blocks/routines:

  • B£INIZI: subroutine that is executed before the MAIN block
  • MAIN Block: this is the main routine that the service execute during every call. It's composed of three elements:
    • IMP0: initialization subroutine, in which to insert all those operations to be carried out before the program execution (e.g. definition of the keys for file access)
    • SELECT block:
      • WHEN £UIBME=xxx.yyy: match when the fun.met defined in the FUN is xxx.yyy, then execute block (many times call a dedicated subroutine);
      • OTHER, that is called when on condition When is matched;
  • FIN0: closing subroutine, in which to insert all those operations to be carried out before the service completion.
  • £JAX_LOG: subroutine for specific application log.

FUN Execution

When a FUN is executed, Kokos searches for the indicated service, start the initialization and executes it. The first routine executed is £INIZI. Then the MAIN block is executed, where the IMP0 subroutines, the SELECT block and the FIN0 subroutine are called in sequence and finally the program is closed. If the program closes with the SETON RT instruction, then the £INIZI routine is not called on subsequent calls. During the initialization phase, the information passed to the FUN is saved in a series of variables that are available in the service scope. The variables are in the QILEGEN/£UIBDS member, the main ones being:

Name varDescription fieldDimension
£UIBPGComponent/Program10
£UIBFUFUN name10
£UIBMEFunction.Method10
£UIBTnType object n2
£UIBPnParameter object n2
£UIBKnCode object n2
£UIBPAParameters P()256
£UIBD1Input field INPUT()31000
£UIB35Error flag (*IN35)1

Suppose the following dummy FUN is executed: F(EXD;X1SCHEDA;GET.SCH) 2(MB;SCP_SCH;X1_SCH01) INPUT(This is an input). Then the variables will be valued as:

  • £UIBFU = 'X1SCHEDA'
  • £UIBME = 'GET.SCH'
  • £UIBT2 = 'MB'
  • £UIBP2 = 'SCP_SCH'
  • £UIBK2 = 'X1_SCH01'
  • £UIBD1 = 'This is an input'

Running the service requires the presence of /COPY: £PDS and £INZSR in the source

Service

As a guided exercise we will develop the service X1_X01_03, responsible for retrieving Activities from the database and returning them as a SmeupDataTable