Skip to content

BB001 RPG36

The BB001.rpg36.txt is an RPG II program running on an IBM System/36, designed for Order Entry Batch Selection. It is called by the BB110P.ocl36 program to manage batch selection, creation, updating, and deletion for order entry processes, such as generating picking tickets. Below, I’ll explain the process steps, business rules, tables (files) used, and any external programs called.


Process Steps of the BB001 RPG Program

The program handles batch selection, creation, updating, and deletion through a series of subroutines and screen interactions. It uses the BBBTCH and BBBTCHX files to store batch information and manages user input via the SCREEN workstation file. Here’s a step-by-step breakdown of the process:

  1. Initialization (Main Line):
  2. Lines 0065–0068: Resets indicators (50, 21, 22, 23, 24, 75, 76) and clears the MSG field to blanks, preparing for screen output and error handling.
  3. Line 0070: Calls the ONETIM subroutine to perform one-time initialization tasks.
  4. Lines 0072–0074: Depending on the screen format (01, 02, or 03), calls subroutines S1, S2, or S3 to handle specific user interactions.

  5. ONETIM Subroutine (Lines 0100–0114):

  6. Line 0102: Clears the CANCEL field and initializes counters (BLIM, Z2, Z7, Z8) to zero.
  7. Line 0104: Positions the BBBTCH file at the beginning (SETLL with BLIM).
  8. Line 0105: Calls DRLFWD to read the first batch record.
  9. Line 0106: Sets indicators 21 and 83 for screen control.
  10. Lines 0107–0112: Checks the PGM field (from LDA, offset 504):

    • If PGM = 'O' (Order Entry), clears indicator 44.
    • If PGM ≠ 'O', sets indicator 44, indicating a different mode (e.g., posting or printing).
  11. S1 Subroutine (Lines 0116–0212) – Batch Selection or Creation:

  12. Lines 0119–0122: If the KG key (likely a cancel key) is pressed, sets CANCEL to 'CANCEL', sets the Last Record (LR) indicator, and exits to ENDS1.
  13. Line 0124: Checks if BTCH#X (user-entered batch number) is zero, indicating a new batch creation.
  14. New Batch Creation (Lines 0127–0166):
    • If PGM ≠ 'O', displays error message "CANNOT CREATE A BATCH NOW" (COM,2), sets indicators 90, 21, 51, and exits.
    • Otherwise, retrieves the next batch number (ABNXTB) from BBBTCHX (line 0136).
    • Increments ABNXTB, updates the file (EXCPTUPDNXB), and handles overflow (if ABNXTB = 99, resets to 1).
    • Sets fields for the new batch: LKDESC (description), PRTD = 'N' (not printed), DATE (creation date), LUDT (last update date, initially zero), #REC (record count, initially zero).
    • Checks if the batch number exists in BBBTCHX. If not, adds a new record (EXCPTADDBCH) and sets LR to exit.
  15. Existing Batch Selection (Lines 0170–0209):

    • If BTCH#X ≠ 0, sets BATCH# = BTCH#X and retrieves the batch from BBBTCHX.
    • Validates:
    • If the batch is deleted (ABDEL = 'D') or BATCH# = 99, displays error "INVALID BATCH NO." (COM,1) and exits.
    • If ABLOCK = 'O' and PGM = 'P', displays error "BATCH # IN USE--CANNOT POST NOW" (COM,5) and exits.
    • If PAR13C ≠ ABSRCE (batch source mismatch), displays error "INVALID BATCH NO." and exits (added 10/27/09).
    • If the batch is locked (ABLOCK ≠ *BLANK) and the user isn’t the one who locked it (ABUSER ≠ USER), displays error "BATCH # IN USE--PLEASE CHOOSE ANOTHER" (COM,3), releases the batch (EXCPTRELBCH), and exits.
    • If valid, retrieves batch fields (LKDESC, PRTD, DATE, LUDT, #REC) and updates the batch record (EXCPTUPDBCH) if not deleted.
    • If DEL = 'D', displays "CMD 4 - TO DELETE EXISTING BATCH" (COM,4) and prepares for deletion confirmation.
    • If PGM = 'P', sets indicator 24 to indicate posting mode.
  16. S2 Subroutine (Lines 0214–0240) – Batch Confirmation or Deletion:

  17. Lines 0217–0227: If the KA key is pressed or deletion is not confirmed (DEL ≠ 'D'), repositions BBBTCH with SETLL, calls DRLFWD to display the next batch, and exits to ENDS2.
  18. Lines 0229–0232: If deletion is confirmed (DEL = 'D' and KD key pressed), executes EXCPTDELBCH to mark the batch as deleted and sets LR to exit.
  19. Lines 0235–0238: If a new batch number is provided, checks if it exists in BBBTCHX. If not, adds it (EXCPTADDBCH) and sets LR.

  20. S3 Subroutine (Lines 0242–0254) – Reset or Cancel Batch:

  21. If the KG key is pressed, retrieves the batch (BATCH#) from BBBTCHX.
  22. If found, saves the batch state (EXCPTSAVBCH), sets CANCEL = 'CANCEL', clears indicators, and sets LR to exit.

  23. DRLFWD Subroutine (Lines 0256–0308) – Display Forward Navigation:

  24. Reads the next record from BBBTCH and populates the display arrays (BTC, LKD, LKW, PRT, USR, DTE, LUD, #RC) for up to 10 records.
  25. Skips deleted records (ABDEL = 'D') or records where ABSRCE ≠ PAR13C (batch source mismatch, added 10/20/17).
  26. Sets lock status messages based on ABLOCK (e.g., "AVAILABLE", "ORD ENTRY", "PICK LIST", etc.).
  27. If no more records are found or batch number is 99, sets indicator 68 and repositions the file.

  28. DRLBAK Subroutine (Lines 0323–0327) – Backward Navigation:

  29. Sets indicator 21 and exits (minimal logic, suggesting backward navigation is not fully implemented).

  30. DETCLR Subroutine (Lines 0310–0321) – Clear Display Arrays:

  31. Resets the display arrays (BTC, LKD, LKW, PRT, USR, DTE, LUD, #RC) to zeros or blanks.

  32. ROLLKY Subroutine (Lines 0079–0098) – Handle Roll Keys:

  33. Checks the STATUS field for roll key codes (01122 for forward, 01123 for backward).
  34. Calls DRLFWD for forward scrolling or DRLBAK for backward scrolling.
  35. Clears STATUS and resets indicator 09 after processing.

  36. Output Operations:

    • SCREEN Output (Lines 0331–0370):
    • Format BB001S1: Displays batch list with batch numbers, lock status, workstation ID, print status, user, dates, and record count.
    • Format BB001S2: Confirms batch details for update or deletion.
    • Format BB001S3: Displays batch details for reset/cancel.
    • BBBTCHX Output (Lines 0371–0403):
    • UPDNXB: Updates the next batch number.
    • ADDBCH: Adds a new batch record with BATCH#, PGM, WSID, PRTD, USER, DATE, LUDT, #REC, and PAR13C.
    • UPDBCH: Updates an existing batch with PGM, WSID, and LUDT.
    • DELBCH: Marks a batch as deleted (DEL = 'D').
    • RELBCH: Releases a batch lock.
    • SAVBCH: Saves the batch lock status and workstation ID.

Business Rules

  1. Batch Creation:
  2. Only allowed in Order Entry mode (PGM = 'O').
  3. Uses the next available batch number (ABNXTB) from BBBTCHX, incrementing it and resetting to 1 if it reaches 99.
  4. New batches are initialized with PRTD = 'N', zero records, and the current date.

  5. Batch Selection:

  6. Validates that the batch exists, is not deleted (ABDEL ≠ 'D'), and is not numbered 99.
  7. Checks if the batch source (ABSRCE) matches the input parameter PAR13C (e.g., 'PP' for viscosity ASN or non-'PP').
  8. Ensures the batch is not locked (ABLOCK = *BLANK) or is locked by the current user (ABUSER = USER).

  9. Batch Locking:

  10. If a batch is locked (ABLOCK ≠ *BLANK) and not by the current user, it cannot be accessed, and an error is displayed.
  11. Locked batches display specific statuses (e.g., "ORD ENTRY", "PICK LIST", "POSTING", "BOL PRINT").

  12. Batch Deletion:

  13. Users can mark a batch for deletion by entering DEL = 'D', which is confirmed via screen format BB001S2.
  14. Deletion updates the batch record with ABDEL = 'D'.

  15. Batch Source Validation (Added 10/27/09):

  16. Ensures the batch source (ABSRCE) matches the input parameter PAR13C to restrict access to batches of the correct type (e.g., 'PP' for viscosity ASN).

  17. Error Handling:

  18. Displays specific error messages for invalid batch numbers, locked batches, or attempts to create a batch outside Order Entry mode.
  19. Uses COM array for standard messages (e.g., "INVALID BATCH NO.", "BATCH # IN USE").

  20. Navigation:

  21. Supports forward scrolling through batch records, skipping deleted or mismatched records.
  22. Backward navigation is minimally implemented.

Tables (Files) Used

  1. SCREEN:
  2. Type: Workstation file (WORKSTN).
  3. Purpose: Displays batch selection, confirmation, and error messages to the user.
  4. Formats: BB001S1 (batch list), BB001S2 (batch confirmation/deletion), BB001S3 (batch reset/cancel).

  5. BBBTCH:

  6. Type: Indexed disk file (48 bytes, logical file, shared access).
  7. Purpose: Stores batch control data for reading and positioning.
  8. Fields: ABDEL (delete code), ABBTCH (batch number), ABLOCK (lock status), ABLKWS (lock workstation ID), ABPRTD (BOL printed), ABUSER (user ID), ABDATE (creation date), ABLUDT (last update date), ABREC (record count), ABSRCE (batch source), ABNXTB (next batch number).

  9. BBBTCHX:

  10. Type: Indexed disk file (48 bytes, physical file, update-capable, shared access).
  11. Purpose: Stores and updates batch control data, including the next batch number.
  12. Fields: Same as BBBTCH.

External Programs Called

  • None: The BB001 program does not explicitly call any external RPG programs. It operates independently, relying on file operations and user interactions via the SCREEN file.

Summary

The BB001 RPG program manages the selection, creation, updating, and deletion of order entry batches. It: - Initializes and displays batch lists for user selection. - Creates new batches in Order Entry mode, assigning unique batch numbers. - Validates batch accessibility based on lock status and batch source. - Supports batch deletion and updating, with error handling for invalid or locked batches. - Uses subroutines (S1, S2, S3, DRLFWD, DRLBAK, DETCLR, ROLLKY) to handle specific tasks.

Tables Used: SCREEN, BBBTCH, BBBTCHX. External Programs Called: None.