
Create a Remote Source
Set Remote Source
Check Remote Source
*&---------------------------------------------------------------------*
*& Report ZICA_CREATE_VIRTUAL_TABLE
*&---------------------------------------------------------------------*
*& Use this report to create/delete a virtual table in SAP<SID> schema.
*& Prerequites:
*& 1. You must have a remote source created in HANA.
*& 2. DB user SAP<SID> has "create virtual table" permission on
*& the remote source.
*& "Grant CREATE VIRTUAL TABLE on remote source <rs_name> to SAP<SID>"
*& Result:
*& A virtual table is created in schema SAP<SID> with prefix '/1BCAMDP/'
*&---------------------------------------------------------------------*
report zica_create_virtual_table.
parameters: vt_name type string obligatory, " the to-be-created virtual table name
remote type string, " remote source
schema type string, " the DB schema in the remote source
rt_name type string, " the remote table name
delete as checkbox. " delete the virtual table
at selection-screen.
if delete = abap_false and
( remote is initial or schema is initial or rt_name is initial ).
message 'Parameters remote, schema, and rt_name are mandatory!' type 'E'.
endif.
start-of-selection.
data(lv_virtual_table_name) = |"/1BCAMDP/{ vt_name }"|.
data(lv_remote_table_name) = |"{ remote }"."NULL"."{ schema }"."{ rt_name }"|.
data lv_ddl_string type string.
if delete = abap_false.
lv_ddl_string = |create virtual table { lv_virtual_table_name } at { lv_remote_table_name }|.
else.
lv_ddl_string = |drop table { lv_virtual_table_name }|.
endif.
try.
data(mo_sql) = new cl_sql_statement( ).
mo_sql->execute_ddl( lv_ddl_string ).
message 'Action is successfully performed!' type 'S'.
catch cx_sql_exception into data(lo_exc).
raise shortdump lo_exc.
endtry.
Grant CREATE VIRTUAL TABLE on remote source ICMR to <Schema of S/4HANA>;
Create Virtual Table using ABAP
Create Virtual Table
Define Virtual Table
GRANT SELECT ON SCHEMA <Schema of Virtual Table> TO <Schema of S/4HANA>;
Create Table Function
@ClientHandling.type: #CLIENT_DEPENDENT
define table function ZICMR_TF
returns
{
RCLNT : mandt;
method_id : ica_method_id;
DOCNR : ica_docnr;
DOCLN : ica_docln;
GRREF : ica_grref;
PSTAT : ica_pstat;
CSTAT : ica_cstat;
DUE_DATE : ica_due_date;
CLEARING_STATUS : ica_clearing_status;
rbukrs : bukrs;
ref_belnr : belnr_d;
gjahr : gjahr;
ref_docln : docln6;
xopvw : xopvw;
augdt : augdt;
augbl : augbl;
auggj : augbl;
bschl : bschl;
koart : koart;
umskz : umskz;
rwcur : waers;
wsl : fins_vwcur12;
rhcur : waers;
hsl : fins_vwcur12;
zuonr : dzuonr;
sgtxt : sgtxt;
rcomp : rcomp_d;
rassc : rassc;
racct : bilkt_ska1;
lracct : hkont;
kunnr : kunnr;
lifnr : lifnr;
awtyp : awtyp;
awkey : awkey;
awsys : awsys;
budat : budat;
bldat : bldat;
blart : blart;
xblnr : xblnr1;
bktxt : bktxt;
xref1_hd : xref1_hd;
xref2_hd : xref2_hd;
usnam : usnam;
cpudt : cpudt;
cputm : cputm;
aedat : aedat_bkpf;
bvorg : bvorg;
xreversing : co_stflg;
xreversed : co_stokz;
}
implemented by method
zicmr_remote_sources=>CALL_01;
class zicmr_remote_sources definition
public
final
create public .
public section.
interfaces if_amdp_marker_hdb .
class-methods call_01
for table function zicmr_tf.
protected section.
private section.
endclass.
class zicmr_remote_sources implementation.
method call_01
by database function for hdb language sqlscript
options read-only.
return
select
SESSION_CONTEXT('CDS_CLIENT') as RCLNT,
'' as method_id,
'0000000000' as DOCNR,
0 as DOCLN,
'000000000000' as GRREF,
'00' as PSTAT,
'' as CSTAT,
'00000000' as DUE_DATE,
case when xopvw = 'X'
then ( case when augbl <> '' then '3'
else '1'
end )
else '0'
end as CLEARING_STATUS,
bseg.bukrs as rbukrs,
bseg.belnr as ref_belnr,
bseg.gjahr as gjahr,
concat('000', bseg.buzei) as ref_docln,
bseg.xopvw,
bseg.augdt,
bseg.augbl,
bseg.auggj,
bseg.bschl,
bseg.koart,
bseg.umskz,
bkpf.waers as rwcur,
case when bseg.shkzg = 'H' then 0 - wrbtr
else wrbtr end as wsl,
t001.waers as rhcur,
case when bseg.shkzg = 'H' then 0 - dmbtr
else dmbtr end as hsl,
bseg.zuonr,
bseg.sgtxt,
t001.rcomp,
bseg.vbund as rassc,
bseg.altkt as racct,
bseg.hkont as lracct,
bseg.kunnr,
bseg.lifnr,
bseg.awtyp,
bseg.awkey,
bseg.awsys,
bseg.h_budat as budat,
bseg.h_bldat as bldat,
bseg.h_blart as blart,
bkpf.xblnr,
bkpf.bktxt,
bkpf.xref1_hd,
bkpf.xref2_hd,
bkpf.usnam,
bkpf.cpudt,
bkpf.cputm,
bkpf.aedat,
bkpf.bvorg,
bkpf.xreversing,
bkpf.xreversed
from "/1BCAMDP/REMOTE_BSEG" as bseg /* or use "ZHANGVIN"."REMOTE_BSEG" */
inner join "/1BCAMDP/REMOTE_BKPF" as bkpf /* or use "ZHANGVIN"."REMOTE_BKPF" */
on bseg.mandt = bkpf.mandt
and bseg.bukrs = bkpf.bukrs
and bseg.belnr = bkpf.belnr
and bseg.gjahr = bkpf.gjahr
inner join "/1BCAMDP/REMOTE_T001" as t001 /* or use "ZHANGVIN"."REMOTE_T001" */
on bseg.mandt = t001.mandt
and bseg.bukrs = t001.bukrs
where bseg.mandt = '910'
and bseg.h_monat > '00'
;
endmethod.
endclass.
@AbapCatalog.sqlViewName: 'ZICMRBSEGEV'
@EndUserText.label: 'ICMR Entry View Based on remote BSEG'
@ClientHandling.type: #CLIENT_DEPENDENT
@ClientHandling.algorithm: #SESSION_VARIABLE
@ObjectModel.usageType.serviceQuality: #X
@ObjectModel.usageType.dataClass: #MIXED
@ObjectModel.usageType.sizeCategory: #XL
@AbapCatalog.compiler.compareFilter:true
define view ZICMR_BSEG_ENTRY_VIEW
as select from ZICMR_TF as A
inner join finsc_fisc_date as B
on A.budat = B.calendar_date
{
A.rclnt,
A.method_id,
A.DOCNR,
A.DOCLN,
A.GRREF,
A.PSTAT,
A.CSTAT,
A.DUE_DATE,
A.CLEARING_STATUS,
A.rbukrs,
A.ref_belnr,
A.gjahr,
A.ref_docln,
B.fiscal_year as ryear,
B.fiscal_period as poper,
cast (B.fiscal_year_period as fis_jahrper_conv preserving type) as fiscyearper,
B.fiscal_year_variant as periv,
A.xopvw,
A.augdt,
A.augbl,
A.auggj,
A.bschl,
A.koart,
A.umskz,
@Semantics.currencyCode
A.rwcur,
@Semantics.amount.currencyCode: 'RWCUR'
A.wsl,
@Semantics.currencyCode
A.rhcur,
@Semantics.amount.currencyCode: 'RHCUR'
A.hsl,
A.zuonr,
A.sgtxt,
A.rcomp,
A.rassc,
A.racct,
A.lracct,
A.kunnr,
A.lifnr,
A.awtyp,
A.awkey,
A.awsys,
A.budat,
A.bldat,
A.blart,
A.xblnr,
A.bktxt,
A.xref1_hd,
A.xref2_hd,
A.usnam,
dats_tims_to_tstmp( A.cpudt,
A.cputm,
abap_system_timezone( $session.client,'NULL' ),
$session.client,
'NULL' ) as timestamp,
A.aedat,
A.bvorg,
A.xreversing,
A.xreversed
}
define view ZICMR_BSEG_ENTRY_VIEW
as select from ZICMR_TF as A
inner join finsc_fisc_date as B
on A.budat = B.calendar_date
{
<field list>
}
union all
select from BSEG as A
inner join finsc_fisc_date as B
on A.budat = B.calendar_date
{
<field list>
}
Create ICMR Data Source
Define Matching Method
Check in Manage Assignment
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 |