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.
Similar Messages
-
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
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 -
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 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. -
How to change a color for a row in ALV grid display
Hi,
how to change a color for a row in ALV grid display based on a condition.Any sample code plzHello Ramya,
Did you check in [SCN|How to color a row of alv grid]
Thanks! -
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 -
Folder for multiple details in ALV GRID DISPLAY
Hi All,
I am developing one ALV GRID DISPLAY report. Here I am displaying the material and production order details in the report. If we have the multiple production order details for one material , then in that case , we have to place one folder at the first material level, in that folder I need to show all the multiple production order details.
I am using FUNCTION MODULE to develope the report, not using any Objects to develope this.
Thanks in advance.
Ramesh.Here is a simple example of such an ALV.
report zrich_0001.
type-pools: slis.
data: begin of head occurs 0,
matnr type afpo-matnr,
maktx type makt-maktx,
EXPAND type c,
end of head.
data: begin of detail occurs 0,
aufnr type afpo-aufnr,
matnr type afpo-matnr,
werks type aufk-werks,
pwerk type afpo-pwerk,
psmng type afpo-psmng,
end of detail.
start-of-selection.
select * into corresponding fields of table detail
from afpo
inner join aufk
on afpo~aufnr = aufk~aufnr
inner join afko
on afpo~aufnr = afko~aufnr
up to 500 rows
where aufk~auart = 'PP01'.
if not detail[] is initial.
sort detail ascending by matnr.
select distinct * into corresponding fields of table head
from makt
for all entries in detail
where matnr = detail-matnr
and spras = sy-langu.
endif.
perform call_alv.
* FORM call_alv *
form call_alv.
data: gt_fieldcat type slis_t_fieldcat_alv,
gs_keyinfo type slis_keyinfo_alv,
gs_layout type slis_layout_alv.
data: ls_fieldcat type slis_fieldcat_alv.
clear gs_keyinfo.
gs_keyinfo-header01 = 'MATNR'.
gs_keyinfo-item01 = 'MATNR'.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'MATNR'.
ls_fieldcat-reptext_ddic = 'Material'.
ls_fieldcat-tabname = 'HEAD'.
ls_fieldcat-outputlen = 18.
append ls_fieldcat to gt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'MAKTX'.
ls_fieldcat-reptext_ddic = 'Description'.
ls_fieldcat-tabname = 'HEAD'.
ls_fieldcat-outputlen = 40.
append ls_fieldcat to gt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'AUFNR'.
ls_fieldcat-reptext_ddic = 'Production Order'.
ls_fieldcat-tabname = 'DETAIL'.
ls_fieldcat-outputlen = 12.
append ls_fieldcat to gt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'WERKS'.
ls_fieldcat-reptext_ddic = 'Production Plant'.
ls_fieldcat-tabname = 'DETAIL'.
ls_fieldcat-outputlen = 4.
append ls_fieldcat to gt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'PWERK'.
ls_fieldcat-reptext_ddic = 'Planning Plant'.
ls_fieldcat-tabname = 'DETAIL'.
ls_fieldcat-outputlen = 4.
append ls_fieldcat to gt_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'PSMNG'.
ls_fieldcat-reptext_ddic = 'Quantity'.
ls_fieldcat-tabname = 'DETAIL'.
ls_fieldcat-outputlen = 20.
append ls_fieldcat to gt_fieldcat.
gs_layout-expand_fieldname = 'EXPAND'.
call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
exporting
it_fieldcat = gt_fieldcat[]
is_layout = gs_layout
i_tabname_header = 'HEAD'
i_tabname_item = 'DETAIL'
is_keyinfo = gs_keyinfo
tables
t_outtab_header = head
t_outtab_item = detail.
endform.
Regard,s
RIch Heilman -
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,
NeerajHi,
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 -
How to color a row in ALV grid display
Hi,
A few rows in the output of ALV grid display should be shown in different color.How can I achieve this?Hi,
Try out this code
DATA : BEGIN OF G_T_CASH OCCURS 0,
PARTICULARS TYPE CHAR120,
AMOUNT1 TYPE CHAR20,
AMOUNT2 TYPE CHAR20,
AMOUNT3 TYPE CHAR20,
ROW_COLOR TYPE CHAR4,----
add this in the internal table for alv
END OF G_T_CASH.
CLEAR G_WA_CASH.
G_WA_CASH-PARTICULARS = 'Opening Cash Balance'.
G_WA_CASH-AMOUNT1 = G_DMBTR.
G_WA_CASH-AMOUNT2 = ''.
G_WA_CASH-AMOUNT3 = ''.
while appending other values also add the following code
G_WA_CASH-ROW_COLOR = 'C200'.----- C200 depicts light gray color
APPEND G_WA_CASH TO G_T_CASH.
add the following code in layout
MOVE 'ROW_COLOR' TO WA_LS_LAYOUT-INFO_FIELDNAME.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_BYPASSING_BUFFER = ' '
I_SAVE = 'A'
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = WA_LS_LAYOUT
IT_FIELDCAT = G_T_CATALOG
IT_EVENTS = GT_EVENTS
TABLES
T_OUTTAB = G_T_CASH[]
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.
Let me know if the problem still persist.
Regards,
Janaki -
Color a specific row in ALV GRID display when user clicks on that row
hi
i have the entire code ready of how to check the line selected by the user and also to color that line but after settings those parameters
for to refresh the GRID so that the row apppears coloured .plz reply soon.... points will be awarded.....
wat i have done is
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = i_repid
i_callback_user_command = 'USER_COMMAND'
is_layout = it_layout
it_fieldcat = int_fieldcat
TABLES
t_outtab = int
EXCEPTIONS
program_error = 1
OTHERS = 2.
to display the GRID then when user clicks on any row this module gets called
FORM user_command USING r_ucomm TYPE sy-ucomm
rs_selfield TYPE slis_selfield.
READ TABLE int INDEX rs_selfield-tabindex.
int-rowcolor = 'C410'.
MODIFY int INDEX rs_selfield-tabindex TRANSPORTING rowcolor.
it_layout-info_fieldname = 'ROWCOLOR'.
then again i call 'REUSE_ALV_GRID_DISPLAY'
to display the GRID with the user selected line colored . the problem with this is when u go back from this screen u go to the previously displayed grid ....... whihc i dont want .....
ENDFORM. "user_commandHi,
By using following code,you can set the colors for each row,
Change this based on your requirement.
TABLES VBAK.
TYPE-POOLS SLIS.
Data Declaration
TYPES: BEGIN OF T_VBAK,
VBELN TYPE VBAK-VBELN,
ERDAT TYPE VBAK-ERDAT,
ERNAM TYPE VBAK-ERNAM,
AUDAT TYPE VBAK-AUDAT,
VBTYP TYPE VBAK-VBTYP,
NETWR TYPE VBAK-NETWR,
VKORG TYPE VBAK-VKORG,
VKGRP TYPE VBAK-VKGRP,
LINE_COLOR(4) TYPE C,
END OF T_VBAK.
DATA: IT_VBAK TYPE STANDARD TABLE OF T_VBAK INITIAL SIZE 0,
WA_VBAK TYPE T_VBAK.
ALV Data Declaration
DATA: FLDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
GD_LAYOUT TYPE SLIS_LAYOUT_ALV,
GD_REPID TYPE SY-REPID.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BLD_FLDCAT.
PERFORM BLD_LAYOUT.
PERFORM DISPLAY_ALV_REPORT.
Build Field Catalog for ALV Report
FORM BLD_FLDCAT.
FLDCAT-FIELDNAME = 'VBELN'.
FLDCAT-SELTEXT_M = 'Sales Document'.
FLDCAT-COL_POS = 0.
*FLDCAT-EMPHASIZE = 'C411'.
FLDCAT-OUTPUTLEN = 20.
FLDCAT-KEY = 'X'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'ERDAT'.
FLDCAT-SELTEXT_L = 'Record Date created'.
FLDCAT-COL_POS = 1.
FLDCAT-KEY = 'X'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'ERNAM'.
FLDCAT-SELTEXT_L = 'Cteated Object Person Name'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'AUDAT'.
FLDCAT-SELTEXT_M = 'Document Date'.
FLDCAT-COL_POS = 3.
FLDCAT-EMPHASIZE = 'C110'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'VBTYP'.
FLDCAT-SELTEXT_L = 'SD Document category'.
FLDCAT-COL_POS = 4.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'NETWR'.
FLDCAT-SELTEXT_L = 'Net Value of the SO in Document Currency'.
FLDCAT-COL_POS = 5.
FLDCAT-OUTPUTLEN = 60.
FLDCAT-DO_SUM = 'X'.
FLDCAT-DATATYPE = 'CURR'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'VKORG'.
FLDCAT-SELTEXT_L = 'Sales Organization'.
FLDCAT-COL_POS = 6.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
FLDCAT-FIELDNAME = 'VKGRP'.
FLDCAT-SELTEXT_M = 'Sales Group'.
FLDCAT-COL_POS = 7.
FLDCAT-EMPHASIZE = 'C801'.
APPEND FLDCAT TO FLDCAT.
CLEAR FLDCAT.
ENDFORM.
Build Layout for ALV Grid Report
FORM BLD_LAYOUT.
GD_LAYOUT-NO_INPUT = 'X'.
GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GD_LAYOUT-INFO_FIELDNAME = 'LINE_COLOR'.
GD_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'.
GD_LAYOUT-CONFIRMATION_PROMPT = 'X'. This asks the confirmation before leaving the screen.
ENDFORM.
Display report using ALV grid
FORM DISPLAY_ALV_REPORT.
GD_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = GD_REPID
IS_LAYOUT = GD_LAYOUT
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = 'SALES DOCUMENT HEADER'
IT_FIELDCAT = FLDCAT[]
I_SAVE = 'X'
TABLES
T_OUTTAB = IT_VBAK
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.
Retrieve data from VBAK table and populate itab IT_VBAK
FORM DATA_RETRIEVAL.
DATA LD_COLOR(1) TYPE C.
SELECT VBELN ERDAT ERNAM AUDAT VBTYP NETWR VKORG
UP TO 20 ROWS
FROM VBAK
INTO TABLE IT_VBAK.
LOOP AT IT_VBAK INTO WA_VBAK.
LD_COLOR = LD_COLOR + 1.
IF LD_COLOR = 8.
LD_COLOR = 1.
ENDIF.
CONCATENATE 'C' LD_COLOR '10' INTO WA_VBAK-LINE_COLOR.
MODIFY IT_VBAK FROM WA_VBAK.
ENDLOOP.
ENDFORM.
FORM TOP_OF_PAGE.
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
W_HEADER TYPE SLIS_LISTHEADER.
W_HEADER-TYP = 'H'.
W_HEADER-INFO = 'WELCOME HEADER LIST'.
APPEND W_HEADER TO T_HEADER.
W_HEADER-TYP = 'S'.
W_HEADER-KEY = 'REPORT:'.
W_HEADER-INFO = SY-REPID.
APPEND W_HEADER TO T_HEADER.
W_HEADER-TYP = 'S'.
W_HEADER-KEY = 'DATE:'.
CONCATENATE SY-DATUM6(2) ' / ' SY-DATUM4(2) ' / ' SY-DATUM(4) INTO W_HEADER-INFO.
APPEND W_HEADER TO T_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER
ENDFORM.
Reward points,if it is useful.
Thanks,
chandu. -
ABAPer's ,
Does anyone can guide me to select single row only in ALV grid , without OO.Hello,
I did not get u.
But check the below code it may help u.
tables: mara.
TYPE-POOLS: SLIS.
data:repid like sy-repid.
data: itb type mara occurs 0 with header line,
IT_FIELDCAT TYPE STANDARD TABLE OF SLIS_FIELDCAT_ALV WITH HEADER LINE,
IT_LAYOUT TYPE SLIS_LAYOUT_ALV,
ITB1 TYPE MAKT OCCURS 0 WITH HEADER LINE.
selection-screen begin of block b.
parameters: p_matnr type matnr.
selection-screen end of block b.
select * from mara into table itb where matnr = p_matnr.
SELECT * FROM MAKT INTO TABLE ITB1 WHERE MATNR = P_MATNR.
repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'HANDLE_USER_COMMAND'
I_STRUCTURE_NAME = 'MARA'
IS_LAYOUT = IT_LAYOUT
IT_FIELDCAT = IT_FIELDCAT[]
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
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = itb
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 HANDLE_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE
SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
CLEAR IT_FIELDCAT[].
IF RS_SELFIELD-FIELDNAME = 'MATNR'.
READ TABLE ITB1 INDEX RS_SELFIELD-TABINDEX.
WRITE: / ITB1-MAKTX.
ENDIF.
ENDCASE.
ENDFORM. "HANDLE_USER_COMMAND
Regards -
Selection of rows in ALV grid (class CL_GRID_CATSXT)
Hi all,
The CATS transaction CATS_APPR_LITE is using the class CL_GRID_CATSXT, method GET_SELECTED_ROWS, to retrieve selected rows in the ALV report.
The user/manager selects these rows to approve the work hours registered by his subordinates. He can only select and approve those rows that have been fully expanded, meaning he cannot select and approve total lines. (If he tries to do so, nothing happens).
I have created a layout that shows only total lines per employee. Using this layout the manager should be able to select the total line for a particular employee and press the "Approve" button. In this way, I need to get a hold of the rows contained in the total line, meaning I need the row numbers of the actual rows which have been added up in the total line.
Does anyone know how to do this...? As mentioned earlier, the CATS_APPR_LITE transaction is using class CL_GRID_CATSXT, method GET_SELECTED_ROWS.
All helpful answers will be rewarded!
Best regards,
MVI guess method GET_SELECTED_ROWS returns the total lines when they are selected ?
if so, you just have to do a LOOP on your internal table having same key fields as selected total line -
In ALV Display I want to have a <u>BLANK row</u> everytime the value of 'Cross Company Code Document Number' (BVORG) changes.
Is there a way to use the Sort Option of "REUSE_ALV_GRID_DISPLAY" to do this? Or is the only possible way is by modifying the ITAB that is being passed for display?
If ITAB is the only method to do it then how should I go about making this happen?
Thanks-
Rohit.if you do again sort then blank rows will come top,so make sure that should not do sort after inserting blank rows.
please sort it before inserting blank row .
sort itab by fields..
loop at itab.
endloop.
do not sort here.
Thanks
Seshu -
How to change the selected row color in an alv grid display ?
Hello ,
I WANT TO CHANGE THE COLOR OF THE SELECTED RECORDS IN AN ALV GRID DISPLAY ?
ITS URGENT..
WILL BE REWARDED...hai Ssnagh Samala
EXicut This report >
Hope It Will Meet U r Requirement.
If Found Helpfull Reward.
REPORT zcuitest_alv_07.
Use of colours in ALV grid (cell, line and column) *
Table
TABLES : mara.
Type
TYPES : BEGIN OF ty_mara,
matnr LIKE mara-matnr,
matkl LIKE mara-matkl,
counter(4) TYPE n,
free_text(15) TYPE c,
color_line(4) TYPE c, " Line color
color_cell TYPE lvc_t_scol, " Cell color
END OF ty_mara.
Structures
DATA : wa_mara TYPE ty_mara,
wa_fieldcat TYPE lvc_s_fcat,
is_layout TYPE lvc_s_layo,
wa_color TYPE lvc_s_scol.
Internal table
DATA : it_mara TYPE STANDARD TABLE OF ty_mara,
it_fieldcat TYPE STANDARD TABLE OF lvc_s_fcat,
it_color TYPE TABLE OF lvc_s_scol.
Variables
DATA : okcode LIKE sy-ucomm,
w_alv_grid TYPE REF TO cl_gui_alv_grid,
w_docking_container TYPE REF TO cl_gui_docking_container.
PARAMETERS : p_column AS CHECKBOX,
p_line AS CHECKBOX,
p_cell AS CHECKBOX.
START-OF-SELECTION.
PERFORM get_data.
END-OF-SELECTION.
PERFORM fill_catalog.
PERFORM fill_layout.
CALL SCREEN 2000.
*& Module status_2000 OUTPUT
text
MODULE status_2000 OUTPUT.
SET PF-STATUS '2000'.
ENDMODULE. " status_2000 OUTPUT
*& Module user_command_2000 INPUT
text
MODULE user_command_2000 INPUT.
DATA : w_okcode LIKE sy-ucomm.
MOVE okcode TO w_okcode.
CLEAR okcode.
CASE w_okcode.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " user_command_2000 INPUT
*& Module alv_grid OUTPUT
text
MODULE alv_grid OUTPUT.
IF w_docking_container IS INITIAL.
PERFORM create_objects.
PERFORM display_alv_grid.
ENDIF.
ENDMODULE. " alv_grid OUTPUT
*& Form create_objects
text
--> p1 text
<-- p2 text
FORM create_objects.
Ratio must be included in http://5..95
CREATE OBJECT w_docking_container
EXPORTING
ratio = 95
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
CREATE OBJECT w_alv_grid
EXPORTING
i_parent = w_docking_container.
ENDFORM. " create_objects
*& Form display_alv_grid
text
--> p1 text
<-- p2 text
FORM display_alv_grid.
CALL METHOD w_alv_grid->set_table_for_first_display
EXPORTING
is_layout = is_layout
CHANGING
it_outtab = it_mara
it_fieldcatalog = it_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
ENDFORM. " display_alv_grid
*& Form get_data
text
--> p1 text
<-- p2 text
FORM get_data.
SELECT * FROM mara UP TO 5 ROWS.
CLEAR : wa_mara-color_line, wa_mara-color_cell.
MOVE-CORRESPONDING mara TO wa_mara.
ADD 1 TO wa_mara-counter.
MOVE 'Blabla' TO wa_mara-free_text.
IF wa_mara-counter = '0002'
AND p_line = 'X'.
Color line
MOVE 'C410' TO wa_mara-color_line.
ELSEIF wa_mara-counter = '0004'
AND p_cell = 'X'.
Color cell
MOVE 'FREE_TEXT' TO wa_color-fname.
MOVE '5' TO wa_color-color-col.
MOVE '1' TO wa_color-color-int.
MOVE '1' TO wa_color-color-inv.
APPEND wa_color TO it_color.
wa_mara-color_cell] = it_color[.
ENDIF.
APPEND wa_mara TO it_mara.
ENDSELECT.
ENDFORM. " get_data
*& Form fill_catalog
text
--> p1 text
<-- p2 text
FORM fill_catalog.
Colour code : *
Colour is a 4-char field where : *
- 1st char = C (color property) *
- 2nd char = color code (from 0 to 7) *
0 = background color *
1 = blue *
2 = gray *
3 = yellow *
4 = blue/gray *
5 = green *
6 = red *
7 = orange *
- 3rd char = intensified (0=off, 1=on) *
- 4th char = inverse display (0=off, 1=on) *
Colour overwriting priority : *
1. Line *
2. Cell *
3. Column *
DATA : w_position TYPE i VALUE '1'.
CLEAR wa_fieldcat.
MOVE w_position TO wa_fieldcat-col_pos.
MOVE 'MATNR' TO wa_fieldcat-fieldname.
MOVE 'MARA' TO wa_fieldcat-ref_table.
MOVE 'MATNR' TO wa_fieldcat-ref_field.
APPEND wa_fieldcat TO it_fieldcat.
ADD 1 TO w_position.
CLEAR wa_fieldcat.
MOVE w_position TO wa_fieldcat-col_pos.
MOVE 'MATKL' TO wa_fieldcat-fieldname.
MOVE 'MARA' TO wa_fieldcat-ref_table.
MOVE 'MATKL' TO wa_fieldcat-ref_field.
Color column
IF p_column = 'X'.
MOVE 'C610' TO wa_fieldcat-emphasize.
ENDIF.
APPEND wa_fieldcat TO it_fieldcat.
ADD 1 TO w_position.
CLEAR wa_fieldcat.
MOVE w_position TO wa_fieldcat-col_pos.
MOVE 'COUNTER' TO wa_fieldcat-fieldname.
MOVE 'N' TO wa_fieldcat-inttype.
MOVE '4' TO wa_fieldcat-intlen.
MOVE 'Counter' TO wa_fieldcat-coltext.
APPEND wa_fieldcat TO it_fieldcat.
ADD 1 TO w_position.
CLEAR wa_fieldcat.
MOVE w_position TO wa_fieldcat-col_pos.
MOVE 'FREE_TEXT' TO wa_fieldcat-fieldname.
MOVE 'C' TO wa_fieldcat-inttype.
MOVE '20' TO wa_fieldcat-intlen.
MOVE 'Text' TO wa_fieldcat-coltext.
APPEND wa_fieldcat TO it_fieldcat.
ENDFORM. " fill_catalog
*& Form fill_layout
text
--> p1 text
<-- p2 text
FORM fill_layout.
Field that identify color line in internal table
MOVE 'COLOR_LINE' TO is_layout-info_fname.
Field that identify cell color in inetrnal table
MOVE 'COLOR_CELL' TO is_layout-ctab_fname.
ENDFORM. " fill_layout
Regards.
Eshwar.
Maybe you are looking for
-
Hi Gurus, i am currently working on a custom program for closing the dispute case.can anyone suggest me what is the criteria to get the resolved dispute cases to be closed. Thanks.
-
Hi. I stupidly deleted all the partitions so i could install windows 7 instead of 8 and i received a blue screen followed by a restart when booting up. I then decided to put windows 8 back on and received Windows error code: 0xc0000001 after the inst
-
I have iLife 05 and I am finally getting around to doing all the cool stuff I am capable of with my MAC. I have a few questions hopefully some people out there could answer. 1. When I want to create a DVD, can I use photos from iPhoto and/or home vid
-
After upgrading my iPhone 4S to iOS6, the Safari bookmark for the iPhone User Guide produces a "404 Not Found. The requested URL /apps/mobile/2.0/ was not found on this server. Apache/2.2.3 (PU_IAS) Server at help.apple.com Port 80" page. Note that t
-
Very urgent..Is this mandatory to maintain LTA in V_TIN7A9.
Hi friends, Is this mandatory to maintain the allowances like LTA , Bonus , Ex-gratia in the table V_TIN7A9 for eligibility. if we maitain in this these wagetypes get defaulted into the basicpay infotype also.then while entering these wagetypes for b