1.Functional Description
This business function loads the MRP Bucketless Date Cache used in MRP planning program from the work
day calendar table F0007 depending on the No of days, Weeks and Months sent in. It will also flag the
bucket dates, and Load the No of days in week/month. It will calculate the Start date, End Date, No
of Buckets loaded. It will load the past due periods depending on the input.
1.1Purpose
This function is used to load dates into MRP Bucketless Date Cache used to calculate the requirements
for a particular item. If there are any errors, the program will return an error code of '1' and an
Error Message '3143'.
1.2Setup Notes and Prerequisites
1.3Special Logic
None
2.Technical Specifications
1. Check data in MRP Bucketless Date Cache for Branch
Call B3401270 in mode 'DELETEALL' to delete records with Input Branch as key.
Open F0007 calendar table
If Error in Opening, Exit with an Error Code of '1'
If Input $$FCP = '1'
Open F3405 FCP table.
If Error in opening the table
Endif
2. Initialize all variables.
Wk System Date = System Date.
If Input Gen Date (STRT) = 0, Input Gen Date = Wk System Date.
Wk Start Date = Input Gen Date (STRT).
If Wk Start Date is not a work day in F0007
Wk Start Date = the first work day after Wk Start Date
EndIf
Output $$FBEG (First Beginning Date) = Wk Start Date
Calculate Wk End Date = STRT + (Input $PD + 7 * Input $PW + 31 * Input $PM) + 31.
Open Calendar Table F0007. If Error Opening - Exit from the Routine with Error Code '1'.
If Input Past Due ($PDUE) = 2, Wk Index $G = 2 Otherwise $G = 1.
Wk Num Days = the number of days between STRT and Wk End Date
Create the following arrays of Size Wk Num Days
Date @DT[Wk Num Days] - Bucketless date - Date
Flag @F[Wk Num Days] - flag to Indicate Month/Week End or Both - Char
Days in Week @DW[Wk Num Days] - To Store no of Days in Week - Integer
Days in Month @DM[Wk Num Days] - To Store no of Days in Month - Integer
Bucket Date @BD[Wk Num Days] - Flag to Indicate Bucket - Char
FCP Bucket Flag @FC[Wk Num Days] - Flag to Indicate FCP Bucket - Char
3. Load Past Due Dates.
If $$FCP = '1'
Wk Date = Wk Start Date
Select F3405 records where MUPETY = 'FC' and MUENDD < Wk Date in Descending
Order
Read F3405 record
If not found
Wk EOF flag = '1'
Endif
Endif
If Input $PD > 0
Subtract 1 Day from Wk Start Date
Else
If Input $PW > 0
Determine Wk DOW Day of Week using Wk Start Date
Add 1 to Wk DOW
Subtract Wk DOW from Wk Start Date
Else
If Input $PM > 0
Subtract 1 month from Wk Start Date
Wk Start Date = Last Day of the Month
Endif
Endif
Endif
Convert Wk Start date into Month ($M), Day ($D) and Year($Y) work fields.
Wk Exit Flag = ' '
Do While Wk Exit Flag <> '1'
If $M <> CZMT or $Y <> CZYR in F0007 table
Call Subroutine Get Calendar
Endif.
If @W[$D] = 'W'
@DT[$G] = Wk Start Date
@BD[$G] = 'B'
@DM[$G] = Wk DIM
Break
Endif
Subtract 1 day from Wk Start Date.
Convert Wk Start date into Month ($M), Day ($D) and Year($Y) work fields.
Enddo.
If $$FCP = '1' and Wk EOF Flag <> '1'
@DT[$G] = MUENDD
@BD[$G] = 'B'
@FC[$G] = '1'
Endif
Output $$BEG = Wk Start Date + 1
If Input $PDUE = 2
Subtract 7 Days from Wk Start Date
Convert Wk Start date into Month ($M), Day ($D) and Year($Y) work fields.
Wk Exit Flag = ' '
Do While Wk Exit Flag <> '1'
If $M <> CZMT or $Y <> CZYR in F0007 table
Call Subroutine Get Calendar
Endif.
If @W[$D] = 'W'
@DT[1] = Wk Start Date
@BD[1] = 'B'
@DM[1] = Wk DIM
Break
Endif
Subtract 1 from Wk Start Date.
Convert Wk Start date into Month ($M), Day ($D) and Year($Y) work
fields.
Enddo.
If $$FCP = '1' and Wk EOF Flag <> '1'
@DT[$G] = MUENDD
@BD[$G] = 'B'
Output $$FBDT = @DT[1]
4. Load the Date Array @DT and @DM arrays as given below
Wk Start Date = @DT[$G].
SAR 1532228 - Calculation of Rec Start Date
Call B3401340 to Write a new record to the cache with Job Number, Branch, Wk Start Date, and
Type 2.
Call B3401340 to Write a new record to the cache with Job Number, Branch,
Type 3.
End mods for SAR 1532228
Do While Wk Start Date < Wk End Date and $G <= Wk Num Days
Add 1 day to Wk Start Date.
Convert Wk Start date into Month ($M), Day ($D) and Year($Y) work fields.
If $M <> CZMT (from F0007 table) or $Y <> CZYR
Call Subroutine Get Calendar
Endif.
Add 1 to $G.
@DT[$G] = Wk Start Date
@DM[$G] = Wk DIM
If @W[$D] <> 'W'
@BD[$G] = 'X'
Endif
Enddo
Wk Period End Index ($PEI) = $G
5. Load the Flag Array @F to Indicate Month End, Week End or Both.
If Input Past Due ($PDUE) = 2, Wk Index $G = 3 Otherwise $G = 2.
Wk Start Date = @DT[$G]
Calculate Day of the Week ($$DW) from Wk Start Date.
Wk End date = Wk Start Date + 7 - $$DW
Wk Prev Date = Wk End Date - 7.
Wk Day in Week (Wk DIW) = 0
Do While Wk Prev Date < Wk Start Date
Convert Wk Prev date into Month ($M), Day ($D) and Year($Y) work fields.
If $M <> CZMT and $Y <> CZYR
Call Subroutine Get Calendar
Endif
If @W[$D] = 'W'
Wk DIW = Wk DIW + 1
Endif
Wk Prev Date = Wk Prev Date + 1
Enddo
Wk Prev Date = Wk Start Date.
Do While $G <= $PEI
If @DT[$G] > Wk End Date
Wk Index ($I) = $G -1.
Wk Exit flag = ' '
Do While Wk Exit flag <> '1'
If $I <= 0 or @DT[$I] = 0 or @F[$I] = 'W'/'B'
Break
Endif
@DW[$I] = Wk DIW
$I = $I -1
Enddo
Wk Index ($I) = $G -1.
@F[$I] = 'W'
Wk DIW = 0
Wk End Date = Wk End Date + 7
Endif
If Month of @DT[$G] <> Month of Wk Prev Date
Wk Index ($I) = $G -1.
If @F[$I] = 'W'
@F[$I] = 'B'
Else
@F[$I] = 'M'
Endif
Endif
If @BD[$G<> 'X'
EndIf
$G = $G + 1
Enddo
6. Calculate and Load Bucket flag @BD flag and @FC flag
If Input Past Due ($PDUE) = 2, Wk Index $G = 3 Otherwise $G = 2.
Wk Index $I = $G -1.
Do While $G <= $PEI and $I <= 55
If Input $PD > 0
If @BD[$G] <> 'X'
@BD[$G] = 'B'
EndIf
Else
If Input $PW > 0
If @F[$G] = 'W' or 'B'
$PW = $PW - 1
Add 1 to $I
@BD[$G] = 'B'
Endif
Else
If Input $PM > 0
If @F[$G] = 'M' or 'B'
$PM = $PM - 1
Add 1 to $I
@BD[$G] = 'B'
Endif
Endif
Endif
Endif
If $PD = 0 and $PW = 0 and $PM = 0
Break
Endif
$G = $G + 1
Enddo
Output $PN = $I
If $$FCP = '1'
Select F3405 records where MUPETY = 'FC' and MUENDD <= @DT[$X] in Descending
Order
Read F3405 record
Output $$FBDT = @DT[1]
@FC[1] = '1'
Else
@BD[2] = MUENDD + 1 day
@FC[2] = '1'
Endif
Endif
7. Load all the Output Arrays and Write records into Cache
Output EndDate $$ENDD = @DT[$G]
Output $FIRST = @DT[1]
For $G = 1 to Wk Num Days Do
If @DT [$G] > Output $$ENDD or <= 0
Break
Endif
If @DT[$G] <= Wk System Date
Output $FIRST = @DT[$G]
Endif
If @BD[$G] <> 'X'
MTF1 = @DW[$G], MTF2 = @DM[$G] , EV03 = @FC[$G]
EndIf
If GenerationMode = '2'
Fetch the record from F33133 for the input Branch
If a record is found
Update the record with the bucket dates from @BD
Else
Insert a new record for the Branch with bucket dates from @BD
End
End
If Input $PDUE = 2, $G = 3 Else $G = 2.
Output First Date in Cache = @DT[1]
8. Close Tables and Deallocate Memory used for the Arrays
Close F0007 table and F3405 table
Deallocate Memory used for the Arrays
Exit the function with Error Code = '0'
Get Calendar Subroutine
Using Input Branch, $M and $Y as keys , Get a record from the Calendar table F0007.
If not found, Exit function with an Error code '1'
Load CZTD01 to CZTD31 from the record into an work array @W[31].
Wk DIM = 0
For Index $I = 1 to 31 Do
If @W[$I] = 'W'
Add 1 to Wk DIM
Endif
Enddo
D3400360 - MRP, Write Date Buckets
Data Item Data Structure DescriptionI/ORequiredNotes
JOB Job Number IY Job Number as string for
cache name
MCU Branch IY Branch for Loading Date Cache
STRT Gen Start Date I
INT01 No of Days I No of Days in Process Option
$PD
INT01 No of Weeks I No of Weeks in Process Option
$PW
INT01 No of Months I No of Months in Process
Option $PM
INT01 No of Past Due Periods I No of Past Due Periods $PDUE
INT01 No of Bucketless Elements O No of Dates in User Index
$PND
INT01 No of Bucket Elements O No of Buckets in User Index
$PN
DATE01 Start Date O Start Date of Planning $FIRST
DATE02 End Date O End Date of Planning $ENDD
DATE03 First Beginning Date O Generation Start Date $$FBEG
DATE04 Beginning Date O Past Due Date + 1 $$BEG
EV01 Suppress Error Message I ' ' - Display Errors '1' -
Suppress Error Messages
ERRC Error Code O '0' - Success (Default) '1' -
Errors in Loading Data
DTAI Error Message Id O ' ' - Success '3143' -
Errors
EV03 Forecast Consumption flag I/O FCP flag in Process Option -
$$FCP
DATE05 Forecast Consumption Begin DateO $$FBDT
DATE06 First Date in Cache O This is the first date in the
Date Cache regardless of
buckets or work days.
EV01 Generation Mode I Added for SAR 1733265.
Bucket dates are dumped to F33133
for Gross Regeneration not Net
Change.
^
Parameter Name | Data Item | Data Type | Req/Opt | I/O/Both |
---|---|---|---|---|
szBranch | MCU | char | NONE | NONE |
An alphanumeric code that identifies a separate entity within a business for which you want to track costs. For example, a business unit
| ||||
jdGenerationStartDate | STRT | JDEDATE | NONE | NONE |
The start date for the order. You can enter this date manually, or have the system calculate it using a backscheduling routine. The routine
| ||||
nNumberOfDays | INT01 | integer | NONE | NONE |
Number of Days in Future to Query for Responses Due. | ||||
nNumberOfWeeks | INT01 | integer | NONE | NONE |
Number of Days in Future to Query for Responses Due. | ||||
nNumberOfMonths | INT01 | integer | NONE | NONE |
Number of Days in Future to Query for Responses Due. | ||||
nNoOfPastDuePeriods | INT01 | integer | NONE | NONE |
Number of Days in Future to Query for Responses Due. | ||||
nNoOfBucketlessElements | INT01 | integer | NONE | NONE |
Number of Days in Future to Query for Responses Due. | ||||
nNoOfBucketElements | INT01 | integer | NONE | NONE |
Number of Days in Future to Query for Responses Due. | ||||
jdStartDate | DATE01 | JDEDATE | NONE | NONE |
Event point for JDE Date. | ||||
jdEndDate | DATE02 | JDEDATE | NONE | NONE |
Event point for JDE Date. | ||||
jdFirstBeginningDate | DATE03 | JDEDATE | NONE | NONE |
Event point for JDE Date. | ||||
cSuppressErrorMessages | EV01 | char | NONE | NONE |
An option that specifies the type of processing for an event. | ||||
cErrorCode | ERRC | char | NONE | NONE |
This error code indicates if any errors occurred during the creation of the Trip Document Detail (F4914) records by the Delivery Document
| ||||
szErrorMessageID | DTAI | char | NONE | NONE |
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
| ||||
jdBeginningDate | DATE04 | JDEDATE | NONE | NONE |
Event point for JDE Date. | ||||
szJobNumberAsString | JOB | char | NONE | NONE |
Job Number | ||||
cForecastConsumptionFlag | EV03 | char | NONE | NONE |
A radio button that specifies the level at which trace/track result is to be displayed. Select the Detail to display all transactions except IB, IX,
| ||||
jdForecastConsumptionBeginDate | DATE05 | JDEDATE | NONE | NONE |
Event point for JDE Date. | ||||
jdFirstDateInCache | DATE01 | JDEDATE | NONE | NONE |
Event point for JDE Date. | ||||
cGenerationMode | EV01 | char | NONE | NONE |
An option that specifies the type of processing for an event. | ||||
nUseDateBranch | INT01 | integer | OPT | NONE |
Number of Days in Future to Query for Responses Due. | ||||
szDateBranch | MCU | char | OPT | NONE |
An alphanumeric code that identifies a separate entity within a business for which you want to track costs. For example, a business unit
| ||||
nInitialBranchCount | INT01 | integer | OPT | NONE |
Number of Days in Future to Query for Responses Due. |
B3401270 Cache, Process MRP Bucketless Dates | ||||
B3401340 MRP, Return Work Days | ||||
B9800210 Convert From and To Julian Date from JDEDATE |
F0007 Workday Calendar | ||||
F33133 Capacity Dates File | ||||
F3405 Forecast Consumption Periods |