AccumulateGetDiscSummary

Accumulate Get Disc Summary

Major Business Rule

Object Name: B4200240

Parent DLL: CDIST

Location: Client/Server

Language: C

Functional Description

Purpose

This function has two distinct phases: accumulate and retrieve, each selected by a 'Mode' parameter 
passed to the function. 


In accumulate mode (called within a loop by the calling program) this function accumulates and stores 

discount information for a given Sales Order Detail line in an array.  An error indicator is the only 

parameter returned to the calling program in accumulate mode.


Retrieve mode (also called within a loop in the calling program) will pass the stored (summarized) 

discount information to the calling program, one array element at a time.


Setup Notes and Prerequisites


Special Logic



Technical Specification

2.2Related Tables 
2.3Related Business Functions

2.4Processing 

The following validation should be performed on the input parameters.  If there are any errors, 
return a '1' in the error code ERRC.  


• MODE can be '1', '2', '3' or '4'.
• When MODE is '2', CNTF must not be less than 1.



When MODE is 3 (Initialise Array/Linked List):


Mode 3 will be used to initialise (clear) the array or linked list and should be the first call made 
to this function.  No parameters (other than Mode) will be needed.




When MODE is 4 (Destroy Array/Linked List):


Mode 4 will be used to delete the array or linked list and should be the last call made to this 
function.  No parameters (other than Mode) will be needed.




When MODE is 1 (Accumulate and Store Discount Information):


The data passed to this function should be stored in a linked list which should have the following 
elements:


PAYTERM-Payment Terms Code

PRICE-Extended Price

FPRICE-Foreign Extended Price

DISCOUNT-Amount of Discount

FDISCOUNT-Foreign Amount of Discount



• Build the linked list:

We need to determine if the data received exists in the linked list by looking for the Payment 
Terms Code (PTC) in array_element PAYTERM.  Set 'Found' ON or OFF.


We will either accumulate the data to an existing index position (Found ON) or add data to a 
new index position (OFF).


If 'Found' OFF (Discount data does not exist in the linked list)

Set the index to the first position where array_element PAYTERM is blank.

Store Payment Terms Code (PTC) in array_element PAYTERM[index].
Store Extended Price (AEXP) to array_element PRICE[index].

Store Foreign Extended Price (FEA) to array_element FPRICE[index].

Store Discount Amount (ADSC) to array_element DISCOUNT[index].

Store Foreign Discount Amount (CDS) to array_element FDISCOUNT[index].



If 'Found' ON (existing array position)
Add Extended Price (AEXP) to array_element PRICE[index].
Add Foreign Extended Price (FEA) to array_element FPRICE[index].

Add Discount Amount (ADSC) to array_element DISCOUNT[index].

Add Foreign Disc. Amount (CDS) to array_element FDISCOUNT[index].




When MODE is 2 (Retrieve Discount Information):


When MODE is '2', the only parameters passed to this function will be MODE and CNTF.  In MODE 2, this 

function will be called from within a loop in the calling program.  CNTF should always be 1 for the 

first call and incremented by 1 for each subsequent call.  


Pass to the calling program the contents of array[CNTF], elements PAYTERM, PRICE, FPRICE, DISCOUNT 

and FDISCOUNT.  When there is no more data in the array, pass back a '1' in the flag field EV01.  When 

EV01 is passed back as a '1', the fields PAYTERM, PRICE, FPRICE, DISCOUNT and FDISCOUNT should be blank 

or zero.


Note:  At this stage elements FPRICE and FDISCOUNT will be zero and have been set aside for future 

use.




^

Data Structure

D4200240 - AccumulateGetDiscSummary

Special Input Expected
MODEModeProcessing1 = Accumulate & Store Mode 2 = Get Mode 3 = Initialize Mode 4 = 

Destroy Mode

PTCPayment Terms CodeReceived when MODE is '1', passed back to calling program when MODE is 

