‎2006 May 22 9:32 AM
Hi,
How can I modify/delete data in a dyanmic table ?
i have created the <dytable>.
Can i read it with conditions ? like :
read table <dytable> with key field1 = 'abc'.
if i use loop & assign, it is too slow.
loop at <dytable> assigning <dytable_line>.
assigning component 'FIELD' to <fs>.
if <fs> = 'abc'
Thanks
Wilson
‎2006 May 22 9:34 AM
‎2006 May 22 9:42 AM
Hai Wilson
Variables for later use
DATA: TABLENAME(10),
COUNT_ROWS TYPE I.
Setting the table name dynamically
MOVE 'CUSTOMERS' TO TABLENAME.
Selecting data
SELECT COUNT( * ) FROM (TABLENAME) INTO COUNT_ROWS.
WRITE: TABLENAME, COUNT_ROWS.
Parameters for reading a single line, can be modified by the end user
PARAMETERS: KEY1(10) DEFAULT 'NAME',
VALUE1(25),
KEY2 LIKE KEY1 DEFAULT 'ID',
VALUE2 LIKE VALUE1.
Declarations for later use
TABLES CUSTOMERS.
DATA ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 100
WITH HEADER LINE.
Filling the internal table
SELECT * FROM CUSTOMERS INTO TABLE ALL_CUSTOMERS.
Dynamic read table command
READ TABLE ALL_CUSTOMERS
WITH KEY (KEY1) = VALUE1
(KEY2) = VALUE2.
Displaying the result
IF SY-SUBRC EQ 0.
WRITE: / ALL_CUSTOMERS-ID,
ALL_CUSTOMERS-NAME,
ALL_CUSTOMERS-CITY,
ALL_CUSTOMERS-TELEPHONE.
ELSE.
WRITE 'Entry not found'.
ENDIF.
Thanks & regards
Sreeni
‎2006 May 22 10:16 AM
Hello,
I am using field-symbols, not dynamic statement.
And i don't want to use loop at assign because it is slow for me.
Thanks
Wilson
‎2006 May 22 10:28 AM
Hi
I don't believe you can do it, because the system can know the fields only at run-time, so you'll get an error while actving or generating your report.
You can have some chance if the field-symbol is directly linked to a structure:
TYPES: BEGIN OF LT_ITAB,
FIELD1.....,
FIELD2.....,
END OF LT_ITAB.
TYPES: GT_ITAB TYPE STANDARD TABLE OF LT_ITAB.
FIELD-SYMBOLS: <FS_ITAB> TYPE GT_ITAB,
<WA> TYPE ANY.
READ TABLE <FS_ITAB> INTO <WA> WITH KEY FIELD1 = 'XXXX'.
Max
‎2006 May 22 10:30 AM
You cannot read the table using the standard read statement. But if you want to delete the rows from the dynamic table use the statement delete itab index sy-tabix.
‎2006 May 22 10:33 AM
‎2006 May 22 10:36 AM
i am not aware of any other searching technique for a dynamic table without using the loop and assigning technique