SAP GRFN_ATF_WRITE Function Module for Write audit log for object, internal used only, do not call me outside
GRFN_ATF_WRITE is a standard grfn atf write SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Write audit log for object, internal used only, do not call me outside 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 grfn atf write FM, simply by entering the name GRFN_ATF_WRITE into the relevant SAP transaction such as SE37 or SE38.
Function Group: GRFN_ATF
Program Name: SAPLGRFN_ATF
Main Program: SAPLGRFN_ATF
Appliation area:
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update: 1

Function GRFN_ATF_WRITE 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 'GRFN_ATF_WRITE'"Write audit log for object, internal used only, do not call me outside.
EXPORTING
I_TOPIC_ID = "Topic of the audit trail
I_FIELD_NAME = "Field Name
I_VALUE_OLD = "Old value of the object
I_VALUE_NEW = "New value of the object
I_OBJECT_KEY = "Table Key
I_OBJECT_SUBKEY = "Table Key
I_TIMESTAMPL = "Time stamp when this table is trailed
I_USER_MAIN = "The user, who (should) made the change
I_USER_ACT = "The user, who actually made the change if delegation exists
I_CHANGE_TYPE = "Insert / Delete / Update
I_DATA_TYPE = "Abap Data Type
I_TYPE_NAME = "Table Name
EXCEPTIONS
DB_INSERT_FAILED = 1
IMPORTING Parameters details for GRFN_ATF_WRITE
I_TOPIC_ID - Topic of the audit trail
Data type: GRFN_ATF_TOPIC_IDOptional: No
Call by Reference: No ( called with pass by value option)
I_FIELD_NAME - Field Name
Data type: FIELDNAMEOptional: No
Call by Reference: No ( called with pass by value option)
I_VALUE_OLD - Old value of the object
Data type: STRINGOptional: No
Call by Reference: No ( called with pass by value option)
I_VALUE_NEW - New value of the object
Data type: STRINGOptional: No
Call by Reference: No ( called with pass by value option)
I_OBJECT_KEY - Table Key
Data type: TABKEYOptional: No
Call by Reference: No ( called with pass by value option)
I_OBJECT_SUBKEY - Table Key
Data type: TABKEYOptional: No
Call by Reference: No ( called with pass by value option)
I_TIMESTAMPL - Time stamp when this table is trailed
Data type: TIMESTAMPLOptional: No
Call by Reference: No ( called with pass by value option)
I_USER_MAIN - The user, who (should) made the change
Data type: UNAMEOptional: No
Call by Reference: No ( called with pass by value option)
I_USER_ACT - The user, who actually made the change if delegation exists
Data type: UNAMEOptional: No
Call by Reference: No ( called with pass by value option)
I_CHANGE_TYPE - Insert / Delete / Update
Data type: GRFN_ATF_CHANGE_TYPEOptional: No
Call by Reference: No ( called with pass by value option)
I_DATA_TYPE - Abap Data Type
Data type: GRFN_ATF_DATA_TYPEOptional: No
Call by Reference: No ( called with pass by value option)
I_TYPE_NAME - Table Name
Data type: TABNAMEOptional: No
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
DB_INSERT_FAILED - The INSERT statement failed
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for GRFN_ATF_WRITE 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_i_topic_id | TYPE GRFN_ATF_TOPIC_ID, " | |||
| lv_db_insert_failed | TYPE GRFN_ATF_TOPIC_ID, " | |||
| lv_i_field_name | TYPE FIELDNAME, " | |||
| lv_i_value_old | TYPE STRING, " | |||
| lv_i_value_new | TYPE STRING, " | |||
| lv_i_object_key | TYPE TABKEY, " | |||
| lv_i_object_subkey | TYPE TABKEY, " | |||
| lv_i_timestampl | TYPE TIMESTAMPL, " | |||
| lv_i_user_main | TYPE UNAME, " | |||
| lv_i_user_act | TYPE UNAME, " | |||
| lv_i_change_type | TYPE GRFN_ATF_CHANGE_TYPE, " | |||
| lv_i_data_type | TYPE GRFN_ATF_DATA_TYPE, " | |||
| lv_i_type_name | TYPE TABNAME. " |
|   CALL FUNCTION 'GRFN_ATF_WRITE' "Write audit log for object, internal used only, do not call me outside |
| EXPORTING | ||
| I_TOPIC_ID | = lv_i_topic_id | |
| I_FIELD_NAME | = lv_i_field_name | |
| I_VALUE_OLD | = lv_i_value_old | |
| I_VALUE_NEW | = lv_i_value_new | |
| I_OBJECT_KEY | = lv_i_object_key | |
| I_OBJECT_SUBKEY | = lv_i_object_subkey | |
| I_TIMESTAMPL | = lv_i_timestampl | |
| I_USER_MAIN | = lv_i_user_main | |
| I_USER_ACT | = lv_i_user_act | |
| I_CHANGE_TYPE | = lv_i_change_type | |
| I_DATA_TYPE | = lv_i_data_type | |
| I_TYPE_NAME | = lv_i_type_name | |
| EXCEPTIONS | ||
| DB_INSERT_FAILED = 1 | ||
| . " GRFN_ATF_WRITE | ||
ABAP code using 7.40 inline data declarations to call FM GRFN_ATF_WRITE
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.Search for further information about these or an SAP related objects