# Business Logic — JBSbatKKKDDIAnkenChsht.createCdNm() [12 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatKKKDDIAnkenChsht` |
| Layer | Service |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatKKKDDIAnkenChsht.createCdNm()

This method is a private utility that combines a code (`cd`) and a name (`nm`) into a single display-friendly string following the format `CD（NM）` — where `CD` is the code value, `NM` is the name value, and `（）` are full-width parentheses. The method acts as a data formatter responsible for producing human-readable identifiers used throughout the KDDI billing/acceptance batch processing system. It implements the null-safety pattern: if the code is null or empty, it returns null immediately, preventing invalid display strings from propagating downstream. If the name is null but the code is present, it substitutes an empty string for the name portion, producing output like `CD（）`. When both code and name are present, both are rendered. This method plays the role of a shared formatting helper called from the `setKDDIRslt` method during result record assembly, ensuring consistent display string construction across batch result handling.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["createCdNm(cd, nm)"])
    CHECK_CD(["JKKBatCommon.isNotNull(cd)"])
    CHECK_NM(["nm == null"])
    RETURN_FORMATTED(["Return JKKStrConst.KDDI_RSLT_CD_NM.replace(CD,cd).replace(NM,empty)"])
    RETURN_FORMATTED_NM(["Return JKKStrConst.KDDI_RSLT_CD_NM.replace(CD,cd).replace(NM,nm)"])
    RETURN_NULL(["Return null"])
    END_NODE(["Return / Next"])

    START --> CHECK_CD
    CHECK_CD -->|true| CHECK_NM
    CHECK_NM -->|true| RETURN_FORMATTED
    CHECK_NM -->|false| RETURN_FORMATTED_NM
    RETURN_FORMATTED --> END_NODE
    RETURN_FORMATTED_NM --> END_NODE
    CHECK_CD -->|false| RETURN_NULL
    RETURN_NULL --> END_NODE
```

**CRITICAL — Constant Resolution:**

| Constant | Actual Value | Business Meaning |
|----------|-------------|-----------------|
| `JKKStrConst.KDDI_RSLT_CD` | `"CD"` | Placeholder token representing the code position in the formatted output template |
| `JKKStrConst.KDDI_RSLT_NM` | `"NM"` | Placeholder token representing the name position in the formatted output template |
| `JKKStrConst.KDDI_RSLT_CD_NM` | `"CD（NM）"` | Template string: code followed by full-width parentheses containing the name |

The processing is straightforward string substitution:
1. The template `CD（NM）` is a fixed format string where `CD` and `NM` are literal placeholder tokens.
2. `.replace(JKKStrConst.KDDI_RSLT_CD, cd)` replaces the `CD` token with the actual code value.
3. `.replace(JKKStrConst.KDDI_RSLT_NM, nm)` (or `""` if null) replaces the `NM` token with the name (or empty string).

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `cd` | `String` | Code value — the identifier of a resource, service type, or result classification in the KDDI billing system. Used as the primary display key in formatted output. If null or empty, the method returns null immediately (no formatting is performed). |
| 2 | `nm` | `String` | Name value — the human-readable label corresponding to the code. May be null when only the code is available for display. If null, an empty string is substituted in the formatted output, producing a result like `CD（）`. |

**Instance fields / external state read:** None. This method is pure — it depends only on its parameters and static constants.

## 4. CRUD Operations / Called Services

### Pre-computed evidence from code analysis graph:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKBatCommon.isNotNull` | JKKBatCommon | - | Reads/validates the `cd` parameter — checks whether the string is not null and not empty; used as a guard condition before formatting |

**Notes:**
- No Create/Update/Delete operations. This is a read-only utility method — it performs string transformation only.
- `JKKBatCommon.isNotNull()` is the static null-check utility (inherited from `JCCBatCommon`) used to guard against null/empty input before attempting string formatting.

## 5. Dependency Trace

