- Değişken Tanımları
- Tablo İfadeleri
- Dönüşüm Operatörü CONV
- Değer Operatörü VALUE
- FOR Operatörü
- Azaltma Operatörü REDUCE
- Koşullu Operatörler COND ve SWITCH
- Taşıma Operatörü CORRESPONDING
- String Birleştirme Dönüşümler
- LOOP AT GROUP BY
- BOOLEAN kontrol
- Classes/Methods
- FILTER Operatörü
Değişken Tanımları
Data statement | |||
Before 7.40 |
|
||
With 7.40 |
|
||
Loop at into work area | |||
Before 7.40 |
|
||
With 7.40 |
|
||
Loop at assigning | |||
Before 7.40 |
|
||
With 7.40 |
|
||
Read assigning | |||
Before 7.40 |
|
||
With 7.40 |
|
||
Select into Table | |||
Before 7.40 |
|
||
With 7.40 |
|
||
Select single into | |||
Before 7.40 |
|
||
With 7.40 |
|
Tablo İfadeleri
Read Table index | |||
Before 7.40 |
|
||
With 7.40 |
|
||
Read Table with key | |||
Before 7.40 |
|
||
With 7.40 |
|
||
Does record exist? | |||
Before 7.40 |
|
||
With 7.40 |
|
||
Get table index | |||
Before 7.40 |
|
||
With 7.40 |
|
Dönüşüm Operatörü CONV
Before 7.40 | ||
|
||
With 7.40 | ||
|
Değer Operatörü VALUE
Structure örneği;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
TYPES: BEGIN OF ty_columns1, cols1 TYPE i, cols2 TYPE i, END OF ty_columns1. TYPES: BEGIN OF ty_columns2, coln1 TYPE i, coln2 TYPE ty_columns1, END OF ty_columns2. DATA: struc_simple TYPE ty_columns1, struc_nest TYPE ty_columns2. struc_nest = VALUE ty_columns2( coln1 = 1 coln2-cols1 = 1 coln2-cols2 = 2 ). |
Tablo ve Range örneği;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
TYPES t_itab TYPE TABLE OF i WITH EMPTY KEY. DATA itab TYPE t_itab. itab = VALUE #( ( ) ( 1 ) ( 2 ) ). DATA lr_exam TYPE RANGE OF i. lr_exam = VALUE #( sign = 'I' option = 'BT' ( low = 1 high = 10 ) ( low = 21 high = 30 ) ( low = 41 high = 50 ) option = 'GE' ( low = 61 ) ). |
FOR Operatörü
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
TYPES: BEGIN OF ty_customer, customer TYPE char10, name TYPE char30, city TYPE char30, route TYPE char10, END OF ty_customer. TYPES: tt_customers TYPE SORTED TABLE OF ty_customer WITH UNIQUE KEY customer. TYPES: tt_citys TYPE STANDARD TABLE OF char30 WITH EMPTY KEY. DATA(t_customres) = VALUE tt_customers( ( customer = 'C0001' name = 'Test Customer 1' city = 'NY' route = 'R0001' ) ( customer = 'C0002' name = 'Customer 2' city = 'LA' route = 'R0003' ) ( customer = 'C0003' name = 'Good Customer 3' city = 'DFW' route = 'R0001' ) ( customer = 'C0004' name = 'Best Customer 4' city = 'CH' route = 'R0003' ) ). |
Before 7.40 | ||
|
||
With 7.40 | ||
|
FOR with THEN and UNTIL|WHILE
1 2 3 4 5 6 7 8 |
TYPES: BEGIN OF ty_line, col1 TYPE i, col2 TYPE i, col3 TYPE i, END OF ty_line, ty_tab TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY. |
Before 7.40 | ||
|
||
With 7.40 | ||
|
Azaltma Operatörü REDUCE
Before 7.40 | ||
|
||
With 7.40 | ||
|
Before 7.40 | ||
|
||
With 7.40 | ||
|
Koşullu Operatörler COND ve SWITCH
Örnek 1
1 2 3 4 5 6 7 8 |
DATA(time) = COND string( WHEN sy-timlo < '120000' THEN |{ sy-timlo TIME = ISO } AM | WHEN sy-timlo > '120000' THEN |{ CONV t( sy-timlo - 12 * 3600 ) TIME = ISO } PM | WHEN sy-timlo EQ '120000' THEN |High Noon| ELSE 'ERROR' ). WRITE time. |
Örnek 2
1 2 3 4 5 6 |
DATA(text) = SWITCH #( sy-langu WHEN 'D' THEN 'DE' WHEN 'E' THEN 'EN' ELSE 'OTHER' ). WRITE text. |
Örnek 3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
DATA(lv_text) = NEW char10( 'ABCD@#@#' ). DATA(lv_output) = NEW char10( ). DO 10 TIMES. DATA(lv_offset) = NEW i( sy-index - 1 ). DATA(lv_char_part) = NEW char1( lv_text->*+lv_offset->*(1) ). DATA(lv_new_part) = SWITCH char1( lv_char_part->* WHEN 'A' THEN 'Z' WHEN 'B' THEN 'Y' WHEN 'C' THEN 'X' WHEN 'D' THEN 'W' ELSE 0 ). lv_output->*+lv_offset->*(1) = lv_new_part. ENDDO. WRITE: lv_output->*. |
Taşıma Operatörü CORRESPONDING
1 2 3 4 5 6 7 8 9 10 11 12 |
DATA ls_ekpo2 TYPE ekpo. SELECT * FROM ekpo INTO TABLE @DATA(lt_ekpo). DATA(ls_ekpo) = lt_ekpo[ 1 ]. MOVE-CORRESPONDING ls_ekpo TO ls_ekpo2. ls_ekpo2 = CORRESPONDING #( ls_ekpo ). |
String Birleştirme Dönüşümler
CONCATENATE
Before 7.40 | ||
|
||
With 7.40 | ||
|
Width/Alignment/Padding
1 2 3 4 |
WRITE / |{ 'Left' WIDTH = 10 ALIGN = LEFT PAD = '0' }|. WRITE / |{ 'Centre' WIDTH = 10 ALIGN = CENTER PAD = '0' }|. WRITE / |{ 'Right' WIDTH = 10 ALIGN = RIGHT PAD = '0' }|. |
Left000000
00Centre00
00000Right
Upper/Lower CASE
1 2 3 4 5 6 7 8 9 |
DATA(text) = 'Text'. TRANSLATE text TO LOWER CASE. TRANSLATE text TO UPPER CASE. WRITE / |{ 'Text' CASE = (cl_abap_format=>c_raw) }|. WRITE / |{ 'Text' CASE = (cl_abap_format=>c_upper) }|. WRITE / |{ 'Text' CASE = (cl_abap_format=>c_lower) }|. |
ALPHA Çevirici
1 2 3 4 5 6 7 8 9 |
DATA(lv_vbeln) = '0000012345'. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = lv_vbeln output = lv_vbeln. WRITE / |{ lv_vbeln ALPHA = OUT }|. |
Tarih Çevirici
1 2 3 4 5 6 7 8 |
DATA(pa_date) = sy-datum. WRITE / pa_date DD/MM/YYYY. WRITE / |{ pa_date DATE = ISO }|. WRITE / |{ pa_date DATE = USER }|. WRITE / |{ pa_date DATE = ENVIRONMENT }|. |
2018-12-03
03.12.2018
03.12.2018
LOOP AT GROUP BY
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
TYPES: BEGIN OF ty_customer, customer TYPE char10, name TYPE char30, city TYPE char30, route TYPE char10, END OF ty_customer. TYPES: tt_customers TYPE SORTED TABLE OF ty_customer WITH UNIQUE KEY customer. TYPES: tt_citys TYPE STANDARD TABLE OF char30 WITH EMPTY KEY. DATA(t_customres) = VALUE tt_customers( ( customer = 'C0001' name = 'Test Customer 1' city = 'NY' route = 'R0001' ) ( customer = 'C0002' name = 'Customer 2' city = 'LA' route = 'R0003' ) ( customer = 'C0003' name = 'Good Customer 3' city = 'DFW' route = 'R0001' ) ( customer = 'C0004' name = 'Best Customer 4' city = 'CH' route = 'R0003' ) ( customer = 'C0005' name = 'So So Customer 5' city = 'NY' route = 'R0001' ) ). DATA(ls_read) = t_customres[ 1 ]. LOOP AT t_customres INTO DATA(ls_cust_2) GROUP BY ( route = ls_cust_2-route ) ASCENDING REFERENCE INTO DATA(route_group_2). WRITE: / route_group_2->route. ENDLOOP. |
R0001
R0003
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
TYPES: BEGIN OF ty_employee, name TYPE char30, role TYPE char30, age TYPE i, END OF ty_employee, ty_employee_t TYPE STANDARD TABLE OF ty_employee WITH KEY name. DATA(gt_employee) = VALUE ty_employee_t( ( name = 'John' role = 'ABAP guru' age = 34 ) ( name = 'Alice' role = 'FI Consultant' age = 42 ) ( name = 'Barry' role = 'ABAP guru' age = 54 ) ( name = 'Mary' role = 'FI Consultant' age = 37 ) ( name = 'Arthur' role = 'ABAP guru' age = 34 ) ( name = 'Mandy' role = 'SD Consultant' age = 64 ) ). DATA: gv_tot_age TYPE i, gv_avg_age TYPE decfloat34. LOOP AT gt_employee INTO DATA(ls_employee) GROUP BY ( role = ls_employee-role size = GROUP SIZE index = GROUP INDEX ) ASCENDING ASSIGNING FIELD-SYMBOL(<group>). CLEAR: gv_tot_age. WRITE: / |Group: { <group>-index } Role: { <group>-role WIDTH = 15 }| & | Number in this role: { <group>-size }|. LOOP AT GROUP <group> ASSIGNING FIELD-SYMBOL(<ls_member>). gv_tot_age = gv_tot_age + <ls_member>-age. WRITE: /13 <ls_member>-name. ENDLOOP. gv_avg_age = gv_tot_age / <group>-size. WRITE: / |Average age: { gv_avg_age }|. SKIP. ENDLOOP. |
BOOLEAN kontrol
1 2 3 4 5 6 7 8 |
DATA lv_bool TYPE boolean. IF lv_bool EQ abap_true. WRITE 'TRUE'. ELSE. WRITE 'FALSE'. ENDIF. |
Classes/Methods
Before 7.40 | ||
|
||
With 7.40 | ||
|
Before 7.40 | ||
|
||
With 7.40 | ||
|
FILTER Operatörü
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
TYPES: BEGIN OF ty_filter, cityfrom TYPE spfli-cityfrom, cityto TYPE spfli-cityto, f3 TYPE i, END OF ty_filter, ty_filter_tab TYPE HASHED TABLE OF ty_filter WITH UNIQUE KEY cityfrom cityto. DATA: lt_splfi TYPE STANDARD TABLE OF spfli. SELECT * FROM spfli APPENDING TABLE lt_splfi. DATA(lt_filter) = VALUE ty_filter_tab( f3 = 2 ( cityfrom = 'NEW YORK' cityto = 'SAN FRANCISCO' ) ( cityfrom = 'FRANKFURT' cityto = 'NEW YORK' ) ). DATA(lt_myrecs) = FILTER #( lt_splfi IN lt_filter WHERE cityfrom = cityfrom AND cityto = cityto ). LOOP AT lt_myrecs ASSIGNING FIELD-SYMBOL(<ls_rec>). WRITE: / <ls_rec>-carrid,8 <ls_rec>-cityfrom,30 <ls_rec>-cityto,45 <ls_rec>-deptime. ENDLOOP. |