How to create functionality to ALV Grid?
Hi All,
My ALV code is running successfully,but I just wanna add few customer specific functionality and my own PF status.Can you suggest me something for this.
Thanks and Regards.
Rajarshi.
Hi Rajarshi,
If you are using REUSE_ALV_GRID_CONTROL, Here is how you add
custom functionality.
1) In the fM REUSE_ALV_GRID_CONTROL pass the parameters
i_callback_user_command = 'USER_COMMAND' i_callback_pf_status_set = 'SET_PF_STATUS'. This are form name.
2) Create a form in your program as below.
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'PFSTAT1' EXCLUDING rt_extab.
ENDFORM. "SET_PF_STATUS
PFSTAT1 is a copy of the Pf-status STANDARD_FULSCREEN of the program SAPLKKBL (copy it using SE41).
Once PFSTAT1 is created you can modify it just like any other PF status and add your own menu or command buttons.
3) To handle the functioanlity create a form of name user_command in your program as below.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
The field "R_UCOMM" will contain the current value of *"SY-UCOMM"
"RS_SELFIELD" will hold contents of the selected line
CASE r_ucomm.
ENDCASE.
ENDFORM. "USER_COMMAND
Hope this helps
Similar Messages
-
How can I call functionality of ALV Grid by event of button outside grid?
Hello,
How can I call functionality of ALV Grid by event of button located outside ALV Grid? For example how to fire printing of this ALV Grid by button click elsewhere on the screen (not in toolbar of ALV Grid).
Best regards,
Josef Motlhi Motl,
these are steps to create a button in ALV and trigger an event from it..
1.Use the parameter i_callback_pf_status_set in the function module REUSE_ALV_GRID_DISPLAY
i_callback_program = gd_repid
i_callback_pf_status_set = 'SET_PF_STATUS'
form set_pf_status using rt_extab type slis_t_extab.
set pf-status 'NEWALVSTATUS'.
endform.
You have to copy the standard ALV pf stauts to 'NEWALVSTATUS' and add your button.
2.You have to do the following to process the new button click.
i_callback_user_command = 'USER_COMMAND'
form user_command using i_ucomm like sy-ucomm
is_selfield type slis_selfield.
case i_ucomm.
3. to copy the standard pf status to a new one.go to the ALV screen and take the menu System -> Status. Then look for the standard pf status. Copy this to Z range and then add your new button.
reward points if helpful
regards
satesh -
How does the SORT function in ALV grid work?
Hi,
I have a report for which the o/p is displayed in ALV grid format.There is one column in the O/p strcuture which is "No of days".Based on certain conditions,i need to display the value for some of the days as Negative e.g. " - 45".Becasuse of this,I have declared the field for the "No of days" of the type "CHAR".
Now when i sort(using ALV grid SORT function) the list on basis of this column,it doesnt give me the correct o/p.
CAN anyone tell me how do i handle this?I want the list to be sorted correctly on basis of the "No of days" column.
Thanks!This is your Fourth Cross Posting in last three days on same issue!!
CHAR type column doesnt work for SORT function in ALV grid!
How to sort a column of type CHAR
I dont,ve link for your Fourth Thread on same,though i'm short memory loss. -
How to create an editable ALV?
How to create an editable ALV?
The follow program demonstrates how to make individual fields of an ALV grid editable (NetPR greater than 10).
Changes required from a basic ALV grid include adding a new field to ALV grid data table(it_ekko), Populating this
field with style attribute and adding an entry to layout control table. Also from the previous examples used on
this website you will also need to change the data type of the fieldcatalog, the layout and use a different function
module for displaying the report.
*& Report ZDEMO_ALVGRID_EDIT *
*& Example of a simple ALV Grid Report *
*& The basic ALV grid, Enhanced to display specific fields as *
*& editable depending on field value *
REPORT ZDEMO_ALVGRID_EDIT .
TABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
field_style TYPE lvc_t_styl, "FOR DISABLE
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA: it_fieldcat TYPE lvc_t_fcat, "slis_t_fieldcat_alv WITH HEADER LINE,
wa_fieldcat TYPE lvc_s_fcat,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE lvc_s_layo, "slis_layout_alv,
gd_repid LIKE sy-repid.
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM set_specific_field_attributes.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-scrtext_m = 'Purchase Order'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-outputlen = 10.
wa_fieldcat-emphasize = 'X'.
wa_fieldcat-key = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'EBELP'.
wa_fieldcat-scrtext_m = 'PO Item'.
wa_fieldcat-col_pos = 1.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'STATU'.
wa_fieldcat-scrtext_m = 'Status'.
wa_fieldcat-col_pos = 2.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'AEDAT'.
wa_fieldcat-scrtext_m = 'Item change date'.
wa_fieldcat-col_pos = 3.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-scrtext_m = 'Material Number'.
wa_fieldcat-col_pos = 4.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MENGE'.
wa_fieldcat-scrtext_m = 'PO quantity'.
wa_fieldcat-col_pos = 5.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MEINS'.
wa_fieldcat-scrtext_m = 'Order Unit'.
wa_fieldcat-col_pos = 6.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NETPR'.
wa_fieldcat-scrtext_m = 'Net Price'.
wa_fieldcat-edit = 'X'. "sets whole column to be editable
wa_fieldcat-col_pos = 7.
wa_fieldcat-outputlen = 15.
wa_fieldcat-datatype = 'CURR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'PEINH'.
wa_fieldcat-scrtext_m = 'Price Unit'.
wa_fieldcat-col_pos = 8.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
Set layout field for field attributes(i.e. input/output)
gd_layout-stylefname = 'FIELD_STYLE'.
gd_layout-zebra = 'X'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = gd_repid
i_callback_user_command = 'USER_COMMAND'
is_layout_lvc = gd_layout
it_fieldcat_lvc = it_fieldcat
i_save = 'X'
TABLES
t_outtab = it_ekko
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_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
UP TO 10 ROWS
FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE it_ekko.
ENDFORM. " DATA_RETRIEVAL
*& Form set_specific_field_attributes
populate FIELD_STYLE table with specific field attributes
form set_specific_field_attributes .
DATA ls_stylerow TYPE lvc_s_styl .
DATA lt_styletab TYPE lvc_t_styl .
Populate style variable (FIELD_STYLE) with style properties
The NETPR field/column has been set to editable in the fieldcatalog...
The following code sets it to be disabled(display only) if 'NETPR'
is gt than 10.
LOOP AT it_ekko INTO wa_ekko.
IF wa_ekko-netpr GT 10.
ls_stylerow-fieldname = 'NETPR' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
"set field to disabled
APPEND ls_stylerow TO wa_ekko-field_style.
MODIFY it_ekko FROM wa_ekko.
ENDIF.
ENDLOOP.
endform. " set_specific_field_attributes -
How to implement 'hypelink' in ALV GRID
Hi,everybody,please tell me how to implement 'hypelink' in ALV GRID?
I just try to design a ALV GRID report but I do not kown the way of using 'hypelink'. I refer to some documents but failsed. somebody can help me and give a example including entire code.1. Create a table where hyperlinks & corresponding handles are stored (TYpe LVC_T_HYPE)
DATA ls_hype TYPE lvc_s_hype .
data lt_hype type lvc_t_hype.
ls_hype-handle = '1' .
ls_hype-href = 'http://www.company.com/carrids/car1' .
APPEND ls_hype TO lt_hype .
2. In your list data table create additional field of type INT4 which will contain the handle of the hyper link (ex. '1' for above hyperlink)
DATA carrid_handle TYPE int4 .
3. For the field which shall contain the hyperlink, make an entry in the field catalog indicating the field name which contains handle for the hyperlink. This is done by setting the handle field name in WEB_FIELD.
ls_fieldcat-fieldname = 'CARRID'
ls_fieldcat-web_field = 'CARRID_HANDLE'.
4. While calling set_table_for_first_display, pass the hyperlink table created in step 1 to parameter 'it_hyperlink'
~Piyush Patil -
How to display rsa3 with ALV grid
Hello,
In some of tyhe systems i'm working with, RSA3 have a button to display the data in ALV grid. I checked and it's not because of the support package. Cab someone please advice how to add the ALV functionality.
Thanks,
Amir
Edited by: Amir Dror on Jan 13, 2009 12:41 PMHello,
we had the same question and problem.
SAP told us via OSS the following:
"... The ALV grid in RSA3 will be supported with the PI_BASIS 2006_1_700.
But you have PI_BASIS 2005_1_700
Furthermore this software component PI_BASIS is independent from the
BW releases so that you can upgrade the latest support packages of the
PI_BASIS 2006_1_700 in source system"
So if you have PI_BASIS 2005 you won't have the functionality of ALV grid in TC RSA3.
(remark: At the moment I can not confirm that ALV grid in RSA3 is available with PI_BASIS 2006_x_xxx. We plan to upgrade in a few month.)
Best regards -
How to create function module for getting customer name
Hi Experts,
How to create function module? when in import parameter kunnr values to be passed it must give name1 details according to the customer number...
how to write the logic in source code....
Regards,
Thiru. R1. First of all create function group.
2. Create function module using this function group.
3. If only one kunnr is needed at a time, create import parameter for it. But if many kunnr to be entered at a time,use table.
4. Fetch name1 for each kunnr from KNA1 table.
"->> if many kunnr
if not t_kunnr[] is initial.
select kunnr as kunnr name1 as name1
into table t_kunnr_name1
from kna1
for all entried in table t_kunnr
where kunnr = t_kunnr-kunnr.
endif.
sort t_kunnr_name1 by kunnr name1.
delete adjacent duplicates from t_kunnr_name1 comparing kunnr name1.
table t_kunnr_name1 will contain kunnr and its name1.
I hope logic is clear for you now.
Regards,
Aparna -
How to create function module in abap for VirtualProvider in bi
how to create function module in abap for VirtualProvider in bi ???????????????
can any one help me with simple example ?????????????????
Moderator message : Duplicate post locked. Read forum rules before posting.
Edited by: Vinod Kumar on Jun 15, 2011 4:40 PMHi ,
Thanks for replies about my question??.
If i am using the exit in my char relation ship how can i debugg that exit???
if i am using BPS0 how to do it???If i am using BPS_WB how to do it??
Case1.Variable (type Exit) I known how to do debugg this one in BPS0 but i'm not sure in BPS_WB??
Case2:Char Relation Ship(Type Exit) how to do in BPS0 and BPS_WB??.
Thanks. -
How to create functional location for IE02
hi all,
can anyone please tell me that how to create functional location for IE02?
Regards saurabh.To attach a functional location to an equipment, please make sure the following settings,
1- You have defined the installation allowed at functional location for the following equipment category.
2- Make sure status of your equipment is AVLB not ESTO.
then Goto IE02 in the structure tab ---> click change installation location and install the functional location.
Regards,
EJ -
How to create function code for field in GRID like list box in screen
Hi all,
I have requirement like drop down is created for field1 in GRID,
and have given f4 help for it, as soon as i change the data in the field
event has to trigger to update thevalues in other field.
This scenario i worked on screens where field is created with listbox and assign function code to it
when the field value changes the event triggers .
Is there is anything like that which will fire the event for field value changes.
can i update anything through the fieldcatalogue.
anybody help me on this
Regards,
MadhaviHi Madhavi,
yes we can do that by registering edit events..
check the below example.. has both the variants dropdown/f4 hlp...
screen flow logic
PROCESS BEFORE OUTPUT.
MODULE pbo.
PROCESS AFTER INPUT.
MODULE pai AT EXIT-COMMAND.
program
* CLASS lcl_event_responder DEFINITION *
CLASS lcl_event_responder DEFINITION.
PUBLIC SECTION.
DATA : ls_changed_cell TYPE lvc_s_modi,
lv_language TYPE spras..
METHODS refresh_changed_data FOR EVENT data_changed
OF cl_gui_alv_grid
IMPORTING er_data_changed
e_ucomm.
ENDCLASS. "event_responder DEFINITION
DATA: go_handler TYPE REF TO lcl_event_responder,
go_container TYPE REF TO cl_gui_custom_container,
go_grid TYPE REF TO cl_gui_alv_grid,
gt_fieldcat TYPE lvc_t_fcat,
gv_language TYPE spras VALUE 'E',
gt_outtab TYPE TABLE OF makt WITH HEADER LINE.
PARAMETERS : dropdown TYPE char01 RADIOBUTTON GROUP grp,
f4help TYPE char01 RADIOBUTTON GROUP grp.
START-OF-SELECTION.
CALL SCREEN 100.
END-OF-SELECTION.
* MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
SET PF-STATUS 'BASIC'.
PERFORM create_and_init_alv CHANGING gt_outtab[]
gt_fieldcat.
ENDMODULE. "pbo OUTPUT
* MODULE PAI INPUT *
MODULE pai INPUT.
SET SCREEN 0. LEAVE SCREEN.
ENDMODULE. "pai INPUT
FORM create_and_init_alv CHANGING pt_outtab LIKE gt_outtab[]
pt_fieldcat TYPE lvc_t_fcat.
CHECK go_container IS NOT BOUND.
CREATE OBJECT go_container
EXPORTING
container_name = 'CUSTOM'.
CREATE OBJECT go_grid
EXPORTING
i_parent = go_container.
PERFORM build_display_table.
PERFORM build_fieldcat CHANGING pt_fieldcat.
IF dropdown EQ abap_true.
PERFORM set_drdn_table.
ENDIF.
go_grid->set_table_for_first_display( CHANGING it_fieldcatalog = pt_fieldcat
it_outtab = pt_outtab ).
go_grid->set_ready_for_input( 1 ).
" raises the 'data_changed' event when we select another cell/any action after changing the data
go_grid->register_edit_event( EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_modified ).
CREATE OBJECT go_handler.
SET HANDLER go_handler->refresh_changed_data FOR go_grid.
ENDFORM. "CREATE_AND_INIT_ALV
FORM build_display_table.
FREE gt_outtab.
SELECT * FROM makt UP TO 20 ROWS INTO TABLE gt_outtab WHERE spras EQ gv_language.
ENDFORM. "build_display_table
FORM build_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'MAKT'
CHANGING
ct_fieldcat = pt_fieldcat.
LOOP AT pt_fieldcat INTO ls_fcat.
IF ls_fcat-fieldname EQ 'SPRAS'.
ls_fcat-edit = abap_true..
ls_fcat-outputlen = 8.
IF dropdown EQ abap_true.
ls_fcat-drdn_hndl = '1'.
ls_fcat-checktable = '!'. "do not check foreign keys
ENDIF.
MODIFY pt_fieldcat FROM ls_fcat.
ENDIF.
ENDLOOP.
ENDFORM. "build_fieldcat
FORM set_drdn_table.
CHECK go_grid->offline( ) IS INITIAL.
DATA: lt_dropdown TYPE lvc_t_drop,
ls_dropdown TYPE lvc_s_drop.
ls_dropdown-handle = '1'.
ls_dropdown-value = 'EN'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = 'DE'.
APPEND ls_dropdown TO lt_dropdown.
CALL METHOD go_grid->set_drop_down_table
EXPORTING
it_drop_down = lt_dropdown.
ENDFORM. " set_drdn_table
FORM change_display_table USING pv_language pv_rowno TYPE i.
READ TABLE gt_outtab INDEX pv_rowno.
SELECT SINGLE * FROM makt INTO gt_outtab WHERE matnr = gt_outtab-matnr AND spras = pv_language.
IF sy-subrc EQ 0.
DELETE gt_outtab INDEX pv_rowno.
INSERT gt_outtab INDEX pv_rowno.
ELSE.
CLEAR : gt_outtab-maktx,
gt_outtab-maktg.
DELETE gt_outtab INDEX pv_rowno.
INSERT gt_outtab INDEX pv_rowno.
ENDIF.
ENDFORM. "change_display_table
* CLASS event_responder IMPLEMENTATION *
CLASS lcl_event_responder IMPLEMENTATION.
METHOD refresh_changed_data.
READ TABLE er_data_changed->mt_mod_cells INTO ls_changed_cell INDEX 1.
CALL FUNCTION 'CONVERSION_EXIT_ISOLA_INPUT'
EXPORTING
input = ls_changed_cell-value
IMPORTING
output = lv_language.
PERFORM change_display_table USING lv_language ls_changed_cell-row_id.
go_grid->refresh_table_display( ).
ENDMETHOD. "click
ENDCLASS. "event_responder IMPLEMENTATION
Cheers,
Jose. -
Generic function displaying alv grid for undefined structure
Hi experts,
I'm doing my first steps on abap development (Totally noob).
I'm writing some little reports based on simple selections (1 or 2 tables).
In every report, I've defined a structure (internal table) that i'm displaying with an ALV Grid.
In every report, I need to create a catalog for my structure in order to make the alv grid working.
What I would like to do is :
Create a function that receives a undefined structure (for all my reports) as a parameter.
This function sould create the catalog for the coresponding structure and call the alv grid function to display the data's contained in this structure.
The goal is : In every report, I would like to use this function to show the selected data's without taking care of catalogs, alv grid, etc...
Is it possible ?
I really don't see how I can do that... Does anybody already tried something like that ?
Thank you for your help
Regards
QuentinHi,
In this method Pass the structure name-
CALL METHOD gh_grid->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME = "<- here pass the structure
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
IS_LAYOUT = "<-Layout variable if using layout
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
CHANGING
it_outtab = gt_line[]
it_fieldcatalog = gt_fieldcat
IT_SORT =
IT_FILTER =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4 -
How to supress dialog while ALV Grid output is send to Spool
Hi,
I need to get the ALV grid output in spool.But when i am executing my program using ALV grid function module with print parameter passed,first its giving a popup with default printer and number of copies and when i press ok for the popup ,spool request is created.But i dont want this popup to come while executing my program.It should create the spool request directly. How to solve this issue.
Regards
ShibinHi Shibin,
Try the below parameter in IS_PRINT Structure:
is_print-print = 'N'.
This will Supress the Dialog and create a Spool with no Immeadiate Output.
Hope This Helps you..
Thanks & Regards,
Suresh Karri -
How to create Status in ALV reports?
Hi experts,
I need to create a status in a alv report. but i am not getting how to create it. i have declared a variable type slis_formname. and appended the events with it. now how to create the status in form.answers will be rewarded.
Thanks in advance,
RamanaHello Venkat,
Copy the standard pf status of the ALV in SE41 and do the following.
DATA: IT_EVENTS TYPE SLIS_T_EVENT,
WA_EVENTS LIKE LINE OF IT_EVENTS.
REFRESH: IT_EVENTS.
CLEAR: WA_EVENTS,IT_EVENTS.
WA_EVENTS-NAME = 'PF_STATUS_SET'.
WA_EVENTS-FORM = 'STATUS'.
APPEND WA_EVENTS TO IT_EVENTS .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = IT_VARIANT-REPORT
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FIELDCAT
I_SAVE = 'A'
IS_VARIANT = IT_VARIANT
IT_SORT = IT_SORT
IT_EVENTS = IT_EVENTS
TABLES
T_OUTTAB = G_T_OUTTAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
FORM status *
FORM STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD' EXCLUDING RT_EXTAB.
ENDFORM.
If useful reward.
Vasanth -
How to Set Checkbox of ALV Grid Dark on Display Mode
ABAP experts, I want to switch between display mode and edit mode for some columns of ALV Grid. So I set "LVC_S_FCAT-EDIT" "X" for the columns which need to switch mode, and use method "SET_READY_FOR_INPUT" to switch.
Currently, the function of switch mode has been achieved. But icons of checkbox columns are light but not dark when display mode, although the columns can't be edited. (Please refer to the image below.) I want to make checkbox columns dark as other columns on display mode.
I tried to use "CL_GUI_ALV_GRID=>MC_STYLE_ENABLED" and "CL_GUI_ALV_GRID=>MC_STYLE_DISABLED", but failed. I also studied sample program "BCALV_EDIT_05" which is related to checkbox in ALV Grid, and compared my program with this program. But I still have not found problems.
Help me solve this problem, please.
Part of my codes are as follows.
Part 1:
IF iv_is_create_group = abap_true OR iv_is_edit_group = abap_true.
set_enable( iv_flag = 1 ).
LOOP AT gt_acct_group_item ASSIGNING <lfs_acct_group_item>.
CLEAR ls_celltab.
IF <lfs_acct_group_item>-celltab IS INITIAL.
CLEAR ls_celltab.
ls_celltab-fieldname = 'CHECK_BOX'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
APPEND ls_celltab TO <lfs_acct_group_item>-celltab.
CLEAR ls_celltab.
ls_celltab-fieldname = 'XPORE'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
APPEND ls_celltab TO <lfs_acct_group_item>-celltab.
ELSE.
LOOP AT <lfs_acct_group_item>-celltab ASSIGNING <lfs_celltab>.
<lfs_celltab>-style = cl_gui_alv_grid=>mc_style_enabled.
ENDLOOP.
ENDIF.
ENDLOOP.
ELSE.
set_enable( iv_flag = 0 ).
LOOP AT gt_acct_group_item ASSIGNING <lfs_acct_group_item>.
IF <lfs_acct_group_item>-celltab IS INITIAL.
CLEAR ls_celltab.
ls_celltab-fieldname = 'CHECK_BOX'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
APPEND ls_celltab TO <lfs_acct_group_item>-celltab.
CLEAR ls_celltab.
ls_celltab-fieldname = 'XPORE'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
APPEND ls_celltab TO <lfs_acct_group_item>-celltab.
ELSE.
LOOP AT <lfs_acct_group_item>-celltab ASSIGNING <lfs_celltab>.
<lfs_celltab>-style = cl_gui_alv_grid=>mc_style_disabled.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDIF.
CALL METHOD gr_grid->refresh_table_display
* EXPORTING
* is_stable =
* i_soft_refresh =
EXCEPTIONS
finished = 1
OTHERS = 2
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
Part 2:
METHOD set_enable.
gr_grid->set_ready_for_input(
i_ready_for_input = iv_flag
ENDMETHOD.Hi Liu,
Please go through the below code.
*& Report YEDIT_DISPLAY
REPORT YEDIT_DISPLAY.
TABLES : VBAK.
TYPE-POOLS SLIS.
TYPES : BEGIN OF TY_VBAK,
VBELN TYPE VBAK-VBELN,
END OF TY_VBAK,
BEGIN OF TY_FINAL,
BOX TYPE C,
VBELN TYPE VBAK-VBELN,
END OF TY_FINAL.
DATA : IT_VBAK TYPE TABLE OF TY_VBAK,
WA_VBAK TYPE TY_VBAK,
IT_FINAL TYPE TABLE OF TY_FINAL,
WA_FINAL TYPE TY_FINAL,
IT_FCAT TYPE TABLE OF SLIS_FIELDCAT_ALV,
WA_FCAT TYPE SLIS_FIELDCAT_ALV.
START-OF-SELECTION.
PERFORM FETCH_DATA.
PERFORM FCAT_DATA.
PERFORM DISPLAY.
*& Form FETCH_DATA
* text
* --> p1 text
* <-- p2 text
FORM FETCH_DATA .
SELECT VBELN INTO TABLE IT_VBAK FROM VBAK UP TO 10 ROWS.
LOOP AT IT_VBAK INTO WA_VBAK.
WA_FINAL-VBELN = WA_VBAK-VBELN.
APPEND WA_FINAL TO IT_FINAL.
CLEAR : WA_FINAL , WA_VBAK.
ENDLOOP.
ENDFORM. " FETCH_DATA
*& Form FCAT_DATA
* text
* --> p1 text
* <-- p2 text
FORM FCAT_DATA .
WA_FCAT-COL_POS = 1.
WA_FCAT-FIELDNAME = 'BOX'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-OUTPUTLEN = '3'.
WA_FCAT-SELTEXT_M = 'BOX'.
wa_fcat-checkbox = 'X'.
WA_FCAT-EDIT = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = 2.
WA_FCAT-FIELDNAME = 'VBELN'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-OUTPUTLEN = '3'.
WA_FCAT-SELTEXT_M = 'Sales Document'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
ENDFORM. " FCAT_DATA
*& Form DISPLAY
* text
* --> p1 text
* <-- p2 text
FORM DISPLAY .
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'
* I_CALLBACK_TOP_OF_PAGE = ' '
IT_FIELDCAT = IT_FCAT
* I_DEFAULT = 'X'
* I_SAVE = ' '
TABLES
T_OUTTAB = IT_FINAL
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM. " DISPLAY
FORM USER_COMMAND USING UCOMM TYPE SY-UCOMM
RTAB TYPE slis_selfield.
CASE UCOMM.
WHEN '&IC1'.
MESSAGE 'SUCESSFUL' TYPE 'S'.
WHEN '&DATA_SAVE'.
PERFORM FIL_FCAT.
PERFORM DISPLAY1.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN OTHERS.
LEAVE TO SCREEN 0.
ENDCASE.
ENDFORM.
*& Form FIL_FCAT
* text
* --> p1 text
* <-- p2 text
FORM FIL_FCAT .
CLEAR IT_FCAT.
WA_FCAT-COL_POS = 1.
WA_FCAT-FIELDNAME = 'BOX'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-OUTPUTLEN = '3'.
WA_FCAT-SELTEXT_M = 'BOX'.
wa_fcat-checkbox = 'X'.
** WA_FCAT-EDIT = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = 2.
WA_FCAT-FIELDNAME = 'VBELN'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-OUTPUTLEN = '3'.
WA_FCAT-SELTEXT_M = 'Sales Document'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
ENDFORM. " FIL_FCAT
*& Form DISPLAY1
* text
* --> p1 text
* <-- p2 text
FORM DISPLAY1 .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
* I_CALLBACK_TOP_OF_PAGE = ' '
IT_FIELDCAT = IT_FCAT
* I_DEFAULT = 'X'
* I_SAVE = ' '
TABLES
T_OUTTAB = IT_FINAL
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM. " DISPLAY1
Here i written code under the SAVE button , if requires you create your own status and apply.
Regards,
Krishna -
How to give space in ALV grid display
Hi,
I have developed one report using alv grid.
Iam getting details like this.
ABCD |12345|34567|
|35363|74567|
but i want like this
ABCD <b>here i want space</b>
|12345|34567|
|35363|74567|
how to give space?
points guaranteed
cheers
kakiHi experts,
Iam trying to get the output like in this report
BALVHD01
for example: ID & No iam getting in the same line.I want to group the numbers for the particular ID.
In my code ID is 'STEXT'
and NO is 'QMNUM'.
this is my code.
REPORT YET_DISPLAYCOST
MESSAGE-ID ZM
NO STANDARD PAGE HEADING
LINE-SIZE 200.
TYPE-POOLS: SLIS.
TABLES: QPCT,
QPGT,
QMEL,
QMMA,
IHPA,
JEST,
HRP1000.
DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
ITAB_EXTAB TYPE SLIS_T_EXTAB.
DATA :
I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
S_FIELDCAT TYPE SLIS_FIELDCAT_ALV ,
G_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND' ,
G_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'T_TOP_OF_PAGE',
I_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER WITH HEADER LINE,
I_EVENTS TYPE SLIS_T_EVENT WITH HEADER LINE,
S_EVENT TYPE SLIS_ALV_EVENT ,
S_LAYOUT TYPE SLIS_LAYOUT_ALV,
IT_SORT TYPE SLIS_T_SORTINFO_ALV.
*to remove sort buttons on the tool bar
DATA : EX TYPE SLIS_T_EXTAB.
DATA : EXWA TYPE SLIS_EXTAB.
DATA: LS_LINE TYPE SLIS_LISTHEADER.
DATA: I_FCALV TYPE SLIS_FIELDCAT_ALV OCCURS 0 WITH HEADER LINE.
DATA:F_TDOBJECT LIKE THEAD-TDOBJECT,
F_TDNAME LIKE THEAD-TDNAME,
F_TDID LIKE THEAD-TDID,
ITAB_LINES LIKE tline OCCURS 0 WITH HEADER LINE.
DATA:BEGIN OF ITAB OCCURS 10,
QMNUM LIKE QMEL-QMNUM,
DESC(72),
END OF ITAB.
DATA: BEGIN OF T_HDR OCCURS 0,
QMNUM LIKE QMEL-QMNUM,
PARNR LIKE IHPA-PARNR,
OBJID LIKE HRP1000-OBJID,
STEXT LIKE HRP1000-STEXT,
END OF T_HDR.
DATA: BEGIN OF T_DET OCCURS 10,
SNO TYPE I,
QMNUM LIKE QMEL-QMNUM,
QMTXT LIKE QMEL-QMTXT,
QMGRP LIKE QMEL-QMGRP,
QMCOD LIKE QMEL-QMCOD,
PARNR LIKE IHPA-PARNR,
OBJNR LIKE QMEL-OBJNR,
STEXT LIKE HRP1000-STEXT,
DESC(72),
COST(20),
END OF T_DET.
DATA: T_FINAL LIKE T_DET OCCURS 0 WITH HEADER LINE.
DATA: SNO(3).
DATA: CHK2(4).
DATA: V_REPID TYPE SY-REPID.
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:S_QMNUM FOR QMEL-QMNUM,
S_QMART FOR QMEL-QMART,
S_QMDAT FOR QMEL-QMDAT.
SELECTION-SCREEN END OF BLOCK A1.
START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM DISPLAY_ALV.
END-OF-SELECTION.
*& FORM GET_DATA
TEXT
FORM GET_DATA.
DATA: G_STEXT LIKE T_DET-STEXT.
*TO GET DETAILS
SELECT QMNUM REFNUM QMDAT QMTXT OBJNR QMGRP QMCOD FROM QMEL
INTO CORRESPONDING FIELDS OF TABLE T_DET
WHERE QMNUM IN S_QMNUM AND
QMART IN S_QMART AND
QMDAT IN S_QMDAT.
LOOP AT T_DET.
SELECT SINGLE * FROM IHPA WHERE OBJNR = T_DET-OBJNR and
PARVW = 'AB'.
IF SY-SUBRC = 0.
T_DET-PARNR = IHPA-PARNR.
MODIFY T_DET.
CLEAR T_DET.
ENDIF.
ENDLOOP.
LOOP AT T_DET.
DELETE T_DET WHERE PARNR EQ ''.
SELECT SINGLE * FROM JEST WHERE OBJNR = T_DET-OBJNR AND
STAT = 'I0072' AND
INACT NE 'X'.
IF SY-SUBRC NE 0.
DELETE T_DET INDEX SY-TABIX.
ENDIF.
ENDLOOP.
LOOP AT T_DET.
SELECT SINGLE * FROM HRP1000 WHERE OBJID = T_DET-PARNR.
IF SY-SUBRC = 0.
T_DET-STEXT = HRP1000-STEXT.
MODIFY T_DET.
CLEAR T_DET.
ENDIF.
ENDLOOP.
LOOP AT T_DET.
CHK2 = T_DET-QMNUM+0(4).
IF CHK2 NE '0002'.
DELETE T_DET INDEX SY-TABIX.
ENDIF.
ENDLOOP.
*--FOR HEADER
LOOP AT T_DET.
SELECT SINGLE * FROM HRP1000 WHERE OBJID = T_DET-PARNR AND
STEXT NE ''.
T_HDR-QMNUM = T_DET-QMNUM.
T_HDR-STEXT = HRP1000-STEXT.
APPEND T_HDR.
CLEAR T_HDR.
ENDLOOP.
LOOP AT T_DET.
F_TDID = 'LTQM'.
F_TDNAME = T_DET-QMNUM.
F_TDOBJECT = 'QMEL'.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = F_TDID
LANGUAGE = SY-LANGU
NAME = F_TDNAME
OBJECT = F_TDOBJECT
TABLES
LINES = ITAB_LINES
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
DESCRIBE TABLE ITAB_LINES LINES SY-TFILL.
IF SY-TFILL > 0.
LOOP AT ITAB_LINES.
ITAB-QMNUM = T_DET-QMNUM.
ITAB-DESC = ITAB_LINES-TDLINE.
APPEND ITAB.
CLEAR ITAB.
ENDLOOP.
ENDIF.
ENDLOOP.
SORT T_DET.
LOOP AT T_DET.
SNO = SNO + 1.
T_FINAL-SNO = SNO.
T_FINAL-QMNUM = T_DET-QMNUM.
T_FINAL-QMTXT = T_DET-QMTXT.
T_FINAL-COST = T_DET-COST.
IF G_STEXT NE T_DET-STEXT.
G_STEXT = T_DET-STEXT.
T_FINAL-STEXT = T_DET-STEXT.
ENDIF.
LOOP AT ITAB WHERE QMNUM = T_DET-QMNUM.
T_FINAL-DESC = ITAB-DESC.
APPEND T_FINAL.
CLEAR T_FINAL.
IF T_FINAL-SNO = '0'.
T_FINAL-SNO = ''.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDFORM. "GET_DATA
*& FORM DISPLAY_ALV
TEXT
FORM DISPLAY_ALV.
V_REPID = SY-REPID.
PERFORM FIELD_CATLOG.
PERFORM EVENT.
PERFORM LAYOUT.
PERFORM SORT_T_FINAL.
PERFORM TOP-OF-PAGE.
PERFORM REMOVE_SORT.
CALL FUNCTION <b>'REUSE_ALV_GRID_DISPLAY'</b>
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
IS_LAYOUT = S_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
I_SAVE = 'A'
IT_SORT = IT_SORT
IT_EVENTS = I_EVENTS[]
IT_EXCLUDING = EX
TABLES
T_OUTTAB = T_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "DISPLAY_ALV
*& Form FIELD_CATLOG
text
FORM FIELD_CATLOG .
PERFORM FILL_FCAT USING:
1 1 'STEXT' 'ATTRIBUTED DIV' 18 'T_FINAL' ' '
1 2 'SNO' 'SR.NO' 18 'T_FINAL' ' '
1 3 'QMNUM' 'ET.REF.NO' 30 'T_FINAL' ' '
1 4 'QMTXT' 'DESCRIPTION' 20 'T_FINAL' ' '
1 4 'DESC' 'DEFECT' 20 'T_FINAL' ' '
1 5 'COST' 'COST' 15 'T_FINAL' 'S'.
ENDFORM. " FIELD_CATLOG
*& Form FILL_FCAT
text
-->LEV text
-->POS text
-->FLD text
-->DES text
-->LEN text
-->TABLE text
-->F text
FORM FILL_FCAT USING LEV POS FLD DES LEN TABLE F.
CLEAR I_FCALV.
I_FCALV-COL_POS = POS.
I_FCALV-FIELDNAME = FLD.
I_FCALV-SELTEXT_L = DES.
I_FCALV-DDICTXT = 'L'.
I_FCALV-OUTPUTLEN = LEN.
I_FCALV-TABNAME = TABLE.
IF F EQ 'S'.
I_FCALV-DO_SUM = 'X'.
ENDIF.
APPEND I_FCALV TO I_FIELDCAT.
ENDFORM. "FILL_FCAT
*& Form SORT_T_FINAL
text
FORM SORT_T_FINAL.
DATA: L_SORT LIKE LINE OF IT_SORT.
REFRESH IT_SORT.
CLEAR L_SORT.
L_SORT-SPOS = '1'.
L_SORT-FIELDNAME = 'STEXT'.
L_SORT-TABNAME = 'T_FINAL'.
L_SORT-UP = 'X'.
APPEND L_SORT TO IT_SORT.
CLEAR L_SORT.
L_SORT-SPOS = '6'.
L_SORT-FIELDNAME = 'COST'.
L_SORT-TABNAME = 'T_FINAL'.
L_SORT-UP = 'X'.
L_SORT-SUBTOT = 'X'.
APPEND L_SORT TO IT_SORT.
CLEAR L_SORT.
S_LAYOUT-CELL_MERGE = 'X'.
ENDFORM. "SORT_T_FINAL
*& Form EVENT
text
FORM EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = I_EVENTS[].
LOOP AT I_EVENTS.
IF I_EVENTS-NAME = SLIS_EV_TOP_OF_PAGE.
I_EVENTS-FORM = 'T_TOP_OF_PAGE'.
ENDIF.
IF I_EVENTS-NAME = SLIS_EV_USER_COMMAND.
I_EVENTS-FORM = 'USER_COMMAND'.
ENDIF.
MODIFY I_EVENTS.
ENDLOOP.
ENDFORM. " EVENT
*& Form LAYOUT
text
FORM LAYOUT .
S_LAYOUT-DETAIL_POPUP = 'X'.
<b> S_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.</b>
ENDFORM. " LAYOUT
*& Form TOP-OF-PAGE
text
FORM TOP-OF-PAGE .
CLEAR LS_LINE.
LS_LINE-TYP = 'H'.
LS_LINE-INFO = 'Error Trouble -by cost'.
APPEND LS_LINE TO I_LIST_TOP_OF_PAGE.
CLEAR LS_LINE.
ENDFORM. " TOP-OF-PAGE
*& Form REMOVE_SORT
text
FORM REMOVE_SORT.
EXWA-FCODE = '&ODN'.
APPEND EXWA TO EX.
EXWA-FCODE = '&OUP'.
APPEND EXWA TO EX.
ENDFORM. "REMOVE_SORT
*& Form T_TOP_OF_PAGE
text
FORM T_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = I_LIST_TOP_OF_PAGE[].
ENDFORM. " T_TOP_OF_PAGE
Maybe you are looking for
-
Safari cannot open the page because the server cannot be found
Trying to open Outlook Webmail App from Ipad 2 and am receiving the Error Message "Safari cannot open the page because the server cannot be found. I have tried resetting my ipad 2 to no avail. Internet connection is working and am able to get into o
-
What is the information we can get the through details tab in RSMO
Hi to all, Currently I am working for P.support project, All of you well known about the importance of Details tab in rsmo screen. Here we have 4 options from where we can get more informaiton... 1) Reqest 2) Extraction 3) processing 4) Datapacket in
-
Flash Player incubator - impossible to uninstall from 64-bit OS
I made the stupid mistake of installing Flash player 11 plugin. I cannot uninstall it, and it is incredibly unstable. OS: Windows 7 pro 64-bit Browser of Choice: Firefox 4.0.1 Plugin version: Adobe Flash Player 11 Plugin version 11.0.1.3 When I go to
-
I have created an animation of a superman like character flying with the animation being his cape flapping, his eye moving occasionally, and he moves up and down slightly to imitate the movement of flight. I exported that animation as a SWF movie. I
-
I have been using Visio version 4 (16&32 bit) until I updated to Windows 7, where it will not load. I would like to access the .vsd files, but Visio viewer will not load my files stating that the file was created in an unsupported version. How can I