ALV Grid Excel in Place using REUSE_ALV_GRID_DISPLAY
I have a ALV grid displayed in a report and i have a bunch of layouts created by various users and the layouts works fine when selected. But when I use 'Excel' (excel-in-place) button to export the grid into an excel sheet, the order of the columns are all jumbled up and not in sync with the ALV grid layout on the screen. However, when I use export to local file>excel option, the order of columns are in sync with the layout. Can any one explain why this is happening and how I can fix it ? Is there any OSS note or something that I need to apply ?
PS : I am using REUSE_ALV_GRID_DISPLAY to display the report and I am building the fieldcatalog manually
Eg :
CLEAR r_fieldcatalog.
MOVE 'TB_OUTPUT' TO r_fieldcatalog-tabname.
MOVE 'BUKRS' TO r_fieldcatalog-fieldname.
MOVE 'VBAK' TO r_fieldcatalog-ref_tabname.
MOVE 'BUKRS_VF' TO r_fieldcatalog-ref_fieldname.
MOVE text-f01 TO r_fieldcatalog-seltext_s.
MOVE text-f01 TO r_fieldcatalog-seltext_m.
MOVE text-f01 TO r_fieldcatalog-seltext_l.
add '1' to lv_col_pos .
move lv_col_pos to r_fieldcatalog-col_pos .
APPEND r_fieldcatalog TO tc_fieldcatalog.
CLEAR r_fieldcatalog.
MOVE 'TB_OUTPUT' TO r_fieldcatalog-tabname.
MOVE 'VKORG' TO r_fieldcatalog-fieldname.
MOVE 'VBAK' TO r_fieldcatalog-ref_tabname.
MOVE 'VKORG' TO r_fieldcatalog-ref_fieldname.
MOVE text-f02 TO r_fieldcatalog-seltext_s.
MOVE text-f02 TO r_fieldcatalog-seltext_m.
MOVE text-f02 TO r_fieldcatalog-seltext_l.
add '1' to lv_col_pos .
move lv_col_pos to r_fieldcatalog-col_pos .
APPEND r_fieldcatalog TO tc_fieldcatalog.
Thanks in advance,
Shareen
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_pf_status_set = 'ALV_PF_STATUS'
i_callback_program = sy-repid
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
i_default = ' '
i_save = g_save
TABLES
t_outtab = it_tab
EXCEPTIONS
program_error = 1
OTHERS = 2.
and beneath this just put a form.as its shown.
FORM alv_pf_status USING l_alv_excl TYPE STANDARD TABLE.
SET PF-STATUS 'STANDARD_FULLSCREEN' "excluding lt_extab
OF PROGRAM 'SAPLSETB'.
ENDFORM. "alv_pf_status
Similar Messages
-
ALV grid with 2 headers - using OOPS
Hi,
I have a requirement wherein I need to display 2 headers using ALV Grid. I am using cl_gui_alv_grid->set_table_for_first display.
Header1 Header2
Col1 Col2 Col3 Col4 Col5
1 2 3 4 5
Please suggest if this is possible, if yes, how to acheive it.
Thanks,
SmitaHI RAM,
I have did same like what you said. but iam not getting. Below is the pgm what i have dev. please correct it and let me knwo.
TYPE-POOLS: SLIS.
DATA: I_CATLOG TYPE slis_t_fieldcat_alv,
W_CATLOG TYPE SLIS_FIELDCAT_ALV,
I_CATLOG2 TYPE slis_t_fieldcat_alv,
W_CATLOG2 TYPE SLIS_FIELDCAT_ALV,
V_PGM TYPE SY-REPID.
data: begin of itab1 occurs 0,
HEADER1(10) TYPE C,
HEADER2(10) TYPE C,
end of itab1.
data: begin of itab occurs 0,
vbeln like vbak-vbeln,
posnr like vbap-posnr,
MATNR LIKE VBAP-MATNR,
MATWA LIKE VBAP-MATWA,
end of itab.
select vbeln
posnr
MATNR
MATWA
from vbap
up to 20 rows
into table itab.
w_catlog-seltext_l = 'HEADER1'.
w_catlog-datatype = 'CHAR'.
w_catlog-outputlen = 10.
W_CATLOG-tabname = 'ITAB1'.
append w_catlog2 to i_catlog2.
clear w_catlog2.
w_catlog-seltext_l = 'HEADER2'.
w_catlog-datatype = 'CHAR'.
w_catlog-outputlen = 10.
W_CATLOG-tabname = 'ITAB1'.
append w_catlog2 to i_catlog2.
clear w_catlog2.
w_catlog-seltext_l = 'Sales Document'.
w_catlog-datatype = 'CHAR'.
w_catlog-outputlen = 10.
w_catlog-fieldname = 'VBELN'.
W_CATLOG-tabname = 'ITAB'.
append w_catlog to i_catlog.
clear w_catlog.
w_catlog-seltext_l = 'ITEM'.
w_catlog-datatype = 'NUMC'.
w_catlog-outputlen = 6.
w_catlog-fieldname = 'POSNR'.
W_CATLOG-tabname = 'ITAB'.
append w_catlog to i_catlog.
clear w_catlog.
w_catlog-seltext_l = 'MATERIAL'.
w_catlog-datatype = 'CHAR'.
w_catlog-outputlen = 18.
w_catlog-fieldname = 'MATNR'.
W_CATLOG-tabname = 'ITAB'.
append w_catlog to i_catlog.
clear w_catlog.
w_catlog-seltext_l = 'Material entered'.
w_catlog-datatype = 'CHAR'.
w_catlog-outputlen = 18.
w_catlog-fieldname = 'MATWA'.
W_CATLOG-tabname = 'ITAB'.
append w_catlog to i_catlog.
clear w_catlog.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_PGM
IT_FIELDCAT = I_CATLOG2
TABLES
T_OUTTAB = ITAB1
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.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_PGM
IT_FIELDCAT = I_CATLOG
TABLES
T_OUTTAB = ITAB
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. -
Hi,
we offen use the ALV-GRID with EXCEL-Layout.
In this layout you can Copy the sheet, print etc.
But a lot of Function are grey and cannot be used.
We want to send the excel-sheet via EXCEL-Button
as an email.
Question: is it possible to set this function
as useable?
thanks for Help
Regards, DieterHi Dieter,
it is true: For many SAP modules the codes are inactive.
Sometimes it works entering &VEXCEL or &XXL in the command line.
Otherwise: If no exitv is available to set your own status including active &VEXCEL or &XXL, it is a modification.
It depends if SAP uses standard or non-standard ALV functions.
Regrads,
Clemens -
How to read an APO table from excel in place using Visual Basic ?
We have enhanced some APO reports using layouts that use excel in place with custom visual basic (VB) code. For example, the VB code can append the data with additional columns that perform specific calculations and then proceed to create pivot table reports in excel..That is working fine.
The challenge is to see if that VB code could read specific APO tables (e.g. product master tables) to bring additional elements into excel and thus expand the report content. We know that additional fields can be added to the reports, but having the flexibility to read tables from VB could be more flexible.
Can that be done?. If so, would it be possible using exclusively the VB code attached to the layout, i.e. no ABAP?Hello Anselmo,
I am assuming you are doing this either using BeX analyzer or by reading the planning book using the RFC ActiveX component and a BAPI.
I think it's possible to retrieve the data from the product master table. Here are my thoughts on how can this be done:
1) You can create a generic datasource (transaction RSO2) for the product master table, connect that to a BW remotecube and use a BeX query to retrieve that values. You can then join the queries using VBA. Alternatively, you can build a muti-provider that connects your current InfoCube to the new RemoteCube and build a query from there. The multi-provider, in this case, joins the data (no more VBA).
2) If you have already loaded your product master data into master data carrying InfoObjects then you can try the same technique as #1 but this time there is no need to create the generic datasource. You can use the InfoObjects for your master data as the InfoProviders for your query.
3) You can try the ActiveX component from SAP which can connect to any emote enabled function in SAP system. SAP already provided some BAPIs (check transaction BAPI for a list) which might be able to provide the data. You can also create your own function modules (be sure to make it remote enabled) using ABAP. (transaction SE37).
Hope this helps -
How to show an ALV grid in planning book (using macro-exit)
Hi Expertss,
I am using a macro-exit. Now in the execution flow of this macro-exit I am required to shaow an ALV grid. I tried calling a Zreport in which i am calling alv screen(screen type dialog box). It is giving a short-dump saying Exception condition "CNTL_ERROR" raised.
If i comments the fieldcatlog and structure name while calling the ALV in my Zreport then the alv is coming but then planning book is not vivible.
Kindly tell what thing I am missing and what probable thing I can do to make it work.
Thanks a lot in advance.I got the solution.
-
ALV Grid and screen title using OO
I've been searching thru documentation and this forum without any luck. I want to display a screen title in the location where the report name displays on a standard report, i.e., between the Menu Toolbar and the Application Toolbar. I am using OO ALV Grid. I found how to do it using function modules, there they set the layout field "gs_test-layo_title" but this field does not exist in OO layout. The field "grid_title" displays the title inside the grid display (not what I want) and the field "detailtitl" does not work either.
Any help will be greatly appreciated.
ThanksHi Nicolas, understand that the OO ALV Grid which you are referring to is implemented into a screen container. This container does not really have anything to do with the screen title. Only when using the full-screen grid(using the FM) do you have direct control of this title via the ALV tool. If you simply want to set this title in the title bar, you can simply do this using the SET TITLE-BAR statement in the PBO of the screen. Or you may even able to simply set the system variable(haven't tested this) again in the PBO of the screen.
sy-title = 'This is my title'.
Regards,
Rich Heilman -
How to upload logo for alv grid when we are using classes
Hi am using cl_gui_alv_tree for displaying alv grid. i want to upload logo in the heade section. as we do in simple alvs using resuse_alv_commentary_write.
plz update me in this regard.
regards
venkatWelcome to SDN.
Check the following threads -
How To use TOP OF PAGE event in OOPS ALV?
Logo & TOP_OF_PAGE in OO ALV
Regards,
Amit
Reward all helpful replies. -
How to export alv into excel sheet without using toolbar button
hi,
i have developed ALV using FM methord on that i have created one button when user will click on that button
hole ALV should export in to excel as it is and that ALV is Heaving top of page contain also i want that shuld
also copy please help me for that please send me the sample code for that
Edited by: ankita khare on Nov 3, 2008 9:42 AMCheck this:
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:/test.xls'
filetype = 'ASC'
write_field_separator = 'X'
TABLES
data_tab = t_output
Regards. -
ALV GRID with n fields, using REUSE_ALV_GRID_DISPLAY and REUSE_ALV_FIELDCATALOG_MERGE to build the catalogue.
In some fields (not all) the system return message "No documentation available".
Note:
- The fields of the structure have standard data element with its own documentation.
- All the fields having this problem stay in an include structure (but other fields of other include structure have not it).
- I tried, after built the field catalogue to modify the ref_tabname, ref_fieldname (and ref_rollname too): no effect.
Someone have an idea on what's happening?
ThanksHi Umby:
I suggest to create structure into TCODE SE11, for example SPFLI_T is a structure that join some fileds of SCARR and SPFLI tables, you can see in Entry help/check the columns: Origin of the input help, Search help and Domain that where filled automatically due Component Type (Standard) that inherit it F1 characteristics.
Regards
José Luis
Edited by: Aguirre Eguiluz Jose Luis on Sep 23, 2010 10:19 AM -
List header for alv grid using abap objects
Hai all,
I have displayed alv grid in container control using abap objects i.e. using method set_table_for_first_display.
now i need to display list header for this alv grid.
please help me how to create with a sample coding.
Thanks and regards,
Prabu S.Create a splitter using CL_GUI_EASY_SPLITTER_CONTAINER with a top and bottom half. Put the alv grid in the bottom half. Use cl_dd_document (documented in help.sap.com ) to build the header in the top half. Use events on CL_GUI_ALV_GRID to handle the top-of-list printing.
Or, if available, use CL_SALV_TABLE, and read the documentation on that. When I needed a header for my report, that's what I did. There's plenty of good documentation about if you'll search for it.
matt -
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 -
Hi,
I am trying to use class CL_ALV_CHANGED_DATA_PROTOCOL to update a database table from an ALV grid.
I have used program BCALV_EDIT_04 as an example.
I am able to successfully processed inserted or deleted lines using the attributes
MT_DELETED_ROWS
MT_INSERTED_ROWS
but I also want to process modified lines.
I was just wondering whether anyone out there has some example code for this.
I can see that there are the following attributes available
MT_MOD_CELLS
MP_MOD_ROWS.
I would ideally like to use MP_MOD_ROWS rather than MT_MOD_CELLS but it is not clear to me what type MP_MOD_ROWS is.
If anyone has any example code for this sort of thing, please let me know.
Thanks,
Rubyhi Ruby,
Yes we can use that *data reference variable *.
It is a variable( something comparable to a pointer ) that points to a int table( table with changed contents )
which ll be created at run-time based on the data type ot the internal table that we pass to the parameter it_outtab of method set_table_for_first_display ...
assign er_data_changed->mp_mod_rows->* to a field-symbol and use it...
Check the below code for example -> method refresh_changed_data
screen flow logic.
PROCESS BEFORE OUTPUT.
MODULE pbo.
PROCESS AFTER INPUT.
MODULE pai.
main 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
TYPES tt_makt TYPE STANDARD TABLE OF makt.
DATA: go_handler TYPE REF TO lcl_event_responder,
go_grid TYPE REF TO cl_gui_alv_grid,
gt_fieldcat TYPE lvc_t_fcat,
gv_language TYPE spras VALUE 'E',
gt_outtab TYPE tt_makt,
gs_tableline TYPE LINE OF tt_makt.
FIELD-SYMBOLS : <changed_rows> TYPE tt_makt.
CALL SCREEN 100.
* 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.
LEAVE PROGRAM.
ENDMODULE. "pai INPUT
FORM create_and_init_alv CHANGING pt_outtab LIKE gt_outtab[]
pt_fieldcat TYPE lvc_t_fcat.
CHECK go_grid IS NOT BOUND.
CREATE OBJECT go_grid
EXPORTING
i_parent = cl_gui_container=>default_screen.
PERFORM build_display_table.
PERFORM build_fieldcat CHANGING pt_fieldcat.
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_enter ).
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.
ls_fcat-edit = abap_true.
MODIFY pt_fieldcat FROM ls_fcat.
ENDLOOP.
ENDFORM. "build_fieldcat
* CLASS event_responder IMPLEMENTATION *
CLASS lcl_event_responder IMPLEMENTATION.
METHOD refresh_changed_data.
ASSIGN er_data_changed->mp_mod_rows->* TO <changed_rows>.
LOOP AT <changed_rows> INTO gs_tableline.
BREAK-POINT.
ENDLOOP.
ENDMETHOD. "click
ENDCLASS. "event_responder IMPLEMENTATION
Cheers,
Jose. -
Error while downloading ALV grid o/p list into local file
Hello friends,
I have developed an ALV report and desplaying it using
'REUSE_ALV_GRID_DISPLAY, function module .While downloading the output list into excel format I am geeting an error "The current statement only supports character-type data objects.
Error Analysis-
In statement
"STRLEN( obj )..."
the argument "obj" can only take a character-type data object.
In this case, the operand "obj" has the non-character type "P".
I have set the import parameter i_save values as 'A'
But still not able to download and facing the same error.
Please help me out ....
Thanking you....
Regards,
Rajesh Akarte
Message was edited by:
Rajesh AkarteHi,
following is the dump code..Is there any problem due to date and currency fields..?
Error in ABAP application program.
The current ABAP program "SAPLKKBL " had to be terminated because one of the
statements could not be executed.
038350 endif.
038360 gs_out-hlplen = strlen( gs_out-hlpchar ).
038370 elseif gs_fc-tech_form = 11. "INS TECH
038380 * Min. Ausgabelänge für ein Datum ist immer 8
038390 if gs_fc-datatype = 'DATS'. "INS TECH
038400 gs_out-hlplen = 8. "INS TECH
038410 * Min. Ausgabelänge für eine Uhrzeit ist immer 6
038420 elseif gs_fc-datatype = 'TIMS'. "INS TECH
038430 gs_out-hlplen = 6. "INS TECH
038440 endif. "INS TECH
038450 elseif gs_fc-tech_form = 1 or gs_fc-tech_form = 90.
038460 * Überführung int. in ext. Format via Konvertierungsexit
038470 if not gs_fc-convexit is initial or "INS TECH
038480 not gs_fc-inttype ca 'CN'.
038490 * elseif not gs_fc-convexit is initial. "DEL TECH11
038500 write Y9CK034230 -
Displaying traffic lights in alv grid report?
Hi everyone,
I have an alv grid report.I m using the FM reuse_alv_grod_display to display my alv report.I am passing the fieldcatalogue automatically.I m getting the output perfectly.Now i have to add traffic lights to that alv report.
Since i m passing the fieldcatalogue automatically i m confused to display the traffic lights?
any suggestions please?
Thank you.hi dp,
look at the program i made... se the bold part you will be able to impelment lights easily,
DECLARING TYPES POOL *
All the definitions of internal tables, structures and constants
are declared in a type-pool called SLIS.
type-pools: slis.
TABLES *
tables: vbak,vbap,kna1.
TYPES *
*&--defining types for TABLE VBAK
types: begin of t_vbak,
vbeln type vbeln_va, "sales document
kunnr type kunag,
erdat type erdat,
auart type auart,
netwr type netwr_ak,
waerk type waerk,
vkorg type vkorg,
vtweg type vtweg,
spart type spart,
name1 type name1_gp,
stras type stras_gp,
ort01 type ort01_gp,
pstlz type pstlz,
regio type regio,
land1 type land1_gp,
telf1 type telf1,
end of t_vbak.
*&--Defining types for TABLE VBAP
types: begin of t_vbap,
vbeln type vbeln_va,
posnr type posnr_va,
matnr type matnr,
maktx type maktx,
end of t_vbap.
*&--MERGED FINAL SALES TABLE
types: begin of t_sales_final,
vbeln type vbeln_va,
kunnr type kunag,
posnr type posnr_va,
erdat type erdat, "date of creation
auart type auart,
netwr type netwr_ak,
waerk type waerk,
vkorg type vkorg,
vtweg type vtweg,
spart type spart,
name1 type name1_gp,
v_lights type c,
stras type stras_gp,
ort01 type ort01_gp,
pstlz type pstlz,
regio type regio,
land1 type land1_gp,
telf1 type telf1,
matnr type matnr,
maktx type maktx,
end of t_sales_final.
defining wrokarea and IT.
WORK AREA DECLARATION *
*&---work area for Internal Tables
data: wa_vbak type t_vbak.
data: wa_vbap type t_vbap.
data: wa_sales_final type t_sales_final.
*&--work area for layout
data: wa_layout type slis_layout_alv.
INTERNAL TABLES DECLARATION *
*&---Internal tables without Header Line.
data : i_vbak type standard table of t_vbak,
i_vbap type standard table of t_vbap,
i_sales_final type standard table of t_sales_final.
*&---Internal table for field catalog
data : i_fieldcat type slis_t_fieldcat_alv,
*&---Internal table for the sorting sequence.
i_sortinfo type slis_t_sortinfo_alv,
*&---Internal table for the event catalog.
i_eventcat type slis_t_event,
*&---Internal table for the top of page event
i_listheader type slis_t_listheader.
VARIABLE DECLARATION *
data : v_progname like sy-repid, "Program name(system defined)
v_gridtitle type lvc_title. "Grid Title
INITIALIZATION EVENT *
initialization.
v_progname = sy-repid.
refresh:i_vbak,
i_vbap,
i_sales_final,
i_fieldcat,
i_sortinfo,
i_eventcat,
i_listheader.
clear: wa_vbak,
wa_vbap,
wa_sales_final,
wa_layout.
SELECTION SCREEN *
SCREEN FOR ENTERING INFORMATION
selection-screen begin of block b1 with frame title text-001.
select-options: r_vbeln for wa_vbak-vbeln obligatory.
select-options: r_erdat for wa_vbak-erdat obligatory.
selection-screen end of block b1 .
AT SELECTION SCREEN *
at selection-screen.
perform zf_validate_sales_doc_no.
perform zf_validate_date.
START OF SELECTION EVENT
start-of-selection.
perform zf_populate_header.
perform zf_populate_detail.
perform zf_append_sales_final.
END OF SELECTION EVENT
end-of-selection.
*If Internal Table Is Populated Then Only Display Alv Report.
if i_sales_final is not initial.
Prepare fieldcatalog .
perform zf_build_fieldcat using i_fieldcat.
MODIFY the records IN the internal TABLE for the traffic lights.
perform zf_modify_final.
build event catalogue
perform zf_eventcat using i_eventcat.
build sorting
perform zf_sorting using i_sortinfo.
&---Build Listheader for TOP OF PAGE EVENT.
perform zf_build_listheader using i_listheader.
&---Build layout.
perform zf_layout.
&---Initializating Grid Title
perform zf_build_grid_title.
&---Display alv grid.
perform zf_display_alv_grid.
else.
*If Table is not Populated ie Records Does not exist
message 'Record Does Not Exist' type 'S'.
endif.
*& Form zf_validate_sales_doc_no
text
--> p1 text
<-- p2 text
form zf_validate_sales_doc_no .
select single vbeln into wa_vbak-vbeln from vbak where vbeln in r_vbeln .
if sy-subrc <> 0.
message i101.
endif.
endform. " zf_validate_sales_doc_no
*& Form zf_validate_date
text
--> p1 text
<-- p2 text
form zf_validate_date .
if date is future
if r_erdat-low >= sy-datum.
message e102.
elseif r_erdat-high >= sy-datum.
message e103.
endif.
endform. " zf_validate_date
*& Form zf_populate_header
text
--> p1 text
<-- p2 text
form zf_populate_header .
select vbeln
kunnr
erdat
auart
netwr
waerk
vkorg
vtweg
spart
into table i_vbak from vbak where vbeln in r_vbeln.
if sy-subrc <> 0.
message 'RECORD DOES NOT EXIST' type 'E'.
endif.
sort i_vbak by vbeln.
*&--LOGIC TO GET FIELDS FROM TABLE KNA1 INTO INTERNAL TABLE I_VBAK
loop at i_vbak into wa_vbak.
select single name1 stras ort01 pstlz regio land1 telf1 into (wa_vbak-name1,
wa_vbak-stras,
wa_vbak-ort01,
wa_vbak-pstlz,
wa_vbak-regio,
wa_vbak-land1,
wa_vbak-telf1)
from kna1
where kunnr = wa_vbak-kunnr.
modifying it_header.
modify i_vbak from wa_vbak.
clear wa_vbak.
endloop.
endform. " zf_populate_header
*& Form zf_populate_detail
text
--> p1 text
<-- p2 text
form zf_populate_detail .
if i_vbak[] is not initial.
select vbeln
posnr
matnr
into table i_vbap from vbap
for all entries in i_vbak where vbeln = i_vbak-vbeln.
endif.
sort i_vbap by vbeln.
sort i_vbap by posnr.
*&--LOGIC TO GET FIELDS FROM TABLE MAKT INTO INTERNAL TABLE I_VBAP
loop at i_vbap into wa_vbap.
select single maktx into (wa_vbap-maktx)
from makt where matnr = wa_vbap-matnr and spras = sy-langu.
modifying it_header.
modify i_vbap from wa_vbap.
clear wa_vbap.
endloop.
endform. " zf_populate_detail
*& Form zf_append_sales_final
text
--> p1 text
<-- p2 text
form zf_append_sales_final .
sort i_vbak by vbeln.
sort i_vbap by vbeln posnr.
loop at i_vbak into wa_vbak.
move-corresponding wa_vbak to wa_sales_final.
read table i_vbap with key vbeln = wa_vbak-vbeln
binary search transporting no fields.
loop at i_vbap into wa_vbap from sy-tabix.
if wa_vbap-vbeln <> wa_vbak-vbeln.
exit.
endif.
move-corresponding wa_vbap to wa_sales_final.
append wa_sales_final to i_sales_final.
endloop.
endloop.
endform. " zf_append_sales_final
*& Form zf_build_fieldcat
text
-->P_I_FIELDCAT text
form zf_build_fieldcat using p_i_fieldcat type slis_t_fieldcat_alv.
data: l_fieldcat type slis_fieldcat_alv. "local Workarea used
clear l_fieldcat.
FOR LIGHT IN COLUMN
clear l_fieldcat.
l_fieldcat-col_pos = '1'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'V_LIGHTS'.
" FIELD FOR WHICH CATALOG ID FILLED.
*We are passing final internal table 'I_FINAL' to l_fieldcat(local
*variable
l_fieldcat-tabname = 'I_SALES_FINAL'.
" INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-just = 'C'. " FOR JUSTIFICATION.
l_fieldcat-outputlen = 20.
" TO DEFINE OUTPUT LENGTH OF THE COLUMN.
append l_fieldcat to p_i_fieldcat.
FIRST COLUMN ********************************
l_fieldcat-col_pos = '2'. " POSITION OF THE COLUMN
l_fieldcat-fieldname = 'VBELN'. " FIELD FOR WHICH CATALOG ID FILLED
l_fieldcat-tabname = 'I_SALES_FINAL'. " INTERNAL TABLE BELONGS TO
l_fieldcat-key = 'X'. " SO THAT this field is not scrollable hiddable.
l_fieldcat-just = 'L'. " FOR JUSTIFICATION
*l_fieldcat-hotspot = 'X'. " MARK THIS field as hotsopt
l_fieldcat-lzero = 'X'. " OUTPUT WITH leading zeros.
l_fieldcat-seltext_l = 'Sales Document'. " long text for header.
l_fieldcat-seltext_m = 'Sales Doc'. " medium text for header.
l_fieldcat-seltext_s = 'Sales Doc'. " sort text for header.
l_fieldcat-outputlen = 20. " SET THE output length.
l_fieldcat-ref_tabname = 'VBAK'. " FOR F1 & F4 help as
append l_fieldcat to p_i_fieldcat.
clear l_fieldcat.
**************************SECOND COLUMN ********************************
*l_fieldcat-col_pos = '3'. " POSITION OF THE COLUMN
l_fieldcat-row_pos = '2'. " POSITION OF THE COLUMN
l_fieldcat-fieldname = 'POSNR'. " FIELD FOR WHICH CATALOG ID FILLED
l_fieldcat-tabname = 'I_SALES_FINAL'. " INTERNAL TABLE BELONGS TO
l_fieldcat-key = 'X'. " SO THAT this field is not scrollable hiddable.
l_fieldcat-just = 'L'. " FOR JUSTIFICATION
l_fieldcat-hotspot = 'X'. " MARK THIS field as hotsopt
l_fieldcat-lzero = 'x'. " OUTPUT WITH leading zeros.
l_fieldcat-seltext_l = 'Sales Document Item'. " long text for header.
l_fieldcat-seltext_m = 'Sales Document Item'. " medium text for header.
l_fieldcat-seltext_s = 'Sales Document Item'. " sort text for header.
l_fieldcat-outputlen = 20. " SET THE output length.
l_fieldcat-ref_tabname = 'VBAP'. " FOR F1 & F4 help as
append l_fieldcat to p_i_fieldcat.
clear l_fieldcat.
endform. " zf_build_fieldcat
*& Form zf_eventcat
text
-->P_I_EVENTCAT text
form zf_eventcat using p_i_eventcat type slis_t_event.
data: l_eventcat type slis_alv_event.
clear l_eventcat.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_i_eventcat
exceptions
list_type_wrong = 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.
TOP OF PAGE FORM
clear l_eventcat.
read table p_i_eventcat into l_eventcat with key
name = slis_ev_top_of_page.
"(COMPONENT "NAME"of structure)
if sy-subrc = 0. "if success
move 'ZF_TOP_OF_PAGE' to l_eventcat-form.
"matches name and moves form to workarea and modifies table
modify p_i_eventcat from l_eventcat index sy-tabix
transporting form.
endif.
PF_STATUS_SET FORM
clear l_eventcat.
read table p_i_eventcat into l_eventcat with key
name = slis_ev_pf_status_set.
if sy-subrc = 0.
move 'ZF_PF_STATUS_SET' to l_eventcat-form.
modify p_i_eventcat from l_eventcat index sy-tabix
transporting form.
endif.
USER_COMMAND FORM
clear l_eventcat.
read table p_i_eventcat into l_eventcat with key
name = slis_ev_user_command.
if sy-subrc = 0.
move 'ZF_USER_COMMAND' to l_eventcat-form.
modify p_i_eventcat from l_eventcat index sy-tabix
transporting form.
endif.
endform. " zf_eventcat
*& Form zf_sorting
text
-->P_I_SORTINFO text
form zf_sorting using p_i_sortinfo.
endform. " zf_sorting
*& Form zf_build_listheader
text
-->P_I_LISTHEADER text
form zf_build_listheader using p_i_listheader type slis_t_listheader.
data: l_listheader type slis_listheader.
refresh p_i_listheader.
clear l_listheader.
HEADER
l_listheader-typ = 'H'.
l_listheader-info = 'FUJITSU CONSULTING INDIA LTD.'.
append l_listheader to p_i_listheader.
SELECTION
l_listheader-typ = 'S'.
l_listheader-key = 'Date:'.
l_listheader-info = sy-datum.
append l_listheader to p_i_listheader.
ACTION
l_listheader-typ = 'A'.
*l_listheader-key =
l_listheader-info = 'SALES ORDER ALV REPORT By Rohan Malik'.
append l_listheader to p_i_listheader.
endform. " zf_build_listheader
*& Form zf_build_grid_title
text
--> p1 text
<-- p2 text
form zf_build_grid_title .
v_gridtitle = 'List of Purchase Order'.
endform. " zf_build_grid_title
*& Form zf_display_alv_grid
text
--> p1 text
<-- p2 text
form zf_display_alv_grid .
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = v_progname
i_grid_title = v_gridtitle
is_layout = wa_layout
it_fieldcat = i_fieldcat
it_sort = i_sortinfo
it_events = i_eventcat
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = i_sales_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. " zf_display_alv_grid
*& Form zf_top_of_page
text
--> p1 text
<-- p2 text
form zf_top_of_page .
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = i_listheader
i_logo = 'ENJOYSAP_LOGO'
I_END_OF_LIST_GRID =
endform. " zf_top_of_page
*& Form zf_user_command
text
--> p1 text
<-- p2 text
form zf_user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield .
case r_ucomm. "FCODE
when 'VA03'.
read table i_sales_final into wa_sales_final index rs_selfield-tabindex.
set parameter id 'AUN' field rs_selfield-value.
call transaction 'VA03' and skip first screen .
message i102 with rs_selfield-value .
when '&IC1'. "for hotspot with VBELN, POSNR, MATNR, KUNNR.
if rs_selfield-fieldname = 'MATNR'.
set parameter id 'MAT' field rs_selfield-value.
call transaction 'MM03' and skip first screen.
return.
message i103 with rs_selfield-value .
endif.
if rs_selfield-fieldname = 'VBELN'.
set parameter id 'AUN' field rs_selfield-value.
call transaction 'VA03' and skip first screen.
return.
message i104 with rs_selfield-value .
endif.
endcase.
endform. " zf_user_command
*& Form ZF_PF_STATUS_SET
text
--> p1 text
<-- p2 text
form zf_pf_status_set using rt_extab type slis_t_extab.
set pf-status 'Z11_RM_ALV_SO'.
endform. " ZF_PF_STATUS_SET
*& Form zf_layout
text
--> p1 text
<-- p2 text
form zf_layout .
wa_layout-zebra = 'X'.
wa_layout-lights_fieldname = 'V_LIGHTS'.
wa_layout-lights_tabname = 'I_SALES_FINAL'.
" 1, 2 or 3 for red, yellow and green respectively.
endform. " zf_layout
*& Form zf_modify_final
text
--> p1 text
<-- p2 text
form zf_modify_final .
CODE TO EXECUTE LIGHTS
*start of loop
loop at i_sales_final into wa_sales_final.
*giving conditions and modifying as we want to change many rows
if wa_sales_final-netwr <= 10000.
wa_sales_final-v_lights = '1'.
modify i_sales_final from wa_sales_final transporting v_lights.
elseif wa_sales_final-netwr > 10000 and wa_sales_final-netwr <= 100000.
wa_sales_final-v_lights = '2'. " Exception.
modify i_sales_final from wa_sales_final transporting v_lights.
else.
wa_sales_final-v_lights = '3'. " Exception.
modify i_sales_final from wa_sales_final transporting v_lights.
endif.
endloop.
reward point s if helpful
rohan malik -
hi experts,
how can i insert logo in alv grid..can u send me some examples of alv that includes all the functionalities like user-command,commentary write n also logo insertion etc..
regards,
ramanhi ,
chk out this .....and try this ..
for getting the events ....
FORM ZVRPSALV_EVENT_CAT CHANGING RT_EVENT TYPE slis_t_event .
DATA : s_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = RT_EVENT
EXCEPTIONS
list_type_wrong = 1
OTHERS = 2.
CASE sy-subrc.
WHEN 1.
MESSAGE s000 WITH 'List type does not exist'(058).
LEAVE LIST-PROCESSING.
WHEN 2.
MESSAGE s000 WITH 'Error with List Type'(059).
LEAVE LIST-PROCESSING.
ENDCASE.
READ TABLE RT_EVENT WITH KEY NAME = slis_ev_top_of_page INTO s_event .
IF sy-subrc = 0.
MOVE 'TOP_OF_PAGE'(056) TO s_event-form.
APPEND s_event TO rt_event.
CLEAR s_event.
ENDIF.
ENDFORM. " EVENT_CAT
*& Form ZVRPSALV_GRIDDISPLAY1
text
--> p1 text
<-- p2 text
FORM ZVRPSALV_GRIDDISPLAY1 .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'DISPLAY_DOCUMENT '
I_CALLBACK_TOP_OF_PAGE = ' TOP-OF-PAGE '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'BASIC LIST'
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = T_FCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = RT_EVENT
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
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 = T_ITAB
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. " ZVRPSALV_GRIDDISPLAY1
SUBROTINE FOR DISPLAYING THE SECONDRY ALV GRID.
FORM DISPLAY_DOCUMENT USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
IF RS_SELFIELD-FIELDNAME = 'VBELN'.
READ TABLE T_ITAB INDEX RS_SELFIELD-TABINDEX .
V_VBELN = T_ITAB-VBELN.
LOOP AT T_ITAB WHERE VBELN = V_VBELN.
Move: T_ITAB-POSNR to T_ITAB1-POSNR ,
T_ITAB-MATNR to T_ITAB1-MATNR ,
T_ITAB-MATKL to T_ITAB1-MATKL,
T_ITAB-ARKTX to T_ITAB1-ARKTX ,
T_ITAB-PSTYV to T_ITAB1-PSTYV ,
T_ITAB-SPART to T_ITAB1-SPART ,
T_ITAB-GSBER to T_ITAB1-GSBER ,
T_ITAB-KWMENG to T_ITAB1-KWMENG .
Append T_ITAB1.
ENDLOOP.
ENDIF.
*& Form ZVRPSALV_COMMENT
text
-->P_T_HEADER text
FORM ZVRPSALV_COMMENT USING P_T_HEADER type slis_t_listheader .
DATA : LS_LINE TYPE SLIS_LISTHEADER.
CLEAR LS_LINE .
LS_LINE-TYP = 'H'.
LS_LINE-INFO = 'HEADING LIST'.
APPEND LS_LINE TO P_T_HEADER.
CLEAR LS_LINE.
LS_LINE-typ = 'S'.
write sy-datum to LS_LINE-info MM/DD/YYYY.
CONCATENATE text-041 LS_LINE-info INTO LS_LINE-info separated by space .
APPEND LS_LINE TO P_T_HEADER.
ENDFORM. " ZVRPSALV_COMMENT
SUBROUINE FOR TOP OF PAGE.
FORM TOP_OF_PAGE.
clear t_header.
DATA: LV_HEADER TYPE SLIS_LISTHEADER.
LV_HEADER-TYP = 'S'.
WRITE SY-DATUM TO LV_HEADER-INFO MM/DD/YYYY.
CONCATENATE TEXT-041 LV_HEADER-INFO INTO LV_HEADER-INFO SEPARATED BY SPACE.
APPEND LV_HEADER TO T_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER
I_LOGO = ' ENJOYSAP_LOGO '
I_END_OF_LIST_GRID =
I_ALV_FORM =
ENDFORM.
*& Form ZVRPSALV_EVENTTAB
text
<--P_T_EVENT text
FORM ZVRPSALV_EVENTTAB CHANGING P_T_EVENT TYPE SLIS_T_EVENT.
DATA : LS_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = P_T_EVENT.
SEARCH THE TOP OF PAGE EVENT.
READ TABLE P_T_EVENT WITH KEY NAME = SLIS_EV_TOP_OF_PAGE INTO LS_EVENT .
IF SY-SUBRC = 0 .
MOVE 'TOP_OF_PAGE' TO LS_EVENT-FORM.
APPEND LS_EVENT TO P_T_EVENT.
ENDIF.
ENDFORM. " ZVRPSALV_EVENTTAB
thanks and regards
Priyank Dixit
Maybe you are looking for
-
Connecting new TV to Macbook: which adapter do I need?
I have a Macbook White Intel Core 2 Duo 2 Ghz. I am trying to connect it to my new Sanyo DP19640 TV to stream Netflix. I cannot seem to determine which adapter I need.
-
SCCM Inventory + WMI Classes
Hi, I have received a below request from my client, and due to my lack of knowledge i am unable to answer this query. Kindly guide me to right direction. Can you please confirm which of the following inventory data we are capturing in SCCM? Note tha
-
My app install is stuck on Finishing...
My whole Creative Cloud desktop app does not appear to be working. I can open the app, but I tried to update Photoshop CC (2014) about a week ago and the progress indicator stalled at 85%. Today I decided to "x" out of it. Now it has said "Finishing.
-
Retrieve imported and validated Entities for further ESSBASE calc Script
Hi folks, once the FDM processing is finished: The Event Script AftConsolidate is executed. It is retrieving all unique Entity entries (trialbalance command), Period (POV), Scenario (POV) etc. and is bulding a dynamic ESSBAE calc script command which
-
How do you burn a slideshow to a DVD that will play on DVD players and PC computers?
I burned a slideshow in Aperture onto a DVD containing about 40 photos with a sound track from iTunes. The disk will play on my iMac but not on my wife's PC or on two of our DVD players (less than three years old.). What am I missing in the burning