Home > Ask the SAP software/management Experts > Application development Questions & Answers > Deleting entries from a dynamic table
Ask The SAP Expert: Questions & Answers
EMAIL THIS

Deleting entries from a dynamic table

Matthew Billingham EXPERT RESPONSE FROM: Matthew Billingham

Pose a Question
Other SAP Categories
Meet all SAP Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 14 April 2008
I have dynamic internal table . How do I delete entries from this table on the basis of some condition?


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Application development
How to implement SAP BADIs
How to correct an SAP ABAP dump with an oversize condition
Creating a function group for an SAP ABAP table maintenance generator
How can I get an ABAP program displaying Excel data to wrap text?
How to read an SAP transaction in an ABAP code
How to create Include programs in the ABAP editor
Defining a structure in a report
Is there a 'load of program' option in report generation?
Validating table fields
The difference between field groups and internal tables

SAP workflow development
How to do additional dialog processing after SAP COMMIT WORK statement
SAP TechEd Demo Jam 2009: Winners use beer keg in demo
How to replace a cancelled SAP workflow item
Retrieving content from an SAP workflow attachment
Changing reserved status of a workflow item
Why you shouldn't change SAP-related workflows in an SWUI
Finding BADIs you can use
Select Text fields: Case-insensitive
Using change documents to update a Z table
Approving workflows from Outlook

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


Well, you can't use DELETE WHERE with dynamic tables, but it is still possible to delete records. Consider a situation where you want to delete all entries in where FIELD1 (one of the fields in the table) is equal to 'X'.

DATA. lp_data TYPE REF TO DATA.
FIELD-SYMBOLS:  TYPE ANY,
                TYPE ANY.

CREATE DATA lp_data LIKE LINE OF .
ASSIGN lp_data->* to .

ASSIGN COMPONENT 'FIELD1' OF STRUCTURE  TO .

LOOP AT  INTO .
  CHECK  EQ 'X'.
  DELETE TABLE  FROM .
ENDLOOP.

Another possibility is to use, for example, with a table that has key fields kf1 and kf2:
DELETE TABLE WITH TABLE KEY ('KF1') = val1 ('KF2') = val2.

With fully specified keys this is very efficient for HASHED tables, somewhat efficient for SORTED tables, and not very efficient, usually, for STANDARD tables.

As ever, what you actually write depends on precisely what you are trying to achieve.




Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



SAP White Paper Topics
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
SearchSAP.com is a search service provided by TechTarget and is completely
independent of and not affiliated with SAP AG.
  TechTarget - The IT Media ROI Experts