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: 

I am not able to define structure type in abap metot.

yalcin_mete
Participant
0 Kudos

Hello,
I get an error when I want to define a structure named "rs_table" after making a type definition.
error : TYPE ''CCT'' is unknown.

method get_cc_mail.
data: lt_data type table of ty_data.

types : begin of ty_cc,
cc type ad_smtpadr,
end of ty_cc.

data : cct type table of ty_cc.
data : rs_table type cct.
...
..

Can't we define type inside method?
Please suggest if anyone has a solution for this.

Thanks.

17 REPLIES 17

Eduardo-CE
Active Participant
0 Kudos

Hi;

Type should be ty_cc, not cct.

Regards,

Eduardo

0 Kudos

Or else can use 'LIKE' in place of 'TYPE' keyword.

DATA: rs_table like cct.

0 Kudos

why not

TYPES: cct TYPE TABLE OF  ty_cc  .

etc.

0 Kudos

Note that we don't know what type should be RS_TABLE... structure, table or what... infinite number of solutions

0 Kudos

By the naming convention, we can guess sometimes, but yes, there could be many solutions.

0 Kudos

But I dont understand.

"sflight" is a table.
"cct" is a table.

data : gs_flight  TYPE sflight  " =>I am not getting any error.<br> " 

data : rs_table TYPE cct  "=> i am getting error.  ( "cct" is a table)"

matt
Active Contributor
0 Kudos

cct is a table. But it isn't a type. After the TYPE keyword you must specify a type.

Go back to your notes and try and learn the difference between TYPE and DATA.

0 Kudos

sflight is a table but it isn't a type.

cct is a table but it isn't a type.

but

data : gs_flight TYPE sflight "=> I am not getting any error"
data : rs_table TYPE cct "=> i am getting error. ( "cct" is a table)"

matt
Active Contributor

sflight defines the structure of a database table in the data dictionary. It is a type. It is not a data object.

cct is an internal table. It is a data object. It is not a type.

At the risk of confusing you further, you can write:

cct = value #( ( cc = '1' ) ).

but you cannot write

sflight = value #( ( carrid = '2' ) ).

0 Kudos

thank you..

Sandra_Rossi
Active Contributor
0 Kudos

"metot" -> "method"

Of course you can define local types.

You should look again at your code, the error is "obvious" (at least you should be able to find it after looking again and again).

Sandra_Rossi
Active Contributor
0 Kudos

Please edit your question (Actions>Edit), select your code and press the button [CODE], which makes the code appear colored/indented, it'll be easier for people to look at it. Thanks!

yalcin_mete
Participant
0 Kudos

I dont understand.

"sflight" is a table.
"cct" is a table.

data : gs_flight  TYPE sflight   "=> I am not getting any error"
data : rs_table TYPE cct "=> i am getting error. ( "cct" is a table)"

Sandra_Rossi
Active Contributor
0 Kudos

It seems that your question is that you want to know

  • how to declare a "data type", and a "data object" (variables, constants).
  • how to declare a data object or a data type based on another "data type" or on another "data object".

If you know, you will be able to solve easily this kind of syntax error.

A "data type" is declared by "TYPES", a "data object" is declared by "DATA".

You declare a data object or a data type based on another "data type" by using "TYPE" or on another "data object" by using "LIKE".

So, your code is currently wrong.

thkolz
Contributor
0 Kudos
TYPES: cct TYPE STANDARD TABLE OF ty_cc.

Sandra_Rossi
Active Contributor

yalcin.mete You have said that:

  • sflight is a table but it isn't a type.
  • cct is a table but it isn't a type.
  • but
data : gs_flight TYPE sflight "=> I am not getting any error"
data : rs_table TYPE cct  "=> i am getting error.  ( "cct" is a table)"

My answer:

  • You are wrong: DDIC tables, structures and views are considered as being Structured Types in ABAP (I could give you the link to the ABAP documentation if you ask)
  • SFLIGHT is a DDIC table
  • CCT is a structured internal table, it's NOT a data type. So you cannot use "TYPE cct", only data types can be indicated after TYPE.
  • I hope you understand now.

yalcin_mete
Participant
0 Kudos

Thank you for everything.
I'm starting to understand...