Hello

Sometimes you need delete Originals in DMS

following  ABAP program delete DMS Originals. ( Be careful )

Excel Structure must :

Document Number Document Type Document Part Document version
000000000000000200000012 DWG 000 00
000000000000000200000012 DWG 000

01

000000000000000200000013 DWG 000 01

Be careful Document Number must 25 character if Document number less than 25 set zero before number ( for example : 200000012 -> 000000000000000200000012)  

How Use :

Step 1:  after create program go t.code se38 execute .

/wp-content/uploads/2014/05/se38_444470.jpg

Step 2 :Enter number row you want start program in excel in and end row

     Select Excel file ( by default C:\Delete.xlsx)

( for example excel file have 20000 row and in first step you want delete 499 row , from row 2 and to row : 500 , next step you want delete 1000 row from row 501 and to row : 1501)

/wp-content/uploads/2014/05/delete_444471.jpg

Step 3 : Run (f8)

sorry code is Spaghetti


*&---------------------------------------------------------------------*
*& Report  ZDMS_DELETE_ORIGINALS_TEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT  ZDMS_DELETE_ORIGINALS.
"CONSTANTS: FILE_PATH LIKE RLGRAP-FILENAME VALUE C:\delete.xlsx'.
            "MAX_ROWS TYPE i VALUE 10000.
TYPES:
       BEGIN OF ST_DIR,
         DOKAR TYPE DOKAR,
         DOKNR TYPE DOKNR,
         DOKVR TYPE DOKVR,
         DOKTL TYPE DOKTL,
       END OF ST_DIR.
PARAMETERS BEG_ROW TYPE i DEFAULT 2.
PARAMETERS END_ROW TYPE i DEFAULT 500.
PARAMETERS FILEPATH LIKE RLGRAP-FILENAME DEFAULT 'c:\Delete.xlsx'.
DATA: it_documents TYPE TABLE OF st_dir,
       wa_documents TYPE st_dir.
DATA it_file_content TYPE TABLE OF ALSMEX_TABLINE WITH HEADER LINE.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
   EXPORTING
     FILENAME                      = FILEPATH
     I_BEGIN_COL                   = 1
     I_BEGIN_ROW                   = BEG_ROW
     I_END_COL                     = 4
     I_END_ROW                     = END_ROW   "15943
   TABLES
     INTERN                        = it_file_content
* EXCEPTIONS
*   INCONSISTENT_PARAMETERS       = 1
*   UPLOAD_OLE                    = 2
*   OTHERS                        = 3
           .
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
DATA: current_row TYPE i VALUE 1,
       rowCount TYPE i.
rowCount = LINES( it_file_content ).
WHILE current_row <= rowCount.
   LOOP AT it_file_content FROM CURRENT_ROW TO CURRENT_ROW + 3.
     CASE it_file_content-COL.
       WHEN '1'.
         WA_DOCUMENTS-DOKNR = it_file_content-VALUE.
       WHEN '2'.
         WA_DOCUMENTS-DOKAR = it_file_content-VALUE.
       WHEN '3'.
         WA_DOCUMENTS-DOKTL = it_file_content-VALUE.
       WHEN '4'.
         WA_DOCUMENTS-DOKVR = it_file_content-VALUE.
     ENDCASE.
   ENDLOOP.
   APPEND WA_DOCUMENTS TO IT_DOCUMENTS.
   CLEAR WA_DOCUMENTS.
   current_row = current_row + 4.
ENDWHILE.
LOOP AT IT_DOCUMENTS INTO WA_DOCUMENTS.
   PERFORM DELETE_ORG USING WA_DOCUMENTS-DOKAR WA_DOCUMENTS-DOKNR WA_DOCUMENTS-DOKVR WA_DOCUMENTS-DOKTL.
ENDLOOP.
WRITE 'Successful!!'.
FORM DELETE_ORG USING dokar doknr dokvr doktl.
   DATA: it_old_originals TYPE TABLE OF BAPI_DOC_FILES2 WITH HEADER LINE,
         ret TYPE BAPIRET2,
         ls_doc    LIKE bapi_doc_draw2,
         ls_docx   LIKE bapi_doc_drawx2.
