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 declare table i method

Former Member
0 Likes
4,032

Hi,

i need to now how to declare table (like in fm) in method,

because when i try declare table in parameters (SE24) with type the structure i build in se11 i get error:

""LT_TAB" is not an internal table "OCCURS n" specification is problem "

And i don't have the option of like (like in fm for structure ) just type.

2. how i have to declare table in changing or returning ?

(in the fm its in tab tables i put - LT_TAB LIKE Z_STRUCTURE)

Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,706

Hi,

Try using the below code for declaration.



TYPES : BEGIN OF gs_bsis,
          bukrs LIKE bsis-bukrs,
          hkont LIKE bsis-hkont,
          gjahr LIKE bsis-gjahr,
        END OF gs_bsis.

DATA : gt_bsis TYPE TABLE OF gs_bsis.  "Inernal table

Thanks,

Sriram Ponna.

11 REPLIES 11
Read only

Former Member
0 Likes
2,707

Hi,

Try using the below code for declaration.



TYPES : BEGIN OF gs_bsis,
          bukrs LIKE bsis-bukrs,
          hkont LIKE bsis-hkont,
          gjahr LIKE bsis-gjahr,
        END OF gs_bsis.

DATA : gt_bsis TYPE TABLE OF gs_bsis.  "Inernal table

Thanks,

Sriram Ponna.

Read only

0 Likes
2,706

Hi Sriram Ponna ,

thanks but where i put it in se24 ?

i new to OO.

Regards

Read only

0 Likes
2,706

Hi ,

In OO you cannot have tables defined with header lines, so in OO its the same way you create tables in programs or FM without header lines. and also you cannot use LIKE statement in the OO ABAP, you could only use TYPE statement.

And about the place where you need to write the code, you should go to the METHOD and double click on the method where you will be displayed the ABAP editor.

Let me know if you face any problem still, else kindly close the thread.

Yugandhar

Read only

0 Likes
2,706

hi Yugandhar Kotha ,

THANKS i try to declare with type and i have the same error,

how i avoid the header line , i don't declare it i just declare table like

structure in se 11.

Regards

Read only

0 Likes
2,706

Hi,

try to declare the work area type first


TYPES BEGIN OF ts_workarea.
TYPES field1 TYPE field1_type.
TYPES END OF ts_workarea.

Then define the table type:


TYPES tt_tabletype TYPE STANDARD TABLE OF ts_workarea WITH DEFAULT KEY.

If you want to create a table type based on SE11 structure then try this:


TYPES tt_tabletype TYPE STANDARD TABLE OF zs_ddic_structure WITH DEFAULT KEY.

Now you can take this table type and use it for attributes or parameters.

More information can be found here: [The Statements TYPES and DATA|http://help.sap.com/saphelp_nw70/helpdata/EN/fc/eb2ff3358411d1829f0000e829fbfe/frameset.htm]

Regards Rudi

Read only

0 Likes
2,706

Hi kramer,

i provide you an example..

if suppose you need to create a table with fields vbeln, posnr then here it goes

types: begin of ty_tab,

vbeln type vbak-vbeln,

posnr type vbap-posnr,

end of ty_tab.

data:

fs_tab type ty_tab,

i_tab type table of ty_tab.

fs_tab will be the work area for the table i_tab.

so when you try appending a record in i_tab, populate fs_tab and use it .

append fs_tab to i_tab.

Let me know how it helped.

Yugandhar

Read only

matt
Active Contributor
0 Likes
2,706

>

> hi Yugandhar Kotha ,

>

> THANKS i try to declare with type and i have the same error,

> how i avoid the header line , i don't declare it i just declare table like

> structure in se 11.

>

> Regards

Go on, give us a clue. WHAT did you try? Post it here in tags...

Read only

0 Likes
2,706

Hi Kramer,

Kindly let us know if you have the problem still else close the thread.

Yugandhar

Read only

0 Likes
2,706

Hi Cosmo,

In OO programing there is no concept of the header line ... Instead of this create a Workarea of the same type.

\[removed by moderator\]

Edited by: Jan Stallkamp on Jun 20, 2008 1:46 PM

Read only

0 Likes
2,706

hi Matthew Billing, ,

Sorry for the time...

i have Fm that work fine,and i wont to do the same but in method,

i declare class & method and parameters of import ,

in the fm i have tables (itab like structure i build in se11) that when Execute the fm i get with data,

what i wont is : now How i declare table in method in se24 ?

Regards

Read only

0 Likes
2,706

if you want to define a parameter of a method as itab (table) then create a table type for your structure. Txn SE11, in data type field enter a name and click create, it will prompt you with options and choose the table type and within the definition use your structure.

On the way you handled points.

use the point system judiciously. you have given points (2) to both wrong answer as well as a close to right answer.

For Others who tried to answer

Please, read the question thrice before attempting to answer and if you dont know or if you are not sure, do not mislead .

Regards

Raja