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

Problem: working with internal tables

Former Member
0 Likes
1,542

Hello,

I have a Problem using internal tables. My code is:

DATA: Begin of adress occurs 3,
        vorname(25) type c,
	 nachname(25) type c,
	 wohnort(25) type c,
end of adress.

*-----Insert Dataset
adress-vorname = 'Test'.
adress-nachname = 'Test'.
adress-wohnort = 'Test'.
append adress.

*-----Insert another Dataset
adress-vorname = 'Test2'.
adress-nachname = 'Test2'.
adress-wohnort = 'Test2'.
append adress.

*-----table-Output to screen
write adress.

I think I misunderstood how to use append. Because this could will only give the 2nd Dataset to screen.

How do I need to change this code to be able to write mutiple Datasets?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,511

Hi,

write like this.


DATA: Begin of adress occurs 3,
        vorname(25) type c,
	 nachname(25) type c,
	 wohnort(25) type c,
end of adress.
 
*-----Insert Dataset
adress-vorname = 'Test'.
adress-nachname = 'Test'.
adress-wohnort = 'Test'.
append adress.
 
*-----Insert another Dataset
adress-vorname = 'Test2'.
adress-nachname = 'Test2'.
adress-wohnort = 'Test2'.
append adress.
 
*-----table-Output to screen
loop at adress.
write adress.
endloop.

rgds,

bharat.

14 REPLIES 14
Read only

Former Member
0 Likes
1,512

Hi,

write like this.


DATA: Begin of adress occurs 3,
        vorname(25) type c,
	 nachname(25) type c,
	 wohnort(25) type c,
end of adress.
 
*-----Insert Dataset
adress-vorname = 'Test'.
adress-nachname = 'Test'.
adress-wohnort = 'Test'.
append adress.
 
*-----Insert another Dataset
adress-vorname = 'Test2'.
adress-nachname = 'Test2'.
adress-wohnort = 'Test2'.
append adress.
 
*-----table-Output to screen
loop at adress.
write adress.
endloop.

rgds,

bharat.

Read only

Former Member
0 Likes
1,511

Loop thru adress and then write ...

loop at adress.

write:/ adress.

endloop.

Read only

Former Member
0 Likes
1,511


write: adress-vorname,
adress-nachname,
adress-wohnort.

Read only

Former Member
0 Likes
1,511

hi,

do this way ..


loop at adress.
*-----table-Output to screen
write : / adress-vorname, adress-nachname, adress-wohnort.
endloop. 

Read only

Former Member
0 Likes
1,511

Hi Frd

Try This coding

loop at adress.

write adress.

endloop.

<REMOVED BY MODERATOR>

By

Pari

Edited by: Alvaro Tejada Galindo on Apr 14, 2008 1:10 PM

Read only

Former Member
0 Likes
1,511

hi,

u must have a loop .

loop at adress.

write : / adress-vorname, adress-nachname, adress-wohnort.

endloop.

Regards

Sindhu

Read only

0 Likes
1,511

Hello,

thank for the answers so far. That part works now.

At the moment I am trying to find something about how to define primary keys in these internal tables.

I can't find anything about this so far. So How can I set which komponent the PK is?

thanks

Read only

0 Likes
1,511

Hi,

Use this sample code..

DATA it_supp TYPE TABLE OF table_name WITH NON-UNIQUE KEY comp1 comp2.

comp1 and comp2 components of table_name.

why NON-UNIQUE ? Since u r referencing a transparent table.

<REMOVED BY MODERATOR>

Regards,

ABAPer 007

Edited by: Alvaro Tejada Galindo on Apr 14, 2008 1:11 PM

Read only

0 Likes
1,511

thanks for the answer. The PKs should be unique though. So how can I use a non-transparent table?

Read only

0 Likes
1,511

ok I think I found a partwise solution:

*TableTyp
TYPES: BEGIN OF LINE,
COLUMN1 TYPE c,
COLUMN2 TYPE c,
COLUMN3 TYPE c,
END OF LINE.
*Primary Key
TYPES ITAB TYPE SORTED TABLE OF LINE WITH UNIQUE KEY COLUMN1.
*Instance
DATA: tabellePrim like LINE.

*Put some values
tabellePrim-COLUMN1 = 'Aaa'.
tabellePrim-COLUMN2 = 'cfd'.
tabellePrim-COLUMN3 = 'eee'.
append tabellePrim.

The errors are where I put some values in. I think the process ist different from the so called transparent tables. So my next step is to find out how to put some Datasets in it and how to read them out afterwards (using WHERE)?

Read only

0 Likes
1,511

You declared your table as type sorted. Use the insert keyword rather than the append.

Please refer to the online help documentation for more information on working with internal tables and the [INSERT|http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb361f358411d1829f0000e829fbfe/frameset.htm] command.

Read only

Former Member
0 Likes
1,511

new Question

Read only

Former Member
0 Likes
1,511

Hi,

Use the write statement inside

LOOP ENDLOOP.

Read only

0 Likes
1,511

if u want multiple records use the loop and end loop in between use the write statement