Link

MiCaller API

Table of contents

  1. Description
  2. Features
    1. call
      1. 1. Without parameters
      2. 2. With parameters
    2. setListMaxRecords
    3. setDateFormat
  3. Considerations and Guidelines

Since: 0.1.0
Context: Any
Category: Integration

Description

This API can be used for MI calls in XtendM3

Features

call

There are two kinds of MI Call methods to be used: one with parameters and one without them.

1. Without parameters

Example:

public class TestProgram extends ExtendM3Trigger {
  private final ProgramAPI program
  private final ExtensionAPI extension
  private final InteractiveAPI interactive
  private final MICallerAPI miCaller
  private final LoggerAPI logger
  
  public TestProgram(ProgramAPI program, ExtensionAPI extension, InteractiveAPI interactive, MICallerAPI miCaller, LoggerAPI logger) {
    this.program = program
    this.extension = extension
    this.interactive = interactive
    this.miCaller = miCaller
    this.logger = logger
  }
  
  public void main() {
    String customer = null
    Closure<?> callback = { Map<String, String> response ->
      logger.info("Response = ${response}")
      if(response.CUNO != null){
        customer = response.CUNO  
      }
    }
    
    miCaller.call("CRS610MI","LstBySearchKey", callback)
    
    interactive.showOkDialog("Customer: " + customer)
  }
}

2. With parameters

Example:

public class TestProgram extends ExtendM3Trigger {
  private final ProgramAPI program
  private final ExtensionAPI extension
  private final InteractiveAPI interactive
  private final MICallerAPI miCaller
  private final LoggerAPI logger
  
  public TestProgram(ProgramAPI program, ExtensionAPI extension, InteractiveAPI interactive, MICallerAPI miCaller, LoggerAPI logger) {
    this.program = program
    this.extension = extension
    this.interactive = interactive
    this.miCaller = miCaller
    this.logger = logger
  }
  
  public void main() {
    String DSPname = interactive.display.fields.WRCUNM.toString();
    String DSPaddress = interactive.display.fields.WRCUA1.toString();
    String DSPpostalcode = interactive.display.fields.WRPONO.toString();
    String DSPtown = interactive.display.fields.WRTOWN.toString();
    
    Map<String, String> params = [ "SQRY":"CUNM:${DSPname}~ AND CUA1:${DSPaddress} AND PONO:${DSPpostalcode} AND TOWN:{DSPtown}".toString() ] // toString is needed to convert from gstring to string
    String customer = null
    Closure<?> callback = {
      Map<String, String> response ->
        logger.info("Response = ${response}")
        if(response.CUNO != null){
          customer = response.CUNO  
        }
    }
    
    miCaller.call("CRS610MI","SearchCustomer", params, callback)
    
    interactive.showOkDialog("Customer: " + customer)    
  }
}  

setListMaxRecords

This method sets the maximum amount of records to be returned by the MI Caller method when using a transaction list.
Example:

public class TestProgram extends ExtendM3Trigger {
  private final ProgramAPI program
  private final ExtensionAPI extension
  private final InteractiveAPI interactive
  private final MICallerAPI miCaller
  private final LoggerAPI logger
  
  public TestProgram(ProgramAPI program, ExtensionAPI extension, InteractiveAPI interactive, MICallerAPI miCaller, LoggerAPI logger) {
    this.program = program
    this.extension = extension
    this.interactive = interactive
    this.miCaller = miCaller
    this.logger = logger
  }
  
  public void main() {
    String DSPname = interactive.display.fields.WRCUNM.toString();
    String DSPaddress = interactive.display.fields.WRCUA1.toString();
    String DSPpostalcode = interactive.display.fields.WRPONO.toString();
    String DSPtown = interactive.display.fields.WRTOWN.toString();
    
    Map<String, String> params = [ "SQRY":"CUNM:${DSPname}~ AND CUA1:${DSPaddress} AND PONO:${DSPpostalcode} AND TOWN:{DSPtown}".toString() ] // toString is needed to convert from gstring to string
    String customer = null
    Closure<?> callback = {
    Map<String, String> response ->
      logger.info("Response = ${response}")
      if(response.CUNO != null){
        customer = response.CUNO  
      }
    }

    miCaller.setListMaxRecords(1)
    miCaller.call("CRS610MI","SearchCustomer", params, callback)
    
    interactive.showOkDialog("Customer: " + customer)    
  }
}  

setDateFormat

The setDateFormat method uses two parameters: character separator and date format. These are the allowed date formats: YMD8, YMD6, MDY6, DMY6, and YWD5.
Example:

public class TestProgram extends ExtendM3Trigger {
  private final ProgramAPI program
  private final ExtensionAPI extension
  private final InteractiveAPI interactive
  private final MICallerAPI miCaller
  private final LoggerAPI logger
  
  public TestProgram(ProgramAPI program, ExtensionAPI extension, InteractiveAPI interactive, MICallerAPI miCaller, LoggerAPI logger) {
    this.program = program
    this.extension = extension
    this.interactive = interactive
    this.miCaller = miCaller
    this.logger = logger
  }
  
  public void main() {
    if (program.getUser() != "CRIUBA36") {
      return 
    }
    String DSPname = interactive.display.fields.WRCUNM.toString();
    String DSPaddress = interactive.display.fields.WRCUA1.toString();
    String DSPpostalcode = interactive.display.fields.WRPONO.toString();
    String DSPtown = interactive.display.fields.WRTOWN.toString();
    
    Map<String, String> params = [ "SQRY":"CUNM:${DSPname}~ AND CUA1:${DSPaddress} AND PONO:${DSPpostalcode} AND TOWN:{DSPtown}".toString() ] // toString is needed to convert from gstring to string
    String customer = null
    Closure<?> callback = { Map<String, String> response ->
      logger.info("Response = ${response}")
      if(response.CUNO != null){
        customer = response.CUNO  
      }
    }
    
    miCaller.setDateFormat("/","YMD8")
    miCaller.call("CRS610MI","SearchCustomer", params, callback)
    
    interactive.showOkDialog("Customer: " + customer)
  }
}  

Considerations and Guidelines