08-13-2013 4:58 PM
Hello
I have a Z table, say, my_table with 4 Z fields in it, well.
My functional guy / business analyst said that the business want to track the changes of this table, hence he has asked me to get this make associate to XXXX (whichi is a Standard SAP Change doc. object, tx. code is SCDO) SCDO, pls. let me know how can i achieve this requirement.
XXXX, say an example of VDARL_CBP, i went to tx oc SCDO and choosen this VDARL_CBP and then clicked the General Info. button on menu, there am seeing some DDIC structures. Like the same way
I guess, its nothing to do with Checking the check box of 'Change Document' under 'Further Characterstics' tab 'in Data element level' of all 4 Z fields
Thank you
08-14-2013 4:57 AM
Hi, Have you consider FUNCTION "CHANGEDOCUMENT_SINGLE_CASE" ?
I am using it to track changes in Z tables .
Can you add code where you update your Z file ?
Make sure your data elements "Indicator for writing change documents" is set.
Regards.
Code:
*----------------------------------------------------------------------*
FORM do_add_change_document
USING
objectclas TYPE cdhdr-objectclas
tabname TYPE cdpos-tabname
change_ind TYPE cdhdr-change_ind
objectid TYPE cdhdr-objectid
image_new
image_old .
DATA: st_cdhdr TYPE cdhdr .
DATA: st_cdpos TYPE cdpos .
st_cdhdr-objectclas = objectclas .
st_cdpos-tabname = tabname .
st_cdhdr-change_ind = change_ind .
st_cdhdr-objectid = objectid .
CALL FUNCTION 'CHANGEDOCUMENT_OPEN'
EXPORTING
objectclass = st_cdhdr-objectclas
objectid = st_cdhdr-objectid
planned_change_number = ' '
planned_or_real_changes = ' '
EXCEPTIONS
sequence_invalid = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'CHANGEDOCUMENT_SINGLE_CASE'
EXPORTING
change_indicator = st_cdhdr-change_ind
docu_delete = 'X'
tablename = st_cdpos-tabname
workarea_new = image_new
workarea_old = image_old
EXCEPTIONS
nametab_error = 1
open_missing = 2
position_insert_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
st_cdhdr-username = sy-uname .
st_cdhdr-udate = sy-datum .
st_cdhdr-utime = sy-uzeit .
st_cdhdr-tcode = sy-tcode .
CALL FUNCTION 'CHANGEDOCUMENT_CLOSE'
EXPORTING
objectclass = st_cdhdr-objectclas
objectid = st_cdhdr-objectid
tcode = st_cdhdr-tcode
username = st_cdhdr-username
date_of_change = st_cdhdr-udate
time_of_change = st_cdhdr-utime
object_change_indicator = st_cdhdr-change_ind
IMPORTING
changenumber = st_cdhdr-changenr
EXCEPTIONS
header_insert_failed = 1
no_position_inserted = 2
object_invalid = 3
open_missing = 4
position_insert_failed = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM . "do_add_change_document
*----------------------------------------------------------------------*
FORM do_changedocu_key
USING
record TYPE data
tabname TYPE tabname
CHANGING
objectid TYPE cdobjectv .
* For the object ID.
DATA: ev_tabkey TYPE cdpos_uid-tabkey .
CALL FUNCTION 'CHANGEDOCU_KEY_ANY2CHAR'
EXPORTING
iv_struct_in = record
iv_tabname = tabname
IMPORTING
ev_tabkey = ev_tabkey
EXCEPTIONS
tabname_is_empty = 1
nametab_error = 2
OTHERS = 3.
IF sy-subrc NE 0.
ENDIF.
objectid = ev_tabkey .
ENDFORM . "do_changedocu_key
*----------------------------------------------------------------------*
FORM do_dsp_change_document
USING
objectclas TYPE cdhdr-objectclas
tabname TYPE cdpos-tabname
objectid TYPE cdhdr-objectid .
* Display .
DATA: editpos TYPE TABLE OF cdred .
CALL FUNCTION 'CHANGEDOCUMENT_READ'
EXPORTING
objectclass = objectclas
tablename = tabname
objectid = objectid
TABLES
editpos = editpos
EXCEPTIONS
no_position_found = 1
wrong_access_to_archive = 2
time_zone_conversion_error = 3
OTHERS = 4.
CHECK sy-subrc EQ 0.
CALL FUNCTION 'CHANGEDOCUMENT_DISPLAY'
EXPORTING
i_applicationid = sy-repid
flg_autocondense = abap_false
i_screen_start_line = 10
i_screen_start_column = 10
i_screen_end_line = 20
i_screen_end_column = 150
TABLES
i_cdred = editpos.
ENDFORM . "do_dsp_change_document
08-13-2013 6:16 PM
I dont understand question fully but u can try to find any user exit after save the tcode scdo and take the return value through user exit and save this value in ztable.
08-13-2013 7:59 PM
Yes, the same way as what you see in VDARL_CBP in the tcode SCDO. Refer the below blog on how to set a change log for the Z Table and how to use the same.
http://wiki.sdn.sap.com/wiki/display/ABAP/Maintaining+Change+Log+for+Database+Tables
~Srini
08-14-2013 1:52 AM
Thank you, but this wiki is talking completely Z table & Z Change Doc Object/SCDO, hence its not relevent for me.
Pls. let me know Can i add a Z table/structure to the Standard SAP's Change Doc Object (you can see it SCDO) with a REPAIR transport, i mean, is it safe? any alternate? any suggestions?
08-14-2013 4:04 AM
08-14-2013 1:47 PM
An alternative would be to create a Z change document object, and include standard as well as Z table in it.
08-14-2013 1:51 PM
You may have to create a Z change object and include the standard objects on it.
~Srini
08-14-2013 4:57 AM
Hi, Have you consider FUNCTION "CHANGEDOCUMENT_SINGLE_CASE" ?
I am using it to track changes in Z tables .
Can you add code where you update your Z file ?
Make sure your data elements "Indicator for writing change documents" is set.
Regards.
Code:
*----------------------------------------------------------------------*
FORM do_add_change_document
USING
objectclas TYPE cdhdr-objectclas
tabname TYPE cdpos-tabname
change_ind TYPE cdhdr-change_ind
objectid TYPE cdhdr-objectid
image_new
image_old .
DATA: st_cdhdr TYPE cdhdr .
DATA: st_cdpos TYPE cdpos .
st_cdhdr-objectclas = objectclas .
st_cdpos-tabname = tabname .
st_cdhdr-change_ind = change_ind .
st_cdhdr-objectid = objectid .
CALL FUNCTION 'CHANGEDOCUMENT_OPEN'
EXPORTING
objectclass = st_cdhdr-objectclas
objectid = st_cdhdr-objectid
planned_change_number = ' '
planned_or_real_changes = ' '
EXCEPTIONS
sequence_invalid = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'CHANGEDOCUMENT_SINGLE_CASE'
EXPORTING
change_indicator = st_cdhdr-change_ind
docu_delete = 'X'
tablename = st_cdpos-tabname
workarea_new = image_new
workarea_old = image_old
EXCEPTIONS
nametab_error = 1
open_missing = 2
position_insert_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
st_cdhdr-username = sy-uname .
st_cdhdr-udate = sy-datum .
st_cdhdr-utime = sy-uzeit .
st_cdhdr-tcode = sy-tcode .
CALL FUNCTION 'CHANGEDOCUMENT_CLOSE'
EXPORTING
objectclass = st_cdhdr-objectclas
objectid = st_cdhdr-objectid
tcode = st_cdhdr-tcode
username = st_cdhdr-username
date_of_change = st_cdhdr-udate
time_of_change = st_cdhdr-utime
object_change_indicator = st_cdhdr-change_ind
IMPORTING
changenumber = st_cdhdr-changenr
EXCEPTIONS
header_insert_failed = 1
no_position_inserted = 2
object_invalid = 3
open_missing = 4
position_insert_failed = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM . "do_add_change_document
*----------------------------------------------------------------------*
FORM do_changedocu_key
USING
record TYPE data
tabname TYPE tabname
CHANGING
objectid TYPE cdobjectv .
* For the object ID.
DATA: ev_tabkey TYPE cdpos_uid-tabkey .
CALL FUNCTION 'CHANGEDOCU_KEY_ANY2CHAR'
EXPORTING
iv_struct_in = record
iv_tabname = tabname
IMPORTING
ev_tabkey = ev_tabkey
EXCEPTIONS
tabname_is_empty = 1
nametab_error = 2
OTHERS = 3.
IF sy-subrc NE 0.
ENDIF.
objectid = ev_tabkey .
ENDFORM . "do_changedocu_key
*----------------------------------------------------------------------*
FORM do_dsp_change_document
USING
objectclas TYPE cdhdr-objectclas
tabname TYPE cdpos-tabname
objectid TYPE cdhdr-objectid .
* Display .
DATA: editpos TYPE TABLE OF cdred .
CALL FUNCTION 'CHANGEDOCUMENT_READ'
EXPORTING
objectclass = objectclas
tablename = tabname
objectid = objectid
TABLES
editpos = editpos
EXCEPTIONS
no_position_found = 1
wrong_access_to_archive = 2
time_zone_conversion_error = 3
OTHERS = 4.
CHECK sy-subrc EQ 0.
CALL FUNCTION 'CHANGEDOCUMENT_DISPLAY'
EXPORTING
i_applicationid = sy-repid
flg_autocondense = abap_false
i_screen_start_line = 10
i_screen_start_column = 10
i_screen_end_line = 20
i_screen_end_column = 150
TABLES
i_cdred = editpos.
ENDFORM . "do_dsp_change_document
08-14-2013 6:39 AM
Thank you, very good suggestion.
By chance do you hv any idea about my original question, as below
"Can i add my Z table to a Standard SAP Change Document Object in SCDO transaction?"
Regards
08-14-2013 7:19 AM
08-14-2013 7:22 AM
08-14-2013 1:31 PM
Any help pls.?
"Can i add my Z table to a Standard SAP Change Document Object in SCDO transaction?"
Regards
08-14-2013 2:13 PM
Its not a good idea to change the standard object as it involves regenerating the FM and you need to change the code wherever the FM is called. So the better option would be to create your own custom object and make the changes.
~Srini
08-14-2013 3:03 PM
Ah, so just adding Z struture is not enough (job done)? do i need to,
1) Regenerate the FMs (by clicking the Generate Update Pgm.)? and
2) change the code, whereever they (FMs) are calling? if so, they are calling in again standard SAP classes, so, do i need to change the standard SAP class as well? Hmmm
Thank you
08-15-2013 3:59 AM
08-16-2013 3:47 AM