Entry points > Module Stock > Standard script FUNCBN 

LECORD: Reading an ORDERS record

Filter on the orders in process in the net requirements calculation.

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called in the net requirements calculation (MRP and MPS) on reading with the lock on each record in the ORDERS table for the creation of the calculation header work file.

Classes and available variables

Variable

Definition

Class [F:CBH]

Contains the data being processed

(Site, product...)

Class [F:ORD]

Contains the ORDERS record

Integer variable I

Set to I = 0 to process the order

Set to I = 1 to ignore the order

STRSTO: Starting stock calculation

Requirements calculation starting stock

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called before the posting of each record in the CBNHEA ([F:CBH]) table.

The starting stock field is already calculated and it can be modified depending on the context.

Variables

Variable or mask

Definition

WPRO

Contains 1 if MPS

Contains 2 if MRP

 

Open tables

All the requirements calculation tables

CALCOUV: Coverage calculation

Non-standard calculation of the coverage for all the buckets.

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called on the calculation of the coverage for the products concerned.

Open tables

All the requirements calculation tables

 [CBH] Work file header loaded

 [ITF] Product-site loaded

 

Available variables

  Variables on entry

WNBBUC                  Number of buckets

WNBJOU                  Number of days processing (End date - starts date +1)

WBUCDEB(0..WNBBUC-1)             Bucket start date grid

WBUCFIN(0..WNBBUC-1)              Bucket end date grid

WQTY(0..WNBJOU-1)                    Requirements grid day by day

 I                                                          Indicator = 0

  Variables to be returned

   WCOUV(0..WNBBUC-1)       Coverage grid by bucket

    I  = 0                    If the standard calculation should be carried out 

I <> 0                   If the coverage grid has been loaded by the entry point

AFTREAPCB: Read of calculation parameters

Processing start for a site

Context and operating mode

Transaction

There is no transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called in the net requirements calculation (MRP and MPS) after reading the requirements calculation parameters (PARMRP table) and before loading the parameters in work variables. The contents of the record can be modified in order for other setup values to be taken into account.

Classes and available variables

Variable

Definition

WPRO

Contains 1 if MPS

Contains 2 if MRP

Class [F:PCB]

Contains the site parameters

 

Open tables

All the requirements calculation tables

BEFWRICBH: Before writing work table header

Entry point before posting each record in the work table CBNHEA / PDPHEA

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called in the net requirement calculation (MRP and MPS) after loading the class buffer [CBH].

The records in the CBW table (work table for the expired lots) have already been written.

Classes and available variables

Variable classes

Definition

Class [F:CBH]

Contains the data giving arise to the posting

WPRO

Contains 1 if MPS    Contains 2 if MRP

 

Open tables

All the requirements calculation tables

BEFWRICBD: Before writing work table detail

Entry point before the posting of each record in the work table CBNDET / PDPDET

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called in the net requirement calculation (MRP and MPS) after loading the class buffer [CBH] from the ORDERS table.

Classes and available variables

Variable classes

Definition

Class [F:CBH]

Contains the header data for the processed product

Class [F:CBD]

Contains the buffer giving rise to the posting

WPRO

Contains 1 if MPS   Contains 2 if MRP

 

Open tables

All the requirements calculation tables

CRESUG: Suggestion creation in work table

Entry point before posting each suggestion in the work table CBNDET / PDPDET

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called in the net requirement calculation (MRP and MPS) after loading the class buffer [CBH] for each purchase or production suggestion.

The buffer is loaded with the exception of the 'start date', 'end date' and 'requirement date' fields.  The WDATS variable contains the reference date for the creation of the suggestion (requirement date), it can be modified to have an affect on the suggestion dates.

 

Classes and available variables

Variable classes

Definition

Class [F:CBH]

Contains the header data

Class [F :ITF]

Contains the product-site management data

Class [F:CBD]

Contains the buffer giving rise to the posting (except the date fields)

Date variable WDATS

Contains the reference date for the creation of the suggestion.This date can be modified to have an impact on the suggestion dates.

WPRO

Contains 1 if MPS   Contains 2 if MRP

 

Open tables

All the requirements calculation tables

ENDSTEP4: After phase 4 (generation of the MRP detail file )

Entry point at the end of phase 4

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called at the end of phase 4 (generation of the CBNDET table). It makes it possible, for example, to warn the user of the end of this phase by sending a message.

Classes and available variables

Variable classes

Definition

Class [F:CBH]

Contains the data giving arise to the posting

WPRO

Contains 1 if MPS    Contains 2 if MRP

 

Open tables

All the requirements calculation tables

ENDSTEP6: After phase 6 (update of the WIP)

