Layout in ALV Grid in OO ABAP
Hello friends,
I want the ALV Grid to be displayed with a default layout. I am able to get the saved layout on the selection screen but when I select that layout still the output layout is not taking it.
Please refer the code which I have written.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_layout.
PERFORM variant_search CHANGING p_layout.
FORM variant_search CHANGING p_layout TYPE slis_vari.
DATA : lv_exit TYPE c,
ls_variant TYPE disvariant.
ls_variant-report = syst-repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = ls_variant
i_save = 'A'
IMPORTING
e_exit = lv_exit
es_variant = ls_variant
EXCEPTIONS
not_found = 1
program_error = 2
OTHERS = 3.
IF sy-subrc EQ 0 AND lv_exit IS INITIAL.
p_layout = ls_variant-variant.
ENDIF.
ENDFORM. " variant_search
*-------The above piece of code helps me to save a layout.
Now when I enter the saved layout in my parameter, I want the output to take this layout and display the grid, but I dont know why it is not taking this layout. Please refer the code which I have written.
lr_layout = gr_alv->get_layout( ).
key-report = sy-repid.
lr_layout->set_key( key ).
lr_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
Please let me know how can I achieve this.
Regards,
Salil
Salil,
Here is some code that uses a default variant.
*& SELECTION-SCREEN
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_werks FOR marc-werks,
s_matnr FOR mara-matnr,
s_uname FOR sy-uname,
s_datum FOR sy-datum,
s_uzeit FOR sy-uzeit,
s_mtart FOR mara-mtart,
s_matkl FOR mara-matkl.
PARAMETERS: p_toler(3) TYPE n.
SELECTION-SCREEN: END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK v1 WITH FRAME.
PARAMETERS: p_vari LIKE disvariant-variant.
SELECTION-SCREEN END OF BLOCK v1.
*& Event INITIALIZATION
INITIALIZATION.
PERFORM set_defaults.
PERFORM default_variant CHANGING p_vari.
Event AT SELECTION-SCREEN ON VALUE-REQUEST
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
PERFORM f4_for_variant CHANGING p_vari.
*& Form default_variant
text
<--PL_VARI variant
FORM default_variant CHANGING pl_vari.
g_repid = sy-repid.
set options: save variants userspecific or general
g_save = 'A'. " 'A' = standard and user-specific saving
initialize variant
CLEAR gs_variant.
gs_variant-report = g_repid.
get default variant
gs_xvariant = gs_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = g_save
CHANGING
cs_variant = gs_xvariant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
pl_vari = gs_xvariant-variant.
ENDIF.
ENDFORM. " default_variant
*& Form f4_for_variant
text
<--PL_VARI variant
FORM f4_for_variant CHANGING pl_vari.
display variant selection dialog box
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = gs_variant
i_save = g_save
it_default_fieldcat =
IMPORTING
e_exit = g_exit
es_variant = gs_xvariant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF g_exit = space.
pl_vari = gs_xvariant-variant.
ENDIF.
ENDIF.
ENDFORM. " f4_for_variant
MODULE status_0100 OUTPUT
MODULE status_0100 OUTPUT.
SET PF-STATUS '100'.
SET TITLEBAR '100'.
IF o_container IS INITIAL.
REFRESH: t_fieldcat,
t_sortcat,
t_groupcat,
gt_exclude.
CREATE OBJECT o_container
EXPORTING container_name = 'CONTAINER'.
Create TOP-Document
CREATE OBJECT o_dyndoc_id
EXPORTING style = 'ALV_GRID'.
Create Splitter for custom_container
CREATE OBJECT o_splitter
EXPORTING parent = o_container
rows = 2
columns = 1.
CALL METHOD o_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = o_parent_top.
CALL METHOD o_splitter->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = o_parent_grid.
Set height for g_parent_html
CALL METHOD o_splitter->set_row_height
EXPORTING
id = 1
height = 12.
CREATE OBJECT o_grid
EXPORTING i_parent = o_parent_grid.
gs_layout-smalltitle = 'X'.
gs_layout-no_rowmark = ' '.
gs_layout-cwidth_opt = 'X'.
gs_layout-zebra = 'X'.
gs_layout-sel_mode = 'D'.
gs_variant-report = sy-cprog.
gs_variant-variant = p_vari.
gs_exclude = cl_gui_alv_grid=>mc_fc_info.
APPEND gs_exclude TO gt_exclude.
gs_exclude = cl_gui_alv_grid=>mc_fc_graph.
APPEND gs_exclude TO gt_exclude.
CALL METHOD o_grid->set_3d_border
EXPORTING
border = 1.
SET HANDLER lcl_event_handler=>hotspot_click FOR o_grid.
SET HANDLER lcl_event_handler=>top_of_page FOR o_grid.
SET HANDLER lcl_event_handler=>print_top_of_page FOR o_grid.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'Z1271'
CHANGING
ct_fieldcat = t_fieldcat.
LOOP AT t_fieldcat INTO h_fieldcat.
CASE h_fieldcat-fieldname.
WHEN 'MATNR'.
h_fieldcat-hotspot = 'X'.
WHEN 'VBELN'.
h_fieldcat-hotspot = 'X'.
WHEN 'UNAME'.
h_fieldcat-coltext = 'Maint. By'.
h_fieldcat-tooltip = 'Material maintained by'.
WHEN 'DATUM'.
h_fieldcat-coltext = 'Maint. Date'.
h_fieldcat-tooltip = 'Material maintenance date'.
WHEN 'UZEIT'.
h_fieldcat-coltext = 'Maint. Time'.
h_fieldcat-tooltip = 'Material maintenance time'.
WHEN 'EDAYS'.
h_fieldcat-coltext = 'EDays'.
h_fieldcat-tooltip = 'Elapsed days'.
WHEN 'ETIME'.
h_fieldcat-coltext = 'ETime'.
h_fieldcat-tooltip = 'Elapsed time same day'.
WHEN 'EDATU'.
h_fieldcat-coltext = 'Delivery Date'.
h_fieldcat-tooltip = 'Delivery date'.
ENDCASE.
MODIFY t_fieldcat FROM h_fieldcat.
CLEAR h_fieldcat.
ENDLOOP.
CALL METHOD o_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
i_save = 'A'
is_variant = gs_variant
it_toolbar_excluding = gt_exclude
CHANGING
it_fieldcatalog = t_fieldcat
it_sort = t_sortcat
it_outtab = t_rpt.
CALL METHOD o_grid->list_processing_events
EXPORTING
i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = o_dyndoc_id.
ENDIF.
ENDMODULE. "status_0100 OUTPUT
Similar Messages
-
ALV GRID Using oo abap example
Hi Friends,
I am new to oo abap, Can any one give me a basic example how i can create alv grid in oo abap.
regards,
DVNSHI,
Programming for ALV grid display using the classes involves creation of a screen and calling it for display.
Since there has to be a linking between the program and the screen we have created , this comes in the form of a container. We use two important classes during the programming for displaying ALV grid, CL_GUI_ALV_GRID and CL_GUI_CUSTOM_CONTAINER.
Steps To Use ALV Grid in a Program
1. Declare reference variables for,
Container (class CL_GUI_CUSTOM_CONTAINER) and
Grid (class CL_GUI_ALV_GRID)
Example
DATA: grid TYPE REF TO cl_gui_alv_grid,
custom_container TYPE REF TO cl_gui_custom_container
2. Create Standard Screen and a container on that screen and give a name to that container ( Use custom control button from tool bar) . This name will be used to link the container we have created on the screen with the object reference of class CL_GUI_CUSTOM_CONTAINER, which we have declared in the first step
3. Call the screen which has been created
4. Instantiate the container control and the ALV Grid Control in PBO of the screen.
Example
IF custom_container IS INITIAL.
CREATE OBJECT custom_container
EXPORTING
CONTAINER_NAME = MY_CONTAINER'.
CREATE OBJECT grid
EXPORTING
I_PARENT = custom_container.
ENDIF
5. For displaying the data, call the method set_table_for_first_display of object reference of CL_GUI_ALV_GRID.
Example
CALL METHOD grid->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT =
IS_LAYOUT =
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
CHANGING
IT_OUTTAB =
IT_FIELDCATALOG =
IT_SORT =
IT_FILTER =
EXCEPTION
INVALID_PARAMETER_COMBINATION =
PROGRAM_ERROR =
TOO_MANY_LINES =
others =
EXPLANATION OF SOME IMPORTANT PARAMETERS.
I_BYPASSING_BUFFER & I_BUFFER_ACTIVE :
When the program is run for the first time, the fields present in the output table and their positions are stored in a buffer. So the buffer is taken as reference for the successive executions. In order to bypass this buffer the above parameter values should be X and (space) respectively. If these values are not passed to the function module, the changes made in the structure of the internal table will not be reflected in the output.
I_STRUCTURE_NAME:
If the structure of your output table corresponds to a structure stored in the Data Dictionary (DDIC), the ALV Grid Control can use this information to generate the field catalog automatically. Pass the table structure as parameter. In this case, all fields of this DDIC structure are displayed in the list.
IS_VARIANT :
It allows the user to save and reuse the layout. It is a structure of type DISVARIANT and contain the display variant name. It facilitates pre-assignment for a layout, rather than displaying report and then choosing displaying variant.
I_SAVE:
This single character variable specifies whether the user specific display variants can be saved or not.
The I_SAVE "Options for saving layouts" parameter can have the following values:
U Only user specific layouts can be saved
X Only global layouts can be saved
A Both user specific and global layouts can be saved
Space Layouts can not be saved
IS_LAYOUT:
This structure of type LVC_S_LAYO
is used to control the layout of the ALV. Two important fields are:
GRID TITLE. : Title of grid
ZEBRA : Alternate lines in list are displayed in different colors.
IT_FIELDCATALOG:
This internal table of type LVC_T_FCAT
is used to specify the position of various fields in the report itab.
There are three ways we can fill the field catalog table
1. Automatically through data dictionary structure (DDIC). In this case we pass the table structure to I_STRUCTURE_NAME.
2. Manually in ABAP program. Filling the internal table of type LVC_T_FCAT
1. . With each row corresponding to each column of output table. Each row of this table will hold value like
i). TABNAME & FIELDNAME specifies the reference fields for F1 help
ii). CTABNAME & CFIELDNAME specifies the reference fields for currency formatting
iii). QTABNAME & QFIELDNAME specifies the reference fields for quantity formatting
iv). SELTEXT_L holds the long description of the field
v). SELTEXT_M holds the medium description of the field
vi). SELTEXT_S holds the small description of the field
vii). KEY specifies the Key field ( cannot be hidden )
viii). OUTPUTLEN species the output length of the field
ix). DO_SUM specifies that subtotal is required on this field
x). NO_OUT specifies a hidden field
3. Semi-Automatically by combining the above 2 procedures.
Call function Module REUSE_ALV_FIELDCATALOG_MERGE and pass DDIC
structure or the output table to generate the field catalog.
Add additional Rows or modify existing properties of the fields to be displayed.
METHODS OF IMPLEMENTING SOME EXTRA FEATURES
Set focus to the grid
After CALL METHODgrid->set_table_for_first_display insert the following stament:
CALL METHOD cl_gui_control=>set_focus EXPORTING control = grid
Refresh grid display
Use the grid method REFRESH_TABLE_DISPLAY
Example:
CALL METHOD grid->refresh_table_display.
Set the title of the grid
Fill the grid_title field of structure lvc_s_layo.
DATA:
gs_layout TYPE lvc_s_layo.
gs_layout-grid_title = 'TITLE'.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'structure name'
is_layout = gs_layout
CHANGING it_outtab = Output table.
The structure lvc_s_layo contains fields for setting graphical properties, displaying exceptions, calculating totals and enabling specific interaction options
Event Handling
We can handle the events triggered by
1. User defined Text Output
2. Mouse-controlled Actions
3. Self-defined and Standard Functions
Steps for Event Handling
1. Define a (local) class for event handling
2. Define a method for each event you need to handle
3. Implement your event handler methods.
4. Create Object of the above class
5. Link used events and event handler methods of the receiver object and the grid
object.
Example program : Handling Double Click Event
Step1.Define a class.
class lcl_my_event_receiver definition.
public section.
methods:
handle_double_click
for event double_click of cl_gui_alv_grid.
endclass.
Step 2. Implement the class
class lcl_my_event_receiver implementation.
method handle_double_click.
message i001(zz) with ' double click event - Triggerd '.
endmethod.
endclass.
Step 3. Declare and create Object for the local class defined and implemented in steps 1 and 2 respectively
o_receiver TYPE REF TO lcl_my_event_receiver (Declaration)
create object o_receiver. (Instantiation)
Step 4. Link the method for handling the event with the grid object in the PBO of screen after instantiating the grid object
set handler o_receiver->handle_double_click for grid.
EXAMPLE PROGRAM TO CHANGE A CLASSICAL REPORT OUTPUT TO A ALV GRID
This can be used as a template program to convert a classical report layout to a ALV grid.
Report<Report name>
Grid data Declarations----------------------------------------------*
INCLUDE ZVINALVD.
Internal table for ALV grid
TYPES: BEGIN OF T_ALV,
Field1 like table-field1,
Field2 like table-field2,
END OF T_ALV.
DATA: I_ALV TYPE TABLE OF T_ALV.
DATA: WA_ALV TYPE T_ALV.
-Class declarations----
INCLUDE ZVINALVE.
Add a checkbox in selection screen for ALV grid display. If it is unchecked
output will be of classical type.
SELECTION-SCREEN BEGIN OF BLOCK box01.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN: COMMENT 4(30) To display repot output as a ALV grid.
PARAMETERS: p_alv AS CHECKBOX.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN END OF BLOCK box01.
START-OF-SELECTION.
Fill the ALV grid internal table
END-OF-SELECTION.
IF P_ALV = X.
PERFORM ALV_DISPLAY.
ELSE.
PERFORM CLASSICAL_DISPLAY.
ENDIF.
Alv Display
FORM ALV_DISPLAY.
CALL SCREEN 100.
ENDFORM.
Module STATUS_0100 OUTPUT
PBO for ALV Grid
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'GRID_DISPLAY'.
DATA:
For parameter IS_VARIANT that is used to set up options for storing
the grid layout as a variant in method set_table_for_first_display
l_layout TYPE disvariant.
GS_LAYOUT-SEL_MODE = 'B'.
Optimize column width
GS_LAYOUT-CWIDTH_OPT = 'X'.
Read data and create objects
IF go_custom_container IS INITIAL.
Create objects for container and ALV grid
CREATE OBJECT go_custom_container
EXPORTING container_name = 'ALV_CONTAINER'.
CREATE OBJECT go_grid
EXPORTING i_parent = go_custom_container.
Create object for event_receiver class
and set handlers
CREATE OBJECT o_event_receiver.
SET HANDLER o_event_receiver->handle_user_command FOR go_grid.
SET HANDLER o_event_receiver->handle_toolbar FOR go_grid.
Layout (Variant) for ALV grid
l_layout-report = sy-repid. "Layout to report
To built fieldcatalog
PERFORM alv_build_fieldcatalog.
Grid setup for first display
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
is_variant = l_layout
i_save = 'A'
is_layout = gs_layout
CHANGING it_outtab = I_ALV
it_fieldcatalog = fieldcat.
Raise event toolbar to show the modified toolbar
CALL METHOD go_grid->set_toolbar_interactive.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
Form ALV_BUILD_FIELDCATALOG.
Store contents of selected line in a internal table
FORM alv_build_fieldcatalog.
CLEAR afield.
afield-fieldname = 'FIELD1'.
afield-tabname = 'I_ALV'.
afield-coltext = Field Name 1.
afield-lzero = ' '.
afield-key = 'X'.
afield-outputlen = XX.
APPEND afield TO fieldcat.
CLEAR afield.
afield-fieldname = 'FIELD2'.
afield-tabname = 'I_ALV'.
afield-coltext = Field Name 2.
APPEND afield TO fieldcat.
ENDFORM. " alv_build_fieldcatalog
Module USER_COMMAND_0100 INPUT
PAI for ALV Grid
MODULE USER_COMMAND_0100 INPUT.
CASE OK_100.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
Form SELECT_LINE
Store contents of selected line in a internal table
FORM SELECT_LINE.
DATA:l_lines TYPE i.
REFRESH gi_index_rows.
CLEAR g_selected_row.
Read index of selected rows
CALL METHOD go_grid->get_selected_rows
IMPORTING et_index_rows = gi_index_rows.
Check if any row are selected at all. If not
table gi_index_rows will be empty
DESCRIBE TABLE gi_index_rows LINES l_lines.
IF l_lines = 0.
CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
EXPORTING
textline1 = 'You must choose a line'.
EXIT.
ENDIF.
Read indexes of selected rows.
LOOP AT gi_index_rows INTO g_selected_row.
IF sy-tabix = 1.
READ TABLE I_ALV INDEX g_selected_row-index INTO
WA_ALV.
ENDIF.
ENDLOOP.
ENDFORM. " SELECT_LINE
Includes:
1. ZVINALVD for data declarations
INCLUDE ZVINALVD .
Type pool for icons - used in the toolbar
TYPE-POOLS: icon.
To allow the declaration of o_event_receiver before the
lcl_event_receiver class is defined, decale it as deferred in the
start of the program
CLASS lcl_event_receiver DEFINITION DEFERRED.
GLOBAL DATA FOR ALV GRID
DATA:
OK code for alv grid screen
OK_100(4) TYPE C,
ALV control: Layout structure
gs_layout TYPE lvc_s_layo,
Declare reference variables to the ALV grid and the container
go_grid TYPE REF TO cl_gui_alv_grid,
go_custom_container TYPE REF TO cl_gui_custom_container,
o_event_receiver TYPE REF TO lcl_event_receiver,
Data for storing information about selected rows in the grid
Internal table
gi_index_rows TYPE lvc_t_row,
Information about 1 row
g_selected_row LIKE lvc_s_row.
fieldcatalog
DATA: fieldcat TYPE LVC_T_FCAT,
afield TYPE LVC_S_FCAT.
2. ZVINALVE for Class/object declarations
INCLUDE ZVINALVE.
C L A S S E S
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS.
CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
Event handler method for event toolbar.
CONSTANTS:
Constants for button type
c_button_normal TYPE i VALUE 0,
c_menu_and_default_button TYPE i VALUE 1,
c_menu TYPE i VALUE 2,
c_separator TYPE i VALUE 3,
c_radio_button TYPE i VALUE 4,
c_checkbox TYPE i VALUE 5,
c_menu_entry TYPE i VALUE 6.
DATA: ls_toolbar TYPE stb_button.
Append seperator to the normal toolbar
CLEAR ls_toolbar.
MOVE c_separator TO ls_toolbar-butn_type..
APPEND ls_toolbar TO e_object->mt_toolbar.
Append a new button that to the toolbar. Use E_OBJECT of
event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.
This class has one attribute MT_TOOLBAR which is of table type
TTB_BUTTON. The structure is STB_BUTTON
CLEAR ls_toolbar.
MOVE 'DISPLAY' TO ls_toolbar-function.
MOVE icon_DISPLAY TO ls_toolbar-icon.
MOVE 'Displaying customer' TO ls_toolbar-quickinfo.
MOVE 'Display' TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD.
METHOD handle_user_command.
Handle own functions defined in the toolbar
CASE e_ucomm.
WHEN 'DISPLAY'.
PERFORM SELECT_LINE.
ENDCASE.
ENDMETHOD.
Reward if useful -
Remove buttons in ALV grid display in ABAP Web Dynpro
Hi,
Sub: ALV grid-->Web Dynpro ABAP.
Request guidance to prevent display of the buttons "Microsoft Excel" and "Print Version" (which provide options to export the ALV grid output into an Excel format document).
Is there a way we could hide this from being displayed on the ALV grid in a Web dynpro ABAP component output?
Thanks very much.
Best Regards,
AdiHi Adithya,
really simple solution is to call cl_salv_wd_model_table_util=>if_salv_wd_table_util_stdfuncs=>set_all( abap_false ). This deactivates all ALV functionality.
For individual setting cl_salv_wd_config_table if_salv_wd_standard_functions~set_<x>_allowed.
- Michelle -
Hi,
I have to save layout in ALV grid which should persist every time when i start the transaction.I am able to get save, change and manage option in the grid and also able to set the default layout but this default layout doesnot work.
please see the code :
l_repvar = sy-repid.
ls_variant = l_repvar.
l_varient = 'A'.
ls_variant-variant = l_varient.
draft_layout-sel_mode = 'D'.
draft_layout-stylefname = 'CELLPROP'.
draft_layout-no_f4 = 'X'.
DISPLAY THE DATA ON THE GRID
CALL METHOD draft_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'PSHLP_DRAFT_ST'
is_layout = draft_layout
it_toolbar_excluding = g_it_exclude
is_variant = ls_variant
i_save = 'A'
i_default = 'X'
CHANGING
it_fieldcatalog = draft_fieldcat
it_outtab = l_draft[].
i have tried by chaging i_save to 'X' and 'U' but no difference.
Useful answers will be rewarded.
Thanks and Regards,
Harshhi,
try with this code,
DATA: wa_disvariant LIKE disvariant.
wa_disvariant-report = g_repid.
wa_disvariant-username = sy-uname.
and pass these values in your function module,
i_save = 'X'
is_variant = wa_disvariant
thanks and regards,
muralidhar. -
Hi
i'm using ALV-GRID OO and i have problems with
saving my own layout.
In the output-liste i have a button to chage the output, but i'm missig
a button to save the new layout.
CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = GT_EXCLUDE
IS_LAYOUT = GS_LAYOUT
I_SAVE = 'A'
CHANGING
IT_FIELDCATALOG = GT_FIELDCAT
IT_OUTTAB = ITAB.
Any idea?
Regards, DieterMake sure that you pass the variant also.
data: variant type disvariant.
variant-report = sy-repid.
variant-username = sy-uname.
CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = GT_EXCLUDE
IS_LAYOUT = GS_LAYOUT
is_variant = variant
I_SAVE = 'A'
CHANGING
IT_FIELDCATALOG = GT_FIELDCAT
IT_OUTTAB = ITAB.
Regards,
Rich Heilman -
Manipulate Layout on ALV Grid with dynamic table
Dear all
i'm generating a dynamic table depending of a date selection. That means that I show columns for weeks and the quantity of weeky migh change.
Now the users wants to have a specific layout of the ALV grid with totals. When he saves the layout, only the weeks at this selection will show the next time he runs the programm with a larger selection.
a) Is it possible to modify the layout during runtime by programming?
b) Do you have any other ideas how to solve this problem?
Thank youYou don't know the names of your columns? hmm you do, because before you created dynamic table you had to create field catalog, so the structure and column names of newly (dynamically) created table will be the same like defined in the field catalog.
The last loop also does not look good, in my opinion should be something like:
LOOP AT lt_datatable +(my first table)+ ASSIGNING <ls_data4>.
AT NEW pernr.
APPEND initial line to <fs_1> assigning <fs_2>.
<fs_2>-pernr = <ls_data4>-pernr.
ENDAT.
ASSIGN COMPONENT <ls_data4>-wage_type OF STRUCTURE <fs_2> TO <fs_5>.
<fs_5> = <ls_data4>-amount.
ENDLOOP.
also keep in mind that number of calls of method cl_alv_table_create=>create_dynamic_table is limited to 36 (?) calls within one program session because it uses dynamic subroutine pool behind so you will have short dump if you will execute that 37 times. -
F4 help for field in ALV grid control (using ABAP objects)
Hi All,
I have created a z table ZTAB which is a master table( with single column X). field X should be a input field in ALV Grid through F4 key. I have created searchelp and assigned it to data element of X feild, and in domain level I have assigned ZTAB as value table.
And in ALV field catalog wrote ls_fcat-ref_tab = 'ZTAB'. But still I'm not getting list of values when I press F4.
Can anyone help me to understand what is missing here? How to call standardard F4 help?
This is very urgent..
Regards
Jaker.u can refer to this standard program :BCALV_EDIT_08
also u wont get the list of values automatically..
declare a class :
CLASS LCL_EVENT_HANDLER DEFINITION.
PUBLIC SECTION.
METHODS :
handle_on_f4 for event onf4 of cl_gui_alv_grid
importing e_fieldname es_row_no er_event_data,
ENDCLASS. "LCL_EVENT_HANDLER
implementation of class
here u pass ur internal table what u want to display as pop up for f4 help.
*& Class (Implementation) LCL_EVENT_HANDLER
Text
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
*Method to handle F4 click.
Method handle_on_f4.
Function to create a popup and passing the values of internal table in it.
CALL FUNCTION 'POPUP_WITH_TABLE'
EXPORTING
ENDPOS_COL = 60
ENDPOS_ROW = 60
STARTPOS_COL = 5
STARTPOS_ROW = 5
TITLETEXT = 'pop up'
IMPORTING
CHOICE = wa_grid-zfield
TABLES
VALUETAB = ITAB
EXCEPTIONS
BREAK_OFF = 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.
RETURN.
ENDIF.
endmethod. "handle_on_f4
ENDCLASS. "LCL_EVENT_HANDLER
hope this gives u some idea. -
I created an alv grid in my web dynpro...
Everything worked fine ! Then I needed to add a column to the alv grid...
SO
1 - Chnaged the structure un SE11
2 - Update component controller context so that the field is displayed
3 - Update all bindings
4 - Update biding between DATA and ALV Table
But the column is not displayed by default in the alv grid ! But if I go to settings, the colomn is available...
What should i do to display this column by default ???
Regards,
SteKamYatah !
I manage to show the columns by default !
We discovered it was stored in the user settings...
Then the question is ... "How do I disable user settings on ALV Grid"
Thanks in advance!
Stekam -
How to set default layout for ALV grid ?
Dear all,
When execute ALV reports, the user customize the layout for their own purpose. But each time they run that report, they must choose again their layout. Is there any way to set the layout as default ?
Thank you very much,
Sylvecat.Hi,'
After you have created a layout just follow the steps listed below for making it as default layout:
1. Click (Save Layout).
2. Enter a name in the Save Layout field. The name must begin with a letter.
3. Type in a description for the layout in the Name field.
4. Select the Default Setting check box if you want this layout to be the default layout every time you run
the report.
5. Click (Continue).
Note: A warning message will appear if you are trying to save over an existing layout. Close the box by
selecting the X in the upper right hand corner or choose Yes to overwrite the layout.
Reward Points if found helpfull..
Cheers,
Chandra Sekhar. -
ALV GRID WEB DYNPRO ABAP CREATE FUNCTION BUTTON ON A NEW LINE?
Dear all,
I'd like to create 2 pushbuttons on a second line of the alvgrid toolbar
Is there any way to do that ?
RegardsHai Anubhav,
Read the node which is binded to the alv and use the following syntax:
CALL METHOD node_first_page_output->get_lead_selection_index
receiving
index = index
where index is type i. and will return u the lead selection.
Regards,
Madhu -
Problem with same layout (variant) for two ALV Grid and ALV Tree
Hello!
I have two docking containers on the screen. On the left i have cl_gui_alv_tree, on the right cl_salv_table.
When a user set a default layout for ALV Grid (or ALV Tree), raport starts and sets this layout in both objects (tree and grid).
How to avoid this?Hi,
Take Two radio buttons.
First radion button display the two containers in grid format,
second radio button display the two containers in tree format base on user selection.
CREATE OBJECT G_DOCING_CONTAINER
EXPORTING PARENT = G_CUSTOM_CONTAINER."G_CONTAINER.
DISPLAY THE DATA IN GRID FORMATA
CREATE OBJECT r_grid
EXPORTING
i_parent = G_DOCING_CONTAINER
CALL METHOD g_docing_container->set_width
EXPORTING
width = 1300.
DISPLAY THE GRID DATA IN SECOND CONTAINER
CREATE OBJECT r_grid1
EXPORTING
i_parent = G_DOCING_CONTAINER
CALL METHOD g_docing_container->set_width
EXPORTING
width = 1300.
OTHERWISE WE CAN DISPLAY THE TWO CONTAINERS DATA IN A GRID FORMAT
CREATE OBJECT g_tree
EXPORTING
parent = g_docing_container"g_custom_container
IF R1 = 'X'. "FOR GRID DISPLAY
CALL METHOD r_grid1->set_table_for_first_display
CALL METHOD r_grid2->set_table_for_first_display
ELSE.
************TREE DISPLAY
ENDIF.
regards,
muralii -
How to use Style in LVC_S_LAYO (ALV Grid Layout)
Hi Experts,
I am trying to set field 'STYLEFNAME' of LVC_S_LAYO while setting up layout for ALV GRID using 'SET_TABLE_FOR_FIRST_DISPLAY' . I'm passing the field name contain the styles for each row. I am setting it in the same way we set 'INFO_FNAME' by passing color field name for coloring the rows. Styles are available in include <CL_ALV_CONTROL> .
Please note styles are working properly when I am setting it at field cat level by setting fieldcat field LVC_S_FCAT-STYLE. But set sets style for entire column. I want to set style for few rows. I want to use style 'ALV_STYLE_BUTTON' .
Please advice how to do this.
Regards,
Sushant.I'll try to understand your question.
You have a 'new-style' alv and want to show some fields as pushbutton.
To make a cell to be displayed as a pushbutton, we have two steps.
Firstly, insert a new inner table of type u201CLVC_T_STYLu201D into your list data table.
*--- Internal table holding list data
DATA BEGIN OF gt_list OCCURS 0 .
INCLUDE STRUCTURE SFLIGHT .
DATA rowcolor(4) TYPE c .
DATA cellcolors TYPE lvc_t_scol .
DATA carrid_handle TYPE int4 .
DATA connid_handle TYPE int4 .
DATA cellstyles TYPE lvc_t_styl .
DATA END OF gt_list .
Fill this inner table for each field to be displayed as pushbutton.
DATA ls_style TYPE lvc_s_styl .
READ TABLE gt_list INDEX 7 .
ls_style-fieldname = 'SEATSMAX' .
ls_style-style = cl_gui_alv_grid=>mc_style_button .
APPEND ls_style TO gt_list-cellstyles .
MODIFY gt_list INDEX 7 .
As usual, we state our list data table field related with styles in the layout structure at field u2018STYLEFNAMEu2019.
e.g. ps_layout-stylefname = 'CELLSTYLES' .
Button click event is handled like hotspot click via the event u201Cbutton_clicku201D through its parameters u201Ces_col_idu201D and u201Ces_row_nou201D which contain the address of the clicked pushbutton cell. -
Field Catolgue in alv grid display
Hi Abapers,
I need to display the percentage rows with decimals and other rows without decimal . Is their any option in field catalog to do like this. Or tell me any other alternative to achieve this.
sno total col1 col2 col3
1 220 100 20 100
2 320 120 50 150
tot 540 220 70 250
per 40.74 1.87 and so on
or ,
I have two different internal tables how can i put it in one field catalog to pass it to alv grid display.
Regards,
PriyaDon't do total by your self in the Pogram.
in the Fieldcatalog there is an Attribute which will do total & Average .
Enable it so that from one internal table data it self it will do good.
example program
Below is an example ABAP program which will populate a simple internal table(it_ekpo) with data and
display it using the basic ALV grid functionality(including column total). The example details the main
sections of coding required to implement the ALV grid functionality:
Data declaration
Data retrieval
Build fieldcatalog
Build layout setup
REPORT zdemo_alvgrid .
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,
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,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
* Build Fieldcatalog for ALV Report
form build_fieldcatalog.
* There are a number of ways to create a fieldcat.
* For the purpose of this example i will build the fieldcatalog manualy
* by populating the internal table fields individually and then
* appending the rows. This method can be the most time consuming but can
* also allow you more control of the final product.
* Beware though, you need to ensure that all fields required are
* populated. When using some of functionality available via ALV, such as
* total. You may need to provide more information than if you were
* simply displaying the result
* I.e. Field type may be required in-order for
* the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
* fieldcatalog-do_sum = 'X'.
* fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-do_sum = 'X'. "Display column total
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
* gd_layout-totals_only = 'X'.
* gd_layout-f2code = 'DISP'. "Sets fcode for when double
* "click(press f2)
* gd_layout-zebra = 'X'.
* gd_layout-group_change_edit = 'X'.
* gd_layout-header_text = 'helllllo'.
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'
exporting
i_callback_program = gd_repid
* i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
* i_callback_user_command = 'USER_COMMAND'
* i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
* it_special_groups = gd_tabgroup
* IT_EVENTS = GT_XEVENTS
i_save = 'X'
* is_variant = z_template
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 table it_ekko.
endform. " DATA_RETRIEVAL
gowri
Message was edited by:
Gowri Krishna -
HI ALL,
I am having a alv grid output of 10 columns .out of these 10 column 1 is editable and column name is discount.i want drop down for this column.
how can i do it ? i had written normal abap, please help me out as this is urgentHi,
Following this report for editable alv report.
REPORT YMS_EDITABLEALV.
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
Thanks,
Sankar M -
Help needed for editable alv grid program
hi,
Can you please tell me how to set a update button in application toolbar of alv griv without suppressing it and how to write the code for that update button so that if I change my editable column data and press the update button my updated data should be stored in my database table.
the code what i wrote is:
TABLES: vbak,vbap.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_final,
vbeln LIKE vbak-vbeln,
erdat LIKE vbak-erdat,
matnr LIKE vbap-matnr,
posnr LIKE vbap-posnr,
END OF t_final.
DATA: i_final TYPE STANDARD TABLE OF t_final INITIAL SIZE 0,
wa_final TYPE t_final.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
fieldcatalog-fieldname = 'VBELN'.
fieldcatalog-seltext_m = 'sales order'.
fieldcatalog-col_pos = 0.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ERDAT'.
fieldcatalog-seltext_m = 'date'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'material no.'.
fieldcatalog-col_pos = 2.
fieldcatalog-edit = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'POSNR'.
fieldcatalog-seltext_m = 'line item no.'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
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'
EXPORTING
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
IT_EVENTS = GT_XEVENTS
i_save = 'X'
is_variant = z_template
TABLES
t_outtab = i_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_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT avbeln aerdat bmatnr bposnr FROM vbak AS a
INNER JOIN vbap AS b ON avbeln = bvbeln
INTO TABLE i_final WHERE avbeln = bvbeln.
ENDFORM. " DATA_RETRIEVAL
thanks in advance.hi sudhir,
thanks for ur reply.
after seeing the code u send to me i made changes to my program.but still when i click on update button,nothing is happening.can u please suggest me an idea.
TABLES: vbak,vbap.
TYPE-POOLS: slis. "ALV Declarations
TYPES: BEGIN OF t_final,
vbeln LIKE vbak-vbeln,
erdat LIKE vbak-erdat,
matnr LIKE vbap-matnr,
posnr LIKE vbap-posnr,
END OF t_final.
DATA: i_final TYPE STANDARD TABLE OF t_final WITH HEADER LINE,
wa_final TYPE t_final.
*DATA:i_final LIKE vbap OCCURS 0.
*DATA:wa_final LIKE vbap.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
fieldcatalog-fieldname = 'VBELN'.
fieldcatalog-seltext_m = 'sales order'.
fieldcatalog-col_pos = 0.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ERDAT'.
fieldcatalog-seltext_m = 'date'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'material no.'.
fieldcatalog-col_pos = 2.
fieldcatalog-edit = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'POSNR'.
fieldcatalog-seltext_m = 'line item no.'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
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'
EXPORTING
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'GUI_STAT'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
it_events = it_events
i_save = 'X'
is_variant = z_template
TABLES
t_outtab = i_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_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT avbeln aerdat bmatnr bposnr FROM vbak AS a
INNER JOIN vbap AS b ON avbeln = bvbeln
INTO TABLE i_final WHERE avbeln = bvbeln.
ENDFORM. " DATA_RETRIEVAL
FORM GUI_STAT *
--> RT_EXTAB *
FORM gui_stat USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'UPDATE' EXCLUDING rt_extab.
ENDFORM.
FORM USER_COMMAND *
--> U_COMM *
--> RS_SELFIELD *
FORM user_command USING u_comm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA:selfield TYPE slis_selfield.
CASE u_comm.
WHEN 'UPDATE'.
LOOP AT i_final ."into wa_final.
i_final-matnr = vbap-matnr.
update (vbap) from table i_final.
IF sy-subrc = 0.
MESSAGE s000(0) WITH 'records updated successfully'.
ENDIF.
ENDLOOP.
ENDCASE.
ENDFORM.
Maybe you are looking for
-
Run Time Error while Entering Quantity in Sales Order
Dear All, Iam getting Run time Error while iam entering material quantity in sales order.Please find the screenshot of the same. kindly Help Me.Me. Plz note that we had done a system copy two days back to our new server. Rgds Thomson ST22 Screenshot
-
OBIEE 11g - Download All/Display All of rows in Answers
Hi All, I have created a request in OBIEE 11g and now displaying it on dashboard. by default shows 25 rows, can extend it fo 500 rows, next i should keep on clicking to see full data. Also download of data is possible for the rows available on page o
-
BOM material transfer from ECC 6.0 to GTS 10.0
We are trying to transfer BOM (Bill of Material) type materials through sales order from ECC to GTS system. However we need to classify in GTS system both parent iteam and child items else the sales order containing BOM material will remain in "block
-
Bluetooth pair with VW car phone handfree system
I have 4 Iphone devices in my family (3G-3GS-4-5). None of these is enabled to pair to my car (VW Passat) bluetooth phone system RNS510 . I was told by the VW customer's service that RNS510 operate the mobile phones through the rSAP (remote Sim Acces
-
ITtunes 5 conflict with Roxio 7.4
Upgrade form iTunes 4.9 to 5 caused Roxio not to see both my DVD-ROM (NEC) and DVD burners (Pioneer & LaCie). Luckily I have goBack and was able to roll the system back twice. iTunes Version 5.0.1 did not fare much better. Other burning software on t