Enterprise Resource Planning Blog Posts by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
kamilmirza
Explorer
6,305

SAP offers limited DMS Objects in standard system and there is always a requirement to have Custom DMS Objects. This is a detailed step-by-step guide to create Custom DMS Objects in SAP system. 

In this article, we will use standard LIKP table and ZVENDCERT custom table for DMS Objects.

1. Add Custom Object / Maintain Key Fields

Table name should not exceed 10 characters, which will be our DMS Object
SAP IMG -> Cross-Application Components -> Document Management -> Control Data -> Maintain Key Fields

kamilmirza_0-1723027285359.png

2. Append MCDOKOB structure with required key fields (if not available)

LIKP table has only one key field i.e. VBELN and it is already in MCDOKOB structure, so no need to append MCDOKOB structure.

kamilmirza_1-1723027575455.png

ZVENDCERT table key fields are LIFNR, CERT_TYPE, CERT_NUMB, BEGDA, ENDDA. We will skip LIFNR because it is already there in MCDOKOB structure. Append MCDOKOB structure accordingly.

kamilmirza_2-1723027698558.png

3. Maintain Object Link Descriptions

This step will add our Custom Object in DMS Object List. Just enter your Language, Custom Object and Object Description. F4 Help of Object field will not show our Custom Object unless you save this entry.

SAP IMG -> Cross-Application Components -> Document Management -> Control Data -> Define Document Types -> Maintain Object Link Descriptions

kamilmirza_3-1723027945482.png

4. Define Document Type (accordingly)

SAP IMG -> Cross-Application Components -> Document Management -> Control Data -> Define Document Types

kamilmirza_4-1723028069588.png

5. Create Object Links

We have 2 methods to create Object Links for our Custom DMS Objects:
  • BAdI Enhancement
  • Modification
We will create LIKP Object Link through BAdI and ZVENDCERT from Modification

5.1 BAdI Enhancement

BAdI DOCUMENT_OBJ is defined so that you can integrate your own objects in transactions for document management (CV01N, CV02N, CV03N, CV04N) without modification.

SAP Documentation

I have used the logics from existing Implementations of DOCUMENT_OBJ BAdI and have tried to keep them simple as possible for better understanding.

5.1.1 Define Object Links

SAP has provided Screen 1500 in CV130/CV100 Function Groups to handle DOCUMENT_OBJ BAdI Objects. Object Links created via DOCUMENT_OBJ BAdI will always have Screen/Dynpro 500 in SPRO screens instead of 1500. We need to link our Document Type with an Object. So, we create the following entry for our newly created Document Type DLH.
SAP IMG -> Cross-Application Components -> Document Management -> Control Data -> Define Document Types -> Define Object Links

kamilmirza_5-1723029006935.png

5.1.2 Maintain Screen for Object Link

Create an entry with LIKP Object and Screen 500
SAP IMG -> Cross-Application Components -> Document Management -> Control Data -> Maintain Screen for Object Link

kamilmirza_6-1723029123660.png

5.1.3 Create DOCUMENT_OBJ BAdI Implementation

Add LIKP Object in Filter Value

kamilmirza_7-1723029242033.png

Add the following code blocks in our Implementation class methods.

 

  METHOD if_ex_document_obj~get_data.

    MOVE if_ex_document_obj~table_drad_db   TO table_drad_db.
    MOVE if_ex_document_obj~table_drad_work TO table_drad_work.
    MOVE if_ex_document_obj~draw            TO draw.
    MOVE if_ex_document_obj~activity        TO activity.

  ENDMETHOD.

  METHOD if_ex_document_obj~put_data.

    MOVE table_drad_db   TO if_ex_document_obj~table_drad_db.
    MOVE table_drad_work TO if_ex_document_obj~table_drad_work.
    MOVE draw            TO if_ex_document_obj~draw.
    MOVE activity        TO if_ex_document_obj~activity.

    DELETE if_ex_document_obj~table_drad_db WHERE dokob NE flt_val.

  ENDMETHOD.

  METHOD if_ex_document_obj~object_check.
  “ Insert your custom logic for OBJECT_CHECK method
    DATA vbeln TYPE vbeln_vl.

    vbeln = ls_obtab-objek.

    SELECT SINGLE  FROM likp WHERE vbeln = @vbeln INTO (delivery_valid).
    IF delivery_valid <> abap_true.
      RAISE object_not_found.
    ENDIF.

  ENDMETHOD.

  METHOD if_ex_document_obj~jump_to_screen.

    CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.

  ENDMETHOD.

 

