BB713 RPG36
The provided BB713.rpg36.txt
is an RPG program (for IBM System/36 or AS/400) called by the BB715.ocl36.txt
OCL program as part of the preprocessing for the "Daily Requirements Report." It processes multi-load and non-multi-load orders to create an intermediate file (BB713M
) for further processing. Below, I’ll explain the process steps, business rules, tables (files) used, and external programs called.
Process Steps of the RPG Program¶
The BB713
RPG program reads order data from BBORDR
and BBORDR2
, processes multi-load orders (with or without a request date) and non-multi-load orders, and writes output to BB713M
. Here’s a step-by-step breakdown:
- Program Initialization:
- Header (H-spec): Line 0002 defines the program name (
BB713
) and page length (P064
). - File Definitions (F-spec):
BBORDR
(input, primary file, 512 bytes, indexed with 11 keys, disk, Line 0006).BBORDR2
(input, full procedural, 512 bytes, indexed with 11 keys, disk, Line 0007).BB713M
(output, 530 bytes, disk, Line 0008).
- Input Definitions (I-spec):
BBORDR
(primary file, Lines 0009–0019):BDKEY
(2–12): Key field for chaining.BORDNO
(4–9): Order number.BORQDT
(22–27): Request date.BOMULO
(284): Multi-load indicator ('Y' or 'N').BOTOLO
(285–287): Total loads.BOLODA
(288–290): Loads per day.BOLOVO
(291–297): Load volume.BOWEPU
(298): Weekend pickup ('Y' or 'N').BORQD8
(299–306): Request date in CYMD format.BBORDR2
(Lines 0021–0024):DFLDS1
(1–256),DFLDS2
(257–512): Generic data fields.BDDEL
(1): Delete flag ('D' for deleted).BDCO
(2–3): Company number.BDORD#
(4–9): Order number.BDSEQ
(10–12): Detail line sequence.BDQTY
(35–41): Order container quantity.
- Data Structures:
DS
(Lines 0033–0036): Defines$CYMD
(1–8),$CN
(1–2, century),$YMD
(3–8, year/month/day).UDS
(Lines 0038–0040): DefinesY2KCEN
(509–510, century) andY2KCMP
(511–512, comparison year for Y2K).
-
Indicators 01, 02, 03, 04, and 05 control input processing; 97 indicates end-of-file; 99 indicates chain failure.
-
Multi-Load Order with Request Date (Lines 0044–0102):
- Condition: Indicator 01 is on,
BOMULO = 'Y'
, andBORQDT ≠ 0
(Lines 0044–0046). -
Steps:
- Chains
BBORDR2
withBDKEY = '001'
to ensure a detail line exists (Lines 0047–0048). - If found (
N99
, Line 0050): - Sets
LODDT8
toBORQD8
(request date, Line 0051). - Sets
LODA
toBOLODA
(loads per day, Line 0052) andLOVO
toBOLOVO
(load volume, Line 0053). - Calculates remaining days (
REMDYS = BOTOLO / LODA
, Lines 0054–0058), adding 1 if there’s a remainder (REMWRK ≠ 0
). - Sets
REMLO
toBOTOLO
(total loads, Line 0059). - Calculates shipped loads (
SHLO = (BOTOLO * BOLOVO - BDQTY) / BOLOVO
) and volume (SKLOVO = SHLO * BOLOVO
, Lines 0061–0065). - Calls
GETLOD
to write the first day’s load (Line 0067). - If
REMDYS > 0
(Line 0069), loops to process remaining days (Lines 0070–0097):- Converts
LODDT8
to$CYMD
and$MDY
(Lines 0072–0073). - Calls
@GTOJ
to get Julian date (G$JD
) and day of week (G$JW
, Line 0074). - Adjusts
G$JD
to skip weekends ifBOWEPU ≠ 'Y'
(Lines 0075–0091): - Friday (
G$JW = 2
): Adds 3 days (to Monday). - Saturday (
G$JW = 3
): Adds 2 days (to Monday). - Sunday (
G$JW = 4
): Adds 1 day (to Monday). - Other days: Adds 1 day.
- Calls
@JTOG
to convert back to Gregorian ($MDY
,$CYMD
, Line 0092). - Updates
LODDT8
(Line 0094) and callsGETLOD
(Line 0096).
- Converts
- Ends loop when
REMDYS = 0
(Line 0097).
- Chains
-
Multi-Load Order without Request Date (Lines 0104–0111):
- Condition: Indicator 01 is on,
BOMULO = 'Y'
, andBORQDT = 0
(Lines 0104–0106). -
Steps:
- Chains
BBORDR2
withBDKEY = '001'
(Lines 0107–0108). - If found (
N99
), writes a detail record toBB713M
using exception outputREGDTL
(Line 0109), copyingDFLDS1
,DFLDS2
, andBORQD8
(Lines 0297–0300).
- Chains
-
Non-Multi-Load Order (Lines 0113–0129):
- Condition: Indicator 01 is on,
BOMULO ≠ 'Y'
(Lines 0113–0114). -
Steps:
- Sets
ORDNO
toBORDNO
(Line 0115). - Sets
BDKEY = '001'
and positionsBBORDR2
withSETLL
(Lines 0116–0117). - Loops through
BBORDR2
records (Lines 0118–0129): - Resets indicators 97, 03, 04, and 05 (Lines 0119–0120).
- Reads
BBORDR2
(Line 0121). - If end-of-file (
97
) or indicators 04/05 are on, jumps toENDIT
(Lines 0122–0124). - If
ORDNO = BDORD#
, writes a detail record toBB713M
usingREGDTL
(Line 0126) and continues reading (AGN
, Line 0127).
- Sets
-
GETLOD Subroutine (Lines 0136–0165):
-
Handles daily load calculations and writes to
BB713M
:- If
LODA > REMLO
, setsLODA = REMLO
(Lines 0141–0143, for the last day’s uneven loads). - Calculates day’s load volume (
LOVO = LODA * BOLOVO
, Line 0146). - If
SKLO > 0
(shipped loads exist, Lines 0148–0158): - If
LODA < SKLO
, zerosLOVO
and adjustsSKLO
andSKLOVO
. - Else, subtracts
SKLOVO
fromLOVO
andSKLO
from itself. - Updates
REMLO
(subtractsLODA
) andREMDYS
(subtracts 1, Lines 0160–0161). - Writes a record to
BB713M
using exception outputLODDTL
(Line 0163), includingDFLDS1
,DFLDS2
,LOVO
, andLODDT8
(Lines 0291–0295).
- If
-
@GTOJ Subroutine (Lines 0170–0234):
-
Converts Gregorian date (
$MDY
,$CN
) to Julian date (G$JD
) and day of week (G$JW
):- Breaks down
$MDY
into$YR
,$MONTH
,$DAY
(Lines 0182–0184). - Calculates century (
$CN
) usingY2KCEN
andY2KCMP
(Lines 0187–0193). - Converts month to Julian days (
G$JD = (MONTH - 3) * 30.6 + DAY
, Lines 0203–0215). - Adds year days (
(YEAR - 1900) * 365.25
, Lines 0218–0227). - Determines day of week (
G$JW = G$JD % 7
, Lines 0231–0232).
- Breaks down
-
@JTOG Subroutine (Lines 0238–0288):
-
Converts Julian date (
G$JD
) to Gregorian ($MDY
,$CN
):- Calculates year (
G$YYWK = G$JD / 365.25
, Lines 0248–0253). - Computes remaining days (
G$YD
, Lines 0255–0260). - Derives month (
G$M
) and day (G$D
) using iterative calculations (Lines 0263–0275). - Combines into
$MDY
(MMDDYY) and$CN
(century, Lines 0277–0286).
- Calculates year (
-
Output to BB713M:
- Two exception outputs:
LODDTL
(Lines 0291–0295): For multi-load orders with calculated dates, writesDFLDS1
,DFLDS2
,LOVO
(load volume),LODDT8
(date).REGDTL
(Lines 0297–0300): For non-multi-load or dateless multi-load orders, writesDFLDS1
,DFLDS2
,BORQD8
(request date).
Business Rules¶
- Multi-Load Orders with Request Date:
- Must have
BOMULO = 'Y'
and a non-zeroBORQDT
. - Requires a detail line with
BDKEY = '001'
inBBORDR2
. - Calculates loads per day (
LODA = BOLODA
), total volume (TOVO = BOTOLO * BOLOVO
), and shipped loads (SHLO = (TOVO - BDQTY) / BOLOVO
). - Distributes loads across days (
REMDYS = BOTOLO / LODA
, rounded up if remainder exists). - Skips weekends unless
BOWEPU = 'Y'
(weekend pickup allowed), advancing to the next valid day (e.g., Friday to Monday). -
Writes one record per day to
BB713M
with calculated volume (LOVO
) and date (LODDT8
). -
Multi-Load Orders without Request Date:
- Must have
BOMULO = 'Y'
andBORQDT = 0
. - Requires a detail line with
BDKEY = '001'
. -
Writes a single record to
BB713M
with the original request date (BORQD8
). -
Non-Multi-Load Orders:
- Must have
BOMULO ≠ 'Y'
. - Processes all detail lines in
BBORDR2
matching the order number (BDORD# = BORDNO
). -
Writes each matching detail line to
BB713M
withBORQD8
. -
Date Handling:
- Uses Y2K-compliant century calculation (
Y2KCEN
,Y2KCMP
) for date conversions. -
Converts between Gregorian (
$MDY
) and Julian (G$JD
) formats to handle date arithmetic and day-of-week checks. -
Load Skipping:
- Accounts for already shipped loads (
SKLO
) and volume (SKLOVO
), reducing the day’s load volume (LOVO
) if applicable.
Tables (Files) Used¶
- Input Files:
BBORDR
: Primary input file containing order headers (512 bytes, indexed with 11 keys).- Fields:
BDKEY
(2–12),BORDNO
(4–9),BORQDT
(22–27),BOMULO
(284),BOTOLO
(285–287),BOLODA
(288–290),BOLOVO
(291–297),BOWEPU
(298),BORQD8
(299–306).
- Fields:
-
BBORDR2
: Detail input file (512 bytes, indexed with 11 keys).- Fields:
DFLDS1
(1–256),DFLDS2
(257–512),BDDEL
(1),BDCO
(2–3),BDORD#
(4–9),BDSEQ
(10–12),BDQTY
(35–41).
- Fields:
-
Output File:
-
BB713M
: Output file (530 bytes) containing processed order data.LODDTL
records:DFLDS1
(1–256),DFLDS2
(257–512),LOVO
(513–519, load volume),LODDT8
(520–527, date).REGDTL
records:DFLDS1
(1–256),DFLDS2
(257–512),BORQD8
(520–527, request date).
-
Internal Data Structures:
DS
:$CYMD
(1–8),$CN
(1–2),$YMD
(3–8) for date handling.UDS
:Y2KCEN
(509–510),Y2KCMP
(511–512) for Y2K date logic.
External Programs Called¶
- None: The
BB713
program does not explicitly call other programs. It performs all processing internally, using subroutines (GETLOD
,@GTOJ
,@JTOG
) and file I/O.
Notes¶
- Integration with OCL: The
BB715.ocl36.txt
callsBB713
to preprocess order data, creatingBB713M
for subsequent programs (BB714
,BB714A
,#GSORT
,BB715
). - Multi-Load Logic: The program splits multi-load orders into daily records, respecting weekend restrictions unless explicitly allowed (
BOWEPU = 'Y'
). - Error Handling: Uses indicator 99 to check for missing detail lines and indicator 97 for end-of-file. No explicit error messages are output, as this is a preprocessing step.
- Y2K Compliance: The
@GTOJ
and@JTOG
subroutines handle century calculations to ensure correct date processing.
Summary¶
The BB713
RPG program preprocesses order data for the Daily Requirements Report, handling:
- Multi-load orders with request dates by calculating daily loads, skipping weekends if needed, and writing daily records.
- Multi-load orders without request dates by writing a single record.
- Non-multi-load orders by copying all matching detail lines.
It uses BBORDR
and BBORDR2
as inputs, writes to BB713M
, and follows rules for load distribution, date validation, and weekend handling. No external programs are called.
Files Used: BBORDR
, BBORDR2
, BB713M
.
External Programs: None.
If you need further details (e.g., field formats, subsequent programs like BB714
), or additional files, let me know!