Entry point at the end of phase 6

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called at the end of phase 6 (update of the ORDERS file). It makes it possible, for example, to warn the user of the end of this phase by sending a message.

Classes and available variables

Variable classes

Definition

Class [F:CBH]

Contains the data giving arise to the posting

WPRO

Contains 1 if MPS                                                     Contains 2 if MRP

 

Open tables

All the requirements calculation tables

CUSMODLTI: Modification of the quality control lead-time for the work orders

Possibility to modify the quality control lead-time for the works orders.

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called in the net requirement calculation (MRP and MPS) at the time of the write to the detail work file ([F :CBD], just after having recovered the quality control lead-time for the orders of the types WOF and WOP.It is used to modify the value of the lead-time, via the assignment of the work variable "Q".

Classes and available variables

Variable

Definition

Class [F:CBH]

Contains the data being processed

(Site, product…)

Class [F:ORD]

Contains the ORDERS record

Variable integer Q

Contains the QC lead-time.

If required assign another value to this variable.

 

Open tables

All the requirements calculation tables

MRPQTYSUG: Modification of the quantity to reorder

Possibility to modify the quantity to be reordered.

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called in the calculation of net requirements (MPS and MRP) during the phase of the suggestions calculation for products managed in stock.It is used to intervene in the quantity to be reordered.

In all the cases, the standard process takes control of applying any loss and to generate the corresponding suggestion(s) whilst respecting the reorder strategy (net/economic quantity, sub-division...).

Classes and available variables

Variable

Definition

Class [F:CBH]

Contains the data being processed

(Site, product …)

Variable decimal WBES

Contains the quantity to be reordered calculated as standard.

If required assign another value to this variable.

 

Open tables

All the requirements calculation tables

COR_STOSEC: Application of the seasonal nature of the safety stock

Possibility to replace the standard application mode for the seasonality of the safety stock.

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called in the calculation of net requirements (MPS and MRP) during the phase of the suggestions calculation.It is used to intervene in the application of seasonality to safety stock.

In all the cases, the standard process takes control of applying any loss and to generate the corresponding suggestion(s) whilst respecting the reorder strategy (net/economic quantity, sub-division...).

Classes and available variables

Variable

Definition

Class [F:CBH]

Contains the data currently being processed (Site, product…)

Class [F :ITF]

Contains the data for the product/site processed

Date variable WDAT

Contains the start date for the bucket concerned

Variable decimal WSAISON

This variable must be loaded with the calculated safety stock

Global variable GPE

To be set to 1 to inhibit the standard seasonality application.

 

Open tables

All the requirements calculation tables

XTRA_ORD: Taking into account of the WIP for additional products

This entry point is used to add WIPs for additional products

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called in the calculation of net requirements (MPS and MRP) at the end of the product WIP loading phase. It is used to integrate additional WIPs, for instance coming from another site.

Example of an addition algorithm:

###########################################################################

$ACTION

Case ACTION

   When "XTRA_ORD" : Gosub XTRA_ORD

Endcase

Return

 

#---------------------------------------------------------------------

$XTRA_ORD

Filter [ORD] Where STOFCY = "XXX" &

&                  ITMREF = [F:CBH]ITMREF &

&                  FMI < 2 &

&                  WIPSTA < 4

&             Order By Key ORD1

 

For [ORD]

    Readlock [ORD] Curr

    If fstat = 0

        I = 0

        If [F:ORD]ENDDAT <= WCALDATF

            If I = 0

                # Important: reset the site on [ORD] because of the transclass [CBD] = [ORD] in TRT_ORD

                [F:ORD]STOFCY = [F:CBH]STOFCY

                Gosub TRT_ORD From FUNCBN

                If GOK <>1

                    Break

                Endif

            Endif

        Endif

    Else

        GOK = -1

        Break

    Endif

Next

Filter [ORD]

Return

 

 

Classes and available variables

Variable

Definition

Class [F:CBH]

Contains the data currently being processed (Site, product...)

Class [F :ITF]

Contains the data for the product/site processed

 

SUGREQAVA: Preparation lead-time taken into account

This entry point is used to take into consideration the preparation lead-time within the framework of the calculation of the suggestions dates.

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called in the calculation of the net requirements (MPS and MRP) during the phase of the suggestion date calculation. 

Example of an algorithm to take the preparation lead-time into account:

  

$ACTION

Case ACTION

    When "SUGREQAVA" : Gosub SUGREQAVA

Endcase

Return

$SUGREQAVA

Case [F:ITF]REOCOD

    When 3,5 : # suggested work order

               WDATR = WDATF

               If [F:ITF]PRPLTI = 0

                    WDATF = WDATR

               Else

                    WCOR = 8

                    WCOD = 2

                    WDEL = [F:ITF]PRPLTI

                    Call CALDAT("-",WCOR,WDATR,WCOD,WDEL,WCAP,WCALDATD,WDATF) From CBNLIB

               Endif

    When Default : # suggested purchasing order/intersite order

Endcase

Return

Classes and variables available

Variable

Definition

Class [F:CBH]

Contains the data currently being processed (Site, product...)

Class [F :ITF]

Contains the data for the product/site processed

 

 

CHECK_CBNDET: Control before update of WIPs

This entry point is used to intervene after the suggestion calculation for each product and before the WIP update (ORDERS).

For example, it can be used to control, modify or delete the PDPDET and CBNDET work tables before the update.

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called in the calculation of net requirements (MPS and MRP) after the phase of the suggestions calculation for products managed in stock.It is used to intervene before the WIP update (Update of the ORDERS table from the PDPDET/CBNDET tables following the processing)

Open tables

All the requirements calculation tables

REPLANNING: Before suggestion replanning

Possibility to replace the standard application mode for the seasonality of the safety stock.

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

The GREPLANNING variable is used to identify where this entry point is called:

- "RPL_INIT" at the beginning of the replanning processing for a given site

- "RPL_TRTSUGITM" suggestion calculation for a product

- "RPL_CUMSTODIS" calculation of total stock available

- "RPL_CALSUGSTO" suggestion calculation of product in stock

 

Classes and available variables

Variable

Definition

Class [F:CBH]

Contains the data currently being processed (Site, product…)

Class [F :ITF]

Contains the data for the product/site processed

 

Open tables

All the requirements calculation tables

LOAD_BUCKET: Before buckets correction

Make the buckets preparation specific, and/or avoid standard corrections.

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called in the calculation of the net requirements (MPS and MRP) after loading the parameters. It is used to avoid the standard calculation of buckets correction by activating the parameter GPE>0. 

Classes and available variables

Variable

Definition

Class [F:CBH]

Contains the data being processed

(Site, product...)

Class [F:ORD]

Contains the ORDERS record

Integer variable I

Set to I = 0 to process the order

Set to I = 1 to ignore the order

ENDSTEP5: After phase 5 (requirements calculation)

Entry point at the end of phase 5

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called at the end of phase 5 (suggestions calculation). For example, it allows to add specific WOS in CBNDET before generating WIPs.

Classes and available variables

Variable classes

Definition

Class [F:CBH]

Contains the data giving arise to the posting

WPRO

Contains 1 if MPS    Contains 2 if MRP

 

Open tables

All the requirements calculation tables

NOHINT: Optimization of the ITM-ITF link

This entry point is used to add the "With Nohint" instruction when performance problems occur on the Link instruction between the [F:ITM] and [F:ITF] tables.

It is called in the FUNCBN processing.

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called in the net requirement calculation, immediately before the loop on products with the MRP/MPS reorder mode.

The GPE variable is used.It is set to the value 0 by default.It will need to be set to 1 in the specific/custom process linked to the entry point if the user wants to add this "With Nohint" instruction in the used query.

Classes and available variables

Variable

Definition

Class [F:CBH]

Contains the data being processed

(Site, product...)

Class [F:ORD]

Contains the ORDERS record

Integer variable I

Set to I = 0 to process the order

Set to I = 1 to ignore the order

NOLOCK: Optimization of previous results deletion

This entry point is used to avoid "Readlock ... Delete" that are too long on a large database, and to use the single-user mode instead with a global lock of the PUR_TABLES_MONO tables involved.

It is called in the FUNCBN processing.

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called in the calculation of the net requirements immediately before deleting the previous results.

The GPE variable is used.It is set to the value 0 by default.It will need to be set to 1 in the specific/custom process linked to the entry point if the user wants to use the single-user mode with a global lock on the tables involved.

Classes and available variables

Variable

Definition

Class [F:CBH]

Contains the data being processed

(Site, product...)

Class [F:ORD]

Contains the ORDERS record

Integer variable I

Set to I = 0 to process the order

Set to I = 1 to ignore the order

CRE_SUG_SPLIT: Split of the suggestions

This entry point is used to take over the suggestions generation in order to perform a split, like a distribution over several suppliers.

It is called in the FUNCBN processing.

Context and operating mode

Transaction

There is no transaction in process.

Log file

There is an open log file

Different call cases

This entry point is called in the calculation of the net requirements immediately before generating a suggestion in the calculation tables.

The following variables are available:

WSUG  suggestion quantity

WDATS Suggestion date

WNBR Number of fraction according to reorder policy

WSTO Stock balance for the current calculation

Source example

#--------------------------------------------------------------------------------------
# Entry point CRE_SUG_SPLIT
# For customizing the splitting of suggestions
# [F:CBH] is online
# Variables:
# - WSUG = suggested qty
# - WDATS = suggested date
# - WNBR = nbr of splits according to reorder policy
# - WSTO = stock balance
#--------------------------------------------------------------------------------------
$ACTION
Case ACTION
When "CRE_SUG_SPLIT" : Gosub CRE_SUG_SPLIT
Endcase
Return
#--------------------------------------------------------------------------------------
$CRE_SUG_SPLIT
# parameters mask
If clalev ([M:ZCSP]) <= 0 : Local Mask ZCSP [ZCSP] : Endif
# test case >> only for purchased item "SPLIT" (GX3APP)
If [F:CBH]ITMREF <> "SPLIT" : Return : Endif
# only for PO suggestions
If [F:CBH]REOCOD <> 2 : Return : Endif
# fill ZCSP parameters mask
Raz [M:ZCSP]
[M:ZCSP]STOFCY = WFCY
[M:ZCSP]ITMREF = [F:CBH]ITMREF
[M:ZCSP]QTY = WSUG
[M:ZCSP]DAT = WDATS
[M:ZCSP]STOBAL = WSTO
[M:ZCSP]PROCESS = "ZFUNCBN"
Gosub POS_SPLITTING
GPE = 1
Return
#--------------------------------------------------------------------------------------
$FEEDBACK
WSUG = [M:ZCSP]QTYOUT
WDATS = [M:ZCSP]DATOUT
WBPRO = [M:ZCSP]BPROUT
WSTO = [M:ZCSP]STOBAL
Gosub CRE_UNE_SUG From FUNCBN
Return
 
#--------------------------------------------------------------------------------------
# Purchase orders suggestions splitting
#--------------------------------------------------------------------------------------
# parameters mask ZCSP must be open and filled (mask ZCSP needs to be created)
#--------------------------------------------------------------------------------------
$POS_SPLITTING
Local Char TSUG_BPR(GLONBPR)(3)
Local Integer TSUG_BPRPCT(3)
Local Decimal TSUG_BPRMINQTY(3)
Local Decimal WWRK, WREO, WREOTOT, WDELTA
Raz TSUG_BPR, TSUG_BPRPCT, TSUG_BPRMINQTY
# test case (GX3APP) split on 3 suppliers
TSUG_BPR(0) = "FOU001"
TSUG_BPRPCT(0) = 40
TSUG_BPRMINQTY(0) = 250
TSUG_BPR(1) = "FOU002"
TSUG_BPRPCT(1) = 40
TSUG_BPRMINQTY(1) = 200
TSUG_BPR(2) = "FOU003"
TSUG_BPRPCT(2) = 20
TSUG_BPRMINQTY(2) = 150
# -------------------------------
# process 1st split - supplier 1
WWRK = int(([M:ZCSP]QTY * TSUG_BPRPCT(0)) / 100)
If WWRK < TSUG_BPRMINQTY(0) : WREO = TSUG_BPRMINQTY(0) : Else : WREO = WWRK : Endif
WREOTOT += WREO
[M:ZCSP]QTYOUT = WREO
[M:ZCSP]DATOUT = [M:ZCSP]DAT + 1
[M:ZCSP]BPROUT = TSUG_BPR(0)
Gosub FEEDBACK From =[M:ZCSP]PROCESS
If WREOTOT >= [M:ZCSP]QTY : Return : Endif
# -------------------------------
# process 2nd split - supplier 2
WWRK = int(([M:ZCSP]QTY * TSUG_BPRPCT(1)) / 100)
If WWRK < TSUG_BPRMINQTY(1) : WREO = TSUG_BPRMINQTY(1) : Else : WREO = WWRK : Endif
WREOTOT += WREO
[M:ZCSP]QTYOUT = WREO
[M:ZCSP]DATOUT = [M:ZCSP]DAT + 1
[M:ZCSP]BPROUT = TSUG_BPR(1)
Gosub FEEDBACK From =[M:ZCSP]PROCESS
If WREOTOT >= [M:ZCSP]QTY : Return : Endif
# -------------------------------
# process 3rd split - supplier 3
WWRK = int(([M:ZCSP]QTY * TSUG_BPRPCT(2)) / 100)
If WWRK < TSUG_BPRMINQTY(2) : WREO = TSUG_BPRMINQTY(2) : Else : WREO = WWRK : Endif
WREOTOT += WREO
[M:ZCSP]QTYOUT = WREO
[M:ZCSP]DATOUT = [M:ZCSP]DAT + 1
[M:ZCSP]BPROUT = TSUG_BPR(2)
# last split, adjust stock balance for MRP calculation
[M:ZCSP]STOBAL += (WREOTOT - [M:ZCSP]QTY)
Gosub FEEDBACK From =[M:ZCSP]PROCESS
Return

CTLSTOSEC: specific case safety stock on 1st requirement

This entry point is used to take over on the rtz of the Safety stock variable.

It is called in the FUNCBN processing, when the "Match safety stock" parameter is set to the "on 1st requirement" value, only on the 1st bucket and if WBESBUC=0.This means that there is no requirement, or that this requirement is covered or allocated on the available stock.

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

Classes and variables available

Variable

Definition

Class [F:CBH]

Contains the data currently being processed (Site, product…)

Class [F :ITF]

Contains the data for the product/site processed

 

Open tables

All the requirements calculation tables

NOADJUST: Start stock adjustment

Requirements calculation starting stock

Context and operating mode

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called before the start stock adjustment, if the physical stock was requested.

The adjustment consists in ignoring the packing slips/picking tickets which are pending validation. 

The activation of variable GPE=1 allows to skip the start stock adjustment and switch back to V5 operating mode, with all the allocations being deducted from the available stock.

Variables

Variable or mask

Definition

WPRO

Contains 1 if MPS

Contains 2 if MRP

 

Open tables

All the requirements calculation tables

BEFWRICBD1: Before MRP result

This entry point is used to control and/or correct data before generating the requirement in the CBNDET or PDPDET table.

Context and operating method

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called during the calculation of net requirements (MRP and MPS) just before inserting the requirement in the MRP/MPS result (2 calls). 

The GPE variable is used.It is set to the value 0 by default.It must be set at 1 in the specific process linked to the entry point if the current line must not be posted.

The variables that can be modified/accessed are in the [F:CBD1] buffer.

Classes and available variables

Variable

Definition

Class [F:CBH]

Contains the data currently being processed (Site, product…)

Class [F :ITF]

Contains the data for the product/site processed

 

 

CTLDATSUG: Suggestion date control

This entry point is used to control and/or correct data before generating the requirement in the CBNDET or PDPDET table.

Context and operating method

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called during the MRP calculation (MRP and MPS) once the suggestion start and end dates have been calculated ($CALDATSUG).

The variables that can be modified/accessed are WDATD = suggestion start date and WDATF = suggestion end date..
Other information relating to the current suggestion are in the [F:CDB1] buffer.

Classes and available variables

Variable

Definition

Class [F:CBH]

Contains the data currently being processed (Site, product...)

Class [F :ITF]

Contains the data for the product/site processed

CTLSTO : Quality control stock resource

This entry point provides access to the creation of a (miscellaneous) resource for stock under quality control.

Context and operating method

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called during MRP and MPS before each quality control stock miscellaneous resource is created ($CTL_STO)

The entry point is positioned immediately before the Write [CBD]

Variable GPE can be modified: GPE = 0 creates the resource, GPE <> 0 does not create the resource. Values of fields in the [F:CBD] class (Detail net need calculation) can be modified before resource creation for example quantity and required date

Setting GOK < 1 will stop the transaction


STARTSTOCKECC: Reorganise versioned starting stock

This entry point is used to reorganise versioned starting stock after calculation by version.

Context and operating method

Transaction

There is one transaction in progress

Log file

There is an open log file

Different call cases

This entry point is called during MRP and MPS immediately after the starting stock is calculated for a versioned product. The entry point can be used to reorganise the calculated starting stock for example: to assign the total starting stock across all versions to one particular version (the latest version).

The starting stock for each version is in WECCSTODIS(n) and the corresponding major and minor version is in WECCVALMAJ(n) and WECCVALMIN(n). Where n = max. number of versions (activity code ECCMX).

Setting GOK < 1 will stop the transaction.


REOMGT: Ignore 'not managed' products

Ignore products (sites) that have Reorder mode = "Not managed".

Context description

This entry point provides the option to ignore all products (sites) in the MRP process where the Reorder mode = "Not managed". For these products no record will be written to the CBNHEA table (MRP header) - this will, potentially, increase performance.


Note: for manufactured products where these 'ignored' products appear as components in the BOM then an extra database read is performed - this will, potentially, decrease preformance.


Transaction

There is one transaction in progress


Log file

There is an open log file


Available variable

Integer WREOMGT     Set to 0 (default) to include all products in the MRP process. Set to 1 to ignore all products (sites) in the MRP process where the Reorder mode = "Not managed".