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

Table Types

Former Member
0 Likes
725

Is it obselete to use the occurs 0 to declare the internal tables.

I am working on the ALVs and declairing the occurs 0 would be easy.

7 REPLIES 7
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
695

Yes it is. You should either use table types definedin the dictionary, or define the TYPE in your program.

Types: begin of ttab,
           fld1 type c,
           fld2 type c,
           end of ttab.
data: itab type table of ttab.
data: wa like line of itab.

Regards,

Rich Heilman

Read only

0 Likes
695

Hi,

But i am using the 'REUSE_ALV_FIELDCATALOG_MERGE'.

I have declaired the internal table as types.

But i can not use that type for the above mentioned FM as it is not a database object.

Read only

0 Likes
695

You can use database object to inherit the structure from, for a internal table.

DATA ITAB TYPE TABLE OF dbtab.

Read only

0 Likes
695

Hi Vishnu,

I can not use the ITAB in the REUSE_ALV_FIELDCATALOG_MERGE.

It needs either a internal table or a structure in the database.

Any way out for me.

Thanks.

Read only

0 Likes
695

Hope this will help to compare your code against working code on my end

type-pools: slis.    " required for ALV

data: g_repid     like sy-repid,
      g_fieldcat  type slis_t_fieldcat_alv,
      g_save(1)   type c,
      g_exit(1)   type c,
      g_variant   like disvariant.

TYPES: begin of t_output,
        tabname    like ddtabname-tabname,
        zzbigdeal  like a701-zzbigdeal,
        kschl      like a701-kschl,
        zzkdkg3    like a701-zzkdkg3,
        kdkgr      like a701-kdkgr,
        waerk      like a701-waerk,
        pltyp      like a701-pltyp,
        inco1      like a702-inco1,
        spart      like a721-spart,
        family_id  like a731-family_id,
        series_id  like a734-series_id,
        model_id   like a737-model_id,
        zzbundleid like a701-zzbundleid,
        matnr      like a701-matnr,
        varcond    like a711-varcond,
        datbi      like a701-datbi,
        datab      like a701-datab,
        kbetr      like konp-kbetr,
        konwa      like konp-konwa,
        krech      like konp-krech,
        loevm_ko   like konp-loevm_ko,
        knumh      like a702-knumh,
      end of t_output.

DATA: i_output TYPE TABLE OF t_OUTPUT.

  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program = g_repid
            it_fieldcat        = g_fieldcat
*            is_layout          = layout
            i_default          = 'A'
            i_save             = g_save
            is_variant         = g_variant
*            it_events          = events[]
       tables
            t_outtab           = i_output
       exceptions
            program_error      = 1
            others             = 2.

  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.

Read only

0 Likes
695

You could do something like this.



REPORT zrich_0001.

type-pools: slis.

data: begin of xma,
       matnr like makt-matnr,
       maktx like makt-maktx,
      end of xma.

data: ima like standard table of xma .
data: fieldcat type slis_t_fieldcat_alv.
data: repid type syrepid.

repid = sy-repid.

select matnr maktx
                 into table ima
                       from makt
                             up to 100 rows
                                where spras = sy-langu.

call function 'REUSE_ALV_FIELDCATALOG_MERGE'
     exporting
          i_program_name     = repid
          i_internal_tabname = 'XMA'
          i_inclname         = repid
          i_bypassing_buffer = 'X'
     changing
          ct_fieldcat        = fieldcat.


call function 'REUSE_ALV_GRID_DISPLAY'
     exporting
          it_fieldcat = fieldcat
     tables
          t_outtab    = ima.


Regards,

Rich Heilman

Read only

Former Member
0 Likes
695

No, declaring internal tables with TYPE declaration would be easier, as you practice it. This is because, you can extend many internal tables from a single TYPE and you can change all of them in one go by extending the TYPE. This is particularly very important if you need to have more than one internal table which SHOULD be structurally similar to others.