‎2010 Sep 09 8:23 PM
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
‎2010 Sep 09 11:48 PM
‎2010 Sep 09 11:48 PM
‎2010 Sep 10 12:51 AM
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
‎2010 Sep 10 2:21 AM
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
‎2010 Sep 10 2:22 AM
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
‎2010 Sep 14 9:31 AM
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!
‎2010 Sep 15 2:35 AM
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