BB605 RPG36
The RPG program BB605.rpg36.txt
is called by the BB600.ocl36.txt
OCL program as part of the invoice posting workflow in an IBM System/36 or AS/400 environment. Its primary function is to post sales analysis transactions from the SA5TRN
and SA5TSH
files to various sales analysis files, handling different transaction types (e.g., distributor buy-back, memo invoices, customer-owned product, product movement) and updating address data. The program includes enhancements for customer-owned product shipments, address copying, and viscosity barcode address printing labels. Below is a detailed explanation of the process steps, business rules, tables used, and external programs called.
Process Steps of the BB605 RPG Program¶
The BB605
program processes sales analysis transactions by reading records from SA5TRN
(transaction details) and SA5TSH
(transaction headers), matching them with address data from SHPADR
, and writing to multiple output files based on transaction type and conditions. It uses the RPG cycle for sequential processing and supports specialized handling for various transaction types.
Process Steps:¶
- File Initialization:
-
The program opens the following files:
- Input Files:
SA5TRN
: Primary input file (IP
), 1024 bytes per record, disk-based. Contains sales analysis transaction details.SA5TSH
: Secondary input file (IS
), 1500 bytes per record, disk-based. Contains sales analysis transaction headers.SHPADR
: Input file (IF
), 448 bytes per record, 13-byte alternate index (AI
), disk-based. Contains ship-to address data (perJB02
).- Output Files (all disk-based, 1024 or 1500 bytes per record, add capability
A
): SA5FILD
: Sales analysis file for detail records (non-memo, non-buy-back).SA5FILM
: Sales analysis file for memo invoice detail records.SA5DBBD
: Distributor buy-back detail records (typesD
,E
).SA5DBBM
: Distributor buy-back memo invoice detail records (typesD
,E
).SA5BCMD
: Memo invoice detail records (typeM
).SA5BCMM
: Memo invoice detail records for memo transactions (typeM
).SA5COPD
: Customer-owned product detail records (perJB01
).SA5COPM
: Customer-owned product memo invoice detail records (perJB01
).SA5MOVD
: Product movement detail records (perJB04
).SA5MOVM
: Product movement memo invoice detail records (perJB04
).SA5COPH
: Customer-owned product header records (1500 bytes).SA5SHP
: Shipping header records (1500 bytes).SA5ADR
: Address file (448 bytes, 42-byte alternate index, external keyEXTK
, perJB02
).
-
Record Processing (SA5TRN):
- The program reads each record from
SA5TRN
sequentially using the RPG cycle (NS 01
, indicator127 C
). - Key fields extracted include:
SADEL
(1 byte, position 1): Delete flag ('D'
for deleted,'M'
for memo invoices).SACO#
(2 bytes, positions 2–3): Company number.SACUST
(6 bytes, positions 4–9): Customer number.SATYPE
(1 byte, position 60): Transaction type (' '
,'M'
,'C'
,'R'
,'D'
,'E'
).SACOON
(1 byte, position 298): Customer-owned product flag (perJB01
).- Record segments:
SAREC
(1–256),SAREC2
(257–512),SAREC3
(513–768),SAREC4
(769–1024).
-
The program processes detail records and directs them to the appropriate output file based on
SATYPE
,SADEL
, andSACOON
. -
Record Processing (SA5TSH):
- The program reads matching records from
SA5TSH
(NS 03
) for header information. - Record segments:
SSREC
(1–256),SSREC2
(257–512),SSREC3
(513–768),SSREC4
(769–1024),SSREC5
(1025–1280),SSREC6
(1281–1500). -
Header records are used for customer-owned product (
SA5COPH
) and shipping (SA5SHP
) output. -
Address Processing (SHPADR, per JB02):
- The program reads
SHPADR
to retrieve ship-to address data, copying it toSA5ADR
for sales analysis address records. -
Fields written to
SA5ADR
include:SDCO
(company number),SDCUST
(customer number),SDSHIP
(ship-to number),SDORDN
(order number),SDSHPN
(ship-to number),SDPORD
(PO number),SDCAR
(carrier),SDBOLN
(BOL number),SDSRN
(serial number),SDINVN
(invoice number),SDEDIC
(EDI code),SDEDYN
(EDI year),SDNAME
(name),SDADR1
(address 1),SDADR2
(address 2),SDCITY
(city),SDST
(state),SDZIP
(zip code),SDCTY
(country),SDPHN1
(phone 1),SDPHN2
(phone 2),SDACCT
(account),SDASNN
(ASN number, perMG03
),SDCPON
(customer PO number, perMG03
).
-
Output Processing:
- The program directs records to output files based on conditions:
- Standard Transactions (
SATYPE = ' '
,'C'
,'R'
): - If
SADEL ≠ 'M'
, write toSA5FILD
(DADD 01
). - If
SADEL = 'M'
, write toSA5FILM
(DADD 02
). - Distributor Buy-Back (
SATYPE = 'D'
,'E'
): - If
SADEL ≠ 'M'
, write toSA5DBBD
(DADD 01 10
). - If
SADEL = 'M'
, write toSA5DBBM
(DADD 02 10
). - Memo Invoices (
SATYPE = 'M'
): - If
SADEL ≠ 'M'
, write toSA5BCMD
(DADD 01 35
, sets position 1 to'A'
). - If
SADEL = 'M'
, write toSA5BCMM
(DADD 02 35
, sets position 1 to'A'
). - Customer-Owned Product (
SACOON = 'Y'
, perJB01
): - If
SADEL ≠ 'M'
, write toSA5COPD
(DADD 01 36
). - If
SADEL = 'M'
, write toSA5COPM
(DADD 02 36
). - Product Movement (per
JB04
): - If
SADEL ≠ 'M'
, write toSA5MOVD
(DADD 01 37
). - If
SADEL = 'M'
, write toSA5MOVM
(DADD 02 37
). - Header Records:
- Customer-owned product headers write to
SA5COPH
(DADD 03 36
). - Shipping headers write to
SA5SHP
(DADD 03N36
). - Address Records (per
JB02
): - Write to
SA5ADR
(EADD SHAADD
) with address data fromSHPADR
.
- Standard Transactions (
-
Each output file receives the full record (
SAREC
,SAREC2
,SAREC3
,SAREC4
for details;SSREC
,SSREC2
,SSREC3
,SSREC4
,SSREC5
,SSREC6
for headers). -
Cycle Completion:
- The RPG cycle processes all records in
SA5TRN
, matching withSA5TSH
andSHPADR
as needed, until the end of the file. - The program terminates after writing all records to the appropriate output files, closing all files.
Business Rules¶
- Transaction Type Segregation:
- Transactions are directed to specific files based on
SATYPE
:' '
,'C'
,'R'
: Standard transactions toSA5FILD
(non-memo) orSA5FILM
(memo).'D'
,'E'
: Distributor buy-back toSA5DBBD
(non-memo) orSA5DBBM
(memo).'M'
: Memo invoices toSA5BCMD
(non-memo) orSA5BCMM
(memo), with position 1 set to'A'
.
- Customer-owned product transactions (
SACOON = 'Y'
) go toSA5COPD
(non-memo) orSA5COPM
(memo). -
Product movement transactions go to
SA5MOVD
(non-memo) orSA5MOVM
(memo) (perJB04
). -
Memo Invoice Handling:
- Records with
SADEL = 'M'
are treated as memo invoices and written to separate files (SA5FILM
,SA5DBBM
,SA5BCMM
,SA5COPM
,SA5MOVM
). -
Memo invoice records in
SA5BCMD
andSA5BCMM
have position 1 set to'A'
to indicate active status. -
Customer-Owned Product (per JB01):
- Transactions flagged as customer-owned product (
SACOON = 'Y'
) are written toSA5COPD
(details) orSA5COPM
(memo details), and headers toSA5COPH
. -
The program supports new fields for customer-owned product shipments and updates supplemental and accessorials/marks tables.
-
Address Copying (per JB02):
- Order shipment addresses from
SHPADR
are copied toSA5ADR
for sales analysis, ensuring accurate address data for reporting and distribution. -
Fields include company, customer, ship-to, order details, and viscosity barcode fields (per
MG03
). -
Viscosity Barcode Support (per MG03):
-
Additional fields (
SDASNN
,SDCPON
) are included inSA5ADR
to support viscosity barcode address printing labels, enhancing integration with barcode systems. -
Product Movement (per JB04):
-
All product movement transactions are written to
SA5MOVD
(non-memo) orSA5MOVM
(memo), ensuring tracking of product movement data. -
No Data Modification:
- The program copies records without modifying their content, relying on input data being correctly formatted.
-
Output files receive the full record segments (
SAREC
,SSREC
, etc.) as read. -
No Error Handling:
- The program assumes input files (
SA5TRN
,SA5TSH
,SHPADR
) exist and contain valid data, and output files can be written to without issues.
Tables (Files) Used¶
- SA5TRN:
- Description: Sales analysis transaction detail file.
- Attributes: 1024 bytes per record, primary input file (
IP
), disk-based. - Fields Used:
SADEL
(1 byte, position 1): Delete flag ('D'
,'M'
).SACO#
(2 bytes, positions 2–3): Company number.SACUST
(6 bytes, positions 4–9): Customer number.SATYPE
(1 byte, position 60): Transaction type (' '
,'M'
,'C'
,'R'
,'D'
,'E'
).SACOON
(1 byte, position 298): Customer-owned product flag.SAREC
(256 bytes, positions 1–256),SAREC2
(257–512),SAREC3
(513–768),SAREC4
(769–1024): Record segments.
- Purpose: Contains transaction details for sales analysis.
-
Usage: Read sequentially to direct records to appropriate output files.
-
SA5TSH:
- Description: Sales analysis transaction header file.
- Attributes: 1500 bytes per record, secondary input file (
IS
), disk-based. - Fields Used:
SSREC
(256 bytes, positions 1–256),SSREC2
(257–512),SSREC3
(513–768),SSREC4
(769–1024),SSREC5
(1025–1280),SSREC6
(1281–1500): Record segments.
- Purpose: Contains transaction header data for customer-owned product and shipping.
-
Usage: Read to write headers to
SA5COPH
andSA5SHP
. -
SHPADR:
- Description: Ship-to address file (per
JB02
). - Attributes: 448 bytes per record, input file (
IF
), 13-byte alternate index, disk-based. - Purpose: Contains ship-to address data for sales analysis.
-
Usage: Read to copy address data to
SA5ADR
. -
SA5FILD:
- Description: Sales analysis detail file for standard transactions.
- Attributes: 1024 bytes per record, output file (
O
), add capability (A
), disk-based. - Purpose: Stores non-memo standard transaction details (
SATYPE = ' '
,'C'
,'R'
). -
Usage: Receives records from
SA5TRN
(DADD 01
). -
SA5FILM:
- Description: Sales analysis detail file for memo invoices.
- Attributes: 1024 bytes per record, output file (
O
), add capability (A
), disk-based. - Purpose: Stores memo invoice details (
SATYPE = ' '
,'C'
,'R'
,SADEL = 'M'
). -
Usage: Receives records from
SA5TRN
(DADD 02
). -
SA5DBBD:
- Description: Distributor buy-back detail file.
- Attributes: 1024 bytes per record, output file (
O
), add capability (A
), disk-based. - Purpose: Stores non-memo distributor buy-back details (
SATYPE = 'D'
,'E'
). -
Usage: Receives records from
SA5TRN
(DADD 01 10
). -
SA5DBBM:
- Description: Distributor buy-back memo invoice detail file.
- Attributes: 1024 bytes per record, output file (
O
), add capability (A
), disk-based. - Purpose: Stores memo invoice distributor buy-back details (
SATYPE = 'D'
,'E'
,SADEL = 'M'
). -
Usage: Receives records from
SA5TRN
(DADD 02 10
). -
SA5BCMD:
- Description: Memo invoice detail file.
- Attributes: 1024 bytes per record, output file (
O
), add capability (A
), disk-based. - Purpose: Stores non-memo memo invoice details (
SATYPE = 'M'
). -
Usage: Receives records from
SA5TRN
(DADD 01 35
, sets position 1 to'A'
). -
SA5BCMM:
- Description: Memo invoice detail file for memo transactions.
- Attributes: 1024 bytes per record, output file (
O
), add capability (A
), disk-based. - Purpose: Stores memo invoice details (
SATYPE = 'M'
,SADEL = 'M'
). -
Usage: Receives records from
SA5TRN
(DADD 02 35
, sets position 1 to'A'
). -
SA5COPD:
- Description: Customer-owned product detail file (per
JB01
). - Attributes: 1024 bytes per record, output file (
O
), add capability (A
), disk-based. - Purpose: Stores non-memo customer-owned product details (
SACOON = 'Y'
). - Usage: Receives records from
SA5TRN
(DADD 01 36
).
- Description: Customer-owned product detail file (per
-
SA5COPM:
- Description: Customer-owned product memo invoice detail file (per
JB01
). - Attributes: 1024 bytes per record, output file (
O
), add capability (A
), disk-based. - Purpose: Stores memo invoice customer-owned product details (
SACOON = 'Y'
,SADEL = 'M'
). - Usage: Receives records from
SA5TRN
(DADD 02 36
).
- Description: Customer-owned product memo invoice detail file (per
-
SA5MOVD:
- Description: Product movement detail file (per
JB04
). - Attributes: 1024 bytes per record, output file (
O
), add capability (A
), disk-based. - Purpose: Stores non-memo product movement details.
- Usage: Receives records from
SA5TRN
(DADD 01 37
).
- Description: Product movement detail file (per
-
SA5MOVM:
- Description: Product movement memo invoice detail file (per
JB04
). - Attributes: 1024 bytes per record, output file (
O
), add capability (A
), disk-based. - Purpose: Stores memo invoice product movement details.
- Usage: Receives records from
SA5TRN
(DADD 02 37
).
- Description: Product movement memo invoice detail file (per
-
SA5COPH:
- Description: Customer-owned product header file.
- Attributes: 1500 bytes per record, output file (
O
), add capability (A
), disk-based. - Purpose: Stores customer-owned product header records.
- Usage: Receives records from
SA5TSH
(DADD 03 36
).
-
SA5SHP:
- Description: Shipping header file.
- Attributes: 1500 bytes per record, output file (
O
), add capability (A
), disk-based. - Purpose: Stores shipping header records.
- Usage: Receives records from
SA5TSH
(DADD 03N36
).
-
SA5ADR:
- Description: Sales analysis address file (per
JB02
). - Attributes: 448 bytes per record, output file (
O
), 42-byte alternate index, external key (EXTK
), disk-based. - Fields Used:
SDCO
(company),SDCUST
(customer),SDSHIP
(ship-to),SDORDN
(order number),SDSHPN
(ship-to number),SDPORD
(PO number),SDCAR
(carrier),SDBOLN
(BOL number),SDSRN
(serial number),SDINVN
(invoice number),SDEDIC
(EDI code),SDEDYN
(EDI year),SDNAME
(name),SDADR1
(address 1),SDADR2
(address 2),SDCITY
(city),SDST
(state),SDZIP
(zip),SDCTY
(country),SDPHN1
(phone 1),SDPHN2
(phone 2),SDACCT
(account),SDASNN
(ASN number),SDCPON
(customer PO number).- Purpose: Stores copied ship-to address data for sales analysis and viscosity barcode labels.
- Usage: Receives address data from
SHPADR
(EADD SHAADD
).
- Description: Sales analysis address file (per
External Programs Called¶
The BB605
RPG program does not explicitly call any external programs. It is a self-contained program that processes input from SA5TRN
, SA5TSH
, and SHPADR
and writes to multiple output files.
Summary¶
The BB605
RPG program, called by BB600.ocl36.txt
, posts sales analysis transactions by:
- Reading transaction details (SA5TRN
) and headers (SA5TSH
).
- Directing records to output files based on transaction type (SATYPE
), delete flag (SADEL
), and customer-owned product flag (SACOON
):
- Standard: SA5FILD
, SA5FILM
.
- Distributor buy-back: SA5DBBD
, SA5DBBM
.
- Memo invoices: SA5BCMD
, SA5BCMM
.
- Customer-owned product: SA5COPD
, SA5COPM
, SA5COPH
.
- Product movement: SA5MOVD
, SA5MOVM
.
- Shipping headers: SA5SHP
.
- Copying ship-to addresses from SHPADR
to SA5ADR
for sales analysis and viscosity barcode labels.
- Supporting customer-owned product, product movement, and address enhancements (per JB01
, JB02
, JB04
, MG03
).
- Terminating after processing all records.
Tables Used: SA5TRN
(transaction details), SA5TSH
(transaction headers), SHPADR
(ship-to addresses), SA5FILD
, SA5FILM
, SA5DBBD
, SA5DBBM
, SA5BCMD
, SA5BCMM
, SA5COPD
, SA5COPM
, SA5MOVD
, SA5MOVM
, SA5COPH
, SA5SHP
, SA5ADR
(output files).
External Programs Called: None.
This program ensures accurate sales analysis by segregating transactions into appropriate files, supporting specialized data (e.g., customer-owned product, viscosity barcodes), and integrating with the broader invoice posting workflow.