0% found this document useful (0 votes)
10 views3 pages

Abap

Uploaded by

a.zorn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Abap

Uploaded by

a.zorn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

* Copy interne Tabelle

---------------------------------------------------------------

* komplette Tabelle durch Zuweisung


itab2 = itab1.

*nur bestimmte Spalten – MOVE-CORRESPONDING


MOVE-CORRESPONDING itab1 TO itab2.

*nur bestimmte Spalten – CORRESPONDING


itab2 = CORRESPONDING #( itab1 ).

*manuell mit Feldsymbolen (~30% langsamer als die beiden vorherigen Varianten)
LOOP AT itab1 ASSIGNING FIELD-SYMBOL(<wa_1>).
APPEND INITIAL LINE TO itab2 ASSIGNING FIELD-SYMBOL(<wa_2>).
MOVE-CORRESPONDING <wa_1> TO <wa_2>.
ENDLOOP.

* copy end---------------------------------------------------------------

* Dek. Var. ---------------------------------------------------------------


type ref to
like line of
like
type

data initial_numbers type test2->initial_numbers.


append VALUE #( group = 'A' number = 19 ) to initial_numbers.

*example 2:
TYPES: BEGIN OF aggregated_data_type,
group TYPE group,
count TYPE i,
sum TYPE i,
min TYPE i,
max TYPE i,
average TYPE f,
END OF aggregated_data_type,
aggregated_data TYPE STANDARD TABLE OF aggregated_data_type WITH EMPTY KEY.

aggregated_data = value #( base aggregated_data "copy to table via base as


foundation
( group = <number>-group count = 1
sum = <number>-number average = <number>-
number max = <number>-number min = <number>-number ) ).

* Dek. Var. ---------------------------------------------------------------

* Loops ---------------------------------------------------------------

** easy loop
loop at initial_numbers REFERENCE into data(initial_number).
write initial_number->number .
endloop.

** 2 loops with GROUP


LOOP AT initial_numbers REFERENCE INTO DATA(initial_number)
GROUP BY ( key = initial_number->group count = GROUP SIZE ) ASCENDING
REFERENCE INTO DATA(group_key). "group by key /w
APPEND INITIAL LINE TO aggregated_data REFERENCE INTO DATA(aggregated_item).
"append initial line -> empty line of aggregated_data
aggregated_item->group = group_key->key.
aggregated_item->count = group_key->count.
aggregated_item->min = 9999999.
LOOP AT GROUP group_key REFERENCE INTO DATA(group_item).
aggregated_item->sum = aggregated_item->sum + group_item->number.
aggregated_item->min = nmin( val1 = aggregated_item->min
val2 = group_item->number ).
aggregated_item->max = nmax( val1 = aggregated_item->max
val2 = group_item->number ).
ENDLOOP.
aggregated_item->average = aggregated_item->sum / aggregated_item->count.
ENDLOOP.

**end Loops ---------------------------------------------------------------

* for example 1
TYPES: BEGIN OF alphatab_type,
cola TYPE string,
colb TYPE string,
colc TYPE string,
END OF alphatab_type.
TYPES alphas TYPE STANDARD TABLE OF alphatab_type.

TYPES: BEGIN OF numtab_type,


col1 TYPE string,
col2 TYPE string,
col3 TYPE string,
END OF numtab_type.
TYPES nums TYPE STANDARD TABLE OF numtab_type.

TYPES: BEGIN OF combined_data_type,


colx TYPE string,
coly TYPE string,
colz TYPE string,
END OF combined_data_type.
TYPES combined_data TYPE STANDARD TABLE OF combined_data_type WITH EMPTY KEY.

LOOP AT alphas REFERENCE INTO DATA(alpha).


combined_data = VALUE #( FOR ls_alpha IN alphas INDEX INTO lv_index
( colx = ls_alpha-cola && VALUE
string( nums[ lv_index ]-col1 OPTIONAL )
coly = ls_alpha-colb && VALUE
string( nums[ lv_index ]-col2 OPTIONAL )
colz = ls_alpha-colc && VALUE
string( nums[ lv_index ]-col3 OPTIONAL ) ) ).

"or
combined_data = value #( for i = 1 while i < lines( alphas ) + 1
(
colx = alphas[ i ]-cola && VALUE string( nums[ i ]-col1 optional )
coly = alphas[ i ]-colb && VALUE string( nums[ i ]-col2 optional )
colz = alphas[ i ]-colc && VALUE string( nums[ i ]-col3 optional )
)
).

*end for

-----------------------------------------------------------------------------------

/nbapi -> Methode SalesOrder.CreateWithDia Anlegen von Datencontainer mit Dialog


und mehr

*demo*
b*demo*

You might also like