Alv Grids


Published on

ALV Grid example

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Alv Grids

  1. 1. ALV grids should be used when possible. They can be customized and ran in the background by creating a layout and setting it up. Ex.type-pools: begin of gt_outtab occurs 0. include structure zorderdata. data: end of gt_outtab, gs_layout type slis_layout_alv, g_exit_caused_by_caller, gs_exit_caused_by_user type slis_exit_by_user, g_repid like sy-repid, w_set_status type slis_formname, w_user_command type function 'REUSE_ALV_GRID_DISPLAY -OR-* create a custom container control for our ALV Control - this is also * create on the screen layout.CREATE OBJECT custom_containerCALL METHOD grid1->set_table_for_first_display* Create Object to receive events and link them to handler methods. * When the ALV Control raises the event for the specified instance * the corresponding method is automatically called.CREATE OBJECT event_receiver. SET HANDLER event_receiver->handle_top_of_page FOR grid1. SET HANDLER event_receiver->handle_double_click FOR grid1.* Controls are not integrated into the TAB-Order * Call quot;set_focusquot; if you want to make sure that 'the cursor' * is active in your control.CALL METHOD cl_gui_control=>set_focus EXPORTING control = grid1.Misc: Enqueue/dequeue function modules are automatically created when a lock object is created in SE11. You can use the function modules in your programs. Program for listing field contents of any structured record. This utility program is from Gordon Tobias. The program is really just a shell for 4 routines which are intended to be called from other programs. The first 2 routines can be called from any program with statements like: PERFORM list_record_fields(zlist_fields_rtti) USING p_any_rec. PERFORM list_fields_with_cols(zlist_fields_rtti) USING p_any_rec. The third routine accepts additional parms for restricting which fields to list. When I want to use this routine, I define 2 SELECT- OPTIONS parms in the calling program, which let me specify that I want to list specific field numbers (e.g. fields 1-5) or names (e.g. all fields whose names match *DAT*). The parm definitions look like: *- Definitions num3 and field_name needed for SELECT-OPTIONS below DATA: num3(3) TYPE n. DATA: field_name(30) TYPE c.
  2. 2. *- SELECT-OPTIONS parms to limit the fields reported upon SELECT-OPTIONS: so_fnum FOR num3, so_fname FOR field_name. And the call to the 3rd routine looks like PERFORM list_specific_fields IN PROGRAM zlist_fields_rtti TABLES so_fnum so_fname USING p_any_rec. The last routine converts any record to a CSV format. If you call it with the 2nd USING parm set to 'HDR', it will create a header line with the field titles. If that 2nd USING parm is blank, it creates a CSV record with the field contents. So the calls to the 4th routine look like: PERFORM convert_to_csv IN PROGRAM zlist_fields_rtti USING p_any_rec 'HDR' quot;Header flag: HDR or ' ' CHANGING w_csv_rec. TRANSFER w_csv_rec TO p_ofile. And PERFORM convert_to_csv IN PROGRAM zlist_fields_rtti USING p_any_rec space quot;Header flag: HDR or ' ' CHANGING w_csv_rec. TRANSFER w_csv_rec TO p_ofile.