0% found this document useful (0 votes)
13 views2 pages

HANA Class 6 Code

Uploaded by

nnxdt9d9dq
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)
13 views2 pages

HANA Class 6 Code

Uploaded by

nnxdt9d9dq
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/ 2

Program 1 ZDEC_OIA_SIMPLE.

report zdec_oia_simple.
types: begin of ty_avg_days,
bp_id type snwd_bpa-bp_id,
open_days type int4,
inv_count type int4,
end of ty_avg_days,

begin of ty_amount,
bp_id type snwd_bpa-bp_id,
company_name type snwd_bpa-company_name,
gross_amount type snwd_so_inv_head-gross_amount,
currency_code type snwd_so_inv_head-currency_code,
end of ty_amount.

begin of ty_oia,
bp_id type snwd_bpa-bp_id,
avg_open_days type int4,
company_name type snwd_bpa-company_name,
gross_amount type snwd_so_inv_head-gross_amount,
currency_code type snwd_so_inv_head-currency_code,
tagging type c,
end of ty_oia.
data: lt_days type table of ty_avg_days,
ls_days type ty_avg_days,
lt_gross type table of ty_amount,
ls_gross type ty_amount,
lt_oia type table of ty_oia,
ls_oia type ty_oia.

data(lo_timer) = cl_abap_runtime=>create_hr_timer().
data(t1) = lo_timer->get_runtime().
select bp_id, head~changed_at
from snwd_so_inv_head as head
inner join snwd_bpa as bpa
on head~buyer_guid = bpa~node_key
where head~payment_status = ' '
into @data(ls_head).

convert time stamp ls_head-changed_at time zone


sy-zonlo into date data(lv_date).
ls_days-open_days = sy-datum - lv_date.
ls_days-inv_count = 1.
ls_days-bp_id = ls_head0bp_id.
collect ls_days into lt_days.
endselect.

select single * into @data(ls_threshold) from


zdp_cust where id = sy-uname.

*takt 2 developments.
select bp_id,company_name, item~gross_amount,
item~currency_code as currency_code
from snwd_so_inv_item as item inner join
snwd_so_inv_head as head
on item~parent_key = head~node_key
inner join snwd_bpa as bpa
on bpa~node_key = head~buyer_guid
where head~payment_status = ''
into @data(ls_amt).
call function 'convert_to_local_currency'
exporting
date = sy-datum
foreign_amount = ls_amt-gross_amount
foreign_currency = ls_amt-currency_code
local_currency = ls_threshold-currency_code
importing
local_amount = ls_gross-gross_amount.

ls_gross = corresponding #(ls_amt).


collect ls_gross into lt_gross.

ENDSELECT.

loop at to lt_days into ls_days.


move-corresponding ls_days to ls_oia.

read table lt_gross into ls_gross with key bp_id = ls_days-bp_id.


ls_oia-gross_amount = ls_gross-gross_amount.
ls_oia-currency_code = ls_gross-currency_code.
ls_oia-company_name = ls_gross-comapny_name.
ls_oia-avg_open_days = ls_days-open_days/ls_days-inv_count.
if ls_oia-avg_open_days > ls_threshold-max_open_days.
ls_oia-tagging = 'X'.
else.
clear: ls_oia-tagging.
endif.
append ls_oia to lt_oia.
endloop.

data(t2) = lo_timer->get_runtime().
data(times) = (t2-t1)/1000.
cl_demo_output=>write_text( text = |the total time taken is {times} ms|).
cl_demo_output=>display_data(
exporting
value = lt_oia
).

You might also like