BalanceSheet ALV to ALV grid
Hiii experts..
I have created one report program similar to RFBILA00 standard program...
now all the information is present in my internal table IT... now what I want to create a ALV tree similar to the output of the this standard program when ALV grid tree control is selected...
can any1 help me...
thanks in advance..
Hi,
Please refer the program "BCALV_TREE_02".
Hope this might help you to solve your problem.
With Regards,
Sumodh.p
Similar Messages
-
To change the colour of the particular cell of ALV report in Grid display.
Hai Friends,
I have created an Alv report in grid display .In that i want to change the colour of the particular cell.Plz provide the answer with a solved example.
Thank u.This works for a Custom Control and OO ALV in a Dialog Module
TABLES: kna1.
* Data (for the ALV Grid)
TYPES:
BEGIN OF t_alv_data,
cust_id TYPE kunnr, "Customer Number
cust_name TYPE name1_gp, "Customer Name
cust_color TYPE i,
* cell coloring field
color TYPE lvc_t_scol, "Cell coloring
END OF t_alv_data.
DATA:
v_alv_data TYPE t_alv_data,
i_alv_data TYPE STANDARD TABLE OF t_alv_data.
* ALV grid containers and objects
DATA:
o_alv_grid TYPE REF TO cl_gui_alv_grid,
o_alv_cont TYPE REF TO cl_gui_custom_container.
* ALV field catalog
DATA:
i_alv_fc TYPE lvc_t_fcat,
v_alv_fc LIKE lvc_s_fcat.
* ALV Layout (colors)
DATA:
v_alv_layout TYPE lvc_s_layo,
i_alv_color TYPE lvc_t_scol,
v_alv_color TYPE lvc_s_scol,
v_alv_color_cell TYPE lvc_s_colo.
* ALV variant
DATA:
v_alv_variant TYPE disvariant.
PARAMETERS:
p_alvvar TYPE disvariant-variant DEFAULT 'DEFAULT'.
DATA: ok_code LIKE sy-ucomm.
* Class for event handling
* CLASS lcl_event_receiver DEFINITION
* [+] Event listener for the ALV grid
* [+] Handles hotspots and data changes
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
* Hotspot clicking
hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id
e_column_id
es_row_no,
* Data changed (such as checkbox clicking)
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
ENDCLASS. "lcl_event_receiver DEFINITION
* CLASS lcl_event_receiver IMPLEMENTATION
* [+] Implementation of the ALV Grid event handler class
CLASS lcl_event_receiver IMPLEMENTATION.
* METHOD hotspot_click *
* [+] Calls evvent_hotspot_click when a hotspot is clicked in the ALV
METHOD hotspot_click.
PERFORM event_hotspot_click
USING e_row_id
e_column_id.
ENDMETHOD. "hotspot_click
* METHOD handle_data_changed *
* [+] Updates the source data when the data in the ALV display has
* been changed, such as by clicking a checkbox.
METHOD handle_data_changed.
DATA: lv_changed TYPE lvc_s_modi.
LOOP AT er_data_changed->mt_good_cells INTO lv_changed
WHERE fieldname = 'CUST_NAME'.
READ TABLE i_alv_data INTO v_alv_data INDEX lv_changed-row_id.
IF sy-subrc = 0.
MOVE lv_changed-value TO v_alv_data-cust_name.
MODIFY i_alv_data FROM v_alv_data INDEX lv_changed-row_id.
ENDIF.
ENDLOOP.
ENDMETHOD. "handle_data_changed
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
* Reference to the event listener class
DATA: event_receiver TYPE REF TO lcl_event_receiver.
* FORM build_event_listener
* [+] Set the event handler on the ALV Grid
FORM build_event_listener.
* Assigning the event listener to the ALV
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_data_changed FOR o_alv_grid.
SET HANDLER event_receiver->hotspot_click FOR o_alv_grid.
ENDFORM. "build_event_listener
* AT SELECTION-SCREEN
* ON VALUE-REQUEST FOR p_alvvar
* [+] Calls choose_alv_variant to ask the user to select an alv grid
* layout variant
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_alvvar.
PERFORM choose_alv_variant
CHANGING
p_alvvar
v_alv_variant.
* START_OF_SELECTION
START-OF-SELECTION.
PERFORM get_data.
SET PF-STATUS 'ALVSCREEN' IMMEDIATELY.
CALL SCREEN 2000.
* FORM get_data
* [+] Gets the data for the ALV grid
FORM get_data.
SELECT kunnr name1
INTO (v_alv_data-cust_id,
v_alv_data-cust_name)
FROM kna1.
APPEND v_alv_data TO i_alv_data.
ENDSELECT.
ENDFORM. "get_data
* MODULE build_alv_grid
* THIS SHOULD BE IN THE "PROCESS BEFORE OUTPUT" OF THE ALV SCREEN
* [+] Builds the ALV Grid objects
* [+] Calls to build the field catalog table
* [+] Loads the field catalog table into the ALV Grid
* [+] Loads the table data into the ALV Grid
MODULE build_alv_grid OUTPUT.
SET TITLEBAR '2000'.
* Also enables layout saving
PERFORM set_alv_variant
USING
p_alvvar
CHANGING
v_alv_variant.
* Building the grid and container on the screen
* NOTE: the container name MUST be upper-case
* Also, we don't want the objects to be created if in batch mode!
IF sy-batch IS INITIAL.
CREATE OBJECT o_alv_cont
EXPORTING
container_name = 'O_ALV_TABLE'.
ENDIF.
CREATE OBJECT o_alv_grid
EXPORTING
i_parent = o_alv_cont.
* builds the event listener
PERFORM build_event_listener.
* Color the cells
PERFORM color_cells.
* Build the field catalog
PERFORM build_alv_fc.
* Loads the data into the grid
CALL METHOD o_alv_grid->set_table_for_first_display
EXPORTING
i_save = 'A'
i_default = 'X'
is_variant = v_alv_variant
is_layout = v_alv_layout
CHANGING
it_outtab = i_alv_data
it_fieldcatalog = i_alv_fc.
ENDMODULE. "build_alv_grid OUTPUT
* FORM build_alv_fc
* [+] Constructs the ALV Grid field catalog table
FORM build_alv_fc.
CLEAR i_alv_fc.
REFRESH i_alv_fc.
* NOTE: the field name MUST be upper-case
* field heading hide hot
* name zero spot just
PERFORM:
alv_field USING 'CUST_ID' 'Cust ID' ' ' 'X' 'R',
alv_field USING 'CUST_NAME' 'Customer Name' ' ' ' ' 'L',
alv_field USING 'CUST_COLOR' 'Color' ' ' ' ' 'R'.
ENDFORM. "build_alv_fc
* FORM alv_field
* [+] Describes and constructs a single field for the ALV Grid field
* catalog. The field length and type are both obtained from the
* actual field passed in to this method.
* [+] Adds the constructed field to the ALV Grid field catalog table
FORM alv_field
USING
p_field_name TYPE c
p_heading TYPE c
p_hide_zeros TYPE c
p_hotspot TYPE c
p_justify TYPE c.
CLEAR v_alv_fc.
DATA:
lv_type(1) TYPE c,
lv_length TYPE i,
lv_heading_length TYPE i.
* get the type and length of this field
FIELD-SYMBOLS <field>.
ASSIGN p_field_name TO <field>.
DESCRIBE FIELD <field> TYPE lv_type OUTPUT-LENGTH lv_length.
* re-adjust the length to the length of the header, if too short
lv_heading_length = strlen( p_heading ).
IF lv_length < lv_heading_length.
lv_length = lv_heading_length.
ENDIF.
* NOTE: the field name MUST be upper-case
v_alv_fc-fieldname = p_field_name.
TRANSLATE v_alv_fc-fieldname TO UPPER CASE.
v_alv_fc-inttype = lv_type.
v_alv_fc-outputlen = lv_length.
v_alv_fc-coltext = p_heading.
v_alv_fc-seltext = p_heading.
v_alv_fc-hotspot = p_hotspot.
* Determining which fields should show zeros
IF p_hide_zeros = 'X'.
v_alv_fc-no_zero = 'X'.
v_alv_fc-lzero = ' '.
ELSE.
v_alv_fc-no_zero = ' '.
v_alv_fc-lzero = 'X'.
ENDIF.
v_alv_fc-just = p_justify.
* Add the field to the field catalog
APPEND v_alv_fc TO i_alv_fc.
ENDFORM. "alv_field
* FORM choose_alv_variant
* [+] Shows a popup that allows the user to choose the layout variant
* for the alv grid of the current program
* [+] Usually called by an AT SELECTION-SCREEN method.
FORM choose_alv_variant
CHANGING
p_variant_name TYPE disvariant-variant
p_variant TYPE disvariant.
CLEAR p_variant.
DATA:
p_exit_check(1) TYPE c.
MOVE sy-repid TO p_variant-report.
CALL FUNCTION 'LVC_VARIANT_F4'
EXPORTING
is_variant = p_variant
i_save = 'A'
IMPORTING
e_exit = p_exit_check
es_variant = p_variant
EXCEPTIONS
not_found = 1
OTHERS = 99.
IF sy-subrc = 0.
IF p_exit_check <> 'X'.
p_variant_name = p_variant-variant.
ENDIF.
ENDIF.
ENDFORM. "choose_alv_variant
* FORM set_alv_variant
* [+] Sets the alv grid layout variant. Used for setting the variant
* when its name is entered in a parameter rather than by using the
* popup, or when loading the variant from a variable of type C
FORM set_alv_variant
USING
p_variant_name TYPE disvariant-variant
CHANGING
p_variant TYPE disvariant.
MOVE sy-repid TO p_variant-report.
p_variant-variant = p_variant_name.
ENDFORM. "set_alv_variant
* FORM color_cells
* [+] Loop through the data and apply coloring
FORM color_cells.
DATA:
my_color TYPE i.
* tell the ALV grid what field in v_alv_data contains color information
v_alv_layout-ctab_fname = 'COLOR'.
my_color = 0.
* loop through each row of the table
LOOP AT i_alv_data INTO v_alv_data.
* clear the variables
CLEAR:
v_alv_color,
v_alv_color_cell,
i_alv_color.
REFRESH:
i_alv_color.
v_alv_data-cust_color = my_color.
PERFORM color_cell USING 'CUST_COLOR' my_color. "negative
* apply the colors
* IF v_alv_data-cust_name = 'Testing Credit'.
* PERFORM color_cell USING 'CUST_NAME' 6. "negative
* ELSEIF v_alv_data-cust_name = 'Goober Goober Also'.
* PERFORM color_cell USING 'CUST_NAME' 5. "positive
* ENDIF.
* set the color data for this table row
v_alv_data-color = i_alv_color.
MODIFY i_alv_data FROM v_alv_data.
my_color = my_color + 1.
IF my_color GT 7.
CLEAR my_color.
ENDIF.
ENDLOOP.
ENDFORM. "color_cells
* FORM color_cell
* [+] Colors a cell in the ALV grid
FORM color_cell
USING
p_cellname TYPE c
p_color TYPE i.
CLEAR:
v_alv_color_cell,
v_alv_color.
* set the color for the cell
* IF p_color = 0.
* v_alv_color_cell-col = 0. "cl_gui_resources=>list_col_background.
* ELSEIF p_color = 1.
* v_alv_color_cell-col = 1. "cl_gui_resources=>list_col_heading.
* ELSEIF p_color = 2.
* v_alv_color_cell-col = 2. "cl_gui_resources=>list_col_normal.
* ELSEIF p_color = 3.
* v_alv_color_cell-col = 3. "cl_gui_resources=>list_col_total.
* ELSEIF p_color = 4.
* v_alv_color_cell-col = 4. "cl_gui_resources=>list_col_key.
* ELSEIF p_color = 5.
* v_alv_color_cell-col = 5. "cl_gui_resources=>list_col_positive.
* ELSEIF p_color = 6.
* v_alv_color_cell-col = 6. "cl_gui_resources=>list_col_negative.
* ELSEIF p_color = 7.
* v_alv_color_cell-col = 7. "cl_gui_resources=>list_col_group.
* ENDIF.
v_alv_color_cell-col = p_color.
v_alv_color-nokeycol = 'X'.
v_alv_color-fname = p_cellname.
* v_alv_color-color = p_color.
v_alv_color-color = v_alv_color_cell.
APPEND v_alv_color TO i_alv_color.
ENDFORM. "color_cell
* FORM event_hotspot_click
* [+] What to do when clicking on a hotspot in the ALV Grid
FORM event_hotspot_click
USING
p_row TYPE lvc_s_row
p_column TYPE lvc_s_col.
DATA:
lv_docnum TYPE kunnr.
READ TABLE i_alv_data INTO v_alv_data INDEX p_row-index.
IF p_column = 'CUST_ID'.
* call a transaction when the cust_id is clicked
SET PARAMETER ID 'AUN' FIELD v_alv_data-cust_id.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
ENDIF.
ENDFORM. "event_hotspot_click
*& Module USER_COMMAND_2000 INPUT
* text
MODULE user_command_2000 INPUT.
CASE ok_code.
WHEN 'BACK'
OR 'STOP'
OR 'CANCEL'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_2000 INPUT -
ALV like LIST GRID BLOCKED and HIRARCHIC using oops class SALV
Hi ,
Can any one let know me is it possible to display all the Flavours of ALV like LIST GRID BLOCKED and HIRARCHICAL
using oops class CL_GUI_ALV and class CL_SALV.
and the relevant events with respect to the type of ALV.
regardsHello
Have you had a look at the documents of Rich Heilman:
[ALV Object Model - Simple 2D Table - Event Handling|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cda3992d-0e01-0010-90b2-c4e1f899ac01]
[ALV Object Model - Hierarchical Sequential List - The Basics|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b0f03986-046c-2910-a5aa-e5364e96ea2c]
[ALV Object Model - Simple 2D Table - The Basics|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/eac1fa0b-0e01-0010-0990-8530de4908a6]
Regards
Uwe -
To make different colours for the columns of ALV report in Grid display.
Hai Friends,
I have created an ALV report in grid display method by using the call function reuse_alv_grid_display.
I have obtained the report.In that report i want to change the colour of each column.Plz provide the answer with a sample program.
Thank u.hi i had a program for the rows with diff colors....do the same thing for the columns..
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,
line_color(4) type c, "Used to store row color attributes
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.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = '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-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).
Set layout field for row attributes(i.e. color)
gd_layout-info_fieldname = 'LINE_COLOR'.
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
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
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.
data: ld_color(1) type c.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into table it_ekko.
*Populate field with color attributes
loop at it_ekko into wa_ekko.
ld_color = ld_color + 1.
Only 7 colours so need to reset color value
if ld_color = 8.
ld_color = 1.
endif.
concatenate 'C' ld_color '10' into wa_ekko-line_color.
wa_ekko-line_color = 'C410'.
modify it_ekko from wa_ekko.
endloop.
endform. " DATA_RETRIEVAL
regards,
venkat -
How to catch changed column values in alv oops using grid
My requirement needs to catch changed column values in alv oops using grid .any method to do this.
please help me out ,
Tks in advanceHave a look into the SAP standarad Programs those programs have the edit option on the ALV output.
BCALV_EDIT_01
BCALV_EDIT_02
BCALV_EDIT_10.
Regards,
Gopi ,
Reward points if helpfull. -
Difference between alv & oops alv
please anybody know the difference between alv & oops alv
Edited by: prahlad sahu on Dec 18, 2007 5:47 AMplease anybody know the difference between alv & oops alv
Edited by: prahlad sahu on Dec 18, 2007 5:47 AM -
Switching between Hierarchical ALV and List/Grid ALV
Hello!
I was checking out the List of GR/IR Balances report (tcode MB5S), which uses Hierarchical ALV. I noticed that there's a button in the output toolbar that enables you to switch from Hierarchical ALV to Grid ALV. Is there a specific setting in the ALV that you need to define in order to use this feature?
Thanks in advance.Hi,
there is no need of any specific settings.
those properties will came when u use the related function module.all the code for this will exist in the function module u r using for creating the hierarchial display.
regards,
bharat. -
i want some example alv grid report example
Hi Raghu,
Check this out.
sample report for interactive report for purchase order.
REPORT YMS_ALVINTERSAMPLE NO STANDARD PAGE HEADING LINE-SIZE 650
MESSAGE-ID ZZ_9838.
TYPE-POOLS: SLIS.
*type declaration for values from ekko
TYPES: BEGIN OF I_EKKO,
EBELN LIKE EKKO-EBELN,
AEDAT LIKE EKKO-AEDAT,
BUKRS LIKE EKKO-BUKRS,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
END OF I_EKKO.
DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
WA_EKKO TYPE I_EKKO.
*type declaration for values from ekpo
TYPES: BEGIN OF I_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MATNR LIKE EKPO-MATNR,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
END OF I_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
WA_EKPO TYPE I_EKPO .
*variable for Report ID
DATA: V_REPID LIKE SY-REPID .
*declaration for fieldcatalog
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
declaration for events table where user comand or set PF status will
be defined
DATA: V_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.
declartion for layout
DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
declaration for variant(type of display we want)
DATA: I_VARIANT TYPE DISVARIANT,
I_VARIANT1 TYPE DISVARIANT,
I_SAVE(1) TYPE C.
*PARAMETERS : p_var TYPE disvariant-variant.
*Title displayed when the alv list is displayed
DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.
INITIALIZATION.
V_REPID = SY-REPID.
PERFORM BUILD_FIELDCATLOG.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_REPORT.
*& Form BUILD_FIELDCATLOG
Fieldcatalog has all the field details from ekko
FORM BUILD_FIELDCATLOG.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'AEDAT'.
WA_FIELDCAT-SELTEXT_M = 'DATE.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'LIFNR'.
WA_FIELDCAT-NO_OUT = 'X'.
WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG
*& Form EVENT_CALL
we get all events - TOP OF PAGE or USER COMMAND in table v_events
FORM EVENT_CALL.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
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.
ENDFORM. "EVENT_CALL
*& Form POPULATE_EVENT
Events populated for TOP OF PAGE & USER COMAND
FORM POPULATE_EVENT.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'USER_COMMAND'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
ENDIF.
ENDFORM. "POPULATE_EVENT
*& Form data_retrieval
retreiving values from the database table ekko
FORM DATA_RETRIEVAL.
SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
ENDFORM. "data_retrieval
*& Form bUild_listheader
text
-->I_LISTHEADEtext
FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA HLINE TYPE SLIS_LISTHEADER.
HLINE-INFO = 'this is my first alv pgm'.
HLINE-TYP = 'H'.
ENDFORM. "build_listheader
*& Form display_alv_report
text
FORM DISPLAY_ALV_REPORT.
V_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = I_TITLE_EKKO
I_GRID_SETTINGS =
IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
i_default = 'ZLAY1'
I_SAVE = 'A'
is_variant = i_variant
IT_EVENTS = V_EVENTS
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 TOP_OF_PAGE
text
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
ENDFORM. "TOP_OF_PAGE
*& Form USER_COMMAND
text
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
PERFORM BUILD_FIELDCATLOG_EKPO.
PERFORM EVENT_CALL_EKPO.
PERFORM POPULATE_EVENT_EKPO.
PERFORM DATA_RETRIEVAL_EKPO.
PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_EKPO.
ENDCASE.
ENDFORM. "user_command
*& Form BUILD_FIELDCATLOG_EKPO
text
FORM BUILD_FIELDCATLOG_EKPO.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELP'.
WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MENGE'.
WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'UOM'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'NETPR'.
WA_FIELDCAT-SELTEXT_M = 'PRICE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG_EKPO
*& Form event_call_ekpo
we get all events - TOP OF PAGE or USER COMMAND in table v_events
FORM EVENT_CALL_EKPO.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
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.
ENDFORM. "event_call_ekpo
*& Form POPULATE_EVENT
Events populated for TOP OF PAGE & USER COMAND
FORM POPULATE_EVENT_EKPO.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT
*& Form TOP_OF_PAGE
text
FORM F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
ENDFORM. "TOP_OF_PAGE
*& Form USER_COMMAND
text
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
*retreiving values from the database table ekko
FORM DATA_RETRIEVAL_EKPO.
SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.
ENDFORM.
FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: HLINE1 TYPE SLIS_LISTHEADER.
HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM.
FORM DISPLAY_ALV_EKPO.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
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 = I_TITLE_EKPO
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT =
I_SAVE = 'A'
IS_VARIANT =
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_EKPO
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.
Hope this resolves your query.
Reward all the helpful answers.
Regards -
How do I change a field in the sum in ALV (List or grid)
My alv, for example:
1.10
2.30
1.50
Sum(DO_SUM) : 4.90
But I need to CEIL( 4.90 ) before showing .
It should be shown as 5.00 in alv.
How do I change this field in the sum ?Use the following code in a PBO module or in an adequate event method
data: total type ref to data,
subtotal1 type ref to data.
field-symbols: <total> like gt_sflight,
<subtotal1> like gt_sflight.
call method grid1->get_subtotals
importing
ep_collect00 = total
ep_collect01 = subtotal1.
assign total->* to <total>.
assign subtotal1->* to <subtotal1>.
Look at [ALV Grid Control (BC-SRV-ALE)|http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf]
Regards -
ALV BLOCK and GRID to move right in screen
Dear all,
How to move the reuse_alv_block_display and grid display to little right side of screen and also it should go back to the previous screen clicking the back button.
Thanks in advance.Hi
call function 'REUSE_ALV_GRID_DISPLAY'
Exporting
This code will start your screen at column 4 and line 5.
SCREEN_START_COLUMN = 4
Screen_start_line = 5.
And you header will come in every page for that you have to define a routine
Form top_of_page.
Endform.
and pass this routine name name to your REUSE_ALV_GRID_DISPLAY FM.
Check this code for the example of TOP_OF_PAGE.
http://www.sap-img.com/abap/sample-alv-heading-in-alv.htm
Regards
Neha
Edited by: Neha Shukla on Nov 30, 2008 7:11 PM -
ALV - click on grid(most left buttons)
Hi,
I had generated an ALV report and my requirement is to select the single row by clicking on the grid itself and then pass the record of selected row to at "user-command" event.Is there any way to only select a single row in grid and how to trap this click(on grid not on the fields)?.
Inputs 'll be appreciable.
Thks
manishHi again,
1. BOLD code is important.
2. just copy paste
3. It will show a list from t001 table
On double-clicking any row,
it will give a message
and display the rownumber, as well as the field
which was clicked.
4.
REPORT abc.
TYPE-POOLS : slis.
Data
DATA : BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE t001.
DATA : flag tyPE c,
END OF itab.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : alvly TYPE slis_layout_alv.
Select Data
SELECT * FROM t001 INTO TABLE itab.
*------- Field Catalogue
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
Display
alvly-box_fieldname = 'FLAG'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid "<-------Important
i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important
is_layout = alvly
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
CALL BACK FORM
FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
slis_selfield.
<b>
IMPORTANT.
data : m(100) type c.
m = whatrow-tabindex.
condense m.
concatenate 'Row Number is ' m into m separated by space.
concatenate m ' : Field Clicked is ' whatrow-fieldname into m separated
by space.
message m type 'I'.</b>
ENDFORM. "ITAB_user_command
regards,
amit m. -
Need class name to display ALV list (not Grid) in objects..
hi,
i need to display ALV list ( not ALV Grid ) in objects.. i dont the class name for tat.. so plz can anyone help me out for the same..
thanks in advance..With cl_salv_table you can have both grid or list, depending what you want.
cl_salv_table=>factory(
EXPORTING
list_display = 'X' "when space then GRID, when 'X' then LIST
IMPORTING
r_salv_table = ref_table
CHANGING
t_table = gt_sflight ).
Regards
Marcin -
Alv numbering and grid for line selection
friends,
how to give serial numbering in alv...the scenario is if the data is coming for the same item, then the serial no. should not get incremented..the serial no. has to change only when a particular item changes..then, how to give a grid or a box so that any particular line can be selected? thanks all..HI,
for numbering you have to control it in program using looping.
some thing like that.
LOOP.
at new item.
endat.
ENDLOOP.
for line selection check the following code, line in bold should be noted.
REPORT ZWA_ALV_SELECT_LINE_ITEM .
TYPE-POOLS : slis.
*-------------- Data
DATA : BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE t001.
DATA : flag tyPE c,
END OF itab.
*DATA: itab like t001 occurs 0 with header line.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : alvly TYPE slis_layout_alv.
data v_repid like sy-repid.
*--------- Select Data
v_repid = sy-repid.
SELECT * FROM t001 INTO TABLE itab.
*------- Field Catalogue
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = v_repid
i_internal_tabname = 'ITAB'
* I_STRUCTURE_NAME =
* I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = v_repid
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
changing
ct_fieldcat = alvfc[] .
*---------------Display
<b>alvly-box_fieldname = 'FLAG'.</b>
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = alvfc[]
i_callback_program = v_repid "<-------Important
i_callback_user_command =
'ITAB_USER_COMMAND' "<------ Important
is_layout = alvly
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
* CALL BACK FORM
FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
slis_selfield.
*--------- IMPORTANT.
data : m(100) type c.
m = whatrow-tabindex.
condense m.
concatenate 'Row Number is ' m into m separated by space.
concatenate m ' : Field Clicked is ' whatrow-fieldname into m separated
by space.
message i000(su) with m.
ENDFORM. "ITAB_user_command
REgards, -
Maximum Number of Columns in OOPs ALV / Normal ALV Grid
Hi Experts ,
We got Stuck in Displaying the 150 Columns in the ALV Display .
Need to Confirm how many Columns can be displayed in ALV - 60/90/99/1023 Or 1023 characters in ALv Display
1. How It can be achieved to display 150 Columns in ALV .
2. By Which way it should be More Efficient Using OOPs ALV or Normal ALV Grid.
We had check almost all the forums Post but didnt get any satisfactory answer for the same .
Thanks in advance
Regards,
Saurabh GoelHello,
If you are preparing your field catalog by using the function module REUSE_ALV_FIELDCAT_MERGE, then you can display a
maximum of something around 70 to 82 fields.
But if you are creating your field catalog manually, then you can display N number of columns in ALV grid.
Check the point of fieldcat preparation.
Hope this helps
Cheers!
Mishra -
ALV - Mass edit grid like spread sheet
Hi,
Users wanted to edit ALV grid similar to spread sheet for ex: drag a column from right hand botton corner to copy values from first column etc.
Is it possible? if atleast I could display grid in spred sheet and save it back.
Regards
KasiCreated a ALV grid event DOUBLE CLICK and maintained code for this event
Maybe you are looking for
-
I have a question about General Data Selection in Report Painter
Please help me out. Thi is the question....here it goes. In a Report in ReportPainter, I have in the General Data Selection the following selected characteristics. They are: Ledger = 0 Record Type = 0 Version = 1 Fiscal Year = Z-ANOACT Period = (1CPE
-
At each startup the US keyboard is selected instead of the French one
At each startup my iMac turns back to the default US English keyboard, while I am using the French one. I have therefore to reselect French in the systems preferences ! What is wrong ? iMac 24 ich, beginning 20093.06 GHz Intel Core duo Os 10.8.4 (12E
-
Restored iPod, and it won't install the 5.0 update. What can i do?
I restored my ipod for the most recent update from 4.0 to 5.0 and it won't install the software, it just keeps freezing at exactly the same point each and every time.
-
Query with F1 Help and the Language settings
Hi Experts My F1 help shows in Czech language...but I need it to be in English. I changed the language to English, however, the F1 Help still displays in Czech. Can you help please? Many thanks Caroline
-
Hi all...I'm sorry to repeat but I'm still having problems...I have a movie from an Adrenalin avid the movie info says the codec is: Avid ABVB NuVista I've downloaded as many codecs as I can find but on the avid site there's a message: This installer