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: 

checkbox in alv oops

Former Member
0 Kudos

hi friends,

i have a internal table which i displayed using oops alv concept i added a checkbox before each row ...now i need to capture each record which is selected by checkbox into a table.

thank u.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi friends,

any sugestions

thank u.

17 REPLIES 17

Former Member
0 Kudos

Hi

I send one program..U refer and copy and paste Exeute u have clear idea.

EX:

REPORT ZBA_CHKBOX_IN_OUTPUT NO STANDARD PAGE HEADING.

TYPE-POOLS: slis.

TABLES: ZPROGMENU.

DATA: FLAG VALUE 1,

SEL,

WA_PROG LIKE ZPROGMENU.

DATA: lt_progmenu like ZPROGMENU OCCURS 0 WITH HEADER LINE,

lt_progmenu1 like ZPROGMENU OCCURS 0 WITH HEADER LINE,

lt_progmenu2 TYPE TABLE OF ZPROGMENU.

DATA : lt_listheader TYPE slis_t_listheader.

DATA: ls_line TYPE slis_listheader.

DATA : gv_toutdt TYPE prps-post1,

gv_touttm TYPE prps-post1.

  • FOR ALV Display

DATA: gr_table TYPE REF TO cl_salv_table.

data: gr_funct type ref to cl_salv_functions.

data: gr_columns type ref to cl_salv_columns_table.

data: gr_column type ref to CL_SALV_COLUMN_table.

*****************TOP OF PAGE*****************************

TOP-OF-PAGE.

ULINE (135).

NEW-LINE.

WRITE : SY-VLINE, (3) TEXT-000 COLOR COL_HEADING,

SY-VLINE, (3) TEXT-001 COLOR COL_HEADING,

SY-VLINE, (20) TEXT-002 COLOR COL_HEADING,

SY-VLINE, (40) TEXT-003 COLOR COL_HEADING,

SY-VLINE, (40) TEXT-004 COLOR COL_HEADING,

SY-VLINE, (10) TEXT-005 COLOR COL_HEADING,

SY-VLINE.

NEW-LINE.

ULINE (135).

NEW-LINE.

*****************START OF SELECTION***********************

START-OF-SELECTION.

select * from ZPROGMENU INTO TABLE lt_progmenu.

DELETE lt_progmenu WHERE PROG IS INITIAL.

SORT lt_progmenu BY APPL TCODE PROG.

LOOP AT lt_progmenu.

PERFORM CHANGE_COLOR.

WRITE 😕 SY-VLINE,

SEL UNDER TEXT-000 AS CHECKBOX, 7 SY-VLINE,

(3) lt_progmenu-appl UNDER TEXT-001, SY-VLINE,

(20) lt_progmenu-tcode UNDER TEXT-002, SY-VLINE,

(40) lt_progmenu-prog UNDER TEXT-003, SY-VLINE,

(40) lt_progmenu-ltext UNDER TEXT-004, SY-VLINE,

(10) lt_progmenu-hit_rate UNDER TEXT-005, SY-VLINE.

ENDLOOP.

NEW-LINE.

WRITE: SY-ULINE(135).

*******************END-OF-SELECTION**************************

END-OF-SELECTION.

SET PF-STATUS 'GUISTAT'.

SET TITLEBAR 'ACN'.

AT USER-COMMAND.

CASE SY-UCOMM .

WHEN 'DISPLAY'.

DO.

CLEAR SEL.

CLEAR WA_PROG.

READ LINE SY-INDEX FIELD VALUE

SEL INTO SEL

lt_progmenu-appl INTO WA_PROG-APPL

lt_progmenu-tcode INTO WA_PROG-tcode

lt_progmenu-PROG INTO WA_PROG-PROG

lt_progmenu-ltext INTO WA_PROG-ltext

lt_progmenu-hit_rate INTO WA_PROG-hit_rate.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

IF SEL = 'x' OR SEL = 'X'.

MOVE-CORRESPONDING WA_PROG TO lt_progmenu1.

APPEND lt_progmenu1.

ENDIF.

ENDDO.

ENDCASE.

IF NOT lt_progmenu1 IS INITIAL.

