Skip to Content
0
Sep 24, 2018 at 01:47 PM

enable check box selection without re-running the report

83 Views

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..

Attachments

aud2.jpg (185.5 kB)