Master SAP ABAP: Assignment 6 Submission

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Assignment 6 Submission

Master SAP ABAP on HANA

Submitted by – SALIM
Assignment 6 – Master ABAP on HANA
Q1. Get the materials with highest Net Price, lowest Net Price, average Net Price, Sum
Total of Net Price, and count of material from VBAP table.
Where Net price = NETWR & Material = MATNR in VBAP table
Hints: Use aggregate functions to find it.
SOL: SELECT MAX( netwr ) AS highest_net_price,
MIN( netwr ) AS lowest_net_price,
AVG( netwr ) AS average_net_price,
SUM( netwr ) AS sum_net_price,
COUNT(*) AS count_of_matnr,
matnr
FROM vbap INTO TABLE @DATA(it_agg) GROUP BY matnr.

cl_demo_output=>display_data( EXPORTING value = it_agg ).

Q2. From Q1, Filter the list of Material, where Total Sum of Net Price is greater 50000.
SOL: SELECT MAX( netwr ) AS highest_net_price,
MIN( netwr ) AS lowest_net_price,
AVG( netwr ) AS average_net_price,
SUM( netwr ) AS sum_net_price,
COUNT(*) AS count_of_matnr,
matnr
FROM vbap INTO TABLE @DATA(it_agg) GROUP BY matnr
HAVING SUM( netwr ) > 50000.

cl_demo_output=>display_data( EXPORTING value = it_agg ).

Q3. Get Purchase order (EBELN) list from EKKO table for company code = 1010 and put in
an internal table say (IT_EKKO). Now fetch Purchase order (EBELN), Item No (EBELP),
Material No (MATNR) from EKPO table using FOR ALL ENTRIES IN IT_EKPO-EBELN and
display.
Achieve the same requirement with the help of Sub queries (i.e. without using the FOR
ALL ENTRIES or INNER JOIN)
SOL:
SELECT ebeln FROM ekko WHERE bukrs = '1010'
INTO TABLE @DATA(it_ebeln).
IF it_ebeln IS NOT INITIAL.
SELECT ebeln, ebelp, matnr FROM ekpo
INTO TABLE @DATA(it_ekpo)
FOR ALL ENTRIES IN @it_ebeln
WHERE ebeln = @it_ebeln-ebeln.
ENDIF.

WhatsApp +1-251-727-9273 All ZAPYard’s LIVE Training History mail@ZAPYard.com Page1


Assignment 6 – Master ABAP on HANA

* Display data
cl_demo_output=>display_data( EXPORTING value = it_ekpo ).

SELECT ebeln, ebelp, matnr FROM ekpo


INTO TABLE @DATA(it_ekpo)
WHERE ebeln IN ( SELECT ebeln FROM ekko WHERE bukrs = '1010' ).

* Display data
cl_demo_output=>display_data( EXPORTING value = it_ekpo ).

Q4. Write a program to demonstrate the below SQL String functions/Mathematical


function –
1. CONCAT
2. CONCAT_WITH_SPACE
3. LPAD
4. RPAD
5. SUBSTRING
6. LOWER
7. UPPER
8. LTRIM
9. RTRIM
10. LENGTH
11. ABS
12. ROUND
13. CIEL
14. Floor
15. DIV
16. DIVISION

SOL:
DELETE FROM demo_expressions.

COMMIT WORK.

DATA: it_expression TYPE TABLE OF demo_expressions.


DATA: wa_expression TYPE demo_expressions.

WhatsApp +1-251-727-9273 All ZAPYard’s LIVE Training History mail@ZAPYard.com Page2


Assignment 6 – Master ABAP on HANA
wa_expression-id = 'X'.
wa_expression-char1 = ' 0123'.
wa_expression-char2 = 'aAAAA'.
wa_expression-dec1 = -10.
wa_expression-dec2 = '3.45'.
APPEND wa_expression TO it_expression.

INSERT demo_expressions FROM TABLE it_expression.

SELECT SINGLE
char1 AS fieldchar1,
char2 AS fieldchar2,
dec1 AS fielddec1,
dec2 AS fieldec2,
concat( char1, char2 ) AS concat_function,
concat_with_space( char1, char2, 1 ) AS concat_with_space,
lpad( char2, 10,'X' ) AS char2_lpad_10_with_x,
rpad( char2, 12,'Y' ) AS char2_rpad_12_with_y,
substring( char2,3,2 ) AS substring_char2_3_2,
lower( char2 ) AS lower_string_char2,
upper( char2 ) AS upper_string_char2,
ltrim( char2, 'a' ) AS char2_ltrim_a,
rtrim( char2, 'A' ) AS char2_rtrim_a,
length( char2 ) AS length_char2,
abs( dec1 ) AS abs_dec1,
round( dec2 , 1 ) AS round_dec2,
ceil( dec2 ) AS ciel,
floor( dec2 ) AS floor,
div( abs( dec1 ) , 3 ) AS div, "3
division( 10, 3, 3 ) AS divsion_up_to_3
FROM demo_expressions
WHERE id = 'X' INTO @DATA(gs_output).

* Display data
cl_demo_output=>display_data( EXPORTING value = gs_output ).

Q5. Get the data (VBELN, VBTYP, AUART, KUNNR, VKORG) from VBAK table for AUART =
‘TA’, VKORG = ‘GH04’. Again get the same fields from VBAK table for AUART = ‘YOR’ and
NETWR > 100. Combined both results using UNION and DISPLAY.
SOL:

WhatsApp +1-251-727-9273 All ZAPYard’s LIVE Training History mail@ZAPYard.com Page3


Assignment 6 – Master ABAP on HANA
SELECT vbeln, vbtyp, auart, kunnr, vkorg FROM vbak WHERE auart = 'TA' AND vko
rg = 'GH04'

UNION

SELECT vbeln, vbtyp, auart, kunnr, vkorg FROM vbak WHERE auart = 'YOR' AND ne
twr GT '100'

INTO TABLE @DATA(it_union_res).

* Display data
cl_demo_output=>display_data( EXPORTING value = it_union_res ).

WhatsApp +1-251-727-9273 All ZAPYard’s LIVE Training History mail@ZAPYard.com Page4

You might also like