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

Problem with simple GRID

Former Member
0 Likes
1,617

Hi. I try to make simple grid.

REPORT ZWOP_TEST1_C15 .

DATA: OK_CODE LIKE SY-UCOMM,
      SAVE_OK LIKE SY-UCOMM.

DATA: go_grid             TYPE REF TO cl_gui_alv_grid,
      go_custom_container TYPE REF TO cl_gui_custom_container.
DATA: ws_fieldcat TYPE lvc_t_fcat.
DATA: ws_field LIKE LINE OF ws_fieldcat.
DATA: is_layout TYPE lvc_s_layo.
DATA: is_print TYPE lvc_s_prnt.
DATA: gs_layout TYPE disvariant.

TABLES: zrfakh.
DATA:
  BEGIN OF itab OCCURS 0,
    bldat LIKE zrfakh-bldat,
    cpudt LIKE zrfakh-cpudt,
  END OF itab.

  SELECT zrfakh~bldat zrfakh~cpudt
  INTO   (itab-bldat, itab-cpudt)
  FROM   zrfakh
  WHERE  werks = '1004'.
    APPEND itab.
  ENDSELECT.

CALL SCREEN '0100'.
*&--------------------------------------------------------------------
*&      Module  STATUS_0100  OUTPUT
*&--------------------------------------------------------------------
*       text
*---------------------------------------------------------------------

MODULE STATUS_0100 OUTPUT.
  SET PF-STATUS '0001'.
  SET TITLEBAR '0100'.
  IF go_custom_container IS INITIAL.
    CREATE OBJECT go_custom_container
       EXPORTING container_name = 'CONTAINER'.
    CREATE OBJECT go_grid
    EXPORTING
    i_parent = go_custom_container.
    PERFORM fill_field_cat.
    PERFORM load_data_into_grid.
  ENDIF.

ENDMODULE.                 " STATUS_0100  OUTPUT
*&--------------------------------------------------------------------
*&      Module  USER_COMMAND_0100  INPUT
*&--------------------------------------------------------------------
*       text
*---------------------------------------------------------------------

MODULE USER_COMMAND_0100 INPUT.

  CASE SY-UCOMM.
    WHEN 'EXIT'.
      PERFORM END_SESSION.
    WHEN 'G1'.
      PERFORM END_SESSION.
    WHEN 'G2'.
      PERFORM END_SESSION.

  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0100  INPUT

*---------------------------------------------------------------------
*      Form  fill_field_cat
*---------------------------------------------------------------------
*       text
*---------------------------------------------------------------------
*  -->  p1        text
*  <--  p2        text
*---------------------------------------------------------------------

FORM fill_field_cat.
  PERFORM append_wsfield
  USING 'bldat' '' 0 1 0 'A' 10 'X' 'C210' ''.
  PERFORM append_wsfield
  USING 'cpudt' '' 0 1 0 'B' 10 'X' 'C210' ''.
ENDFORM.                    " fill_field_cat


*---------------------------------------------------------------------

*       FORM append_wsfield

*---------------------------------------------------------------------

*       ........

*---------------------------------------------------------------------

*  -->  FIELDNAME

*  -->  INTTYPE

*  -->  DECIMALS

*  -->  COL_POS

*  -->  DECIMALS_O

*  -->  COLTEXT

*  -->  OUTPUTLEN

*---------------------------------------------------------------------

FORM append_wsfield USING fieldname inttype decimals col_pos
decimals_o
coltext outputlen fix emphasize sum.
  ws_field-fieldname = fieldname.
  ws_field-inttype = inttype.
  ws_field-decimals   = decimals.
  ws_field-col_pos   = col_pos.
  ws_field-decimals_o   = decimals_o.
  ws_field-coltext   = coltext.
  ws_field-outputlen = outputlen.
  ws_field-seltext  = coltext.
  ws_field-emphasize = emphasize.
  ws_field-fix_column = fix.
  ws_field-do_sum = sum.
  APPEND ws_field TO ws_fieldcat .
ENDFORM.
*&--------------------------------------------------------------------
*&      Form  load_data_into_grid
*&--------------------------------------------------------------------
*       text
*---------------------------------------------------------------------
*  -->  p1        text
*  <--  p2        text
*---------------------------------------------------------------------

