CalculateF4229PeriodSalesCost

Calculate F4229 Period Sales Cost

Major Business Rule

Object Name: B4200620

Parent DLL: CDIST

Location: Client/Server

Language: C





Functional Description


Purpose


Use this function to get the total period sales amount (AS01 - AS14) and total cost amount (CI01 - 

CI14) for a certain period/fiscal year/century range in the Sales Summary History table (F4229).  The 

function will take the specified record, total up all the period sales and period cost amounts that fall 

within the given period/fiscal year/century range and then return these two totals.



Setup Notes and Prerequisites



• Before calling this function, you will need to call the "Return Period Number, Fiscal Year and 
Century" business function for both the starting and ending range values.  This function will return the 

correct period, fiscal year and century for that range.

• When calling this function,  you will need to pass over the Business Unit  (MCU), Address Number 
(AN8), Order Type (DCTO), Item Number - Short (ITM), Line Type (LNTY), Sales Catalog Section (SRP1), Sub 

Section (SRP2), Sales Category Code3 (SRP3), Sales Category Code4 (SRP4) and Fiscal Year (FY) as the 

key to find the correct F4229 record..

• You will also need to pass over the beginning and ending periods, fiscal years and centuries that 
make up the range to do the totals on.

• You will also need a dictionary item work field for each value that you will need returned from the 
function; total sales, total cost.~




Special Logic


None.


Technical Specification



BF will compute the total period sales amount (AS01 - AS14) and total cost amount (CI01 - CI14) for a 

certain period/fiscal year/century range in the Sales Summary History table F4229.


Related Tables


Table Table Description
F4229Sales Summary History



Find the Correct F4229 Record


1.Use the MCU, AN8, DCTO, ITM, LNTY, SRP1, SRP2, SRP3, SRP4 and FY Data Items passed in 

to find the correct record in the F4229 file. 


Process and Total the Sales and Cost Amounts


1.  If the Starting Century = Ending Century

         If  Starting Year = Ending Year Total from the corresponding values in (AS01..AS14 and 

CI01..CI14) from the Starting Period to the Ending Period.  

         elseif Starting Year <> Ending Year

              If Starting Year > Fiscal Year < Ending Year

                  Add all 14 periods for sales and cost.

              elseif Fiscal Year = Starting Year

                  Add Starting Period to 14 period amounts for sales and cost

              else  

//Fiscal Year = Ending Year

                  Add 1 to Ending Period amounts for sales and cost

      else  

   //Starting Century <> Ending Century

         If Century = Starting Century     

  // Century here is the Century (CRTY) field in the F4229 record

              If Fiscal Year > Starting Year

                  Add all 14 period amounts for sales and cost

              else  

// Fiscal Year = Starting Year

                  Add Starting Period to 14 amounts for sales and cost

         else  

  // Century = Ending Century    

  // Century here is the Century (CRTY) field in the F4229 record


              If Fiscal Year < Ending Year

                  Add all 14 periods for sales and cost

              else  

// Fiscal Year = Ending Year

                  Add 1 to Ending Period amounts for sales and cost


Examples:

      Each record will have 14 period sales amount and period cost amount bins.


AS01 .. AS14 = 14 period sales amounts

CI01 .. CI14 = 14 period cost amounts


For the following examples there will be four records in the F4229 file that will be found by passing 

in a certain key combination.  For the first record (Record1), the Century (CTRY) will be 19 and the 

Fiscal Year (FY) will be 97.  For the second record (Record2), the Century (CTRY) will be 19 and the 

Fiscal Year (FY) will be 98.  For the third record (Record3), the Century (CTRY) will be 20 and the 

Fiscal Year (FY) will be 01.  And the fourth record (Record4) will have a Century (CTRY) of 20 and a 

Fiscal Year (FY) of 02.


Example 1: Starting Century = 19, Ending Century = 19, Staring Year = 97, Ending Year = 97, Starting 

Period = 4, Ending Period = 10


Record3 and Record4 will not be calculated because they are in the wrong century.  Record2 

will not calculate because it lies in the wrong year. And Record1 will have AS04 through AS10 and CI04 

through CI10 calculated.


Example 2:  Starting Century = 19, Ending Century = 19, Staring Year = 97, Ending Year = 98, Starting 

Period = 5, Ending Period = 11


Record3 and Record4 will not be calculated because they fall within the wrong Century.  

Record1 will have from AS05 to AS14 and CI05 to CI14 calculated.  And Record2 will have from AS01 to AS11 

