# SAP_WAPI_START_WORKFLOW — Workflow: Start Workflow

> Starts a workflow or task directly, without an event, and returns the ID of the created work item. It is used when a program must start a specific workflow template (WS…) with a filled container, for example from a custom approval transaction. Fill INPUT_CONTAINER with the container elements the workflow expects, set DO_COMMIT if no other COMMIT WORK follows, and check RETURN_CODE and MESSAGE_LINES.

- Modules: CA
- Type: Function module
- Function group: SWRR
- Remote-enabled (RFC): Yes
- S/4HANA status: Used the same way in S/4HANA
- URL: https://nekuhub.com/en/functions/sap-wapi-start-workflow/

## Importing parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| TASK | SWR_STRUCT-TASK | Task or workflow template | Yes |
| LANGUAGE | SWR_STRUCT-WILANGUAGE | Language | - |
| DO_COMMIT | XFLAG | Execute COMMIT WORK | - |
| USER | SYUNAME | User who starts the workflow | - |
| START_ASYNCHRONOUS | XFLAG | Start asynchronously | - |
| DESIRED_START_DATE | SWR_DATEIN | Desired start date | - |
| DESIRED_START_TIME | SWR_TIMEIN | Desired start time | - |
| DESIRED_START_ZONLO | SYSTZONLO | Time zone of the start time | - |
| IFS_XML_CONTAINER | XSTRING | Container as XML | - |

## Exporting parameters

| Parameter | Type | Description |
|---|---|---|
| RETURN_CODE | SY-SUBRC | Return code |
| WORKITEM_ID | SWR_STRUCT-WORKITEMID | ID of the created work item |
| NEW_STATUS | SWR_WISTAT | Status of the work item |

## Tables parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| INPUT_CONTAINER | SWR_CONT | Input container | - |
| AGENTS | SWRAGENT | Agents | - |
| MESSAGE_LINES | SWR_MESSAG | Message lines | - |
| MESSAGE_STRUCT | SWR_MSTRUC | Message structure | - |

## Call template (ABAP)

```abap
CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
  EXPORTING
    task = lv_task
  IMPORTING
    return_code = lv_return_code
    workitem_id = lv_workitem_id
    new_status = lv_new_status
  TABLES
    input_container = lt_input_container
    agents = lt_agents
    message_lines = lt_message_lines
    message_struct = lt_message_struct.
```

## Related tables

SWWWIHEAD

