Using the Multiplex SubProg

It is recognised that not every object can be exposed through webservices due to the object being unsafe or the not having desired functionality/capability to be manipulated through webservices.

To counter these limitations, it is often necessary to use subprograms which provide the necessary interaction with the objects.

The Multiplex subprogram is allows you to map header & detail data (it cannot be any deeper) from IMan through to X3. IMan first serialises the data, where it is pushed through the webservice subprogram, where the data is then de-serialised into two arrays.

Installing the Multiplex

Creating the Script

  1. Create script in the your X3 folder with the name ‘ZMULTIPLEX’.
  2. Copy the contents of the file ‘X3MULTIPLEX.SRC’ to the script.
  3. Save and compile the script.

Exposing the Script

  1. Go to Development, Script Dictionary, Scripts, Subprograms (or equivalent in v6.x).
  2. Create a new subprogram.

  1. File
    • ZMULTIPLEX (per the script name).
  2. Subprograms
    • MULTIPLEXSUB
  3. Web Services
    • Checked
  4. Web Service Name
    • ZRLMPLEX
  1. In the Parameter Definition, select the DETAIL_DATA and change the dimension to 200. This value will allow a maximum of 200 lines to be entered in any single transaction.

  1. Save the Subprogram and publish it.

Adding your Code/Logic/Callout

Adding The Callout

This section will add the callout to your code.

  1. Open the ZMULTIPLEX script, move to line 61 & 62.
  2. Add a ‘WHEN’ clause to call out to your specific code. The text in the WHEN clause will be one of the arguments/fields which you specify when mapping the code.

  1. Save and compile the code.

Adding Your Code

There are two arrays and a variable you use to access the data being written in from IMan.

  • PARSED_HDR
    • A single dimension array containing the values of fields from the Header. The array is zero based, so the first field is PARSED_HDR(0), the second PARSED_HDR(1) and so on.
  • PARSED_DTL
    • A two-dimensional array containing the detail lines and their values, where the first index is the line, the second is the field.
      • For example:
      • PARSED_DTL(0,0) – The first field in the first line.
      • PARSED_DTL(2,3) – The foruth field in the third line.
  • LINE_IDX
    • Is an integer representing the line count i.e. the number of lines written in through the subprogram.

Returning Values

It is possible to return values back to IMan simply by setting the variables RTNFLD1 to RTNFLD8.

For example, the following would return to RTNFLD1 the value of an order number:

RTNFLD1 = SOHNUM_0

Example

The following example illustrates how both the three variables can be used.

The example is based on an SOH update routine to adjust the QTY and WALLQTY fields on existing orders. This update leverages an exposed SOH object, where the following code is called first (to update the QTY & WALLQTY), before the standard X3 SOH update is made.

ZZWSSOH$INITMAJ

WW_ACTION = "MODIFY"

WW_IDENT = PARSED_HDR(0)

Local Integer SOP_LINE

Local Char LINE_CHAR(20)

Local Integer QTY

Local Integer I : I=0

Local Integer LINE_FND

Local File SORDERQ [SOQ]

#Get the Order Number (PARSED_HDR(0))

For [SOQ] Where SOHNUM = PARSED_HDR(0)

NUMLIG_1(I) = I : QTY_1(I) = [F:SOQ]QTY

#Using LINE_IDX to parse through the lines.

For J=0 To LINE_IDX - 1

#Get the first field in the current line.

LINE_CHAR = PARSED_LINES(J, 0)

If LINE_CHAR <> ""

SOP_LINE= val(LINE_CHAR)

#Get the second field in the current line.

QTY = val(PARSED_LINES(J, 1))

If SOP_LINE = [F:SOQ]SOPLIN

NUMLIG_1(I) = I : WALLQTY_1(I) = QTY

if QTY > QTY_1(I)

NUMLIG_1(I) = I : QTY_1(I) = QTY

Endif

Break

Endif

Endif

Next J

I = I + 1

Next

#Process the new lines

For K=0 To LINE_IDX - 1

LINE_CHAR = PARSED_LINES(K, 0)

If LINE_CHAR = ""

QTY = val(PARSED_LINES(K, 1))

NUMLIG_1(I) = I

ITMREF_1(I) = PARSED_LINES(K, 2)

QTY_1(I) = QTY

WALLQTY_1(I) = QTY

I = I + 1

Endif

Next

NBLIG_1 = I

Close Local File [SOQ]

Return

Mapping Interface

This section describes how to use the mapping from within the IMan X3 connector screen.

Import Type

When the subprogram is published, you see an entry at the bottom of the import types for Subprogram – Realisable Multiplex Subprog.

Record Mapping

The Multiplex program has two levels (header and detail).

Header Field Mapping

  • GoSub Routine
    • This is value is the “WHEN” condition.
  • FLD1-FLD25
    • These are the input fields which are written to the PARSED_HDR array. FLD1 maps to the first (0) index, FLD2 to the second (1) index and so on.
  • RTNFLD1 – RTNFLD8
    • These are the return values set in your callout code.
  • SYS.ERROR & SYS.WARNING
    • The standard error and warning messages generated from X3.

Detail Field Mapping

  • FLD1-FLD25
    • These are the input fields which are written to the PARSED_HDR array. FLD1 maps to the first (0) index, FLD2 to the second (1) index and so on.