Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to refresh table control in a maintenance dialog.

0 Kudos

Hello SAPients.

I have a Maintenance Dialog for a ZTable, I have two fields that are updated with code (Changed by and Changed on) in the event "01 Before saving the data in the database". The data is correctly saved in the ZTable, but the records changed are not refreshed in the screen after I clicked the save button. What can I do to get the Table Control refreshed and make it show the new values of those fields immediately after I clicked the Save button?

Thank you in advance for your kind help.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Ricardo - I use the following code in event 01 and the screen is refreshed after the data is saved:


*&---------------------------------------------------------------------*
*&      Form  FILL_SY_FIELDS
*&---------------------------------------------------------------------*
*       Add the creation date and userid if the line is being created.
*       Add the change date and userid if the line is being changed.
*----------------------------------------------------------------------*
form fill_sy_fields.

  data: f_index like sy-tabix. "Index to note the lines found

  data begin of total_s.
          include structure ZZHB6_GL_ST_CD_V.
  data action.
  data mark.
  data end of total_s.

  data extract_s like total_s.

  loop at total.
    if <action> = 'U'.
      move total to total_s.
      read table extract with key total.
      if sy-subrc eq 0.
        f_index = sy-tabix.
        extract_s = extract.
      else.
        clear f_index.
      endif.
*       (make desired changes to the line TOTAL)
      total_s-zzfchdate = sy-datum.
      total_s-zzfchusr  = sy-uname.
      move total_s to total.
      modify total.
      check f_index gt 0.
      extract = total.
      modify extract index f_index.
    elseif <action> = 'N'.
      move total to total_s.
      read table extract with key total.
      if sy-subrc eq 0.
        f_index = sy-tabix.
        extract_s = extract.
      else.
        clear f_index.
      endif.
*       (make desired changes to the line TOTAL)
      total_s-zzfcredate = sy-datum.
      total_s-zzfcreusr  = sy-uname.
      move total_s to total.
      modify total.
      check f_index gt 0.
      extract = total.
      modify extract index f_index.
    elseif total is initial.
      move total to total_s.
      read table extract with key total.
      if sy-subrc eq 0.
        f_index = sy-tabix.
        extract_s = extract.
      else.
        clear f_index.
      endif.
*       (make desired changes to the line TOTAL)
      delete total.
      check f_index gt 0.
      delete extract index f_index.
    endif.
  endloop.
  sy-subrc = 0.

endform.                    " FILL_SY_FIELDS

Rob

3 REPLIES 3

Former Member
0 Kudos

Ricardo - I use the following code in event 01 and the screen is refreshed after the data is saved:


*&---------------------------------------------------------------------*
*&      Form  FILL_SY_FIELDS
*&---------------------------------------------------------------------*
*       Add the creation date and userid if the line is being created.
*       Add the change date and userid if the line is being changed.
*----------------------------------------------------------------------*
form fill_sy_fields.

  data: f_index like sy-tabix. "Index to note the lines found

  data begin of total_s.
          include structure ZZHB6_GL_ST_CD_V.
  data action.
  data mark.
  data end of total_s.

  data extract_s like total_s.

  loop at total.
    if <action> = 'U'.
      move total to total_s.
      read table extract with key total.
      if sy-subrc eq 0.
        f_index = sy-tabix.
        extract_s = extract.
      else.
        clear f_index.
      endif.
*       (make desired changes to the line TOTAL)
      total_s-zzfchdate = sy-datum.
      total_s-zzfchusr  = sy-uname.
      move total_s to total.
      modify total.
      check f_index gt 0.
      extract = total.
      modify extract index f_index.
    elseif <action> = 'N'.
      move total to total_s.
      read table extract with key total.
      if sy-subrc eq 0.
        f_index = sy-tabix.
        extract_s = extract.
      else.
        clear f_index.
      endif.
*       (make desired changes to the line TOTAL)
      total_s-zzfcredate = sy-datum.
      total_s-zzfcreusr  = sy-uname.
      move total_s to total.
      modify total.
      check f_index gt 0.
      extract = total.
      modify extract index f_index.
    elseif total is initial.
      move total to total_s.
      read table extract with key total.
      if sy-subrc eq 0.
        f_index = sy-tabix.
        extract_s = extract.
      else.
        clear f_index.
      endif.
*       (make desired changes to the line TOTAL)
      delete total.
      check f_index gt 0.
      delete extract index f_index.
    endif.
  endloop.
  sy-subrc = 0.

endform.                    " FILL_SY_FIELDS

Rob

Former Member
0 Kudos

Change both 'total' and 'extract' internal tables in the event.

Former Member
0 Kudos

Hi Ricardo,

You said you want to update the fields ...right? As far as i know, you need to write the code in <b>event 18</b>.

Check this forum ID for more information ..

Hope this will be of some help to you.

Regards,

Vicky

PS: Award points if helpful