Saturday, May 30, 2026

AMDP 3: Call AMDP method inside another AMDP method

  •  In this Post will Call AMDP  Method inside another AMDP method.
  • When we call AMDP method inside AMDP method then calling method should be Static AMDP method.
Step 1: Define the structure, table type and method as below

Step 2: Implement AMDP method and code 















AMDP Code:

CLASS zcl_amdp_demo_class DEFINITION

PUBLIC FINAL

CREATE PUBLIC.


PUBLIC SECTION.


"Add AMDP Class Interface

INTERFACES if_amdp_marker_hdb.


"Define Structure

TYPES: BEGIN OF lty_head,

SalesOrder TYPE vbeln_va,

OrderDate TYPE audat,

OrderType TYPE auart,

SalesOrg TYPE vkorg,

DistChannel TYPE vtweg,

Division TYPE spart,

END OF ltY_head,


BEGIN OF lty_item,

SalesOrder TYPE vbeln_va,

SalesItem TYPE posnr_va,

Material TYPE matnr,

Desc TYPE arktx,

Qty TYPE kwmeng,

Unit TYPE vrkme,

Price TYPE netwr_ap,

Currency TYPE waerk,

END OF lty_item.


"Define table type

TYPES: tt_output TYPE TABLE OF lty_head,

tt_head TYPE TABLE OF lty_head,

tt_item TYPE TABLE OF lty_item.


"Instance AMDP Method

CLASS-METHODS: get_data_select_options IMPORTING VALUE(iv_mandt) TYPE mandt

VALUE(iv_where) TYPE string

EXPORTING VALUE(et_output) TYPE tt_output,


get_salesord_amdp_to_amdp IMPORTING VALUE(iv_mandt) TYPE mandt

VALUE(iv_where) TYPE string

EXPORTING VALUE(et_head) type tt_head

VALUE(et_item) TYPE tt_item.


ENDCLASS.



CLASS zcl_amdp_demo_class IMPLEMENTATION.


METHOD get_data_select_options BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY

USING VBAK.


et_output = select vbeln as SalesOrder,

audat as OrderDate,

auart as OrderType,

vkorg as SalesOrg,

vtweg as DistChannel,

spart as Division

from vbak

where mandt = :iv_mandt;


et_output = APPLY_FILTER ( :et_output, :iv_where );


ENDMETHOD.


METHOD get_salesord_amdp_to_amdp BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY

USING ZCL_AMDP_DEMO_CLASS=>GET_DATA_SELECT_OPTIONS

vbap.


--Call AMDP Method inside AMDP Method

CALL "ZCL_AMDP_DEMO_CLASS=>GET_DATA_SELECT_OPTIONS"( iv_mandt => :iv_mandt,

iv_where => :iv_where,

et_output => :et_head );


et_item = select a.vbeln as SalesOrder,

a.posnr as SalesItem,

a.matnr as Material,

a.arktx as Desc,

a.kwmeng as Qty,

a.vrkme as Unit,

a.netwr as Price,

a.waerk as Currency

from vbap as a

inner join :et_head as b on b.salesorder = a.vbeln;


ENDMETHOD.


ENDCLASS.




















No comments:

Post a Comment

RAP8: Early numbering

In this post will show you how to use early numbering . Step 1: Add early numbering key word in interface behavior definition and activate b...