Code: Alles auswählen.
*" IMPORTING
*" VALUE(I_OBJECTCLASS) TYPE CDOBJECTCL DEFAULT 'MATERIAL'
*" VALUE(I_OBJECTID) TYPE CDOBJECTV
*" VALUE(I_DATUM) TYPE SYDATUM
*" VALUE(I_UZEIT) TYPE SYUZEIT
*" VALUE(I_TABNAME) TYPE CDTABNAME
*" VALUE(I_FLDNAME) TYPE FIELDNAME
*" VALUE(I_TABKEY) TYPE CDTABKEY OPTIONAL
*" EXPORTING
*" VALUE(E_VALUE) TYPE CDFLDVALN
*** Init
CLEAR: gt_cdsrt[], e_value, gv_aenderung_vorhanden.
*** Lesen der Änderungsbelegköpfe
CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
EXPORTING
objectclass = i_objectclass
objectid = i_objectid
username = space
TABLES
i_cdhdr = gt_cdhdr
EXCEPTIONS
no_position_found = 1
wrong_access_to_archive = 2
time_zone_conversion_error = 3
OTHERS = 4.
IF sy-subrc = 0.
LOOP AT gt_cdhdr.
*** Lesen der Änderungsbelegpositionen
PERFORM aenderung_lesen USING i_tabname i_fldname i_tabkey.
ENDLOOP.
SORT gt_cdsrt BY tabname fname udate ASCENDING utime ASCENDING.
LOOP AT gt_cdsrt WHERE udate < i_datum OR
( udate = i_datum AND utime <= i_uzeit ).
e_value = gt_cdsrt-f_new.
gv_aenderung_vorhanden = 'X'.
ENDLOOP.
ENDIF.
IF gv_aenderung_vorhanden = space.
*** Exception auslösen, damit der Aufrufer erkennen kann, dass der
*** aktuelle Wert gültig ist.
RAISE keine_aenderung.
ENDIF.
ENDFUNCTION.
*---------------------------------------------------------------------*
* FORM aenderungen_lesen *
*---------------------------------------------------------------------*
FORM aenderung_lesen USING f_tab TYPE cdtabname
f_fld TYPE fieldname
f_tabkey TYPE cdtabkey.
CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
EXPORTING
changenumber = gt_cdhdr-changenr
tablekey = f_tabkey
tablename = f_tab
IMPORTING
header = gs_header
TABLES
editpos = gt_cdpos
EXCEPTIONS
no_position_found = 1
wrong_access_to_archive = 2
OTHERS = 3.
IF sy-subrc = 0.
LOOP AT gt_cdpos WHERE fname = f_fld.
MOVE-CORRESPONDING gt_cdhdr TO gt_cdsrt.
MOVE-CORRESPONDING gt_cdpos TO gt_cdsrt.
APPEND gt_cdsrt.
ENDLOOP.
ENDIF.
ENDFORM.