MTOLINK_PRP: Adding a rule

This entry point is used to ignore specific requests or resources in the calculation of assignments or to take into consideration specification assignment criteria together with the MTOLINK_RULES entry point.

Context and operating mode

On loading the grids (memory) of the requests and resources, it is possible to ignore the current order (in the [F:ORDB] class) by setting GPE to 1 or to value up to 3 user fields (chains of 50 characters max) by testing MTOLINK_PE_MODE:

- MTOLINK_PE_MODE = "D" for the requests:

TDEM_USRFLD1(NDEM)
TDEM_USRFLD2(NDEM)
TDEM_USRFLD3(NDEM)

- MTOLINK_PE_MODE = "R" for the resources:

TRESS_USRFLD2(NRESS)
TRESS_USRFLD2(NRESS)
TRESS_USRFLD3(NRESS)

All the orders concerned by the calculation are loaded to the memory. Moreover, for performances reasons, it is recommended to store all the elements to be taken into account there.
It is also recommended to add the user fields directly to the ORDERS table for enhanced performances.

In the code example provided below, the XUSRFLD user field is copied in the memory variable.

MTOLINK_RULES: Adding a rule

This entry point is used, jointly with the MTOLINK_PRP entry point, to trigger additional constraints (rules) in the assignment calculation algorithm.

Context and operating mode

At the beginning of the assignment calculation, the resource prioritization rules (see assignment rules) are loaded in memory with WUSRFLT(I_RULE)=1.

Immediately before, a first call is made in "activation mode" to the entry point MTOLINK_RULES with MTOLINK_PE_MODE  = 'ACT'. It is used to inform the calculation that:

- 1 or 3 additional priority and specific rules to take into account, by assigning WUSRFLT(WNBRULE)=2 and by incrementing the rule counter (WNBRULE)

- or to manage specific conditions added to the standard rule settings.

A second call is then made in "application mode" to the MTOLINK_RULES entry point with:

- MTOLINK_PE_MODE = 'APP' for a specific rule (if WUSRFLT(I_RULE)=2)

- MTOLINK_PE_MODE = 'BPP' for any specific or standard rule (irrespective of WUSRFLT(I_RULE))

Then set GPE to 1 to indicate the incompatibility between the current request (variables TDEM_...(I)) and the current resource (variables TRESS_...(K)) for the current rule (W...(I_RULE)).

Note: R_USRFLD1..3 = TDEM_USRFLD1..3 (I)

Example of usage

#----------------------------------------------------------------------------------
$ACTION

When "MTOLINK_PRP"           : Gosub MTOLINK_PRP
When "MTOLINK_RULES"         : Gosub MTOLINK_RULES
Endcase
Return

#----------------------------------------------------------------------------------
# Entry point triggered when loading demand(s) and resource(s) lists
# Can be use either to store user data (for later use when applying rules)
# Or to skip an order (return GPE = 1)
$MTOLINK_PRP
# in this example, we store XUSRFLD in user fields
GPE = 0
Case MTOLINK_PE_MODE
When "D": TDEM_USRFLD1(NDEM)   = [F:ORDB]XUSRFLD
When "R": TRESS_USRFLD1(NRESS) = [F:ORDB]XUSRFLD
Endcase
Return


#----------------------------------------------------------------------------------
# Here we use the user fields stored using MTOLINK_PRP entry point
# Assignments will only be generated for compatible user fields

$MTOLINK_RULES
Case MTOLINK_PE_MODE
When "ACT": # rule activation
WUSRFLT(WNBRULE) = 2
WNBRULE += 1
When "APP": # rule application
# matching user fields
GPE = 0
If TRESS_USRFLD1(K) <> TDEM_USRFLD1(I) : GPE = 1 : Endif
Endcase
Return

BEFMLKCRE: Before the creation of an assignment in the MTOLINK table

This entry point is used to take control before the creation of a new assignment record in the MTOLINK table.

Context and operating method

Transaction

There is one transaction in progress.

To cancel the transaction if there is a problem, the GOK variable must be set to 0.

Available screen and file classes

The buffer  [F:MLK1] is loaded at the moment of the entry point call.

The [M:MLIK] screen class is loaded with the call parameters to the MTOLINKLIB processing:

- [M:MLIK]STOFCY and [M:MLIK]ITMREF show the related product-site

- [M:MLIK]DEMTYP, DEMNUM, DEMLIN, DEMSEQ, DWIPTYP show the related request WIP

- [M:MLIK]RESSTYP, RESSNUM, RESSLIN, RESSSEQ, RWIPTYP show the related resource WIP

- [M:MLIK]MAJCOD shows the processing type

C

Creation of a new assignment

M

Modification of an assignment

A

Cancellation of an assignment

P

Proposal of new assignments generated based on the product-site assignment rule

Z

Resetting assignments related to a resource or a request

E

Entry of a resource

Open tables

In the table below, the significant content flag indicates that the content is in phase with the context (...).

Table

Abbreviation

Significant content

Table Title

MTOLINK

MLK1

Yes

Assignments

ORDERS

ORDB

No

WIPs

PARMTO

PTO

Yes if [M:MLIK]MAJCOD="P" or "E"

Assignment rules

BEFMLKUPD: Before the modification of an assignment in the MTOLINK table

This entry point is used to take control before the modification of an assignment record in the MTOLINK table.

Context and operating method

Transaction

There is one transaction in progress.

To cancel the transaction if there is a problem, the GOK variable must be set to 0.

Available screen and file classes

The buffer  [F:MLK1] is loaded at the moment of the entry point call. The call is performed within a For [MLK1] loop.

