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 AM
Hi,
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
Similar Messages
-
How to insert multiple rows in oracle forms when using TEMPLATE FORM
I got a case study on PO creation nd in that I have to insert multiple rows in form especally when PO creation screen is there.
I tried by different syntaxes but its not working.I need correct syntax to insert the multiple rows in to the table in oracle formsPlease Oracle EBS queries on EBS forums.
-
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. -
How to capture changed value in ALV Grid
Hi Guys,
I have an ALV grid report where I have 'Edit On' for one of the quantity fields in the report. How do I capture the new (changed) value in the suboutine for user command when user changes the value in the report and clicks on a button ?
Points assured for helpful replies.FORM USER_COMMAND USING P_UCOMM LIKE SY-UCOMM...........
Data ref1 type ref to cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = ref1.
call method ref1->check_changed_data
ENDFORM.
Also chk the blog
/people/community.user/blog/2007/01/10/displaychange-mode-of-editable-fields-in-alv-using-function-modules-but-not-custom-containers -
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 -
How to capture the event in ALV grid display?
Hi experts,
How to capture the event in an ALV grid display which is editable. I have to capture the TAB key or ENTER key.
regards,
Arul Jothi.Hi Arul,
Take a look at sample program BCALV_EDIT_03. (Find string "register ENTER" in the program to see how to register)
Basically you have to Register edit events using method call REGISTER_EDIT_EVENT and then write a handler method for event DATA_CHANGED..
If you are using a REUSE..GRID fm then first get the grid reference using function module GET_GLOBALS_FROM_SLVC_FULLSCR and then repeat the above procedure..
Hope this helps..
Sri
Message was edited by: Srikanth Pinnamaneni -
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 identify column name in ALV tree when user clicks a particular field
Hi All,
In My requirement i am displaying ALV Tree.
In Which When the user clicks on a particular header column it should navigate to other transaction.
Now the issue is it is navigating to other transaction when we click on any column of the header row.
But, the user requires only for particular column .
Is there any method to catch the field name in CLASS 'CL_GUI_ALV_TREE'.
Regards,
Bhanu.RCheck out for CUCOL system field.
Regards,
Lalit Mohan Gupta. -
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! -
Set specific rows in ALV grid ready for input
Hi everyone,
I have a question about how to set specific rows in ALV grid ready for input.
I know that I can make some columns ready for input before the ALV displayed,but I have no idea how to make specific rows displayed in the ALV ready for input.Hello Aaron
For editable columns we can use the fieldcatalog (LVC_S_FCAT-EDIT = 'X') but for rows you need to define editability on cell level.
The required steps are documented in sample report BCALV_EDIT_02. Below I point out a few crucial points:
*§1.Extend your output table for a field, e.g., CELLTAB, that holds
* information about the edit status of each cell for the
* corresponding row (the table type is SORTED!).
DATA: BEGIN OF gt_outtab occurs 0. "with header line
include structure sflight.
DATA: celltab type LVC_T_STYL.
DATA: END OF gt_outtab.
*§3.Provide the fieldname of the celltab field by using field
* STYLEFNAME of the layout structure.
gs_layout-stylefname = 'CELLTAB'.
CALL METHOD grid1->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT'
is_layout = gs_layout
CHANGING it_outtab = gt_outtab[].
Note: in the sample report only field SEATSMAX is editable. In your case you need
to fill CELLTAB for all fields in a row.
*§2.After selecting data, set edit status for each row in a loop
* according to field SEATSMAX.
LOOP AT gt_outtab.
l_index = sy-tabix.
refresh lt_celltab.
if gt_outtab-seatsmax ge 300.
perform fill_celltab using 'RW'
changing lt_celltab.
else.
perform fill_celltab using 'RO'
changing lt_celltab.
endif.
*§2c.Copy your celltab to the celltab of the current row of gt_outtab.
INSERT LINES OF lt_celltab INTO TABLE gt_outtab-celltab.
MODIFY gt_outtab INDEX l_index.
ENDLOOP.
ENDFORM. " SELECT_DATA_AND_INIT_STYLE
NOTE: LVC_T_STYL is a SORTED table type. Thus, take care that you are using the
INSERT ... INTO TABLE statement and not APPEND (because then nothing is appended
to the CELLTAB itab).
IF p_mode EQ 'RW'.
*§2a.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell
* to status "editable".
l_mode = cl_gui_alv_grid=>mc_style_enabled.
ELSE. "p_mode eq 'RO'
*§2b.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_DISABLED to set a cell
* to status "non-editable".
l_mode = cl_gui_alv_grid=>mc_style_disabled.
ENDIF.
ls_celltab-fieldname = 'SEATSMAX'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
Regards
Uwe -
How to implement functionkeys on the ALV GRID tool bar
Hello All,
I need to implement functionkeys(Ex.given below) to the standard buttons like Ascending order etc. on the ALVGRID Tool Bar . I have implementedObject orient concept( Methods) to display the out put.I tried by using set pf-status but it is not comming.
Ex:
ALV Grid Toll Bar Buttons ( Func.Keys )
Print Preview ( CtrlShiftF10)
Sort in Ascending order ( Ctrl+F6 )
Thanks in Advance.
Vijay
Edited by: Vijay Reddy on Aug 19, 2008 10:12 AM
Edited by: Vijay Reddy on Aug 19, 2008 10:13 AMHi,
check this code,
REPORT zcl_timesheet_approval MESSAGE-ID zcl_msg.
* CLASS L_CL_EVENTS DEFINITION *
* Class for inserting buttons on the toolbar *
CLASS l_cl_events DEFINITION.
PUBLIC SECTION.
METHODS:
toolbar FOR EVENT toolbar
OF cl_gui_alv_grid
IMPORTING e_object
e_interactive,
user_command FOR EVENT user_command
OF cl_gui_alv_grid
IMPORTING e_ucomm .
ENDCLASS. " L_CL_EVENTS DEFINITION
* CLASS L_CL_EVENTS IMPLEMENTATION *
* Implementation of class L_CL_EVENTS *
CLASS l_cl_events IMPLEMENTATION.
METHOD toolbar.
PERFORM event_toolbar USING e_object.
ENDMETHOD. " TOOLBAR
METHOD user_command.
PERFORM event_ucomm USING e_ucomm.
ENDMETHOD. " USER_COMMAND
ENDCLASS. " L_CL_EVENTS IMPLEMENTATION
CONSTANTS:
c_boolean_yes(1) TYPE c " Boolean - yes
VALUE 'X',
c_approve_status(1) TYPE c " Approval status
VALUE 'A',
c_rej_status(1) TYPE c " Rejected status
VALUE 'R',
c_save_status(1) TYPE c " Save status
VALUE 'S',
c_fcode_approve(7) TYPE c " Function code - APPROVE
VALUE 'APPROVE',
c_fcode_rej(6) TYPE c " Function code - REJECT
VALUE 'REJECT',
c_fcode_back(4) TYPE c " Function code - BACK
VALUE 'BACK',
c_fcode_onli(4) TYPE c " Function code - EXECUTE
VALUE 'ONLI',
c_fcode_exit(4) TYPE c " Function code - EXIT
VALUE 'EXIT',
c_fcode_cancel(6) TYPE c " Function code - CANCEL
VALUE 'CANCEL',
c_zero(1) TYPE c " Constant value 0
VALUE '0',
c_alv_scr(7) TYPE c " GUI status : ALV screen
VALUE 'ALV_SCR'.
* Field-string declarations...........................................
DATA:
* Field-string to build fieldcat.
fs_fcat TYPE lvc_s_fcat,
* Field-string for t_temp
fs_temp TYPE type_s_temp.
* Working variables...................................................
* Internal table declarations........................................
DATA:
* Internal table to build fieldcat.
t_fcat TYPE lvc_t_fcat,
* For ALV ...........................................................
DATA:
* To create instance for cl_gui_custom_container
g_grid TYPE REF TO cl_gui_custom_container,
* To create instance for cl_gui_alv_grid
g_alv TYPE REF TO cl_gui_alv_grid,
* To create instance for l_cl_events
g_events TYPE REF TO l_cl_events,
* To assign name for custom container
g_container TYPE scrfname VALUE 'CONTAINER',
* To assign layout
g_fcatlayo TYPE lvc_s_layo.
* AT SELECTION-SCREEN EVENT *
AT SELECTION-SCREEN.
* To perform user actions on the selection screen
PERFORM user_command.
* MODULE STATUS_0100 OUTPUT *
* This module will create the objects for the instance and display *
* the records *
MODULE status_0100 OUTPUT.
SET PF-STATUS c_alv_scr.
PERFORM set_titlebar USING w_display.
* If program executed in foreground.
IF sy-batch IS INITIAL.
* If g_grid is empty.
IF g_grid IS INITIAL.
* To create object for instance grid
CREATE OBJECT g_grid
EXPORTING
container_name = g_container.
* To create object for object grid
CREATE OBJECT g_alv
EXPORTING
i_parent = g_grid.
ELSE.
* IF W_SUBMIT EQ
CALL METHOD g_alv->refresh_table_display.
ENDIF. " IF G_GRID IS INITIAL
ENDIF. " IF SY-BATCH IS INITIAL
REFRESH t_fcat.
* If w_display eq 'X' .
IF w_display EQ c_boolean_yes.
* To display all records except saved data
PERFORM display_allrecords.
ENDIF. " IF W_FLAG EQ C_BOOLEAN_YES
IF w_submit EQ c_boolean_yes.
* To display submitted records
PERFORM submitted_records.
ENDIF. " IF W_SUBMIT EQ C_BOOLEAN_YES
ENDMODULE. " STATUS_0100 OUTPUT
* MODULE USER_COMMAND_0100 INPUT *
* To perform user actions in the screen 100 *
MODULE user_command_0100 INPUT.
* To update the data in the ALV grid
PERFORM check_changed_data.
w_okcode = ok_code.
CLEAR ok_code.
CASE w_okcode.
WHEN c_fcode_back.
LEAVE TO SCREEN 0.
WHEN c_fcode_exit OR c_fcode_cancel.
LEAVE PROGRAM.
ENDCASE. " CASE W_OKCODE
ENDMODULE. " USER_COMMAND_0100
* FORM BUILD_FCAT *
* To build the field catalog giving managers comment in editable mode *
* -->PR_Tabname type lvc_tname *
* -->PR_Fieldname type lvc_fname *
* -->PR_Coltext type lvc_txtcol *
* -->PR_Colpos type lvc_colpos *
FORM build_fcat USING pr_tabname TYPE lvc_tname
pr_fieldname TYPE lvc_fname
pr_coltext TYPE lvc_txtcol
pr_colpos TYPE lvc_colpos.
CLEAR fs_fcat.
fs_fcat-tabname = pr_tabname.
fs_fcat-fieldname = pr_fieldname.
fs_fcat-coltext = pr_coltext.
fs_fcat-col_pos = pr_colpos.
IF fs_fcat-fieldname EQ 'MNGCOMMENT'.
fs_fcat-edit = c_boolean_yes.
fs_fcat-lowercase = c_boolean_yes.
fs_fcat-dd_outlen = 60.
ELSE.
fs_fcat-edit = space.
ENDIF. " IF FS_FCAT-FIELDNAME...
APPEND fs_fcat TO t_fcat.
ENDFORM. " BUILD_FCAT
* FORM BUILD_FCATD *
* To build fieldcatalog in the display mode *
* -->pr_Tabname type lvc_tname *
* -->pr_Fieldname type lvc_fname *
* -->pr_Coltext type lvc_txtcol *
* -->pr_Colpos type lvc_colpos *
FORM build_fcatd USING pr_tabname TYPE lvc_tname
pr_fieldname TYPE lvc_fname
pr_coltext TYPE lvc_txtcol
pr_colpos TYPE lvc_colpos .
CLEAR fs_fcat.
fs_fcat-tabname = pr_tabname.
fs_fcat-fieldname = pr_fieldname.
fs_fcat-coltext = pr_coltext.
fs_fcat-col_pos = pr_colpos.
fs_fcat-edit = space.
APPEND fs_fcat TO t_fcat.
ENDFORM. " BUILD_FCATD
* FORM ALV_DISPLAY *
* To display data in ALV *
* --> pr_table type standard table *
* --> pr_fcat type lvc_t_fcat *
FORM alv_display USING pr_table TYPE STANDARD TABLE
pr_fcat TYPE lvc_t_fcat .
* Local data declaration....
DATA: lt_exclude TYPE ui_functions.
* To exclude buttons on the ALV grid
PERFORM exclude_tb_functions CHANGING lt_exclude.
* To display ALV
CALL METHOD g_alv->set_table_for_first_display
EXPORTING
i_default = space
is_layout = g_fcatlayo
it_toolbar_excluding = lt_exclude
CHANGING
it_outtab = pr_table[]
it_fieldcatalog = pr_fcat[].
ENDFORM. " ALV_DISPLAY
* FORM EVENT_TOOLBAR *
* Setting toolbar in the alv grid *
* -->E_OBJECT TYPE REF TO CL_ALV_EVENT_TOOLBAR_SET *
FORM event_toolbar USING e_object
TYPE REF TO cl_alv_event_toolbar_set.
* Local declaration for the button.
DATA: ls_toolbar TYPE stb_button.
* To add Approve button
ls_toolbar-function = c_fcode_approve.
ls_toolbar-butn_type = c_zero.
ls_toolbar-text = text-001.
APPEND ls_toolbar TO e_object->mt_toolbar.
* To add Reject button
CLEAR ls_toolbar.
ls_toolbar-function = c_fcode_rej.
ls_toolbar-butn_type = c_zero.
ls_toolbar-text = text-013.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDFORM. " EVENT_TOOLBAR
* FORM EXCLUDE_TB_FUNCTIONS *
* To exclude buttons from ALV grid *
* <--> PR_EXCLUDE TYPE UI_FUNCTIONS *
FORM exclude_tb_functions CHANGING pr_exclude TYPE ui_functions.
* Local data declaration...
DATA ls_exclude TYPE ui_func.
* To remove the buttons on the ALV grid.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
APPEND ls_exclude TO pr_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
APPEND ls_exclude TO pr_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
APPEND ls_exclude TO pr_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
APPEND ls_exclude TO pr_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
APPEND ls_exclude TO pr_exclude.
ENDFORM. " EXCLUDE_TB_FUNCTIONS
* FORM EVENT_UCOMM *
* After Input in the ALV grid,if user select record and press *
* approve or reject then the record will get updated *
* --> PR_ucomm type sy-ucomm *
FORM event_ucomm USING pr_ucomm LIKE sy-ucomm.
CASE pr_ucomm.
* If e_ucomm contains 'APP' i.e.function code for Approve button
WHEN c_fcode_approve. " To approve selected record
PERFORM app_timesheet USING c_approve_status.
* If e_ucomm contains 'REJ' i.e. function code for Reject
WHEN c_fcode_rej. " To reject selected record
PERFORM app_timesheet USING c_rej_status.
ENDCASE. " CASE E_UCOMM
ENDFORM. " EVENT_UCOMM
* FORM APP_TIMESHEET *
* To get the selected records and update the records in database *
* --> pr_status type char01 *
FORM app_timesheet USING pr_status TYPE char01 .
* Local data declaration......
DATA:
lt_marked_rows TYPE lvc_t_roid, " Table to get rowid
l_fs_marked_row LIKE LINE OF lt_marked_rows.
" Field-string for lt_marked_rows
* To get all the selected rows in the table lt_marked_rows
CALL METHOD g_alv->get_selected_rows
IMPORTING
et_row_no = lt_marked_rows.
* Reading each row id and updating the database.
LOOP AT lt_marked_rows INTO l_fs_marked_row.
* Reading the table t_timesheet with rowid
READ TABLE t_timesheet INTO fs_timesheet INDEX
l_fs_marked_row-row_id.
* If record is there in the table.
IF sy-subrc EQ 0.
CLEAR fs_timesheet-appstatus.
GET PARAMETER ID 'ZEMPID' FIELD w_empid.
* Changing the appstatus.
fs_timesheet-appstatus = pr_status.
fs_timesheet-approvedby = w_empid.
* Updating the database table.
UPDATE zcl_timesheet FROM fs_timesheet.
IF sy-subrc EQ 0.
fs_temp-empid = fs_timesheet-empid.
fs_temp-workdate = fs_timesheet-workdate.
fs_temp-linenum = fs_timesheet-linenum.
append fs_temp to t_temp.
ENDIF. " IF SY-SUBRC EQ 0.
ENDIF. " IF SY-SUBRC EQ 0
ENDLOOP. " LOOP AT LT_MARKED_ROWS...
perform delete_data .
PERFORM refresh_table USING pr_status.
ENDFORM. " APP_TIMESHEET
* FORM CHECK_CHANGED_DATA *
* To change the data *
* No parameters are passsed to this subroutine *
FORM check_changed_data .
* To change the data.
CALL METHOD g_alv->check_changed_data.
ENDFORM. " CHECK_CHANGED_DATA
* FORM REFFRESH_TABLE *
* To refresh output table and issue message according p_status *
* -->PR_STATUS TYPE CHAR01 *
FORM refresh_table USING pr_status TYPE char01.
* To refresh output table.
CALL METHOD g_alv->refresh_table_display.
* Depending upon pr_status message is given.
IF pr_status EQ c_approve_status.
MESSAGE s001.
ELSE.
MESSAGE s002.
ENDIF. " IF P_STATUS EQ C_APPROVE_STATUS
ENDFORM. " REFRESH_TABLE
* FORM SET_TITLEBAR *
* To set titlebar on the screen 100. *
* -->PR_STATUS TYPE CHAR01 *
FORM set_titlebar USING pr_status TYPE char01.
* If pr_status eq 'X'.
IF pr_status EQ c_boolean_yes.
SET TITLEBAR c_alv_scr WITH text-017.
ELSE.
SET TITLEBAR c_alv_scr WITH text-018.
ENDIF. " IF P_STATUS EQ C_BOOLEAN_YES
ENDFORM. " SET_TITLEBAR
* FORM USER_COMMAND *
* According to sy-ucomm the action is performed in the screen 100 *
* No parameters are passsed to this subroutine *
FORM user_command .
CASE sy-ucomm.
* If p_app is selected, submitted data will be displayed for approval
WHEN c_fcode_onli OR c_fcode_approve.
CLEAR sy-ucomm.
* To display the submitted records.
IF p_app EQ c_boolean_yes.
w_submit = c_boolean_yes.
* To get submitted records
PERFORM get_data.
ENDIF. " IF P_APP EQ C_BOOLEAN_YES
* To display all records according to selection.
IF p_disp EQ c_boolean_yes.
w_display = c_boolean_yes.
* To display
PERFORM display_all.
CLEAR w_display.
ENDIF. " IF P_DISP EQ C_BOOLEAN_YES
IF p_sdn EQ c_boolean_yes.
PERFORM GET_GRAPH.
ENDIF.
ENDCASE. " CASE SY-UCOMM
ENDFORM. " USER_COMMAND
* FORM DISPLAY_ALLRECORDS *
* To display all the records in the display mode *
* No parameters are passsed to this subroutine *
FORM display_allrecords .
CLEAR w_display.
PERFORM build_fcatd USING 'T_TIME' 'WORKDATE' text-002 '1'.
PERFORM build_fcatd USING 'T_TIME' 'EMPID' text-009 '2'.
PERFORM build_fcatd USING 'T_TIME' 'PROJECTID' text-003 '3'.
PERFORM build_fcatd USING 'T_TIME' 'PROJECTNAME' text-004 '4'.
PERFORM build_fcatd USING 'T_TIME' 'OBJECTID' text-005 '5'.
PERFORM build_fcatd USING 'T_TIME' 'OBJECTNAME' text-006 '6'.
PERFORM build_fcatd USING 'T_TIME' 'ACTIVITYID' text-007 '7'.
PERFORM build_fcatd USING 'T_TIME' 'ACTIVITYNAME' text-008 '8'.
PERFORM build_fcatd USING 'T_TIME' 'TIMEWORKED' text-010 '9'.
PERFORM build_fcatd USING 'T_TIME' 'DESCRIPTION' text-011 '10'.
PERFORM build_fcatd USING 'T_TIME' 'APPSTATUS' text-012 '11'.
PERFORM build_fcatd USING 'T_TIME' 'BILLSTATUS' text-016 '12'.
PERFORM build_fcatd USING 'T_TIME' 'SDNSTATUS' text-019 '13'.
PERFORM build_fcatd USING 'T_TIME' 'MNGCOMMENT' text-014 '14'.
PERFORM alv_display USING t_time t_fcat.
ENDFORM. " DISPLAY_ALLRECORDS
* FORM SUBMITTED_RECORDS *
* To display submitted records for the manager to approve *
* No parameters are passsed to this subroutine *
FORM submitted_records .
CLEAR w_submit.
* To create object for instance g_events
CREATE OBJECT g_events.
* If w_first equal to space
IF w_first IS INITIAL.
SET HANDLER g_events->toolbar
FOR g_alv.
w_first = c_boolean_yes.
ENDIF. " IF W_FIRST IS INITIAL..
SET HANDLER g_events->user_command
FOR g_alv.
g_fcatlayo-sel_mode = c_approve_status.
REFRESH t_fcat.
* to fill ur field cat table.
ENDFORM. " SUBMITTED_RECORDS
* FORM DELETE_DATA *
* This form is used to delete thedata from output table after updating *
* the database *
* No parameters are passsed to this subroutine *
form delete_data .
loop at t_temp into fs_temp.
loop at t_timesheet into fs_timesheet where
empid = fs_temp-empid
and workdate = fs_temp-workdate
and linenum = fs_temp-linenum.
delete t_timesheet index sy-tabix.
endloop. " LOOP AT T_TEMP INTO FS_TEMP
endloop . " LOOP AT T_TIMESHEET INTO FS_T..
endform. " DELETE_DATA
Hope it helps you.
Regards
Manjari. -
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. -
Multiple Input Rows In ALV Grid (Editable)
Hi,
I have an editable ALV grid and need to have multiple blank rows ready for input. Something similar to what happens when you click the "New Entries" button in SM30 (Table Maintainance).
There is a local function for appending lines in the ALV grid toolbar but this only allows a single entry.
I have replaced the local function with my own button (same icon etc) and on user_command event, I am appending several blank lines to my output table.
However these lines are not being shown on the screen. I have looked through the layout and field catalog but there is no field to allow blank lines to be shown.
My 2 questions are:
1. Is there some standard way of entering multiple entries in ALV Grid Editable.
2. If not then how to allow blank lines to be shown as ready for input.
Also if someone could suggest a way to do error checking for all entries on the screen especially duplicate entries I will be extremely grateful.
Many Thanks,
PreetHi, Preet!
You can easily do whatever checks you wish. You should declare an event handling method for event DATA_CHANGED and call the ADD_PROTOCOL_ENTRY method of the ER_DATA_CHANGED event parameter (it's an object of the class CL_ALV_CHANGED_DATA_PROTOCOL). You must not forget to set handler for your ALV grid.
For example, this piece of code checks for all changed fields resulting in error message if they are initial. In short, this makes all the fields obligatory.
METHODS: on_data_changed FOR EVENT data_changed OF cl_gui_alv_grid IMPORTING er_data_changed.
SET HANDLER your_object->on_data_changed FOR your_alv_grid.
METHOD on_data_changed.
DATA: s_mod_cell TYPE lvc_s_modi.
LOOP AT er_data_changed->mt_mod_cells INTO s_mod_cell.
IF s_mod_cell-value IS INITIAL.
* issue message 'Make an entry in all required fields'
CALL METHOD er_data_changed->add_protocol_entry
EXPORTING i_msgid = '00'
i_msgno = '055'
i_msgty = 'E'
i_fieldname = s_mod_cell-fieldname
i_row_id = s_mod_cell-row_id.
ENDIF.
ENDMETHOD.
Furthermore, if you make your class inherited from CL_GUI_ALV_GRID you can make use of protected attribute MT_OUTTAB which is a data object referencing your output table. Then you can have:
FIELD-SYMBOLS: <outtab> TYPE STANDARD TABLE.
ASSIGN me->mt_outtab->* TO <outtab>.
* do whatever you want with <outtab>
Hope this helps.
Kind regards,
Igor
P.S. Regarding the blank lines that you need, what's wrong with standard ALV grid buttons "Append row" and "Insert row" which appear whenever the grid is editable (unless you deliberately remove them)? They work just fine with me (just like on SM30). I don't see reason for programatically appending lines to your internal table. -
HOW CAN I HAVE THE NUMBER OF SELECTED ROWS IN ALV GRID?
HI.
HOW CAN I HAVE THE NUMBER OF SELECTED ROWS IN ALV GRID????
GABRY =)You need to use
data : grid1 type ref to cl_gui_alv_grid.
call method grid1->get_selected_rows
importing
et_index_rows = i_sel_alvrows[].
a®
Maybe you are looking for
-
Photo library won't open after iOS 5 update
I updated both my iPod Touch and iPhone 4 to the new iOS 5.0 right after it was released. I initially noticed that my library of photos would not fully sync to both products but I remedied that by manually clicking each photo album I have available v
-
Automator Folder Actions - Use filename as subject in email
I regularly email .pdf atttachments to my head office. These are hand-written sales orders which are scanned in. The scanner software gives each file a sequential filename (eg. OrderNo_110612). I have set up a Folder Action in Automator to create a n
-
JBO-33008 Error finding application context
Can anyone explain what causes JBO-33008 or where I can find more information on the exception. I have been unable to find any documentation (even the help in JDev goes from 34001 to 55001). Any information would be greatly appreciated. Thanks in adv
-
Will the new time capsule back up Windows on an iMac running Parallels Desktop?
Will the new time capsule back up Windows on an iMac running Parallels Desktop?
-
OS X will not install on recently zero'd out HD...HELP!
I recently did a 7-pass erase to my HD as I plan on selling my computer. After the erase was done I shut down my comp and rebooted from the Leopard install disk. About 60-70% of the way through the install fails with errors about 'HewlettPackardPrint