Skip to end of metadata
Go to start of metadata

Purpose

When you are using the content version function in DMS a new version of an original could be created if you check it in again after editing. This versions will be visible in the 'Originals' tab. In case there are content versions available you will see a small arrow on the left side of the original. With a click on this arrow sign the existing versions will be displayed. Normally only one version could be set as active and is marked with a small green square icon and all former versions are marked yellow which shows that they are inactive.

But sometime it may happens that due to unknown reasons two content versions are marked as active at the same time. This behavior means to be an inconsistency and cause serious problems like not able to check in the original file again or the "reset check-out" functions do not work properly. Therefore this inconsistency needs to be corrected and only one version should be made active again.

Solution

This correction can be done in two ways. On the one hand you can change this manually with the help of some function modules. This method can be used if you have just one or two of such cases in your system and you know them. On the other hand there is a special report which helps to identify such inconsistencies and correct them.

1. Manual correction

Please proceed as follows in order to deactivate the multiple content versions manually:    
                                                                          
1. from DMS_KPRO_READ, please copy those PHIO-Id-s which you would like to deactivate.

2. TA se37: FM SDOK_PHIO_PROPERTIES_GET -> Single Test, for the object-Id please enter the PHIO-Id, for the class DMS_PCD1 -> Execute. Now you get the property DMS_ACTIVE_VERSION with value "X",  which means that this version is the active one.

3. se37: FM SDOK_PHIO_PROPERTIES_SET -> Single Test: please enter again the PHIO-Id and the class and for the table Properties. Then  leave DMS_ACTIVE_VERSION blank and execute the function module.

4. if you now run DMS_KPRO_READ, only the relevant original version should be active.

2. Report correction

For finding and correcting such inconsistencies faster the following report ZZ_DMS_KPRO_CHECK_ACTIVE could be created and used in your system.

*ZZ_DMS_KPRO_CHECK_ACTIVE :
*
*1. The report lists DIRs with their originals which have more than
*one active versions in the KPRO.
*2. The report allows the user to select data between two
*dates(excluding them).
*3. Selecting only the 'from' date returns data for only that
*particular date.
*4. Selecting only the 'to' date returns data till the particular
*date.
*5. Selecting none, retrieves all data.
*6. The report allows the user to select from the list the versions
*to be deleted or deactivated.
*7. Selecting 'delete' option deletes the content version(s) from r/3
* DMS.
*8. Selecting 'deactivate' option deactivates the chosen version(s).
*9. The report refreshes itself automatically once either of the
*button is pressed.
*10. The 'refresh' button refreshes the list.
*11. The report doesn't make any judgement while deleting or
*deactivating versions; this is totally based on user's inputs.
*12. Deletion of records are possible only if they are consistent.
*13. Its advisable to use DMS_Kpro_Check1 report for deletion of
*versions from the content *server. This report doesn't delete versions
*from the content server so that data can be recovered *back.
*14. The green tick mark in the output list shows that the
*content version exists in the *content server.
*15. The match stick indicates that the version is active.
*16 The arrow displays the DIR in CV03n mode.

REPORT ZZ_DMS_KPRO_CHECK_ACTIVE .
include: <icon>.

DATA: lt_doc2loio TYPE STANDARD TABLE OF dms_doc2loio,
lt_phios TYPE TABLE OF dms_ph_cd1,
ls_doc2loio TYPE dms_doc2loio ,
ls_phio_id LIKE sdokobject,
lt_phios_rec TYPE dms_rec_phio OCCURS 0 WITH HEADER LINE,
lt_phios_rec2 TYPE dms_rec_phio OCCURS 0 WITH HEADER LINE,
lt_prop LIKE sdokpropty OCCURS 0 WITH HEADER LINE,
GS_PHIO LIKE sdokobject,
gs_doc_key TYPE dms_doc_key,
ls_files LIKE dms_phio2file,
lt_loio TYPE dms_doc2loio OCCURS 0 WITH HEADER LINE,
lt_comp LIKE sdokcomupd OCCURS 0 WITH HEADER LINE,
lt_bad_obj TYPE TABLE OF sdokerrmsg.


