Selecting multiple rows in ALV
Hi Experts,
I am using REUSE_ALV_GRID_DISPLAY FM in my program for my ALV output . I need to select multiple rows and will click a custom button on the appln toolbar. How can I know which all rows are selected? Please help.
Many Thanks,
Neeraj
Hi,
Try this way.
<font color=blue><pre>
REPORT ztest_alv_row_selection.
DATA: BEGIN OF it_output OCCURS 0,
select TYPE c, <font color=red>"This variable stores the value when row selected.</font>
bukrs TYPE t001-bukrs,
butxt TYPE t001-butxt,
END OF it_output.
TYPE-POOLS:slis.
DATA:it_events TYPE STANDARD TABLE OF slis_alv_event,
it_fieldcat TYPE STANDARD TABLE OF slis_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
wa_events TYPE slis_alv_event,
wa_layout TYPE slis_layout_alv.
DATA:g_program TYPE sy-repid VALUE sy-repid.
START-OF-SELECTION.
SELECT * FROM t001 INTO CORRESPONDING FIELDS OF TABLE it_output UP TO 100 ROWS.
DEFINE fieldcatalog.
wa_fieldcat-fieldname = &1.
wa_fieldcat-tabname = &2.
wa_fieldcat-seltext_l = &3.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
END-OF-DEFINITION.
fieldcatalog: "Column table col text
'BUKRS' 'IT_OUTPUT' 'BUKRS',
'BUTXT' 'IT_OUTPUT' 'BUTXT'.
wa_layout-box_fieldname = 'SELECT'. <font color=red> "This has to be set to get selection</font>
wa_layout-colwidth_optimize = 'X'.
wa_events-name = 'PF_STATUS_SET'.
wa_events-form = 'PF_STATUS_SET'.
APPEND wa_events TO it_events.
CLEAR wa_events.
wa_events-name = 'USER_COMMAND'.
wa_events-form = 'USER_COMMAND'.
APPEND wa_events TO it_events.
CLEAR wa_events.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_program
is_layout = wa_layout
it_fieldcat = it_fieldcat
it_events = it_events
TABLES
t_outtab = it_output.
*& Form PF_STATUS_SET
FORM pf_status_set USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZTEST'.
1. When you set Pf status ZTEST, standard application tools will be removed.
2. Goto SE41 give program 'SAPLKKBL' and status 'STANDARD_FULLSCREEN'.
3. Copy the status from those to ZTEST of our program. Now you will see all standard functions.
ENDFORM. "PF_STATUS_SET
FORM USER_COMMAND *
FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.
Check function code
CASE r_ucomm.
WHEN 'DISPLAY'. "user presses SAVE
LOOP AT it_output.
IF it_output-select EQ 'X'.
Process records that have been selected
WRITE:/ it_output.
ENDIF.
ENDLOOP.
ENDCASE.
ENDFORM. "user_command</pre></font>
Thanks
Venkat.O
Similar Messages
-
How to select multiple row in ALV report
Hi friends,
1. How to select multiple row in ALV report
( How to set tab in ALV report and want to select multiple line.)
Thanking you.
SubashHi Sahoo,
If you are using the class CL_GUI_ALV_GRID. In methods SET_TABLE_FOR_FIRST_DISPLAY.
in layout structure you will find field SEL_MODE
pass :
LS_LAYOUT-SEL_MODE = 'A'.
In PAI.
CALL METHOD GRID->GET_SELECTED_ROWS
IMPORTING
ET_INDEX_ROWS = T_ROWS
ET_ROW_NO = T_ROWID.
Hope these will solve your problem.
Regards,
Kumar M. -
Selecting Multiple Rows from ALV GRID Display
Hi,
I am having a ALV GRID Display. I want to select multiple rows from the Output and move them to an internal table.
Please let me know how do I acheive this.
Thanks in advance,
Ishaq.Hi,
Have a look on the following code. It displays the selected rows which hv been selected in basic list.
TABLES:
spfli.
TYPE-POOLS:
slis.
DATA:
BEGIN OF t_spfli OCCURS 0,
checkbox.
INCLUDE STRUCTURE spfli.
DATA: END OF t_spfli.
DATA:
t_sspfli LIKE STANDARD TABLE OF t_spfli .
DATA:
fs_spfli LIKE LINE OF t_sspfli.
DATA:
fs_layout TYPE slis_layout_alv,
w_program TYPE sy-repid.
SELECT *
FROM spfli
INTO CORRESPONDING FIELDS OF TABLE t_spfli.
*fs_layout-info_fieldname = 'COLOR'.
fs_layout-box_fieldname = 'CHECKBOX'.
w_program = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = w_program
i_callback_pf_status_set = 'FLIGHT'
i_callback_user_command = 'SPFLI_INFO'
i_structure_name = 'SPFLI'
is_layout = fs_layout
TABLES
t_outtab = t_spfli
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 FLIGHT
text
-->RT_EXTAB text
FORM flight USING rt_extab TYPE slis_t_extab..
SET PF-STATUS 'FLIGHT' EXCLUDING rt_extab.
ENDFORM. "FLIGHT
*& Form SPFLI_INFO
text
-->UCOMM text
-->SELFIELD text
FORM spfli_info USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
selfield-refresh = 'X'.
CASE ucomm.
WHEN 'FLIGHT'.
LOOP AT t_spfli.
IF t_spfli-checkbox = 'X'.
t_spfli-checkbox = ' '.
t_spfli-color = 'C51'.
MODIFY t_spfli TRANSPORTING checkbox.
fs_spfli = t_spfli.
APPEND fs_spfli TO t_sspfli.
ENDIF.
ENDLOOP.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
CLEAR fs_spfli.
fs_layout-info_fieldname = 'COLOR'.
fs_layout-confirmation_prompt = 'X'.
fs_layout-key_hotspot = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = w_program
i_structure_name = 'SFLIGHT'
is_layout = fs_layout
TABLES
t_outtab = t_sspfli
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.
REFRESH t_sspfli.
ENDFORM. "SPFLI_INFO
Regards,
Chandu -
Selecting multiple rows in ALV grid display
Hi,
I have an ALV grid display in my report.
My grid contains multiple rows.
I have to select multiple rows at a time, to perform some operations on the selected rows.
How can it be achieved?
Thanks,
Sandeep.Hi ,
you have to use a box fieldname in the report to be able to select multiple lines at a time :
- in your internal table declaration put the first field as 'box_fieldname' of type c1
- then in your work area for layout add, lwa_layout-box_fieldname = 'box_fieldname'
- in the perform for handling user commands, all selected lines will have an "X" in the field name 'box_fieldname'
Thanks and Regards,
Dev. -
Selecting multiple rows in alv grid
my requirement is i want to send the data from alv grid to smartforms using check boxes from report output but without using either oo framework or layout-box_fieldname.can anybody give me the solution?
in fieldcatalog you have to use CHECKBOX = 'X' INPUT = 'X' and EDIT = 'X' for the columns which ever you want to be check box .
You need use the Function moduel in the user command to get the updated data with checked value.
GET_GLOBALS_FROM_SLVC_FULLSCR
follow the sample code.
REPORT ZTEST_ALV_CHECK MESSAGE-ID ZZ .
TYPE-POOLS: SLIS.
DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
L_LAYOUT TYPE SLIS_LAYOUT_ALV,
X_EVENTS TYPE SLIS_ALV_EVENT,
IT_EVENTS TYPE SLIS_T_EVENT.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
CHK(1),
color(4),
END OF ITAB.
SELECT VBELN
POSNR
FROM VBAP
UP TO 20 ROWS
INTO TABLE ITAB.
X_FIELDCAT-FIELDNAME = 'CHK'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 1.
X_FIELDCAT-INPUT = 'X'.
X_FIELDCAT-EDIT = 'X'.
X_FIELDCAT-CHECKBOX = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-SELTEXT_L = 'VBELN'.
X_FIELDCAT-HOTSPOT = 'X'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 2.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-SELTEXT_L = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 3.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_LAYOUT-info_fieldname = 'COLOR'.
*L_LAYOUT-ZEBRA = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = L_LAYOUT
I_CALLBACK_PF_STATUS_SET = 'STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FIELDCAT
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
FORM STATUS USING P_EXTAB TYPE SLIS_T_EXTAB.
"Copy the standard program SAPLKKBL , STANDARD status to your program
SET PF-STATUS 'STATUS'.
ENDFORM. " STATUS
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
DATA: GD_REPID LIKE SY-REPID, "Exists
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.
loop at itab where chk = 'X'.
"collect all the records to an internal table here..
endloop.
"Now call your smartform here using SSFFunction module and the get the dynamic function . From there call the Function with the selected values, to show the smartform
RS_SELFIELD-refresh = 'X'.
break-point.
ENDFORM. "USER_COMMAND
Regards
Vijay Babu Dudla -
How to capture multiple rows of ALV grid when user selected?
Actually,It is easy to get one single line.However, my user wants select several lines of ALV grid by condition . i need to process the selected lines ,so i need to put these lines into an internal table. But now, i have no idea to capture the lines.
What method for an ALV Grid will return the lines the user has selected?
Appreciate for your help!
Edited by: Heyman52 on Aug 25, 2010 4:28 AM
Edited by: Heyman52 on Aug 25, 2010 4:30 AMHi,
Once user selects multiple rows and press another button for further execution, you can modify your internal table with marked rows using selection column.
You need to add user command code in your ALV grid call. Please refer below code.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'F_GUI_STATUS'
I_CALLBACK_USER_COMMAND = 'F_USERCOMMAND'
I_GRID_TITLE = TEXT-026
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = I_FIELDCAT
TABLES
T_OUTTAB = I_OUTTAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC NE 0.
MESSAGE S475 DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
*- User command for details display.
PERFORM F_USERCOMMAND USING I_UCOMM
I_SELFIELD.
FORM F_USERCOMMAND USING FP_R_UCOMM LIKE SY-UCOMM
FP_SELFIELD TYPE SLIS_SELFIELD.
IF L_V_REF_GRID IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = L_V_REF_GRID.
ENDIF.
IF NOT L_V_REF_GRID IS INITIAL.
CALL METHOD L_V_REF_GRID->CHECK_CHANGED_DATA.
ENDIF.
ENDFORM.
You can then read your final internal table as below and take the selected records in another internal table.
LOOP AT I_OUTTAB ASSIGNING <FS_OUTTAB> WHERE SEL EQ 'X'.
APPEND <FS_OUTTAB> TO I_CHECK.
ENDLOOP.
Edited by: Archana Pawar on Aug 25, 2010 11:16 AM -
How to apply List box for multiple selection of rows in ALV report ?
Hi Exprots,
1: How to apply List box for multiple selection of rows in ALV report ?
Thanking you.
Subashhi,
check the below program.
REPORT zalv_dropdowns.
*Type pools declarations for ALV
TYPE-POOLS : slis.
*data declarations for ALV container,ALV grid, Fieldcatalogues & layout
DATA: g_grid TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
gt_fieldcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo.*INTERNAL TABLE AND WA DECLARATIONS FOR t517 A table
DATA: gt_outtab TYPE STANDARD TABLE OF t517a INITIAL SIZE 0,
wa_outtab TYPE t517a.
START-OF-SELECTION.*Call to ALV
CALL SCREEN 600.*On this statement double click it takes you to the screen painter SE51.
*Create a Custom container and name it CCONT and OK code as OK_CODE.
*Save check and Activate the screen painter.
*Now a normal screen with number 600 is created which holds the ALV grid.
PBO of the actual screen , Here we can give a title and customized menus
Here we also call the subroutine for ALV output.
MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
PERFORM alv_output.
ENDMODULE. "pbo OUTPUT
MODULE PAI INPUT *
MODULE pai INPUT.
ENDMODULE. "pai INPUT
*& Form BUILD_FIELDCAT
FORM build_fieldcat.
DATA ls_fcat TYPE lvc_s_fcat.
*Build the field catalogue
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'T517A'
CHANGING
ct_fieldcat = gt_fieldcat.
To assign dropdown in the fieldcataogue
LOOP AT gt_fieldcat INTO ls_fcat.
CASE ls_fcat-fieldname.
WHEN 'SLART'.
*is the first list box
ls_fcat-drdn_hndl = '1'.
ls_fcat-outputlen = 15.
MODIFY gt_fieldcat FROM ls_fcat.
is the second list box
WHEN 'ABART'.
ls_fcat-drdn_hndl = '2'.
ls_fcat-outputlen = 15.
MODIFY gt_fieldcat FROM ls_fcat.
ENDCASE.
ENDLOOP.
ENDFORM. "build_fieldcat
*& Form ALV_OUTPUT
FORM alv_output .*Create object for container
CREATE OBJECT g_custom_container
EXPORTING container_name = 'CCONT'.
*create object for grid
CREATE OBJECT g_grid
EXPORTING i_parent = g_custom_container.
Build fieldcat and set column
*Assign a handle for the dropdown listbox.
PERFORM build_fieldcat.
*Build layout
PERFORM build_layout.
Define a drop down table.
PERFORM dropdown_table.
*fetch values from the T517A table
SELECT * FROM t517a INTO TABLE gt_outtab.
*Display ALV output
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_fieldcatalog = gt_fieldcat
it_outtab = gt_outtab.ENDFORM. "ALV_OUTPUT
*& Form dropdown_table
text
--> p1 text
<-- p2 text
FORM dropdown_table.*Declarations for drop down lists in ALV.
DATA: lt_dropdown TYPE lvc_t_drop,
ls_dropdown TYPE lvc_s_drop.
First SLART listbox (handle '1').
ls_dropdown-handle = '1'.
ls_dropdown-value = '01 Primary school'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '1'.
ls_dropdown-value = '02 Lower Secondary'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '1'.
ls_dropdown-value = '03 Upper Secondary'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '04 Professional School'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '05 College'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '06 University'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '09 Other Establishment'.
APPEND ls_dropdown TO lt_dropdown.* Second ABART listbox (handle '2'). ls_dropdown-handle = '2'.
ls_dropdown-value = '10 Primary School certificate'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '20 Lower secondary/Junior high'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '30 High school diploma(B-levels)'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '31 Vocational'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '32 Matriculation'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '40 Specialist vocational certificate'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '50 College degree Level1'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '51 College degree Level2'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '52 Masters degree'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '60 Univ Degree level1'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '61 Bachelors degree'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '62 Masters degree'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '63 Licenciate'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '64 Doctors Degree Ph.D'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '89 None'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '90 Unknown'.
APPEND ls_dropdown TO lt_dropdown.*method to display the dropdown in ALV
CALL METHOD g_grid->set_drop_down_table
EXPORTING
it_drop_down = lt_dropdown.ENDFORM. " dropdown_table
*& Form build_layout
text
*layout for ALV output
FORM build_layout . gs_layout-cwidth_opt = 'X'.
gs_layout-grid_title = 'ALV DROPDOWN LISTS'.
gs_layout-no_toolbar = 'X'.ENDFORM. " build_layout
endform.
Edited by: S.r.v.r.Kumar on Jun 1, 2009 2:48 PM -
Selecting multiple rows of an alv
Hi All,
I have a requirement where in i have to select multiple rows of an alv and when i click a button i should get the data of all the selected rows, i am able to select only one row by default , how to select multiple rows or records,i am new to this Web dynpro alv , can aynbody please help me on this.
Thanks,
Praveen.hi, praveen kumar.
About how to make "Multiple-select" of ALV available, you can take a reference of the following coding. Just one example:
****ALV Config****
DATA:
lr_salv_wd_table TYPE REF TO iwci_salv_wd_table,
l_value TYPE REF TO cl_salv_wd_config_table,
lr_table_settings TYPE REF TO if_salv_wd_table_settings.
lr_salv_wd_table = wd_this->wd_cpifc_alv_child( ). "Your statically declared ALV component usage
l_value = lr_salv_wd_table->get_model( ).
* tabel setting
lr_table_settings ?= l_value .
lr_table_settings->set_selection_mode( cl_wd_table=>e_selection_mode-MULTI ).
About how to get your selected records of ALV, you can make use of the context node bound to your ALV component. For example,
****get selected elements****
lt_elems = lo_node->GET_SELECTED_ELEMENTS(
INCLUDING_LEAD_SELECTION = abap_true ).
These are just examples. For detail, you can search them.
Thanks.Best wishes. -
Selecting Multiple rows in an ALV
Hi Experts,
Using 'REUSE_ALV_GRID_DISPLAY' is it possible to select multiple rows, WITHOUT using CTRL OR SHIFT keys ?
thanks in advance.I have done an application for multiple selection in ALV using check box concept. Please find that code below.
*& Report ZATL_DELIVERY
REPORT zatl_delivery.
INCLUDE zatl_delivery_declarations.
SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln OBLIGATORY.
SELECTION-SCREEN END OF BLOCK a.
INITIALIZATION.
AT SELECTION-SCREEN.
START-OF-SELECTION .
SET PF-STATUS 'ABC'.
SET PF-STATUS 'BCD'.
get the sales order numbers thru given
selection-screen parameters
SELECT vbeln FROM vbak INTO TABLE it_data
WHERE vbeln IN s_vbeln.
AND ERDAT = P_DATE.
IF NOT it_data[] IS INITIAL.
SELECT vbeln vstel FROM vbap INTO TABLE it_vstel
FOR ALL ENTRIES IN it_data
WHERE vbeln = it_data-vbeln.
ENDIF.
LOOP AT it_data INTO wa_data.
CALL FUNCTION 'ZBAPI_GET_MATERIAL_PLANT_DTL'
EXPORTING
v_vbeln = wa_data-vbeln
TABLES
it_bapi = it_result.
LOOP AT it_result INTO wa_result.
READ TABLE it_vstel INTO wa_vstel WITH KEY
vbeln = wa_result-vbeln.
wa_final-vbeln = wa_result-vbeln. " SALES ORDER NO
wa_final-matnr = wa_result-matnr.
wa_final-vstel = wa_vstel-vstel.
wa_final-werks = wa_result-werks.
wa_final-labst = wa_result-kwmeng.
APPEND wa_final TO it_final.
CLEAR wa_result.
ENDLOOP.
REFRESH it_result.
CLEAR wa_data.
ENDLOOP.
PERFORM build_fldcat.
PERFORM disp_output.
*SET PF-STATUS 'ABC'.
*& Form ABC
text
-->EXTAB text
FORM abc USING extab TYPE slis_t_extab.
SET PF-STATUS 'ABC'. " excluding extab.
ENDFORM. "ABC
read
*& Form build_fldcat
text
--> p1 text
<-- p2 text
FORM build_fldcat .
wa_fldcat-col_pos = '1'.
wa_fldcat-fieldname = 'MARK'.
wa_fldcat-checkbox = 'X'.
wa_fldcat-edit = 'X'.
wa_fldcat-seltext_m = 'MARK'.
APPEND wa_fldcat TO i_fldcat.
CLEAR wa_fldcat.
wa_fldcat-col_pos = '2'.
wa_fldcat-fieldname = 'VBELN'.
wa_fldcat-tabname = 'IT_FINAL'.
wa_fldcat-seltext_m = 'SALES ORD NO'.
APPEND wa_fldcat TO i_fldcat.
wa_fldcat-col_pos = '3'.
wa_fldcat-fieldname = 'MATNR'.
wa_fldcat-tabname = 'IT_FINAL'.
wa_fldcat-seltext_m = 'MAT NO'.
APPEND wa_fldcat TO i_fldcat.
wa_fldcat-col_pos = '4'.
wa_fldcat-fieldname = 'WERKS'.
wa_fldcat-tabname = 'IT_FINAL'.
wa_fldcat-seltext_m = 'PLANT'.
APPEND wa_fldcat TO i_fldcat.
wa_fldcat-col_pos = '5'.
wa_fldcat-fieldname = 'LABST'.
wa_fldcat-tabname = 'IT_FINAL'.
wa_fldcat-seltext_m = 'QNTY'.
APPEND wa_fldcat TO i_fldcat.
ENDFORM. " build_fldcat
*& Form disp_output
text
--> p1 text
<-- p2 text
FORM disp_output .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'ABC'
it_fieldcat = i_fldcat
i_callback_user_command = 'CHECKED'
TABLES
t_outtab = it_final
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.
ENDFORM. " disp_output
*& Form CHECKED
text
-->R_UCOMM text
-->RS_SELFIELD text
FORM checked USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA: gd_repid LIKE sy-repid, "Exists
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.
CASE r_ucomm.
WHEN 'DELIVERY'.
IF rs_selfield-fieldname = 'MARK'.
DATA : date_external(10) TYPE c.
DATA: temp_date TYPE sy-datum.
temp_date = sy-datum.
temp_date = temp_date + 1.
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
date_internal = sy-datum
IMPORTING
date_external = date_external
EXCEPTIONS
date_internal_is_invalid = 1
OTHERS = 2.
LOOP AT it_final INTO wa_final WHERE mark EQ 'X'.
PERFORM bdc_dynpro USING 'SAPMV50A' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LV50C-VBELN'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LIKP-VSTEL'
wa_final-vstel. " 'HLL'.
PERFORM bdc_field USING 'LV50C-DATBI'
date_external. "
PERFORM bdc_field USING 'LV50C-VBELN'
wa_final-vbeln. " '34'.
PERFORM bdc_dynpro USING 'SAPMV50A' '0200'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LIPS-MATNR(02)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=SICH'.
PERFORM bdc_field USING 'LIKP-BLDAT'
date_external. " '19.09.2008'.
CLEAR date_external.
CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
EXPORTING
date_internal = temp_date
IMPORTING
date_external = date_external
EXCEPTIONS
date_internal_is_invalid = 1
OTHERS = 2.
PERFORM bdc_field USING 'LIKP-WADAT'
date_external ." '19.09.2008'.
CLEAR date_external.
PERFORM bdc_field USING 'LIKP-BTGEW'
wa_final-labst. " -'12'.
PERFORM bdc_field USING 'LIKP-GEWEI'
'wa_likp-GEWEI'.
PERFORM bdc_transaction USING 'VL01'.
PERFORM msg_get TABLES it_msg.
CLEAR wa_final.
REFRESH it_msg.
ENDLOOP.
PERFORM disp_msg.
ENDIF.
ENDCASE.
ENDFORM. "CHECKED
*& Form BDC_DYNPRO
text
-->P_0443 text
-->P_0444 text
FORM bdc_dynpro USING value(p_0443)
value(p_0444).
wa_bdc-program = p_0443.
wa_bdc-dynpro = p_0444.
wa_bdc-dynbegin = 'X'.
APPEND wa_bdc TO it_bdc.
CLEAR wa_bdc.
ENDFORM. " BDC_DYNPRO
*& Form BDC_FIELD
text
-->P_0448 text
-->P_0449 text
FORM bdc_field USING value(p_0448)
value(p_0449).
wa_bdc-fnam = p_0448.
wa_bdc-fval = p_0449.
APPEND wa_bdc TO it_bdc.
CLEAR wa_bdc.
ENDFORM. " BDC_FIELD
*& Form BDC_TRANSACTION
text
-->P_0508 text
FORM bdc_transaction USING value(p_0508).
CALL TRANSACTION p_0508 USING it_bdc
MODE 'N'
UPDATE 'S'
MESSAGES INTO it_msg.
ENDFORM. " BDC_TRANSACTION
*& Form msg_get
text
-->P_IT_MSG text
FORM msg_get TABLES p_it_msg STRUCTURE bdcmsgcoll.
LOOP AT p_it_msg INTO wa_msg.
v_msgid = wa_msg-msgid.
v_msgnr = wa_msg-msgnr.
v_msgv1 = wa_msg-msgv1.
v_msgv2 = wa_msg-msgv2.
v_msgv3 = wa_msg-msgv3.
v_msgv4 = wa_msg-msgv4.
IF wa_msg-msgtyp = 'E' OR
wa_msg-msgtyp = 'A' OR
wa_msg-msgtyp = 'X'.
PERFORM build_msg USING v_msgid
v_msgnr
v_msgv1
v_msgv2
v_msgv3
v_msgv4
CHANGING msg_text_e.
Build the text for successful records getting created
ELSEIF wa_msg-msgtyp = 'S' OR
wa_msg-msgtyp = 'W' OR
wa_msg-msgtyp = 'I'.
PERFORM build_msg USING v_msgid
v_msgnr
v_msgv1
v_msgv2
v_msgv3
v_msgv4
CHANGING msg_text_s.
ENDIF.
ENDLOOP.
ENDFORM. " msg_get
*& Form build_msg
text
-->P_V_MSGID text
-->P_V_MSGNR text
-->P_V_MSGV1 text
-->P_V_MSGV2 text
-->P_V_MSGV3 text
-->P_V_MSGV4 text
<--P_MSG_TEXT_E text
FORM build_msg USING p_v_msgid
p_v_msgnr
p_v_msgv1
p_v_msgv2
p_v_msgv3
p_v_msgv4
CHANGING p_msg_text_s.
CALL FUNCTION 'TB_MESSAGE_BUILD_TEXT'
EXPORTING
langu = sy-langu
msgid = p_v_msgid
msgno = p_v_msgnr " wa_msgcoll-msgnr
msgv1 = p_v_msgv1
msgv2 = p_v_msgv2
msgv3 = p_v_msgv3
msgv4 = p_v_msgv4
IMPORTING
text = p_msg_text_s.
wa_mess-v_msg = p_msg_text_s .
APPEND wa_mess TO i_mess.
CLEAR wa_mess.
ENDFORM. " build_msg
*& Form disp_msg
text
--> p1 text
<-- p2 text
FORM disp_msg .
PERFORM build_fieldcat_secandary.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'BCD'
it_fieldcat = i_fldcat1
i_callback_user_command = 'SECANDARY'
TABLES
t_outtab = i_mess
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.
ENDFORM. " disp_msg
*& Form build_fieldcat_secandary
text
--> p1 text
<-- p2 text
FORM build_fieldcat_secandary .
wa_fldcat1-col_pos = '1'.
wa_fldcat1-fieldname = 'V_MSG'.
wa_fldcat1-tabname = 'I_MESS'.
wa_fldcat1-seltext_m = 'MESSAGE'.
APPEND wa_fldcat1 TO i_fldcat1.
ENDFORM. " build_fieldcat_secandary
*& Form SECANDARY
text
-->R_UCOMM text
FORM secandary USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN 'BCK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDFORM. "SECANDARY
*& Form ABC
text
-->EXTAB text
FORM bcd USING extab TYPE slis_t_extab.
SET PF-STATUS 'BCD'. " excluding extab.
ENDFORM. "ABC
Hope this will help you,
Murthy. -
Multiple selection of rows in alv output list
experts,
using 'REUSE_ALV_GRID_DISPLAY'
the following is the sample code ,without using ctrl or shift key i am unable to select multiple rows .
any resolvable answers.
REPORT zpushbutton1.
type-pools : slis.
*structure declarations
types : begin of ty_mara,
matnr type matnr,
ernam type ernam,
mbrsh type mbrsh,
CHKBOX TYPE CHAR1,
end oF ty_mara.
types : begin of ty_marc,
matnr type matnr,
werks type werks_d,
pstat type pstat_d,
end of ty_marc.
*internal table declarations
DATA : gi_mara TYPE STANDARD TABLE OF TY_MARA INITIAL SIZE 0.
data : gi_fieldcat type slis_t_fieldcat_alv.
*workarea declarations
DATA : gs_mara TYPE TY_MARA,
gs_fieldcat type slis_fieldcat_alv.
SELECT matnr
ernam
mbrsh
FROM mara
INTO TABLE gi_mara
UP TO 10 ROWS.
perform build_fieldcat using :
'1' 'CHKBOX' 'GI_MARA' 'SELECT' 'X' ,
'2' 'MATNR' 'GI_MARA' 'MATEIRALNO' ' ',
'3' 'ERNAM' 'GI_MARA' 'PERSON CREAT' ' ',
'4' 'MBRSH' 'GI_MARA' 'INDUSTRY' ' '.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = GI_FIELDCAT
TABLES
t_outtab = GI_MARA
*& Form BUILD_FIELDCAT
form BUILD_FIELDCAT using
PCOL TYPE CHAR2
PFLDNAME TYPE CHAR10
PTABNAME TYPE CHAR10
PSELTEXT TYPE CHAR15
PINPUT TYPE CHAR1.
GS_FIELDCAT-COL_POS = PCOL.
GS_FIELDCAT-FIELDNAME = PFLDNAME.
GS_FIELDCAT-TABNAME = PTABNAME.
GS_FIELDCAT-SELTEXT_M = PSELTEXT.
GS_FIELDCAT-EDIT = PINPUT.
APPEND GS_FIELDCAT TO GI_FIELDCAT.
CLEAR GS_FIELDCAT.
endform. " BUILD_FIELDCAT
thanks and regardsexperts,
can we set cursor properties during the output display
ex : i have used function module reuse_alv_grid_display to display a list of records with passing parameter
is_layout-box_fieldname and is_layout-box_tabname to list the first column as pushbutton.
when i select a row ,gets selected now when i move the
cursor (mouse) to the other row and select the row, the row previously selected will be deselected.
solution to the above problem is to hold the ctrl or shift key for
multiple selections.
is there any other alternative procedure so that without holding
ctrl or shift key multiple rows get selected.
thks and rgrds -
Select Multiple Rows in a Table without CTRL
Expecting the user to press "Ctrl" when selecting multple rows is very unfriendly and unintuitive. We'd like the row selection to work as in ALV where you just select multiple rows by clicking on them.
We've set the tables rowSelectable to true and selectionMode to 'multi' but we still cannot select multiple rows without the CTRL hotkey.
This issue apparently [arose before|About selection in the table] but wasn't resolved.
System Details
SAP_ABA 701 0006 SAPKA70106
SAP_BASIS 701 0006 SAPKB70106
SAP_AP 700 0019 SAPKNA7019Hello Marc,
you need to call IF_WD_CONTEXT_NODE->set_selected(index = lv_index) sorry for the typo in my previous comment.
by calling IF_WD_CONTEXT_NODE->set_selected method wont remove the lead selection.
to unselect the records, you can call the same method by passing the FLAG value as abap_false.
so for your usecase the logic will be like this in the ON_SELECT event handler
1. get the index of the new_lead_selection
2. check whether this is already seleted in the context node by calling IF_WD_CONTEXT_NODE->IS_selected
3. if already selected then call IF_WD_CONTEXT_NODE->set_selected( flag = abap_false index = lv_index)
if not selected then call IF_WD_CONTEXT_NODE->set_selected( index = lv_index )
Hope this solved your problem.
BR, Saravanan
Edited by: Saraa_n on Jul 6, 2011 11:52 AM -
Select multiple rows in a grid
Hi All,
I want to select multiple rows in a grid on click of a button, there is no checkbox there are multiple rows which need to be selected like we do on pressing shift key on the keyboard. Please suggest how can this be done.
thanks in advance.
Regards,
AnjuHi Anju,
You can check this link to solve your problem:
https://wiki.sdn.sap.com/wiki/display/Snippets/ALV%2bGrid%2bDisplay%2bwith%2bcheckbox%2bto%2bprocess%2bselected%2brecords%2bat%2bruntime
Hope it helps you.
Thanks & Regards,
Sarita Singh Rathour -
How to select multiple records in ALV with out pressing ctrl
Hi Experts,
Is there a way to select multiple records in ALV with out pressing ctrl button on the key board?
Selection and deselection should allow multiple records.
any clue is highly appreciated.
regards,
AjayThe keyboard always plays a role, although with the Shift key you can select blocks of records.
○ CTRLclick, CTRLspacebar
Toggles a selection.
○ SHIFTclick, CTRLshift
Selects the area from the lead selection to the row selected. If no lead selection is set, the selection starts from the first row. In the multiNoLead mode, the selection starts from the row last selected -
How to select multiple rows from List Of Values
Hello,
I use ADF 11g to create my list of values (LOV). I want to select multiple rows from it. but i can't.
so how i can select many rows to set them in my adf table.
Thank in advanceHi,
LOV is map to an attribute in the viewObject so it will return only one value or more values from selected row. You can't select multiple rows from LOV.
But you can do this by using popup which you can select multiple rows and insert the selected rows to another table.
This blog post explain how to achieve this :
http://husaindalal.blogspot.com/2009/11/search-from-popup-and-add-to-new-table.html#comments
Sameh Nassar -
Selecting multiple rows in a table
Hi All,
I have one problem with selecting multiple rows in a table.I tried with setting table property-selectionMode as Multi, but i dinn't get the solution.
please provide me solution for this.
Thanks & Regards,
Sreelakshmi.HI
Int leadSelection = wdcontext.nodemodelnode.getLeadSelection();
for(int i=0;i<wdcontext.nodeModelNode.size;i++)
if(wdcontext.nodeModelNode.isMultiselected(i) || leadSelection ==i)
String name = wdcontext.nodemodelnode.getnameelementatindex(i).getName();
String address = wdcontext.nodemodelnode.getaddresselementatindex(i).getAddress();
String age = wdcontext.nodemodelnode.getAgeelementatindex(i).getAge();
Create a method for the Table Property onLeadSelect() where you can open a popup window
Create a value node and with attributes same as Table attributes and then set the values of the table
to the value node attributes.
Thanks
Maybe you are looking for
-
Can I use my Gaming series as an output device for another computer?
Hello, I tried to search for some similar topics but nothing showed up, so I apologize in advance if this has been asked before: Can I use my Gaming series as an output device (monitor) for another computer?? I am searching for use my Gaming series a
-
Span-Based Monitor of IPPA Agents at remote site for UCCX 9X
I understand to be able to monitor/record agents using IPPA (for UCCX), you need to utilize Span-based monitoring as opposed to Desktop Monitoring. According to the SRND, it also states that there should be no routing devices between agent phone (IPP
-
Editable ALV's in WD4A (Like in Straight ABAP OO)
Last year I had to master ABAP OO editable ALV's to put one in a MIGO dialog process exit. The editable ALV class methods are pretty cool and do a lot of the work for you. So while in NET310 this week, I was looking at all the SAP-provided WD4A ALV
-
I have started X fine as root, but it doesn't start as a normal user. FATAL: Module fbcon not found. (EE) VESA(1): Cannot read V_BIOS (3) Input/output error
-
Can't update from 10.4 to 10.4.9 on iMac -=
I had to do an archive and install on our iMac G5 1.6 GHz. When I attempt to run software update to update to 10.4.9, I get the timed out message - do I have to run an imbetween update, like 10.4.5 or something? Thanks