Problem with check box in ALV Grid Display
I am Displaying Material Master Data in ALV Grid Display with Check Box for each record and if i checked check box then i am processing Update operation in Database, my question is after perform update operation check box should be clear.
Kindly help me!!!!
Hello Raj
Given the fact that you do not tell us the most important piece of information (namely whether you are using OO-based ALV or not) I assume you are using fm-based ALV lists.
In this case you probably have defined a USER_COMMAND routine as described in the documentation of the fm.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* define local data
DATA: ls_outtab LIKE LINE OF gt_outtab,
ld_idx TYPE i.
LOOP AT gt_outtab INTO ls_outtab
WHERE ( chkbox = 'X' ).
ld_idx = syst-tabix.
" Call your update function / method / perform
ls_outtab-chkbox = space.
MODIFY gt_outtab FROM ls_outtab INDEX ld_Idx
TRANSPORTING chkbox.
ENDLOOP.
" And now trigger refresh of the ALV display:
rs_selfield-refresh = 'X'. " <<< !!!
ENDFORM.
Regards
Uwe
Similar Messages
-
Problem with check Box in ALV list
Hi All,
In my alv list I am using Check box and if I enabled the check box after pressing that pushbutton its not reflecting in the internal table how can I resolve it.
Please find below the piece of codes
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
sy-ucomm = ucomm.
CASE ucomm.
When 'SAVE'.
I am checking my internal table value here.
my logic....
When others.
Endcase.
FORM FIELD_CATLOGUE USING VALUE(P_tname) "Int.table name
VALUE(P_fname) "Field name
VALUE(P_title) "Column name
VALUE(P_sum) "Sum
VALUE(P_edit) "Edit
VALUE(P_Check). " Check box
CLEAR wa_fcat.
wa_fcat-tabname = p_tname.
wa_fcat-fieldname = p_fname.
wa_fcat-seltext_l = p_title.
wa_fcat-do_sum = P_Sum.
Wa_Fcat-edit = P_Edit.
Wa_Fcat-checkbox = P_Check.
Append wa_fcat to i_fcat.
gs_user_command type slis_formname value 'USER_COMMAND'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = i_fcat
is_layout = ilay
I_DEFAULT = 'X'
I_SAVE = 'A'
I_CALLBACK_PF_STATUS_SET = gs_user_status
i_callback_user_command = gs_user_command
TABLES
t_outtab = it_data
EXCEPTIONS
program_error = 1
others = 2.Hi,
Refer this program:-
* internal table and alv declarations
* with one field in internal table as
* flag(1) type c (for checkbox in alv)
* START-OF-SELECTION
START-OF-SELECTION.
"your select query to populate data in internal table
* END-OF-SELECTION
END-OF-SELECTION.
* FIELD CATALOG FOR FIRST GRID DISPLAY
PERFORM field_catalog.
* SORT W.R.T. WORK ORDER NUMBER FOR FIRST GRID DISPLAY
PERFORM sort_field.
* FOR LAYOUT FOR FIRST GRID DISPLAY
PERFORM set_layout.
* DISPLAY RECORDS IN ALV GRID FOR FIRST GRID DISPLAY
PERFORM alv_display.
*& SUBROUTINE DEFINITIONS
*& Form FIELD_CATALOG
* SUB-ROUTINE FIELD_CATALOG USED TO SET THE COLUMNS FOR
* THE ALV GRID (OUTPUT FORMAT)
* SETS THE COLUMN NAME AND THE OUTPUT LENGTH FOR THE FIELDS
FORM field_catalog .
wa_field-fieldname = 'FLAG'. " name of field from internal table
wa_field-tabname = 'IT_FINAL'. " internal table name
wa_field-outputlen = 2. " output length on screen
wa_field-checkbox = c_check. " print as checkbox
wa_field-edit = c_check. " make field open for input
wa_field-seltext_l = ' '. " header information
APPEND wa_field TO it_field. " append field catalog internal table
CLEAR wa_field. " clear field catalog work area
wa_field-fieldname = 'AUFNR'. " name of field from internal table
wa_field-tabname = 'IT_FINAL'. " internal table name
wa_field-outputlen = 20. " output length on screen
wa_field-seltext_l = text-003. " header information
APPEND wa_field TO it_field. " append field catalog internal table
CLEAR wa_field. " clear field catalog work area
ENDFORM. " FIELD_CATALOG
*& Form SORT_FIELD
* SUB-ROUTINE SORT_FIELD IS USED TO SORT THE RECORDS IN THE
* INTERNAL TABLE BASED ON THE GIVEN FIELD AND NATURE OF
* SORTING TO BE DONE (ASCENDING OR DESCENDING)
FORM sort_field .
wa_sort-spos = 1. " sort priority
wa_sort-fieldname = 'AUFNR'. " field on which records sorted
wa_sort-tabname = 'IT_FINAL'. " internal table name
wa_sort-up = c_check. " sort ascending
APPEND wa_sort TO it_sort. " append sort info internal table
CLEAR wa_sort. " clear sort info work area
ENDFORM. " SORT_FIELD
*& Form SET_LAYOUT
* SUB-ROUTINE SET_LAYOUT IS USED TO SET THE DISPLAY OF THE
* ALV GRID LINES IN ALTERNATIVE COLOURS
FORM set_layout .
wa_layout-zebra = c_check. " so set colors of line alternatively
ENDFORM. " SET_LAYOUT
*& Form ALV_DISPLAY
* SUB-ROUTINE ALV_DISPLAY IS USED TO SET THE PARAMETERS
* FOR THE FUNCTION MODULE REUSE_ALV_GRID_DISPLAY
* AND PASS THE INTERNAL TABLE EXISTING THE RECORDS TO BE
* DISPLAYED IN THE GRID FORMAT
FORM alv_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_rep_id " report id
i_callback_pf_status_set = 'PF' " for PF-STATUS
i_callback_user_command = 'USER_COMMAND' " for User-Command
is_layout = wa_layout " for layout
it_fieldcat = it_field " field catalog
it_sort = it_sort " sort info
TABLES
t_outtab = it_final " internal table
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. " ALV_DISPLAY
*& Form pf
* SUB-ROUTINE PF IS USED TO SET THE PF-STATUS OF THE SCREEN
* ON WHICH THE ALV GRID IS DISPLAYED
* -->RT_EXTAB
FORM pf USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZTG_STAT'.
ENDFORM. "pf
*& Form USER_COMMAND
* SUB-ROUTINE USER_COMMAND IS USED TO HANDLE THE USER ACTION
* AND EXECUTE THE APPROPIATE CODE
* -->LV_OKCODE used to capture the function code
* of the user-defined push-buttons
* -->L_SELFIELD text
FORM user_command USING lv_okcode LIKE sy-ucomm l_selfield TYPE slis_selfield.
* assign the function code to variable v_okcode
lv_okcode = sy-ucomm.
* handle the code execution based on the function code encountered
CASE lv_okcode.
* when the function code is EXECUTE then process the selected records
WHEN 'EXECUTE'.
* refresh it_process when user processes selected records
REFRESH it_process.
* to reflect the data changed into internal table
DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new
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.
* refresh the ALV Grid output from internal table
l_selfield-refresh = c_check.
WHEN 'SEL_ALL'.
* to select all the records displayed in ALV Grid
LOOP AT it_final INTO wa_final.
wa_final-flag = 'X'.
MODIFY it_final FROM wa_final.
ENDLOOP.
* refresh the ALV Grid output from internal table
l_selfield-refresh = c_check.
WHEN 'DESEL_ALL'.
* to deselect all the records displayed in ALV Grid
LOOP AT it_final INTO wa_final.
wa_final-flag = ' '.
MODIFY it_final FROM wa_final.
ENDLOOP.
* refresh the ALV Grid output from internal table
l_selfield-refresh = c_check.
ENDCASE.
ENDFORM. "USER_COMMAND
Hope this helps you.
Regards,
Tarun. -
How to merge rows with similar values in alv grid display in webdynpro
Hi experts,
i want to know about how to merge rows with similar values in alv grid display of webdynpro.grouping rows is possible in table display in webdynpro but i am not able to do row grouping in the alv grid display in webdynpro.
kindly suggest.
thanks ,
Anita.Hi Anita,
did you find a solution for this? I have opened a Thread, if you know the answer maybe you could help me out:
Is there an ALV function similar to the TABLE Row grouping?
Thanx in advanced!!!
Kind Regards,
Gerardo J -
Hi Gurus,
I developed one alv(grid) report. the grid having first three columns are with check boxes. Now my requirement is if I tick or on tick those check boxes I need to track which records check boxes are modiried.
But I canot tracking the modified records . after ticking or unticking those check boxs values are not modified in intrnal table.
plese help this is very urgent.
Regards,
Shashikumar.GHi Kiran,
I displayed internal table with check boxes that is ok.
after displaying the internal table if i tick or un tick the records those are not modified in internal table but I need to track the records which are modified.
please give me repply urgently.
Regards,
Shashikumar.G -
How to get check box in alv grid list output
hi gurus,
can anyone inform me
how to get check box in alv output it should not be a pop up window
thank you
regards
kals.or
hi go through the fallowing code.
code*&----
*& Report YGS_ALV_BOM *
REPORT YGS_ALV_BOM .
TABLES : MAST,STKO,STPO.
TYPE-POOLS: SLIS.
TYPES : BEGIN OF TY_MAST,
CHECK_BOX,
MATNR TYPE MAST-MATNR,
WERKS TYPE MAST-WERKS,
STLAN TYPE MAST-STLAN,
STLNR TYPE MAST-STLNR,
STLAL TYPE MAST-STLAL,
END OF TY_MAST.
TYPES : BEGIN OF TY_STKO,
STLTY TYPE STKO-STLTY,
STLNR TYPE STKO-STLNR,
STLAL TYPE STKO-STLAL,
STKOZ TYPE STKO-STKOZ,
BMENG TYPE STKO-BMENG,
BMEIN TYPE STKO-BMEIN,
END OF TY_STKO.
TYPES : BEGIN OF TY_STPO,
LIGHTS,
STLTY TYPE STPO-STLTY,
STLNR TYPE STPO-STLNR,
STLKN TYPE STPO-STLKN,
STPOZ TYPE STPO-STPOZ,
IDNRK TYPE STPO-IDNRK,
MENGE TYPE STPO-MENGE,
MEINS TYPE STPO-MEINS,
END OF TY_STPO.
DATA : IT_MAST TYPE TABLE OF TY_MAST,
WA_MAST TYPE TY_MAST,
IT_STKO TYPE TABLE OF TY_STKO,
WA_STKO TYPE TY_STKO,
IT_STPO TYPE TABLE OF TY_STPO,
WA_STPO TYPE TY_STPO.
DATA : lt_fieldcat TYPE slis_t_fieldcat_alv,
ls_layout TYPE slis_layout_alv,
ls_event TYPE slis_alv_event,
lt_event TYPE slis_t_event,
it_sortinfo type slis_t_sortinfo_alv,
ls_header TYPE slis_listheader,
lt_header TYPE slis_t_listHEADER.
DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
SELECT-OPTIONS : S_MATNR FOR MAST-MATNR.
START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM BUILD_FIELDCAT USING LT_FIELDCAT.
PERFORM BUILD_LAYOUT.
END-OF-SELECTION.
PERFORM DISPLAY_DATA.
*& Form GET_DATA
text
--> p1 text
<-- p2 text
form GET_DATA .
REFRESH : IT_MAST.
SELECT MATNR
WERKS
STLAN
STLNR
FROM MAST
INTO CORRESPONDING FIELDS OF TABLE IT_MAST
WHERE MATNR IN S_MATNR.
endform. " GET_DATA
*& Form BUILD_FIELDCAT
text
--> p1 text
<-- p2 text
form BUILD_FIELDCAT USING LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA : L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
REFRESH : LT_FIELDCAT.
L_FIELDCAT-COL_POS = 1.
L_FIELDCAT-FIELDNAME = 'MATNR'.
L_FIELDCAT-TABNAME = 'IT_MAST'.
L_FIELDCAT-REF_FIELDNAME = 'MATNR'.
L_FIELDCAT-REF_TABNAME = 'MAST'.
APPEND L_FIELDCAT TO LT_FIELDCAT.
L_FIELDCAT-COL_POS = 2.
L_FIELDCAT-FIELDNAME = 'WERKS'.
L_FIELDCAT-TABNAME = 'IT_MAST'.
L_FIELDCAT-REF_FIELDNAME = 'WERKS'.
L_FIELDCAT-REF_TABNAME = 'MAST'.
APPEND L_FIELDCAT TO LT_FIELDCAT.
L_FIELDCAT-COL_POS = 3.
L_FIELDCAT-FIELDNAME = 'STLNR'.
L_FIELDCAT-TABNAME = 'IT_MAST'.
L_FIELDCAT-REF_FIELDNAME = 'STLNR'.
L_FIELDCAT-REF_TABNAME = 'MAST'.
APPEND L_FIELDCAT TO LT_FIELDCAT.
endform. " BUILD_FIELDCAT
*& Form BUILD_LAYOUT
text
--> p1 text
<-- p2 text
form BUILD_LAYOUT .
CLEAR LS_LAYOUT.
LS_LAYOUT-BOX_FIELDNAME = 'CHECK_BOX'.
LS_LAYOUT-BOX_TABNAME = 'IT_MAST'.
endform. " BUILD_LAYOUT
*& Form DISPLAY_DATA
text
--> p1 text
<-- p2 text
form DISPLAY_DATA .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_STRUCTURE_NAME =
IS_LAYOUT = LS_LAYOUT
IT_FIELDCAT = LT_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 = IT_MAST
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. " DISPLAY_DATA
FORM PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'YSTATUS' OF PROGRAM SY-REPID
EXCLUDING RT_EXTAB.
ENDFORM.
FORM USER_COMMAND USING RF_UCOMM TYPE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
CASE RF_UCOMM.
WHEN '&NEXT'.
PERFORM GET_DATA_BOM .
PERFORM BUILD_FIELDCAT_BOM USING LT_FIELDCAT.
PERFORM BUILD_LAYOUT_BOM.
PERFORM DISPLAY_DATA_BOM.
ENDCASE.
ENDFORM.
*& Form GET_DATA_BOM
text
--> p1 text
<-- p2 text
form GET_DATA_BOM .
CLEAR : WA_STPO,
WA_MAST.
REFRESH : IT_STPO.
DATA : IT_CHECK TYPE TABLE OF TY_MAST.
LOOP AT IT_MAST INTO WA_MAST.
IF WA_MAST-CHECK_BOX EQ 'X'.
APPEND WA_MAST TO IT_CHECK.
ENDIF.
ENDLOOP.
SELECT STLTY
STLNR
STLKN
VGKNT
IDNRK
MENGE
MEINS
FROM STPO
INTO CORRESPONDING FIELDS OF TABLE IT_STPO
FOR ALL ENTRIES IN IT_CHECK
WHERE IDNRK EQ IT_CHECK-MATNR.
CLEAR WA_STPO.
LOOP AT IT_STPO INTO WA_STPO.
SELECT SINGLE * FROM MAST WHERE MATNR EQ WA_STPO-IDNRK.
IF SY-SUBRC = 0.
WA_STPO-LIGHTS = '2'.
ELSE.
WA_STPO-LIGHTS = '1'.
ENDIF.
MODIFY IT_STPO FROM WA_STPO.
ENDLOOP.
endform. " GET_DATA_BOM
*& Form BUILD_FIELDCAT_BOM
text
--> p1 text
<-- p2 text
form BUILD_FIELDCAT_BOM USING LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA : L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
REFRESH : LT_FIELDCAT.
L_FIELDCAT-COL_POS = 1.
L_FIELDCAT-FIELDNAME = 'STLTY'.
L_FIELDCAT-TABNAME = 'IT_STPO'.
L_FIELDCAT-REF_FIELDNAME = 'STLTY'.
L_FIELDCAT-REF_TABNAME = 'STPO'.
APPEND L_FIELDCAT TO LT_FIELDCAT.
L_FIELDCAT-COL_POS = 2.
L_FIELDCAT-FIELDNAME = 'STLNR'.
L_FIELDCAT-TABNAME = 'IT_STPO'.
L_FIELDCAT-REF_FIELDNAME = 'STLNR'.
L_FIELDCAT-REF_TABNAME = 'STPO'.
APPEND L_FIELDCAT TO LT_FIELDCAT.
L_FIELDCAT-COL_POS = 3.
L_FIELDCAT-FIELDNAME = 'STLKN'.
L_FIELDCAT-TABNAME = 'IT_STPO'.
L_FIELDCAT-REF_FIELDNAME = 'STLKN'.
L_FIELDCAT-REF_TABNAME = 'STPO'.
APPEND L_FIELDCAT TO LT_FIELDCAT.
L_FIELDCAT-COL_POS = 4.
L_FIELDCAT-FIELDNAME = 'IDNRK'.
L_FIELDCAT-TABNAME = 'IT_STPO'.
L_FIELDCAT-REF_FIELDNAME = 'IDNRK'.
L_FIELDCAT-REF_TABNAME = 'STPO'.
APPEND L_FIELDCAT TO LT_FIELDCAT.
L_FIELDCAT-COL_POS = 5.
L_FIELDCAT-FIELDNAME = 'MENGE'.
L_FIELDCAT-TABNAME = 'IT_STPO'.
L_FIELDCAT-REF_FIELDNAME = 'MENGE'.
L_FIELDCAT-REF_TABNAME = 'STPO'.
APPEND L_FIELDCAT TO LT_FIELDCAT.
endform. " BUILD_FIELDCAT_BOM
*& Form BUILD_LAYOUT_BOM
text
--> p1 text
*<-- p2 text
form BUILD_LAYOUT_BOM .
CLEAR : LS_LAYOUT.
LS_LAYOUT-LIGHTS_FIELDNAME = 'LIGHTS'.
LS_LAYOUT-LIGHTS_TABNAME = 'IT_STPO'.
endform. " BUILD_LAYOUT_BOM
*& Form DISPLAY_DATA_BOM
text
--> p1 text
<-- p2 text
form DISPLAY_DATA_BOM .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND_BOM'
I_CALLBACK_TOP_OF_PAGE = 'TOP9'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = 'ALV_BACKGROUND'
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = LS_LAYOUT
IT_FIELDCAT = LT_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
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = IT_STPO
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. " DISPLAY_DATA_BOM
FORM TOP9 .
CLEAR LS_HEADER.
REFRESH LT_HEADER.
LS_HEADER-TYP = 'H'.
LS_HEADER-INFO = 'BILL OF MATERIALS'.
APPEND LS_HEADER TO LT_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = LT_HEADER
I_LOGO = 'ENJOYSAP_LOGO'
I_END_OF_LIST_GRID =
ENDFORM.
FORM USER_COMMAND_BOM USING RF_UCOMM_BOM LIKE SY-UCOMM
SEL_FIELD TYPE SLIS_SELFIELD.
CASE RF_UCOMM_BOM.
WHEN '&IC1'.
SET PARAMETER ID 'MAT' FIELD WA_STPO-IDNRK.
SET PARAMETER ID 'WRK' FIELD WA_MAST-WERKS.
SET PARAMETER ID 'CSA' FIELD WA_MAST-STLAN.
CALL TRANSACTION 'CS03' AND SKIP FIRST SCREEN.
ENDCASE.[/code] -
How to add a check box in ALV Grid using SAP R/3 release 4.6b?
Hello everyone,
I hope you all fine.
I'm writing because I have a requirement with ALV Grid, what I need to do, is to insert a checkbox into a cell, I already read the forum to know how to do that, but I'm using a SAP R/3 release 4.6b, and when I execute the program the checkbox is displayed greyout, because this release doesn't have the EDIT property into the slis_t_fieldcat_alv.
Does any body know how to enable the checkbox cell in the ALV Grid for this release?, so it will allow the user to mark the desired rows.
I'll really appreciate if you guys could help me to find a solution.
Thanks for your time.
Regards,
GuillermoHi,
if you need just a check box for each line, try to get rid of this line from your layout.
g_layout-box_fieldname = 'ZZCHECK'.
SAP uses this field to store info about selected lines. Hence you click on the second check box, you select different line and the first line is erased. You can select more line by holding SHIFT + CTRL
Cheers -
Re: creating check boxes in ALV grid using web dynpro
Hi Techies,
I need to have a check box column in alv grid, and it should allow me to select the check box and the selected row has to be updated in the database.
Kindly assist me with the steps to handle the above mentioned scenario
Thanks in advance.Now to first make the last column of my ALV as a checkbox:
method BUILD_ALV .
data: l_ref_cmp_usage type ref to if_wd_component_usage.
" Instantiate the ALV usage
l_ref_cmp_usage = wd_This->wd_CpUse_My_Alv( ).
if l_ref_cmp_usage->has_active_component( ) is initial.
l_ref_cmp_usage->create_component( ).
endif.
" Get reference to the model
DATA: l_ref_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
l_ref_INTERFACECONTROLLER = wd_This->wd_CpIfc_My_Alv( ).
data: lr_config type ref to Cl_Salv_Wd_Config_Table.
lr_config = l_ref_INTERFACECONTROLLER->Get_Model( ).
|" Set read only mode to false (and display edit toolbar)
lr_config->if_salv_wd_table_settings~set_read_only( abap_false ).
data: lr_table_settings type ref to if_salv_wd_table_settings.
lr_table_settings ?= lr_config.
lr_table_settings->set_read_only( abap_false ).
data: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lt_columns TYPE salv_wd_t_column_ref,
lr_checkbox1 TYPE REF TO cl_salv_wd_uie_checkbox,
lr_checkbox2 TYPE REF TO cl_salv_wd_uie_checkbox.
FIELD-SYMBOLS <fs_column> LIKE LINE OF lt_columns.
" Embed the UI elements within the ALV
lr_column_settings ?= lr_config.
lt_columns = lr_column_settings->get_columns( ).
" Embed an checkbox within the column APPROVE
LOOP AT lt_columns ASSIGNING <fs_column>.
CASE <fs_column>-id.
WHEN 'APPROVE'.
CREATE OBJECT lr_checkbox1
EXPORTING
checked_fieldname = <fs_column>-id.
<fs_column>-r_column->set_cell_editor( lr_checkbox1 ).
FREE lr_checkbox1.
ENDCASE.
ENDLOOP.
ENDMETHOD. "BUILD_ALV -
Hi,
I want to display an ALV grid/ list report with a check box at the begining of each row.
I want to select some or all check boxes.
Based on the selection, i need to perform some action (like z table update).
Can u plz send the sample code to meet this requirement.
ThanksHi..
I had developed this code long time it uses container and its working
*& Report ZHR_REPT_EMP_NOT_PBOOKED
*& Program title: List of employees who have not done Pre-Booking and
* Provision to send E mail to such employees
*& Description: To display a list of emloyees in report and then sending mails to them
REPORT ZHR_REPT_EMP_NOT_PBOOKED.
TYPE-POOLS slis.
*-----------tables
TABLES: pernr,
pa0001,
hrp1001,
hrp1000,
zodtab,
zcstab,
zsbutab.
*-----------Infotypes
INFOTYPES :0001, "org assignment,
1001,
1000,
0105.
TYPES : BEGIN OF i_conf,
checkbox ,
pernr TYPE pa0001-pernr, "personnel Number.
ename TYPE pa0001-ename, "Name of Employee.
zzbtc TYPE pa0001-zzbtc, "Band.
btrtl TYPE pa0001-btrtl, "Grade
Location type string,
persk type string,
ptext type string,
werks TYPE p0001-werks,
zzod_txt type string, "OD name
zzod type pa0001-zzod,
zzcs type string, "cluster/sector
vertical type string,
sbu LIKE pa0001-zzsbu, "SBU
sbutxt LIKE zsbutab-zsbutxt, "SBUTXT
orgeh LIKE pa0001-orgeh, "Vertical
org_text type string,
zzbloc LIKE pa0001-zzbloc, "base location
dept_loc type string, "dept loc
ename_s LIKE pa0001-ename, "Department
zztc LIKE pa0001-zztc,
endda type p0001-endda,
celltab type lvc_t_styl,
END OF i_conf.
DATA : it_conf TYPE STANDARD TABLE OF i_conf WITH HEADER LINE,
wa_conf TYPE i_conf.
*data: begin of gs_outtab.
*data: checkbox type c. "field for checkbox
** §B1.Extend your output table by a field to dis- or enable
** cells for input.
*data: celltab type lvc_t_styl. "field to switch editability
* include structure i_conf.
*data: end of gs_outtab.
*data: gt_outtab type gs_outtab occurs 0 with header line.
*& DATA DECLARATION FOR EMAIL
DATA: docdata TYPE sodocchgi1,
objpack TYPE STANDARD TABLE OF sopcklsti1 WITH HEADER LINE,
objhead TYPE STANDARD TABLE OF solisti1 WITH HEADER LINE,
objtxt TYPE STANDARD TABLE OF solisti1 WITH HEADER LINE,
objbin TYPE STANDARD TABLE OF solisti1 WITH HEADER LINE,
reclist TYPE STANDARD TABLE OF somlreci1 WITH HEADER LINE.
DATA: tab_lines TYPE sy-tabix.
DATA : p_1001 TYPE TABLE OF p1001 WITH HEADER LINE.
DATA : p_0001 TYPE TABLE OF p0001 WITH HEADER LINE.
DATA : p_0105 TYPE TABLE OF p0105 WITH HEADER LINE.
DATA : od TYPE p0001-zzod.
DATA : new_pernr type p0001-pernr.
DATA : pernr_s type p0001-pernr.
DATA : email_s type p0105-USRID_LONG.
DATA : email type p0105-USRID_LONG.
DATA : tc_name type string.
DATA : tc_num type string.
DATA : emails type string.
DATA : sel_all type string.
DATA: REF_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA : flag type i.
DATA : title TYPE string.
DATA : pernr_temp tYPE p0001-pernr.
DATA : rel type string.
DATA : stat type string.
DATA : count type i.
DATA : v_dynnr type sy-dynnr.
DATA : g_grid type ref to cl_gui_alv_grid.
DATA : g_custom_container type ref to cl_gui_custom_container,
g_container type scrfname value 'CC'.
*************field cat********************************
DATA: fieldcat TYPE lvc_t_fcat,
wa_fieldcat LIKE LINE OF fieldcat.
DATA: gd_layout TYPE lvc_s_layo,
gd_repid TYPE sy-repid.
DATA:gt_events TYPE slis_t_event,
gt_list_top_of_page TYPE slis_t_listheader.
DATA rec_fetched TYPE sy-tabix.
CONSTANTS g_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_zzod FOR zsbutab-zod NO INTERVALS ,
s_btrtl FOR pa0001-btrtl NO INTERVALS.
SELECTION-SCREEN END OF BLOCK b1.
start-of-selection.
if pn-begda is initial.
pn-begda = '18000101'.
endif.
if pn-endda is initial.
pn-begda = '99991230'.
endif.
clear : it_conf,it_conf[].
get pernr.
clear new_pernr.
move pernr-pernr to new_pernr.
**************checking whether employee has booked or prebooked for any event****************
clear: p_1001,p_1001[].
perform read_info tables p_1001 using new_pernr '1' 'B027' .
IF SY-SUBRC <> 0.
clear: p_1001,p_1001[].
perform read_info tables p_1001 using new_pernr '1' 'B023' .
IF SY-SUBRC <> 0.
clear: p_1001,p_1001[].
perform read_info tables p_1001 using new_pernr '2' 'B027' .
IF SY-SUBRC <> 0.
clear: p_1001,p_1001[].
perform read_info tables p_1001 using new_pernr '2' 'B023' .
IF SY-SUBRC <> 0.
clear : p_0001,p_0001[].
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
pernr = new_pernr
infty = '0001'
BEGDA = pn-begda
ENDDA = pn-endda
TABLES
infty_tab = p_0001
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.
sort p_0001 descending by begda.
read table p_0001 index 1.
move p_0001-pernr to wa_conf-pernr.
move p_0001-ename to wa_conf-ename.
move p_0001-zzbtc to wa_conf-zzbtc.
move p_0001-btrtl to wa_conf-btrtl.
move p_0001-werks to wa_conf-werks.
move p_0001-zzsbu to wa_conf-sbu.
move p_0001-orgeh to wa_conf-orgeh.
move p_0001-zzbloc to wa_conf-zzbloc.
move p_0001-zztc to wa_conf-zztc.
move p_0001-zzod to wa_conf-zzod.
move p_0001-endda to wa_conf-endda.
move p_0001-btrtl to wa_conf-btrtl.
***************clustor txt**********************
select single zcstxt into wa_conf-zzcs from zcstab
where zcs = p_0001-zzcs
and zod = p_0001-zzod.
***********operating division*******************************
select single ZODLTXT into wa_conf-zzod_txt from zodtab
where zod = wa_conf-zzod.
***********sbu txt***************************************************************
select single zsbutxt into wa_conf-sbutxt from zsbutab
where zsbu = wa_conf-sbu.
***********location**************************************
select single btext into wa_conf-location from t001p
where btrtl = wa_conf-btrtl
and werks = wa_conf-werks.
***********Dept*********************************************
select single orgtx into wa_conf-org_text from t527x
where sprsl = 'EN'
and orgeh = wa_conf-orgeh
and begda <= p_0001-begda
and endda >= p_0001-begda.
***************grade******************************************
SELECT SINGLE ptext FROM t503t INTO wa_conf-persk
WHERE sprsl = 'EN'
AND persk = p_0001-persk .
********************vertical*****************************
select single zverttxt into wa_conf-vertical from zvtab
where zvert = p_0001-zzvert.
********deputation location******************
if p_0001-ZZDEPFLG = 'X'.
select single zdltxt into wa_conf-dept_loc from zdltab where zdl = p_0001-zzdploc.
endif.
***get imm superior
CALL FUNCTION 'ZHR_GET_IMMMED_SUPERIOR'
EXPORTING
pernr = new_pernr
* begda = '18000101'
* endda = '99991231'
IMPORTING
v_pernr = pernr_s
EXCEPTIONS
not_found = 1
OTHERS = 2.
if sy-subrc = 0.
** find the email of the immed. superiors personal number..
clear : p_0001,p_0001[].
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
pernr = pernr_s
infty = '0001'
BEGDA = pn-begda
ENDDA = pn-endda
TABLES
infty_tab = p_0001
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.
read table p_0001 index 1.
move p_0001-ename to wa_conf-ename_s.
endif.
if wa_conf-btrtl in s_btrtl and wa_conf-zzod in s_zzod .
append wa_conf to it_conf.
endif.
endif.
endif.
endif.
endif.
clear wa_conf.
end-of-selection.
if it_conf[] is initial.
MESSAGE i501(zmod).
exit.
endif.
CALL SCREEN 100.
*& Module STATUS_0100 OUTPUT
* text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'USER'.
* SET TITLEBAR 'xxx'.
if g_custom_container is initial.
data: lt_exclude type ui_functions.
create object g_custom_container
EXPORTING
container_name = g_container.
create object g_grid
EXPORTING
i_parent = g_custom_container.
perform fieldcat_build .
* Exclude all edit functions in this example since we do not need them:
perform exclude_tb_functions changing lt_exclude.
* perform build_data.
*§ B3.Use the layout structure to aquaint additional field to ALV.
gd_layout-stylefname = 'CELLTAB'.
PERFORM build_layout.
if it_conf[] is initial.
* MESSAGE i501(zmod). "No data exists
else.
call method g_grid->set_table_for_first_display
EXPORTING
is_layout = gd_layout
it_toolbar_excluding = lt_exclude
CHANGING
it_fieldcatalog = fieldcat
it_outtab = it_conf[].
* create object g_event_receiver.
* set handler g_event_receiver->catch_doubleclick for g_grid.
* Set editable cells to ready for input initially
call method g_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
endif.
endif.
ENDMODULE. " STATUS_0100 OUTPUT
*call screen 100.
*& Form build_layout
FORM build_layout.
CLEAR gd_layout.
v_dynnr = 100.
gd_layout-cwidth_opt = 'X'.
* gd_layout-zebra = 'X'.
* gd_layout-grid_title = text-002.
ENDFORM. "build_layout
*& Form exclude_tb_functions
* text
* -->PT_EXCLUDE text
form exclude_tb_functions changing pt_exclude type ui_functions.
data ls_exclude type ui_func.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.
append ls_exclude to pt_exclude.
endform. "exclude_tb_functions
*& Form field_cat
* text
FORM fieldcat_build .
wa_fieldcat-fieldname = 'CHECKBOX'.
wa_fieldcat-tabname = 'IT_CONF'.
wa_fieldcat-checkbox = 'X'.
wa_fieldcat-edit = 'X'.
APPEND wa_fieldcat TO fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'PERNR'.
wa_fieldcat-coltext = 'P.S. No'.
wa_fieldcat-tabname = 'IT_CONF'.
APPEND wa_fieldcat TO fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ENAME'.
wa_fieldcat-coltext = 'Employee Name'.
wa_fieldcat-tabname = 'IT_CONF'.
APPEND wa_fieldcat TO fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ZZBTC'.
wa_fieldcat-coltext = 'Band'.
wa_fieldcat-tabname = 'IT_CONF'.
APPEND wa_fieldcat TO fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'PERSK'.
wa_fieldcat-coltext = 'Grade'.
wa_fieldcat-tabname = 'IT_CONF'.
APPEND wa_fieldcat TO fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ZZOD'.
wa_fieldcat-coltext = 'OD Name'.
wa_fieldcat-tabname = 'IT_CONF'.
APPEND wa_fieldcat TO fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ZZCS'.
wa_fieldcat-coltext = 'Cluster / Sector '.
wa_fieldcat-tabname = 'IT_CONF'.
APPEND wa_fieldcat TO fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'VERTICAL'.
wa_fieldcat-coltext = 'Vertical'.
wa_fieldcat-tabname = 'IT_CONF'.
APPEND wa_fieldcat TO fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'SBUTXT'.
wa_fieldcat-coltext = 'SBU'.
wa_fieldcat-tabname = 'IT_CONF'.
APPEND wa_fieldcat TO fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ORG_TEXT'.
wa_fieldcat-coltext = 'Dept.'.
wa_fieldcat-tabname = 'IT_CONF'.
APPEND wa_fieldcat TO fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'LOCATION'.
wa_fieldcat-coltext = 'Empl. Base Location '.
wa_fieldcat-tabname = 'IT_CONF'.
APPEND wa_fieldcat TO fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'DEPT_LOC'.
wa_fieldcat-coltext = 'Empl. Deputation Location '.
wa_fieldcat-tabname = 'IT_CONF'.
APPEND wa_fieldcat TO fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ENAME_S'.
wa_fieldcat-coltext = 'IS Name '.
wa_fieldcat-tabname = 'IT_CONF'.
APPEND wa_fieldcat TO fieldcat.
clear wa_fieldcat.
endform. "field_cat
*& Form check_lock
* text
* -->PS_OUTTAB text
* -->P_LOCKED text
form check_lock using ps_outtab type i_conf
changing p_locked.
data ls_celltab type lvc_s_styl.
loop at ps_outtab-celltab into ls_celltab.
if ls_celltab-fieldname = 'CHECKBOX'.
if ls_celltab-style eq cl_gui_alv_grid=>mc_style_disabled.
p_locked = 'X'.
else.
p_locked = space.
endif.
endif.
endloop.
endform. "check_lock
*& Module USER_COMMAND_0100 INPUT
* text
MODULE USER_COMMAND_0100 INPUT.
IF sy-ucomm = 'EMAIL'.
clear it_conf.
* CALL METHOD g_grid->refresh_table_display.
data: ls_outtab type i_conf.
data: l_valid type c,
l_locked type c.
*§A4ad. Before you (a)set, reset or (d)evaluate checkboxes,
* you must check the input cells.
* If all entries are ok, ALV transferes new values to the output
* table which you then can modify.
call method g_grid->check_changed_data
IMPORTING
e_valid = l_valid.
if l_valid eq 'X'.
loop at it_conf into ls_outtab.
if not ls_outtab-checkbox is initial
and not ls_outtab-checkbox eq '-'.
***************************sending mail to employee and his/her superior************************************
select single sachn telnr into (tc_name , tc_num) from t526
where SACHX = it_conf-zztc
and werks = it_conf-werks .
* ******find the emil of employee.
clear : p_0105,p_0105[].
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
pernr = ls_outtab-pernr
infty = '0105'
BEGDA = pn-begda
ENDDA = pn-endda
TABLES
infty_tab = p_0105
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.
if sy-subrc = 0.
read table p_0105 with key subty = '0010'.
move p_0105-USRID_LONG to email.
endif.
** find immediate superior by Z FM.
clear pernr_s.
CALL FUNCTION 'ZHR_GET_IMMMED_SUPERIOR'
EXPORTING
pernr = ls_outtab-pernr
IMPORTING
v_pernr = pernr_s
EXCEPTIONS
not_found = 1
OTHERS = 2.
if sy-subrc = 0.
** find the email of the immed. superiors personal number..
clear : p_0105,p_0105[].
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
pernr = pernr_s
infty = '0105'
BEGDA = pn-begda
ENDDA = pn-endda
TABLES
infty_tab = p_0105
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.
read table p_0105 with key subty = '0010'.
move p_0105-USRID_LONG to email_s.
endif.
if email <> ' '.
count = 1.
perform send_mail using ls_outtab-ename email email_s tc_name tc_num count .
endif.
if email_s <> ' '.
count = 2.
perform send_mail using ls_outtab-ename email email_s tc_name tc_num count.
endif.
call method g_grid->refresh_table_display.
modify it_conf from ls_outtab.
endif.
endloop.
call method g_grid->refresh_table_display.
endif.
set screen 100.
endif.
***************************end of sending mail*****************************************************
IF sy-ucomm = 'SELECT'.
* CALL METHOD g_grid->refresh_table_display.
*§A4ad. Before you (a)set, reset or (d)evaluate checkboxes,
* you must check the input cells.
* If all entries are ok, ALV transferes new values to the output
* table which you then can modify.
call method g_grid->check_changed_data
IMPORTING
e_valid = l_valid.
if l_valid eq 'X'.
loop at it_conf into ls_outtab.
perform check_lock using ls_outtab
changing l_locked.
if l_locked is initial
and not ls_outtab-checkbox eq '-'.
ls_outtab-checkbox = 'X'.
endif.
modify it_conf from ls_outtab.
endloop.
call method g_grid->refresh_table_display.
endif.
set screen 100.
endif.
IF sy-ucomm = 'BCK' and v_dynnr = 100.
clear v_dynnr.
set screen 1000.
leave screen. " 0."1000.
**call selection-screen 1000.
*call screen 1000.
endif.
IF sy-ucomm = 'EXIT' and v_dynnr = 100.
clear v_dynnr.
leave program.
endif.
IF sy-ucomm = 'CANC' and v_dynnr = 100.
clear v_dynnr.
leave program.
endif.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form send_mail
* text
* -->EMAIL_S text
* -->EMAIL text
* -->TC_NAME text
* -->TC_NUM text
form send_mail using ename email email_s tc_name tc_num count.
* *Body of mail
CLEAR objtxt.
CLEAR objtxt[].
objtxt = text-005.
concatenate objtxt ename into objtxt separated by space.
append objtxt.
clear objtxt.
objtxt = text-006.
concatenate objtxt email_s into objtxt separated by space.
append objtxt.
clear objtxt.
append objtxt.
objtxt = text-002.
append objtxt.
clear objtxt.
objtxt = text-003.
append objtxt.
clear objtxt.
append objtxt.
objtxt = text-004.
concatenate objtxt tc_name 'at' tc_num into objtxt separated by space.
append objtxt.
clear objtxt.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
*Mail description
CLEAR docdata.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
docdata-obj_name = 'Reminder'.
docdata-obj_descr = 'REMINDER TO DO PRE-BOOKING'.
docdata-obj_langu = sy-langu.
*Packing list for main document
CLEAR objpack.
CLEAR objpack[].
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
*Email receiver's list
CLEAR reclist.
CLEAR reclist[].
if count = 1.
* reclist-receiver = 'email address'."put email add here
reclist-receiver = email.
else.
reclist-receiver = email_s.
endif.
reclist-rec_type = 'U'.
APPEND reclist.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = docdata
document_type = 'RAW'
put_in_outbox = 'X'
commit_work = 'X'
TABLES
object_content = objtxt
receivers = reclist
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
OTHERS = 8.
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. "send_mail
*& Form eventtab_build
FORM eventtab_build USING rt_events TYPE slis_t_event.
*Registration of events to happen during list display
DATA: ls_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = rt_events.
READ TABLE rt_events WITH KEY name = slis_ev_top_of_page INTO ls_event.
IF sy-subrc = 0.
MOVE g_top_of_page TO ls_event-form.
APPEND ls_event TO rt_events.
ENDIF.
ENDFORM. "eventtab_build
*& Form top_of_page
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = gt_list_top_of_page.
ENDFORM. "top_of_page
*& Form COMMENT_BUILD
FORM comment_build USING lt_top_of_page TYPE slis_t_listheader.
DATA: ls_line TYPE slis_listheader,
rp_date TYPE string. "report date
* LIST HEADING LINE: TYPE H
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = text-007.
APPEND ls_line TO lt_top_of_page.
CONCATENATE sy-datum+6(2) sy-datum+4(2) sy-datum(4) INTO rp_date SEPARATED BY '.'.
* STATUS LINE: TYPE S
CLEAR ls_line.
ls_line-typ = 'S'.
ls_line-key = text-008.
ls_line-info = rp_date.
APPEND ls_line TO lt_top_of_page.
ENDFORM. "comment_build
*& Form read_info
* text
* -->P_1001 text
* -->PERNR text
* -->STAT text
* -->REL text
form read_info tables p_1001 using pernr stat rel.
CALL FUNCTION 'RH_READ_INFTY_1001'
EXPORTING
AUTHORITY = 'DISP'
WITH_STRU_AUTH = 'X'
PLVAR = '01'
OTYPE = 'P'
OBJID = pernr
ISTAT = stat
SUBTY = rel
BEGDA = pn-begda
ENDDA = pn-endda
TABLES
I1001 = p_1001
EXCEPTIONS
NOTHING_FOUND = 1
WRONG_CONDITION = 2
WRONG_PARAMETERS = 3
OTHERS = 4.
endform. "read_info
*& Module BACK INPUT
* text
MODULE BACK INPUT.
IF SY-UCOMM = 'E'.
leave program.
endif.
IF SY-UCOMM = 'ENDE'.
leave program.
endif.
IF SY-UCOMM = 'ECAN'.
leave program.
endif.
ENDMODULE. " BACK INPUT
regards
vivek -
Hi ,
I am creating a Check box in WAD which is a selection variable for a characteristic. I am able to get the display of all the values listed.
Problem is : I want to have the list of values displayed with a check mark and I am not able to see where to make this setting in WAD.
Any suggestions....
ThanksHello Raj
Given the fact that you do not tell us the most important piece of information (namely whether you are using OO-based ALV or not) I assume you are using fm-based ALV lists.
In this case you probably have defined a USER_COMMAND routine as described in the documentation of the fm.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* define local data
DATA: ls_outtab LIKE LINE OF gt_outtab,
ld_idx TYPE i.
LOOP AT gt_outtab INTO ls_outtab
WHERE ( chkbox = 'X' ).
ld_idx = syst-tabix.
" Call your update function / method / perform
ls_outtab-chkbox = space.
MODIFY gt_outtab FROM ls_outtab INDEX ld_Idx
TRANSPORTING chkbox.
ENDLOOP.
" And now trigger refresh of the ALV display:
rs_selfield-refresh = 'X'. " <<< !!!
ENDFORM.
Regards
Uwe -
Check box in ALV grid gets unselected for new selection
Hi all,
This is my code :
TYPE-POOLS : slis.
Variable
DATA: g_repid LIKE sy-repid,
g_title TYPE lvc_title,
g_set_pf_stat TYPE slis_formname VALUE 'SET_PF_STATUS',
g_user_command TYPE slis_formname VALUE 'USER_COMMAND',
g_layout TYPE slis_layout_alv,
g_print_alv TYPE slis_print_alv,
g_variant LIKE disvariant,
c_char_a(1) VALUE 'A',
c_char_x(1) VALUE 'X',
itab_alv_sort TYPE slis_t_sortinfo_alv,
itab_alv_fcat TYPE slis_t_fieldcat_alv,
fm_name type rs38l_fnam," Function Module Name
* l_sfctrlparams LIKE ssfctrlop, " Form Print Parameter
* l_sfoutopt LIKE ssfcompop,
pri_params LIKE pri_params,
c_x type c .
* Internal tables Begin with IT_ *
DATA : it_fcat TYPE SLIS_T_FIELDCAT_ALV, "---ALV
it_disp type table of ZLOI.
* Work Area for Internal tables Begin with WA_ *
data : wa_fcat TYPE slis_fieldcat_alv , "---ALV
wa_layout TYPE lvc_s_layo, "---ALV
wa_it_disp like line of it_disp.
* Objects *
DATA : cref TYPE REF TO cl_gui_custom_container, "---ALV
gref TYPE REF TO cl_gui_alv_grid. "---ALV
* Start-of-selection
Start-of-selection.
perform fetch_po_det.
perform build_fcat.
perform alv_display.
*& Form FETCH_PO_DET
* text
* --> p1 text
* <-- p2 text
FORM FETCH_PO_DET .
data : it_po type table of crmd_orderadm_h,
wa_po like line of it_po,
wa_header type BBP_PDS_PO_HEADER_D.
select guid
object_id
DESCRIPTION
POSTING_DATE
CREATED_BY
from crmd_orderadm_h
into corresponding fields of table it_po
where object_type = 'BUS2201'.
loop at it_po into wa_po.
move wa_po-object_id to wa_it_disp-ZZPONO.
move wa_po-DESCRIPTION to wa_it_disp-ZZPODESC.
move wa_po-posting_date to wa_it_disp-ZZPODATE.
move wa_po-created_by to wa_it_disp-ZZPOCREATOR.
CALL FUNCTION 'BBP_PD_PO_GETDETAIL'
EXPORTING
I_OBJECT_ID = wa_it_disp-zzpono
IMPORTING
E_HEADER = wa_header.
move wa_header-total_value to wa_it_disp-ZZPOVAL.
move wa_header-currency to wa_it_disp-ZZPOCUR.
append wa_it_disp to it_disp.
endloop.
* write : wa_it_disp-zzpono.
ENDFORM. " FETCH_PO_DET
*& Form BUILD_FCAT
* text
* --> p1 text
* <-- p2 text
FORM BUILD_FCAT .
g_repid = sy-repid.
g_title = 'LOI details'.
g_print_alv-no_print_listinfos = 'X'.
g_variant-report = sy-repid.
g_variant-variant = sy-title.
CLEAR g_layout.
g_layout-f2code = ' '.
wa_layout-zebra = 'X'.
g_layout-flexible_key = 'X'.
g_layout-colwidth_optimize = 'X'.
g_layout-detail_initial_lines = 'X'.
g_layout-box_fieldname = 'ZZCHECK'.
*g_layout-box_tabname = 'ITAB_REPORT'.
*Check box
wa_fcat-fieldname = 'ZZCHECK'.
wa_fcat-checkbox = 'X'.
wa_fcat-outputlen = '1'.
wa_fcat-col_pos = '1'.
wa_fcat-edit = '1'.
wa_fcat-seltext_m = 'No'.
append wa_fcat to it_fcat.
*Po no
clear wa_fcat.
wa_fcat-fieldname = 'ZZPONO' .
wa_fcat-tabname = 'IT_DISP'.
* wa_fcat-seltext = 'Purchase Order'.
wa_fcat-seltext_m = 'Purchase Order'.
*wa_fcat-seltext_s = 'Purchase Order.
wa_fcat-icon = 'X'.
wa_fcat-col_pos = '2'.
wa_fcat-outputlen = 10.
append wa_fcat to it_fcat.
*Desc
wa_fcat-fieldname = 'ZZPODESC' .
wa_fcat-tabname = 'IT_DISP'.
*wa_fcat-seltext_l = 'Description'.
wa_fcat-seltext_m = 'Description'.
*wa_fcat-seltext_s = 'Description'.
wa_fcat-col_pos = '3'.
wa_fcat-outputlen = 10.
append wa_fcat to it_fcat.
*Postign date
wa_fcat-fieldname = 'ZZPODATE' .
wa_fcat-tabname = 'IT_DISP'.
wa_fcat-seltext_l = 'Posting Date'.
wa_fcat-seltext_m = 'Posting Date'.
*wa_fcat-seltext_s = 'Posting Date'.
wa_fcat-col_pos = '4'.
wa_fcat-outputlen = 8.
append wa_fcat to it_fcat.
*value
wa_fcat-fieldname = 'ZZPOVAL' .
wa_fcat-tabname = 'IT_DISP'.
*wa_fcat-seltext_l = 'PO value'.
wa_fcat-seltext_m = 'PO value'.
*wa_fcat-seltext_s = 'PO value'.
wa_fcat-col_pos = '5'.
wa_fcat-outputlen = 15.
append wa_fcat to it_fcat.
*Currency
wa_fcat-fieldname = 'ZZPOCUR' .
wa_fcat-tabname = 'IT_DISP'.
*wa_fcat-seltext_l = 'PO Currency'.
wa_fcat-seltext_m = 'PO Currency'.
*wa_fcat-seltext_s = 'PO Currency'.
wa_fcat-col_pos = '6'.
wa_fcat-outputlen = 5.
append wa_fcat to it_fcat.
*Creator
wa_fcat-fieldname = 'ZZPOCREATOR' .
wa_fcat-tabname = 'IT_DISP'.
*wa_fcat-seltext_l = 'Buyer'.
wa_fcat-seltext_m = 'Buyer'.
*wa_fcat-seltext_s = 'Buyer'.
wa_fcat-col_pos = '7'.
wa_fcat-outputlen = 12.
append wa_fcat to it_fcat.
ENDFORM. " BUILD_FCAT
*& Form ALV_DISPLAY
* text
* --> p1 text
* <-- p2 text
FORM ALV_DISPLAY .
sort it_disp by ZZPONO.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = g_repid
I_CALLBACK_PF_STATUS_SET = g_set_pf_stat
I_CALLBACK_USER_COMMAND = g_user_command
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
I_GRID_TITLE = g_title
* I_GRID_SETTINGS =
IS_LAYOUT = g_layout
IT_FIELDCAT = it_fcat[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
IS_VARIANT = g_variant
* IT_EVENTS =
* IT_EVENT_EXIT =
IS_PRINT = g_print_alv
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = it_disp[]
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. " ALV_DISPLAY
*& Form user_command
* text
* -->R_UCOMM text
* -->RS_SELFIELD text
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield. "#EC CALLED
CASE R_UCOMM.
WHEN 'PRINT'.
READ TABLE IT_disp INTO WA_IT_DISP WITH KEY ZZCHECK = 'X'.
IF SY-SUBRC EQ 0.
loop at it_DISP INTO WA_IT_DISP.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TEXT_QUESTION = 'Print the LOI details?'
TEXT_BUTTON_1 = 'Yes'
TEXT_BUTTON_2 = 'No'.
* IMPORTING
* ANSWER = w_answer.
IF SY-SUBRC 0.
ENDIF.
* PERFORM CALL_SF.
endloop.
ENDIF.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'CANCEL'.
LEAVE PROGRAM.
ENDCASE.
rs_selfield-refresh = 'X'.
ENDFORM. "user_command
*& Form set_pf_status
* text
* -->RT_EXTAB text
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZSTANDARD' EXCLUDING rt_extab.
SET TITLEBAR sy-tcode.
ENDFORM. "set_pf_status
Now in my ALV grid o/p i can see the check box but if i select one row and then try to slect another the first one gets deselected.
Can anybody tell me what is missing?Hi,
if you need just a check box for each line, try to get rid of this line from your layout.
g_layout-box_fieldname = 'ZZCHECK'.
SAP uses this field to store info about selected lines. Hence you click on the second check box, you select different line and the first line is erased. You can select more line by holding SHIFT + CTRL
Cheers -
Problem while setting PF_status in ALV Grid Display
Hi,
i have a final internal table with first field as a check box. I have delete button on application tool-bar, with usercommand and pf status defined for it.
Once the output is displayed i should have the option of checking the line (check box) and delete then records from the list.
problem here is once i check the box and click on delete button is not getting deleted. but instead if i check the box and double click on the line(ie f2 fuctionality) and then click on refresh, then the records are getting deleted.
i have not provided and pf status for f2 functionality, by default its getting activated before the delete fuctionality is called.
i have attached my code below.
DATA : fk_events TYPE slis_t_event,
f_user_command TYPE slis_formname VALUE 'USER_COMMAND',
f_status TYPE slis_formname VALUE 'STANDARD_SP01',
fieldnam(10) TYPE c.
DATA: gs_layout TYPE slis_layout_alv.
DATA: ls_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = fk_events.
READ TABLE fk_events INTO ls_event WITH KEY name = slis_ev_user_command
IF sy-subrc = 0.
MOVE f_user_command TO ls_event-form.
MODIFY fk_events FROM ls_event TRANSPORTING form WHERE name =
ls_event-name.
ENDIF.
READ TABLE fk_events INTO ls_event WITH KEY name =
slis_ev_pf_status_set
IF sy-subrc = 0.
MOVE f_status TO ls_event-form.
MODIFY fk_events FROM ls_event TRANSPORTING form WHERE name =
ls_event-name.
ENDIF.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'ZWR_SECOND_TO_CREATION1'
i_callback_pf_status_set = f_status
i_callback_user_command = f_user_command
it_fieldcat = gt_fieldcat[]
it_events = fk_events[]
TABLES
t_outtab = gt_final[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
FORM user_command USING r_comm TYPE sy-ucomm
rs_selfield TYPE slis_selfield.
fieldnam = rs_selfield-fieldname.
CASE r_comm.
WHEN 'DELETE''.
LOOP AT gt_final INTO gk_final.
IF gk_final-del_sat = 'X'.
DELETE gt_final WHERE vbeln = gk_final-vbeln.
ENDIF.
rs_selfield-refresh = 'X'.
ENDLOOP.
WHEN OTHERS.
EXIT.
ENDCASE.
FORM standard_sp01 USING extab TYPE slis_t_extab.
SET PF-STATUS 'RAM' EXCLUDING extab. " For PF-Status
ENDFORM. "STANDARD_SP01
i wud be very thankful if someone cud help me
thanx
ramHi,
i have a final internal table with first field as a check box. I have delete button on application tool-bar, with usercommand and pf status defined for it.
Once the output is displayed i should have the option of checking the line (check box) and delete then records from the list.
problem here is once i check the box and click on delete button is not getting deleted. but instead if i check the box and double click on the line(ie f2 fuctionality) and then click on refresh, then the records are getting deleted.
i have not provided and pf status for f2 functionality, by default its getting activated before the delete fuctionality is called.
i have attached my code below.
DATA : fk_events TYPE slis_t_event,
f_user_command TYPE slis_formname VALUE 'USER_COMMAND',
f_status TYPE slis_formname VALUE 'STANDARD_SP01',
fieldnam(10) TYPE c.
DATA: gs_layout TYPE slis_layout_alv.
DATA: ls_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = fk_events.
READ TABLE fk_events INTO ls_event WITH KEY name = slis_ev_user_command
IF sy-subrc = 0.
MOVE f_user_command TO ls_event-form.
MODIFY fk_events FROM ls_event TRANSPORTING form WHERE name =
ls_event-name.
ENDIF.
READ TABLE fk_events INTO ls_event WITH KEY name =
slis_ev_pf_status_set
IF sy-subrc = 0.
MOVE f_status TO ls_event-form.
MODIFY fk_events FROM ls_event TRANSPORTING form WHERE name =
ls_event-name.
ENDIF.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'ZWR_SECOND_TO_CREATION1'
i_callback_pf_status_set = f_status
i_callback_user_command = f_user_command
it_fieldcat = gt_fieldcat[]
it_events = fk_events[]
TABLES
t_outtab = gt_final[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
FORM user_command USING r_comm TYPE sy-ucomm
rs_selfield TYPE slis_selfield.
fieldnam = rs_selfield-fieldname.
CASE r_comm.
WHEN 'DELETE''.
LOOP AT gt_final INTO gk_final.
IF gk_final-del_sat = 'X'.
DELETE gt_final WHERE vbeln = gk_final-vbeln.
ENDIF.
rs_selfield-refresh = 'X'.
ENDLOOP.
WHEN OTHERS.
EXIT.
ENDCASE.
FORM standard_sp01 USING extab TYPE slis_t_extab.
SET PF-STATUS 'RAM' EXCLUDING extab. " For PF-Status
ENDFORM. "STANDARD_SP01
i wud be very thankful if someone cud help me
thanx
ram -
How to print check box in ALV list display and how to pick selected ones
Hi
i am displaying one ALV list dispaly. for that im adding one check box fields by filling the fieldcat as below:
wa_fldcat-checkbox = 'X'.
wa_fldcat-edit = 'X'.
but the check box is showing disable mode only. i want to display that check box and if i select that check box i want pick that records. for ALV grid i found one FM to pick records of selectedones as below.
DATA ref_grid TYPE REF TO cl_gui_alv_grid.
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.
IF ref_grid IS NOT INITIAL.
CALL METHOD ref_grid->check_changed_data.
ENDIF.
but how can i do for list display to pick those selected one records.
Can any one sugget regarding this.
Thanks in advance.
Rahul.Hi,
Thanks. now it's enabled. but how can we pick the records from that list whichever i selected through that check box.
i found this one for ALV grid:
DATA ref_grid TYPE REF TO cl_gui_alv_grid.
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.
IF ref_grid IS NOT INITIAL.
CALL METHOD ref_grid->check_changed_data.
ENDIF.
but how for ALV normal list display.
Thanks.
rahul -
How to create command button called 'Remarks' and Check box in ALV GRID?
Hi, Experts,
Requirement is: in the ALVE GRID report output, user select a record by clicking the check box and pressing the button 'Remarks' it will take me into other transaction from the output list.
Please help me out.
Reward points.
SekharHi Chandra Shekar,
Check the following sample program. 2 things to remember.
1. Check the callback subroutine PF_STATUS_SET and create PF status for the program.and also ur REMARKS button in the application tool. Comments are made every where wherever those are needed. After creating Pf status execute the report.
2.Once you select records by selecting checkboxes, u have to press on Refresh button( that is there on application toolbar), then only for selected records, CHECK field in the internal is updated. After that press on REMARKS button .
REPORT zvenkat_alv_grid.
TABLES:t001.
"Types
TYPES:
BEGIN OF t_1001,
check TYPE c,
bukrs TYPE t001-bukrs,
butxt TYPE t001-butxt,
ort01 TYPE t001-ort01,
land1 TYPE t001-land1,
END OF t_1001.
"Work area
DATA:
w_t001 TYPE t_1001.
"Internal table
DATA:
i_t001 TYPE STANDARD TABLE OF t_1001.
" ALV Declarations
* Types Pools
TYPE-POOLS:
slis.
* Types
TYPES:
t_fieldcat TYPE slis_fieldcat_alv,
t_events TYPE slis_alv_event,
t_layout TYPE slis_layout_alv.
* Workareas
DATA:
w_fieldcat TYPE t_fieldcat,
w_events TYPE t_events,
w_layout TYPE t_layout.
* Internal Tables
DATA:
i_fieldcat TYPE STANDARD TABLE OF t_fieldcat,
i_events TYPE STANDARD TABLE OF t_events.
*& start of selection
START-OF-SELECTION.
PERFORM get_data.
*& end-of-selection.
END-OF-SELECTION.
PERFORM build_fieldcatlog.
PERFORM build_events.
PERFORM build_layout.
PERFORM list_display.
*& Form get_data
FORM get_data .
SELECT bukrs
butxt
ort01
land1
FROM t001
INTO CORRESPONDING FIELDS OF TABLE i_t001
UP TO 30 ROWS.
ENDFORM. " get_data
*& Form build_fieldcatlog
FORM build_fieldcatlog .
CLEAR:w_fieldcat,i_fieldcat[].
PERFORM build_fcatalog USING:
'CHECK' 'I_T001' ' ',
'BUKRS' 'I_T001' 'BUKRS',
'BUTXT' 'I_T001' 'BUTXT',
'ORT01' 'I_T001' 'ORT01',
'LAND1' 'I_T001' 'LAND1'.
ENDFORM. "BUILD_FIELDCATLOG
*& Form BUILD_FCATALOG
FORM build_fcatalog USING l_field l_tab l_text.
w_fieldcat-fieldname = l_field.
w_fieldcat-tabname = l_tab.
w_fieldcat-seltext_m = l_text.
IF l_field = 'CHECK'..
w_fieldcat-checkbox = 'X'.
w_fieldcat-edit = 'X'.
ENDIF.
APPEND w_fieldcat TO i_fieldcat.
CLEAR w_fieldcat.
ENDFORM. " build_fieldcatlog
*& Form build_events
* text
FORM build_events.
CLEAR :
w_events, i_events[].
w_events-name = 'TOP_OF_PAGE'."Event Name
w_events-form = 'TOP_OF_PAGE'."Callback event subroutine
APPEND w_events TO i_events.
CLEAR w_events.
w_events-name = 'USER_COMMAND' .
w_events-form = 'USER_COMMAND' .
APPEND w_events TO i_events.
CLEAR w_events.
w_events-name = 'PF_STATUS_SET' .
w_events-form = 'PF_STATUS_SET' .
APPEND w_events TO i_events.
CLEAR w_events.
ENDFORM. "build_events
*& Form build_layout
FORM build_layout .
w_layout-colwidth_optimize = 'X'.
w_layout-zebra = 'X'.
ENDFORM. " build_layout
*& Form list_display
FORM list_display .
DATA:
l_program TYPE sy-repid.
l_program = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_program
is_layout = w_layout
it_fieldcat = i_fieldcat
it_events = i_events
TABLES
t_outtab = i_t001
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. " list_display
*& Form top_of_page
FORM top_of_page.
DATA :
li_header TYPE slis_t_listheader,
w_header LIKE LINE OF li_header.
DATA:
l_date TYPE char10.
WRITE sy-datum TO l_date.
w_header-typ = 'H'.
CONCATENATE sy-repid ':' 'From Date' l_date INTO w_header-info SEPARATED BY space.
APPEND w_header TO li_header.
CLEAR w_header.
w_header-typ = 'S'.
w_header-info = sy-title.
APPEND w_header TO li_header.
CLEAR w_header.
w_header-typ = 'A'.
w_header-info = sy-uname.
APPEND w_header TO li_header.
CLEAR w_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = li_header.
ENDFORM. "top_of_page
*& Form pf_status_set
FORM pf_status_set USING extab TYPE slis_t_extab.
"Procedure to set own pf-status.
"1.Goto Transaction code SE41
"2.give program = SAPLKKBL and status = STANDARD_FULLSCREEN.
"3.Click on Application toolbar STATUS button
"4.Give ur program name Status name that is to be used in the program using SET pf-status statement
"5.Create ur button REMARKS.
SET PF-STATUS 'STATUS1' EXCLUDING extab.
ENDFORM. "pf_status_set
*& Form user_command
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
CASE ucomm .
WHEN 'REMARKS'."When u click on remarks button.
LOOP AT i_t001 INTO w_t001 WHERE check = 'X'.
WRITE :/ w_t001-bukrs, 'Checked'.
ENDLOOP.
ENDCASE.
ENDFORM. "user_command
I hope that it helps u .
Regards,
Venkat.O -
Problem with check box need an idea
hello i need some help.
i am tring to make a attendence register as an assignment. what i am tring to do is that i can add student name in a file and then retrive them from a file and then mark there presents or absents.the part i cant get done is how do i mark the attendence. i want to display name and then the teacher can just click in the check box infront of the name to mark the present and when he clicks on the save button it would save the attendence in the file.
now the problem is the check box have to increase and decrease if a name is add or deleted in the file
SO does any one have any ideas what i can do to solve this problemlets suppose your file contains student name which are seperted by comma or space (what ever).then u can read it and open stringtokenizer with delimater you used to seperate names.count the number of tokens and create your check box on the count of tokens.There may be some good idea too and if any one have i would like to know.
-
How to show check box in ALV grid??
Hi All,
I am using an option edit in the feild catalogue which allows me to change the values in a few columns in the ALV list.
What I want is to be able to show a check box in a few columns which user can check and use the value X in the program for the later processing....
Can somebody tell me how to show a check box in the ALV screen in the changeable format??
Win full point by answering this typical question..
Thanks - Chandanhi go through the fallowing code.
*& Report YGS_ALV_BOM *
REPORT YGS_ALV_BOM .
TABLES : MAST,STKO,STPO.
TYPE-POOLS: SLIS.
TYPES : BEGIN OF TY_MAST,
CHECK_BOX,
MATNR TYPE MAST-MATNR,
WERKS TYPE MAST-WERKS,
STLAN TYPE MAST-STLAN,
STLNR TYPE MAST-STLNR,
STLAL TYPE MAST-STLAL,
END OF TY_MAST.
TYPES : BEGIN OF TY_STKO,
STLTY TYPE STKO-STLTY,
STLNR TYPE STKO-STLNR,
STLAL TYPE STKO-STLAL,
STKOZ TYPE STKO-STKOZ,
BMENG TYPE STKO-BMENG,
BMEIN TYPE STKO-BMEIN,
END OF TY_STKO.
TYPES : BEGIN OF TY_STPO,
LIGHTS,
STLTY TYPE STPO-STLTY,
STLNR TYPE STPO-STLNR,
STLKN TYPE STPO-STLKN,
STPOZ TYPE STPO-STPOZ,
IDNRK TYPE STPO-IDNRK,
MENGE TYPE STPO-MENGE,
MEINS TYPE STPO-MEINS,
END OF TY_STPO.
DATA : IT_MAST TYPE TABLE OF TY_MAST,
WA_MAST TYPE TY_MAST,
IT_STKO TYPE TABLE OF TY_STKO,
WA_STKO TYPE TY_STKO,
IT_STPO TYPE TABLE OF TY_STPO,
WA_STPO TYPE TY_STPO.
DATA : lt_fieldcat TYPE slis_t_fieldcat_alv,
ls_layout TYPE slis_layout_alv,
ls_event TYPE slis_alv_event,
lt_event TYPE slis_t_event,
it_sortinfo type slis_t_sortinfo_alv,
ls_header TYPE slis_listheader,
lt_header TYPE slis_t_listHEADER.
DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
SELECT-OPTIONS : S_MATNR FOR MAST-MATNR.
START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM BUILD_FIELDCAT USING LT_FIELDCAT.
PERFORM BUILD_LAYOUT.
END-OF-SELECTION.
PERFORM DISPLAY_DATA.
*& Form GET_DATA
* text
* --> p1 text
* <-- p2 text
form GET_DATA .
REFRESH : IT_MAST.
SELECT MATNR
WERKS
STLAN
STLNR
FROM MAST
INTO CORRESPONDING FIELDS OF TABLE IT_MAST
WHERE MATNR IN S_MATNR.
endform. " GET_DATA
*& Form BUILD_FIELDCAT
* text
* --> p1 text
* <-- p2 text
form BUILD_FIELDCAT USING LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA : L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
REFRESH : LT_FIELDCAT.
L_FIELDCAT-COL_POS = 1.
L_FIELDCAT-FIELDNAME = 'MATNR'.
L_FIELDCAT-TABNAME = 'IT_MAST'.
L_FIELDCAT-REF_FIELDNAME = 'MATNR'.
L_FIELDCAT-REF_TABNAME = 'MAST'.
APPEND L_FIELDCAT TO LT_FIELDCAT.
L_FIELDCAT-COL_POS = 2.
L_FIELDCAT-FIELDNAME = 'WERKS'.
L_FIELDCAT-TABNAME = 'IT_MAST'.
L_FIELDCAT-REF_FIELDNAME = 'WERKS'.
L_FIELDCAT-REF_TABNAME = 'MAST'.
APPEND L_FIELDCAT TO LT_FIELDCAT.
L_FIELDCAT-COL_POS = 3.
L_FIELDCAT-FIELDNAME = 'STLNR'.
L_FIELDCAT-TABNAME = 'IT_MAST'.
L_FIELDCAT-REF_FIELDNAME = 'STLNR'.
L_FIELDCAT-REF_TABNAME = 'MAST'.
APPEND L_FIELDCAT TO LT_FIELDCAT.
endform. " BUILD_FIELDCAT
*& Form BUILD_LAYOUT
* text
* --> p1 text
* <-- p2 text
form BUILD_LAYOUT .
CLEAR LS_LAYOUT.
LS_LAYOUT-BOX_FIELDNAME = 'CHECK_BOX'.
LS_LAYOUT-BOX_TABNAME = 'IT_MAST'.
endform. " BUILD_LAYOUT
*& Form DISPLAY_DATA
* text
* --> p1 text
* <-- p2 text
form DISPLAY_DATA .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* I_STRUCTURE_NAME =
IS_LAYOUT = LS_LAYOUT
IT_FIELDCAT = LT_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 = IT_MAST
* 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. " DISPLAY_DATA
FORM PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'YSTATUS' OF PROGRAM SY-REPID
EXCLUDING RT_EXTAB.
ENDFORM.
FORM USER_COMMAND USING RF_UCOMM TYPE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
CASE RF_UCOMM.
WHEN '&NEXT'.
PERFORM GET_DATA_BOM .
PERFORM BUILD_FIELDCAT_BOM USING LT_FIELDCAT.
PERFORM BUILD_LAYOUT_BOM.
PERFORM DISPLAY_DATA_BOM.
ENDCASE.
ENDFORM.
*& Form GET_DATA_BOM
* text
* --> p1 text
* <-- p2 text
form GET_DATA_BOM .
CLEAR : WA_STPO,
WA_MAST.
REFRESH : IT_STPO.
DATA : IT_CHECK TYPE TABLE OF TY_MAST.
LOOP AT IT_MAST INTO WA_MAST.
IF WA_MAST-CHECK_BOX EQ 'X'.
APPEND WA_MAST TO IT_CHECK.
ENDIF.
ENDLOOP.
SELECT STLTY
STLNR
STLKN
VGKNT
IDNRK
MENGE
MEINS
FROM STPO
INTO CORRESPONDING FIELDS OF TABLE IT_STPO
FOR ALL ENTRIES IN IT_CHECK
WHERE IDNRK EQ IT_CHECK-MATNR.
CLEAR WA_STPO.
LOOP AT IT_STPO INTO WA_STPO.
SELECT SINGLE * FROM MAST WHERE MATNR EQ WA_STPO-IDNRK.
IF SY-SUBRC = 0.
WA_STPO-LIGHTS = '2'.
ELSE.
WA_STPO-LIGHTS = '1'.
ENDIF.
MODIFY IT_STPO FROM WA_STPO.
ENDLOOP.
endform. " GET_DATA_BOM
*& Form BUILD_FIELDCAT_BOM
* text
* --> p1 text
* <-- p2 text
form BUILD_FIELDCAT_BOM USING LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA : L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
REFRESH : LT_FIELDCAT.
L_FIELDCAT-COL_POS = 1.
L_FIELDCAT-FIELDNAME = 'STLTY'.
L_FIELDCAT-TABNAME = 'IT_STPO'.
L_FIELDCAT-REF_FIELDNAME = 'STLTY'.
L_FIELDCAT-REF_TABNAME = 'STPO'.
APPEND L_FIELDCAT TO LT_FIELDCAT.
L_FIELDCAT-COL_POS = 2.
L_FIELDCAT-FIELDNAME = 'STLNR'.
L_FIELDCAT-TABNAME = 'IT_STPO'.
L_FIELDCAT-REF_FIELDNAME = 'STLNR'.
L_FIELDCAT-REF_TABNAME = 'STPO'.
APPEND L_FIELDCAT TO LT_FIELDCAT.
L_FIELDCAT-COL_POS = 3.
L_FIELDCAT-FIELDNAME = 'STLKN'.
L_FIELDCAT-TABNAME = 'IT_STPO'.
L_FIELDCAT-REF_FIELDNAME = 'STLKN'.
L_FIELDCAT-REF_TABNAME = 'STPO'.
APPEND L_FIELDCAT TO LT_FIELDCAT.
L_FIELDCAT-COL_POS = 4.
L_FIELDCAT-FIELDNAME = 'IDNRK'.
L_FIELDCAT-TABNAME = 'IT_STPO'.
L_FIELDCAT-REF_FIELDNAME = 'IDNRK'.
L_FIELDCAT-REF_TABNAME = 'STPO'.
APPEND L_FIELDCAT TO LT_FIELDCAT.
L_FIELDCAT-COL_POS = 5.
L_FIELDCAT-FIELDNAME = 'MENGE'.
L_FIELDCAT-TABNAME = 'IT_STPO'.
L_FIELDCAT-REF_FIELDNAME = 'MENGE'.
L_FIELDCAT-REF_TABNAME = 'STPO'.
APPEND L_FIELDCAT TO LT_FIELDCAT.
endform. " BUILD_FIELDCAT_BOM
*& Form BUILD_LAYOUT_BOM
* text
* --> p1 text
*<-- p2 text
form BUILD_LAYOUT_BOM .
CLEAR : LS_LAYOUT.
LS_LAYOUT-LIGHTS_FIELDNAME = 'LIGHTS'.
LS_LAYOUT-LIGHTS_TABNAME = 'IT_STPO'.
endform. " BUILD_LAYOUT_BOM
*& Form DISPLAY_DATA_BOM
* text
* --> p1 text
* <-- p2 text
form DISPLAY_DATA_BOM .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
* I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND_BOM'
I_CALLBACK_TOP_OF_PAGE = 'TOP9'
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
I_BACKGROUND_ID = 'ALV_BACKGROUND'
* I_GRID_TITLE =
* I_GRID_SETTINGS =
IS_LAYOUT = LS_LAYOUT
IT_FIELDCAT = LT_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
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = IT_STPO
* 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. " DISPLAY_DATA_BOM
FORM TOP9 .
CLEAR LS_HEADER.
REFRESH LT_HEADER.
LS_HEADER-TYP = 'H'.
LS_HEADER-INFO = 'BILL OF MATERIALS'.
APPEND LS_HEADER TO LT_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = LT_HEADER
I_LOGO = 'ENJOYSAP_LOGO'
* I_END_OF_LIST_GRID =
ENDFORM.
FORM USER_COMMAND_BOM USING RF_UCOMM_BOM LIKE SY-UCOMM
SEL_FIELD TYPE SLIS_SELFIELD.
CASE RF_UCOMM_BOM.
WHEN '&IC1'.
SET PARAMETER ID 'MAT' FIELD WA_STPO-IDNRK.
SET PARAMETER ID 'WRK' FIELD WA_MAST-WERKS.
SET PARAMETER ID 'CSA' FIELD WA_MAST-STLAN.
CALL TRANSACTION 'CS03' AND SKIP FIRST SCREEN.
ENDCASE.
Maybe you are looking for
-
Since I upgraded my iMac,my time machine is not backing up automatically to my time capsule since my upgrade to Moutain Lion.
-
Error through F-44 that Consolidated companies 1000 and ' ' are different
Dear Expert At the time of Vendor clearing through F-44 I get the warning message that "Withholding tax information ignored" where Withholding tax related customization and master has been updated accordingly. If I ignore the same warning and save th
-
Soft KeyBoard is not working on ios 7 with Air sdk 3.8
Hi In my app Soft KeyBoard is not working on ios 7 with Air sdk 3.8. Does any one know soluton for this ?
-
Hi i use this minus operator to find the non matching row of the second query. after looking at the reasult of this query , i searched the one result in the second query alone i could see the data. it's worng The MINUS query returns all rows in the f
-
Edge Animate error when trying to install
I'm getting an incomplete install when I try to download and install Edge Animate: Exit Code: 6 Please see specific errors below for troubleshooting. For example, ERROR: -------------------------------------- Summary --------------------------------