‎2008 Apr 14 9:44 AM
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?
‎2008 Apr 14 9:47 AM
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.
‎2008 Apr 14 9:47 AM
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.
‎2008 Apr 14 9:47 AM
Loop thru adress and then write ...
loop at adress.
write:/ adress.
endloop.
‎2008 Apr 14 9:48 AM
‎2008 Apr 14 9:48 AM
hi,
do this way ..
loop at adress.
*-----table-Output to screen
write : / adress-vorname, adress-nachname, adress-wohnort.
endloop.
‎2008 Apr 14 9:50 AM
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
‎2008 Apr 14 9:51 AM
hi,
u must have a loop .
loop at adress.
write : / adress-vorname, adress-nachname, adress-wohnort.
endloop.
Regards
Sindhu
‎2008 Apr 14 1:50 PM
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
‎2008 Apr 14 2:07 PM
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
‎2008 Apr 14 2:15 PM
thanks for the answer. The PKs should be unique though. So how can I use a non-transparent table?
‎2008 Apr 14 3:19 PM
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)?
‎2008 May 29 2:04 PM
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.
‎2008 Apr 14 1:50 PM
‎2008 Apr 14 6:19 PM
‎2013 May 16 2:03 PM
if u want multiple records use the loop and end loop in between use the write statement