Application Development 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: 

Reg alv grid using module pool programming

Former Member
0 Kudos

Dear Friends,

I have a situation where i am using alv grid in module programming where in when i click the total button in the tool bar for any numeric column, the screen goes for a run time error.

I have giving all conditions such as made the column in the field structure of lvc_field_catalog as do_sum = 'X',

still goes for a dump...can anyone throw some hints to do more or the reason behind this and also have not excluded the function code for this total pushbutton while passing to the method set_table_for_first_display

thanks...

7 REPLIES 7

david_carballido
Active Participant
0 Kudos

Hi ... can you show us the dump, in special the Error analysis, i think that the error is produce because the field is not decimal or integer type

0 Kudos

The field type for that column is of type DMBTR, currency field.....

0 Kudos

This is the error i get...

894 gs_roid-row_id = rs_row-index * -1.

895 endif.

896 gs_roid-sub_row_id = rs_row-rowtype+7(10).

897 gs_poid-row_id = gs_roid-row_id.

898 gs_poid-sub_row_id = gs_roid-sub_row_id.

899 gs_poid-rowtype = rs_row-rowtype.

900 gs_poid-index = rs_row-index.

901 insert gs_poid into table rt_poid.

902 endif.

903 append gs_roid to rt_roid.

904

905 loop at rt_fieldcat assigning <ls_fieldcat> where tech ne 'X' and

906 no_out ne 'X'.

907

908 if gflg_invisible = 'X'.

909 if <ls_fieldcat>-do_sum is initial.

910 clear gflg_invisible.

911 continue.

912 else.

913 clear g_col_counter.

914 clear gflg_invisible.

915 endif.

916 endif.

917

918 clear gs_lvc_data.

919 clear g_style.

920

921 assign component

922 <ls_fieldcat>-fieldname of structure rt_data to <g_field>.

923 if sy-subrc ne 0.

>>>> message x000(0k).

925 endif.

926

927 g_col_counter = g_col_counter + 1.

928

929 gs_lvc_data-row_pos = r_row_counter.

930 gs_lvc_data-col_pos = g_col_counter.

931 gs_lvc_data-row_id = gs_roid-row_id.

932 gs_lvc_data-sub_row_id = gs_roid-sub_row_id.

Hai developers.... could anyone crack the net out of the shell?

0 Kudos

dear friends..

I am working on this for two days..can anyone throw some light on this...

0 Kudos

Hi,

There is a problem with the way you are handling the field symbols, specially the command below

assign component

<ls_fieldcat>-fieldname of structure rt_data to <g_field>.

Please avoid field symbols to define a component of a structure, it should be the other way round the structure you are using must be a field symbol and the component you are assigning must be specified with numeric type ( eg: 1 or sy-index ) ot the field name itself, for eg if there is field MATNR in the structure the write as below

assign component MATNR of..............

Hope this explanation of mine will help you sove your problem.

With best wishes,

Murthy.

Former Member
0 Kudos

hi,

check this up

internal tables

DATA: i_tab TYPE TABLE OF zchangereq,

w_tab TYPE zchangereq.

  • display field details

DATA: w_field_cat_wa TYPE lvc_s_fcat. " Field Catalog work area

*

&----


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-020.

&----


PARAMETERS: p_outs RADIOBUTTON GROUP g1,

p_comp RADIOBUTTON GROUP g1.

SELECTION-SCREEN END OF BLOCK b1.

&----


*MACROS

&----


DEFINE add_field.

  • &1 = FIELDNAME &2 = HEADING &3 = Key field flag

clear w_field_cat_wa.

w_field_cat_wa-fieldname = &1.

  • lw_field_cat_wa-ref_table = p_ref_table.

  • lw_field_cat_wa-inttype = p_inttype.

  • lw_field_cat_wa-decimals = p_decimals.

  • lw_field_cat_wa-coltext = p_coltext.

  • lw_field_cat_wa-seltext = p_seltext.

  • lw_field_cat_wa-do_sum = p_do_sum.

  • lw_field_cat_wa-no_out = p_no_out.

  • lw_field_cat_wa-col_pos = p_col_pos.

  • lw_field_cat_wa-reptext = p_coltext.

  • lw_field_cat_wa-colddictxt = p_colddictxt.

w_field_cat_wa-scrtext_m = &2.

w_field_cat_wa-key = &3.

append w_field_cat_wa to i_field_cat.

END-OF-DEFINITION.

*----


  • ALV specific Declarations...........................................

*----


  • ALV specific Internal table declarations.............................

DATA: i_field_cat TYPE lvc_t_fcat, " Field catalogue

i_alv_sort TYPE lvc_t_sort. " Sort table

  • ALV variables........................................................

DATA: w_alv_layout TYPE lvc_s_layo, " ALV Layout

w_alv_save TYPE c, " ALV save

w_alv_variant TYPE disvariant. " ALV Variant

  • ALV Class definitions................................................

*----


CLASS lcl_event_handler DEFINITION.

*----


PUBLIC SECTION.

METHODS: handle_double_click

FOR EVENT double_click OF cl_gui_alv_grid

IMPORTING e_row e_column.

METHODS: handle_hotspot

FOR EVENT hotspot_click OF cl_gui_alv_grid

IMPORTING e_row_id e_column_id.

ENDCLASS. " CLASS LCL_EVENT_HANDLER DEF..

  • ALV Class implementation............................................

  • In the Event of a Double Click drill down to the corresponding CHANGE REQUEST

*----


CLASS lcl_event_handler IMPLEMENTATION.

*----


METHOD handle_double_click.

DATA: l_tab LIKE LINE OF i_tab.

CHECK e_row-rowtype(1) EQ space.

