SAP Function Modules

STATUS_CHANGE_FOR_ACTIVITY SAP Function module - Carry Out Status Changes for an Activity







STATUS_CHANGE_FOR_ACTIVITY is a standard SAP function module available within R/3 SAP systems depending on your version and release level. Below is the pattern details for this FM showing its interface including any import and export parameters, exceptions etc as well as any documentation contributions (Comments) specific to the object.

See here to view full function module documentation and code listing, simply by entering the name STATUS_CHANGE_FOR_ACTIVITY into the relevant SAP transaction such as SE37 or SE80.

Associated Function Group: BSVA
Released Date: Not Released
Processing type: Normal fucntion module
Normal function module settings


Pattern for FM STATUS_CHANGE_FOR_ACTIVITY - STATUS CHANGE FOR ACTIVITY





CALL FUNCTION 'STATUS_CHANGE_FOR_ACTIVITY' "Carry Out Status Changes for an Activity
  EXPORTING
*   activity_allowed = SPACE    " xfeld         'Activity Allowed' Flag (Only for OBTYP = ORC)
*   check_only = SPACE          " xfeld         'Carry Out Checks Only' Flag
*   client = SY-MANDT           " sy-mandt      Client (Use Only in Exceptional Cases!)
*   no_check = SPACE            " xfeld         'No Check Whether Activity Allowed' Flag
    objnr =                     " jsto-objnr    Object Number
    vrgng =                     " tj01-vrgng    Activity for which the Subsequent Statuses are to be Set
*   zeile = SPACE               " mesg-zeile    Line Number for Message Handler, if Active
*   set_chgkz =                 " jsto-chgkz    'Activate Change Documents' Flag
*   date =                      " sy-datum      Effective Date for Results Analysis
*   no_authority_check = SPACE  " xfeld         Suppress Authorization Check
  IMPORTING
    stonr =                     " tj30-stonr    Status Number
    activity_not_allowed =      "               'Activity not Allowed' Flag
    activity_not_allowed =      "               Activity not Allowed
    error_occurred =            "               'Error Message Occurred' Flag
    object_not_found =          "               'Status Object Not Found' Flag
    object_not_found =          "               Status Object Not Found
    status_inconsistent =       "               'Status Set and Deleted' Flag
    status_inconsistent =       "               Individual Status Should be Set and Deleted
    status_not_allowed =        "               'Status Change Not Allowed' Flag
    status_not_allowed =        "               Status Change Not Allowed
    warning_occurred =          "               'Warning Message Occurred' Flag
  EXCEPTIONS
    ACTIVITY_NOT_ALLOWED = 1    "               Activity not Allowed
    ACTIVITY_NOT_ALLOWED = 1    "               'Activity not Allowed' Flag
    OBJECT_NOT_FOUND = 2        "               Status Object Not Found
    OBJECT_NOT_FOUND = 2        "               'Status Object Not Found' Flag
    STATUS_INCONSISTENT = 3     "               Individual Status Should be Set and Deleted
    STATUS_INCONSISTENT = 3     "               'Status Set and Deleted' Flag
    STATUS_NOT_ALLOWED = 4      "               Status Change Not Allowed
    STATUS_NOT_ALLOWED = 4      "               'Status Change Not Allowed' Flag
    WRONG_INPUT = 5             "               CHECK_ONLY = 'X' and NO_CHECK = 'X'
    WARNING_OCCURED = 6         "               Activity is "Allowed with Warning" Only
    .  "  STATUS_CHANGE_FOR_ACTIVITY

ABAP code example for Function Module STATUS_CHANGE_FOR_ACTIVITY





The ABAP code below is a full code listing to execute function module STATUS_CHANGE_FOR_ACTIVITY including all data declarations. The code uses the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the original method of declaring data variables up front. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8).

DATA:
ld_stonr  TYPE TJ30-STONR ,
ld_activity_not_allowed  TYPE STRING ,
ld_activity_not_allowed  TYPE STRING ,
ld_error_occurred  TYPE STRING ,
ld_object_not_found  TYPE STRING ,
ld_object_not_found  TYPE STRING ,
ld_status_inconsistent  TYPE STRING ,
ld_status_inconsistent  TYPE STRING ,
ld_status_not_allowed  TYPE STRING ,
ld_status_not_allowed  TYPE STRING ,
ld_warning_occurred  TYPE STRING .

DATA(ld_activity_allowed) = 'Check type of data required'.
DATA(ld_check_only) = 'Check type of data required'.
DATA(ld_client) = 'Check type of data required'.
DATA(ld_no_check) = 'Check type of data required'.

