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

how to define range when using oo environment

Former Member
0 Likes
5,649

Hi all,

I have a doubt regarding this when using OO:

DATA: spfli_wa TYPE spfli, 
      r_carrid TYPE RANGE OF spfli-carrid, 
      r_carrid_line LIKE LINE OF r_carrid.

Is there a structure I can do "type" for the work-area?

Thanks in advance,

Edited by: orgasmics on Sep 9, 2010 9:23 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,063

Check Ranges table types, for example CURTO_PSPNR_RANGE_T

6 REPLIES 6
Read only

Former Member
0 Likes
2,064

Check Ranges table types, for example CURTO_PSPNR_RANGE_T

Read only

mvoros
Active Contributor
0 Likes
2,063

Hi,

I use statement LIKE LINE OF without any problems. I don't see why it should not be OK. There is no structure unless you define it by yourself.

Here is a quote from document about obsolete ABAP statements in OO.

Error message in ABAP Objects if the following syntax is used:

DATA itab TYPE LIKE TABLE OF ... WITH HEADER LINE.

Correct syntax:

DATA: itab TYPE LIKE TABLE OF ... ,

wa LIKE LINE OF itab.

You can see that LIKE LINE OF is used in section Correct syntax.

Cheers

Read only

Former Member
0 Likes
2,063

Hello,

if you maintain or develop your class in transaction SE24 for example, then you will find a button Local Types in the Icon Bar.

Click on it and define a Type range.

E.g.

TYPES : rnge_bukrs TYPE RANGE OF bukrs.

TYPES : rnge_line TYPE LINE OF rnge_bukrs.

That will create a range table type and a structure of the same type.

You can use these types in any data statements of any method in that class or attribute of your your class or interfaces of your methods.

Hope that is what you are looking for.

Cheers

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,063

Hello,

As Martin has mentioned LIKE LINE OF <itab> will create a single table line using the internal table as reference. AFAIK in OO context LIKE is still acceptable.

But if you're still obsessed with TYPE, you can try as mentioned in the previous post.

BR,

Suhas

Read only

Former Member
0 Likes
2,063

Hi, thank you all.

My obsession comes when (afaik) "LIKE" alocates memory space for the variable, and "TYPE" only alocates the type data.

Correct me if I'm wrong.

Thank you all for your responses!

Read only

0 Likes
2,063

Hi,

I doubt that there is a difference between LIKE and TYPE. LIKE just allows you to use already defined object for data definition. I also think that it doesn't matter if the code is structured correctly. If program is broken into small chunks (routines or methods) and there are no global variables. then you need all your local variables in the method and there is no difference if they are allocated in data definition or 3 lines later.

Cheers