Downtime Announcement: Please note the SAP Community Wiki will be unavailable due to a system upgrade on Thursday, September 24th between 6 and 7 AM CEST
Skip to end of metadata
Go to start of metadata

Table Maintenance Generator for event Number 01  and 05.

Create Maintenance view for the database table and write the following code in Include.

*&--------------------------------------------------------------*
*&      Form  create_entry
*&--------------------------------------------------------------*
FORM create_entry.

  zvmaint-zcreatedate     = sy-datum.       " Creation Date
  zvmaint-zcreatetime     = sy-uzeit.       " Creation Time
  zvmaint-zcreateuser     = sy-uname.       " Created By
  zvmaint-zupdateuser     = sy-uname.       " Last Update user
  zvmaint-zupdatedate     = sy-datum .      " Last Update date
  zvmaint-zupdatetime     = sy-uzeit.       " Last Update time

ENDFORM.                    " _CREATE_ENTRY
*&---------------------------------------------------------------------*
*&      Form  modify_entry
*&---------------------------------------------------------------------*
FORM  modify_entry.
  DATA: lv_index TYPE sy-tabix.                   " Number of lines found

  CONSTANTS : lc_action_update TYPE c VALUE 'U',    "Updating current record
              lc_action_create TYPE c VALUE 'N'.    "Creating new  record
* Clearing data objects.
  CLEAR : lv_index.
*-- Check the all entries of records in table by looping each record.
  LOOP AT zvmaint_total.
*-- Check record updated.
    IF <action> = lc_action_update .
*         Read the EXTRACT table with current record.
      READ TABLE extract WITH KEY zvmaint_total.
      IF sy-subrc EQ 0.
        lv_index = sy-tabix.
      ELSE.
        CLEAR lv_index.
      ENDIF.
*   Populating updated fields to table.
      zvmaint_total-zupdateuser = sy-uname.    "Last Update   name
      zvmaint_total-zupdatedate = sy-datum .   " Last Update date
      zvmaint_total-zupdatetime = sy-uzeit.    "Lase Update time
*         Modify the current record in the table.
      MODIFY zvmaint_total.
      CHECK lv_index GT 0.
      extract = zvmaint_total.
      MODIFY extract INDEX lv_index.

*       Check the record created.
    ELSEIF <action> = lc_action_create .

      READ TABLE extract WITH KEY zvmaint_total.
      IF sy-subrc EQ 0.
        lv_index = sy-tabix.
      ELSE.
        CLEAR lv_index.
      ENDIF.

*         Modify the current record in the table.
      MODIFY zvmaint_total.
      CHECK lv_index GT 0.
      extract = zvmaint_total.
      MODIFY extract INDEX lv_index.

    ELSEIF zvmaint_total IS INITIAL.
      READ TABLE extract WITH KEY zvmaint_total.
      IF sy-subrc EQ 0.
        lv_index = sy-tabix.
      ELSE.
        CLEAR lv_index.
      ENDIF.

*         Make desired changes to the line total.
      DELETE zvmaint_total.
      CHECK lv_index GT 0.
      DELETE extract INDEX lv_index.
    ENDIF.
    CLEAR: lv_index.

  ENDLOOP.
  sy-subrc = 0.

ENDFORM.                    "modify_entry

  • No labels

2 Comments

  1. Former Member

    These are the events CREATE and CHANGE table entry.......!!!!

    We can populate the fields automatically using the events and those will be in display mode only.

  2. Hi,

    Why do we really need to touch the EXTRACT table. Whatever changes done in TOTAL are reflecting in the dbase.

    Regards,

    Vamshi.