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: 

TYPES statement in abap class to include structure

Former Member
0 Kudos

hi ,

i have declared following in a abap class...

TYPES:
      zts_alv_line TYPE zmat_pr_costest_alv.
     TYPES:BEGIN OF ts_alv_line,
            include type zts_alv_line,
            matkl type mara-matkl,
            t023t type t023t-wgbez,
            lvorm type mara-lvorm,
            end of ts_alv_line.

     TYPES: tt_alv_data TYPE STANDARD TABLE OF ts_alv_line WITH DEFAULT KEY.
     DATA:
      alv_data TYPE tt_alv_data.

now while refering to alv_data-matnr the sap is giving error that this component does not have matnr.

please help.

Edited by: Suhas Saha on Feb 3, 2012 1:11 PM

1 ACCEPTED SOLUTION

nabheetscn
Active Contributor
0 Kudos
TYPES:
zts_alv_line TYPE ZCOMP_S_query_line.
TYPES:BEGIN OF ts_alv_line,
matkl type mara-matkl,
t023t type t023t-wgbez,
lvorm type mara-lvorm.
include type zts_alv_line.
types:end of ts_alv_line.

TYPES: tt_alv_data TYPE STANDARD TABLE OF ts_alv_line WITH DEFAULT KEY.
DATA:
alv_data type ts_alv_line-->Change here
9 REPLIES 9

Former Member
0 Kudos

Hi,

Try like below, Inside method & in declaration,

TYPES:BEGIN OF ty_chk,

b TYPE mara, ( Give your struct/table name)

c TYPE matnr,

END OF ty_chk.

DATA: lt_tbl TYPE TABLE OF ty_chk,

lw_tbl TYPE ty_chk.

lw_tbl-c = lw_tbl-b-matnr.

Regards,

S.Senthilkumar

0 Kudos

hi senthi,

thanks for yout reply.

i have understood what you have said.

but is there any method to jst refer it derectly as w_tbl-matnr.

because if it is lyk that i will have to change it in every method it is called.

regards,

somesh

0 Kudos

Hi,

I dont think it's possible, as you are referring a filed(matnr) which is one of the fields of structure 'zts_alv_line'.

Any way I will also try.

Regards,

S.Senthilkumar.

nabheetscn
Active Contributor
0 Kudos
TYPES:
zts_alv_line TYPE ZCOMP_S_query_line.
TYPES:BEGIN OF ts_alv_line,
matkl type mara-matkl,
t023t type t023t-wgbez,
lvorm type mara-lvorm.
include type zts_alv_line.
types:end of ts_alv_line.

TYPES: tt_alv_data TYPE STANDARD TABLE OF ts_alv_line WITH DEFAULT KEY.
DATA:
alv_data type ts_alv_line-->Change here

0 Kudos

Thanks, this method worked for me

0 Kudos

Thanks Nabheet !!

SuhaSaha
Advisor
Advisor
0 Kudos
TYPES: zts_alv_line TYPE zmat_pr_costest_alv.
TYPES:BEGIN OF ts_alv_line,
            include type zts_alv_line,
            matkl type mara-matkl,
            t023t type t023t-wgbez,
            lvorm type mara-lvorm,
            end of ts_alv_line.

Actually by defining this you've defined include as field of ts_alv_line. Actually ts_alv_line is a nested structure.

I think you need to re-define the structure definition as:

TYPES:BEGIN OF ts_alv_line.
      INCLUDE TYPE zts_alv_line.
TYPES: matkl TYPE mara-matkl,
       t023t TYPE t023t-wgbez,
       lvorm TYPE mara-lvorm.
TYPES: END OF ts_alv_line.

BR,

Suhas

Former Member
0 Kudos

hi suhas,

thanks to your reply.

but i am still geting the same error.

the problem is that the variable is in some other class which is refering to the type ts_alv_line.

so when i acess matnr it gives the error.

regards,

somesh

kabil_g
Active Participant
0 Kudos

Hi Somesh,

                The Above Class is Right ,Go ahead once or else try a new structure to define. it would be best for you.

Regards,

Kabil