ALV Grid using OOP
Hi Friends,
Let me know how to handle the event raised by clicking the hotspot of an ALV grid that is placed over one splitter container.
I am explaining the problem in detail:
(1) I have to display an ALV grid and when any hotspot of that ALV grid is clicked,
the row-id should be captured and used to fetch corresponding records from
child table (primarykey-foreign key relationship) and the resulting grid should be
displayed on the same screen at the same time and for any further click, the
child grid is to be refreshed.
(2) For this, I have created one custom container, placed one splitter container having two rows & one column over it and placed the ALV grids over that by getting the corresponding containers of the splitter.
(3) Now, when the hotspot is clicked the SY-UCOMM is empty (even it is not entering the PAI block if I do not place the back button). So, I am not able to get the row-id of the clicked row & without that, can't proceed any further.
(4) Rest of the things are working fine and I have tested that also.
Please help me out as I am new to this field and started practicing ABAP just a month back.
Thanks & Regards
Aditya P. Srivastava
Hi Aditya
Here is the complete for the same,
<b>Some Prerequisites in terms of screen, custom control & flow logic</b>
<i>Screen Name: 9000, Custom Container name : CONTAINER.
flow logic in screen 9000
PROCESS BEFORE OUTPUT.
MODULE status_9000.
MODULE init_9000.
PROCESS AFTER INPUT.
MODULE user_command_9000.</i>
<b>
Here goes the code,</b>
REPORT zkb_2alv_grids.
DATA: i_t000 TYPE TABLE OF t000,
w_t000 TYPE t000,
i_tcurr TYPE TABLE OF tcurr.
Declaration for all the objects required
DATA: o_container TYPE REF TO cl_gui_custom_container,
o_splitter TYPE REF TO cl_gui_easy_splitter_container,
o_container_top TYPE REF TO cl_gui_container,
o_container_bottom TYPE REF TO cl_gui_container,
o_salv_table1 TYPE REF TO cl_salv_table,
o_salv_table2 TYPE REF TO cl_salv_table,
o_salv_columns TYPE REF TO cl_salv_columns_table,
o_salv_column TYPE REF TO cl_salv_column_table.
DATA: o_events TYPE REF TO cl_salv_events_table.
CLASS lcl_handle_events DEFINITION
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS: on_link_click
FOR EVENT link_click
OF cl_salv_events_table
IMPORTING row column.
ENDCLASS. "lcl_handle_events DEFINITION
CLASS lcl_handle_events IMPLEMENTATION
CLASS lcl_handle_events IMPLEMENTATION.
METHOD on_link_click.
READ TABLE i_t000 INTO w_t000 INDEX row.
SELECT * FROM tcurr
INTO TABLE i_tcurr
WHERE fcurr = w_t000-mwaer.
o_salv_table2->refresh( ).
ENDMETHOD. "lcl_handle_events
ENDCLASS. "lcl_handle_events IMPLEMENTATION
START-OF-SELECTION.
DATA: event_handler TYPE REF TO lcl_handle_events.
Select Data
SELECT * FROM t000 INTO TABLE i_t000.
CALL SCREEN 9000.
*& Module init_9000 OUTPUT
text
MODULE init_9000 OUTPUT.
DATA: lv_cx_salv_msg TYPE REF TO cx_salv_msg,
lw_bal_s_msg TYPE bal_s_msg.
IF NOT o_container IS BOUND.
Create a Custom Control
CREATE OBJECT o_container
EXPORTING
container_name = 'CONTAINER'
repid = sy-repid
dynnr = '9000'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Create splitter control
CREATE OBJECT o_splitter
EXPORTING
parent = o_container
orientation = 0
sash_position = 30
with_border = 1
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Assign the left and right control that were splitted
o_container_top = o_splitter->top_left_container.
o_container_bottom = o_splitter->bottom_right_container.
ENDIF. " IF NOT o_container IS BOUND.
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
r_container = o_container_top
IMPORTING
r_salv_table = o_salv_table1
CHANGING
t_table = i_t000.
CATCH cx_salv_msg INTO lv_cx_salv_msg.
lv_cx_salv_msg->if_alv_message~get_message(
RECEIVING
r_s_msg = lw_bal_s_msg ).
MESSAGE ID lw_bal_s_msg-msgid
TYPE lw_bal_s_msg-msgty
NUMBER lw_bal_s_msg-msgno
WITH lw_bal_s_msg-msgv1 lw_bal_s_msg-msgv2
lw_bal_s_msg-msgv3 lw_bal_s_msg-msgv4.
ENDTRY.
Column Settings
o_salv_columns = o_salv_table1->get_columns( ).
o_salv_column ?= o_salv_columns->get_column( 'MWAER' ).
o_salv_column->set_cell_type( 5 ).
o_events = o_salv_table1->get_event( ).
CREATE OBJECT event_handler.
SET HANDLER event_handler->on_link_click FOR o_events.
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
r_container = o_container_bottom
IMPORTING
r_salv_table = o_salv_table2
CHANGING
t_table = i_tcurr.
CATCH cx_salv_msg INTO lv_cx_salv_msg.
lv_cx_salv_msg->if_alv_message~get_message(
RECEIVING
r_s_msg = lw_bal_s_msg ).
MESSAGE ID lw_bal_s_msg-msgid
TYPE lw_bal_s_msg-msgty
NUMBER lw_bal_s_msg-msgno
WITH lw_bal_s_msg-msgv1 lw_bal_s_msg-msgv2
lw_bal_s_msg-msgv3 lw_bal_s_msg-msgv4.
ENDTRY.
Display the ALV Grid
o_salv_table1->display( ).
o_salv_table2->display( ).
ENDMODULE. " init_9000 OUTPUT
*& Module user_command_9000 INPUT
text
MODULE user_command_9000 INPUT.
CASE sy-ucomm .
WHEN 'BACK' OR 'EXIT' OR 'CANC'.
SET SCREEN 0.
LEAVE SCREEN.
ENDCASE.
ENDMODULE. " user_command_9000 INPUT
*& Module status_9000 OUTPUT
text
MODULE status_9000 OUTPUT.
SET PF-STATUS '9000'.
ENDMODULE. " status_9000 OUTPUT
Regards
Kathirvel
Similar Messages
-
Display error message in ALV grid using OOPS
Hi,
I have a requirement to display report in ALV. I have created ALV grid using OOPS with three editable cells and 1 button on toolbar. When user enter values in Ediatble cell and click on the Toolbar button, sales order item should be assigned to contract.
When the user select the row and click on toolbar button, a salesorder item should be assigned to contract and i am using BAPI and fine with BAPI. All the error message should be displayed in a popup and the corresponding failed row should change its color .
Once the user identified the failed row, he can edit the value in the ediatble cells and should reprocess in the same screen ( without going back to selection screen).
To display POP Up, I am using FM BAL_LOG_CREATE, BAL_LOG_MSG_ADD, BAL_DSP_PROFILE_NO_TREE_GET, BAL_CNTL_CREATE.
by using above 4 FM , i can display POP UP. but i cannot change the color of the failed row.
Once I identified the failed row and reprocess from the same screen , I am successful in processing the failed row, but my error log still has the reprocessed row as failed row because, error log is not refreshing.
Please suggest me how to clear error log which was created by using the above FM's and change the color of the failed row .
Thanks in AdvanceHi
Please suggest me how to clear error log which was created by using the above FM's....
U can use BAL_LOG_REFRESH
....and change the color of the failed row
You need to insert a new field for Colour Attributes in your output table and input its name in the layout structure:
IS_LAYOUT-INFO_FNAME = <field name for colour>
The field has to be a CHAR 3 and its value can be -
> Cxy
C is a constant
x is the colour number (from 1 to 9)
y is intensified (0 = off, 1 = on)
After changing the value of output table you need to run the method REFRESH_TABLE_DISPLAY for refreshing the output
Max -
Sub total in ALV GRID using oops concept
Hi,
If Plant (VBAP-WERKS) is not the same for all items on a Sales Order (VBAK-VBELN is the same for al items) then create a separate line on the report for each different plant specified in the line items. Copy all fields from the original order line except for plant and Net Value. Net Value should be the total of item Net Values for all items with the same plant in the order.
Example:
Data:
Order---- Item- Plant- Net Value---
123---- 010- 3467- 100.00---
123---- 020- 7865- 50.00---
123---- 030- 3467- 80.50---
Report:
Order- Plant- Net Value---
123- 3467- 180.50---
123- 7865- 50.00----
I need to dispaly the Report format in ALV Grid using oops concept...
no need of calling any function modules.
Regards,
NithyaHi
Here is example code
This is the method to be called:
get_subtotals
Use
Returns the current subtotals of the ALV Grid Control. Having created totals for at least one column, users can calculate at most nine subtotals. The list is sorted by the values of one or several columns (called the subtotals column). If a value is changed in the subtotals column, the subtotal is displayed (this is also referred to as control level change).
Integration
Before you access the subtotals value, you use the method get_sort_criteria to get the sort table . One row of this table describes properties of a column in the output table.
If the field SUBTOT is set for a column in this table, the column is a subtotals column.
The field SPOS then indicates at which level (see below) the subtotal has been calculated.
The field FIELDNAME contains the name of the subtotals column in the output table.
Based on this information, you specifically access the values of the tables passed (using reference variables COLLECT01 to COLLECT09).
Features
CALL METHOD <ref. var. to CL_GUI_ALV_GRID>->get_subtotals
IMPORTING
EP_COLLECT00 = <reference variable of type REF TO DATA>
EP_COLLECT01 = <reference variable of type REF TO DATA>
EP_COLLECT02 = <reference variable of type REF TO DATA>
EP_COLLECT03 = <reference variable of type REF TO DATA>
EP_COLLECT04 = <reference variable of type REF TO DATA>
EP_COLLECT05 = <reference variable of type REF TO DATA>
EP_COLLECT06 = <reference variable of type REF TO DATA>
EP_COLLECT07 = <reference variable of type REF TO DATA>
EP_COLLECT08 = <reference variable of type REF TO DATA>
EP_COLLECT09 = <reference variable of type REF TO DATA>
ET_GROUPLEVELS = <ínternal table of type LVC_T_GRPL>.
In order to access the values of EP_COLLECT00 to EP_COLLECT09, you use ASSIGN to dereference the relevant reference variable in a field symbol of your output table type (see below).
Parameters
Meaning
EP_COLLECT00
Points to the totals line. Since there is only one totals line which, in addition, has a unique totalling area, no further information is available for this table in table ET_GROUPLEVELS.
get_subtotals
EP_COLLECT01 to EP_COLLECT09
Point to the subtotals line. For each subtotals level, there is one reference variable. Each of these variables points to an internal table that has the type of the output table. EP_COLLECT01 points to the subtotal at the hightest level, while EP_COLLECT02 points to the subtotal at the second highest level, and so on. The levels are derived from the sort priority (field SPOS in the sort table ). The column by which the data was sorted first, is the highest subtotals level.
ET_GROUPLEVELS
Manages all indexes for the individual control levels. The fields of the table have the following meaning:
INDEX_FROM, INDEX_TO: Rows of the output table for which the subtotal was created
LEVEL: Subtotals level (see above)
COUNTER: Number of rows for which the subtotal was created
COMPRESS: For this subtotals line, the user has hidden the associated rows.
COLLECT: Indicates the subtotals table (01-09) in which the values are stored
For an overview, see Methods of Class CL_GUI_ALV_GRID
Activities -
Freeze toolbar while scrolling down in ALV grid using OOPS
Hi,
My program is showing few products in ALV grid using OOPS. But If I scroll down to select a product, then I cant see the toolbar on which I have to press a button using selected product. Is there any way to freeze toolbar while scrolling down also.
As of now I have to scroll up after selecting product and then press the button on toolbar.
Regards,
Seema
Edited by: Seema Naharia on Feb 23, 2012 9:17 AMHi ,
You may have to set handler for the toolbars. Check class cl_gui_alv_grid for the events toolbar.
Or just for a try, since your problem is only when scrolling,you can use set_visible_row_count to -1 , so that data will appear in same view without the need to scroll.
Regards,
Ramya -
HI all,
Is it necessary to use container for ALV grid using classes.If not then please help me with a sample code.REPORT z_alv_using_oops_conepts MESSAGE-ID z_OOPS.
TABLES: ekko, ekpo.
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA: ok_code TYPE sy-ucomm,
gx_fcat1 TYPE lvc_s_fcat,
gt_fcat1 TYPE STANDARD TABLE OF lvc_s_fcat,
gx_fcat2 TYPE lvc_s_fcat,
gt_fcat2 TYPE STANDARD TABLE OF lvc_s_fcat,
gx_layout1 TYPE lvc_s_layo,
gx_layout2 TYPE lvc_s_layo,
gx_variant TYPE disvariant,
g_custom_container1 TYPE REF TO cl_gui_custom_container,
g_custom_container2 TYPE REF TO cl_gui_custom_container,
grid1 TYPE REF TO cl_gui_alv_grid,
grid2 TYPE REF TO cl_gui_alv_grid,
g_container1 TYPE scrfname VALUE 'MAIN_REPORT_LIST',
g_container2 TYPE scrfname VALUE 'SECOND_REPORT_LIST',
gv_event_rec1 TYPE REF TO lcl_event_receiver,
gv_event_rec2 TYPE REF TO lcl_event_receiver,
gv_repid TYPE sy-repid,
gt_final1 TYPE STANDARD TABLE OF ekko,
gt_final2 TYPE STANDARD TABLE OF ekpo,
gt_final3 TYPE STANDARD TABLE OF ekpo,
gx_final TYPE ekko,
gx_final1 TYPE ekpo.
INITIALIZATION.
SELECTION-SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK blk3 WITH FRAME .
SELECT-OPTIONS:
s_ebeln FOR ekko-ebeln obligatory,
s_ebelp FOR ekpo-ebelp,
s_bukrs FOR ekko-bukrs,
s_bsart FOR ekko-bsart.
SELECTION-SCREEN END OF BLOCK blk3.
LOCAL CLASSES: Definition
*===============================================================
class lcl_event_receiver: local class to
define and handle own functions.
Definition:
~~~~~~~~~~~
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
hotspot_click1
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id
e_column_id,
hotspot_click2
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id
e_column_id.
PRIVATE SECTION.
ENDCLASS. "lcl_event_receiver DEFINITION
CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD hotspot_click1.
DATA: lv_tabix TYPE sy-tabix,
lx_final TYPE ekko.
READ TABLE gt_final1 INTO gx_final INDEX e_row_id.
IF sy-subrc = 0.
gt_final3 = gt_final2.
DELETE gt_final3 WHERE ebeln NE gx_final-ebeln.
IF NOT g_custom_container2 IS INITIAL.
CALL METHOD grid2->refresh_table_display.
CALL METHOD grid1->refresh_table_display.
ENDIF.
ELSE.
MESSAGE s000 WITH text-003.
LEAVE LIST-PROCESSING.
ENDIF.
ENDMETHOD. "hotspot_click1
METHOD hotspot_click2.
READ TABLE gt_final3 INTO gx_final1 INDEX e_row_id.
IF sy-subrc = 0.
SET PARAMETER ID 'BES' FIELD gx_final-ebeln.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDMETHOD. "button_click1
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
START-OF-SELECTION *
START-OF-SELECTION.
SELECT * FROM ekko INTO TABLE gt_final1 WHERE ebeln IN s_ebeln
AND bukrs IN s_bukrs
AND bsart IN s_bsart.
IF sy-subrc = 0.
SELECT * FROM ekpo INTO TABLE gt_final2 FOR ALL ENTRIES IN gt_final1
WHERE ebeln = gt_final1-ebeln
AND ebelp IN s_ebelp.
IF sy-subrc = 0.
gt_final3 = gt_final2.
ENDIF.
ENDIF.
PERFORM sub_get_fieldcat CHANGING gt_fcat1.
PERFORM sub_get_fieldcat CHANGING gt_fcat2.
END-OF-SELECTION *
END-OF-SELECTION.
PERFORM display_process.
CALL SCREEN 9000.
MODULE pbo OUTPUT
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
gx_layout1-grid_title = 'Purchase Order Header'.
gx_layout1-zebra = 'X'.
gx_layout1-info_fname = 'COLOR_LINE'.
gx_layout1-sel_mode = 'X'.
gx_layout2-grid_title = 'Purchase Order Items'.
gx_layout2-zebra = 'X'.
gx_layout1-stylefname = 'CB'.
gs_layout1-excp_led = gc_check.
gs_layout1-excp_group = gc_check.
gv_repid = sy-repid.
gx_variant-report = gv_repid.
READ TABLE gt_final1 INTO gx_final INDEX 1.
IF sy-subrc = 0.
DELETE gt_final3 WHERE ebeln NE gx_final-ebeln.
ENDIF.
IF g_custom_container1 IS INITIAL.
CREATE OBJECT g_custom_container1
EXPORTING
container_name = g_container1.
CREATE OBJECT grid1
EXPORTING
i_parent = g_custom_container1.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
is_layout = gx_layout1
is_variant = gx_variant
i_save = 'U'
i_default = 'X'
i_structure_name = 'EKKO'
CHANGING
it_outtab = gt_final1
it_fieldcatalog = gt_fcat1.
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = grid1.
ENDIF.
IF g_custom_container2 IS INITIAL.
CREATE OBJECT g_custom_container2
EXPORTING
container_name = g_container2.
CREATE OBJECT grid2
EXPORTING
i_parent = g_custom_container2.
CALL METHOD grid2->set_table_for_first_display
EXPORTING
is_layout = gx_layout2
is_variant = gx_variant
i_save = 'U'
i_default = 'X'
i_structure_name = 'EKPO'
CHANGING
it_outtab = gt_final3
it_fieldcatalog = gt_fcat2.
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = grid2.
ENDIF.
CREATE OBJECT gv_event_rec1.
SET HANDLER gv_event_rec1->hotspot_click1 FOR grid1.
CREATE OBJECT gv_event_rec2.
SET HANDLER gv_event_rec1->hotspot_click2 FOR grid2.
IF gt_final2 IS INITIAL.
MESSAGE i000 WITH 'No Items exist for the Purchase Order'.
ENDIF.
ENDMODULE. "PBO OUTPUT
MODULE PAI INPUT *
MODULE pai INPUT.
To react on oi_custom_events:
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
LEAVE PROGRAM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'CANCEL'.
LEAVE TO SCREEN 0.
ENDCASE.
CLEAR ok_code.
ENDMODULE. "PAI INPUT
FORM EXIT_PROGRAM *
FORM exit_program.
CALL METHOD grid1->free.
CALL METHOD grid2->free.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = gv_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(009).
ENDIF.
ENDFORM. "EXIT_PROGRAM
*& Form display_process
text
--> p1 text
<-- p2 text
FORM display_process .
DATA: a LIKE sy-ucomm.
DO 100 TIMES.
DO 300 TIMES.
GET TIME.
ENDDO.
a(3) = sy-index.a+3 = '%'.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = sy-index
text = a.
ENDDO.
ENDFORM. " display_process
*& Form sub_get_fieldcat
text
<--P_GT_FCAT1 text
FORM sub_get_fieldcat CHANGING lt_fcat TYPE lvc_t_fcat.
gx_fcat1-fieldname = 'EBELN'.
gx_fcat1-tabname = 'gt_final1'.
gx_fcat1-hotspot = 'X'.
APPEND gx_fcat1 TO lt_fcat.
ENDFORM. " sub_get_fieldcat -
Disable editable field in ALV grid using OOPS
I have following requirements,
Displaying ALV grid output with most of the fields editable.
Validations on data entered for each fields,for error messages
Query :
I want to make all the fields except the field in ERROR in display only mode
similar to case when we do validation of fields in table controls.HI
check the below links lot of info and examples r there for OOPS
http://www.sapgenie.com/abap/OO/index.htm
http://www.geocities.com/victorav15/sapr3/abap_ood.html
http://www.brabandt.de/html/abap_oo.html
Check this cool weblog:
/people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
/people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm
http://www.sapgenie.com/abap/OO/
http://www.sapgenie.com/abap/OO/index.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
http://www.allsaplinks.com/
http://www.sap-img.com/
http://www.sapgenie.com/
http://help.sap.com
http://www.sapgenie.com/abap/OO/
http://www.sapgenie.com/abap/OO/index.htm
http://www.sapgenie.com/abap/controls/index.htm
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
http://www.sapgenie.com/abap/OO/index.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
http://www.sapgenie.com/abap/OO/
these links
http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm
For funtion module to class
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm
for classes
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
for methods
http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
for inheritance
http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
for interfaces
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
For Materials:
1) http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291
2) http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
3) http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
8) http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
1) http://www.erpgenie.com/sap/abap/OO/index.htm
2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
Check these sample code
data : begin of it_mara occurs 0,
mark type flag,
matnr type matnr,
mtart type mtart,
meins type meins,
end of it_mara.
data : begin of it_mara1 occurs 0,
mark type flag,
matnr type matnr,
mtart type mtart,
meins type meins,
end of it_mara1.
data : begin of it_mara2 occurs 0,
mark type flag,
matnr type matnr,
mtart type mtart,
meins type meins,
end of it_mara2.
data : t_fieldcat type lvc_t_fcat,
t_fieldcat1 type lvc_t_fcat,
s_fieldcat like line of t_fieldcat.
data : s_layout type lvc_s_layo.
data : control type ref to cl_gui_custom_container,
grid type ref to cl_gui_alv_grid.
data: begin of wa ,
mark type flag,
matnr type matnr,
mtart type mtart,
meins type meins,
end of wa.
class lcl_events_box definition.
public section.
methods :
*Handler_Data_Changed for event Data_Changed of cl_gui_alv_grid
*imporTing er_data_changed,
Handler_User_Command for event User_Command of cl_gui_alv_grid
imporTing e_ucomm,
Handler_ToolBar for event ToolBar of cl_gui_alv_grid
importing E_object E_interactive.
endclass.
class lcl_events_box implementation.
method Handler_user_command.
PERFORM FORM_USERCOMMAND CHANGING E_UCOMM.
endmethod.
method Handler_ToolBar.
PERFORM FORM_TOOLBAR CHANGING E_OBJECT E_INTERACTIVE
E_OBJECT->MT_TOOLBAR.
endmethod.
ENDCLASS.
start-of-selection.
data : w_events type ref to lcl_events_box.
select matnr mtart meins from mara into corresponding fields of table
it_mara.
call screen 100.
*& Module pbo_module OUTPUT
text
MODULE pbo_module OUTPUT.
if GRID is initial.
CREATE OBJECT CONTROL
EXPORTING
CONTAINER_NAME = 'CUST_CTRL'.
CREATE OBJECT GRID
EXPORTING
I_PARENT = CONTROL.
PERFORM BUILD_CATALOG.
PERFORM BUILD_CATALOG1.
PERFORM BUILD_LAYOUT.
CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = s_layout
CHANGING
IT_OUTTAB = it_mara[]
IT_FIELDCATALOG = t_fieldcat.
CREATE OBJECT W_EVENTS.
SET HANDLER : W_EVENTS->HANDLER_TOOLBAR FOR GRID,
W_EVENTS->HANDLER_USER_COMMAND FOR GRID.
CALL METHOD GRID->SET_TOOLBAR_INTERACTIVE.
ELSE.
call method grid->refresh_table_display.
ENDIF.
ENDMODULE. " pbo_module OUTPUT
*& Form BUILD_CATALOG
FORM BUILD_CATALOG .
S_FIELDCAT-COL_POS = '1'.
S_FIELDCAT-FIELDNAME = 'MARK'.
S_FIELDCAT-CHECKBOX = 'X'.
S_FIELDCAT-eDIT = 'X'.
APPEND S_FIELDCAT TO T_FIELDCAT.
CLEAR S_FIELDCAT.
S_FIELDCAT-COL_POS = '2'.
S_FIELDCAT-FIELDNAME = 'MATNR'.
S_FIELDCAT-SCRTEXT_M = 'MATERIAL'.
APPEND S_FIELDCAT TO T_FIELDCAT.
S_FIELDCAT-COL_POS = '3'.
S_FIELDCAT-FIELDNAME = 'MTART'.
S_FIELDCAT-SCRTEXT_M = 'MATERL TYPE'.
APPEND S_FIELDCAT TO T_FIELDCAT.
S_FIELDCAT-COL_POS = '4'.
S_FIELDCAT-FIELDNAME = 'MEINS'.
S_FIELDCAT-SCRTEXT_M = 'UOM'.
APPEND S_FIELDCAT TO T_FIELDCAT.
ENDFORM. " BUILD_CATALOG
*& Form BUILD_LAYOUT
text
--> p1 text
<-- p2 text
FORM BUILD_LAYOUT .
S_LAYOUT-ZEBRA = 'X'.
S_LAYOUT-CWIDTH_OPT = 'X'.
S_LAYOUT-GRID_TITLE = 'Material Details'.
ENDFORM.
" BUILD_LAYOUT////////////////////////////////////
" USER_COMMAND_0100 INPUT
*& Form FORM_USERCOMMAND
text
<--P_E_UCOMM text
form FORM_USERCOMMAND changing p_e_ucomm.
CASE P_E_UCOMM.
WHEN 'INT1'.
DO.
READ TABLE IT_MARA INDEX SY-INDEX TRANSPORTING MARK MATNR.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
IF IT_MARA-MARK = 'X'.
read table it_mara into wa TRANSPORTING MATNR MTART MEINS .
MOVE-CORRESPONDING WA TO IT_MARA1.
READ TABLE IT_MARA1 TRANSPORTING MATNR MTART MEINS .
MOVE-CORRESPONDING IT_MARA1 TO IT_MARA2.
APPEND IT_MARA2.
CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = s_layout
CHANGING
IT_OUTTAB = it_mara2[]
IT_FIELDCATALOG = t_fieldcat1.
SET PARAMETER ID 'MAT' FIELD IT_MARA-MATNR.
CALL TRANSACTION 'MM02'.
. ENDIF.
ENDIF.
ENDDO.
ENDCASE.
endform. " FORM_USERCOMMAND
*& Form FORM_TOOLBAR
text
<--P_E_OBJECT text
<--P_E_INTERACTIVE text
<--P_E_OBJECT_>MT_TOOLBAR text
FORM FORM_TOOLBAR CHANGING P_E_OBJECT TYPE REF TO
CL_ALV_EVENT_TOOLBAR_SET
P_E_INTERACTIVE
MT_TOOLBAR TYPE TTB_BUTTON.
DATA WAL_BUTTON TYPE STB_BUTTON.
*WAL_BUTTON-ICON = ICON_status_reverse.
WAL_BUTTON-TEXT = 'GO'.
WAL_BUTTON-QUICKINFO = 'PROCEED'.
waL_button-FUNCTION = 'INT1'.
WAL_BUTTON-BUTN_TYPE = 0.
WAL_BUTTON-DISABLED = SPACE.
insert WAL_BUTTON INTO P_E_OBJECT->MT_TOOLBAR index 1.
endform. " FORM_TOOLBAR
*& Module PF-STATUS OUTPUT
text
module PF-STATUS output.
set pf-status 'Z7PSTAT'.
endmodule. " PF-STATUS OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
module USER_COMMAND_0100 input.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'CANCEL'.
LEAVE PROGRAM.
ENDCASE.
endmodule. " USER_COMMAND_0100 INPUT
*& Form BUILD_CATALOG1
text
--> p1 text
<-- p2 text
form BUILD_CATALOG1 .
S_FIELDCAT-COL_POS = '1'.
S_FIELDCAT-FIELDNAME = 'MATNR'.
S_FIELDCAT-SCRTEXT_M = 'MATERIAL'.
APPEND S_FIELDCAT TO T_FIELDCAT1.
S_FIELDCAT-COL_POS = '2'.
S_FIELDCAT-FIELDNAME = 'MTART'.
S_FIELDCAT-SCRTEXT_M = 'MATERL TYPE'.
APPEND S_FIELDCAT TO T_FIELDCAT1.
S_FIELDCAT-COL_POS = '3'.
S_FIELDCAT-FIELDNAME = 'MEINS'.
S_FIELDCAT-SCRTEXT_M = 'UOM'.
APPEND S_FIELDCAT TO T_FIELDCAT1.
endform. " BUILD_CATALOG1
check the below link may be useful for you
http://www.sapdevelopment.co.uk/reporting/alvhome.htm
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
Simple ALV report
http://www.sapgenie.com/abap/controls/alvgrid.htm
http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
ALV
1. Please give me general info on ALV.
http://www.sapfans.com/forums/viewtopic.php?t=58286
http://www.sapfans.com/forums/viewtopic.php?t=76490
http://www.sapfans.com/forums/viewtopic.php?t=20591
http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
2. How do I program double click in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=11601
http://www.sapfans.com/forums/viewtopic.php?t=23010
3. How do I add subtotals (I have problem to add them)...
http://www.sapfans.com/forums/viewtopic.php?t=20386
http://www.sapfans.com/forums/viewtopic.php?t=85191
http://www.sapfans.com/forums/viewtopic.php?t=88401
http://www.sapfans.com/forums/viewtopic.php?t=17335
4. How to add list heading like top-of-page in ABAP lists?
http://www.sapfans.com/forums/viewtopic.php?t=58775
http://www.sapfans.com/forums/viewtopic.php?t=60550
http://www.sapfans.com/forums/viewtopic.php?t=16629
5. How to print page number / total number of pages X/XX in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
http://www.sapfans.com/forums/viewtopic.php?t=64320
http://www.sapfans.com/forums/viewtopic.php?t=44477
7. How can I set the cell color in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=52107
8. How do I print a logo/graphics in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=81149
http://www.sapfans.com/forums/viewtopic.php?t=35498
http://www.sapfans.com/forums/viewtopic.php?t=5013
9. How do I create and use input-enabled fields in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=84933
http://www.sapfans.com/forums/viewtopic.php?t=69878
10. How can I use ALV for reports that are going to be run in background?
http://www.sapfans.com/forums/viewtopic.php?t=83243
http://www.sapfans.com/forums/viewtopic.php?t=19224
11. How can I display an icon in ALV? (Common requirement is traffic light icon).
http://www.sapfans.com/forums/viewtopic.php?t=79424
http://www.sapfans.com/forums/viewtopic.php?t=24512
12. How can I display a checkbox in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=88376
http://www.sapfans.com/forums/viewtopic.php?t=40968
http://www.sapfans.com/forums/viewtopic.php?t=6919
Go thru these programs they may help u to try on some hands on
ALV Demo program
BCALV_DEMO_HTML
BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode
BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode
BCALV_GRID_DEMO Simple ALV Control Call Demo Program
BCALV_TREE_DEMO Demo for ALV tree control
BCALV_TREE_SIMPLE_DEMO
BC_ALV_DEMO_HTML_D0100
<b>Reward all helpfull answers</b>
Regards -
Enable User Defined toolbar button on click - editable alv grid using oops
Hi all,
I have created editable alv using oops concept.
created 2 user defined toolbar button save and print using method toolbar
ls_toolbar-text = 'Print'. "#EC NOTEXT
ls_toolbar-quickinfo = space.
ls_toolbar-checked = space.
APPEND ls_toolbar TO e_object->mt_toolbar.
requirement is
initially print button should be disabled, and save enabled
when i click save button, print button should be enabled.
I want coding in editable alv oops concept
kindly help
regards
senthil kumarHalo Senthil,
You should call set_toolbar_interactive method of cl_gui_alv_grid in the on_user_command( ie the event handler for event user command) .
method on_user_command.
case e_ucomm.
when 'SAVE'. or whatever your function code is .
my_save_flag = 'X'.
call method grid->set_toolbar_interactive.
endmethod.
This triggers the toolbar event of the
cl_gui_alv_grid. Inside the eventhandler method ( ie the on_toolbar method ) you should set the toolbar.
if my_save_flag = 'X'.
read table e_object->mt_toolbar
clear l_toolbar-disabled.
modify e_object->mt_toolbar.
endif.
e_ucomm will not have the function code if the save button is not in the toolbar area.
then you can set the my_save_flag in the data_changed event handler of the Cl_gui_alv_grid.
Regards
Arshad -
Controlling Font size in alv grid using oops
Hi Experts,
I have a requirement where i want to change the font size of the grid title bar.
Is there any way of acheiving this.
I do see a method set_title size in the class cl_gui_alv_grid. However it is a protected method and i am not able implement it in my program.
Any pointers on this would be higly appreciated.
Thanks and Regards,
Jey sabith EbronHi
I tried and it worked with me.
The grid title was indeed changed from the the method Set_Title_Size.
To use the method you have to Create a Local Class Inheriting the Class CL_GUI_ALV_GRID.
CLASS ZCL_GUI_ALV_GRID DEFINITION INHERITING FROM CL_GUI_ALV_GRID.
PUBLIC SECTION.
METHODS TITLE_SIZE.
PRIVATE SECTION.
ENDCLASS. "ZCL_GUI_ALV_GRID DEFINITION
Then use the above method in the Implementation part as .
CLASS ZCL_GUI_ALV_GRID IMPLEMENTATION.
METHOD TITLE_size.
ME->SET_TITLE_SIZE( EXPORTING SIZE = 1
EXCEPTIONS ERROR = 1 ).
ENDMETHOD.
ENDCLASS.
Now when your reference variable should be
Data :GRID type ref to ZCL_GUI_ALV_GRID.
and Create the Object as
CREATE OBJECT GRID
EXPORTING I_PARENT = G_CUSTOM_CONTAINER1.
Before Calling Set_table_for_ first_display, Call the created method
CALL METHOD GRID->TITLE_SIZE. -
Is there any to restrict the no of display fields in alv grid using oops?
hi,
i have 100 field in an internal table , and i passed that internal table to set_table_for_first_display, Now my aim is to display only 20 fields among that 100, these twenty may vary based on selection but count of fields should be always 20. Is it possible .....Yes!! youhave to prepare the field catalogue dynamically..based upon the selection..get the names of all the fields to be displayed ..take first twenty of them and for the rest of the fields in the internal table which are not in these twenty..mark no_out = 'X'.
-
Disbable button on alv report using oops
Hi all,
I have a button to toll bar of alv grid using oops
based on that when the user clicks on that some action is performed and list is displayed again
now when the list is diaplyed i need the button that i added to be disabled so that the user cannot click it agin
i have everything i don't know how to disable the button.
USING THIS STATMENT move 'X' to ls_toolbar-disabled WE CAN DISABLE BUT I DON'T WHERE TO PASS IT..
LOCAL CLASSES: Definition
*===============================================================
class lcl_event_receiver: local class to
define and handle own functions.
Definition:
~~~~~~~~~~~
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.
private section.
endclass.
lcl_event_receiver (Definition)
*===============================================================
LOCAL CLASSES: Implementation
*===============================================================
class lcl_event_receiver (Implementation)
class lcl_event_receiver implementation.
method handle_toolbar.
append a separator to normal toolbar
clear ls_toolbar.
move 3 to ls_toolbar-butn_type.
append ls_toolbar to e_object->mt_toolbar.
append an icon to show booking table
clear ls_toolbar.
move 'ADD' to ls_toolbar-function.
move icon_employee to ls_toolbar-icon.
move 'Show Bookings'(111) to ls_toolbar-quickinfo.
move 'Add Material'(112) to ls_toolbar-text.
move '' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
endmethod.
method handle_user_command.
case e_ucomm.
when 'ADD'.
call method g_grid->get_selected_rows
importing et_index_rows = lt_rows.
call method cl_gui_cfw=>flush.
if sy-subrc ne 0.
add your handling, for example
call function 'POPUP_TO_INFORM'
exporting
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
else.
*tHIS IS THE PART IAM HAVING PROBLEM WITH
*class lcl_event_receiver implementation.
method handle_toolbar.
*clear : ls_toolbar.
loop at e_object->mt_toolbar into ls_toolbar WHERE FUNCTION = 'ADD'.
DELETE e_object->mt_toolbar FROM ls_toolbar.
move ' ' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
endloop.
*ENDMETHOD.
*ENDCLASS.
***tHIS IS THE PART
call method g_grid->refresh_table_display.
endif.
endcase.
endmethod.
Thanks in advanceHi
hI ALL,
MY QUESTION IS WHEN method handle_toolbaR WOULD BE TRIGERRED
first time i have the button enabled and when i press the button its get disabled.This is what i need
But iam trying to understand how this is working
Let me know whether iam right or not
when this piece of code would be triggered
method handle_toolbar.
clear ls_toolbar.
move 3 to ls_toolbar-butn_type.
append ls_toolbar to e_object->mt_toolbar.
clear ls_toolbar.
move 'ADD' to ls_toolbar-function.
move icon_employee to ls_toolbar-icon.
move 'Show Bookings'(111) to ls_toolbar-quickinfo.
move 'Add Material'(112) to ls_toolbar-text.
move ' ' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
IF FLAG = 'X'.
LOOP AT e_object->mt_toolbar INTO ls_toolbar.
if ls_toolbar-function = 'ADD'.
ls_toolbar-disabled = 'X'.
MODIFY e_object->mt_toolbar FROM ls_toolbar.
endif.
ENDLOOP.
ENDIF.
1 ) would this be triggered
when i call this call method g_grid->refresh_table_display.
2)or
call method g_grid->set_toolbar_interactive
This is my piece of code
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.
private section.
endclass.
class lcl_event_receiver implementation.
method handle_toolbar.
clear ls_toolbar.
move 3 to ls_toolbar-butn_type.
append ls_toolbar to e_object->mt_toolbar.
clear ls_toolbar.
move 'ADD' to ls_toolbar-function.
move icon_employee to ls_toolbar-icon.
move 'Show Bookings'(111) to ls_toolbar-quickinfo.
move 'Add Material'(112) to ls_toolbar-text.
move ' ' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
IF FLAG = 'X'.
LOOP AT e_object->mt_toolbar INTO ls_toolbar.
if ls_toolbar-function = 'ADD'.
ls_toolbar-disabled = 'X'.
MODIFY e_object->mt_toolbar FROM ls_toolbar.
endif.
ENDLOOP.
ENDIF.
endmethod.
method handle_user_command.
case e_ucomm.
when 'ADD'.
call method g_grid->get_selected_rows
importing et_index_rows = lt_rows.
call method cl_gui_cfw=>flush.
if sy-subrc ne 0.
else.
perform test.
call method g_grid->refresh_table_display.
endif.
endcase.
endmethod. "handle_user_command
odule status_0100 output.
SET PF-STATUS 'STATUS'.
set pf-status 'MAIN100'.
set titlebar 'HEADER_CHECK'.
if g_custom_container is initial.
create object g_custom_container
exporting container_name = g_container.
create object g_grid
exporting i_parent = g_custom_container.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'ZTEST'
changing
ct_fieldcat = fieldcat
exceptions
others = 3
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
g_layout-sel_mode = 'A'. " TO GET SELECTION BOX
call method g_grid->set_table_for_first_display
exporting
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
is_layout = g_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
it_toolbar_excluding = pt_exclude
IT_HYPERLINK =
IT_ALV_GRAPHICS =
changing
it_outtab = i_zTEST
it_fieldcatalog = fieldcat
IT_SORT =
IT_FILTER =
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
create object event_receiver.
set handler event_receiver->handle_user_command for g_grid.
set handler event_receiver->handle_toolbar for g_grid.
call method g_grid->set_toolbar_interactive.
endif. "IF grid1 IS INITIAL
call method cl_gui_control=>set_focus exporting control = g_grid.
endmodule. " STATUS_0100 OUTPUT
Thanks
Suchitra -
hi friendz,
can any one of u give an example, how to build alv report using oops abap ?
thanks in advance.
points for sure
regards,
VijayaHi Vijaya,
I hope the following code upto your requirement.
*& Report ZMAT_ALV_GRID *
REPORT ZCL_CLASS1.
TYPES: BEGIN OF T_MARA,
MATNR TYPE MARA-MATNR,
MAKTX TYPE MAKT-MAKTX,
WERKS TYPE MARD-WERKS,
LGORT TYPE MARD-LGORT,
LABST TYPE MARD-LABST,
END OF T_MARA.
*DATA: IT_MARA TYPE STANDARD TABLE OF T_MARA.
DATA: IT_MARA TYPE T_MARA OCCURS 0.
DATA: O_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
O_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA: X_FLDCAT TYPE LVC_S_FCAT.
DATA: IT_FLDCAT TYPE LVC_T_FCAT.
DATA: I_LAYOUT TYPE LVC_S_LAYO.
DATA: X_SORT TYPE LVC_S_SORT.
DATA: I_SORT TYPE LVC_T_SORT.
TABLES: MARA.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
PARAMETERS: P_CHK AS CHECKBOX.
START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM GENERATE_FLDCAT.
PERFORM GENERATE_LAYOUT.
PERFORM DO_SORT.
SET SCREEN 100.
*& Module STATUS_0100 OUTPUT
text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MAIN'.
SET TITLEBAR 'xxx'.
PERFORM BUILD_ALV.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form BUILD_ALV
text
FORM BUILD_ALV .
CREATE OBJECT O_CONT
EXPORTING
CONTAINER_NAME = 'MAT_CONTAINER'
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
others = 6.
CREATE OBJECT O_GRID
EXPORTING
I_PARENT = O_CONT
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
others = 5.
CALL METHOD O_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 = I_LAYOUT
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
CHANGING
IT_OUTTAB = IT_MARA
IT_FIELDCATALOG = IT_FLDCAT[]
IT_SORT = I_SORT
IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
others = 4.
ENDFORM. " BUILD_ALV
*& Form GET_DATA
text
FORM GET_DATA .
SELECT A~MATNR
B~MAKTX
C~WERKS
C~LGORT
C~LABST
INTO TABLE IT_MARA
FROM MARA AS A
INNER JOIN MAKT AS B
ON BMATNR = AMATNR
INNER JOIN MARD AS C
ON CMATNR = AMATNR
WHERE A~MATNR IN S_MATNR
AND B~SPRAS = SY-LANGU.
ENDFORM. " GET_DATA
*& Form GENERATE_FLDCAT
text
FORM GENERATE_FLDCAT .
*CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_BUFFER_ACTIVE =
I_STRUCTURE_NAME = 'ZSMARA'
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER =
I_INTERNAL_TABNAME = ' '
CHANGING
CT_FIELDCAT = IT_FLDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
X_FLDCAT-COL_POS = 1.
X_FLDCAT-FIELDNAME = 'MATNR'.
X_FLDCAT-OUTPUTLEN = '18'.
X_FLDCAT-REPTEXT = 'Material No'.
APPEND X_FLDCAT TO IT_FLDCAT.
X_FLDCAT-COL_POS = 2.
X_FLDCAT-FIELDNAME = 'MAKTX'.
X_FLDCAT-OUTPUTLEN = '48'.
X_FLDCAT-REPTEXT = 'Material Desc'.
X_FLDCAT-TOOLTIP = 'Material Desc'.
APPEND X_FLDCAT TO IT_FLDCAT.
X_FLDCAT-COL_POS = 3.
X_FLDCAT-FIELDNAME = 'WERKS'.
X_FLDCAT-OUTPUTLEN = '5'.
X_FLDCAT-REPTEXT = 'Plant'.
X_FLDCAT-TOOLTIP = 'Plant'.
APPEND X_FLDCAT TO IT_FLDCAT.
X_FLDCAT-COL_POS = 4.
X_FLDCAT-FIELDNAME = 'LGORT'.
X_FLDCAT-OUTPUTLEN = '5'.
X_FLDCAT-REPTEXT = 'S.Loc'.
X_FLDCAT-TOOLTIP = 'S.Loc'.
APPEND X_FLDCAT TO IT_FLDCAT.
X_FLDCAT-COL_POS = 5.
X_FLDCAT-FIELDNAME = 'LABST'.
X_FLDCAT-OUTPUTLEN = '20'.
X_FLDCAT-REPTEXT = 'Quantity'.
X_FLDCAT-TOOLTIP = 'Quantity'.
X_FLDCAT-DO_SUM = 'X'.
APPEND X_FLDCAT TO IT_FLDCAT.
ENDFORM. " GENERATE_FLDCAT
*& Form GENERATE_LAYOUT
text
FORM GENERATE_LAYOUT .
I_LAYOUT-ZEBRA = 'X'.
I_LAYOUT-FRONTEND = 'X'.
I_LAYOUT-GRID_TITLE = 'ALV GRID USING OOPS'.
I_LAYOUT-NUMC_TOTAL = 'X'.
ENDFORM. " GENERATE_LAYOUT
*& Form DO_SORT
text
FORM DO_SORT .
X_SORT-FIELDNAME = 'MATNR'.
X_SORT-UP = 'X'.
X_SORT-SUBTOT = 'X'.
IF P_CHK = 'X'.
X_SORT-EXPA = SPACE.
ELSE.
X_SORT-EXPA = 'X'.
ENDIF.
APPEND X_SORT TO I_SORT.
ENDFORM. " DO_SORT
inorder to execute this code perfectly, do the following things.
1. Create a Graphical Screen 100.
2. Place a Custom Control on that screen and give name as MAT_CONTAINER.
3. activate the screen.
and execute the program.
if this suits requirement award points.
satish -
Toolbar in alv display using oops alv
i have written code for displaying toolbar in alv display using oops, but it is not displaying please find the below code and let me know reason.
*& Report ZTRANSFER_ORDER2 *
REPORT ZTRANSFER_ORDER2 .
*& Report ZTRANSFER_ORDER *
TABLES:sflight.
TYPE-POOLS : icon.
* G L O B A L I N T E R N A L T A B L E S
CLASS lcl_event_receiver DEFINITION DEFERRED.
types : begin of ty_mara,
matnr type matnr,
mtart type mtart,
mbrsh type mbrsh,
matkl type matkl,
bismt type bismt,
meins type meins,
end of ty_mara.
DATA: t_mara type STANDARD TABLE OF ty_mara.
* G L O B A L D A T A
DATA: ok_code LIKE sy-ucomm,
g_wa_mara type ty_mara.
DATA : t_fcat type LVC_T_FCAT.
DATA : l_VAR TYPE disvariant.
DATA : gs_layout type lvc_s_layo.
* Declare reference variables to the ALV grid and the container
G L O B A L D A T A
DATA: ok_code LIKE sy-ucomm.
Declare reference variables to the ALV grid and the container
DATA:
go_grid TYPE REF TO cl_gui_alv_grid,
go_custom_container TYPE REF TO cl_gui_custom_container.
data : it_toolbar TYPE stb_button,
event_receiver TYPE REF TO lcl_event_receiver.
* S T A R T - O F - S E L E C T I O N.
START-OF-SELECTION.
CALL SCREEN 100 .
*CLASS lcl_event_receiver DEFINITION.
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
*handling toolbar for interactive
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
*handling menu button
handle_menu_button
FOR EVENT menu_button OF cl_gui_alv_grid
IMPORTING e_object e_ucomm,
*On click of the menu button
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
PRIVATE SECTION.
ENDCLASS.
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
handle toolbar
CLEAR it_toolbar.
MOVE 'DETAIL' TO it_toolbar-function.
MOVE icon_detail TO it_toolbar-icon.
MOVE 2 TO it_toolbar-butn_type.
APPEND it_toolbar TO e_object->mt_toolbar.
ENDMETHOD. "handle_toolbar
METHOD handle_menu_button.
handle own menubuttons
IF e_ucomm = 'DETAIL'.
CALL METHOD e_object->add_function
EXPORTING
fcode = 'DISPLAY'
text = 'DISPLAY'.
ENDIF.
ENDMETHOD. "handle_menu_button
METHOD handle_user_command.
*On click
CASE e_ucomm.
WHEN 'DISPLAY'.
MESSAGE 'Menu Clicked' TYPE 'I'.
ENDCASE.
ENDMETHOD. "handle_user_command
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
*& Module USER_COMMAND_0100 INPUT
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Module STATUS_0100 OUTPUT
MODULE status_0100 OUTPUT.
sET PF-STATUS 'STATUS'.
Create objects
IF go_custom_container IS INITIAL.
CREATE OBJECT go_custom_container
EXPORTING container_name = 'ALV_CONTAINER'.
CREATE OBJECT go_grid
EXPORTING
i_parent = go_custom_container.
PERFORM load_data_into_grid.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Form load_data_into_grid
FORM load_data_into_grid.
Read data from table SFLIGHT
SELECT matnr mtart mbrsh matkl bismt meins
FROM mara
INTO corresponding fields of TABLE t_mara.
PERFORM fld_cate changing T_fcat.
l_var-report = sy-repid.
gs_layout-grid_title = 'Analysis Report'.
gs_layout-NO_TOOLBAR = 'X'.
gs_layout-BOX_FNAME = 'Selection'.
Load data into the grid and display them
caLL METHOD go_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'S_MVKE'
i_save = 'A'
is_variant = l_var
is_layout = gs_layout
CHANGING
it_outtab = t_mara[]
it_fieldcatalog = t_fcat.
endform.
*& Module pai INPUT
text
MODULE pai INPUT.
data: l_valid type c.
clear ok_code.
break-point.
ok_code = sy-ucomm.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'BACK'.
call method go_grid->check_changed_data
importing
e_valid = l_valid.
loop at t_mara into g_wa_mara.
endloop.
ENDCASE.
ENDMODULE. " pai INPUT
*& Form fld_cate
text
<--P_T_FCAT text
FORM fld_cate CHANGING P_T_FCAT TYPE lvc_t_fcat.
DATA : s_fcat type LVC_S_FCAT .
REFRESH: t_fcat.
CLEAR s_fcat.
s_fcat-fieldname = 'BOX1'.
s_fcat-coltext = 'Box1'.
s_fcat-seltext = 'Box1'.
s_fcat-CHECKBOX = 'X'.
s_fcat-EDIT = 'X'.
APPEND s_fcat TO P_T_FCAT.
CLEAR s_fcat.
s_fcat-row_pos = 1.
s_fcat-col_pos = 1.
s_fcat-fieldname = 'MATNR'.
s_fcat-ref_field = 'MATNR'.
s_fcat-ref_table = 'T_MARA'.
s_fcat-coltext = 'Material'.
s_fcat-seltext = 'Material'.
s_fcat-EDIT = 'X'.
APPEND s_fcat TO P_T_FCAT.
CLEAR s_fcat.
s_fcat-row_pos = 2.
s_fcat-col_pos = 2.
s_fcat-fieldname = 'MTART'.
s_fcat-ref_field = 'MTART'.
s_fcat-ref_table = 'T_MARA'.
s_fcat-coltext = 'Material type'.
s_fcat-seltext = 'Material type'.
APPEND s_fcat TO P_T_FCAT.
CLEAR s_fcat.
s_fcat-fieldname = 'BOX2'.
s_fcat-coltext = 'Box2'.
s_fcat-seltext = 'Box2'.
s_fcat-CHECKBOX = 'X'.
s_fcat-EDIT = 'X'.
APPEND s_fcat TO P_T_FCAT.
CLEAR s_fcat.
s_fcat-row_pos = 3.
s_fcat-col_pos = 3.
s_fcat-fieldname = 'MBRSH'.
s_fcat-ref_field = 'MBRSH'.
s_fcat-ref_table = 'T_MARA'.
s_fcat-coltext = 'Industry Sector'.
s_fcat-seltext = 'Industry Sector'.
APPEND s_fcat TO P_T_FCAT.
CLEAR s_fcat.
s_fcat-row_pos = 4.
s_fcat-col_pos = 4.
s_fcat-fieldname = 'MATKL'.
s_fcat-ref_field = 'MATKL'.
s_fcat-ref_table = 'T_MARA'.
s_fcat-coltext = 'Material Group'.
s_fcat-seltext = 'Material Group'.
APPEND s_fcat TO P_T_FCAT.
CLEAR s_fcat.
s_fcat-row_pos = 5.
s_fcat-col_pos = 5.
s_fcat-fieldname = 'BISMT'.
s_fcat-ref_field = 'BISMT'.
s_fcat-ref_table = 'T_MARA'.
s_fcat-coltext = 'Old material number'.
s_fcat-seltext = 'Old material number'.
APPEND s_fcat TO P_T_FCAT.
CLEAR s_fcat.
s_fcat-row_pos = 6.
s_fcat-col_pos = 6.
s_fcat-fieldname = 'MEINS'.
s_fcat-ref_field = 'MEINS'.
s_fcat-ref_table = 'T_MARA'.
s_fcat-coltext = 'Base Unit of Measure'.
s_fcat-seltext = 'Base Unit of Measure'.
APPEND s_fcat TO P_T_FCAT.
CLEAR s_fcat.
s_fcat-fieldname = 'BOX3'.
s_fcat-coltext = 'Box3'.
s_fcat-seltext = 'Box3'.
s_fcat-CHECKBOX = 'X'.
s_fcat-EDIT = 'X'.
APPEND s_fcat TO P_T_FCAT.
ENDFORM. " fld_cate .MOVE 2 TO it_toolbar-butn_type.
Try changing the 2 (menu) to 0 (button) and see if that helps
also you need to set the event handler after you create your alv object
set handler handle_toolbar for [whatever object is called].
Edited by: Kev Mycock on Jul 24, 2008 7:59 AM -
ALV report using OOPS concept.
Hi,
Please help me in writing ALV report using OOPS concept as i have never used this concept before.Please post a clear picture for this.
Thanks in advance.Hi
Refer this code:
REPORT zcls_alv_oops MESSAGE-ID z1.
TABLES : mara.
Types Declaration..\
TYPES :
BEGIN OF t_mara,
matnr TYPE matnr,
mtart TYPE mtart,
maktx TYPE maktx,
END OF t_mara,
BEGIN OF t_marc,
matnr TYPE matnr,
werks TYPE werks_d,
mtart TYPE mtart,
maktx TYPE maktx,
END OF t_marc.
Internal Tables Declaration..\
DATA :
i_mara TYPE TABLE OF t_mara,
i_marc TYPE TABLE OF t_marc,
i_fcat1 TYPE lvc_t_fcat,
i_fcat2 TYPE lvc_t_fcat.
Constants Declaration..\
CONSTANTS :
c_cont1 TYPE scrfname VALUE 'CONT1',
c_cont2 TYPE scrfname VALUE 'CONT2'.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
SELECT-OPTIONS:
s_matnr FOR mara-matnr NO INTERVALS.
SELECTION-SCREEN SKIP 1.
PARAMETERS :
p_hotspt RADIOBUTTON GROUP r1 DEFAULT 'X',
p_bttn RADIOBUTTON GROUP r1.
SELECTION-SCREEN END OF BLOCK b1.
\* Class forward referncing.
CLASS lcl_rcvr_class DEFINITION DEFERRED.
\* Pointers Declaration..
DATA :
lp_rcvr TYPE REF TO lcl_rcvr_class,
lp_cont1 TYPE REF TO cl_gui_custom_container,
lp_cont2 TYPE REF TO cl_gui_custom_container,
lp_grid1 TYPE REF TO cl_gui_alv_grid,
lp_grid2 TYPE REF TO cl_gui_alv_grid.
\* Local Class Definiton.
CLASS lcl_rcvr_class DEFINITION.
PUBLIC SECTION.
METHODS :
hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no,
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
ENDCLASS.
\* Local Class Implementation.
CLASS lcl_rcvr_class IMPLEMENTATION.
METHOD hotspot_click.
DATA :
wa_mara TYPE t_mara,
wa_marc TYPE t_marc.
DATA :
l_index TYPE sy-tabix.
READ TABLE i_mara INTO wa_mara INDEX e_row_id-index.
IF sy-subrc EQ 0.
REFRESH i_marc.
SELECT matnr
werks
INTO TABLE i_marc
FROM marc
WHERE matnr EQ wa_mara-matnr.
IF sy-subrc EQ 0.
LOOP AT i_marc INTO wa_marc.
l_index = sy-tabix.
wa_marc-mtart = wa_mara-mtart.
wa_marc-maktx = wa_mara-maktx.
MODIFY i_marc FROM wa_marc INDEX l_index
TRANSPORTING mtart maktx.
ENDLOOP.
CALL SCREEN 200.
ELSE.
MESSAGE e121 WITH text-005 wa_mara-matnr.
ENDIF.
ENDIF.
ENDMETHOD.
METHOD handle_double_click.
DATA :
wa_mara TYPE t_mara,
wa_marc TYPE t_marc.
DATA :
l_index TYPE sy-tabix.
READ TABLE i_mara INTO wa_mara INDEX e_row-index.
IF sy-subrc EQ 0.
REFRESH i_marc.
SELECT matnr
werks
INTO TABLE i_marc
FROM marc
WHERE matnr EQ wa_mara-matnr.
IF sy-subrc EQ 0.
LOOP AT i_marc INTO wa_marc.
l_index = sy-tabix.
wa_marc-mtart = wa_mara-mtart.
wa_marc-maktx = wa_mara-maktx.
MODIFY i_marc FROM wa_marc INDEX l_index
TRANSPORTING mtart maktx.
ENDLOOP.
CALL SCREEN 200.
ELSE.
MESSAGE e121 WITH text-005 wa_mara-matnr.
ENDIF.
ENDIF.
ENDMETHOD.
ENDCLASS.
\* Start of Selection
START-OF-SELECTION.
\* Extract the Material Master data for the Input Material.
SELECT a~matnr
a~mtart
b~maktx
INTO TABLE i_mara
FROM mara AS a
INNER JOIN makt AS b
ON a~matnr EQ b~matnr
WHERE a~matnr IN s_matnr
AND b~spras EQ sy-langu.
END-OF-SELECTION.
IF NOT i_mara\[\] IS INITIAL.
\* Call Screen to display the Material Master data.
CALL SCREEN 100.
ELSE.
MESSAGE s121 WITH text-006.
ENDIF.
\*& Module DISP_GRID OUTPUT
\* text
MODULE disp_grid OUTPUT.
\* Build the Field catelog for Material Master data.
PERFORM build_fcat.
\* Display the Material Master data using ALV.
PERFORM disp_alv.
ENDMODULE. " DISP_GRID OUTPUT
\*& Module USER_COMMAND_0100 INPUT
\* text
MODULE user_command_0100 INPUT.
\*when exit or cancel is clicked program has to come out
CASE sy-ucomm.
WHEN 'EXIT' OR 'CANC'.
LEAVE PROGRAM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
\*& Form build_fcat
\* text
\* \--> p1 text
\* <-\- p2 text
FORM build_fcat.
DATA : ws_fcat TYPE lvc_s_fcat.
ws_fcat-fieldname = 'MATNR'.
ws_fcat-scrtext_m = text-001.
ws_fcat-tabname = 'I_MARA'.
IF p_hotspt EQ 'X'.
ws_fcat-hotspot = 'X'.
ENDIF.
APPEND ws_fcat TO i_fcat1.
CLEAR ws_fcat.
ws_fcat-fieldname = 'MTART'.
ws_fcat-scrtext_m = text-002.
ws_fcat-tabname = 'I_MARA'.
APPEND ws_fcat TO i_fcat1.
CLEAR ws_fcat.
ws_fcat-fieldname = 'MAKTX'.
ws_fcat-scrtext_m = text-003.
ws_fcat-tabname = 'I_MARA'.
APPEND ws_fcat TO i_fcat1.
CLEAR ws_fcat.
ENDFORM. " build_fcat
\*& Form disp_alv
\* text
\* \--> p1 text
\* <-\- p2 text
FORM disp_alv.
IF lp_cont1 IS INITIAL.
\* Create the Container Object of Material Master.
CREATE OBJECT lp_cont1
EXPORTING
container_name = c_cont1
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6 .
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
\* Create the Object for Grid of Material Master.
CREATE OBJECT lp_grid1
EXPORTING
i_parent = lp_cont1
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
\* Dipslay Material Master data by calling method.
CALL METHOD lp_grid1->set_table_for_first_display
CHANGING
it_outtab = i_mara
it_fieldcatalog = i_fcat1
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
\* Set Handler for the Hot Spot Event.
CREATE OBJECT lp_rcvr.
IF p_hotspt EQ 'X'.
SET HANDLER lp_rcvr->hotspot_click FOR lp_grid1.
ELSE.
SET HANDLER lp_rcvr->handle_double_click FOR lp_grid1.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " disp_alv
\*& Module STATUS_0100 OUTPUT
\* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MAIN_STAT'.
SET TITLEBAR 'T_100'.
ENDMODULE. " STATUS_0100 OUTPUT
\*& Module STATUS_0200 OUTPUT
\* text
MODULE status_0200 OUTPUT.
SET PF-STATUS 'PLANT_STAT'.
SET TITLEBAR 'T_200'.
ENDMODULE. " STATUS_0200 OUTPUT
\*& Module DISP_GRID_plant OUTPUT
\* text
MODULE disp_grid_plant OUTPUT.
\* Build the Field catelog for Material Plant data.
PERFORM build_fcat_plant.
\* Display the Material Master Plant data using ALV.
PERFORM disp_alv_plant.
ENDMODULE. " DISP_GRID_plant OUTPUT
\*& Module USER_COMMAND_0200 INPUT
\* text
MODULE user_command_0200 INPUT.
\*when exit or cancel is clicked program has to come out
CASE sy-ucomm.
WHEN 'EXIT' OR 'CANC'.
LEAVE PROGRAM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0200 INPUT
\*& Form build_fcat_plant
\* text
\* \--> p1 text
\* <-\- p2 text
FORM build_fcat_plant.
DATA : ws_fcat TYPE lvc_s_fcat.
ws_fcat-fieldname = 'MATNR'.
ws_fcat-scrtext_m = text-001.
ws_fcat-tabname = 'I_MARC'.
APPEND ws_fcat TO i_fcat2.
CLEAR ws_fcat.
ws_fcat-fieldname = 'WERKS'.
ws_fcat-scrtext_m = text-004.
ws_fcat-tabname = 'I_MARC'.
APPEND ws_fcat TO i_fcat2.
CLEAR ws_fcat.
ws_fcat-fieldname = 'MTART'.
ws_fcat-scrtext_m = text-002.
ws_fcat-tabname = 'I_MARC'.
APPEND ws_fcat TO i_fcat2.
CLEAR ws_fcat.
ws_fcat-fieldname = 'MAKTX'.
ws_fcat-scrtext_m = text-003.
ws_fcat-tabname = 'I_MARC'.
APPEND ws_fcat TO i_fcat2.
CLEAR ws_fcat.
ENDFORM. " build_fcat_plant
\*& Form disp_alv_plant
\* text
\* \--> p1 text
\* <-\- p2 text
FORM disp_alv_plant.
IF lp_cont2 IS INITIAL.
\* Create the Container Object of Material Plant data.
CREATE OBJECT lp_cont2
EXPORTING
container_name = c_cont2
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
\* Create the Object for Grid of Material Plant data.
CREATE OBJECT lp_grid2
EXPORTING
i_parent = lp_cont2
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
\* Dipslay Material Plant data by calling method.
CALL METHOD lp_grid2->set_table_for_first_display
CHANGING
it_outtab = i_marc
it_fieldcatalog = i_fcat2
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDIF.
ELSE.
\* Call method 'REFRESH_TABLE_DISPLAY' to refresh the grid data.
CALL METHOD lp_grid2->refresh_table_display.
ENDIF.
ENDFORM. " disp_alv_plant
Thanks
Vasudha -
Attaining Hot spot in ALV Tree Using OOPS concept
Hi All,
In our requirement we are displaying the data in ALV Tree Using OOPS.
We need to achieve hot spot on one of the header field.
I am using Class 'CL_GUI_ALV_TREE'
Ex:
CreditAccnt/ Company codes DSO DDSO
26 15 15
8000 5 5
8545 10 10
In the above example for every credit accnt in header we r displaying the values ( DSO ,DDSO) for all company codes.
Now we require hot spot on Credit Accnt 26. Such that when user clicks on the credit accnt it should navigate to another transaction.
NOTE: we havent build any field catalogue for field CreditAccnt/ Company codes .Hi,
You can refer to the tutorial -
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/an%20easy%20reference%20for%20alv%20grid%20control.pdf
Or try using the code below-
CLASS lcl_event_receiver DEFINITION
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
Hot Spot Click
handle_hotspot
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id
e_column_id
es_row_no,
ENDCLASS.
Implementation
*& Method handle_hotspot
This method is called when the user clicks on a hotspot to drill down.
The following types are exported from the ALV
LVC_S_ROW
LVC_S_COL
LVC_S_ROID
METHOD handle_hotspot.
The hotspot processing coded in the form below.
PERFORM f9802_handle_hotspot USING e_row_id
e_column_id
es_row_no.
ENDMETHOD.
*& Form f9802_handle_hotspot
This form is called when the user clicks on a hotspot on the ALV grid
The parameters are of type
-->P_E_ROW text
-->P_E_COL text
-->P_E_ROID text
FORM f9802_handle_hotspot USING p_row
p_col
p_roid.
DATA: lw_output LIKE LINE OF i_output.
READ TABLE i_output INDEX p_row INTO lw_output.
SET PARAMETER ID 'MAT' FIELD lw_output-matnr.
CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
ENDFORM. " f9802_handle_hotspot
FORM f9300_modify_field_cat TABLES p_fieldcat STRUCTURE lvc_s_fcat.
Field-symbols: <lfs_fieldcat> TYPE lvc_s_fcat.
LOOP AT p_fieldcat ASSIGNING <lfs_fieldcat>.
CASE <lfs_fieldcat>-fieldname.
WHEN 'MATNR'.
<lfs_fieldcat>-hotspot = c_x.
<lfs_fieldcat>-key = c_x.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
ENDFORM.
In PBO,
module STATUS_9001 output.
Set handlers for events
SET HANDLER o_eventreceiver->handle_hotspot FOR o_Alvgrid.
ENDMODULE.
Hope this helps -
F4 help in ALV grid using existing search help
Hi All,
It would be appreciable , if some help on problem. Thanks in advance.
How to provide user defined F4 help in ALV grid using existing search help?
ALV grid has developed using OOPS concept.
Thanks,
Sudhakar.Hi,
if you already developed using OO concept, it should be possible to:
create a handler for event ONF4
The interface will tell you actual field name and value where F4 is pressed. This will enable you to call your own routine (see FM F4-IF....).
Please check how the standard handles F4 - if you have standard and customer-F4 mixed you shouldtake care that the standard handling is triggered.
Regards,
Clemens
Maybe you are looking for
-
Can i roll back to Acrobat 9 Standard from Acrobat X Standard?
Can i roll back to Acrobat 9 Standard from Acrobat X Standard? I bought Acrobat X license and want to roll back to 9. Thanks in advance.
-
Compressor help needed.
Well compressor first of all used to be working just fine. The problem is that now when i do a video in Final Cut Pro5 and export using compressor, the compression takes forever? An hour and a half video exported at 6.2mbps to a .m2v took about 10 ho
-
I have a Sony 5.1 Ch. Home Theater System hooked up to my iMac with a HDMI to Mini Displayport cable. My iMac is outputting surround sound just fine. I was just wondering what is the difference between using the Mini Displayport for surroud sound aud
-
Mac Mini W/ DVI Projector???
I'm Interested in getting a DVI projector to use with my Mac mini. Is this possible? any suggestions?
-
What is root level of backup drive
I have instructions to transfer backups from current backup drive to new backup drive. It says to drag the current backup drive to the ROOT LEVEL of the new backup drive. What is the root level? Thanks, Kathy