Example of a Prompt

Agent: Document Agent

<aside> <img src="notion://custom_emoji/be6005d7-8302-4c8e-93fe-03d0d3d71970/12f3c107-d7a8-8009-8054-007a9b09b0b8" alt="notion://custom_emoji/be6005d7-8302-4c8e-93fe-03d0d3d71970/12f3c107-d7a8-8009-8054-007a9b09b0b8" width="40px" />

@Order List Monthly Report Screen_Requirements Specification I would like to design a daily batch process to aggregate data for display on the screen. Please output it according to the format of the @COBOL Batch Processing Design Document Template.

</aside>

Template

## Document Information

| Item          | Content |
| ------------- | ------- |
| Document Name |         |
| Document No.  |         |
| Creation Date |         |
| Last Updated  |         |
| Author        |         |
| Approver      |         |
| Target System |         |
| Related Docs  |         |

## Overview

### Purpose

### Process Overview

### Schedule Information

| Execution Timing | Execution Condition | Execution Priority | Max Allowable Execution Time |
| ---------------- | ------------------- | ------------------ | ---------------------------- |
|                  |                     |                    |                              |

## Prerequisites

### Execution Environment

| Item               | Content |
| ------------------ | ------- |
| OS                 |         |
| COBOL System       |         |
| Required Resources |         |
| Dependent Systems  |         |

### Pre-conditions

### Post-conditions

## Process Flow

### Overall Flow

```mermaid
flowchart TD
    A[Start] --> B[Initialization]
    B --> C[Main Process]
    C --> D[Finalization]
    D --> E[End]

    %% Legend
    classDef start fill:#9f6,stroke:#333,stroke-width:2px
    classDef process fill:#66f,stroke:#333,stroke-width:1px,color:#fff
    classDef endnode fill:#f96,stroke:#333,stroke-width:2px

    class A start
    class B,C,D process
    class E endnode

Detailed Flow

flowchart TD

    %% Initialization
    A[Start] --> B[Get Environment Variables]
    B --> C[Open File]
    C --> D{Open Success?}
    D -->|Yes| E[Set Initial Values]
    D -->|No| Z[Abnormal End]

    %% Main Process
    E --> F[Read Input File]
    F --> G{EOF?}
    G -->|Yes| H[Go to Finalization]
    G -->|No| I[Data Processing]
    I --> J[Write Output File]
    J --> F

    %% Finalization
    H --> K[Aggregation]
    K --> L[Close File]
    L --> M[Normal End]

    %% Class Definitions (Class name end → endClass)
    classDef startClass fill:#9f6,stroke:#333,stroke-width:2px
    classDef process fill:#66f,stroke:#333,stroke-width:1px
    classDef decision fill:#ff7,stroke:#333,stroke-width:1px
    classDef endClass fill:#f96,stroke:#333,stroke-width:2px

    %% Class Assignment
    class A startClass
    class B,C,E,F,I,J,K,L process
    class D,G decision
    class M,Z endClass

Input/Output File Specifications

Input File

File Name Format Record Length Block Factor Description

Record Layout

Item Name Start Position Length Format Description

Output File

File Name Format Record Length Block Factor Description

Record Layout

Item Name Start Position Length Format Description

Work File

File Name Format Record Length Block Factor Description

Program Structure

Module Structure

Module Name Type Function Overview

Data Item Definitions

WORKING-STORAGE SECTION

Item Name Level Data Type Length Initial Value Description

LINKAGE SECTION

Item Name Level Data Type Length Description

Main Processing Logic

Initialization

Main Process

Finalization

Error Handling

Error Code List

Error Code Description Countermeasure

Exception Handling Flow

flowchart TD
    A[Error Occurred] --> B{Error Type Judgment}
    B -->|File Error| C[File Error Handling]
    B -->|Data Error| D[Data Error Handling]
    B -->|System Error| E[System Error Handling]
    C --> F[Output Error Log]
    D --> F
    E --> F
    F --> G[Set Return Code]
    G --> H[Abnormal End]

    %% Legend
    classDef error fill:#f66,stroke:#333,stroke-width:1px
    classDef decision fill:#ff7,stroke:#333,stroke-width:1px
    classDef process fill:#66f,stroke:#333,stroke-width:1px
    classDef endClass fill:#f96,stroke:#333,stroke-width:2px

    class A error
    class B decision
    class C,D,E,F,G process
    class H endClass

## Output Image

```markdown
## Document Information

| Item          | Content                                                                     |
| ------------- | --------------------------------------------------------------------------- |
| Document Name | Order List Monthly Report Aggregation Batch Design Document                 |
| Document No.  |                                                                             |
| Creation Date | 2025-08-14                                                                  |
| Last Updated  | 2025-08-14                                                                  |
| Author        | Dummy                                                                       |
| Approver      |                                                                             |
| Target System | EC-CUBE                                                                     |
| Related Docs  | Order List Monthly Report Screen Requirements, Order List Display API, etc. |

