SAP CRM_STATUS_CHANGE_FOR_ACTIVITY Function Module for Carry Out Status Changes for an Activity
CRM_STATUS_CHANGE_FOR_ACTIVITY is a standard crm status change for activity SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Carry Out Status Changes for an Activity processing and below is the pattern details for this FM, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.
See here to view full function module documentation and code listing for crm status change for activity FM, simply by entering the name CRM_STATUS_CHANGE_FOR_ACTIVITY into the relevant SAP transaction such as SE37 or SE38.
Function Group: CRMBSVA
Program Name: SAPLCRMBSVA
Main Program: SAPLCRMBSVA
Appliation area:
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function CRM_STATUS_CHANGE_FOR_ACTIVITY pattern details
In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.CALL FUNCTION 'CRM_STATUS_CHANGE_FOR_ACTIVITY'"Carry Out Status Changes for an Activity.
EXPORTING
* ACTIVITY_ALLOWED = ' ' "'Activity Allowed' Flag (Only for OBTYP = ORC)
* CHECK_ONLY = ' ' "'Carry Out Checks Only' Flag
* CLIENT = SY-MANDT "Client (Use Only in Exceptional Cases!)
* NO_CHECK = ' ' "'No Check Whether Activity Allowed' Flag
OBJNR = "Object Number
VRGNG = "Activity for which the Subsequent Statuses are to be Set
* ZEILE = ' ' "Line Number for Message Handler, if Active
* SET_CHGKZ = "'Activate Change Documents' Flag
* XNOAUTO = "Do not update status of this object automatically
IMPORTING
STONR = "Status number
ACTIVITY_NOT_ALLOWED = "'Activity not Allowed' Flag
ERROR_OCCURRED = "'Error Message Occurred' Flag
OBJECT_NOT_FOUND = "'Status Object Not Found' Flag
STATUS_INCONSISTENT = "'Status Set and Deleted' Flag
STATUS_NOT_ALLOWED = "'Status Change Not Allowed' Flag
WARNING_OCCURRED = "'Warning Message Occurred' Flag
EXCEPTIONS
ACTIVITY_NOT_ALLOWED = 1 OBJECT_NOT_FOUND = 2 STATUS_INCONSISTENT = 3 STATUS_NOT_ALLOWED = 4 WRONG_INPUT = 5 WARNING_OCCURED = 6
IMPORTING Parameters details for CRM_STATUS_CHANGE_FOR_ACTIVITY
ACTIVITY_ALLOWED - 'Activity Allowed' Flag (Only for OBTYP = ORC)
Data type: XFELDDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
CHECK_ONLY - 'Carry Out Checks Only' Flag
Data type: XFELDDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
CLIENT - Client (Use Only in Exceptional Cases!)
Data type: SY-MANDTDefault: SY-MANDT
Optional: Yes
Call by Reference: No ( called with pass by value option)
NO_CHECK - 'No Check Whether Activity Allowed' Flag
Data type: XFELDDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
OBJNR - Object Number
Data type: CRM_JSTO-OBJNROptional: No
Call by Reference: No ( called with pass by value option)
VRGNG - Activity for which the Subsequent Statuses are to be Set
Data type: TJ01-VRGNGOptional: No
Call by Reference: No ( called with pass by value option)
ZEILE - Line Number for Message Handler, if Active
Data type: MESG-ZEILEDefault: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)
SET_CHGKZ - 'Activate Change Documents' Flag
Data type: CRM_JSTO-CHGKZOptional: Yes
Call by Reference: No ( called with pass by value option)
XNOAUTO - Do not update status of this object automatically
Data type: CRM_JSTO_UPD-XNOAUTOOptional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for CRM_STATUS_CHANGE_FOR_ACTIVITY
STONR - Status number
Data type: TJ30-STONROptional: No
Call by Reference: No ( called with pass by value option)
ACTIVITY_NOT_ALLOWED - 'Activity not Allowed' Flag
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
ERROR_OCCURRED - 'Error Message Occurred' Flag
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
OBJECT_NOT_FOUND - 'Status Object Not Found' Flag
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
STATUS_INCONSISTENT - 'Status Set and Deleted' Flag
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
STATUS_NOT_ALLOWED - 'Status Change Not Allowed' Flag
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
WARNING_OCCURRED - 'Warning Message Occurred' Flag
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
ACTIVITY_NOT_ALLOWED - 'Activity not Allowed' Flag
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
OBJECT_NOT_FOUND - 'Status Object Not Found' Flag
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
STATUS_INCONSISTENT - 'Status Set and Deleted' Flag
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
STATUS_NOT_ALLOWED - 'Status Change Not Allowed' Flag
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
WRONG_INPUT - CHECK_ONLY = 'X' and NO_CHECK = 'X'
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
WARNING_OCCURED - Activity is 'Allowed with Warning' Only
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for CRM_STATUS_CHANGE_FOR_ACTIVITY Function Module
The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than 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 newer method of declaring data variables on the fly. 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), which i why i have stuck to the origianl for this example.| DATA: | ||||
| lv_stonr | TYPE TJ30-STONR, " | |||
| lv_activity_allowed | TYPE XFELD, " SPACE | |||
| lv_activity_not_allowed | TYPE XFELD, " | |||
| lv_check_only | TYPE XFELD, " SPACE | |||
| lv_object_not_found | TYPE XFELD, " | |||
| lv_activity_not_allowed | TYPE XFELD, " | |||
| lv_client | TYPE SY-MANDT, " SY-MANDT | |||
| lv_error_occurred | TYPE SY, " | |||
| lv_status_inconsistent | TYPE SY, " | |||
| lv_no_check | TYPE XFELD, " SPACE | |||
| lv_object_not_found | TYPE XFELD, " | |||
| lv_status_not_allowed | TYPE XFELD, " | |||
| lv_objnr | TYPE CRM_JSTO-OBJNR, " | |||
| lv_wrong_input | TYPE CRM_JSTO, " | |||
| lv_status_inconsistent | TYPE CRM_JSTO, " | |||
| lv_vrgng | TYPE TJ01-VRGNG, " | |||
| lv_warning_occured | TYPE TJ01, " | |||
| lv_status_not_allowed | TYPE TJ01, " | |||
| lv_zeile | TYPE MESG-ZEILE, " SPACE | |||
| lv_warning_occurred | TYPE MESG, " | |||
| lv_set_chgkz | TYPE CRM_JSTO-CHGKZ, " | |||
| lv_xnoauto | TYPE CRM_JSTO_UPD-XNOAUTO. " |
|   CALL FUNCTION 'CRM_STATUS_CHANGE_FOR_ACTIVITY' "Carry Out Status Changes for an Activity |
| EXPORTING | ||
| ACTIVITY_ALLOWED | = lv_activity_allowed | |
| CHECK_ONLY | = lv_check_only | |
| CLIENT | = lv_client | |
| NO_CHECK | = lv_no_check | |
| OBJNR | = lv_objnr | |
| VRGNG | = lv_vrgng | |
| ZEILE | = lv_zeile | |
| SET_CHGKZ | = lv_set_chgkz | |
| XNOAUTO | = lv_xnoauto | |
| IMPORTING | ||
| STONR | = lv_stonr | |
| ACTIVITY_NOT_ALLOWED | = lv_activity_not_allowed | |
| ERROR_OCCURRED | = lv_error_occurred | |
| OBJECT_NOT_FOUND | = lv_object_not_found | |
| STATUS_INCONSISTENT | = lv_status_inconsistent | |
| STATUS_NOT_ALLOWED | = lv_status_not_allowed | |
| WARNING_OCCURRED | = lv_warning_occurred | |
| EXCEPTIONS | ||
| ACTIVITY_NOT_ALLOWED = 1 | ||
| OBJECT_NOT_FOUND = 2 | ||
| STATUS_INCONSISTENT = 3 | ||
| STATUS_NOT_ALLOWED = 4 | ||
| WRONG_INPUT = 5 | ||
| WARNING_OCCURED = 6 | ||
| . " CRM_STATUS_CHANGE_FOR_ACTIVITY | ||
ABAP code using 7.40 inline data declarations to call FM CRM_STATUS_CHANGE_FOR_ACTIVITY
The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8.| "SELECT single STONR FROM TJ30 INTO @DATA(ld_stonr). | ||||
| DATA(ld_activity_allowed) | = ' '. | |||
| DATA(ld_check_only) | = ' '. | |||
| "SELECT single MANDT FROM SY INTO @DATA(ld_client). | ||||
| DATA(ld_client) | = SY-MANDT. | |||
| DATA(ld_no_check) | = ' '. | |||
| "SELECT single OBJNR FROM CRM_JSTO INTO @DATA(ld_objnr). | ||||
| "SELECT single VRGNG FROM TJ01 INTO @DATA(ld_vrgng). | ||||
| "SELECT single ZEILE FROM MESG INTO @DATA(ld_zeile). | ||||
| DATA(ld_zeile) | = ' '. | |||
| "SELECT single CHGKZ FROM CRM_JSTO INTO @DATA(ld_set_chgkz). | ||||
| "SELECT single XNOAUTO FROM CRM_JSTO_UPD INTO @DATA(ld_xnoauto). | ||||
Search for further information about these or an SAP related objects