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

Manipulate data in dynamic table

0 Likes
753

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

7 REPLIES 7
Read only

Former Member
0 Likes
707

check the thread..

Read only

Former Member
0 Likes
707

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

Read only

0 Likes
707

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

Read only

0 Likes
707

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

Read only

Former Member
0 Likes
707

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.

Read only

0 Likes
707

Any method for searching the dynamic table ?

Read only

0 Likes
707

i am not aware of any other searching technique for a dynamic table without using the loop and assigning technique