Developer ToolsFree generatorPDF, Excel, Word exportSAP BW/4HANAAll SAP BW and BW/4HANA tools

SAP BW Process Chain API Generator: RSPC_API_CHAIN_START in ABAP

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.

Fill in

Generated code
Download:

1. Start the chain and wait for the result

REPORT ZBW_START_CHAIN.

PARAMETERS: p_chain TYPE rspc_chain DEFAULT 'ZPC_SALES_DAILY',
            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.

  " 120 minutes at 30 second intervals
  lv_loops = ( 120 * 60 ) / 30.

  DO lv_loops TIMES.
    WAIT UP TO 30 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

" 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 = 'ZPC_SALES_DAILY'
    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

" 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 = 'ZPC_SALES_DAILY'
  ORDER BY datum DESCENDING, zeit DESCENDING
  INTO TABLE @DATA(lt_runs)
  UP TO 20 ROWS.

Status codes returned in E_STATUS (domain RSPC_STATE)

ValueMeaning
GSuccessfully completed
FCompleted
REnded with errors
JEnded with error (for example subsequent job missing)
XCanceled
AActive
PPlanned
QReleased
YReady
SSkipped at restart

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.

Get your chain monitoring checked

Tell us how your chains are triggered and monitored today and we will suggest a simpler, more reliable setup for your BW release.

Optional. The tool and every export work without this. No spam.

Was this tool useful?

How to use it

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.

  • 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

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

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

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.

Frequently Asked Questions

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

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?

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?

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?

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.

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.