and CI01 to CI11 calculated.  The reason for this is the Starting Period starts in the fifth period of 

1997 and the ending period is the eleventh period of 1998.  So the range of periods to calculate runs 

from the fifth period of 1997 all the way through the end of 1997 (fourteenth period)  and it then 

runs from the beginning of 1998 (first period) all the way to the eleventh period of 1998.


Example 3:  Starting Century = 19, Ending Century = 20, Staring Year = 98, Ending Year = 01, Starting 

Period = 6, Ending Period = 9~  


Record1 will not calculate because its Century/Fiscal Year combination falls before the 
Starting Century/Starting Fiscal Year combination (19/97 < 19/98).  Record4 will not be calculated 

because its Century/Fiscal Year combination is after the Starting Century/Starting Fiscal Year 

combination (20/02 > 20/01).  Record2 will have from AS06 to AS14 and CI06 to CI14 

calculated.  And Record3 will have from AS01 to AS09 and CI01 to CI09 calculated.  The reason for this 

is the Starting Period starts in the sixth period of 1998 and the ending period is the ninth 

period of 2001.  So the range of periods to calculate runs from the sixth period of 1998 all the 

way through the end of the 19th century (including the fourteenth period of 1998) and it then 

runs from the beginning of  the 20th century (including the first period of 2001) all the way 

to the ninth period of 2001.


2.  Return the total Period amounts for that record in the Sales Totals and Cost Totals variables.




Data Structure

D4200620 - Calculate F4229 Period Sales Cost





Special Input Expected


Parameters:


Data Item Data Structure DescriptionI/O Required   Notes

MCU      Business Unit                  I    Y         Business Unit of

                                                               F4229 record

AN8      Address Number                 I    Y         Sold to Customer                       

                                         Number for F4229                                             

                   record

DCTO        Order Type                    I    Y         Order Type for                         

                                        F4229 record

ITM      Item Number - Short            I    Y         Item Number - Short                    

                                            of F4229 record

LNTY      Line Type                    I    Y         Line Type of F4229                     

                                           record

SRP1      Sales Catalogue Section        I    Y         Sales Catalogue                        

                                        Section of F4229                                              

                  record

SRP2      Sub Section                    I    Y         Sub Section of                         

                                       F4229 record

SRP3      Sales Category Code3           I    Y         Sales Category                         

                                       Code3 of F4229                                                 

               record

SRP4      Sales Category Code4       I    Y         Sales Category                         

                                       Code4 of F4229                                                 

               record

FY      Fiscal Year                   I    Y         Fiscal Year of                         

                                       F4229 record

CRPR      Starting Period             I    Y         Period where                           

                                     starting range                                                   

                                                                            begins

CRPR      Ending Period             I        Y         Period where ending                    

                                            range ends

FY      Starting Year             I    Y         Fiscal year                            

                                    starting range                                                    

            begins in

FY      Ending Year                   I    Y         Fiscal year ending                     

                                           range ends in

CTRY      Starting Century             I    Y         Century starting                       

                                         range begins in

CTRY      Ending Century             I    Y         Century ending                         

                                       range ends in.





Special Output Returned


Parameters:


Data Item Data Structure DescriptionI/ORequiredNotes

AM0      Sales Totals             O   N      Total of all period                       

                                      sales totals falling                                            

                 in the starting and                                                             

ending range

AM0      Cost Totals                   O    N      Total of all period                       

                                      costs totals falling                                            

                 in the starting and                                                                  

                                                       ending range.




^

Parameter NameData ItemData TypeReq/OptI/O/Both
szBusinessUnitMCUcharNONENONE

An alphanumeric code that identifies a separate entity within a business for which you want to track costs. For example, a business unit 
might be a warehouse location, job, project, work center, branch, or plant. You can assign a business unit to a document, entity, or person for 
purposes of responsibility reporting. For example, the system provides reports of open accounts payable and accounts receivable by 
business unit to track equipment by responsible department. Business unit security might prevent you from viewing information about business units 
for which you have no authority.

mnAddressNumberAN8MATH_NUMERICNONENONE

A number that identifies an entry in the Address Book system, such as employee, applicant, participant, customer, supplier, tenant, or 
location.

szOrderTypeDCTOcharNONENONE

A user defined code (00/DT) that identifies the type of document. This code also indicates the origin of the transaction. J.D. Edwards has 
reserved document type codes for vouchers, invoices, receipts, and time sheets, which create automatic offset entries during the post 
program. (These entries are not self-balancing when you originally enter them.) The following document types are defined by J.D. Edwards and 
should not be changed: P Accounts Payable documents   R Accounts Receivable documents   T Payroll documents   I Inventory documents  
O Purchase Order Processing documents   J General Accounting/Joint Interest Billing documents   S Sales Order Processing documents

