Skip to content

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:

  1. File Initialization:
  2. 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 (per JB02).
    • 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 (types D, E).
    • SA5DBBM: Distributor buy-back memo invoice detail records (types D, E).
    • SA5BCMD: Memo invoice detail records (type M).
    • SA5BCMM: Memo invoice detail records for memo transactions (type M).
    • SA5COPD: Customer-owned product detail records (per JB01).
    • SA5COPM: Customer-owned product memo invoice detail records (per JB01).
    • SA5MOVD: Product movement detail records (per JB04).
    • SA5MOVM: Product movement memo invoice detail records (per JB04).
    • SA5COPH: Customer-owned product header records (1500 bytes).
    • SA5SHP: Shipping header records (1500 bytes).
    • SA5ADR: Address file (448 bytes, 42-byte alternate index, external key EXTK, per JB02).
  3. Record Processing (SA5TRN):

  4. The program reads each record from SA5TRN sequentially using the RPG cycle (NS 01, indicator 127 C).
  5. 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 (per JB01).
    • Record segments: SAREC (1–256), SAREC2 (257–512), SAREC3 (513–768), SAREC4 (769–1024).
  6. The program processes detail records and directs them to the appropriate output file based on SATYPE, SADEL, and SACOON.

  7. Record Processing (SA5TSH):

  8. The program reads matching records from SA5TSH (NS 03) for header information.
  9. Record segments: SSREC (1–256), SSREC2 (257–512), SSREC3 (513–768), SSREC4 (769–1024), SSREC5 (1025–1280), SSREC6 (1281–1500).
  10. Header records are used for customer-owned product (SA5COPH) and shipping (SA5SHP) output.

  11. Address Processing (SHPADR, per JB02):

  12. The program reads SHPADR to retrieve ship-to address data, copying it to SA5ADR for sales analysis address records.
  13. 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, per MG03), SDCPON (customer PO number, per MG03).
  14. Output Processing:

  15. The program directs records to output files based on conditions:
    • Standard Transactions (SATYPE = ' ', 'C', 'R'):
    • If SADEL ≠ 'M', write to SA5FILD (DADD 01).
    • If SADEL = 'M', write to SA5FILM (DADD 02).
    • Distributor Buy-Back (SATYPE = 'D', 'E'):
    • If SADEL ≠ 'M', write to SA5DBBD (DADD 01 10).
    • If SADEL = 'M', write to SA5DBBM (DADD 02 10).
    • Memo Invoices (SATYPE = 'M'):
    • If SADEL ≠ 'M', write to SA5BCMD (DADD 01 35, sets position 1 to 'A').
    • If SADEL = 'M', write to SA5BCMM (DADD 02 35, sets position 1 to 'A').
    • Customer-Owned Product (SACOON = 'Y', per JB01):
    • If SADEL ≠ 'M', write to SA5COPD (DADD 01 36).
    • If SADEL = 'M', write to SA5COPM (DADD 02 36).
    • Product Movement (per JB04):
    • If SADEL ≠ 'M', write to SA5MOVD (DADD 01 37).
    • If SADEL = 'M', write to SA5MOVM (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 from SHPADR.
  16. Each output file receives the full record (SAREC, SAREC2, SAREC3, SAREC4 for details; SSREC, SSREC2, SSREC3, SSREC4, SSREC5, SSREC6 for headers).

  17. Cycle Completion:

  18. The RPG cycle processes all records in SA5TRN, matching with SA5TSH and SHPADR as needed, until the end of the file.
  19. The program terminates after writing all records to the appropriate output files, closing all files.

Business Rules

  1. Transaction Type Segregation:
  2. Transactions are directed to specific files based on SATYPE:
    • ' ', 'C', 'R': Standard transactions to SA5FILD (non-memo) or SA5FILM (memo).
    • 'D', 'E': Distributor buy-back to SA5DBBD (non-memo) or SA5DBBM (memo).
    • 'M': Memo invoices to SA5BCMD (non-memo) or SA5BCMM (memo), with position 1 set to 'A'.
  3. Customer-owned product transactions (SACOON = 'Y') go to SA5COPD (non-memo) or SA5COPM (memo).
  4. Product movement transactions go to SA5MOVD (non-memo) or SA5MOVM (memo) (per JB04).

  5. Memo Invoice Handling:

  6. Records with SADEL = 'M' are treated as memo invoices and written to separate files (SA5FILM, SA5DBBM, SA5BCMM, SA5COPM, SA5MOVM).
  7. Memo invoice records in SA5BCMD and SA5BCMM have position 1 set to 'A' to indicate active status.

  8. Customer-Owned Product (per JB01):

  9. Transactions flagged as customer-owned product (SACOON = 'Y') are written to SA5COPD (details) or SA5COPM (memo details), and headers to SA5COPH.
  10. The program supports new fields for customer-owned product shipments and updates supplemental and accessorials/marks tables.

  11. Address Copying (per JB02):

  12. Order shipment addresses from SHPADR are copied to SA5ADR for sales analysis, ensuring accurate address data for reporting and distribution.
  13. Fields include company, customer, ship-to, order details, and viscosity barcode fields (per MG03).

  14. Viscosity Barcode Support (per MG03):

  15. Additional fields (SDASNN, SDCPON) are included in SA5ADR to support viscosity barcode address printing labels, enhancing integration with barcode systems.

  16. Product Movement (per JB04):

  17. All product movement transactions are written to SA5MOVD (non-memo) or SA5MOVM (memo), ensuring tracking of product movement data.

  18. No Data Modification:

  19. The program copies records without modifying their content, relying on input data being correctly formatted.
  20. Output files receive the full record segments (SAREC, SSREC, etc.) as read.

  21. No Error Handling:

  22. 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

  1. SA5TRN:
  2. Description: Sales analysis transaction detail file.
  3. Attributes: 1024 bytes per record, primary input file (IP), disk-based.
  4. 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.
  5. Purpose: Contains transaction details for sales analysis.
  6. Usage: Read sequentially to direct records to appropriate output files.

  7. SA5TSH:

  8. Description: Sales analysis transaction header file.
  9. Attributes: 1500 bytes per record, secondary input file (IS), disk-based.
  10. 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.
  11. Purpose: Contains transaction header data for customer-owned product and shipping.
  12. Usage: Read to write headers to SA5COPH and SA5SHP.

  13. SHPADR:

  14. Description: Ship-to address file (per JB02).
  15. Attributes: 448 bytes per record, input file (IF), 13-byte alternate index, disk-based.
  16. Purpose: Contains ship-to address data for sales analysis.
  17. Usage: Read to copy address data to SA5ADR.

  18. SA5FILD:

  19. Description: Sales analysis detail file for standard transactions.
  20. Attributes: 1024 bytes per record, output file (O), add capability (A), disk-based.
  21. Purpose: Stores non-memo standard transaction details (SATYPE = ' ', 'C', 'R').
  22. Usage: Receives records from SA5TRN (DADD 01).

  23. SA5FILM:

  24. Description: Sales analysis detail file for memo invoices.
  25. Attributes: 1024 bytes per record, output file (O), add capability (A), disk-based.
  26. Purpose: Stores memo invoice details (SATYPE = ' ', 'C', 'R', SADEL = 'M').
  27. Usage: Receives records from SA5TRN (DADD 02).

  28. SA5DBBD:

  29. Description: Distributor buy-back detail file.
  30. Attributes: 1024 bytes per record, output file (O), add capability (A), disk-based.
  31. Purpose: Stores non-memo distributor buy-back details (SATYPE = 'D', 'E').
  32. Usage: Receives records from SA5TRN (DADD 01 10).

  33. SA5DBBM:

  34. Description: Distributor buy-back memo invoice detail file.
  35. Attributes: 1024 bytes per record, output file (O), add capability (A), disk-based.
  36. Purpose: Stores memo invoice distributor buy-back details (SATYPE = 'D', 'E', SADEL = 'M').
  37. Usage: Receives records from SA5TRN (DADD 02 10).

  38. SA5BCMD:

  39. Description: Memo invoice detail file.
  40. Attributes: 1024 bytes per record, output file (O), add capability (A), disk-based.
  41. Purpose: Stores non-memo memo invoice details (SATYPE = 'M').
  42. Usage: Receives records from SA5TRN (DADD 01 35, sets position 1 to 'A').

  43. SA5BCMM:

  44. Description: Memo invoice detail file for memo transactions.
  45. Attributes: 1024 bytes per record, output file (O), add capability (A), disk-based.
  46. Purpose: Stores memo invoice details (SATYPE = 'M', SADEL = 'M').
  47. Usage: Receives records from SA5TRN (DADD 02 35, sets position 1 to 'A').

  48. 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).
  49. 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).
  50. 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).
  51. 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).
  52. 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).
  53. 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).
  54. 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).

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.