5.1.4 Create a Function Group and Screen for our Implementation

Create a Function Group and Screen as Subscreen type. Enter Program called as ‘SAPL<Z FUNCTION GROUP>’ with Screen and create the following entry in Implementation Subscreens tab:

kamilmirza_8-1723029529152.png

Note: Z Program name and Screen can also be added.
Function Group Data Declarations in TOP include:

 

CONTROLS: tc TYPE TABLEVIEW USING SCREEN 9002.

TYPES: BEGIN OF ty_tab,
         vbeln TYPE vbeln_vl.
         INCLUDE STRUCTURE dms_drad_badi_work.
TYPES: END OF ty_tab.

CONSTANTS: dms_object TYPE dokob VALUE 'LIKP'.

DATA: itab            TYPE TABLE OF ty_tab,
      wa              TYPE ty_tab,
      object_instance TYPE REF TO if_ex_document_obj,
      table_drad_work TYPE dms_tbl_drad_badi_work,
      wa_drad_work    TYPE dms_drad_badi_work,
      table_drad_db   TYPE TABLE OF drad,
      draw            TYPE draw,
      activity        TYPE i,
      vbeln           TYPE vbeln_vl,
      tabdrad         TYPE STANDARD TABLE OF drad,
      vb_flag         TYPE flag.

 

 Screen 9002 Flow Logic:

 

  MODULE init.

  LOOP AT itab INTO wa WITH CONTROL tc CURSOR tc-current_line.
    MODULE set_data.
  ENDLOOP.

PROCESS AFTER INPUT.

  LOOP AT itab.
    CHAIN.
      FIELD: wa-vbeln.
      FIELD: wa-tab_mark. “ table control mark field
      MODULE get_data ON CHAIN-REQUEST.
    ENDCHAIN.
  ENDLOOP.

  MODULE put_data.

 

PBO Modules:

 

MODULE init OUTPUT.

  cl_exithandler=>get_instance_for_subscreens(
  CHANGING
    instance = object_instance ).

  object_instance->get_data(
  EXPORTING
    flt_val         = dms_object
  IMPORTING
    table_drad_work = table_drad_work
    table_drad_db   = table_drad_db
    draw            = draw
    activity        = activity ).

  LOOP AT table_drad_work INTO wa_drad_work WHERE objky IS NOT INITIAL.
    CLEAR wa.
    MOVE-CORRESPONDING wa_drad_work TO wa.
    wa-vbeln = wa-objky.
    READ TABLE itab WITH KEY vbeln = wa-objky TRANSPORTING NO FIELDS.
    IF sy-subrc <> 0.
      APPEND wa TO itab.
    ENDIF.
  ENDLOOP.

ENDMODULE.

MODULE set_data OUTPUT.

  IF activity = 3.
    LOOP AT SCREEN.
      IF screen-name = 'WA-VBELN'.
        screen-input = 0.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ELSE.
    DATA(lines) = lines( itab ).
    tc-lines = lines + 1.
  ENDIF.

ENDMODULE.

 

PAI Modules:

 

MODULE get_data INPUT.

  IF wa-vbeln IS NOT INITIAL.

    SELECT SINGLE  FROM likp WHERE vbeln = -vbeln INTO (delivery_valid).

    IF delivery_valid = abap_false.
      SET CURSOR FIELD 'WA-VBELN' LINE tc-current_line.
      MESSAGE 'Delivery not valid' TYPE 'E'.
    ENDIF.

    READ TABLE itab WITH KEY vbeln = wa-vbeln TRANSPORTING NO FIELDS.
    IF sy-subrc = 0.
      MODIFY itab FROM wa INDEX tc-current_line.
    ELSE.
      APPEND wa TO itab.
    ENDIF.

  ENDIF.