DATA: lf_diff(1) TYPE c,
GF_MARK(1) TYPE C,
lf_fid(32) TYPE c,
lf_content(1) type c.
DATA: lf_i TYPE i,
lf_idx TYPE i,
lf_count TYPE i,
lf_icount TYPE i,
lf_lines TYPE I.

data: ls_line like line of lt_phios_rec.


FIELD-SYMBOLS: <fs1> TYPE dms_ph_cd1,
<fs2> TYPE dms_doc2loio,
<fs3> TYPE dms_REC_PHIO.
**----------------------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-100.
select-options: Dt_From for sy-datum.
SELECTION-SCREEN END OF BLOCK block1.
*-----------------------------------------------------

START-OF-SELECTION.
SET PF-STATUS 'REF-STATUS'.

SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_phios
PACKAGE SIZE 500
FROM dms_ph_cd1
where crea_time in dt_From.

lf_i = lf_i + 1.
PERFORM write_db_read_progress
USING 'DMS_PCD1' text-004 lf_i.

SELECT * FROM dms_doc2loio
INTO CORRESPONDING FIELDS OF TABLE lt_doc2loio
FOR ALL ENTRIES IN lt_phios
WHERE lo_objid = lt_phios-loio_id AND
lo_type = '01' AND
lo_is_ref = ''.

APPEND LINES OF LT_DOC2LOIO TO lt_loio.

LOOP AT lt_phios ASSIGNING <FS1>.
ls_phio_id-class = 'DMS_PCD1'.
ls_phio_id-objid = <FS1>-PHIO_ID.

CALL FUNCTION 'SDOK_PHIO_PROPERTIES_GET'
EXPORTING: object_id = ls_phio_id
TABLES: properties = lt_prop
EXCEPTIONS: not_existing = 1
not_authorized = 2
OTHERS = 3.
IF sy-subrc <> 0.
CONTINUE.
ENDIF.

LOOP AT lt_prop.
CASE lt_prop-name.
WHEN 'DMS_FILE_ID'.
lt_phios_rec-file_id = lt_prop-value.

WHEN 'DMS_ACTIVE_VERSION'.
lt_phios_rec-active_version = lt_prop-value.

WHEN 'CHECKED_OUT'.
lt_phios_rec-checked_out = lt_prop-value.

WHEN 'CHECKOUT_USER'.
lt_phios_rec-checkout_user = lt_prop-value.

WHEN 'CREATED_AT'.
lt_phios_rec-created_at = lt_prop-value.

ENDCASE.
ENDLOOP.

SELECT SINGLE * FROM dms_phio2file INTO ls_files
WHERE file_id = lt_phios_rec-file_id.
IF sy-subrc <> 0.
CLEAR ls_files.
ENDIF.

lt_phios_rec-LO_OBJID = <FS1>-LOIO_ID.
lt_phios_rec-ph_objid = ls_phio_id-objid.
lt_phios_rec-ph_CLASS = ls_phio_id-class.
lt_phios_rec-FILENAME = ls_files-FILENAME.
lt_phios_rec-protected = ls_files-protected.

IF lt_phios_rec-active_version = 'X'.
APPEND lt_phios_rec.
ENDIF.
ENDLOOP.

REFRESH lt_phios[].
REFRESH lt_prop[].

ENDSELECT.

CLEAR LF_LINES.
DESCRIBE TABLE LT_PHIOS_REC LINES lf_lines.
if lf_lines > 0.
SORT lt_phios_rec BY file_id created_at DESCENDING .
Perform check_active_phios.
endif.

PERFORM WRITE_LIST.

**--------------------------------------------------------------
AT LINE-SELECTION.
IF NOT gs_doc_key IS INITIAL.
PERFORM doc_info.
EXIT.
ENDIF.

**--------------------------------------------------------------

FORM check_active_phios.

clear ls_line.
clear lf_count.

LOOP AT lt_phios_rec.
IF lt_phios_rec-active_version = 'X'.
IF LS_LINE IS INITIAL.
LS_LINE = LT_PHIOS_REC.
LF_COUNT = 1.
ELSE.
IF LS_LINE-FILE_ID <> LT_PHIOS_REC-FILE_ID.
IF LF_COUNT < 2.
LF_ICOUNT = SY-TABIX - 1.
DELETE lt_phios_rec INDEX LF_ICOUNT.
CLEAR LS_LINE.
LS_LINE = LT_PHIOS_REC.
LF_COUNT = 1.
ELSE.
CLEAR LS_LINE.
LS_LINE = LT_PHIOS_REC.
LF_COUNT = 1.
ENDIF.