## Overview

### Purpose

- To generate aggregated data for display and analysis on the administrator's "Order List Monthly Report Screen" (@document).
- To aggregate order data by month, calculate sales, order count, status distribution, customer/product rankings, etc. via batch processing, aiming to speed up screen display and stabilize performance.

### Process Overview

- Extract and aggregate last month's order data from "Order", "Customer", "Product" tables, and output to dedicated monthly summary tables/files.
- Calculate items such as total sales, order count, count by status, daily sales trends, ranking values, etc., according to screen requirements (@document).

### Schedule Information

| Execution Timing            | Condition                     | Priority | Max Allowed Time |
| --------------------------- | ----------------------------- | -------- | ---------------- |
| Midnight, 1st of each month | Extract previous month's data | High     | 30 minutes       |

## Prerequisites

### Execution Environment

| Item               | Content                     |
| ------------------ | --------------------------- |
| OS                 | Linux                       |
| Language/Engine    | PHP (CLI) or Shell Batch    |
| Required Resources | DB access privileges        |
| Dependent System   | EC-CUBE main order database |

### Pre-conditions

- Order data is updated monthly without issues.
- Definitions and preparations for summary tables/files are complete.

### Post-conditions

- Monthly summary data is aggregated and output.
- In case of errors, notify the responsible person.

## Process Flow

### Overall Flow

```mermaid
flowchart TD
    A[Batch Start] --> B[Initialize Environment/Variables]
    B --> C[Extract Previous Month's Order Data]
    C --> D[Aggregate Sales/Order Count]
    D --> E[Aggregate by Status]
    E --> F[Aggregate Daily Sales Trends]
    F --> G[Aggregate Rankings]
    G --> H[Output to Summary Table/File]
    H --> I[End Process]

Detailed Flow

flowchart TD
    A[Start] --> B[Batch Environment Setup (Get Target Month, etc.)]
    B --> C[Execute Order Table Extraction Query]
    C --> D{Extraction Success?}
    D -->|Yes| E[Aggregation Processing]
    E --> F[Update Summary Table/File]
    F --> H[Normal End]
    D -->|No| Z[Log Error/Notify]
    Z --> H

Input/Output File Specifications

Input Files

File Name Format Record Length Block Factor Description
DB: Order Table SQL Extract previous month's orders
DB: Product, Customer SQL Link product/customer master data

Record Layout

Item Name Start Pos Length Format Description
order\_id int Order ID
customer\_id int Customer ID
product\_id int Product ID
total\_price int Total Order Amount
order\_date date Order Date
status str Order Status

Output Files

File Name Format Record Length Block Factor Description
Monthly Order Summary Table SQL Write aggregation results
Monthly Sales Ranking CSV CSV Sales ranking by product/customer
Monthly Sales Trend CSV CSV Daily sales trend data

Record Layout (Example: Monthly Order Summary Table)

Item Name Start Pos Length Format Description
period str Target month for aggregation
total\_sales int Total sales
total\_orders int Total order count
status\_new int New order count
status\_paid int Paid order count
... Other status counts

Working Files

File Name Format Record Length Block Factor Description
Daily/Ranking Temp Files CSV Temporary files during aggregation

Program Structure

Module Structure

Module Name Type Function Overview
OrderExtract Extract Extract previous month's order data
SalesAggregator Aggregate Aggregate sales/order count/status
TrendAnalyzer Analyze Aggregate daily trends/rankings
SummaryWriter Output Write summary

Data Item Definitions

WORKING-STORAGE SECTION

Item Name Level Data Type Length Initial Value Description
WS-MONTH 01 CHAR 7 Target month (YYYY/MM)
WS-TOTAL 01 INT 4 0 Total sales
WS-STATUSCNT 01 INT 4 0 Count by status

LINKAGE SECTION

Item Name Level Data Type Length Description
PARA 01 CHAR Batch execution parameter

Main Processing Logic

Initial Processing

Main Processing

End Processing

Error Handling

Error Code List

Error Code Description Countermeasure
001 DB connection error Retry/Notify responsible person
002 Extraction failure Log/Consider re-execution
099 Other errors Detailed log/Notify responsible person

Exception Handling Flow

flowchart TD
    A[Error Occurred] --> B{Error Type Judgment}
    B -->|DB| C[DB Error Handling]
    B -->|Aggregation| D[Data Error Handling]
    B -->|Output| E[File Error Handling]
    C --> F[Error Log Output]
    D --> F
    E --> F
    F --> G[Notification/End]