# (DD15) Business Logic — JFUSetVariTsushinKikiMskmCC.getMskmshoDtlNoSibn() [33 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JFUSetVariTsushinKikiMskmCC` |
| Layer | CC/Common Component (Business Logic Component — shared utility class) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JFUSetVariTsushinKikiMskmCC.getMskmshoDtlNoSibn()

This method is responsible for **allocating an order detail number** (`mskmsho_dtl_no`) for equipment provisioning service contracts. It is a shared private utility method called by other logic within the `JFUSetVariTsushinKikiMskmCC` component, which handles various communication equipment application and registration workflows.

The method implements a **conditional routing pattern**: it checks whether the current context represents an **ONU (Optical Network Unit) exchange job** (i.e., replacing an existing ONU device with a new one). If so, it initializes a request parameter map, sets up template fields (form code, service type, operation date), and executes the SC (Service Component) `EKK0021C014` to allocate a unique order detail number. This number is then extracted from the SC result template and returned.

If the context is NOT an ONU exchange job, the method returns `null`, indicating no number allocation is needed in the current workflow context. The method acts as a **bridge between workflow-specific business logic and the generic number allocation SC**, encapsulating the preparation of input data and the extraction of the result in a single call.

The service type handled is **HGW (Home Gateway)** — the method hardcodes `SVC_TIKI_CD` (service connection code) to `HGW`, meaning this number allocation is specific to home gateway equipment provisioning scenarios. The application form code is set to `CD00591_01`, which represents the equipment application form type.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getMskmshoDtlNoSibn handle, param, fixedText"])

    START --> GET_DATA["Get HashMap inMap = param.getData fixedText"]

    GET_DATA --> CHECK_ONU{"isOnuKokanKoji inMap"}

    CHECK_ONU -- "true: ONU exchange job" --> INIT_DATA["initData param, fixedText, IN_COLUMN_LIST_EKK0021C014"]

    INIT_DATA --> SET_FUNC["setFuncCode param, fixedText, FUNC_CD_1"]

    SET_FUNC --> SET_FORM["inMap.put MSKM_FORM_CD, CD00591_01"]

    SET_FORM --> SET_SVC["inMap.put SVC_TIKI_CD, HGW"]

    SET_SVC --> SET_YMD["inMap.put YMD, JCCBPCommon.getOpeDate null"]

    SET_SVC --> SET_YMD["inMap.put YMD, JCCBPCommon.getOpeDate null"]

    SET_YMD --> EXEC_SC["executeSC handle, param, fixedText,<br/>TEMPLATE_ID_EKK0021C014,<br/>TEMPLATE_ID_EKK0021C014_DETAIL,<br/>IN_COLUMN_LIST_EKK0021C014,<br/>ERROR_COLUMN_EKK0021C014"]

    EXEC_SC --> GET_KEY["getMaxTempTempleteKey inMap, TEMP_TEMPLATE_KEY_EKK0021C014"]

    GET_KEY --> GET_VAL["getTemplateValue inMap, key, MSKMSHO_DTL_NO"]

    GET_VAL --> RETURN_VAL["Return mskmshoDtlNo"]

    CHECK_ONU -- "false: Not ONU exchange" --> RETURN_NULL["Return null"]

    RETURN_VAL --> END_NODE(["End"])
    RETURN_NULL --> END_NODE
