Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to create ALV using Methods(oo)

Former Member
0 Likes
937

Hi,

How to create ALV using Methods(oo) and where do i go to start developing an alv report.

Thanks

pc

1 ACCEPTED SOLUTION
Read only

amit_khare
Active Contributor
0 Likes
885

Welcome to SDN.

Reports are cretaed using SE38 or SE80 only.

For reference on OO ALV check BCALV* reports in SE38 they are the best provided samples.

Check following threads also -

Regards,

Amit

Reward all helpful replies.

8 REPLIES 8
Read only

amit_khare
Active Contributor
0 Likes
886

Welcome to SDN.

Reports are cretaed using SE38 or SE80 only.

For reference on OO ALV check BCALV* reports in SE38 they are the best provided samples.

Check following threads also -

Regards,

Amit

Reward all helpful replies.

Read only

Former Member
0 Likes
885

this sample program would be helpful you to understand OOABAP ALV .

go through this line by line.

TYPE-POOLS: icon.

TABLES: zsflight.

  • To allow the declaration of o_event_receiver before the

  • lcl_event_receiver class is defined, decale it as deferred in the

  • start of the program

CLASS lcl_event_receiver DEFINITION DEFERRED.

*----


  • G L O B A L I N T E R N A L T A B L E S

*----


*DATA: gi_sflight TYPE STANDARD TABLE OF sflight.

  • To include a traffic light and/or color a line the structure of the

  • table must include fields for the traffic light and/or the color

TYPES: BEGIN OF st_sflight.

INCLUDE STRUCTURE zsflight.

  • Field for traffic light

TYPES: traffic_light TYPE c.

  • Field for line color

TYPES: c_check TYPE lvc_checkb.

TYPES: line_color(4) TYPE c.

TYPES: carrid_handle TYPE int4,

ptype_dd_hndl TYPE int4,

ptype_dd_hndl1 TYPE int4.

TYPES: END OF st_sflight.

TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight.

DATA: gi_sflight TYPE tt_sflight.

DATA: gt_exclude TYPE ui_functions,

gt_fieldcat TYPE lvc_t_fcat,

gt_hype TYPE lvc_t_hype,

gt_drdp TYPE lvc_t_drop.

  • For top of page event.

DATA: text(255) TYPE c. "sdydo_text_element.

DATA: o_dd_doc TYPE REF TO cl_dd_document.

DATA: o_split TYPE REF TO cl_gui_easy_splitter_container .

DATA: o_split1 TYPE REF TO cl_gui_easy_splitter_container .

DATA: o_top TYPE REF TO cl_gui_container,

o_bot TYPE REF TO cl_gui_container,

o_top1 TYPE REF TO cl_gui_container,

o_bot1 TYPE REF TO cl_gui_container.

TYPE-POOLS: slis.

*DATA: text like SDYDO_TEXT_ELEMENT.

  • End top of page variables.

**----


  • * G L O B A L D A T A

**----


DATA: ok_code LIKE sy-ucomm,

  • * Work area for internal table

g_wa_sflight TYPE st_sflight,

g_wa_sflight1 TYPE st_sflight,

  • * ALV control: Layout structure

gs_layout TYPE lvc_s_layo.

  • * 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,

go_er_data_changed TYPE REF TO cl_alv_changed_data_protocol,

o_event_receiver TYPE REF TO lcl_event_receiver.

DATA:

  • * Work area for screen 200

g_screen200 LIKE zsflight.

  • * Data for storing information about selected rows in the grid

DATA:

  • * Internal table

gi_index_rows TYPE lvc_t_row,

  • * Information about 1 row

g_selected_row LIKE lvc_s_row.

**----


  • * C L A S S E S

**----


CLASS lcl_event_receiver DEFINITION.

PUBLIC SECTION.

METHODS:

handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid

IMPORTING

e_object e_interactive,

handle_user_command FOR EVENT user_command OF cl_gui_alv_grid

IMPORTING e_ucomm,

handle_double_click FOR EVENT double_click OF cl_gui_alv_grid

IMPORTING e_row e_column es_row_no,

handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid

IMPORTING er_data_changed,

handle_top_of_page FOR EVENT top_of_page OF cl_gui_alv_grid

IMPORTING e_dyndoc_id.

ENDCLASS. "lcl_event_receiver DEFINITION

*----


  • * CLASS lcl_event_receiver IMPLEMENTATION

*----


