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: 

Data changed and REUSE_ALV_GRID_DISPLAY

Former Member
0 Kudos

Hi,

I have a problem for get the data which changed on my internal table : wlt_final

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_buffer_active         = space
      i_callback_program      = sy-repid
      I_CALLBACK_USER_COMMAND = c_user_command
      is_layout               = wa_alv_presentation
      i_structure_name        = 'ZTYPFAC'
      IT_FIELDCAT             = t_catalogue_pv[]
    TABLES
      T_OUTTAB                = wlt_final
    EXCEPTIONS
      PROGRAM_ERROR           = 1
      OTHERS                  = 2.

My Usercommand :

FORM USER_COMMAND USING F_UCOMM LIKE SY-UCOMM
                I_SELFIELD TYPE SLIS_SELFIELD.

  DATA: F_SUBRC LIKE SY-SUBRC,
        s_final like wls_final.

  READ TABLE wlt_final INDEX i_selfield-tabindex INTO s_final.
  break epetrini.
  CASE F_UCOMM.
    WHEN '&IC1'.
      CASE i_SELFIELD-SEL_TAB_FIELD.
        WHEN 'wlt_final-BELNR'.
          "CHECK NOT wlt_final-BELNR IS INITIAL.
          SET PARAMETER ID 'BLN' FIELD s_final-BELNR.
          SET PARAMETER ID 'BUK' FIELD s_final-BUKRS.
          SET PARAMETER ID 'GJR' FIELD s_final-GJAHR.
          CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
        WHEN 'wlt_final-VBELN'.
          "CHECK NOT wlt_final-BELNR IS INITIAL.
          SET PARAMETER ID 'VF' FIELD s_final-VBELN.
          CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN.
      ENDCASE.
    when '&DATA_SAVE'.
         data : wls_ZTYPFAC2 type ZTYPFAC2.
         break epetrini.
         loop at wlt_final into s_final where flag <> '' or MAJ = 'X'.
              clear wls_ZTYPFAC2.
              select single * from ZTYPFAC2 into wls_ZTYPFAC2 where VBELN = s_final-VBELN and BELNR = s_final-BELNR and MAJ = 'X'.
                if sy-subrc = 0.
                    update ZTYPFAC2
                    set FLAG  = s_final-FLAG
                        COMM  = s_final-COMM
                        uname = sy-uname
                        datem = sy-datum
                    where VBELN = s_final-VBELN and BELNR = s_final-BELNR.
                else.
                    wls_ZTYPFAC2-flag  = s_final-flag.
                    wls_ZTYPFAC2-VBELN = s_final-VBELN.
                    wls_ZTYPFAC2-BELNR = s_final-BELNR.
                    wls_ZTYPFAC2-COMM  = s_final-COMM.
                    wls_ZTYPFAC2-uname = sy-uname.
                    wls_ZTYPFAC2-datem = sy-datum.
                    wls_ZTYPFAC2-MAJ   = 'X'.
                    insert into ZTYPFAC2 values wls_ZTYPFAC2.
                endif.
         endloop.
  ENDCASE.
ENDFORM.                    "USER_COMMAND

i use the User command for modify the different line of my ALV but when i do my Update i can't get only the line of the ALV which have changed !

Thank you very much for your answer

Edited by: Emilien P. on Sep 14, 2010 9:33 AM

3 REPLIES 3

Former Member
0 Kudos

Hi,

In your user command write the following code :


*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*

FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
        RS_SELFIELD TYPE SLIS_SELFIELD.

  DATA : REF_GRID TYPE REF TO CL_GUI_ALV_GRID.

  DATA: L_VALID TYPE C.

*Code to reflect the changes done in the internal table

  IF REF_GRID IS INITIAL.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
      IMPORTING
        E_GRID = REF_GRID.
  ENDIF.

  IF NOT REF_GRID IS INITIAL.

    CALL METHOD REF_GRID->CHECK_CHANGED_DATA
      IMPORTING
        E_VALID = L_VALID.

  ENDIF.
"After calling the above method and FM you will get the changed data from ALV
  CASE SY-UCOMM.

    WHEN 'FCODE'.
    "Write your code here
   ENDCASE.
ENDFORM.

Thanks & Regards,

Rock.

0 Kudos

i try to put this code im m y usercommand.

I have no error but i don't understand how can i do for get the data changed the first module function return REF_GRID ( ) and the second return L_VALID = 'X'

thank you for your helps !

0 Kudos

This was the answer I was searching for, yesterday I didn't found anything.

It works perfectly, I user  REUSE_ALV_GRID_DISPLAY as a popup (specifying coordinates) and when I finished (by pushing OK button and not INTRO before) data was unchanged at internal table. With your method it changes correctly.

Good work !!!!!!