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

ALV using OO

Former Member
0 Likes
871

I am raised with an syntax error as i_mara is not type compatable to it_outtab... what should I do?

DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid .

DATA: BEGIN OF i_mara OCCURS 0.
DATA: box TYPE c.
        INCLUDE STRUCTURE mara.
DATA: END OF i_mara.

CALL METHOD gr_alvgrid->set_table_for_first_display
  EXPORTING
*    IS_VARIANT                    =
    i_save                        = 'A'
    i_default                     = 'X'
*    IS_LAYOUT                     =
  CHANGING
    it_outtab                     = i_mara
    it_fieldcatalog               = i_fc[]
  EXCEPTIONS
    invalid_parameter_combination = 1
    program_error                 = 2
    too_many_lines                = 3
    OTHERS                        = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
844

hi,

you have declared ur internal table structure as Begin of itab occurs 0, .

So this type of declaration creates an internal table with header line .

so you have given as i_mara to it_outtab. So you are passing the work area instead of internal table .

Pass it_outab = i_mara[].

This will denote the internal table.

7 REPLIES 7
Read only

Former Member
0 Likes
844

HI

do this

types: BEGIN OF t_mara OCCURS 0.

types: box TYPE c.

INCLUDE STRUCTURE mara.

types: END OF t_mara.

data: i_mara like standard table of t_mata.

Regards

Aditya

Read only

Former Member
0 Likes
844

Hi,

Declare i_mara as:

DATA :i_mara TYPE TABLE OF mara.

It will work.

Revert back if any issues.

Reward points if helpful.

Regards,

Mukul

Edited by: Mukul Sharma on Jun 6, 2008 6:55 AM

Read only

Former Member
0 Likes
845

hi,

you have declared ur internal table structure as Begin of itab occurs 0, .

So this type of declaration creates an internal table with header line .

so you have given as i_mara to it_outtab. So you are passing the work area instead of internal table .

Pass it_outab = i_mara[].

This will denote the internal table.

Read only

Former Member
0 Likes
844

Hi Raj,

it_outtab is expecting an Internal table.

DATA: BEGIN OF i_mara OCCURS 0.

DATA: box TYPE c.

INCLUDE STRUCTURE mara.

DATA: END OF i_mara.

This only defines an internal table / structure with header line i_mara.

Solution :

it_outtab = i_mara[ ]

Hope it helps.

Regards

Hemant Khemani

Read only

Former Member
0 Likes
844

Hi Raj,

First u hv to create object of container then create object for alv grid then assign grid to container then use method set_table_for_first_display or it will give u Dump.

heres the sample code for that.

DATA: g_ref_custom_detail_1 TYPE REF TO cl_gui_custom_container, "Detail container

g_ref_alv_grid_detail_1 TYPE REF TO cl_gui_alv_grid . "Detail ALV instance

      • Create Objects for Custom Container and ALV Grid.

CREATE OBJECT g_ref_custom_detail_1

EXPORTING

container_name = 'SER_ORD_HISTORY'

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

OTHERS = 6.

        • Create ALV instance for detail

CREATE OBJECT g_ref_alv_grid_detail_1

EXPORTING

i_parent = g_ref_custom_detail_1

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

OTHERS = 5.

        • Output data using ALV

CALL METHOD g_ref_alv_grid_detail_1->set_table_for_first_display

EXPORTING

is_variant = lwa_variant

it_toolbar_excluding = it_exclude1

i_save = c_save

CHANGING

it_outtab = i_mara[]

it_fieldcatalog = i_fc[]

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

I think it should work.

Regards,

Swarup

Read only

Former Member
0 Likes
844

Hi das and hemanth ur answers were usefull.. but now I am getting a dump...


 An exception occurred that is explained in detail below.
 The exception, which is assigned to class 'CX_SY_REF_IS_INITIAL', was not
  caught and
 therefore caused a runtime error.
 The reason for the exception is:
 Es wurde versucht mit einer 'NULL' Objektreferenz (zeigt auf 'nichts')
 auf eine Komponente zuzugreifen (Variable: "GR_ALVGRID").
 Eine Objektreferenz muß auf ein Objekt (eine Instanz einer Klasse)
 zeigen, bevor man sie zum Zugriff auf Komponenten nutzen kann.
 Entweder die Referenz wurde noch nie gesetzt, oder sie wurde mit
 einer CLEAR Anweisung auf 'NULL' gesetzt.


>>>>> CALL METHOD gr_alvgrid->set_table_for_first_display
   86   EXPORTING
   87 *    IS_VARIANT                    =
   88     i_save                        = 'A'
   89     i_default                     = 'X'
   90 *    IS_LAYOUT                     =
   91   CHANGING
   92     it_outtab                     = i_mara[]
   93     it_fieldcatalog               = i_fc[]
   94   EXCEPTIONS
   95     invalid_parameter_combination = 1
   96     program_error                 = 2
   97     too_many_lines                = 3
   98     OTHERS                        = 4.
   99 IF sy-subrc <> 0.
  100 * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
  101 *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  102 ENDIF.

Read only

0 Likes
844

follow the process which i hv told u.

It should work.

Regards,

Swarup