CLASS lcl_event_receiver IMPLEMENTATION.

METHOD handle_data_changed.

call method go_grid->check_changed_data.

ENDMETHOD. "handle_data_changed

METHOD handle_toolbar.

  • * Event handler method for event toolbar.

CONSTANTS:

  • * Constants for button type

c_button_normal TYPE i VALUE 0,

c_menu_and_default_button TYPE i VALUE 1,

c_menu TYPE i VALUE 2,

c_separator TYPE i VALUE 3,

c_radio_button TYPE i VALUE 4,

c_checkbox TYPE i VALUE 5,

c_menu_entry TYPE i VALUE 6.

DATA:

ls_toolbar TYPE stb_button.

  • Append separator to the normal toolbar

  • CLEAR LS_TOOLBAR.

  • MOVE C_SEPARATOR TO LS_TOOLBAR-BUTN_TYPE.

  • APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.

  • * Append a new button that to the toolbar. Use E_OBJECT of

  • * event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.

  • * This class has one attribute MT_TOOLBAR which is of table type

  • * TTB_BUTTON. The structure is STB_BUTTON

CLEAR ls_toolbar.

MOVE 'CHANGE' TO ls_toolbar-function.

MOVE icon_change TO ls_toolbar-icon.

MOVE c_radio_button TO ls_toolbar-butn_type.

MOVE 'Change flight' TO ls_toolbar-quickinfo.

MOVE 'Change' TO ls_toolbar-text.

MOVE ' ' TO ls_toolbar-disabled.

APPEND ls_toolbar TO e_object->mt_toolbar.

ENDMETHOD. "handle_toolbar

METHOD handle_user_command.

  • * Handle own functions defined in the toolbar

CASE e_ucomm.

WHEN 'CHANGE'.

PERFORM change_flight.

  • * LEAVE TO SCREEN 0.

ENDCASE.

ENDMETHOD. "handle_user_command

METHOD handle_double_click.

  • * Handle double click function

PERFORM change_flight.

ENDMETHOD. "HANDLE_DOUBLE_CLICK

METHOD handle_top_of_page.

text = 'Classification Offers'.

CALL METHOD e_dyndoc_id->add_text

EXPORTING

text = text

sap_fontsize = 'LARGE'

sap_style = 'HEADING'.

CALL METHOD e_dyndoc_id->display_document

EXPORTING

parent = o_top1.

ENDMETHOD. "handle_top_of_page

ENDCLASS. "lcl_event_receiver IMPLEMENTATION

**----


  • * S T A R T - O F - S E L E C T I O N.

**----


START-OF-SELECTION.

  • BREAK-POINT.

SET SCREEN '100'.

**&----


**

  • *& Module USER_COMMAND_0100 INPUT

**&----


**

MODULE user_command_0100 INPUT.

CASE sy-ucomm.

WHEN 'BACK' .

LEAVE TO SCREEN 0.

WHEN 'CANCEL' .

LEAVE PROGRAM.

WHEN 'EXIT' .

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

**&----


**

  • *& Module STATUS_0100 OUTPUT

**&----


**

MODULE status_0100 OUTPUT.

DATA:

    • For parameter IS_VARIANT that is sued to set up options for storing

    • the grid layout as a variant in method set_table_for_first_display

l_layout TYPE disvariant,

  • * Utillity field

l_lines TYPE i.

  • * After returning from screen 200 the line that was selected before

    • going to screen 200, should be selected again. The table

*gi_index_rows

  • * was the output table from the GET_SELECTED_ROWS method in form

  • * CHANGE_FLIGHT

DESCRIBE TABLE gi_index_rows LINES l_lines.

IF l_lines > 0.

CALL METHOD go_grid->set_selected_rows

EXPORTING

it_index_rows = gi_index_rows.

CALL METHOD cl_gui_cfw=>flush.

REFRESH gi_index_rows.

ENDIF.

SET PF-STATUS 'OOABAP'.

SET TITLEBAR 'AMIT' WITH 'OOABAP' 'Events'.

  • * Read data and create objects

IF go_custom_container IS INITIAL.

  • * Read data from datbase table

PERFORM get_data.

PERFORM fieldcatalog_build CHANGING gt_fieldcat.

PERFORM hyperlink CHANGING gt_hype.

  • * Create objects for container and ALV grid

CREATE OBJECT go_custom_container

EXPORTING container_name = 'ALV_CONTAINER'.

CREATE OBJECT go_grid