```

**Processing description:**

1. **Data retrieval**: Fetch the input HashMap from the request parameter object using the `fixedText` key.
2. **ONU exchange check**: Determine if this is an ONU exchange job by checking whether the `IN_ONU_KOKAN_KOJI_UM` map entry equals `CD00002_1`.
3. **If ONU exchange (true branch)**:
   - Initialize the request data with the input column list for SC `EKK0021C014`.
   - Set the function code to `FUNC_CD_1` (registration function).
   - Set the application form code to `CD00591_01` (equipment application form).
   - Set the service type/connection code to `HGW` (Home Gateway).
   - Set the operation date to the current system date.
   - Execute the SC `EKK0021C014` (Order Detail Number Allocation SC) with the prepared template and input columns.
   - Retrieve the allocated order detail number from the SC result template.
   - Return the allocated number.
4. **If not ONU exchange (false branch)**: Return `null`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Session handle for the current transaction/context. Used to pass the database/session context to the SC execution, enabling the SC to perform data access and resource management. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object carrying bidirectional data between the screen/CBS layer and the SC. It holds the input HashMap (via `getData`) and is modified during initialization (`initData`) and function code setting (`setFuncCode`). |
| 3 | `fixedText` | `String` | Service message key used as a map key to retrieve and store data within the request parameter object. It identifies which data block within `param` the method should operate on. |

**External state / instance fields referenced:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `IN_ONU_KOKAN_KOJI_UM` | `String` | Input item constant for ONU exchange presence flag — key name used to check if the current operation involves an ONU device exchange. |
| `IN_COLUMN_LIST_EKK0021C014` | `List<String>` | Input column list for the Order Detail Number Allocation SC — specifies which fields (MSKM_FORM_CD, SVC_TIKI_CD, YMD) are sent as input. |
| `TEMPLATE_ID_EKK0021C014` | `String` | Template ID for the Order Detail Number Allocation SC — value: `"EKK0021C014"`. |
| `TEMPLATE_ID_EKK0021C014_DETAIL` | `String` | Detail template ID — `null` (no detail template for this SC). |
| `ERROR_COLUMN_EKK0021C014` | `String` | Error check column — `null` (no specific error column check for this SC). |
| `TEMP_TEMPLATE_KEY_EKK0021C014` | `String` | SC execution result retrieval key — composed of `TEMP_TEMPLATE_PRIFIX + "EKK0021C014" + TEMP_TEMPLATE_PRIFIX_SEP`. |
| `SVC_TIKI_HGW` | `String` | Service type/connection code for Home Gateway — value: `"HGW"`. |
| `EKK0021C014CBSMsg.MSKM_FORM_CD` | `String` | Map key for application form code field. |
| `EKK0021C014CBSMsg.SVC_TIKI_CD` | `String` | Map key for service type/connection code field. |
| `EKK0021C014CBSMsg.YMD` | `String` | Map key for operation date field. |
| `EKK0021C014CBSMsg.MSKMSHO_DTL_NO` | `String` | Map key for the allocated order detail number field returned by the SC. |
| `JFUStrConst.CD00591_01` | `String` | Application form code constant — the equipment application form type. |
| `JPCModelConstant.FUNC_CD_1` | `String` | Function code constant — value: `"1"` (registration function). |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `initData` | - | - | Initializes the request parameter map with input column list entries for SC EKK0021C014 |
| - | `setFuncCode` | - | - | Sets function code to FUNC_CD_1 (registration) on the request parameter |
| C/R | `executeSC` | EKK0021C014SC | KK_T_MSKMSHO_DTL (order detail header) | Executes the Order Detail Number Allocation SC — reads the next available sequence number for the given form type, service type, and date, then reserves/allocates it |
| R | `JCCBPCommon.getOpeDate` | - | - | Retrieves the current system operation date |
| R | `getMaxTempTempleteKey` | - | - | Gets the maximum template key from the SC result to locate the allocated number |
| R | `getTemplateValue` | - | - | Extracts the allocated order detail number from the SC result template |

**Notes:**
- The SC `EKK0021C014` is the **Order Detail Number Allocation SC** (申込明細番号採番SC). It receives the form code, service type, and date as input, and returns an allocated sequential order detail number (`mskmsho_dtl_no`).
- `executeSC` delegates to the SC layer which performs the database read (sequence number retrieval) and potentially a write (reservation).
- `getTemplateValue` extracts the returned value from the SC response template.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CC: `JFUSetVariTsushinKikiMskmCC` (internal) | `JFUSetVariTsushinKikiMskmCC.someMethod` -> `getMskmshoDtlNoSibn` | `executeSC [C/R] KK_T_MSKMSHO_DTL`, `getOpeDate [R]`, `getTemplateValue [R]` |

**Notes:**
- This method is `private` and is **not directly called by screens or batch jobs**. It is an internal helper method invoked by other methods within `JFUSetVariTsushinKikiMskmCC` during ONU exchange equipment provisioning workflows.
- The primary terminal operations from this method are: `executeSC` (Order Detail Number Allocation SC), `JCCBPCommon.getOpeDate` (read current date), `getTemplateValue` (extract allocated number), `getMaxTempTempleteKey` (locate template key), `initData` (initialize parameters), and `setFuncCode` (set function code).

## 6. Per-Branch Detail Blocks

**Block 1** — [IF condition] `isOnuKokanKoji(inMap)` (L4367)

> Checks whether the current operation is an ONU exchange job. The `isOnuKokanKoji` helper compares the map value at key `IN_ONU_KOKAN_KOJI_UM` (`"onu_kokan_koji_um"`) against `JFUStrConst.CD00002_1` (ONU exchange job flag).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `HashMap inMap = (HashMap)param.getData(fixedText)` // Retrieve input data map [-> fixedText key] |
| 2 | IF | `if (isOnuKokanKoji(inMap))` // Check if ONU exchange job [-> IN_ONU_KOKAN_KOJI_UM="onu_kokan_koji_um"] |
| 3 | SET | `inMap.put(EKK0021C014CBSMsg.MSKM_FORM_CD, JFUStrConst.CD00591_01)` // Set application form code [-> CD00591_01] |
| 4 | SET | `inMap.put(EKK0021C014CBSMsg.SVC_TIKI_CD, SVC_TIKI_HGW)` // Set service type [-> SVC_TIKI_HGW="HGW"] |
| 5 | SET | `inMap.put(EKK0021C014CBSMsg.YMD, JCCBPCommon.getOpeDate(null))` // Set operation date |
| 6 | CALL | `executeSC(handle, param, fixedText, TEMPLATE_ID_EKK0021C014, TEMPLATE_ID_EKK0021C014_DETAIL, IN_COLUMN_LIST_EKK0021C014, ERROR_COLUMN_EKK0021C014)` // Execute SC EKK0021C014 [TEMPLATE_ID_EKK0021C014="EKK0021C014"] |
| 7 | SET | `String mskmshoDtlNo = getTemplateValue(inMap, getMaxTempTempleteKey(inMap, TEMP_TEMPLATE_KEY_EKK0021C014), EKK0021C014CBSMsg.MSKMSHO_DTL_NO)` // Get allocated number [-> TEMP_TEMPLATE_KEY_EKK0021C014] |
| 8 | RETURN | `return mskmshoDtlNo;` // Return allocated order detail number |

**Block 2** — [ELSE implicit / condition false] (L4396)

> When `isOnuKokanKoji(inMap)` returns `false` — the operation is not an ONU exchange job. No number allocation is performed.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // No number allocation needed |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `mskmsho_dtl_no` | Field | Order detail number — a unique sequential identifier assigned to each line item within a service equipment application order. Allocated by SC EKK0021C014. |
| `mskm` | Acronym | Equipment Application (機器申込) — refers to equipment application/registration records in the system. |
| `mskmsho` | Acronym | Equipment Application Header (機器申込) — the header/master record of an equipment application. |
| `mskmsho_dtl` | Acronym | Equipment Application Detail (機器申込明細) — detail/line-item record within an equipment application. |
| `isOnuKokanKoji` | Method/Field | ONU exchange job flag — indicates whether the current operation involves replacing an existing Optical Network Unit (ONU) device. |
| `onu_kokan_koji_um` | Field | ONU exchange job presence/absence flag — map key storing whether an ONU exchange is being performed. |
| `CD00002_1` | Constant | ONU exchange job flag value — the code indicating "ONU exchange job" (ONU交換工事). |
| `SVC_TIKI_CD` | Field | Service type/connection code — identifies the type of service connection (HGW, FTTH, etc.). |
| `SVC_TIKI_HGW` | Constant | Home Gateway service type — value: `"HGW"`. Indicates the service involves a home gateway device. |
| `HGW` | Business term | Home Gateway — the residential gateway/router device provided to customers for internet connectivity. |
| `MSKM_FORM_CD` | Field | Application form code — the type of application form being used for the equipment registration. |
| `CD00591_01` | Constant | Equipment application form code — the specific form type used for equipment application registration. |
| `YMD` | Field | Year-Month-Day — the operation date in YYYYMMDD format. |
| `FUNC_CD_1` | Constant | Function code 1 — value: `"1"`. Represents the registration (insert) function type. |
| `EKK0021C014` | SC Code | Order Detail Number Allocation Service Component — the SC that allocates the next sequential order detail number based on form code, service type, and date. |
| `TEMP_TEMPLATE_KEY_EKK0021C014` | Constant | Template key prefix for SC EKK0021C014 result retrieval — used to locate the SC response data in the template map. |
| `IN_COLUMN_LIST_EKK0021C014` | Constant | Input column list for SC EKK0021C014 — defines the fields MSKM_FORM_CD, SVC_TIKI_CD, and YMD as inputs to the SC. |
| `executeSC` | Method | Execute Service Component — generic method that invokes a SC (Service Component) with template IDs and input parameters. |
| `getTemplateValue` | Method | Retrieve value from SC response template map — extracts a specific field value from the SC result. |
| `getMaxTempTempleteKey` | Method | Get the maximum template key from SC result — locates the correct template entry in the result map. |
| `initData` | Method | Initialize request parameter data — sets up the request parameter map with column definitions for a given SC. |
| `setFuncCode` | Method | Set function code on request parameter — sets the operation type (e.g., registration = FUNC_CD_1). |
| `fixedText` | Parameter | Service message key — used to identify which data block within the request parameter the method should operate on. |
| `SessionHandle` | Type | Session handle — manages the database session and transaction context for SC execution. |
| `IRequestParameterReadWrite` | Type | Request parameter interface — bidirectional data carrier between screen, CC, and SC layers. |
| `JCCBPCommon` | Class | Common BP (Business Process) utility class — provides shared methods such as `getOpeDate` for retrieving the system operation date. |
| `JFUBaseCC` | Class | Base common component — parent class providing generic methods like `executeSC`, `initData`, `setFuncCode`, `getTemplateValue`, `getMaxTempTempleteKey`. |
| ONU | Acronym | Optical Network Unit — a device that terminates fiber-optic cables and converts optical signals to electrical signals for customer premises equipment. |
| `KK_T_MSKMSHO_DTL` | Entity | Order detail header table (likely) — database table storing equipment application order detail records, from which sequence numbers are allocated. |
