## 4.2.15.2.2.1  Creating a Change Document Object
When creating a change document object, the following naming-rules apply:
- For customer objects, start the name with a 'Z' or a 'Y' . For more information, see SAP Note 16466.
- If a name space is requested, use an object starting with namespace as object name.
- Keep in mind that the change document object name including the name space has a maximum length of 15 characters. That means that if the name space has 10 characters, only 5 characters are left for the change document object name.
## Process
Use method IF\_CHDO\_OBJECT\_TOOLS\_REL~CREATE\_AND\_GENERATE\_OBJECT to create and generate change document objects.
The name of the object is assigned using the import parameter IV\_OBJECT . Object details and generation information are passed using the internal tables IT\_CD\_OBJECT\_DEF (the object definition), IT\_CDOBJECT\_TEXT (object texts) and IS\_CD\_OBJECT\_GEN (generation information).
Once generated, the class (&lt;name space&gt;CL\_&lt;change document object name&gt;\_CHDO) with methods WRITE and IF\_CHDO\_ENHANCEMENTS~AUTHORITY\_CHECK are created. IV\_CL\_OVERWRITE can be used to specify whether an existing class with the specified name can be overwritten or not. If a class already exists and can't be overwritten, no changes will be made. Changes are saved in the transport request ( IV\_CORRNR ).
Method AUTHORITY\_CHECK of interface 'IF\_CHDO\_ENHANCEMENTS' must be implemented later on in order to enable an authorization check for reading change documents.
The export parameter ET\_ERRORS is used to return all generation messages (messages from message class CD ). Any syntax errors in the generated class are provided using ET\_SYNT\_ERROR (with long text if applicable ( ET\_SYNT\_ERROR\_LONG )).
Import Parameters
| Parameter Name   | Field Name   | Value Help                                                                                                                                                                                                                                                                                                                                     |
|------------------|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| IV_OBJECT        |              | Nameof change document object                                                                                                                                                                                                                                                                                                                  |
| IT_CD_OBJECT_DEF |              | Change document object definition                                                                                                                                                                                                                                                                                                              |
|                  | TABNAME      | Nameof the table as defined in the dic- tionary                                                                                                                                                                                                                                                                                                |
|                  | MULTCASE     | If more than one record for a particu- lar table is to be documented during a single CREATE/UPDATE/DELETE op- eration, the value MULTCASE should be 'ABAP_TRUE' or 'X' (multiple case). If no value is provided a single record can be documented and passed in a work area (single case).                                                     |
|                  | DOCUDEL      | DOCUDEL = SPACE The deletion of a table entry will be documented in one change document item using the table key to identify the table entry deleted. The fieldFNAME will be filled with 'KEY' . DOCUDEL = 'X' Each change document relevant field value of the table entry will be docu- mented individually in its own change document item. |
| Parameter Name   | Field Name   | Value Help                                                                                                                                                                                                                                                                                                                                                                                                                                                |
|------------------|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|                  | DOCUINS      | DOCUINS = SPACE The insert of a table entry will be docu- mented in one change document item using the table key to identify the in- serted table entry. The field FNAMEwill be filled with 'KEY' . DOCUINS = 'X' Each change document relevant field value of the table entry will be docu- mented individually in its own change document item. The change indicator is 'J' instead of 'I' .                                                            |
|                  | REFNAME      | If fields of table TABNAME reference unit or currency field values from another table, the name of that table must be passed here to document its values as well. Only one reference table can be used for table TABNAME. In single case, the referenced entry from table REFNAME is passed as two additional work areas (old, new). In mul- tiple case, the import tables (old, new) are enhanced to include the referenced structure of table REFNAME . |
|                  | DOCUD_IF     | If you want to document the value of a field even though it is initial when data is deleted, mark this field. If it is not marked, log entries will only be written if the field values are not initial when they are deleted. Be aware that a lot of additional change documents may be written, if you choose this option. Only mark this flag if it is required.                                                                                       |
| Parameter Name    | Field Name   | Value Help                                                                                                                                                                                                                                                                                                                                                             |
|-------------------|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|                   | DOCUI_IF     | If you want to document the value of a field even though it is initial when data is inserted, mark this field. If it is not marked, log entries will only be written if the field values are not initial when they are inserted. Be aware that a lot of additional change documents may be written, if you choose this option. Only mark this flag, if it is required. |
| IT_CD_OBJECT_TEXT |              | Object texts for change document ob- ject                                                                                                                                                                                                                                                                                                                              |
|                   | LANG_KEY     | Language key of the text                                                                                                                                                                                                                                                                                                                                               |
|                   | OBJECT_TEXT  | Descriptive short text for the change document object                                                                                                                                                                                                                                                                                                                  |
| IS_CD_OBJECT_GEN  |              | Change document object generation in- formation                                                                                                                                                                                                                                                                                                                        |
|                   | AUTHOR       | User who performs the generation                                                                                                                                                                                                                                                                                                                                       |
|                   | UPDNAME      | User who performs the change                                                                                                                                                                                                                                                                                                                                           |
|                   | CHANGE_DATE  | Date of change                                                                                                                                                                                                                                                                                                                                                         |
|                   | CHANGE_TIME  | Time of change                                                                                                                                                                                                                                                                                                                                                         |
|                   | TEXTCASE     | Special Text Handling flag Select this field to log long text changes. The old and new status of long texts is not logged. Only the fact that they have been changed is noted.                                                                                                                                                                                         |
|                   | DEVCLASS     | Change document object package                                                                                                                                                                                                                                                                                                                                         |
| IV_CL_OVERWRITE   |              | Whether generated class should over- write an already existing class. Value 'X' means an existing class will be overwrit- ten.                                                                                                                                                                                                                                         |
| IV_CORRNR         |              | Transport request where changes should be logged                                                                                                                                                                                                                                                                                                                       |
## Export Parameters
| Parameter Name     | Field Name   | Value Help                                                                                 |
|--------------------|--------------|--------------------------------------------------------------------------------------------|
| ET_ERRORS          | ET_ERRORS    | ET_ERRORS                                                                                  |
|                    | kind         | Message type (emtpy means informa- tion message, ,E-, means error)                         |
|                    | msgid        | Message class (CD)                                                                         |
|                    | msgnr        | Message ID                                                                                 |
|                    | v1           | Variable to message                                                                        |
|                    | v2           | Variable to message                                                                        |
|                    | v3           | Variable to message                                                                        |
|                    | v4           | Variable to message                                                                        |
|                    | text         | Short text of the message                                                                  |
| ET_SYNT_ERRORS     |              | Syntax errors raised during generation of class. Check syntax of generated class directly. |
| ET_SYNT_ERROR_LONG |              | Syntax errors raised during generation of class. Check syntax of generated class directly. |
##  Sample Code
```
CLASS zcl_chdo_test DEFINITION PUBLIC FINAL CREATE PUBLIC . PUBLIC SECTION. INTERFACES if_oo_adt_classrun. PROTECTED SECTION. PRIVATE SECTION. ENDCLASS. CLASS zcl_chdo_test IMPLEMENTATION. METHOD if_oo_adt_classrun~main. DATA: ls_error       TYPE abap_bool, rt_errors      TYPE if_chdo_object_tools_rel=>ty_tr_error_tab, lt_errors_err  TYPE LINE OF if_chdo_object_tools_rel=>ty_tr_error_tab, p_it_tcdob     TYPE if_chdo_object_tools_rel=>ty_tcdobdef_tab, p_it_tcdobt    TYPE if_chdo_object_tools_rel=>ty_tcdobtext_tab, p_it_tcdrp     TYPE if_chdo_object_tools_rel=>ty_tcdgen, lt_tcdobt      TYPE if_chdo_object_tools_rel=>ty_tcdobt_tabtyp, ls_tcdob       TYPE LINE OF if_chdo_object_tools_rel=>ty_tcdobdef_tab, ls_tcdobt      TYPE LINE OF if_chdo_object_tools_rel=>ty_tcdobtext_tab. data: lr_err                TYPE REF TO cx_chdo_generation_error. ls_tcdob-tabname = 'ZCHDO'. ls_tcdob-multcase = ' '. ls_tcdob-docudel = ' '. ls_tcdob-docuins = ' '. ls_tcdob-docud_if = ' '.
```
```
APPEND ls_tcdob TO p_it_tcdob. ls_tcdobt-lang_key = 'D'. ls_tcdobt-object_text = 'Single Case'. APPEND ls_tcdobt TO p_it_tcdobt. p_it_tcdrp-author = 'X11'. p_it_tcdrp-textcase = 'X'. p_it_tcdrp-devclass = '<development class>'. CLEAR: rt_errors, lr_err. TRY. cl_chdo_object_tools_rel=>if_chdo_object_tools_rel~create_and_generate_object( EXPORTING iv_object          = 'ZCHDO_TEST' " change document object name it_cd_object_def   = p_it_tcdob   " change document object definition it_cd_object_text  = p_it_tcdobt  " change document object text is_cd_object_gen   = p_it_tcdrp   " change document object generation info iv_cl_overwrite    = 'X'          " class overwrite flag iv_corrnr          = '<transport_request>' " transport request number IMPORTING et_errors          = rt_errors    " generation message table *          et_synt_errors     = *          et_synt_error_long = ). CATCH cx_chdo_generation_error into lr_err. out->write( |Exception occurred: { lr_err->get_text( ) }| ). ls_error = 'X'. ENDTRY. IF ls_error IS INITIAL. READ TABLE rt_errors WITH KEY kind = 'E-' INTO lt_errors_err. IF sy-subrc IS INITIAL. out->write( |Exception occurred: { lt_errors_err-text } | ). ELSE. out->write( |Change document object created and generated | ). ENDIF. ENDIF. ENDMETHOD. ENDCLASS.
```