READ TABLE i_tab INDEX e_row-index INTO l_tab.

SET PARAMETER ID 'ZTY' FIELD l_tab-ztype.

SET PARAMETER ID 'ZCR' FIELD l_tab-zcref.

CALL TRANSACTION 'ZCRT' AND SKIP FIRST SCREEN.

ENDMETHOD. " HANDLE_DOUBLE_CLICK

  • not working yet - hotspot seems to stay in the gui!!

METHOD handle_hotspot.

DATA: l_tab LIKE LINE OF i_tab.

CHECK e_row_id-rowtype(1) EQ space.

READ TABLE i_tab INDEX e_row_id-index INTO l_tab.

SET PARAMETER ID 'ZTY' FIELD l_tab-ztype.

SET PARAMETER ID 'ZCR' FIELD l_tab-zcref.

CALL TRANSACTION 'ZCRT' AND SKIP FIRST SCREEN.

ENDMETHOD. " HANDLE_DOUBLE_CLICK

ENDCLASS. " CLASS LCL_EVENT_HANDLER IMPL...

  • ALV Grid Control definitions........................................

DATA:

  • ALV Grid Control itself

o_grid TYPE REF TO cl_gui_alv_grid,

  • Container to hold the ALV Grid Control

o_custom_container TYPE REF TO cl_gui_custom_container,

  • Event handler (defined in the class above)

o_event_handler TYPE REF TO lcl_event_handler.

&----


INITIALIZATION.

&----


PERFORM create_field_catalogue. " Create ALV Field Catalog

&----


START-OF-SELECTION.

&----


  • Outstanding requests

IF p_outs = 'X'.

SELECT * FROM zchangereq

INTO TABLE i_tab

WHERE zstatus < 99.

ELSE.

  • completed requests

SELECT * FROM zchangereq

INTO TABLE i_tab

WHERE zstatus = 99.

ENDIF.

&----


END-OF-SELECTION.

&----


PERFORM list_output_to_alv. " Perform ALV Output operations

----


  • FORM LIST_OUTPUT_TO_ALV *

----


  • This subroutine is used to call the screen for ALV Output. *

----


  • There are no interface parameters to be passed to this subroutine. *

----


FORM list_output_to_alv.

CALL SCREEN 100.

*

ENDFORM. " LIST_OUTPUT_TO_ALV

----


  • Module STATUS_0100 OUTPUT *

----


  • This is the PBO module which will be processed befor displaying the *

  • ALV Output. *

----


MODULE status_0100 OUTPUT.

SET PF-STATUS '0100'. " PF Status for ALV Output Screen

IF p_outs = 'X'.

SET TITLEBAR 'STD'.

ELSE.

  • completed requests

SET TITLEBAR 'COMP'.

ENDIF.

CREATE OBJECT: o_custom_container

EXPORTING container_name = 'SC_GRID',

o_grid

EXPORTING i_parent = o_custom_container.

PERFORM define_alv_layout. " ALV Layout options definitions

PERFORM save_alv_layout_options. " save ALV layout options

PERFORM call_alv_grid. " Call ALV Grid Control

ENDMODULE. " STATUS_0100 OUTPUT

----


  • Module USER_COMMAND_0100 INPUT *

----


  • This is the PAI module which will be processed when the user performs*

  • any operation from the ALV output. *

----


MODULE user_command_0100 INPUT.

CASE sy-ucomm.

WHEN 'EXIT' OR 'BACK' OR 'CANC'.

  • may need to do this so display is refreshed if other report selected

CALL METHOD o_custom_container->free.

SET SCREEN 0.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

----


  • FORM DEFINE_ALV_LAYOUT *

----


  • This subroutine is used to Define the ALV layout. *

----


FORM define_alv_layout .

w_alv_layout-numc_total = 'X'. " Numc total line

w_alv_layout-cwidth_opt = 'X'. " Optimal column width

w_alv_layout-detailinit = 'X'. " Show values that are initial in

" detail list.

w_alv_layout-sel_mode = 'A'. " Column selection mode

w_alv_layout-no_merging = 'X'. " No merging while sorting columns

w_alv_layout-keyhot = 'X'.

ENDFORM. " DEFINE_ALV_LAYOUT

----


  • FORM SAVE_ALV_LAYOUT_OPTIONS *

----


  • This subroutine is used to Save the ALV layout options. *

----


FORM save_alv_layout_options.

  • See the ALV grid control documentation for full list of options

w_alv_save = 'A'.

w_alv_variant-report = sy-repid.

ENDFORM. " SAVE_ALV_LAYOUT_OPTIONS

----


  • FORM CALL_ALV_GRID *

----


  • This subroutine is used to call ALV Grid control for processing. *

----


FORM call_alv_grid.

CALL METHOD o_grid->set_table_for_first_display

EXPORTING

is_layout = w_alv_layout

i_save = w_alv_save

is_variant = w_alv_variant

CHANGING

it_outtab = i_tab[]

it_sort = i_alv_sort

it_fieldcatalog = i_field_cat.

  • Link used Events and Event Handler Methods

CREATE OBJECT o_event_handler.

  • Set handler o_event_handler->handle_top_of_page for o_grid.

SET HANDLER o_event_handler->handle_double_click FOR o_grid.

ENDFORM. " CALL_ALV_GRID

&----


*& Form create_field_catalogue

&----


  • set up field catalogue

&----


FORM create_field_catalogue .

  • Fieldname Heading Key?

*eg add_field 'ZTYPE' 'Type' 'X'.

ENDFORM. " create_field_catalogue

0 Kudos

hI,

Thank you all for the immedite responses. But i am not using any field symbols, that s a system generated error from the system