# SAP BW Process Chain API Generator: RSPC_API_CHAIN_START in ABAP

> Source: https://netray.co/tools/sap-bw-process-chain-rspc-api-abap-generator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Generate an ABAP report that starts a process chain through the RSPC API, polls its status until green or red, interrupts a schedule, or lists scheduled chains.

## Category

developer

## Erp

SAP BW/4HANA

## Audience

- BW developer
- BW administrator
- SAP Basis administrator

## Tool

**Kind:** template

**Output:** code

**Language:** abap

**Fields:**

#### Report name

**Key:** report

**Type:** text

**Default:** ZBW_START_CHAIN

#### Process chain technical name

**Key:** chain

**Type:** text

**Default:** ZPC_SALES_DAILY

#### Poll interval (seconds)

**Key:** poll

**Type:** number

**Default:** 30

#### Maximum wait (minutes)

**Key:** maxwait

**Type:** number

**Default:** 120

**Blocks:**

#### 1. Start the chain and wait for the result

**Body:** REPORT {{report}}.

PARAMETERS: p_chain TYPE rspc_chain DEFAULT '{{chain}}',
            p_wait  AS CHECKBOX DEFAULT 'X'.

DATA: lv_logid  TYPE rspc_logid,
      lv_status TYPE rspc_state,
      lv_loops  TYPE i.

START-OF-SELECTION.
  CALL FUNCTION 'RSPC_API_CHAIN_START'
    EXPORTING
      i_chain = p_chain
    IMPORTING
      e_logid = lv_logid
    EXCEPTIONS
      failed  = 1
      OTHERS  = 2.
  IF sy-subrc <> 0.
    MESSAGE |Chain { p_chain } could not be started (sy-subrc { sy-subrc })| TYPE 'E'.
  ENDIF.
  WRITE: / 'Started', p_chain, 'log ID', lv_logid.

  CHECK p_wait = abap_true.

  " {{maxwait}} minutes at {{poll}} second intervals
  lv_loops = ( {{maxwait}} * 60 ) / {{poll}}.

  DO lv_loops TIMES.
    WAIT UP TO {{poll}} SECONDS.
    CALL FUNCTION 'RSPC_API_CHAIN_GET_STATUS'
      EXPORTING
        i_chain   = p_chain
        i_logid   = lv_logid
      IMPORTING
        e_status  = lv_status.
    CASE lv_status.
      WHEN 'G' OR 'F'.
        WRITE: / 'Finished successfully, log ID', lv_logid.
        EXIT.
      WHEN 'R' OR 'J'.
        WRITE: / 'Ended with errors, log ID', lv_logid.
        EXIT.
      WHEN 'X'.
        WRITE: / 'Canceled, log ID', lv_logid.
        EXIT.
      WHEN OTHERS.
        " A = active, P = planned, Q = released, Y = ready: keep waiting
    ENDCASE.
  ENDDO.

  IF lv_status <> 'G' AND lv_status <> 'F'.
    MESSAGE |Chain { p_chain } status { lv_status } after wait| TYPE 'E'.
  ENDIF.

#### 2. Interrupt a scheduled chain

**Body:** " Removes the chain from the schedule (release of the start job).
" i_kill = abap_true also stops processes that are running.
CALL FUNCTION 'RSPC_API_CHAIN_INTERRUPT'
  EXPORTING
    i_chain = '{{chain}}'
    i_kill  = abap_false
  EXCEPTIONS
    failed  = 1
    OTHERS  = 2.
IF sy-subrc <> 0.
  MESSAGE 'Interrupt failed' TYPE 'E'.
ENDIF.

#### 3. List chains, their start variants and last runs

**Body:** " Start processes (type TRIGGER) of active chains
SELECT chain_id, type, variante
  FROM rspcchain
  WHERE objvers = 'A'
    AND type    = 'TRIGGER'
  ORDER BY chain_id
  INTO TABLE @DATA(lt_start).

" Released start jobs waiting to run (status S = released)
SELECT jobname, jobcount, sdlstrtdt, sdlstrttm, status
  FROM tbtco
  WHERE jobname = 'BI_PROCESS_TRIGGER'
    AND status  = 'S'
  ORDER BY sdlstrtdt, sdlstrttm
  INTO TABLE @DATA(lt_jobs).

" Last 20 runs of one chain with their analysed status
SELECT chain_id, log_id, datum, zeit, analyzed_status
  FROM rspclogchain
  WHERE chain_id = '{{chain}}'
  ORDER BY datum DESCENDING, zeit DESCENDING
  INTO TABLE @DATA(lt_runs)
  UP TO 20 ROWS.

#### Status codes returned in E_STATUS (domain RSPC_STATE)

**Table:**

**Columns:**

- Value
- Meaning

**Rows:**

**0:** G

**1:** Successfully completed

**0:** F

**1:** Completed

**0:** R

**1:** Ended with errors

**0:** J

**1:** Ended with error (for example subsequent job missing)

**0:** X

**1:** Canceled

