CHANGE_SOURCE 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 CHANGE_SOURCE into the relevant SAP transaction such as SE37 or SE80.
Associated Function Group:
S38E
Released Date:
Not Released
Processing type: Normal fucntion module
CALL FUNCTION 'CHANGE_SOURCE' "
EXPORTING
mode = " char4
source = " trdir-name
* first_line = 1 " sy-index
* cursor_line = 1 " sy-index
* cursor_offset = 0 " sy-index
* full_name = SPACE " string
* enhname = SPACE " enhname
editor_handle = " cl_wb_pgeditor
not_read = "
* textelement = " textpool ABAP Text Pool Definition
* with_impl_enhancements = SPACE " char1
* single_enhname = SPACE " enhname
* CHANGING
* status = ' ' " progdir-state ABAP: Program Status (Active, Saved, Transported...)
EXCEPTIONS
CANCELLED = 1 "
NOT_FOUND = 2 "
. " CHANGE_SOURCE
The ABAP code below is a full code listing to execute function module CHANGE_SOURCE 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).
SELECT single STATE
FROM PROGDIR
INTO @DATA(ld_status).
DATA(ld_mode) = 'Check type of data required'.
SELECT single NAME
FROM TRDIR
INTO @DATA(ld_source).
DATA(ld_first_line) = '123 '.
DATA(ld_cursor_line) = '123 '.
DATA(ld_cursor_offset) = '123 '.
DATA(ld_full_name) = '123 '.
DATA(ld_enhname) = '123 '.
DATA(ld_editor_handle) = '123 '.
DATA(ld_not_read) = 'some text here'.
DATA(ld_textelement) = '123 '.
DATA(ld_with_impl_enhancements) = '123 '.
DATA(ld_single_enhname) = '123 '. . CALL FUNCTION 'CHANGE_SOURCE' EXPORTING mode = ld_mode source = ld_source * first_line = ld_first_line * cursor_line = ld_cursor_line * cursor_offset = ld_cursor_offset * full_name = ld_full_name * enhname = ld_enhname editor_handle = ld_editor_handle not_read = ld_not_read * textelement = ld_textelement * with_impl_enhancements = ld_with_impl_enhancements * single_enhname = ld_single_enhname * CHANGING * status = ld_status EXCEPTIONS CANCELLED = 1 NOT_FOUND = 2 . " CHANGE_SOURCE
IF SY-SUBRC EQ 0. "All OK ELSEIF SY-SUBRC EQ 1. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 2. "Exception "Add code for exception here ENDIF.
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_status | TYPE PROGDIR-STATE , |
| ld_mode | TYPE CHAR4 , |
| ld_source | TYPE TRDIR-NAME , |
| ld_first_line | TYPE SY-INDEX , |
| ld_cursor_line | TYPE SY-INDEX , |
| ld_cursor_offset | TYPE SY-INDEX , |
| ld_full_name | TYPE STRING , |
| ld_enhname | TYPE ENHNAME , |
| ld_editor_handle | TYPE CL_WB_PGEDITOR , |
| ld_not_read | TYPE STRING , |
| ld_textelement | TYPE TEXTPOOL , |
| ld_with_impl_enhancements | TYPE CHAR1 , |
| ld_single_enhname | TYPE ENHNAME . |
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 CHANGE_SOURCE or its description.