Skip to Content
avatar image
Former Member

Only save when "save"-icon is pressed in REUSE_ALV_GRID_DISPLAY

Hi,

I have waisted about a whole day trying to find out how to make my ALV save, no matter what icon they use, but it seems it only works when pressing the “save”-icon.

I am rather new to ABAP but used to be a 4GL programmer in Progress and find much of it familiar. Some friendly “stealing” of code from the net helps me on the way.

I have created a huge report with several possibillities for adding, deleting and changing data in a personal budget file our users have.

What I want it to do is to save any changes done if they choose for instance to add a line or delete a line. It all works fine if they click the “sav-icon” first, so I tried to implement the “save-data” code to the other functions, but it seems to ignore it.

I have a form like this:

FORM F_SAVE_DATA.
  DATA : WA_REPCP   TYPE TY_REP.
  DATA : WA_REP_TMP TYPE ZREP_PCCCGL.
  CLEAR IT_CHANGES[].
  LOOP AT IT_REP INTO WA_REP.
    READ TABLE IT_REPCP INTO WA_REPCP INDEX SY-TABIX.
    IF WA_REPCP NE WA_REP.
      APPEND WA_REP TO IT_CHANGES.
      MOVE-CORRESPONDING WA_REP TO WA_REP_TMP.
      MODIFY ZREP_PCCCGL FROM WA_REP_TMP .
    ENDIF.
    CLEAR WA_REPCP.
  ENDLOOP.
ENDFORM.

And the user commands defined like this (example) – but it ignores the “PERFORM F_SAVE_DATA” in user command “&DEL”. When it returns it has reset the values that where changed.

FORM USER_COMMAND  USING P_UCOMM    LIKE SY-UCOMM
                         P_SELFIELD TYPE SLIS_SELFIELD.
  CASE P_UCOMM.
    WHEN '&DATA_SAVE'.
      PERFORM F_SAVE_DATA.
      PERFORM GET_DATA.
      P_SELFIELD-REFRESH = 'X'.
    WHEN '&DEL'.
PERFORM F_SAVE_DATA.
      READ TABLE IT_REP INTO WA_REP INDEX P_SELFIELD-TABINDEX.
        UPDATE ZREP_PCCCGL
           SET STA = 'D'
         WHERE TUSER = sy-uname
           AND GL = WA_REP-GL.
      PERFORM GET_DATA.
      P_SELFIELD-REFRESH = 'X'.
  ENDCASE.
ENDFORM.

Any help would be very much appreciated��

Best regards, Sølve S.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Apr 16 at 08:40 AM

    i'd guess it's a missing commit work between updating db-Tables and re-reading data.

    Regards

    Stefan Seeburger

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi, and thanx for your effort, but unfortunately it did not help. Tried both “Commit work” and “Commit work and wait”

      /Sølve

  • Apr 16 at 08:43 AM

    about alv ist important to know that the alv "knows" the data from the internal table u gave him. if u update that table. you have to display the changed data using a "refresh" so alv knows that the data of the itab got changed.

    Regards

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 16 at 12:45 PM

    Hi again. Tried this as well (if I understood you correctly, added ‘p_selfield-refresh = ‘X’) but it did not work. The strange thing is that it works perfect when pressing the “Save”-icon, but not any other icons (like my “&INS”-icon).

    I make me think that maybe pressing the “Save”-icon does more than just performing “&SAVE_DATA”….. – for instance have some predefined code running first….

    B.r. Sølve

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 16 at 01:32 PM

    Buttons from the gui-status like SAVE triggers PAI and PBO of your dynpro . i duno if thats the case when Buttons in ALV are pressed.

    i guess u will figure out when debugging your Code.

    Regards

    Add comment
    10|10000 characters needed characters exceeded