Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Single-record editing/locking for table maintenance view generation

Hello all,

Please excuse my being a newbie... I have done my research and cannot figure this out, so I'm reaching out to this great community...

When creating table maintenance views, SAP builds a screen that shows all records, and locks the entire table for editing, while it is open. Our problem is that due to constant data loading, we cannot have an entire table locked at any time.

Is there a methodology to generate maintenance views that lock (and edit) tables on a row-by-row basis? I do not think the standard generator can do it, so we are looking at custom ABAP solutions. We would rather not write custom code, as we have to implement this for many tables. Any best practices would be very much appreciated!

Thank you in advance,

-Adam

Tags:
Former Member
Former Member replied

Hi,

I have modified the code to make the key fields as non mandatory...Then it will select all the records if we don't enter anything in the popup...

* Single key maintenance.
PARAMETERS: p_table TYPE tabname OBLIGATORY.

DATA: t_dd03l  TYPE STANDARD TABLE OF dd03l,
      s_dd03l  TYPE dd03l.
DATA: t_fields TYPE STANDARD TABLE OF sval,
      s_fields TYPE sval.
DATA: t_data   TYPE STANDARD TABLE OF vimsellist,
      s_data   TYPE vimsellist,
      s_varkey TYPE vim_enqkey.
DATA: t_sellist TYPE STANDARD TABLE OF vimsellist.
DATA: t_header  TYPE STANDARD TABLE OF vimdesc.
DATA: t_namtab  TYPE STANDARD TABLE OF vimnamtab.
DATA: t_excl    TYPE STANDARD TABLE OF vimexclfun.


START-OF-SELECTION.

* Get the key fields for the table.
  SELECT * FROM dd03l
          INTO TABLE t_dd03l
          WHERE tabname = p_table
          AND   keyflag = 'X'.
  IF sy-subrc <> 0.
    MESSAGE s208(00) WITH 'No key fields found for this table'.
    LEAVE LIST-PROCESSING.
  ENDIF.

* Remove the mandt.
  DELETE t_dd03l WHERE fieldname = 'MANDT'.

  SORT t_dd03l BY position.

* Populate the fields.
  LOOP AT t_dd03l INTO s_dd03l.
    s_fields-fieldname = s_dd03l-fieldname.
    s_fields-tabname   = s_dd03l-tabname.
    s_fields-field_obl = ' '.
    APPEND s_fields TO t_fields.
  ENDLOOP.

* Get the single values
  CALL FUNCTION 'POPUP_GET_VALUES'
    EXPORTING
      no_value_check  = 'X'
      popup_title     = 'Table maintenance'
    TABLES
      fields          = t_fields
    EXCEPTIONS
      error_in_fields = 1
      OTHERS          = 2.
  IF sy-subrc <> 0.
    MESSAGE s208(00) WITH 'Error in calling FM POPUP_GET_VALUES'.
    LEAVE LIST-PROCESSING.
  ENDIF.

  s_varkey = sy-mandt.
* Populate the values for VIEW_MAINTENANCE_CALL.
  LOOP AT t_fields INTO s_fields.
    s_data-viewfield = s_fields-fieldname.
    s_data-operator  = 'EQ'.
    s_data-value     = s_fields-value.
    s_data-and_or    = 'AND'.
    s_data-tabix     = sy-tabix + 1.

    IF NOT s_fields-value IS INITIAL.
      APPEND s_data TO t_data.
    ENDIF.

* Concatenate the values for locking.
    CONCATENATE s_varkey s_data-value INTO s_varkey.

  ENDLOOP.

* lock the records.
  CALL FUNCTION 'ENQUEUE_E_TABLEE'
    EXPORTING
      mode_rstable   = 'E'
      tabname        = p_table
      varkey         = s_varkey
    EXCEPTIONS
      foreign_lock   = 1
      system_failure = 2
      OTHERS         = 3.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    LEAVE LIST-PROCESSING.
  ENDIF.

* Get the view info.
  CALL FUNCTION 'VIEW_GET_DDIC_INFO'
    EXPORTING
      viewname        = p_table
    TABLES
      sellist         = t_sellist
      x_header        = t_header
      x_namtab        = t_namtab
    EXCEPTIONS
      no_tvdir_entry  = 1
      table_not_found = 2
      OTHERS          = 3.
  IF sy-subrc <> 0.
    MESSAGE s208(00) WITH 'Error in calling FM VIEW_GET_DDIC_INFO'.
    LEAVE LIST-PROCESSING.
  ENDIF.


* Now the values are got. pass it on to the maintenance view.
  CALL FUNCTION 'VIEW_MAINTENANCE'
    EXPORTING
      view_action               = 'U'
      view_name                 = p_table
    TABLES
      dba_sellist               = t_data[]
      excl_cua_funct            = t_excl[]
      x_header                  = t_header[]
      x_namtab                  = t_namtab[]
    EXCEPTIONS
      missing_corr_number       = 1
      no_database_function      = 2
      no_editor_function        = 3
      no_value_for_subset_ident = 4
      OTHERS                    = 5.
  IF sy-subrc <> 0.
    MESSAGE s208(00) WITH 'Error in calling FM VIEW_MAINTENANCE'.
    LEAVE LIST-PROCESSING.

  ENDIF.

Thanks

Naren

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question