ELSE.
LF_COUNT = LF_COUNT + 1.
ENDIF.
ENDIF.
ELSE.
DELETE lt_phios_rec INDEX SY-TABIX.
ENDIF.
ENDLOOP.

IF LF_COUNT < 2.
DESCRIBE TABLE LT_PHIOS_REC LINES lf_lines.
DELETE lt_phios_rec INDEX lf_lines.
ENDIF.

ENDFORM.
*********************************************
FORM update_phio_properties
using value(lt_phio_obj) like sdokobject.


REFRESH LT_PROP.

CALL FUNCTION 'SDOK_PHIO_PROPERTIES_GET'
EXPORTING: object_id = lt_phio_obj
TABLES: properties = lt_prop
EXCEPTIONS: not_existing = 1
not_authorized = 2
OTHERS = 3.
IF sy-subrc <> 0.
ENDIF.

loop at lt_prop.
CASE lt_prop-name.
WHEN 'DMS_FILE_ID'.
update dms_phio2file
set PROTECTED = 'X'
where FILE_ID = lt_prop-value.
EXIT.
ENDCASE.
ENDLOOP.

LOOP AT lt_phios_rec.
if lt_phios_rec-FILE_ID = lt_prop-value.
UPDATE DMS_PH_CHKO_CD1
SET TARGET_DIR = ' '
WHERE PHIO_ID = lt_phios_rec-PH_OBJID AND
PH_CLASS = 'DMS_PCD1'.
ENDIF.
ENDLOOP.


ENDFORM.
**-------------------------------------------------------------
AT USER-COMMAND.

CASE sy-ucomm.
WHEN 'DELETE'.
CLEAR LF_LINES.
DESCRIBE TABLE LT_PHIOS_REC LINES lf_lines.
IF lf_lines > 0.
PERFORM delete_marked_lines.
ENDIF.
WHEN 'DEACTIVATE'.
CLEAR LF_LINES.
DESCRIBE TABLE LT_PHIOS_REC LINES lf_lines.
IF lf_lines > 0.
PERFORM deactivate_marked_lines.
ENDIF.
WHEN 'REFRESH'.
CLEAR LF_LINES.
DESCRIBE TABLE LT_PHIOS_REC LINES lf_lines.
IF lf_lines > 0.
PERFORM check_active_phios.
PERFORM write_list.
ENDIF.
WHEN 'PICK'.

ENDCASE.
*--------------------------------------------------------------
FORM delete_marked_lines.

DATA: lt_loio TYPE TABLE OF sdokobject,
lt_phio TYPE TABLE OF sdokobject.

DATA: ls_object TYPE sdokobject.
DATA: lf_mark(1) TYPE c.
DATA: lf_answer(1) TYPE c.

CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING: defaultoption = 'Y'
textline1 = text-012
textline2 = ''
titel = ''
IMPORTING: answer = lf_answer.
CHECK lf_answer = 'J'.

DO.
CLEAR: lf_mark,
ls_object.
READ LINE sy-index FIELD VALUE gf_mark INTO lf_mark.
IF sy-subrc <> 0.
EXIT.
ENDIF.

IF lf_mark = 'X'.

CALL FUNCTION 'CV120_KPRO_PHIO_DELETE'
EXPORTING: PF_PHIO = GS_PHIO-OBJID.
IF SY-SUBRC <> 0.
CONTINUE.
ENDIF.

DELETE lt_phios_rec
WHERE ph_objid = GS_PHIO-OBJID.
if sy-subrc <> 0.
continue.
endif.

ENDIF.
ENDDO.

SUBTRACT 1 FROM sy-lsind.
PERFORM check_active_phios.
PERFORM write_list.
SCROLL LIST INDEX sy-lsind TO FIRST PAGE LINE 1.
SET CURSOR 1 1.

ENDFORM.

**************************************************************

FORM deactivate_marked_lines.

DATA: lt_loio TYPE TABLE OF sdokobject,
lt_phio TYPE TABLE OF sdokobject.

