List of Use Cases Implemented by the Program Call Stack¶
The RPGLE program call stack, consisting of BB928P, BB928, BB9284, and BB9285, implements a set of functionalities for managing salesman ID records within a billing and invoicing system on IBM i. These programs collectively support the following use cases:
- View Salesman ID Records:
-
Allows users to view a list of salesman ID records in a subfile, with options to filter by company number and salesman ID, and display all records (active and inactive) in inquiry mode.
-
Create a Salesman ID Record:
-
Enables users to create a new salesman ID record, specifying company number, salesman ID, name, and email address, ensuring the company exists and the record does not already exist.
-
Update a Salesman ID Record:
-
Permits users to modify existing salesman ID records (name and email address), protecting key fields (company number and salesman ID) to maintain data integrity.
-
Inactivate/Reactivate a Salesman ID Record:
-
Allows users to toggle the status of a salesman ID record between active (
A) and inactive (I), ensuring the record exists and is in the appropriate state for the action. -
Print a Salesman ID Listing:
- Generates a printed report of all salesman ID records, including company number, salesman ID, name, email address, and status, sorted by company and salesman ID.
Function Requirement Document: Manage Salesman ID Records¶
Salesman ID Management Function Requirements¶
Purpose¶
The ManageSalesmanID function manages salesman ID records in a billing and invoicing system, supporting creation, update, inactivation/reactivation, and printing of records without interactive screen handling. It processes inputs directly and applies business rules to maintain data integrity.
Inputs¶
- Company Number (
co): Numeric, identifies the company (validated againstbicont). - Salesman ID (
smid): Alphanumeric, unique identifier for the salesman. - Salesman Name (
smnm): Alphanumeric, required for create/update. - Email Address (
emal): Alphanumeric, required for create/update. - File Group (
fgrp):GorZ, selects database file (gbbslsmorzbbslsm). - Operation (
op): Enum (CREATE,UPDATE,INACTIVATE,REACTIVATE,PRINT). - Output Flag (
flag): Output parameter, indicates success (1,A,I) or failure (E).
Process Steps¶
- Validate Inputs:
- Ensure
coexists inbicont. - For
CREATE, verifycoandsmiddo not exist inbbslsm. - For
UPDATE,INACTIVATE, orREACTIVATE, verifycoandsmidexist inbbslsm. - For
CREATEandUPDATE, ensuresmnmandemalare non-blank. - For
INACTIVATE, ensure the record is not already inactive (smdel ≠ 'I'). -
For
REACTIVATE, ensure the record is inactive (smdel = 'I'). -
Select Database File:
-
Apply file override to use
gbbslsm(iffgrp = 'G') orzbbslsm(iffgrp = 'Z'). -
Execute Operation:
- CREATE:
- Write a new record to
bbslsmwithco,smid,smnm,emal, andsmdel = 'A'(active). - Set
flag = '1'on success.
- Write a new record to
- UPDATE:
- Update the existing record in
bbslsmwith newsmnmandemal, preservingco,smid, andsmdel. - Set
flag = '1'on success.
- Update the existing record in
- INACTIVATE:
- Update the record in
bbslsm, settingsmdel = 'I'. - Set
flag = 'I'on success.
- Update the record in
- REACTIVATE:
- Update the record in
bbslsm, settingsmdel = 'A'. - Set
flag = 'A'on success.
- Update the record in
-
PRINT:
- Read all records from
bbslsmsequentially. - Generate a report to
qsysprtwith: - Header: Company name, report title ("Salesman Id Listing By Co#/Salesman Id"), page number, job name, program name, user ID, file group, date (MM/DD/YYYY), time (HH:MM:SS), and column headers ("Co", "Slsm Id", "Salesman Name", "Email Address", "Del").
- Detail: For each record, print
smco,smsmid,smsmnm,smemal,smdel. - Format: 68 lines, 164 characters wide, 8 LPI, 15 CPI, overflow at line 62, held and saved in the job’s output queue.
- Set
flag = '1'on success.
- Read all records from
-
Handle Errors:
- If
cois invalid, setflag = 'E'and return error message "Invalid company number." - If
smnmoremalis blank forCREATEorUPDATE, setflag = 'E'and return error message "Salesman name and email required." - If record exists for
CREATEor does not exist forUPDATE,INACTIVATE, orREACTIVATE, setflag = 'E'and return appropriate error message. -
If status is invalid for
INACTIVATEorREACTIVATE, setflag = 'E'and return error message "Invalid record status." -
Clean Up:
- Close all files and remove overrides.
Business Rules¶
- Data Integrity:
- Company number must exist in
bicont. - Salesman ID must be unique for
CREATEand exist forUPDATE,INACTIVATE, orREACTIVATE. - Salesman name and email address are mandatory for
CREATEandUPDATE. - Status Management:
- Records can be active (
A), inactive (I), or deleted (D). - Only non-inactive records can be inactivated; only inactive records can be reactivated.
- Report Generation:
- The
PRINToperation includes all records, regardless of status, sorted by company number and salesman ID. - The report is formatted with fixed positions and includes metadata (job, user, date, time).
- Database Selection:
- File group (
GorZ) determines the database file (gbbslsmorzbbslsm). - Error Handling:
- Invalid inputs or operations result in
flag = 'E'with a descriptive error message.
Calculations¶
- Date and Time Formatting (for
PRINT): - Date: Converted to
MM/DD/YYYYformat using system timestamp (ps#mdy) and time conversion structure (t#mdcy). - Time: Converted to
HH:MM:SSformat using system timestamp (ps#hms) and time conversion structure (t#hms). - Page Overflow (for
PRINT): - Triggers header printing when the printer file reaches line 62, as defined in the printer override.
Outputs¶
- Database Updates: Modified
bbslsmrecords forCREATE,UPDATE,INACTIVATE, orREACTIVATE. - Report: Printed listing to
qsysprtforPRINT. - Flag: Returns
1(success forCREATE,UPDATE,PRINT),A(success forREACTIVATE),I(success forINACTIVATE), orE(error).
Dependencies¶
- Database Files:
bbslsm: Salesman ID records (input forPRINT, update/add for others).bicont: Company records (input for validation).- External Programs:
QCMDEXC: Executes file overrides forbbslsmandqsysprt.QMHSNDPM: Sends error messages to the program message queue.QMHRMVPM: Removes messages from the program message queue.