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

internal table

Former Member
0 Likes
1,716

Please use an informative subject in future

Hi,

Can any one pls tell me how to define internal table in OOABAP.

my requirement is , i need to define a internal table of type KNA1.

and itab1 like itab occurs 1 with header line.how to define this in OOABAP

when i defined like....itab like kna1.it is showing an error saying like should not be used in ooabap.

how should i write that.

Edited by: Matt on Mar 17, 2009 11:09 AM

17 REPLIES 17
Read only

Former Member
0 Likes
1,673

TRY BELOW CODE :

DATA: ITAB TYPE TABLE OF KNA1.

Read only

0 Likes
1,673

Thanks for the quick response

there is a structure zstruct with 10 fields

and can i write the code as.......

data str type zstruct.

or is there any standard way

Read only

0 Likes
1,673

Use "data str type zstruct.", you will get a structure.

If you want a internal table, should write "data strtab type table of zstruct.", it will create an internal table without header line, and line structure is same as zstruct.

The loop statement should be:

DATA: ftabix TYPE i.

LOOP AT strtab INTO str.

ftabix = sy-tabix.

str-com1 = ''.....

MODIFY strtab FROM str INDEX ftabix.

ENDLOOP.

Read only

0 Likes
1,673

Hi

u can create internal table using structure

str type STANDARD TABLE OF zstruct.

eg:

types:BEGIN OF str1,

empid type zprtable-empid,

uname type zprtable-uname,

password type zprtable-password,

end of str1 .

types:

itab type STANDARD TABLE OF str1 .

Regards

Arun

Read only

0 Likes
1,673

Hi,

Just as a rule of thumb, normally we like to define it like this:

1. Type declaration

TYPES: BEGIN OF ABC

FIELD1 TYPE char01,

FIELD2 TYPE sy-uname,

END OF ABC

2. work area declaration

DATA: WA_ABC TYPE ABC

3. Internal table declaration

DATA: WA_ABC TYPE TABLE OF ABC, or

DATA: WA_ABC LIKE TABLE OF WA_ABC.

Actually there is no rigid rule for declaration.

Regards,

Lim...

Read only

0 Likes
1,673

Hi,

Data : it_struct type standard table of str,

wa_struct type str.

This is the format in OOABAP.

Thanks.

Read only

0 Likes
1,673

Hi,

Use like below,

DATA BEGIN OF gt_struct.
        INCLUDE STRUCTURE sflight.
DATA rcol(4) TYPE c.
DATA colors TYPE lvc_t_scol.
DATA END OF gt_struct.

Regards

Bala Krishna

Read only

0 Likes
1,673

The mainly diffirent from OOABAP and classic ABAP is that, in OOABAP, the internal table must not have the header line.

Read only

Former Member
0 Likes
1,673

hi

try this..



Types: begin of i_tab ,
          name1 type kna1-name1,
          end of i_tab.

DATA: it_tab type standard table of i_tab.

hope this help you

Regards

Ritesh J

Read only

faisalatsap
Active Contributor
0 Likes
1,673

Hi,

Test the following.

DATA: it_kna1 LIKE STANDARD TABLE OF kna1, " Internal Table
      wa_it_kna2 LIKE kna1.                " Workarea or HeaderLine

Best Regards,

Faisal

Read only

Former Member
0 Likes
1,673

Hi,

Try below logic.

DATA: it_kna1 type standard table of kna1,

wa_kna1 type kna1.

Thanks,

Asit Purbey.

Read only

faisalatsap
Active Contributor
0 Likes
1,673

Hi, M S

Total Questions:   	 16 (15 unresolved)

Please Close you open Questions.

Best Regards,

Faisal

Read only

Former Member
0 Likes
1,673

hi,

You can do it this way

DATA: i_KNA1 type standart table of KNA!.

Hope this will help u

Thanks and Regards

Suraj S. Niar

Read only

Former Member
0 Likes
1,673

**OOABAP DO NOT ACCEPT INTERNAL TABLES WITH HEADER LINES.***

SO FIRST DECLARE

TYPES : BEGIN OF TY_TAB,

FIELD1,

END OF TY-TAB.

DATA: GT_TAB TYPE TABLE OF TY_TAB

DATA:GS_TAB LIKE LINE OF GT_TAB.

Read only

Former Member
0 Likes
1,673

TYPES: BEGIN OF t_kna1 ,

kunnr TYPE kunnr,

name1 TYPE name1,

END OF t_kna1.

Data: i_kna1 TYPE STANDARD TABLE OF t_kna1.

Regards,

Joan

Read only

matt
Active Contributor
0 Likes
1,673

Please use an informative subject in future

Once you've got your type, why not use the full declarative statement for tables.

DATA: mytab TYPE STANDARD¦HASHED¦SORTED TABLE WITH (NON-)UNIQUE KEY key1 key2.

or

DATA: mytab TYPE STANDARD¦HASHED¦SORTED TABLE WITH (NON-)UNIQUE KEY table_line.

Read only

Former Member
0 Likes
1,673

Hi In OPps u should not use occurs in internal table creation.

and u should not use include alos

like include mara.

you should crete structure and then internal table like itab type table of st

wa type st.

or else itab type standard table of mara.

Regards