0% found this document useful (0 votes)
2 views4 pages

03 New ABAP Syntax

The document outlines various features of ABAP syntax, including complex case statements, aggregate functions, and inline data declarations. It provides examples of SQL queries, data manipulation, and looping through internal tables. The report serves as a reference for utilizing advanced ABAP programming techniques.

Uploaded by

Let us ABAP
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)
2 views4 pages

03 New ABAP Syntax

The document outlines various features of ABAP syntax, including complex case statements, aggregate functions, and inline data declarations. It provides examples of SQL queries, data manipulation, and looping through internal tables. The report serves as a reference for utilizing advanced ABAP programming techniques.

Uploaded by

Let us ABAP
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/ 4

*&---------------------------------------------------------------------*

*& Report znew_abap_syntax_nov


*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT znew_abap_syntax_nov.

"Feature 10 - Complex Case and select data from internal table

select bpa~company_name, ceil( sum( gross_amount ) ) as gross_amount,


amt~currency_code,
case when sum( gross_amount ) > 1000000 then 'High'
when sum( gross_amount ) > 500000 and sum( gross_amount ) <= 1000000 then
'Medium'
else 'Low' end as ord_type
from snwd_bpa as bpa inner join snwd_so as amt on
bpa~node_key = amt~buyer_guid
group by bpa~company_name, amt~currency_code
into table @data(itab).

select ord_type, sum( gross_amount ) as total_amount from @itab as mytab


group by ord_type into table @data(calc_table).

loop at calc_table into data(wa).


write: / wa-ord_type, wa-total_amount.
endloop.

"Feature 9 - Simple Case

*select bp_id, company_name,


* case bp_role
* when '01' then 'Customer'
* when '02' then 'Supplier'
* else 'I dont know'
* end as bp_role
* from snwd_bpa into table @data(itab).
*
*loop at itab into data(wa).
*write: / wa-bp_id, wa-company_name, wa-bp_role.
*endloop.

""Feature 8 - Using Aggregate function with Having clause, SQL Functions

*select bpa~company_name, ceil( sum( so~gross_amount ) ) as gross_amount,


so~currency_code
*from snwd_bpa as bpa inner join snwd_so as so on
*bpa~node_key = so~buyer_guid
*GROUP BY bpa~company_name, so~currency_code
*HAVING sum( so~gross_amount ) > 1000000
*into table @data(itab).
*
*loop at itab into data(wa).
*write: / wa-company_name, wa-gross_amount, wa-currency_code.
*endloop.

""Feature 7 - String liternal inside a select


*Select 'M/s' && ' ' && company_name as company_name from snwd_bpa into table
@data(itab).
*
*loop at itab into data(wa).
*write: / wa-company_name.
*endloop.

""Feature 6 - Looping internal table records as a Object


*types: BEGIN OF ty_game,
* team type c LENGTH 20,
* captain type c LENGTH 20,
* goals type i,
* END OF ty_game,
* tt_game type STANDARD TABLE OF ty_game WITH DEFAULT KEY.
*
*data(itab) = value tt_game( ( team = 'Liverpool' captain = 'Messi' goals = 8 )
* ( team = 'Manchester' captain = 'Ronaldo' goals = 9 )
* ( team = 'Chelsy' captain = 'Nymar' goals = 6 ) ).
*
*loop at itab reference into data(lo_line).
*
* WRITE : / lo_line->captain, lo_line->goals, lo_line->team.
*
*ENDLOOP.

""Feature 5 - Constructor Expression


*data: lo_obj type ref to cl_e2eie_ic_tc_dpc_ext.
*
*CREATE OBJECT lo_obj.
*data(lo_obj) = new cl_e2eie_ic_tc_dpc_ext( ).

""Feature 4 : Table Expression


*types: BEGIN OF ty_game,
* team type c LENGTH 20,
* captain type c LENGTH 20,
* goals type i,
* END OF ty_game,
* tt_game type STANDARD TABLE OF ty_game WITH DEFAULT KEY.
*
*data(itab) = value tt_game( ( team = 'Liverpool' captain = 'Messi' goals = 8 )
* ( team = 'Manchester' captain = 'Ronaldo' goals = 9 )
* ( team = 'Chelsy' captain = 'Nymar' goals = 6 ) ).
*
*
**read table itab into data(wa) with key captain = 'Ronaldo'.
*if ( line_exists( itab[ captain = 'Ronaldo' ] ) ).
* data(wa) = itab[ captain = 'Ronaldo' ].
*
* WRITE : wa-captain, wa-goals, wa-team.
*ENDIF.

""" Feature 3: String Expression


*data : lv_country type c LENGTH 20 value 'India',
* lv_string type string.
*
**CONCATENATE 'I Love ' '''' lv_country '''' INTO lv_string RESPECTING BLANKS.
*
*lv_string = |I Love '{ lv_country }'|.
*
*WRITE : lv_string.

""" Feature 2: Value Expression and Corresponding


*types: BEGIN OF ty_game,
* team type c LENGTH 20,
* captain type c LENGTH 20,
* goals type i,
* END OF ty_game,
* BEGIN OF ty_rugby,
* scrum type c LENGTH 20,
* master type c LENGTH 20,
* score type i,
* gold type c,
* END OF ty_rugby,
* tt_game type STANDARD TABLE OF ty_game WITH DEFAULT KEY,
* tt_rugby type STANDARD TABLE OF ty_rugby WITH DEFAULT KEY .
*
*data: itab type table of ty_game,
* jtab type table of ty_rugby.
*
*itab = value #( ( team = 'Liverpool' captain = 'Messi' goals = 8 )
* ( team = 'Manchester' captain = 'Ronaldo' goals = 9 ) ).
*
*jtab = CORRESPONDING #( itab MAPPING master = captain score = goals scrum =
team ).
*
*
*jtab = value #( for anubhav in itab ( master = anubhav-captain
* score = anubhav-goals
* scrum = anubhav-team
* gold = cond #( let ref_score = 9 in
* when anubhav-goals >=
ref_score then 'X'
* else ''
* )
*) ).

"Value Expression
*data(itab) = value tt_game( ( team = 'Liverpool' captain = 'Messi' goals = 8 )
* ( team = 'Manchester' captain = 'Ronaldo' goals = 9 ) ).

*wa-team = 'Liverpool'.
*wa-captain = 'Messi'.
*wa-goals = 8.
*append wa to itab.
*wa-team = 'Manchester'.
*wa-captain = 'Ronaldo'.
*wa-goals = 9.
*append wa to itab.

*loop at jtab into data(wa).


*write: / wa-master, wa-score, wa-scrum, wa-gold.
*endloop.

""" Feature 1: Inline data declaration


*data: itab type table of mara.
* wa like line of itab.

"in select query when we use inline declaration, use the


"@ symbol for escaping of host variable
*select matnr, matkl, meins UP TO 20 ROWS from mara into table @data(itab).
*
*"Inline declaration of field symbols
*loop at itab ASSIGNING FIELD-SYMBOL(<fs>).
*
* WRITE : <fs>-matnr, <fs>-matkl, <fs>-meins.
*
*ENDLOOP.

"Ctrl+7 - to comment your code in Eclipse tool


*loop at itab into data(wa).
*write : / wa-matnr, wa-matkl.
*endloop.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy