BB705 RPG36
The provided document, BB705.rpg36.txt
, is an RPG program for the IBM System/36, called by the OCL program BB705.ocl36.txt
to generate a Pending Orders Report. It processes sorted order data and produces a formatted report based on company, location, request date, carrier, order, and sequence. Below, I’ll explain the process steps, business rules, tables used, and external programs called, integrating context from the previous programs (BB705P.ocl36.txt
, BB705P.rpg36.txt
, and BB705.ocl36.txt
).
Process Steps of the RPG Program¶
The BB705
RPG program reads sorted order data from BBORDR
(via BB705S
from the OCL), retrieves additional details from supporting files, and outputs a formatted report to the LIST
printer file. Here’s a step-by-step breakdown:
- File and Data Definitions:
- Input Files:
BBORDR
(532 bytes, primary input, sorted data fromBB705S
): Contains order header, detail, and remark records.ARCUST
(384 bytes, indexed): Customer data.SHIPTO
(2048 bytes, indexed): Ship-to address data.BICONT
(256 bytes, indexed): Company data (used inBB705P
for validation).GSCTUM
(64 bytes, indexed): Unit of measure or control data.INLOC
(512 bytes, indexed): Location data (used inBB705P
for validation).
- Output File:
LIST
(164 bytes, printer file): Outputs the formatted pending orders report.
- Arrays:
AST
(82 elements, 2 characters): Stores asterisks for formatting (e.g.,*** TOTAL ***
).HYP
(82 elements, 2 characters): Stores hyphens for formatting (e.g., separators).
- Record Formats (from
BBORDR
):- Header (
NS 01
): Fields likeBOCO
(company),BORDNO
(order number),BOCUST
(customer),BOSHIP
(ship-to),BORQDT
(request date), etc. - Detail (
NS 02
): Fields likeBDLOC
(location),BDPROD
(product),BDQTY
(quantity),BDPRCE
(price), etc. - Miscellaneous Detail (
NS 03
): Fields likeBMMSTY
(type),BMQTY
(quantity),BMAMT
(amount), etc. - Order Entry Remarks (
NS 04
): Fields likeBXOMK1-4
(remarks). - Invoice/Dispatch Remarks (
NS 05
): Fields likeBXIMK1-2
(invoice remarks),BXDSP1-4
(dispatch info). - Bill of Lading Remarks (
NS 06
): Fields likeBXBMK1-4
(BOL remarks),BXFRNM
(freight name),BXFRA1-3
(freight addresses).
- Header (
-
Program Modifications:
VV01
: Changed product code (BDPROD
) from numeric to alphanumeric.DC01
(05/12/2010): Added call toMSHPADR
for compressed ship-to address.JB02
(05/31/2010): RevisedMSHPADR
parameters to include country (SCTY
).JB03
(10/18/2017): Removed order types 'M' (cash return) and 'C' (cash sale), with 'M' reused for product move.
-
Initialization and Main Processing:
- The program uses RPG’s cycle-driven processing to read
BBORDR
records sequentially. - Level Breaks:
L3
(company/location): Triggers on changes inBOCO
orBOLOCT
(temporary location, positions 513-515).L2
(request date): Triggers on changes inBORQDT
.L1
(order): Triggers on changes inBORDNO
.
- Header Subroutine (
HDR
):- Validates order type (
BOTYPE = 'R'
or'M'
, perJB03
modification; sets indicator27
). - Retrieves customer data from
ARCUST
usingARKEY
(company + customer number). - Retrieves ship-to data:
- If
BOSHIP = 0
, uses customer address (ARNAME
,ARADR1-4
) and blanksSAD5
,SCTY
. - Otherwise, chains
SHIPTO
usingKEY11
(company + customer or order number + ship-to). - Calls
MSHPADR
to get compressed ship-to address (SNAM
,SAD1-5
,SCTY
). - Sets indicators
70-72
,61
based on non-blank address fields (SAD2-5
). - Checks if prepaid amount (
BOPAMT
) is zero (sets61
).
- Validates order type (
-
Detail Processing:
- Processes header, detail, and remark records based on record type (
NS 01-06
). - Accumulates totals for quantities (
BDQTY
,BMQTY
) and amounts (BDTOT
,BMTOT
,L1TOT
).
- Processes header, detail, and remark records based on record type (
-
Report Output:
- Printer File (
LIST
):- Company/Location Header (
D 102 L3
): Prints company name (BCNAME
), page number, system date (SYDATEY
), program name, and system time (SYTIME
). - Location Header (
D 1 L3
): Prints location code (BOLOCT
), location name (LOCNAM
), and date range (FRDMDYY
toTODMDYY
). - Request Date Header (
D 0/01 L2
): Prints request date (BORQDTY
) and “PENDING ORDERS”. - Order Header (
D 1 L1
): Prints company (BOCO
), order number (BORDNOZ
), type (BOTYPE
), customer (BOCUSTZ
,ARNAME
), ship-to (BOSHIPZ
,SNAM
,SAD1-5
,SCTY
), bill of lading (BOBOL#Z
), order date (BOORDTY
), pickup date (BORQDTY
), time (BOTIME
), carrier code (BOCACD
), freight codes (BOFPER
,BOFRCD
), PO numbers (BOPORD
,BOSHPO
), user fields (BOVAR1-2
), routing (BORTG1-2
), terms (BOTERM
), salesman (BOSLMN
), delivery (BODELV
), multi-load info (BOMULO
,BOTOLOZ
,BOLODAZ
,BOLOVOM
), and weekend pickup (BOWEPU
). - Detail Lines (
D 1 02 60
): Prints location (BDLOC
), product (BDPROD
), quantity (BDQTY
), price (BDPRCE
), unit of measure (BDUM
), no-charge code (BDNOCH
), description (BDDESC
), and total (BDTOT
). - Miscellaneous Lines (
D 1 03 60
): Prints type (BMMSTY
), quantity (BMQTY
), amount (BMAMT
), G/L number (BMGL#
), description (BMDESC
), and total (BMTOT
). - Remarks:
- Order Entry (
PRTOEM
,62
): PrintsBXOMK1-4
if non-blank. - Dispatch Info (
PRTDIM
,66
): PrintsBXDSP1-4
if non-blank. - Invoice Remarks (
PRTIVM
,63
): PrintsBXIMK1-2
if non-blank. - BOL Remarks (
PRTBOM
,64
): PrintsBXBMK1-4
if non-blank. - Freight Info (
PRTFRM
,65
): PrintsBXFRNM
,BXFRA1-3
if non-blank. - Totals:
- Order Total (
T 1 L1
): Prints “ TOTAL ” andL1TOT
. - Separator (
T 11 L1
): Prints asterisks (AST
).
- Company/Location Header (
-
Output Logic:
- Remarks are printed only if non-blank (indicators
62-66
). - Address fields (
SAD2-5
) are conditionally printed based on indicators70-72
,61
.
- Remarks are printed only if non-blank (indicators
-
Program Termination:
- The RPG cycle processes all records, outputs the report, and ends when
BBORDR
is exhausted.
Business Rules¶
The program enforces the following business rules for the pending orders report:
- Order Type Filtering:
-
Only orders with
BOTYPE = 'R'
(regular) or'M'
(product move, perJB03
) are included. Legacy types 'M' (cash return) and 'C' (cash sale) are excluded. -
Data Validation:
- Customer data is retrieved from
ARCUST
using company and customer number (BOCO
,BOCUST
). - Ship-to data is retrieved from
SHIPTO
or defaults to customer address ifBOSHIP = 0
. ForBOSHIP = 999
or900
, special key construction is used. -
The
MSHPADR
program compresses ship-to addresses, including country (SCTY
, perJB02
). -
Report Formatting:
- Hierarchical structure: Company/location (
L3
), request date (L2
), order (L1
). - Includes detailed order information (customer, ship-to, dates, carrier, freight, etc.).
- Remarks (order, invoice, dispatch, BOL, freight) are printed only if non-blank.
-
Totals are calculated for detail (
BDTOT
), miscellaneous (BMTOT
), and order-level (L1TOT
). -
Address Handling:
- Ship-to address (
SAD1-5
) is printed only for non-blank fields, with country (SCTY
) included if available. -
Prepaid amount (
BOPAMT
) is highlighted if zero. -
Data Integration:
- Uses
BICONT
andINLOC
for company and location details (consistent withBB705P
validation). GSCTUM
provides unit of measure data for detail lines.
Tables Used¶
- AST:
-
Array (82 elements, 2 characters) for printing asterisks (e.g.,
*** TOTAL ***
or separators). -
HYP:
-
Array (82 elements, 2 characters) for printing hyphens (e.g., section separators).
-
Files as Data Sources (function as relational tables):
BBORDR
: Sorted order data (header, detail, remarks).ARCUST
: Customer data (name, address).SHIPTO
: Ship-to address data.BICONT
: Company data.GSCTUM
: Unit of measure or control data.INLOC
: Location data.
No additional RPG tables (e.g., TABxxx
) are defined.
External Programs Called¶
- MSHPADR:
- Called in the
HDR
subroutine to retrieve compressed ship-to addresses. - Parameters:
KEY11
(company + customer/order + ship-to),SNAM
,SAD1-5
,SCTY
. - Added in
DC01
(05/12/2010), with country support inJB02
(05/31/2010).
Summary¶
- Process Steps:
- Define input files (
BBORDR
,ARCUST
,SHIPTO
,BICONT
,GSCTUM
,INLOC
) and output printer file (LIST
). - Process
BBORDR
records using RPG cycle with level breaks (L3
,L2
,L1
). - Execute
HDR
subroutine to validate order type, retrieve customer/ship-to data, and callMSHPADR
for address compression. - Output report with headers (company, location, date, order), details (products, quantities, prices), remarks (order, invoice, dispatch, BOL, freight), and totals.
-
End when
BBORDR
is exhausted. -
Business Rules:
- Filter orders by type ('R', 'M').
- Validate and retrieve customer/ship-to data.
- Print non-blank remarks and addresses.
- Calculate and display totals at order level.
-
Format report hierarchically for clarity.
-
Tables Used:
- Arrays:
AST
(asterisks),HYP
(hyphens). -
Files:
BBORDR
,ARCUST
,SHIPTO
,BICONT
,GSCTUM
,INLOC
. -
External Programs Called:
MSHPADR
: Retrieves compressed ship-to addresses.
This program completes the workflow started by BB705P
(input validation) and BB705.ocl36.txt
(data preparation/sorting). If you have the RPG code for BB7051
or file layouts for BBORDR
, ARCUST
, etc., I can provide further details. Let me know if you need additional analysis or a search for related information!