mnShortItemNumberITMMATH_NUMERICNONENONE

An inventory item number. The system provides three separate item numbers plus an extensive cross-reference capability to other item 
numbers (see data item XRT) to accommodate substitute item numbers, replacements, bar codes, customer numbers, supplier numbers, and 
so forth. The item numbers are as follows:   o Item Number (short) - An eight-digit, computer-assigned item number     o 2nd Item Number - The 
25-digit, free-form, user defined alphanumeric item number     o 3rd Item Number - Another 25-digit, free-form, user defined alphanumeric item 
number

szLineTypeLNTYcharNONENONE

A code that controls how the system processes lines on a transaction. It controls the systems with which the transaction interfaces, such as 
General Ledger, Job Cost, Accounts Payable, Accounts Receivable, and Inventory Management. It also specifies the conditions under 
which a line prints on reports, and it is included in calculations. Codes include the following: S Stock item   J Job cost   N Nonstock item   F Freight  
T Text information   M Miscellaneous charges and credits   W Work order

szSalesCatalogueSectionSRP1charNONENONE





Sales Catalogue Section of F4229 record



^

szSubSectionSRP2charNONENONE




Sub Section of F4229 record



^

szSalesCategoryCode3SRP3charNONENONE




Sales Category Code3 of F4229 record



^

szSalesCateqoryCode4SRP4charNONENONE




Sales Category Code4 of F4229 record



^

mnFiscalYearFYMATH_NUMERICNONENONE

A number that identifies the fiscal year. Generally, you can either enter a number in this field or leave it blank to indicate the current fiscal 
year (as defined on the Company Setup form). Specify the year at the end of the first period rather than the year at the end of the fiscal period. 
For example, a fiscal year begins October 1, 1998 and ends September 30, 1999. The end of the first period is October 31, 1998. Specify the 
year 98 rather than 99.

mnStartingPeriodCRPRMATH_NUMERICNONENONE

This week or month. This is usually a number between 1 and 52 that designates the relative position in the year. For example, on a 
calendar basis using increments of weeks, Period 4 would be the 7-day time period which begins on January 22.

mnEndingPeriodCRPRMATH_NUMERICNONENONE

This week or month. This is usually a number between 1 and 52 that designates the relative position in the year. For example, on a 
calendar basis using increments of weeks, Period 4 would be the 7-day time period which begins on January 22.

mnStartingYearFYMATH_NUMERICNONENONE

A number that identifies the fiscal year. Generally, you can either enter a number in this field or leave it blank to indicate the current fiscal 
year (as defined on the Company Setup form). Specify the year at the end of the first period rather than the year at the end of the fiscal period. 
For example, a fiscal year begins October 1, 1998 and ends September 30, 1999. The end of the first period is October 31, 1998. Specify the 
year 98 rather than 99.

mnEndingYearFYMATH_NUMERICNONENONE

A number that identifies the fiscal year. Generally, you can either enter a number in this field or leave it blank to indicate the current fiscal 
year (as defined on the Company Setup form). Specify the year at the end of the first period rather than the year at the end of the fiscal period. 
For example, a fiscal year begins October 1, 1998 and ends September 30, 1999. The end of the first period is October 31, 1998. Specify the 
year 98 rather than 99.

mnStartingCenturyCTRYMATH_NUMERICNONENONE

The calendar century associated with the year. Enter is the first two digits of the year. For example, 19 indicates any year beginning with 19 
(1998, 1999), 20 indicates any year beginning with 20 (2000, 2001), and so on.

mnEndingCenturyCTRYMATH_NUMERICNONENONE

The calendar century associated with the year. Enter is the first two digits of the year. For example, 19 indicates any year beginning with 19 
(1998, 1999), 20 indicates any year beginning with 20 (2000, 2001), and so on.

mnSalesTotalsAM0MATH_NUMERICNONENONE

Everest Parent Data Item

mnCostTotalsAM0MATH_NUMERICNONENONE

Everest Parent Data Item

szSalesCategoryCode5SRP5charOPTNONE

One of ten category codes to be used for sales coding purposes.  These codes can represent such classifications as color, material 
content, or use.

Related Functions

B4000460 Free Ptr To Data Structure

Related Tables

F4229 Sales Summary History File