FORM load_data_into_grid.
  DATA: title(50).
  DATA: time(8).
  DATA: date(10).
  DATA: x.
  title = 'Dane osobowe'.
  is_layout-cwidth_opt = 'X'.
  is_layout-zebra = 'X'.
  is_layout-grid_title = title.
  is_print-prnt_title = '1'.
  is_layout-info_fname = 'LINECOLOR'.
  gs_layout-report = sy-repid.
  CALL METHOD go_grid->set_table_for_first_display
    EXPORTING is_layout = is_layout
              is_print = is_print
              is_variant = gs_layout
              i_save     = 'A'
    CHANGING  it_outtab  = itab
              it_fieldcatalog = ws_fieldcat.

ENDFORM.                    " load_data_into_grid

*&--------------------------------------------------------------------
*&      Form  END_SESSION
*&--------------------------------------------------------------------
*       text
*---------------------------------------------------------------------
*  -->  p1        text
*  <--  p2        text
*---------------------------------------------------------------------


FORM END_SESSION.
  FREE go_grid.
  FREE go_custom_container.
  LEAVE PROGRAM.
ENDFORM.                    " END_SESSION

and I receive an <b><i>ERROR: "ITAB" is not type-compatible with formal parameter "IT_OUTTAB".</i></b>

I'd be very thankful for help.

Greetings. P.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,582

Hi Piotr ,

The reason can be you have define your internal table as below

<b> BEGIN OF itab OCCURS 0,

bldat LIKE zrfakh-bldat,

cpudt LIKE zrfakh-cpudt,

END OF itab</b>

so it an internal table with a header line and in ABAP objects internal table with header lines are not supported.

So what you can do is define a type first and then a table of that type , the code will look some thing like this

Type : Begin of ty_1 ,

bldat type bldat,

cpudt type cpudt,

End of ty_1.

Data : itab type table of ty_1.

Hope this helps.

Regards

Arun

18 REPLIES 18
Read only

Former Member
0 Likes
1,582

pass itab[] instead of itab

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
1,582

Hi,

Try passing ITAB[].

Regards,

Sesh

Read only

Former Member
0 Likes
1,582

hi,

in this section try like this

CALL METHOD go_grid->set_table_for_first_display

EXPORTING is_layout = is_layout

is_print = is_print

is_variant = gs_layout

i_save = 'A'

CHANGING it_outtab = itab[]

it_fieldcatalog = ws_fieldcat.

ENDFORM.

as u have not created any implicit header for taht table so u have to pass body of that internal table.

if helpful reward some points.

with regards,

suresh.

Read only

Former Member
0 Likes
1,582

Hello,

Change here.


 CALL METHOD go_grid->set_table_for_first_display
    EXPORTING is_layout = is_layout
              is_print = is_print
              is_variant = gs_layout
              i_save     = 'A'
    CHANGING  it_outtab  = itab[]  " Check Here
              it_fieldcatalog = ws_fieldcat.

Vasanth

Read only

Former Member
0 Likes
1,582

Hi.

Please try to define your itab in a different way.

DATA: BEGIN OF s_itab,
  bldat TYPE zrfakh-bldat,
  cpudt TYPE zrfakh-cpudt,
END OF s_itab,
itab LIKE STANDARD TABLE OF s_itab.

Hope that works.

Regards,

Timo.

Read only

Former Member
0 Likes
1,582

Hi,

Your Itab Structure is,

BEGIN OF itab OCCURS 0,

bldat LIKE zrfakh-bldat,

cpudt LIKE zrfakh-cpudt,

END OF itab.

But you tried to append the values to your itab like,

EXPORTING is_layout = is_layout

is_print = is_print --->

is_variant = gs_layout -


> you can't append this values to ur Itab.

i_save = 'A' -


>

CHANGING it_outtab = itab

So Only you got the error.

So please modify your Itab Structure and try Again.

Thanks,

Reward If Helpful.

Read only

Former Member
0 Likes
1,583

Hi Piotr ,

The reason can be you have define your internal table as below

<b> BEGIN OF itab OCCURS 0,

bldat LIKE zrfakh-bldat,

cpudt LIKE zrfakh-cpudt,

END OF itab</b>

so it an internal table with a header line and in ABAP objects internal table with header lines are not supported.

So what you can do is define a type first and then a table of that type , the code will look some thing like this

Type : Begin of ty_1 ,

bldat type bldat,

cpudt type cpudt,

End of ty_1.

Data : itab type table of ty_1.

Hope this helps.

Regards

Arun

Read only

0 Likes
1,582

<u><b>Priyank Jain, Seshatalpasai M..., Suresh Babu Aluri, Vasanth M</b></u>

it_outtab  = itab[]

<i>Grid appears with columns with empty content.</i>

<u><b> Timo Schunda </b></u>