### Pre-computed evidence from code analysis graph:

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `isNotNull` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKKDDIAnkenChsht | `JBSbatKKKDDIAnkenChsht.setKDDIRslt` -> `JBSbatKKKDDIAnkenChsht.createCdNm` | `isNotNull [R] -` |

**Analysis:**
- `createCdNm` is a private method with a single caller: `setKDDIRslt` (same class), which assembles KDDI result records during batch processing.
- No screen (KKSV*) or external CBS entry points directly invoke this method — it is an internal helper exclusively used by the batch's result-setting logic.

## 6. Per-Branch Detail Blocks

**Block 1** — IF `(JKKBatCommon.isNotNull(cd))` (L623)

> Check whether the code parameter has a non-null, non-empty value. This is the primary guard: if the code is absent, no formatted output can be produced.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `JKKBatCommon.isNotNull(cd)` — Validates that `cd` is not null or empty [-> JKKBatCommon.isNotNull] |

**Block 1.1** — IF `(nm == null)` (L624-626)

> The name parameter is null. Produce a formatted string with an empty name placeholder. Result: `CD（）`.

| # | Type | Code |
|---|------|------|
| 1 | SET | Template = `"CD（NM）"` [-> `JKKStrConst.KDDI_RSLT_CD_NM` = `"CD（NM）"`] |
| 2 | SET | Placeholder CD = `"CD"` [-> `JKKStrConst.KDDI_RSLT_CD` = `"CD"`] |
| 3 | SET | Placeholder NM = `"NM"` [-> `JKKStrConst.KDDI_RSLT_NM` = `"NM"`] |
| 4 | RETURN | `Template.replace("CD", cd).replace("NM", "")` — Code is inserted, name placeholder is replaced with empty string [-> `"CD（）"` with actual code] |

**Block 1.2** — ELSE-IF `(nm != null)` (L627)

> Both code and name are present. Produce the fully formatted display string. Result: `CD（NM）`.

| # | Type | Code |
|---|------|------|
| 1 | SET | Template = `"CD（NM）"` [-> `JKKStrConst.KDDI_RSLT_CD_NM` = `"CD（NM）"`] |
| 2 | SET | Placeholder CD = `"CD"` [-> `JKKStrConst.KDDI_RSLT_CD` = `"CD"`] |
| 3 | SET | Placeholder NM = `"NM"` [-> `JKKStrConst.KDDI_RSLT_NM` = `"NM"`] |
| 4 | RETURN | `Template.replace("CD", cd).replace("NM", nm)` — Both code and name are inserted into the template [-> `"ActualCode（ActualName）"`] |

**Block 2** — ELSE (L629-630)

> The code parameter is null or empty. No valid formatted output can be produced. Return null.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `null` — Returns null because the required code component is absent [Guard: `isNotNull(cd)` was false] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|-----------------|
| `cd` | Parameter | Code — An identifier string used to classify or reference a resource, service, or result in the KDDI billing system |
| `nm` | Parameter | Name — The human-readable label associated with a code value |
| KDDI_RSLT_CD | Constant | Result Code placeholder token (`"CD"`) — Used within the template to mark where the code value should be inserted |
| KDDI_RSLT_NM | Constant | Result Name placeholder token (`"NM"`) — Used within the template to mark where the name value should be inserted |
| KDDI_RSLT_CD_NM | Constant | Result Code-Name combined template (`"CD（NM）"`) — Fixed format string for displaying code and name together with full-width parentheses |
| JKKBatCommon | Class | KDDI Batch Common — Base utility class for batch processing, extended from JCCBatCommon. Provides shared helper methods including `isNotNull` for null-checking |
| isNotNull | Method | Null-check utility — Returns true if the given String is neither null nor empty; used as a guard against invalid input |
| コード（Code） | Japanese term | A classification or identifier code used throughout the KDDI system |
| 名称（Name） | Japanese term | The human-readable name or label corresponding to a code |
| コード名称結合（CdNm） | Japanese term | Code-Name combination — The business operation of merging a code with its display name into a single formatted string |