lt_progmenu2[] = lt_progmenu1[].

TRY.

CALL METHOD cl_salv_table=>factory

IMPORTING

r_salv_table = gr_table

CHANGING

t_table = lt_progmenu2.

CATCH cx_salv_msg .

ENDTRY.

gr_table->display( ).

ENDIF.

CLEAR: SEL,lt_progmenu,lt_progmenu1,lt_progmenu2.

REFRESH: lt_progmenu,lt_progmenu1,lt_progmenu2.

&----


*& Form CHANGE_COLOR

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form CHANGE_COLOR .

IF FLAG = 1.

FORMAT COLOR 2 INTENSIFIED ON.

FLAG = 2.

ELSE.

FORMAT COLOR 2 INTENSIFIED OFF.

FLAG = 1.

ENDIF.

endform. " CHANGE_COLOR

Former Member
0 Kudos

hi friends,

any sugestions

thank u.

0 Kudos

Hi,

You can use the method CHECK_CHANGED_DATA of class CL_GUI_ALV_GRID.

There are 2 ways to use this:

1. Calling this method directly will update the internal table that you have passed for display with the changed values.

2. You can implement this method in your program and then check the table MT_MODIFIED_CELLS which contains all the records that are modified on the screen... Check the structure of the table in class CL_GUI_ALV_GRID_BASE which is super class for CL_GUI_ALV_GRID.

Hope this solves your problem.

Regards,

Kunjal

0 Kudos

hi kunjal,

can u tell me the exact code bcoz i tried this also

thank u

0 Kudos

Hi,

Which class you are using for displaying the data on screen using OOPS concept..?

Which way you wish to go the 1st or 2nd?

BR

Kunjal

0 Kudos

hi,

i am using set_screen_for_first_display

0 Kudos

hi,

SET_TABLE_FOR_FIRST_DISPLAY

0 Kudos

I suppose you are using CL_GUI_ALV_GRID.

for the 1st option..

In PAI, you can directly write as

CALL <class_ref>-CHECK_CHANGED_DATA( ).

This will solve your problem. After the execution of this statement. The internal table used in the method set_screen_for_first_display to display data will be updated.

2nd method,

You can check the given link below, it has the code that you need to implement.

[Link to implement CHECK_CHANGED_DATA locally in code|;

BR

Kunjal

0 Kudos

HI KUNJAL,

I WIL TRY IT AND COME BACK TO U

THANK U

0 Kudos

*

HI KUNJAL,

CALL METHOD GRID2->CHECK_CHANGED_DATA

IMPORTING

E_VALID = V.

CHANGING

C_REFRESH = 'X'.

IS IT CORECT

0 Kudos

Try using it this way....

CALL METHOD GRID2->CHECK_CHANGED_DATA
IMPORTING
E_VALID = V.

BR

Kunjal

0 Kudos

yah i did the same ... now the changes will b reflected to the table which i passed in set_table_firs_table_display

0 Kudos

So, After this statement you can use the

LOOP AT ITAB INTO WA WHERE <check_box> = 'X'.

**Do your processing here...

ENDLOOP.

I think this is what you want to do... if i am mistaken then do let me know..

BR

Kunjal

0 Kudos

ok ok i willtry this

0 Kudos

HI KUNJAL,

THANKS A LOT MY PROBLEM IS SOLVED

THANK U

Former Member
0 Kudos

Hi,

Do like this....



call method g_grid->check_changed_data
              importing
                 e_valid = l_valid.

  if l_valid eq 'X'.
    call method g_grid->get_selected_rows
      importing
         et_row_no     = lt_row_no[].

    loop at lt_row_no.
       read table pt_outtab into ls_outtab index lt_row_no-row_id.
       if ls_outtab-checkbox ne '-'.
         ls_outtab-checkbox = '-'.
       else.
         ls_outtab-checkbox = ' '.
       endif.
       modify pt_outtab from ls_outtab index lt_row_no-row_id.

    endloop.

    call method g_grid->refresh_table_display.

Hope it will helps

Former Member
0 Kudos

hi urmila t,

Could you please send the code of how you created an alv with checkbox using oop concept. please i really need it.

plsssssssssss.

ricky.