'2' as contents of: array_element PAYTERM[CNTF].

AEXPExtended PriceSimilar to PTC: array_element PRICE[CNTF]

FEAForeign Extended PriceSimilar to PTC: array_element FPRICE[CNTF]

ADSCDiscount AmountSimilar to PTC: array_element  DISCOUNT[CNTF]

CDSForeign Discount AmountSimilar to PTC: array_element FDISCOUNT[CNTF]

CNTFCount FieldOnly reqd when MODE = 2.  This parameter requests the array element to 

be retrieved.  It should always be 1 for the first call, and incremented by 1 for each subsequent 

call. 



Special Output Returned

PTCPayment Terms CodeReceived when MODE is '1', passed back to calling program when MODE is 

'2' as contents of: array_element PAYTERM[CNTF].

AEXPExtended PriceSimilar to PTC: array_element PRICE[CNTF]

FEAForeign Extended PriceSimilar to PTC: array_element FPRICE[CNTF]

ADSCDiscount AmountSimilar to PTC: array_element  DISCOUNT[CNTF]

CDSForeign Discount AmountSimilar to PTC: array_element FDISCOUNT[CNTF]

EV01End Of Array FlagPassed back to calling program when MODE is '2'.  Will contain '0' 

during the 'Get' process and '1' once the last array element has been passed back.

ERRCErrorCode


^

Parameter NameData ItemData TypeReq/OptI/O/Both
cStoreGetOrInitializeMODEcharNONENONE

Special Input Expected
MODEab ModeProcessing


Significant Data Values

1 = Accumulate & Store Mode

2 = Get Mode

3 = Initialize Mode

4 = Destroy  Modeab 



^

szPaymentTermsCodePTCcharNONENONE

A code that specifies the terms of payment, including the percentage of discount available if the invoice is paid by the discount due date. 
Use a blank code to indicate the most frequently-used payment term. You define each type of payment term on the Payment Terms Revisions 
form. Examples of payment terms include: Blank Net 15 001      1/10 net 30 002      2/10 net 30 003      Due on the 10th day of every month 006     
Due upon receipt  This code prints on customer invoices.

mnExtendedPriceAEXPMATH_NUMERICNONENONE

The number of units multiplied by the unit price.

mnForeignExtendedPriceFEAMATH_NUMERICNONENONE

The product of the foreign price times the number of units.

mnDiscountAmountADSCMATH_NUMERICNONENONE

The amount of the invoice or voucher pay item that is eligible to be subtracted from the gross amount when the transaction is paid. The 
system calculates discount amounts based on the payment term entered on the transaction.  Note: If the system calculates the discount, verify 
that it applies to the pay item specified. Usually, freight, sales tax, and labor charges that are included in the gross amount do not qualify for 
discounts.

mnForeignDiscountAmountCDSMATH_NUMERICNONENONE

The foreign amount of the discount available as opposed to the amount of the discount actually taken.

cEndOfArrayFlagEV01charNONENONE

Special Output Returned
EV01ab End Of Array  Flagab 


Significant Data Values

Passed back to calling program when MODE is '2'.  Will contain '0' during the 'Get' process and '1' 

once the last array element has been passed  back.ab 

^

nCounterINT01integerNONENONE

Number of Days in Future to Query for Responses Due. 

cErrorCodeERRCcharNONENONE

This error code indicates if any errors occurred during the creation of the Trip Document Detail (F4914) records by the Delivery Document 
Set Server program (XT4914).

cSuppressErrorMsgEV01charNONENONE

An option that specifies the type of processing for an event.

szErrorMsgIDDTAIcharNONENONE

A code that identifies and defines a unit of information. It is an alphanumeric code up to 8 characters long that does not allow blanks or 
special characters such as %, &, or +. You create new data items using system codes 55-59. You cannot change the alias.

idPtrToDiscountListGENLNGIDNONENONE

General purpose ID variable.

Related Functions

None

Related Tables

None