DATA: BEGIN OF s_itab,
        bldat TYPE zrfakh-bldat,
        cpudt TYPE zrfakh-cpudt,
      END OF s_itab,
      itab LIKE STANDARD TABLE OF s_itab.

  SELECT zrfakh~bldat zrfakh~cpudt
  INTO   (itab-bldat, itab-cpudt)
  FROM   zrfakh
  WHERE  werks = '1004'.
    APPEND itab.
  ENDSELECT.

<i>

ERROR: The list "(ITAB-BLDAT" after "INTO" is not of the form (f1, ...,fn), or contains an undefined field. excludes specification of a field list. </i>

<b><u> Arun R </u> </b>


TYPES: BEGIN OF ty_1,
         bldat TYPE zrfakh-bldat,
         cpudt TYPE zrfakh-cpudt,
       END OF ty_1.
DATA : itab TYPE TABLE OF ty_1.

  SELECT zrfakh~bldat zrfakh~cpudt
  INTO   (itab-bldat, itab-cpudt)
  FROM   zrfakh
  WHERE  werks = '1004'.
    APPEND itab.
  ENDSELECT.

<i>ERROR: The list "(ITAB-BLDAT" after "INTO" is not of the form (f1, ...,fn), or contains an undefined field. excludes specification of a field list</i>

Read only

0 Likes
1,582

Hi Piotr ,

Yes since now your internal table does not have a heder line so the statement wont work.

Try this

SELECT bldat cpudt

INTO table itab

FROM zrfakh

WHERE werks = '1004'.

this will directly move the selected data into the internal table.

Hope this helps

Reward points if helpful.

Regards

Arun

Read only

0 Likes
1,582

<u><b> Arun R </b></u>

TYPES: BEGIN OF ty_1,
         bldat TYPE zrfakh-bldat,
         cpudt TYPE zrfakh-cpudt,
       END OF ty_1.
DATA : itab TYPE TABLE OF ty_1.

  SELECT zrfakh~bldat zrfakh~cpudt
  INTO TABLE itab
  FROM   zrfakh
  WHERE  werks = '1004'.

<i>Grid appears with columns, which are ampty. But itab is not empty.</i>

Read only

0 Likes
1,582

Hi,

Check the table zrfakh in SE16 for werks = '1004'.

Otherwise, check in debugging mode after this select whether sy-subrc eq 4.If it is 4,then there is no such record in the table zrfakh.

Read only

0 Likes
1,582

itab is not empty

Read only

0 Likes
1,582

Hi,

Try commenting the is_print and is_variant and observe where the error occurs.If both are working,then try using LVC_FIELDCATALOG_MERGE function module for getting fieldcatalog by creating a structure similar to output table in SE11.If it works fine,then you need to check the code you have written now for fieldcatalog.

CALL METHOD go_grid->set_table_for_first_display

EXPORTING is_layout = is_layout

  • is_print = is_print

  • is_variant = gs_layout

i_save = 'A'

CHANGING it_outtab = itab

it_fieldcatalog = ws_fieldcat.

Read only

0 Likes
1,582

<u><b> Jayanthi Jayara... </b></u>

What is the work area for? Where should I put result of SELECT statement? Which table should I give to the it_outtab ?

Read only

0 Likes
1,582

Hi,

Check this link.I have explained all the steps here for creating a simple OOPS ALV.It will help you.Reward points if it helps.

<a href="https://wiki.sdn.sap.com/wiki/display/Snippets/ABAP-7StepstocreateOOPSALV(forbeginners).">https://wiki.sdn.sap.com/wiki/display/Snippets/ABAP-7StepstocreateOOPSALV(forbeginners).</a>

Read only

0 Likes
1,582

<u><b> Jayanthi Jayara... </b></u>

sorry, but the page doesn't exist

Read only

0 Likes
1,582

Hi Piotr ,

When you populate the catalog , please type the feild name in upper case.

The current statement is

PERFORM append_wsfield

USING 'bldat' '' 0 1 0 'A' 10 'X' 'C210' ''.

Replace that with

PERFORM append_wsfield

USING <b>'BLDAT'</b> '' 0 1 0 'A' 10 'X' 'C210' ''.

Regards

Arun

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,582

Hi,

Declare the itab without header line.Since you are using OOPS concept, the internal table with header line is not allowed.

Try this code and kindly reward points by clikcing the star on the left of reply,if it helps.

types:

BEGIN OF ty,

bldat LIKE zrfakh-bldat,

cpudt LIKE zrfakh-cpudt,

END OF ty.

data : itab type standard table of ty,"Internal table

wa type ty."Work area