Read only fields in the Maintenance View

Problem: you have a Maintenance View and you want to have Key Fields automatically populated.

Solution: First of all you need to create a database view to the table you want the users to maintain. This database view should be of type maintenance.

In the definition of the database view mark the fields you want to be automatically updated as a read-only fields („R”). These fields will not be updated by the user.

When you have done this, generate the Maintenance View to the newly created database view. After activation go to the events of this Maintenance View and create procedure for the event called „Fill Hidden Fields”. This event was created exactly for the purpose of filling out hidden and read-only fields. The body of the procedure for the event is presented below.

  FIELD-SYMBOLS:
    <lv_field> TYPE ANY,
    <ls_line> TYPE ANY.
 
  LOOP AT <vim_ck_sellist> ASSIGNING <ls_line>.
    ASSIGN COMPONENT 'VIEWFIELD' OF STRUCTURE <ls_line> TO <lv_field>.
    CHECK sy-subrc = 0
      AND <lv_field> = 'KEY_FIELD'.
 
    ASSIGN COMPONENT 'VALUE' OF STRUCTURE <ls_line> TO <lv_field>.
    CHECK sy-subrc = 0.
* table is a variable defined by TABLES command
    table-key_field = <lv_field>.
    RETURN.
  ENDLOOP.
  FIELD-SYMBOLS:
    <lv_field> TYPE ANY,
    <ls_line> TYPE ANY.

  LOOP AT <vim_ck_sellist> ASSIGNING <ls_line>.
    ASSIGN COMPONENT 'VIEWFIELD' OF STRUCTURE <ls_line> TO <lv_field>.
    CHECK sy-subrc = 0
      AND <lv_field> = 'KEY_FIELD'.

    ASSIGN COMPONENT 'VALUE' OF STRUCTURE <ls_line> TO <lv_field>.
    CHECK sy-subrc = 0.
* table is a variable defined by TABLES command
    table-key_field = <lv_field>.
    RETURN.
  ENDLOOP.

Komentowanie jest zakończone.