Skip to content

Latest commit

 

History

History
708 lines (476 loc) · 11 KB

updating-a-change-document-object-188e1b7.md

File metadata and controls

708 lines (476 loc) · 11 KB

Updating a Change Document Object

Use method IF_CHDO_OBJECT_TOOLS_REL~UPDATE_OBJECT to modify and regenerate change document objects.

The name of the object is assigned using the import parameter IV_OBJECT. The object details and generation information are passed using the internal tablesIT_CD_OBJECT_DEF (the object definition), IT_CD_OBJECT_TEXT (the object texts) and IS_CD_OBJECT_GEN (the generation information).

If the internal tables are not filled, the object definition is read directly from the database tables TCDOB and TADIR and the generation information is read directly from database table TCDRP. If only parameter IS_CD_OBJECT_GEN is passed, the change document object will be newly generated without changing the change document object definition. Use this method when the structure of a table, that belongs to the change document object, was changed.

Once generated, a class (<name space>CL_<change document object name>_CHDO) with methods WRITE and IF_CHDO_ENHANCEMENTS~AUTHORITY_CHECK are created. You can use IV_CL_OVERWRITE to specify whether an existing class can be overwritten with the specified name or not. If a class already exists and can’t be overwritten, no changes will be made. Changes made to the class 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

 

Name of change document object

IT_CD_OBJECT_DEF

 

Change document object definition

 

TABNAME

Name of the table as defined in the dictionary

 

MULTCASE

If more than one record for a particular table is to be documented during a single CREATE/UPDATE/DELETE operation, the value MULTICASE 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 field FNAME will be filled with ‘KEY’.

DOCUDEL = ‘X’

Each change document relevant field value of the table entry will be documented individually in its own change document item.

The change indicator is ‘E’ instead of ‘D’.

 

DOCUINS

DOCUINS = SPACE

The insert of a table entry will be documented in one change document item using the table key to identify the inserted table entry. The field FNAME will be filled with ‘KEY’.

DOCUINS = ‘X’

Each change document relevant field value of the table entry will be documented 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 has to 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 multiple 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.

 

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 object

 

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 information

 

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 overwrite an already existing class. Value ‘X’ means an existing class will be overwritten.

IV_CORRNR

 

Transport request where changes should be logged

Export Parameters

Parameter Name

Field Name

Value Help

ET_ERRORS

 

 

 

kind

Message type (emtpy means information 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_update_object DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.
   INTERFACES if_oo_adt_classrun.
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.



CLASS zcl_chdo_update_object IMPLEMENTATION.
  METHOD if_oo_adt_classrun~main.
  DATA:
        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,
        lt_tcdob              TYPE iF_CHDO_OBJECT_TOOLS_REL=>TY_TCDOBDEF_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_TCDOBTEXT_TAB,
        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 = 'X'.
  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: Update'.

  APPEND ls_tcdobt TO p_it_tcdobt.

  p_it_tcdrp-author = sy-uname.
  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~update_object(
      EXPORTING
        iv_object          = 'ZCHDO_TEST'
        it_cd_object_def   = p_it_tcdob
        it_cd_object_text  = p_it_tcdobt
        is_cd_object_gen   = p_it_tcdrp
        iv_cl_overwrite    = 'X'
        iv_corrnr          = '<transport request>'
      IMPORTING
        et_errors          = rt_errors
    ).
    CATCH cx_chdo_generation_error INTO lr_err.
  ENDTRY.
      IF lr_err 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 updated | ).
        ENDIF.
      ENDIF.
  ENDMETHOD.
ENDCLASS.