**0:** A

**1:** Active

**0:** P

**1:** Planned

**0:** Q

**1:** Released

**0:** Y

**1:** Ready

**0:** S

**1:** Skipped at restart

**Notes:** Parameters checked against the function module interfaces: RSPC_API_CHAIN_START (I_CHAIN; E_LOGID; exception FAILED), RSPC_API_CHAIN_GET_STATUS (I_CHAIN, I_LOGID; E_STATUS) and RSPC_API_CHAIN_INTERRUPT (I_CHAIN, I_KILL; exception FAILED). The function modules have further optional parameters, including a message text output on GET_STATUS; check their names and types in SE37 on your release before adding them, and run the report in a background job, not in dialog, when waiting is on.

## Content

**Intro:** This generator writes an ABAP report that starts an SAP BW process chain through the RSPC API, waits for it and reports green, red or canceled, plus snippets to interrupt a schedule and to list scheduled chains and recent runs. It works on BW 7.x and BW/4HANA, where the RSPC API function modules are unchanged.

**Sections:**

#### How to use it

**Body:** Enter the report name, the technical name of the chain (as shown in RSPC or the BW Modeling Tools), the poll interval and the maximum wait. Create the report in SE38 or ADT, paste block 1 and activate. Running it in a background job lets an external scheduler or a job step wait for the chain and fail the step when the chain ends red, which is the usual reason to call the API instead of scheduling the chain directly. Blocks 2 and 3 are fragments to drop into the same or another report.

**Bullets:**

- The chain's start process must be set to start using a meta chain or API, not direct scheduling.
- The user running the report needs authorization object S_RS_PC for the chain.
- From outside SAP the same function modules can be called over RFC if they are remote-enabled on your release; check in SE37.

#### How scheduling works in SAP BW

**Body:** Every process chain begins with a start process (process type TRIGGER in table RSPCCHAIN). With direct scheduling, activating and scheduling the chain releases a background job named BI_PROCESS_TRIGGER at the planned time; that is what you see in SM37 and what block 3 lists from TBTCO. With the API or meta chain option there is no own schedule, and the chain runs only when RSPC_API_CHAIN_START is called or a parent chain reaches it. Each run gets a log ID; RSPCLOGCHAIN keeps one row per run with date, time and analysed status, which is the quickest way to answer how often a chain ran red last month.

#### Reading the status and finding the error message

**Body:** RSPC_API_CHAIN_GET_STATUS returns a one-letter state from domain RSPC_STATE in E_STATUS. G and F are success, R and J are errors, X is canceled, and A, P, Q and Y mean still in progress, so the generated loop keeps polling for those. When a chain goes red, the status only tells you that it failed; the detail lives in the process log. Open RSPC, choose the log view for the run, right click the red process and display messages, or look at the job log of the failing process in SM37. Repeating only failed processes after fixing data is done from the same log view.

#### Common mistakes

**Body:** Polling in a dialog work process ties up a dialog slot and runs into the dialog time limit, so run waiting reports in the background. Passing the chain name in lower case fails because technical names are stored in upper case. Calling the API on a chain whose start variant is set to direct scheduling starts an extra run next to the scheduled one. Interrupting with I_KILL set stops running loads mid-request, which can leave red requests to clean up in the target. Finally, a chain that is still being changed (version M) runs in its last active version, so activate first.

**Cta:** If your BW team wants to ask which chains failed and why in plain English, answered from your own logs on your own servers, we can set that up.

**Faq:**

#### How do I start a process chain from ABAP with RSPC_API_CHAIN_START?

**Answer:** Call RSPC_API_CHAIN_START with I_CHAIN set to the chain's technical name, read E_LOGID, and handle the FAILED exception. Use the log ID with RSPC_API_CHAIN_GET_STATUS to follow the run. The start process of the chain must allow starting by API or meta chain.

#### How do I see a list of scheduled process chains in SAP BW?

**Answer:** Scheduled chains have a released job named BI_PROCESS_TRIGGER, visible in SM37 or in table TBTCO with status S. The start processes themselves are rows with type TRIGGER in RSPCCHAIN, version A. RSPC also lists chains by display component with their last run status.

#### How do I schedule a process chain in SAP BW?

**Answer:** Maintain the start process variant: choose direct scheduling, set the date, time and periodicity, then activate and schedule the chain from RSPC. That releases the BI_PROCESS_TRIGGER job. Choose start using meta chain or API instead if another chain or an external scheduler should trigger it.

#### Where do I find the process chain error message?

**Answer:** RSPC_API_CHAIN_GET_STATUS only returns the status. For the message, open the run in the RSPC log view, select the red process and display its messages, or check the job log of that process in SM37. Load errors also appear in the DTP monitor of the request.

## Search terms

rspc_api_chain_start in sap bw, how to schedule process chain in sap bw, sap bw list of scheduled process chains, sap bw process chain error message, how to create process chain in sap bw, rspc_api_chain_get_status, rspc_api_chain_interrupt

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