EXPORTING

i_parent = go_custom_container.

  • * Create object for event_receiver class

  • * and set handlers

CREATE OBJECT o_event_receiver.

SET HANDLER o_event_receiver->handle_user_command FOR go_grid.

SET HANDLER o_event_receiver->handle_toolbar FOR go_grid.

SET HANDLER o_event_receiver->handle_double_click FOR go_grid.

SET HANDLER o_event_receiver->handle_data_changed FOR go_grid.

SET HANDLER o_event_receiver->handle_top_of_page FOR go_grid.

  • SET HANDLER o_event_receiver->on_f4 FOR go_grid.

  • * Layout (Variant) for ALV grid

l_layout-report = sy-repid. "Layout fo report

  • *---------------------------------------------------------------

  • * Setup the grid layout using a variable of structure lvc_s_layo

  • *---------------------------------------------------------------

  • * Set grid title

gs_layout-grid_title = 'Flights'.

  • * Selection mode - Single row without buttons

  • * (This is the default mode

gs_layout-sel_mode = 'A'.

  • gs_layout-cwidth_opt = 'X'.

  • * Name of the exception field (Traffic light field) and the color

  • * field + set the exception and color field of the table

gs_layout-excp_fname = 'TRAFFIC_LIGHT'.

gs_layout-info_fname = 'LINE_COLOR'.

LOOP AT gi_sflight INTO g_wa_sflight.

IF g_wa_sflight-paymentsum < 100000.

  • * Value of traffic light field

g_wa_sflight-traffic_light = '1'.

  • * Value of color field:

  • * C = Color, 6=Color 1=Intesified on, 0: Inverse display off

g_wa_sflight-line_color = 'C610'.

ELSEIF g_wa_sflight-paymentsum => 100000 AND

g_wa_sflight-paymentsum < 1000000.

g_wa_sflight-traffic_light = '2'.

g_wa_sflight-line_color = 'C710'.

ELSE.

g_wa_sflight-traffic_light = '3'.

g_wa_sflight-line_color = 'C510'.

ENDIF.

MODIFY gi_sflight FROM g_wa_sflight.

ENDLOOP.

PERFORM exclude_toolbar_buttons CHANGING gt_exclude.

PERFORM drildown_list CHANGING gt_drdp.

  • PERFORM f_help.

LOOP AT gi_sflight INTO g_wa_sflight1 WHERE connid = '454'.

g_wa_sflight1-ptype_dd_hndl = 7.

  • g_wa_sflight1-PTYPE_DD_HNDL1 = 2.

MODIFY gi_sflight FROM g_wa_sflight1 INDEX sy-tabix

TRANSPORTING ptype_dd_hndl .

ENDLOOP.

CALL METHOD go_grid->set_drop_down_table

EXPORTING

it_drop_down = gt_drdp

  • IT_DROP_DOWN_ALIAS = GT_DRDP

.

  • * Grid setup for first display

CALL METHOD go_grid->set_table_for_first_display

EXPORTING

  • I_STRUCTURE_NAME = 'SFLIGHT'

is_variant = l_layout

i_save = 'A'

i_default = 'X'

is_layout = gs_layout

it_toolbar_excluding = gt_exclude

it_hyperlink = gt_hype

CHANGING

it_outtab = gi_sflight

it_fieldcatalog = gt_fieldcat

.

  • *-- End of grid setup -------------------------------------------

  • Raise event toolbar to show the modified toolbar

CALL METHOD go_grid->set_toolbar_interactive.

  • * Set focus to the grid. This is not necessary in this

  • * example as there is only one control on the screen

CALL METHOD cl_gui_control=>set_focus

EXPORTING

control = go_grid.

ELSE.

CALL METHOD go_grid->refresh_table_display.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

**&----


**

  • *& Module USER_COMMAND_0200 INPUT

**&----


**

  • * text

**----


**

MODULE user_command_0200 INPUT.

CASE sy-ucomm.

WHEN 'EXIT200'.

LEAVE TO SCREEN 100.

WHEN'SAVE'.

PERFORM save_changes.

ENDCASE.

ENDMODULE. " USER_COMMAND_0200 INPUT

**&----


**

  • *& Form get_data

**&----


**

  • * text

**----


**

FORM get_data.

  • * Read data from table SFLIGHT

SELECT *

FROM zsflight

INTO CORRESPONDING FIELDS OF TABLE gi_sflight.

ENDFORM. " load_data_into_grid

**&----


**

  • *& Form change_flight

**&----


**

  • * Reads the contents of the selected row in the grid, ans transfers

  • * the data to screen 200, where it can be changed and saved.

**----


**

FORM change_flight.

DATA:l_lines TYPE i.

DATA: lt_fcat TYPE lvc_t_fcat,

ls_fcat TYPE lvc_s_fcat,

ls_layout TYPE lvc_s_layo.

REFRESH gi_index_rows.

CLEAR g_selected_row.

  • * Read index of selected rows

CALL METHOD go_grid->get_selected_rows

IMPORTING

et_index_rows = gi_index_rows.

  • * Check if any row are selected at all. If not

  • * table gi_index_rows will be empty

DESCRIBE TABLE gi_index_rows LINES l_lines.

IF l_lines = 0.

CALL METHOD go_grid->get_frontend_fieldcatalog

IMPORTING

et_fieldcatalog = gt_fieldcat[].

CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'

EXPORTING

textline1 = 'You must choose a line'.

LOOP AT gt_fieldcat INTO ls_fcat .

IF ls_fcat-fieldname = 'CONNID'.

ls_fcat-no_out = 'X'.

MODIFY gt_fieldcat FROM ls_fcat INDEX sy-tabix TRANSPORTING

no_out.

ENDIF.

ENDLOOP.

CALL METHOD go_grid->set_frontend_fieldcatalog

EXPORTING

it_fieldcatalog = gt_fieldcat[].

EXIT.

ENDIF.

  • * Read indexes of selected rows. In this example only one

  • * row can be selected as we are using gs_layout-sel_mode = 'B',

  • * so it is only ncessary to read the first entry in

  • * table gi_index_rows

LOOP AT gi_index_rows INTO g_selected_row.

IF sy-tabix = 1.

READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight

.

ENDIF.

ENDLOOP.

  • * Transfer data from the selected row to screenm 200 and show

  • * screen 200

CLEAR g_screen200.

MOVE-CORRESPONDING g_wa_sflight TO g_screen200.

LEAVE TO SCREEN '200'.

ENDFORM. " change_flight

**&----


**

  • *& Form save_changes

**&----


**

  • * Changes made in screen 200 are written to the datbase table

  • * zsflight, and to the grid table gi_sflight, and the grid is

  • * updated with method refresh_table_display to display the changes

**----


**

FORM save_changes.

DATA: l_traffic_light TYPE c.

  • * Update traffic light field

  • * Update database table

MODIFY zsflight FROM g_screen200.

  • * Update grid table , traffic light field and color field.

  • * Note that it is necessary to use structure g_wa_sflight

  • * for the update, as the screen structure does not have a

  • * traffic light field

MOVE-CORRESPONDING g_screen200 TO g_wa_sflight.

IF g_wa_sflight-paymentsum < 100000.

g_wa_sflight-traffic_light = '1'.

  • * C = Color, 6=Color 1=Intesified on, 0: Inverse display off

g_wa_sflight-line_color = 'C610'.

ELSEIF g_wa_sflight-paymentsum => 100000 AND

g_wa_sflight-paymentsum < 1000000.

g_wa_sflight-traffic_light = '2'.

CLEAR g_wa_sflight-line_color.

ELSE.

g_wa_sflight-traffic_light = '3'.

CLEAR g_wa_sflight-line_color.

ENDIF.

MODIFY gi_sflight INDEX g_selected_row-index FROM g_wa_sflight.

  • * Refresh grid

CALL METHOD go_grid->refresh_table_display.

CALL METHOD cl_gui_cfw=>flush.

LEAVE TO SCREEN '100'.

ENDFORM. " save_changes

&----


*& Form exclude_toolbar_buttons

&----


  • text

----


  • <--P_GT_EXCLUDE text

----


FORM exclude_toolbar_buttons CHANGING pt_exclude TYPE ui_functions.

DATA: ls_exclude TYPE ui_func.

  • ls_exclude = cl_gui_alv_grid=>mc_fc_maximum.

  • APPEND ls_exclude TO pt_exclude.

*

  • ls_exclude = cl_gui_alv_grid=>mc_fc_minimum.

  • APPEND ls_exclude TO pt_exclude.

*

  • ls_exclude = cl_gui_alv_grid=>mc_fc_subtot.

  • APPEND ls_exclude TO pt_exclude.

*

ls_exclude = cl_gui_alv_grid=>mc_fc_print.

APPEND ls_exclude TO pt_exclude.

  • LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_SUM.

  • APPEND LS_EXCLUDE TO PT_EXCLUDE.

ENDFORM. " exclude_toolbar_buttons

&----


*& Form fieldcatalog_build

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fieldcatalog_build CHANGING pt_fieldcat TYPE lvc_t_fcat.

DATA:ls_fcat TYPE lvc_s_fcat,

lv_tabix LIKE sy-tabix.

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

  • I_BUFFER_ACTIVE =

i_structure_name = 'ZAMITSFLIGHT'

CHANGING

ct_fieldcat = pt_fieldcat[].

LOOP AT pt_fieldcat INTO ls_fcat.

lv_tabix = sy-tabix.

CASE ls_fcat-fieldname .

WHEN 'CARRID'.

ls_fcat-web_field = 'CARRID_HANDLE'.

ls_fcat-drdn_hndl = '5'.

ls_fcat-coltext = 'Carrier ID'.

WHEN 'CONNID'.

ls_fcat-coltext = 'Connid'.

ls_fcat-drdn_field = 'PTYPE_DD_HNDL'.

  • LS_FCAT-DRDN_HNDL = '1'.

WHEN 'PAYMENTSUM'.

ls_fcat-coltext = 'PAY'.

ls_fcat-outputlen = 10.

WHEN 'TRAFFIC_LIGHT'.

ls_fcat-coltext = 'Traffic_light'.

WHEN 'PLANETYPE'.

ls_fcat-coltext = 'Planetype'.

ls_fcat-f4availabl = 'X'.

WHEN 'C_CHECK'.

ls_fcat-coltext = 'CHECKBOX'.

ls_fcat-outputlen = 2.

ls_fcat-checkbox = 'X'.

ls_fcat-edit = 'X'.

ENDCASE.

MODIFY pt_fieldcat FROM ls_fcat INDEX lv_tabix.

ENDLOOP.

  • PERFORM f_help .

ENDFORM. " fieldcatalog_build

&----


*& Form HYPERLINK

&----


  • text

----


  • <--P_GT_HYPE text

----


FORM hyperlink CHANGING pt_hype TYPE lvc_t_hype.

DATA: ls_hype TYPE lvc_s_hype.

ls_hype-handle = '1'.

ls_hype-href = 'http://www.company.com/carrids/car1'.

APPEND ls_hype TO pt_hype.

LOOP AT gi_sflight INTO g_wa_sflight1 WHERE carrid = 'AA'.

  • IF g_wa_sflight1-carrid = 'AA'.

g_wa_sflight1-carrid_handle = '1'.

  • ENDIF.

MODIFY gi_sflight INDEX sy-tabix FROM g_wa_sflight1.

ENDLOOP.

ENDFORM. " HYPERLINK

&----


*& Form drildown_list

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM drildown_list CHANGING lt_drdp TYPE lvc_t_drop .

DATA: "lt_ddval type lvc_t_drop,

ls_ddval TYPE lvc_s_drop.

ls_ddval-handle = '7' .

ls_ddval-value = '400'.

APPEND ls_ddval TO lt_drdp.

ls_ddval-handle = '7' .

ls_ddval-value = '454'.

APPEND ls_ddval TO lt_drdp.

ls_ddval-handle = '7' .

ls_ddval-value = '455'.

APPEND ls_ddval TO lt_drdp.

ls_ddval-handle = '5' .

ls_ddval-value = 'AA'.

APPEND ls_ddval TO lt_drdp.

ls_ddval-handle = '5' .

ls_ddval-value = 'LH'.

APPEND ls_ddval TO lt_drdp.

ls_ddval-handle = '5' .

ls_ddval-value = 'SQ'.

APPEND ls_ddval TO lt_drdp.

ENDFORM. " drildown_list

&----


*& Form f_help

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


*FORM f_help .

  • DATA: lt_f4 TYPE lvc_t_f4,

  • ls_f4 TYPE lvc_s_f4.

*

  • ls_f4-fieldname = 'PLANETYPE'.

  • ls_f4-register = 'X'.

  • ls_f4-getbefore = 'X'.

  • APPEND ls_f4 TO lt_f4.

*

  • CALL METHOD go_grid->register_f4_for_fields

  • EXPORTING

  • it_f4 = lt_f4.

*

*

*ENDFORM. " f_help

&----


*& Form f4_help_1

&----


  • text

----


  • -->P_E_FIELDNAME text

  • -->P_ES_ROW_NO text

----


*FORM f4_help_1 USING p_e_fieldname

  • p_es_row_no.

*

*ENDFORM. " f4_help_1

&----


*& Module STATUS_0101 OUTPUT

&----


  • text

----


MODULE status_0101 OUTPUT.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

SET PF-STATUS 'POPUP'.

SET TITLEBAR 'POPUP'.

  • CALL METHOD g_onf4->show_f4.

ENDMODULE. " STATUS_0101 OUTPUT

&----


*& Module USER_COMMAND_0101 INPUT

&----


  • text

----


MODULE user_command_0101 INPUT.

DATA: save_ok TYPE sy-ucomm.

save_ok = ok_code.

CLEAR ok_code.

CASE save_ok.

WHEN 'CANCEL'.

  • CALL METHOD g_onf4->reset.

LEAVE SCREEN.

ENDCASE.

ENDMODULE. " USER_COMMAND_0101 INPUT

&----


*& Module check_changed INPUT

&----


  • text

----


MODULE check_changed_entries INPUT.

CALL METHOD go_grid->check_changed_data .

ENDMODULE. " check_changed INPUT

Read only

Former Member
0 Likes
885

Hi,

You can find all you need in this document; <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907">An Easy Reference For ALV Grid Control</a>

There are all the steps to create an ALV, to handle events, to hide buttons,... And all is done step by step, giving the code you need.

Hopping it will help you,

Sergio

Read only

Former Member
0 Likes
885

Hi,

Dont forget to go through the documentation,

http://help.sap.com/saphelp_47x200/helpdata/en/bf/3bd1369f2d280ee10000009b38f889/content.htm

Regards,

Azaz Ali.

Read only

Former Member
0 Likes
885

Hi Pc,

Give ur mail id,

So that i can send some documents

regarding alv.

<b>Regards,

Jackie</b>.

Read only

Former Member
0 Likes
885

REPORT zazualvgrid .

DATA: grid1 TYPE REF TO cl_gui_alv_grid,

ok_code LIKE sy-ucomm,

mycontainer TYPE scrfname VALUE 'CUST',

container TYPE REF TO cl_gui_custom_container.

DATA : t_ekpo TYPE TABLE OF zekpo.

DATA : v_save,

v_repid LIKE sy-repid,

v_variant TYPE disvariant.

INCLUDE zsta.

INCLUDE zpbo.

START-OF-SELECTION.

PERFORM set_data.

END-OF-SELECTION.

CLEAR v_variant.

v_repid = sy-repid .

v_variant-report = v_repid.

v_save = 'A'.

CALL SCREEN 786.

----


  • FORM CREATE_CON *

----


  • ........ *

----


FORM create_con.

IF container IS INITIAL.

CREATE OBJECT container EXPORTING

container_name = mycontainer

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5.

IF sy-subrc NE 0.

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

titel = sy-repid

txt2 = sy-subrc

txt1 = 'The control could not be created'(510).

  • TXT3 = ' '

  • TXT4 = ' '

ENDIF.

CREATE OBJECT grid1 EXPORTING

i_parent = container.

CALL METHOD grid1->set_table_for_first_display

EXPORTING i_structure_name = 'ZEKPO'

is_variant = v_variant

i_save = v_save

i_default = 'X'

CHANGING it_outtab = T_EKPO.

ENDIF.

ENDFORM. "

----


  • FORM SET_DATA *

----


  • ........ *

----


FORM set_data.

SELECT EBELN EBELP MATNR BUKRS STATU

FROM EKPO INTO TABLE t_EKPO UP TO 20 ROWS.

ENDFORM. " GET_DATA

module USER_COMMAND_0786 input.

CASE OK_CODE.

WHEN 'EXIT' or 'BACK'.

CALL METHOD container->free.

LEAVE TO SCREEN 0.

ENDCASE.

CLEAR OK_CODE.

endmodule. " USER_COMMAND_0786 INPUT

module STATUS_0786 output.

SET PF-STATUS 'ZAZUALVGRID'.

SET TITLEBAR 'GRID_DISPLAY'.

PERFORM CREATE_CON.

endmodule. " STATUS_0786 OUTPut

Regards,

Azhar

Read only

Former Member
0 Likes
885

Hi Friends,

I did ALV using methods and events.

Thanks for all

pc