SAPSAP 实用篇SAP 修行

How to create table function usi

2019-12-16  本文已影响0人  _扫地僧_

Issue

As described in this SCN thread.

For detail about AMDP, please read this post.

Solution

Create a table function with following source code

@ClientDependent: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
define table function ztf_crmd_partner_but000
with parameters @Environment.systemField: #CLIENT
clnt:abap.clnt, bp_guidset: crmt_partner_no, bp_no: crmt_partner_no
returns { client:s_mandt;
bp_guid: BU_PARTNER_GUID;
title:AD_TITLE;
name: BU_NAME1TX;
}

implemented by method
zcl_amdp_bp_impl=>crmd_partner_but000;

Implement ABAP class zcl_amdp_bp_impl

CLASS zcl_amdp_bp_impl DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_amdp_marker_hdb.
TYPES:
BEGIN OF bp_detail,
bp_guid TYPE BU_PARTNER_GUID,
title TYPE BU_PARTNER_GUID,
name TYPE BU_NAME1TX,
END OF bp_detail,
bp_detail_tab TYPE STANDARD TABLE OF bp_detail WITH KEY bp_guid.
CLASS-METHODS crmd_partner_but000
FOR TABLE FUNCTION ztf_crmd_partner_but000.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_amdp_bp_impl IMPLEMENTATION.
METHOD crmd_partner_but000
BY DATABASE FUNCTION FOR HDB
LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING crmd_partner but000.
RETURN SELECT sc.client as client,
sp.partner_guid as bp_guid,
sp.title as title,
sp.name1_text as name
FROM crmd_partner AS sc
INNER JOIN but000 AS sp ON sc.client = sp.client AND
sc.PARTNER_NO = sp.partner_guid
WHERE sc.client = :clnt AND
sc.guid = :bp_guidset AND
sc.partner_no = :bp_no AND
sc.partner_fct = '00000001'
ORDER BY sc.client;
ENDMETHOD.
ENDCLASS.

Perform testing

It works as defined.

要获取更多Jerry的原创文章,请关注公众号"汪子熙":


上一篇下一篇

猜你喜欢

热点阅读