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: 

enable check box selection without re-running the report

former_member185116
Active Participant
0 Kudos

hello all,

i have developed an ALV report using CL_GUI_ALV_GRID,

when the end user select a check box and clicks AUDIT button in the application tool bar,

i am trying to save the particular checked record into a Z-Table, which is my requirement..

for that i have written my code as,

MODULE USER_COMMAND_0100 INPUT.

if ok_code is NOT INITIAL.

save_ok = ok_code.
clear ok_code.
endif.

case save_ok.

 when 'BACK'.

    CALL METHOD CL_GUI_CFW=>FLUSH.
    leave  TO SCREEN 0.

   when 'APPR'.

DATA: l_valid type c,
      lv_refresh   TYPE char01 VALUE 'X'.

      clear : l_valid.


CALL METHOD OBJ_ALVGRID1->check_changed_data

IMPORTING

e_valid = l_valid

CHANGING

c_refresh = lv_refresh.


data : lv_count.

clear : lv_count.


 loop at it_fin1 INTO wa_fin1 WHERE sel eq 'X'.

   lv_count = lv_count + 1.

 endloop.

if lv_count > 1.
   MESSAGE 'Please check only one row at a time'  TYPE 'E'.
 endif.

 READ TABLE it_fin1 INTO wa_fin1 with key sel = 'X'.
  if sy-subrc = 0.

   wa_aud-hkont = wa_fin1-hkont.

   wa_aud-gsber = wa_fin1-gsber.

   wa_aud-base = wa_fin1-base.

   wa_aud-cgst = wa_fin1-cgst.

   wa_aud-sgst = wa_fin1-sgst.

   wa_aud-igst = wa_fin1-igst.

   wa_aud-total = wa_fin1-total.

   wa_aud-belnr = wa_fin1-belnr.      "accounting document no

   wa_aud-gjahr = wa_fin1-gjahr.      "accounting document year

   wa_aud-bldat = wa_fin1-bldat.

   wa_aud-budat = wa_fin1-budat.      "posting date

   wa_aud-xblnr = wa_fin1-xblnr.      "reference
   wa_aud-buzei = wa_fin1-buzei.

   wa_aud-buzid = wa_fin1-buzid.

   wa_aud-txgrp = wa_fin1-txgrp.

   wa_aud-bschl = wa_fin1-bschl.    "40 or 50 only

   wa_aud-koart = wa_fin1-koart.   "S = G/L accounts , D = customers

   wa_aud-shkzg = wa_fin1-shkzg.

   wa_aud-mwskz = wa_fin1-mwskz.     "tax code
   wa_aud-kunnr = wa_fin1-kunnr.

   wa_aud-name1 = wa_fin1-name1.

   wa_aud-gstno = wa_fin1-gstno.

   wa_aud-regio = wa_fin1-regio.

   wa_aud-rtext  = wa_fin1-rtext.

   wa_aud-panno  = wa_fin1-panno.



   wa_aud-SEL  = wa_fin1-sel.




   INSERT INTO ZCUST_AUDIT VALUES wa_aud.

*     modify ZCUST_AUDIT FROM wa_aud.

   commit WORK.

  endif.
endcase.
ENDMODULE.                 " USER_COMMAND_0100  INPUT

here everything is working fine , only problem is when the user selects(check box in row1) row one and clicks audit button corresponding record is getting saved in Z-table, however when the user deselects first row and selects a new row(like 2nd row)and clicks audit button the record is not getting saved unless i re-run the report by going back and pressing F8..

how do i save the record with out re-run the report again and again..

please suggest me a suitable solution,

thanks in advance..

5 REPLIES 5

0 Kudos

Try to put a breakpoint in your code and see if it's beeing called correctly every time.

0 Kudos

method check->changed->data is getting called but the control not going inside the method, where as for the first time the control is going inside the method..

0 Kudos

Try it (do oly one time):

OBJ_ALVGRID1->register_edit_event( cl_gui_alv_grid=>mc_evt_modified ).
OBJ_ALVGRID1->register_edit_event( cl_gui_alv_grid=>MC_EVT_ENTER ).

Where I found

jitendra_it
Active Contributor
0 Kudos

Clear the check box from entries once AUDIT button is pressed. It will also help user to save time from deselecting them and selecting the new entries' checkbox.

SimoneMilesi
Active Contributor
0 Kudos

The question you should ask yourself is "why the 2nd record is not saved?" and you can check the answer in debug.

Surely clearing the checkbox after the save is successful would help the user.

Like disabling the single checkbox the user already saved to avoid them to save over and over the same record.

And you should refresh the alv after your PF.