DATA: ls_object TYPE sdokobject.
DATA: lf_mark(1) TYPE c.
DATA: lf_answer(1) TYPE c.
DATA: lf_error(1) TYPE c.


CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING: defaultoption = 'Y'
textline1 = text-012
textline2 = ''
titel = ''
IMPORTING: answer = lf_answer.
CHECK lf_answer = 'J'.

DO.
CLEAR: lf_mark,
ls_object.
READ LINE sy-index FIELD VALUE gf_mark INTO lf_mark.
IF sy-subrc <> 0.
EXIT.
ENDIF.

IF lf_mark = 'X'.

PERFORM kpro_update_old_version in program SAPLCV120
USING gs_phio
pf_replace
CHANGING lf_error.
IF sy-subrc <> 0.
CONTINUE.
ENDIF.

Read TABLE LT_PHIOS_REC WITH KEY PH_OBJID = GS_PHIO-OBJID
ASSIGNING <FS3> .
<FS3>-active_version = ' '.

PERFORM update_phio_properties using GS_PHIO.

ENDIF.
ENDDO.
SUBTRACT 1 FROM sy-lsind.
PERFORM check_active_phios.
PERFORM write_list.
SCROLL LIST INDEX sy-lsind TO FIRST PAGE LINE 1.
SET CURSOR 1 1.

ENDFORM.
**----------------------------------------------------------

FORM write_db_read_progress USING pf_class
pf_text
pf_i.
DATA: lf_txt(150) TYPE c,
lf_x TYPE i.

lf_x = pf_i * 500.
lf_txt = lf_x.
CONDENSE lf_txt NO-GAPS.

CONCATENATE pf_text '(' lf_txt ' Records) ...'
INTO lf_txt.

PERFORM sys_write_progress
USING lf_txt 0.
ENDFORM.

*******************************************************
FORM sys_write_progress USING pf_text
pf_percentage.

IF sy-batch IS INITIAL.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING: percentage = pf_percentage
text = pf_text.
ELSE.
WRITE: / icon_green_light AS ICON, pf_text.
ENDIF.
ENDFORM.
******************************************************
FORM WRITE_LIST.

FORMAT RESET.
CLEAR LF_LINES.
DESCRIBE TABLE LT_PHIOS_REC LINES lf_lines.

WRITE: /10 LF_LINES, 'RECORDS FOUND FROM ',Dt_From-LOW, ' TO ',
Dt_From-HIGH .

SORT lt_loio BY LO_OBJID.
LOOP AT LT_PHIOS_REC.

READ TABLE lt_loio WITH KEY LO_objid = LT_PHIOS_REC-LO_OBJID
BINARY SEARCH ASSIGNING <FS2>.
IF SY-SUBRC <> 0.
continue.
ENDIF.

ls_phio_id-class = LT_PHIOS_REC-PH_class.
ls_phio_id-objid = LT_PHIOS_REC-PH_OBJID.

CALL FUNCTION 'CV120_KPRO_CONTENT_CHECK'
EXPORTING: ps_phio_id = ls_phio_id
IMPORTING: pfx_content = lf_content.
IF sy-subrc <> 0.
CONTINUE.
ENDIF.

FORMAT COLOR COL_NORMAL INTENSIFIED ON.

WRITE: /1 'DIR :',<FS2>-DOKAR,'/',
<FS2>-DOKNR,'/',
<FS2>-DOKVR,'/',
<FS2>-DOKTL,' ',
'Loio Id :',LT_PHIOS_REC-LO_OBJID.


WRITE: /5 gf_mark as checkbox,
'Filename : ',LT_PHIOS_REC-filename(75).
GS_PHIO-objid = LT_PHIOS_REC-PH_OBJID.
GS_PHIO-class = LT_PHIOS_REC-PH_class.
HIDE GS_PHIO.
CLEAR GS_PHIO.

WRITE: /7 'Active Vesrion :',LT_PHIOS_REC-Active_version,
icon_activate as icon.

WRITE: 60 icon_export AS ICON HOTSPOT ON.
gs_doc_key-dokar = <FS2>-DOKAR.
gs_doc_key-doknr = <FS2>-DOKNR.
gs_doc_key-dokvr = <FS2>-DOKVR.
gs_doc_key-doktl = <FS2>-DOKTL.
HIDE gs_doc_key.
CLEAR gs_doc_key.