ENDMODULE.

MODULE put_data INPUT.

  cl_exithandler=>get_instance_for_subscreens(
  CHANGING
    instance = object_instance ).

  LOOP AT itab INTO wa.
    CLEAR wa_drad_work.

    MOVE-CORRESPONDING wa TO wa_drad_work.
    wa_drad_work-objky = wa-vbeln.

    APPEND wa_drad_work TO table_drad_work.
  ENDLOOP.

  object_instance->put_data(
  EXPORTING
    table_drad_work = table_drad_work
    table_drad_db   = table_drad_db
    flt_val         = dms_object
    activity        = activity ).        

ENDMODULE.

 

5.1.5 Result

Create a document with DLH document type and enter a valid Delivery number in Object Links tab in CV01N. Object Linkage is completed between DMS Object and Document Type.

kamilmirza_9-1723030438520.png

Just for Demo: 

To integrate DMS functionality in Delivery transactions VL0xN, we have created a Custom Tab (Screen 9001) in Delivery header with DMS Attachment button with the following logic:

Screen 9001 Flow Logic:

 

PROCESS BEFORE OUTPUT.

PROCESS AFTER INPUT.
  MODULE user_command_9001.

 

PAI Modules:

 

MODULE user_command_9001 INPUT.

  IF sy-ucomm = 'ATTACH'.

    IMPORT p1 = vbeln FROM MEMORY ID 'ZDELIVERY'.

    CASE sy-tcode.
      WHEN 'VL02N'.
        DATA(mode) = 1.
      WHEN 'VL03N'.
        mode = 3.
    ENDCASE.

    CALL FUNCTION 'DOCUMENT_ASSIGNMENT'
      EXPORTING
        check_exist = abap_true
        dokob       = dms_object
        objky       = CONV drad-objky( vbeln )
        opcode      = mode " 1=Create 2=Change 3=Display
      IMPORTING
        vb_flag     = vb_flag
      TABLES
        tabdrad     = tabdrad.

    IF vb_flag IS NOT INITIAL AND tabdrad IS NOT INITIAL.
      MODIFY drad FROM TABLE tabdrad.
      IF sy-subrc = 0.
        COMMIT WORK AND WAIT.
      ELSE.
        ROLLBACK WORK.
      ENDIF.
    ENDIF.

    CLEAR sy-ucomm.

  ENDIF.

ENDMODULE.

 

kamilmirza_10-1723030902173.png

5.2 Modification

Modification is possible with Access Key provided from SAP. We will create Object Link for ZVENDCERT Custom DMS Object. Custom DMS Objects can be added through Modification according to SAP:

SAP Note 1417841 - FAQ: Document management

7. Question: Can other SAP objects also be added for linking to documents?
Answer: Yes. In principle, any SAP object can be added using a modification. You will find a short guide about this in the SAP Library (SAP Library -> SAP ERP Cross-Application Functions -> Cross-Application Components -> Document Management -> Document Info Record -> Linking Objects to a Document -> Adding Other Objects)

The documentation has been kept brief intentionally because, for technical reasons, the requirements differ from object to object and we cannot go into object-specific details in general documentation. Bear in mind that the interface must be programmed on both the DMS side and the object side when other objects are added. Additional SAP objects should be added by experienced ABAP developers only.

SAP Note 2429909 - DMS Standard Object Links where to find/Procedure if non standard object used

4. If you are trying to use NON STANDARD OBJECT link to what is listed above. And wish to create a link to Non Standard Object. You may refer to online documentation Referencing CV100 & CV130. The documentation in the provided links has been kept brief intentionally because, for technical reasons, the requirements differ from object to object and we cannot go into object specific details in general documentation. Bear in mind that the interface must be programmed on both the DMS side and the object side when the objects are added. Additional SAP objects should be added by experienced ABAP developers only. So I truly recommend you to contact your local consulting organization on this.

