Questions tagged [internal-tables]

Use this tag for questions regarding ABAP internal tables.

141 questions
17
votes
2 answers

Delete the current row from an internal table in a loop

Can I safely delete the active row while looping over an internal table? As an example, consider this code: LOOP AT lt_itab INTO ls_wa. IF [...] . " A check that can't be done inside a 'DELETE lt_itab WHERE' DELETE lt_itab INDEX…
Lilienthal
  • 4,327
  • 13
  • 52
  • 88
8
votes
1 answer

Most efficient itab filtering with ABAP 7.40+ syntax

With release 7.40 we have plenty of ways to filter internal table data. For example, one can use such ABAP constructs: FILTER operator DATA(lt_extract) = FILTER #( lt_bseg USING KEY matnr_bwtar WHERE matnr = CONV matnr( SPACE ) …
Suncatcher
  • 10,355
  • 10
  • 52
  • 90
8
votes
5 answers

How to set dynamic key for READ TABLE?

I'm trying to work out a way to read an internal table that has to be created dynamically. I have created the following report that fills a dynamic internal table with data. On the last line, I'm trying to read it with a key (mandt for example), but…
B. Bowles
  • 764
  • 4
  • 9
  • 21
7
votes
3 answers

Syntax for creating internal table from existing database table?

I'm new to ABAP. Started learning about internal tables. I was reading on the ways to create internal tables. I came across the following syntax to create an internal table from an existing database table: data: it_mara type table of mara. I'm…
The-Droidster
  • 635
  • 7
  • 13
7
votes
3 answers

Table comprehensions: get subset from internal table into another one

As stated in the topic, I want to have a conditioned subset of an internal table inside another internal table. Let us first look, what it may look like the old fashioned way. DATA: lt_hugeresult TYPE tty_mytype, lt_reducedresult TYPE…
icbytes
  • 1,831
  • 1
  • 17
  • 27
7
votes
4 answers

Count itab rows that meet some condition?

I get a internal table from a Function Module call that returns ~ 100 rows. About 40% of the rows are not relevant to me because I only need the entries with PAR1 = "XYZ". On SQL tables (transparent tables), I can use a select count(*) from tab…
Jasper
  • 660
  • 1
  • 7
  • 19
6
votes
3 answers

DELETE ADJACENT DUPLICATES delete order?

If there are entries with the same key. sort itab by key. delete adjacent duplicates from itab comparing key. Does anyone know which one will be deleted if delete adjacent duplicates..comparing key? The first one or second one?
Dustin Sun
  • 5,292
  • 9
  • 49
  • 87
6
votes
5 answers

Find last matching result using "read table with key"

I need to find the sy-tabix of a the last entry in an internal table that matches v_key = x. I'm trying to do it with: read table i_tab with key v_key = x But since there are multiple entries in the table that match v_key = x, how can I make sure I…
Suimon
  • 271
  • 1
  • 6
  • 15
6
votes
3 answers

Extracting unique values from an internal table

What is the most efficient way to extract the unique values from a column or multiple columns of an internal table?
Lilienthal
  • 4,327
  • 13
  • 52
  • 88
5
votes
3 answers

What is the shortest notation for updating a column in an internal table?

I have an ABAP internal table. Structured, with several columns (e.g. 25). Names and types are irrelevant. The table can get pretty large (e.g. 5,000 records). | A | B | ... | | --- | --- | --- | | 7 | X | ... | | 2 | CCC | ... | | 42 |…
Florian
  • 4,821
  • 2
  • 19
  • 44
5
votes
1 answer

Warning when secondary key fully specified but not used, but if specified then error

I am baffled. If I compile the following piece of code REPORT zzy. CLASS lcl_main DEFINITION FINAL CREATE PRIVATE. PUBLIC SECTION. CLASS-METHODS: class_constructor, main. PRIVATE SECTION. TYPES: BEGIN OF t_record, …
Jagger
  • 10,350
  • 9
  • 51
  • 93
5
votes
3 answers

READ TABLE with dynamic key fields?

I have the name of a table DATA lv_tablename TYPE tabname VALUE 'xxxxx', and a generic FIELD-SYMBOLS: TYPE ANY TABLE. which contains entries selected from that corresponding table. I've defined my line structure FIELD-SYMBOLS:
vlad-ardelean
  • 7,480
  • 15
  • 80
  • 124
4
votes
1 answer

Best way to check if a line with non-initial field exists?

Let's say I have a table quants and want to find out if any line exists, where the field lenum is not initial. The table is declared inline using a select statement, so I do not have a key available. Because I don't have a key, the following…
Kevin Holtkamp
  • 479
  • 4
  • 17
4
votes
1 answer

Adding the values of a field using FOR loop

How do I add the values in a field based on the same values in another field using FOR loop? Types: Begin of ty_final, doctype type char5, posnr type char5, total type quan5, End of ty_final. DATA(lt_final) = VALUE ty_final( …
isekaid_maou
  • 273
  • 1
  • 9
  • 19
4
votes
1 answer

How to transpose an internal table rows into columns?

I want to transpose my internal table rows into column and i want to fix the first column,i am trying to do it with the following code but i am not getting the expected result....it is not converting all the rows into columns *Types…
rhsabbir
  • 247
  • 1
  • 6
  • 19
1
2 3
9 10