BB943P RPGLE
The provided document is an RPGLE program named BB943P, called from the OCL procedure BB943INQ.ocl36.txt in the IBM System/36 (or AS/400 compatibility mode) environment. This program is designed to "Work With Customer Sales Agreements," providing functionality for inquiring, maintaining, copying, or deleting customer sales agreement records. Below, I’ll explain the process steps, business rules, tables used, and external programs called, based on the provided RPGLE source code and the OCL context.
Process Steps of the RPGLE Program¶
The BB943P program is an interactive RPGLE program that manages a subfile-based display for customer sales agreements. It supports inquiry (INQ) and maintenance (MNT) modes, allowing users to view, add, update, copy, or delete sales agreement records. Here’s a detailed breakdown of the process steps:
- Initialization (
*inzsrSubroutine): - Receive Parameters: The program accepts two parameters via the
*ENTRYplist:p$mode(3 characters): Specifies the run mode (INQfor inquiry orMNTfor maintenance).p$fgrp(1 character): Specifies the file group (GorZ) for file overrides.
- Set Up Work Fields: Initializes variables, such as
rrn1(subfile relative record number),pagsz1(page size set to 28), and message handling fields (dspmsg,m@pgmq). - Set Current Date/Time: Uses the
TIMEoperation to populatet#timeand converts it to a date format (t#cymd) for validations. - Define Key Lists: Sets up key lists (
kls1s1,kls1s2, etc.) for file access based on fields like company (c1cono), customer (c1cust), location (c1loc), and container (c1cntr). -
Set Default Values: Initializes fields like
c1statto'CF '(likely a default status) ando$fileto'BICUAG'(primary file). -
Open Database Tables (
opntblSubroutine): - File Overrides: Based on
p$fgrp(GorZ), applies file overrides usingovgorovzarrays (e.g.,ovrdbf file(arcust) tofile(*libl/garcust)forGgroup). This ensures the program accesses the correct file library (GorZ). -
Open Files: Opens all defined files (
arcust,bicont,bicuag,gscntr1,gsprod,gstabl,inloc,shipto,bicuax,bicua10) withusropnfor controlled access. -
Process Subfile (
srsfl1Subroutine): - Clear Message Subfile: Calls
clrmsgto clear any existing messages in the message subfile. - Initialize Subfile Mode: Sets
sfmod1to'1'(folded mode) and*in45(subfile fold indicator) to*onfor the initial subfile load. - Set Global Protection: If
p$modeis'INQ', sets*in70to*onto protect input fields (read-only mode). In'MNT'mode, fields are editable (*in70is*off). - Initialize Filters:
- Sets
w$expdto*off(exclude expired entries by default) and assignsF8=Incl DelorF8=Excl Deltos1f08dbased on thefkyarray. - Sets
f13selto'D'(descending order) and assignsF13=Descendtos1f13s(updated byjk02revision for ascending/descending toggle).
- Sets
- Position File: Calls
sf1repto position the file based on user input (e.g., company, customer, location). -
Main Loop (
sf1agn):- Displays the command line (
sflcmd1) and message subfile (msgctlormsgclr). - Checks if subfile records exist (
rrn1 > 0) to set*in41(subfile display indicator). - Sets fold/unfold mode (
*in45) based onsfmod1. - Displays the subfile control format (
sflctl1) usingEXFMT. - Processes user input based on function keys:
- F3 (Exit): Exits the loop (
sf1agn = *off). - F4 (Prompt): Calls
promptto display selection windows for fields like customer (C1CUST), ship-to (C1SHIP), location (C1LOC), container (C1CNTR), or product code (C1PRCD). - F5 (Refresh): Sets
repsflto*onto reload the subfile. - F8 (Toggle Expired): Toggles
w$expdbetween include/exclude expired entries and reloads the subfile. - F9 (History Inquiry): Calls
histinqto invokeGB730Pfor customer history. - F13 (Toggle Ascend/Descend): Toggles
f13selbetween'A'(ascending) and'D'(descending) and reloads the subfile (added byjk02). - Page Down: Calls
sf1lodto load more subfile records. - Enter: Validates password (
validatepw) and processes subfile selections (sf1prc). - F6 (Add): Validates password and calls
sf1addto add a new record. - F10 (Position Cursor): Clears cursor position (
row1,col1). - User Repositioning: If control fields (e.g.,
c1cono,c1cust) change, callssf1repto reposition the subfile.
- Displays the command line (
-
Process Subfile Selections (
sf1prcSubroutine): -
Reads subfile records (
READC sfl1) and processes each selected record by callingsf1chgif*in81is*off(record found). -
Process Subfile Record Changes (
sf1chgSubroutine): - Processes user selections based on
s1opt(subfile option field):- Option 2 (Update): Calls
sf1s02if in'MNT'mode and record is not deleted (s1del ≠ 'D'). - Option 3 (Copy): Calls
sf1s03if in'MNT'mode and record is not deleted. - Option 4 (Delete): Calls
sf1s04if in'MNT'mode. - Option 5 (Display): Calls
sf1s05to display the customer order.
- Option 2 (Update): Calls
-
Updates the subfile record after processing by chaining to
bicuag, formatting fields (sf1fmt,sf1col), and updatingsfl1. -
Reposition Subfile (
sf1repSubroutine): - Clears the subfile (
sf1clr) and resetsrrn1. - Validates control fields (
sf1cte) for company (c1cono), customer (c1cust), etc. - Positions the file (
bicuaxorbicua10) based onf13sel(ascending/descending, perjk02) using key lists (kls1s1orkls1s2). - Handles partial PO data entry (
c1pord) by calculating its length (w$slen, perjk06). -
Loads the subfile (
sf1lod) and retains control fields for future repositioning. -
Edit Subfile Control Input (
sf1cteSubroutine): - Validates input fields:
- Company (
c1cono): Chains tobicont. If invalid or zero, sets errorERR0010and*in50,*in51. - Customer (
c1cust): Chains toarcust. If invalid, sets an error (not fully shown due to truncation).
- Company (
-
Additional validations are likely performed for other fields, but the code is truncated.
-
Copy Record (
sf1s03Subroutine): - Calls
BB943to copy a record, passing parameters likec1cono,s1seqn(sequence number),w$validpw(password validation), ando$mode('MNT'). - Processes return flag (
o$flag):'1': Record copied, displays message fromcom(04)and repositions subfile.'0': Record not copied, displays message fromcom(09)and sets*in60.
-
If
o$MsgFlag = '1'(perjk03), displays an expiration message (com(11)). -
Delete Record (
sf1s04Subroutine): - Calls
BB944to delete a record, passingc1cono,s1seqn,p$fgrp, ando$flag. -
Processes return flag:
'D': Record marked deleted, displays message fromcom(05).'A': Record marked active, displays message fromcom(06).
-
Display Customer Order (
sf1s05Subroutine):- Calls
BB943in'INQ'mode to display the record, passing similar parameters as insf1s03.
- Calls
-
History Inquiry (
histinqSubroutine):- Calls
GB730Pwithx$custhistdata structure to display customer history.
- Calls
-
Field Prompting (
promptSubroutine):- Handles field prompting for input fields using external programs:
C1CUST: CallsLARCUSTto select a customer.C1SHIP: CallsLCSTSHPto select a ship-to address.C1LOC: CallsLINLOCto select a location.C1CNTR: CallsLGSCNCDto select a container code.C1PRCD: CallsLGSPRODto select a product code.- Updates control fields with selected values.
-
Message Handling (
addmsg,wrtmsg,clrmsgSubroutines):- Add Message (
addmsg): Sends messages to the program message queue usingQMHSNDPM. - Write Message (
wrtmsg): Displays the message subfile (msgctl). - Clear Message (
clrmsg): Clears the message subfile usingQMHRMVPM.
- Add Message (
-
Program Termination:
- Closes all files (
close *all). - Sets
*inlr = *onand returns.
- Closes all files (
Business Rules¶
The program enforces several business rules for managing customer sales agreements:
- Mode-Based Access:
- In
'INQ'mode, fields are protected (*in70 = *on), allowing only viewing. -
In
'MNT'mode, fields are editable, enabling add, update, copy, and delete operations. -
Subfile Options:
- Option 2 (Update): Allowed in
'MNT'mode for non-deleted records (s1del ≠ 'D'). - Option 3 (Copy): Allowed in
'MNT'mode for non-deleted records, callsBB943to copy records. - Option 4 (Delete): Allowed in
'MNT'mode, callsBB944to mark records as deleted or active. -
Option 5 (Display): Displays record details via
BB943in'INQ'mode. -
Validation:
- Company (
c1cono): Must exist inbicontfile. - Customer (
c1cust): Must exist inarcustfile. - Password Validation: Calls
validatepwfor add (F6) and enter operations to ensure valid access. - Expired Records: Toggles inclusion/exclusion via
F8(w$expd). Displays expiration messages ifo$MsgFlag = '1'(perjk03). -
Partial PO Data Entry: Supports partial purchase order input (
c1pord) with length calculation (perjk06). -
Sorting:
-
Toggles between ascending and descending order via
F13(f13sel = 'A'or'D', perjk02). -
Error Handling:
- Displays error messages (e.g.,
ERR0010for invalid company) using the message subfile. -
Uses
comarray for predefined messages (e.g., "Record has been copied," "Record has been deleted"). -
Container Type Restriction:
-
Per revision
jb07(07/22/2024), the ability to enter container type in a sales agreement was removed. -
Price Display:
-
If the off-price field (
BAOFFP) is non-zero, the subfile price field is displayed in yellow (perjk04). -
Default Password:
- In add mode, defaults password flag to
'N'if blank (perjk01).
Tables Used¶
The program uses the following files, as defined in the File Specification (F-spec) section:
- bb943pd: Display file (workstation file) with a subfile (
sfl1) for interactive user interface. - arcust: Customer master file, input-only, keyed.
- bicont: Company file, input-only, keyed.
- bicuag: Customer sales agreement file, input-only, keyed.
- gscntr1: Container file (replaced
gscntrperjk05), input-only, keyed. Renames fieldtpfil5totcfil5to avoid conflict withgsprod. - gsprod: Product file, input-only, keyed.
- gstabl: Table file (likely for codes or configurations), input-only, keyed.
- inloc: Location file, input-only, keyed.
- shipto: Ship-to address file, input-only, keyed.
- bicuax: Alternate sales agreement file, input-only, keyed, with renamed record format (
bicuagpftobicuagp1). - bicua10: Another alternate sales agreement file (added per
jk02), input-only, keyed, with renamed record format (bicuagpftobicuagp2).
File Overrides:
- The ovg and ovz arrays specify overrides for file groups G and Z, mapping files to libraries (e.g., garcust, zbicuag).
External Programs Called¶
The program calls the following external programs:
- BB943:
- Called in
sf1s03(copy) andsf1s05(display) subroutines. - Parameters include
c1cono,s1stat,w$validpw,s1seqn,o$frsq,c1f6flag,c1cust,c1loc,c1cntr,c1prcd,c1prim,c1ship,o$mode,p$fgrp,o$flag, ando$MsgFlag. -
Used for copying or displaying sales agreement records.
-
BB944:
- Called in
sf1s04(delete) subroutine. - Parameters include
c1cono,s1seqn,p$fgrp, ando$flag. -
Handles deletion or reactivation of records.
-
GB730P:
- Called in
histinqsubroutine. - Parameter:
x$custhist(data structure with company, customer, location, container, etc.). -
Displays customer history.
-
LARCUST:
- Called in
promptsubroutine forC1CUST. - Parameters:
o$cono,o$cust,o$fgrp. -
Allows selection of a customer code.
-
LCSTSHP:
- Called in
promptsubroutine forC1SHIP. - Parameter:
x$cstshp(data structure with company, search, customer, ship-to, flag, file group). -
Allows selection of a ship-to address.
-
LINLOC:
- Called in
promptsubroutine forC1LOC. - Parameters:
c1cono,c1loc,o$fgrp. -
Allows selection of a location code.
-
LGSCNCD:
- Called in
promptsubroutine forC1CNTR. - Parameters:
c1cntr,o$fgrp. -
Allows selection of a container code.
-
LGSPROD:
- Called in
promptsubroutine forC1PRCD. - Parameters:
c1cono,c1prcd,o$fgrp. -
Allows selection of a product code.
-
QCMDEXC:
- Called in
opntblto execute file override commands. -
Parameters:
dbov##(override command),dbol##(length). -
QMHSNDPM:
- Called in
addmsgto send messages to the program message queue. - Parameters:
m@id,m@msgf,m@data,m@l,m@type,m@pgmq,m@scnt,m@key,m@errc.
- Called in
-
QMHRMVPM:
- Called in
clrmsgto clear messages from the message queue. - Parameters:
m@pgmq,m@scnt,m@rmvk,m@rmv,m@errc.
- Called in
Summary¶
- Process Steps:
- Initialize parameters, work fields, and key lists.
- Apply file overrides and open database files.
- Process the subfile (
srsfl1): clear messages, set modes, position file, and handle user input (F3, F4, F5, F6, F8, F9, F10, F13, Enter, Page Down). - Process subfile selections (
sf1prc,sf1chg) for update, copy, delete, or display. - Reposition subfile (
sf1rep) based on user input and sorting preferences. - Validate control fields (
sf1cte) for company and customer. - Handle copy (
sf1s03), delete (sf1s04), and display (sf1s05) operations. - Support history inquiry (
histinq) and field prompting (prompt). - Manage messages (
addmsg,wrtmsg,clrmsg). -
Close files and terminate.
-
Business Rules:
- Supports inquiry and maintenance modes with protected fields in
INQ. - Validates company, customer, and other inputs.
- Handles subfile options (update, copy, delete, display).
- Toggles expired record inclusion and sort order.
- Restricts container type entry (per
jb07). - Displays price in yellow if
BAOFFPis non-zero (perjk04). -
Defaults password flag to
'N'in add mode (perjk01). -
Tables Used:
-
bb943pd(display file),arcust,bicont,bicuag,gscntr1,gsprod,gstabl,inloc,shipto,bicuax,bicua10. -
External Programs Called:
BB943,BB944,GB730P,LARCUST,LCSTSHP,LINLOC,LGSCNCD,LGSPROD,QCMDEXC,QMHSNDPM,QMHRMVPM.
If you have additional files (e.g., GSY2K, display file bb943pd, or source for called programs like BB943), I can provide further details. Let me know if you need specific clarifications or analysis of related components!