*  ls_doc-DOCUMENTNUMBER = '0000000000000000000010005'.
*  ls_doc-DOCUMENTPART = '000'.
*  ls_doc-DOCUMENTTYPE = 'ENG'.
*  ls_doc-DOCUMENTVERSION = '00'.
   ls_doc-DOCUMENTNUMBER = doknr.
   ls_doc-DOCUMENTPART = doktl.
   ls_doc-DOCUMENTTYPE = dokar.
   ls_doc-DOCUMENTVERSION = dokvr.
   CALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2'
     EXPORTING
       DOCUMENTTYPE         = ls_doc-DOCUMENTTYPE
       DOCUMENTNUMBER       = ls_doc-DOCUMENTNUMBER
       DOCUMENTPART         = LS_DOC-DOCUMENTPART
       DOCUMENTVERSION      = ls_doc-DOCUMENTVERSION
*     GETOBJECTLINKS       = ' '
*     GETCOMPONENTS        = ' '
*     GETSTATUSLOG         = ' '
*     GETLONGTEXTS         = ' '
       GETACTIVEFILES       = 'X'
       GETDOCDESCRIPTIONS   = 'X'
       GETDOCFILES          = 'X'
*     GETCLASSIFICATION    = ' '
*     GETSTRUCTURE         = ' '
*     GETWHEREUSED         = ' '
*     HOSTNAME             = ' '
       INHERITED            = 'X'
     IMPORTING
*     DOCUMENTDATA         =
       RETURN               = ret
     TABLES
*     OBJECTLINKS          =
*     DOCUMENTDESCRIPTIONS =
*     LONGTEXTS            =
*     STATUSLOG            =
       DOCUMENTFILES        = it_old_originals
*     COMPONENTS           =
*     CHARACTERISTICVALUES =
*     CLASSALLOCATIONS     =
*     DOCUMENTSTRUCTURE    =
*     WHEREUSEDLIST        =
     .
   LOOP AT it_old_originals.
     it_old_originals-DELETEVALUE = 'X'.
     MODIFY it_old_originals.
   ENDLOOP.
   CALL FUNCTION 'BAPI_DOCUMENT_CHANGE2'
     EXPORTING
       DOCUMENTTYPE               = ls_doc-DOCUMENTTYPE
       DOCUMENTNUMBER             = ls_doc-DOCUMENTNUMBER
       DOCUMENTPART               = LS_DOC-DOCUMENTPART
       DOCUMENTVERSION            = ls_doc-DOCUMENTVERSION
       DOCUMENTDATA               = LS_DOC
       DOCUMENTDATAX              = LS_DOCX
*   HOSTNAME                   =
*   DOCBOMCHANGENUMBER         =
*   DOCBOMVALIDFROM            =
*   DOCBOMREVISIONLEVEL        =
*   SENDCOMPLETEBOM            = ' '
*   PF_FTP_DEST                = ' '
*   PF_HTTP_DEST               = ' '
*   CAD_MODE                   = ' '
*   ACCEPT_EMPTY_BOM           = ' '
* IMPORTING
*   RETURN                     =
    TABLES
*   CHARACTERISTICVALUES       =
*   CLASSALLOCATIONS           =
*   DOCUMENTDESCRIPTIONS       =
*   OBJECTLINKS                =
*   DOCUMENTSTRUCTURE          =
      DOCUMENTFILES              = it_old_originals
*   LONGTEXTS                  =
*   COMPONENTS                 =
             .
ENDFORM.
To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Arun Kumar Kaul

    Hello Ali,

    Before runing any program make delete flag ON then

    T-Code sa38 execute

    program MCDOKDEL execute

    I thing much easy this way

    Regards

    Arun kaul

    (0) 
  2. Pooja Gunjal

    Hello all,

    i am a newbie in DMS,i just want to know how to ensure that if i deleted a dir (Using program MCDOKDEL) then its corresponding original is also deleted ?

     

    Thanks In Advance.

    (0) 

Leave a Reply