if lf_content = 'X'.
WRITE: /7 'Phio Id :', LT_PHIOS_REC-PH_OBJID, icon_okay AS ICON
COLOR COL_KEY INTENSIFIED.
else.
WRITE: /7 'Phio Id :', LT_PHIOS_REC-PH_OBJID COLOR COL_KEY
INTENSIFIED.
endif.
WRITE: /7 'File ID :', LT_PHIOS_REC-file_id.
WRITE: /7 'Created At :', LT_PHIOS_REC-created_at.

WRITE: /7 'Checked Out :', LT_PHIOS_REC-CHECKED_OUT.
WRITE: /7 'Checkout User :', LT_PHIOS_REC-checkout_user.

ULINE.
ULINE.

ENDLOOP.
ENDFORM.
***----------------------------------------------------------------
FORM doc_info.
CALL FUNCTION 'CV110_DOC_DIALOG'
EXPORTING: pf_skip_first = 'X'
pf_transaction = 'CV03'
pf_commit = 'X'
pf_dokar = gs_doc_key-dokar
pf_doknr = gs_doc_key-doknr
pf_dokvr = gs_doc_key-dokvr
pf_doktl = gs_doc_key-doktl
EXCEPTIONS: not_found = 1
no_auth = 2
locked = 3
error = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
CLEAR gs_doc_key.
ENDFORM. "doc_info

After implementing this report sometimes a dump maybe raised during the execution. This dump indicates a problem with object REF-STATUS. This mayb happen of this object Status REF-STATUS is not created for programm ZZ_DMS_KPRO_CHECK_ACTIVE_1. To avoid this dump please open the program ZZ_DMS_KPRO_CHECK_ACTIVE_1 in transaction SE80 and double click on the term 'REF-STATUS' which can be found under "Events" > "START-OF-SELECTION". After double clicking you will be able to create menu entries or icons which are then available when you execute the report. After you maintained all wanted icons and menu entries please activate the report again.

Due to note 1411287 a new parameter 'pf_replace' was inserted in the FORM 'kpro_update_old_version' and so the PERFORM statement needs to be
updated too in report ZZ_DMS_KPRO_CHECK_ACTIVE as well.

In the above report sample this change is already included so you might face a syntax error when in your system the note 1411287 is not implemented now.

As this is a special non-standard report, I can only ask you to change this coding for  the paramter 'pf_replace' and test the report
afterwards again.

Back

3 Comments

  1. Former Member

    IS there a spelling error or bug somewhere? In line 352, there is a reference to a variable "pf_replace" that isn't declared or defined anywhere.

    Regards,

    Espen Leknes

    1. Hi Espen,

      Due to note 1411287 a new parameter 'pf_replace' was inserted in the
      FORM 'kpro_update_old_version' and so the PERFORM statement needs to be
      updated too in report ZZ_DMS_KPRO_CHECK_ACTIVE.

      I check how this FORM is called in other includes and I think that
      the coding in the report needs to be changed like:

        PERFORM kpro_update_old_version in program SAPLCV120
            USING ps_phio_id
                  pf_replace
            CHANGING lf_error.

      As this is a special non-standard report, I can only ask you to
      change this coding and add the paramter 'pf_replace' and test the report
      afterwards again. Maybe this parameter needs to be handed over with
      value 'X' too for having the correct effect.

      I hope that this could be useful to explain this behavior and the parameter

      Best regards,
      Christoph

  2. Hi Christoph,

    we do not use the functionality of Content Versions in our document types. But from time to time we run into this issue.

    For us it would be really interesting what causes the System to accidentally create these content versions and setting more than one to active.

    I found these SAP notes, but they are not fitting to our release or we aren't using WEBUI and we do not use KPRO UPDATE function:

    2061382 - Inkonsistenz beim Einchecken von Originalen im DIS
    2089833 - Fehler beim Anzeigen oder Bearbeiten von Datei
    2064338 - Unpassende Fehlermeldung bei Fehlschlagen von Datei-Upload oder Datei-Download
    942228 - Modifizierter Report DMS_KPRO_CHECK1 für KPRO-Verbuchung
    1674446 - Fehlgeschlagener Checkin kann Inkonsistenzen erzeugen

    Thanks in advance
    Martin Schneider