The [M:MLIK] screen class is loaded with the call parameters to the MTOLINKLIB processing:

- [M:MLIK]STOFCY and [M:MLIK]ITMREF show the related product-site

- [M:MLIK]DEMTYP, DEMNUM, DEMLIN, DEMSEQ, DWIPTYP show the related request WIP

- [M:MLIK]RESSTYP, RESSNUM, RESSLIN, RESSSEQ, RWIPTYP show the related resource WIP

- [M:MLIK]MAJCOD shows the processing type

C

Creation of a new assignment

M

Modification of an assignment

A

Cancellation of an assignment

P

Proposal of new assignments generated based on the product-site assignment rule

Z

Resetting assignments related to a resource or a request

E

Entry of a resource

Open tables

In the table below, the significant content flag indicates that the content is in phase with the context (...).

Table

Abbreviation

Significant content

Table Title

MTOLINK

MLK1

Yes

Assignments

ORDERS

ORDB

No

WIPs

PARMTO

PTO

Yes if [M:MLIK]MAJCOD="P" or "E"

Assignment rules

BEFMLKDEL: Before deleting an assignment from the MTOLINK table

This entry point is used to take control before deleting an assignment record from the MTOLINK table.

Context and operating method

Transaction

There is one transaction in progress.

To cancel the transaction if there is a problem, the GOK variable must be set to 0.

Available screen and file classes

The buffer  [F:MLK1] is loaded at the moment of the entry point call. The call is performed within a For [MLK1] loop.

The [M:MLIK] screen class is loaded with the call parameters to the MTOLINKLIB processing:

- [M:MLIK]STOFCY and [M:MLIK]ITMREF show the related product-site

- [M:MLIK]DEMTYP, DEMNUM, DEMLIN, DEMSEQ, DWIPTYP show the related request WIP

- [M:MLIK]RESSTYP, RESSNUM, RESSLIN, RESSSEQ, RWIPTYP show the related resource WIP

- [M:MLIK]MAJCOD shows the processing type

C

Creation of a new assignment

M

Modification of an assignment

A

Cancellation of an assignment

P

Proposal of new assignments generated based on the product-site assignment rule

Z

Resetting assignments related to a resource or a request

E

Entry of a resource

Open tables

In the table below, the significant content flag indicates that the content is in phase with the context (...).

Table

Abbreviation

Significant content

Table Title

MTOLINK

MLK1

Yes

Assignments

ORDERS

ORDB

No

WIPs

PARMTO

PTO

Yes if [M:MLIK]MAJCOD="P" or "E"

Assignment rules

MTOLINK_ENT2: Allocation of assigned requests to a resource

This entry point is used to take control upon entry of a resource (receipt or production reporting) in order to specifically manage the allocation of the assigned requests to the resource.

Context and operating method

Transaction

There is one transaction in progress.

To cancel the transaction if there is a problem, the GOK variable must be set to 0.

Available screen and file classes

The [M:MLIK] screen class is loaded with the call parameters of the MTOLINKLIB processing:

- [M:MLIK]STOFCY and [M:MLIK]ITMREF show the related product-site

- [M:MLIK]RESSTYP, RESSNUM, RESSLIN, RESSSEQ, RWIPTYP show the related resource WIP

- [M:MLIK]LIKQTY shows the resource quantity received in stock unit

- [M:MLIK]MAJCOD shows the processing type and equals "E" for Resource receipt

- [M:MLIK]TRTNAM equals "MTKMTOLIB" for production reporting, "PURMTOLIB" for a receipt

Use

A table of NDEM requests (TDEM_OFF, TDEM_TYP, TDEM_NUM, TDEM_MTO, TDEM_DAT) assigned to the received resource is created and sorted according to TDEM_OFF:

TDEM_TYP,TDEM_NUM,TDEM_DAT: type, number and end date of the request WIP

TDEM_MTO: qty assigned between the request and the resource

TDEM_OFF: sort order for the request, calculated based on the requests prioritization parameters of the assignment rule

The standard processing is as follows:

WREQQTY = [M:MLIK]LIKQTY: WCOVQTY = 0

For I=0 to NDEM-1

Read of the request(I) WIP

Gosub FILL_LINKD: # Assignment of [M:MLIK]DEMTYP, DEMNUM, DEMLIN, DEMSEQ, DWIPSTA, DWIPTYP based on the WIP

[M:MLIK]LIKQTY = min(TDEM_MTO(I), WREQQTY-WCOVQTY)

Gosub MAJ_MTO_ALLOCATION From =[M:MLIK]TRTNAM: # Allocation based on the assignment

WCOVQTY += [M:MLIK]LIKQTY

Update of the request(I) WIP with the assigned qty -= [M:MLIK]LIKQTY

If [M:MLIK]LIKQTY = TDEM_MTO(I)

Gosub MTOLINK_DEL: # Deletion of the assignment between the resource and the request(I)

Else

[M:MLIK]LIKQTY = TDEM_MTO(I) - [M:MLIK]LIKQTY

Gosub MTOLINK_MOD:# Modification of the assignment between the resource and the request(I)

Endif

If WCOVQTY >= WREQQTY: break: Endif

Next I

Update of the resource WIP with the assigned qty -= WREQQTY

Set the global variable GPE to 1 to inhibit this standard processing

Open tables

In the table below, the significant content flag indicates that the content is in phase with the context (…).

Table

Abbreviation

Significant content

Table Title

MTOLINK

MLK1

No

Assignments

ORDERS

ORDB

No

WIPs

ITMFACILIT

ITF

Yes

Products-Sites

PARMTO

PTO

Yes

Assignment rules