Application Development and Automation 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: 
Read only

ALV issue

Former Member
0 Likes
965

Hi All,

I have displayed the list through REUSE_ALV_GRID_DISPLAY, the first field I have added a check box in the internal table, now I want to select the line by selecting the check box and save in the internal table for further processing.

How I can do it?

Thanx

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
926

Hi Dharmendra Pewa,

Try the following:

DATA: ref_grid TYPE REF TO cl_gui_alv_grid.

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.

ENDIF.

This will update the check box in the internal table.

Hope this information is help to you.

Regards,

José

7 REPLIES 7
Read only

Former Member
0 Likes
926

while populating FIELDCATALOG follow this code:

WA_FCAT-SELTEXT_L = 'Select'.

WA_FCAT-COL_POS = '1'.

WA_FCAT-FIELDNAME = 'CHECK'.

WA_FCAT-CHECKBOX = 'X'.

WA_FCAT-TABNAME = 'ITAB'.

WA_FCAT-OUTPUTLEN = '6'.

WA_FCAT-INPUT(1) = 'X'.

WA_FCAT-EDIT(1) = 'X'.

APPEND WA_FCAT TO FCAT.

CLEAR WA_FCAT.

Regards,

SAKTHIVEL.VT

Read only

0 Likes
926

I have done this all, but when I try to access the itab it is not being updated.

Read only

Former Member
0 Likes
926

Hi,

You will need to have the name of the variable defined in your internal table for the checkbox same as the new field that you will add through the fieldcatalog as mentioned in the previous post. Now you need to do some processing on the records selected through the checkbox. You must be doing so on the click of a button or so. You will have to define a subroutine say USER_COMMAND and pass the same to the parameter I_CALLBACK_USER_COMMAND in the FM REUSE_ALV_GRID_DISPLAY and inside this subroutine, you can use the code

loop at <internal table> where <checkbox fieldname> = 'X'.

do processing

endloop.

If you are allowing processing on only onle record at a time you can replace the loop with read statement.

Hope this helps

Regards

Sachin

Read only

sarbajitm
Contributor
0 Likes
926

Hi,

Suppose you have a custom button in your toolbar and after selecting some of the rows using checkbox you want to click that button in order to carry on further processing.If the scenario like this then

1)create PF-STATUS at first and set it in your ALV display

by setting the parameter i_callback_pf_status_set = 'PF_STATUS_SET' (in this way where 'PF_STATUS_SET' is the name of a subroutine)(search to learn how to create custom PF-STATUS from a standard one )

write the subroutine in this way

FORM pf_status_set USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'ZSTANDARD' OF PROGRAM 'ZSAR_ASSGN1_GRIDALV'.

ENDFORM. "pf_status_set

2) also set the parameter i_callback_user_command = 'USER_COMMAND'

USER_COMMAND is also an subroutine

write this subroutine in the following way

FORM user_command USING I_r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield

WHEN '&XZZ'.

CLEAR l_cntr.

LOOP AT IT_final INTO WA_final.

IF WA_final-chk = 'X'."CHK is the name of the checkbox

l_cntr = l_cntr + 1.

ENDIF.

ENDLOOP.

IF l_cntr GT 1.

" Perform the task here

ENDIF.

ENDFORM.

Regards.

Sarbajit.

Read only

Former Member
0 Likes
927

Hi Dharmendra Pewa,

Try the following:

DATA: ref_grid TYPE REF TO cl_gui_alv_grid.

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.

ENDIF.

This will update the check box in the internal table.

Hope this information is help to you.

Regards,

José

Read only

venkat_o
Active Contributor
0 Likes
926

Hi Dharmendra, Try this sample program. It works for you.

REPORT  ZTEST_NOTEPAD.
DATA: BEGIN OF IT_NFAL OCCURS 0,
        CHECK TYPE C,
        EINRI TYPE NFAL-EINRI,
        FALNR TYPE NFAL-FALNR,
        FALAR TYPE NFAL-FALAR,
      END OF IT_NFAL.
TYPE-POOLS:SLIS.
DATA:IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
     WA_FIELDCAT LIKE LINE OF IT_FIELDCAT.
DEFINE FIELDCAT.
  WA_FIELDCAT-FIELDNAME = &1.
  WA_FIELDCAT-TABNAME   = &2.
  WA_FIELDCAT-SELTEXT_M = &3.
  WA_FIELDCAT-CHECKBOX  = &4.
  WA_FIELDCAT-INPUT     = &5.
  WA_FIELDCAT-HOTSPOT   = &6.
  APPEND WA_FIELDCAT TO IT_FIELDCAT.
  CLEAR  WA_FIELDCAT.
END-OF-DEFINITION.

START-OF-SELECTION.
SELECT * FROM NFAL INTO CORRESPONDING FIELDS OF TABLE IT_NFAL UP TO 100 ROWS.
  FIELDCAT: 'CHECK' 'IT_NFAL' 'CHECK'  'X' 'X' 'X',
            'EINRI' 'IT_NFAL' 'EINRI'  ''  ''  '',
            'FALNR' 'IT_NFAL' 'FALNR'  ''  ''  '',
            'FALAR' 'IT_NFAL' 'FALAR'  ''  ''  ''.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM       = SY-REPID
      I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
      IT_FIELDCAT              = IT_FIELDCAT
    TABLES
      T_OUTTAB                 = IT_NFAL.
*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.
  IF r_ucomm = '&IC1'.
    IT_NFAL-CHECK = 'X'.
    MODIFY IT_NFAL INDEX RS_SELFIELD-TABINDEX TRANSPORTING CHECK..
    rs_selfield-refresh = 'X'. "This variable refreshes the data displayed in ALV
  ENDIF.
ENDFORM.                    "USER_COMMAND
Thanks Venkat.O

Read only

Former Member
0 Likes
926

hi dharmendra ,

Refer to this link's sample program

1. have a pramter in the selection screen for variant.

PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT.

2.

G_SAVE = 'A'.
CLEAR G_VARIANT.
G_VARIANT-REPORT = G_REPID.
* Get default variant
GX_VARIANT = G_VARIANT.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
I_SAVE = G_SAVE
CHANGING
CS_VARIANT = GX_VARIANT
EXCEPTIONS
NOT_FOUND = 2.
IF SY-SUBRC = 0.
P_VARI = GX_VARIANT-VARIANT.
ENDIF.
* Process on value request
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
IS_VARIANT = G_VARIANT
I_SAVE = G_SAVE
* it_default_fieldcat =
IMPORTING
E_EXIT = G_EXIT
ES_VARIANT = GX_VARIANT
EXCEPTIONS
NOT_FOUND = 2.
IF SY-SUBRC = 2.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
IF G_EXIT = SPACE.
P_VARI = GX_VARIANT-VARIANT.
ENDIF.
ENDIF.


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_BACKGROUND_ID = 'ALV_BACKGROUND'
I_CALLBACK_PROGRAM = G_REPID
I_STRUCTURE_NAME = 'SFLIGHT'
IS_LAYOUT = GS_LAYOUT
IT_FIELDCAT = GT_FIELDCAT[]
* IT_EXCLUDING =
IT_SPECIAL_GROUPS = GT_SP_GROUP[]
IT_SORT = GT_SORT[]
* IT_FILTER =
* IS_SEL_HIDE =
* i_default = g_default
I_SAVE = G_SAVE
IS_VARIANT = G_VARIANT

-Thanks & Regards

Saurabh Goel