5.2.1 Create Subscreen in CV130 Function Group

Copy any screen from CV130 FG Screens to 900X

kamilmirza_0-1723031892608.png

Add our Custom DMS Object ZVENDCERT fields in its table control:

kamilmirza_1-1723031974310.png

kamilmirza_2-1723032016733.png

Copy newly created Screen 9001 to Function Group CV100 and CV140

kamilmirza_3-1723032143558.png

5.2.2 Create OBJECT_CHECK_XXX Function Module

Copy any standard OBJECT_CHECK_XXX function module, like OBJECT_CHECK_EQUI or OBJECT_CHECK_PMAUFK, and name it as our custom DMS Object name as OBJECT_CHECK_ZVENDCERT. We can use any Function Group. This FM is used to validate the entered data in our screen 9001. Change your logic accordingly.

kamilmirza_4-1723032247891.png

 

FUNCTION object_check_zvendcert.
  
  TABLES: zvendcert.

  DATA: BEGIN OF lt_objecttab OCCURS 0.
          INCLUDE STRUCTURE cltable.
  DATA: END OF lt_objecttab.

  DATA: BEGIN OF lt_tdskey OCCURS 0,
          lifnr     TYPE lifnr,
          cert_type TYPE zvendcert_type,
          cert_numb TYPE zvendcert_numb,
          begda     TYPE begda,
          endda     TYPE endda.
  DATA: END   OF lt_tdskey.
  "--------------------------------------------

  CLEAR no_auth.
  CLEAR message_type.
  CLEAR fault_text.

  IF single IS NOT INITIAL.
    READ TABLE otab INDEX 1.

    lt_tdskey = otab-objek.

    SELECT SINGLE * FROM zvendcert
      WHERE lifnr = lt_tdskey-lifnr
        AND cert_type = lt_tdskey-cert_type
        AND cert_numb = lt_tdskey-cert_numb
        AND begda = lt_tdskey-begda
        AND endda = lt_tdskey-endda.

    IF syst-subrc EQ 0.

      otab-obtxt = 'Vendor Certificate'(001).
      MODIFY otab INDEX 1.

      IF called_from = 2.

        lt_objecttab-tname = 'ZVENDCERT'.

        CALL METHOD cl_abap_container_utilities=>fill_container_c
          EXPORTING
            im_value               = zvendcert
          IMPORTING
            ex_container           = lt_objecttab-table
          EXCEPTIONS
            illegal_parameter_type = 1
            OTHERS                 = 2.

        APPEND lt_objecttab.
        CALL FUNCTION 'CTMS_OBJECT_AREA'
          TABLES
            objects = lt_objecttab.

      ENDIF.

    ELSE.

      otab-obtxt = 'Vendor Certificate not valid'(002).
      RAISE object_not_found.

    ENDIF.

  ENDIF.

ENDFUNCTION.

 

5.2.3 Define Document Type (accordingly)

SAP IMG -> Cross-Application Components -> Document Management -> Control Data -> Define Document Types

kamilmirza_5-1723032420384.png

5.2.4 Define Object Link

Create new entry to add linkage for our newly created ZVC Document Type (in 5.2.3) to Object Link ZVENDCERT with Screen 9001

kamilmirza_6-1723032572827.png

5.2.5 Maintain Screen for Object Link

Create an entry with ZVENDCERT Object and Screen 9001
SAP IMG -> Cross-Application Components -> Document Management -> Control Data -> Maintain Screen for Object Link

kamilmirza_7-1723032677781.png

5.2.6 Result

Now we can create our ZVENDCERT Object Document with ZVC Document Type. Now we can integrate our DMS Object in our transaction.

kamilmirza_8-1723032755237.png

 

Useful Links

SAP Document Management System (Documentation) 

Document Management 

Fast Skip on SAP Document Management Service 01 

DMS Adding Other Objects 

Enhancement Without Modification of the Object Links