SELECT single OBJNR
FROM JSTO
INTO @DATA(ld_objnr).


SELECT single VRGNG
FROM TJ01
INTO @DATA(ld_vrgng).


DATA(ld_zeile) = some text here

SELECT single CHGKZ
FROM JSTO
INTO @DATA(ld_set_chgkz).

DATA(ld_date) = '20210129'.
DATA(ld_no_authority_check) = '20210129'. . CALL FUNCTION 'STATUS_CHANGE_FOR_ACTIVITY' EXPORTING * activity_allowed = ld_activity_allowed * check_only = ld_check_only * client = ld_client * no_check = ld_no_check objnr = ld_objnr vrgng = ld_vrgng * zeile = ld_zeile * set_chgkz = ld_set_chgkz * date = ld_date * no_authority_check = ld_no_authority_check IMPORTING stonr = ld_stonr activity_not_allowed = ld_activity_not_allowed activity_not_allowed = ld_activity_not_allowed error_occurred = ld_error_occurred object_not_found = ld_object_not_found object_not_found = ld_object_not_found status_inconsistent = ld_status_inconsistent status_inconsistent = ld_status_inconsistent status_not_allowed = ld_status_not_allowed status_not_allowed = ld_status_not_allowed warning_occurred = ld_warning_occurred EXCEPTIONS ACTIVITY_NOT_ALLOWED = 1 ACTIVITY_NOT_ALLOWED = 1 OBJECT_NOT_FOUND = 2 OBJECT_NOT_FOUND = 2 STATUS_INCONSISTENT = 3 STATUS_INCONSISTENT = 3 STATUS_NOT_ALLOWED = 4 STATUS_NOT_ALLOWED = 4 WRONG_INPUT = 5 WARNING_OCCURED = 6 . " STATUS_CHANGE_FOR_ACTIVITY
IF SY-SUBRC EQ 0. "All OK ELSEIF SY-SUBRC EQ 1. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 1. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 2. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 2. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 3. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 3. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 4. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 4. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 5. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 6. "Exception "Add code for exception here ENDIF.







ABAP code to compare 7.40 inline data declaration with original syntax

The below ABAP code uses the older none in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. It may also be useful if you are using an older version of SAP as some of the newer syntax above, such as the @DATA is not available until 4.70 EHP 8.

DATA:
ld_stonr  TYPE TJ30-STONR ,
ld_activity_allowed  TYPE XFELD ,
ld_activity_not_allowed  TYPE STRING ,
ld_activity_not_allowed  TYPE STRING ,
ld_check_only  TYPE XFELD ,
ld_error_occurred  TYPE STRING ,
ld_client  TYPE SY-MANDT ,
ld_object_not_found  TYPE STRING ,
ld_object_not_found  TYPE STRING ,
ld_no_check  TYPE XFELD ,
ld_objnr  TYPE JSTO-OBJNR ,
ld_status_inconsistent  TYPE STRING ,
ld_status_inconsistent  TYPE STRING ,
ld_vrgng  TYPE TJ01-VRGNG ,
ld_status_not_allowed  TYPE STRING ,
ld_status_not_allowed  TYPE STRING ,
ld_zeile  TYPE MESG-ZEILE ,
ld_warning_occurred  TYPE STRING ,
ld_set_chgkz  TYPE JSTO-CHGKZ ,
ld_date  TYPE SY-DATUM ,
ld_no_authority_check  TYPE XFELD .

ld_activity_allowed = '20210129'.
ld_check_only = '20210129'.
ld_client = 'Check type of data required'.
ld_no_check = 'Check type of data required'.

SELECT single OBJNR
FROM JSTO
INTO ld_objnr.


SELECT single VRGNG
FROM TJ01
INTO ld_vrgng.


ld_zeile = some text here

SELECT single CHGKZ
FROM JSTO
INTO ld_set_chgkz.

ld_date = '20210129'.
ld_no_authority_check = '20210129'.

SAP Documentation for FM STATUS_CHANGE_FOR_ACTIVITY


The function module executes an activity on a status object.
It first checks whether the activity is currently allowed, i.e. ...See here for full SAP fm documentation

Contribute (Add Comments)

Please help keep this info upto date and use the comments section below to add useful hints, tips and information specific to this SAP function. This will then be available for you and other users to easily find by simply searching on the object name STATUS_CHANGE_FOR_ACTIVITY or its description.