Call AMDP inside another AMDP Part 4
Code Info:-
CLASS zcl_amdp_select_option DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_amdp_marker_hdb.
TYPES:BEGIN OF ty_out,
mandt TYPE mandt,
vbeln TYPE vbeln,
posnr TYPE posnr,
matnr TYPE matnr,
* maktx TYPE maktx,
kunnr TYPE kunnr,
name1 TYPE name1,
END OF ty_out,
tt_out TYPE TABLE OF ty_out.
CLASS-METHODS handle_select_option
IMPORTING
VALUE(iv_mandt) TYPE sy-mandt
VALUE(iv_where) TYPE string
EXPORTING
VALUE(et_out) TYPE tt_out.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_amdp_select_option IMPLEMENTATION.
METHOD handle_select_option BY DATABASE PROCEDURE FOR HDB
LANGUAGE SQLSCRIPT
USING vbak vbap kna1 .
et_out = select so.mandt,
so.vbeln,
item.posnr,
item.matnr,
so.kunnr,
kna1.name1
from vbak as so
INNER JOIN vbap as item
on so.mandt = item.mandt
and so.vbeln = item.vbeln
LEFT OUTER JOIN kna1
on so.mandt = kna1.mandt
and so.kunnr = kna1.kunnr
WHERE so.mandt = :iv_mandt ;
et_out = apply_filter( :et_out, :iv_where );
ENDMETHOD.
ENDCLASS.
******************************************************************
REPORT z_amdp_cunsumtion.
DATA: lv_vbaln TYPE vbak-vbeln,
lv_posnr TYPE vbap-posnr,
lv_kunnr TYPE vbak-kunnr,
lv_matnr TYPE vbap-matnr.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: s_vbeln FOR lv_vbaln,
s_posnr FOR lv_posnr,
s_kunnr FOR lv_kunnr,
s_matnr FOR lv_matnr.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
cl_shdb_seltab=>combine_seltabs(
EXPORTING
it_named_seltabs = VALUE #(
( name = 'VBELN' dref = REF #( s_vbeln[] ) )
( name = 'POSNR' dref = REF #( s_posnr[] ) )
( name = 'KUNNR' dref = REF #( s_kunnr[] ) )
( name = 'MATNR' dref = REF #( s_matnr[] ) )
)
iv_client_field = 'MANDT'
RECEIVING
rv_where = DATA(lv_where)
).
* CATCH cx_shdb_exception.
zcl_amdp_select_option=>handle_select_option(
EXPORTING
iv_mandt = sy-mandt
iv_where = lv_where
IMPORTING
et_out = DATA(it_out)
).
cl_demo_output=>display( it_out ).
Comments
Post a Comment