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

Grid multiple selection through chck box

suresh_kumar53
Participant
0 Likes
286

I have written the code for multiple selection in grid. I need to display orders of customers for which we have selected in grid. But am not getting the details of customers selected in grid. Please Verify the code below and do necessary changes.

Rewards guarented.

tables: kna1.

type-pools: slis.

data: begin of lt_kna1 occurs 0,

ch type char1,

kunnr type kunnr,

name1 type name1,

land1 type land1,

end of lt_kna1,

begin of lt_vbak occurs 0,

kunnr type kunnr,

vbeln type vbeln,

erdat type erdat,

ername type ername,

end of lt_vbak,

begin of lt_vbap occurs 0,

vbeln type vbeln,

posnr type posnr,

matnr type matnr,

charg type charg_d,

end of lt_vbap.

data: lt_fcat type slis_t_fieldcat_ALV,

ls_fcat type slis_fieldcat_ALV,

lt_fcat1 type slis_t_fieldcat_ALV,

ls_fcat1 type slis_fieldcat_ALV,

GS_LAYOUT TYPE SLIS_LAYOUT_ALV,

lv_repid type sy-repid,

gs_grid_set type lvc_s_glay.

lv_repid = sy-repid.

select-options: s_kunnr for kna1-kunnr.

select kunnr name1 land1 from kna1 into corresponding fields of

table lt_kna1

where kunnr in s_kunnr.

if not lt_knA1[] is initial.

select kunnr vbeln erdat ernam from vbak into table lt_vbak

for all entries in lt_kna1[]

where kunnr = lt_kna1-kunnr.

endif.

gs_grid_set-edt_cll_cb = 'X'.

gs_layout-box_fieldname = 'CH'.

gs_layout-no_input = 'X'.

gs_layout-colwidth_optimize = 'X'.

  • GS_LAYOUT-EDIT = 'X'.

ls_fcat-col_pos = 1.

Ls_fcat-fieldname = 'CH'.

Ls_fcat-tabname = 'LT_KNA1'.

Ls_fcat-input = 'X'.

Ls_fcat-outputlen = 1.

Ls_fcat-checkbox = 'X'.

Ls_fcat-edit = 'X'.

*GS_FIELDCAT_LN-NO_OUT = 'X'.

  • gs_fieldcat_ln-tech = 'X'.

APPEND Ls_fcat TO Lt_fcat.

CLEAR: LS_FCAT.

ls_fcat-col_pos = 2.

ls_fcat-fieldname = 'KUNNR'.

Ls_fcat-tabname = 'LT_KNA1'.

*ls_fcat-ref_fieldname = 'KUNNR'.

LS_FCAT-SELTEXT_M = 'KUNNR'.

APPEND LS_FCAT TO LT_FCAT.

CLEAR: LS_FCAT.

ls_fcat-col_pos = 3.

ls_fcat-fieldname = 'NAME1'.

Ls_fcat-tabname = 'LT_KNA1'.

*ls_fcat-ref_fieldname = 'NAME1'.

LS_FCAT-SELTEXT_M = 'NAME1'.

APPEND LS_FCAT TO LT_FCAT.

CLEAR: LS_FCAT.

ls_fcat-col_pos = 4.

ls_fcat-fieldname = 'LAND1'.

Ls_fcat-tabname = 'LT_KNA1'.

*ls_fcat-ref_fieldname = 'LAND1'.

LS_FCAT-SELTEXT_M = 'LAND1'.

APPEND LS_FCAT TO LT_FCAT.

CLEAR: LS_FCAT.

ls_fcat-col_pos = 1.

ls_fcat-fieldname = 'VBELN'.

LS_FCAT-SELTEXT_M = 'VBELN'.

APPEND LS_FCAT TO LT_FCAT1.

CLEAR: LS_FCAT.

ls_fcat-col_pos = 2.

ls_fcat-fieldname = 'ERDAT'.

LS_FCAT-SELTEXT_M = 'ERDAT'.

APPEND LS_FCAT TO LT_FCAT1.

CLEAR: LS_FCAT.

ls_fcat-col_pos = 3.

ls_fcat-fieldname = 'ERNAME'.

LS_FCAT-SELTEXT_M = 'ERNAME'.

APPEND LS_FCAT TO LT_FCAT.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = lv_repid

I_CALLBACK_PF_STATUS_SET = 'SET_PF'

I_CALLBACK_USER_COMMAND = 'UCOM1'

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

I_GRID_SETTINGS = gs_grid_set

IS_LAYOUT = gs_layout

IT_FIELDCAT = LT_FCAT

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = LT_KNA1

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

FORM set_pf USING lt_extab TYPE slis_t_extab.

SET PF-STATUS 'STANDARD'.

ENDFORM.

FORM UCOM1 USING r_ucomm TYPE sy-ucomm

ls_selfield TYPE slis_selfield.

DATA: LS_KNA1 LIKE LT_KNA1,

lt_kna1_l like lt_kna1 occurs 0.

case: r_ucomm.

when 'DISP'.

LOOP AT LT_KNA1 INTO LS_KNA1 where ch = 'X'.

append ls_kna1 to lt_kna1_l.

ENDLOOP.

endcase.

ENDFORM.

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
265

Your coding displays the field "CH" both as the selection box on the left AND as a editable checkbox on the first column. So i think the data input in the checkbox and the flag line selected clear each other

Remove the field "CH" from field catalog, it should work.

<i>*ls_fcat-col_pos = 1.

*Ls_fcat-fieldname = 'CH'.

*Ls_fcat-tabname = 'LT_KNA1'.

*Ls_fcat-input = 'X'.

*Ls_fcat-outputlen = 1.

*Ls_fcat-checkbox = 'X'.

*Ls_fcat-edit = 'X'.

**GS_FIELDCAT_LN-NO_OUT = 'X'.

    • gs_fieldcat_ln-tech = 'X'.

*APPEND Ls_fcat TO Lt_fcat.</i>

Regards

1 REPLY 1
Read only

RaymondGiuseppi
Active Contributor
0 Likes
266

Your coding displays the field "CH" both as the selection box on the left AND as a editable checkbox on the first column. So i think the data input in the checkbox and the flag line selected clear each other

Remove the field "CH" from field catalog, it should work.

<i>*ls_fcat-col_pos = 1.

*Ls_fcat-fieldname = 'CH'.

*Ls_fcat-tabname = 'LT_KNA1'.

*Ls_fcat-input = 'X'.

*Ls_fcat-outputlen = 1.

*Ls_fcat-checkbox = 'X'.

*Ls_fcat-edit = 'X'.

**GS_FIELDCAT_LN-NO_OUT = 'X'.

    • gs_fieldcat_ln-tech = 'X'.

*APPEND Ls_fcat TO Lt_fcat.</i>

Regards