Sales Order Detail AMDP Class
Sales Order Detail AMDP Class
AMDP is Different From CDS View in the CDS view we can receive data but ADMP also possibility we can modify the data as per the requirement
CLASS ztest_001 DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
*Marker interface for Database Procedures
INTERFACES: if_amdp_marker_hdb.
*Structure
TYPES:
BEGIN OF ty_order,
vbeln TYPE vbeln, "Sales Order Number
posnr TYPE posnr_va, "Item Number
vkorg TYPE vkorg, "Sales Organization
item_price TYPE netwr_ap, "Item Price
status TYPE char30, "Delivery Status
END OF ty_order.
* Table type
TYPES:
tt_order TYPE STANDARD TABLE OF ty_order WITH EMPTY KEY.
* Method Definition
CLASS-METHODS get_salesorder_details
IMPORTING
VALUE(iv_vbeln) TYPE vbeln
EXPORTING
VALUE(et_order) TYPE tt_order.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS ztest_001 IMPLEMENTATION.
METHOD get_salesorder_details BY DATABASE PROCEDURE
FOR HDB
LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING vbak vbap vbup.
*To get Sales Order details
et_order = SELECT vbak.vbeln,
vbap.posnr,
vbak.vkorg,
vbap.netwr as item_price,
CASE vbap.LFSTA
WHEN '' then 'Not Relevant'
WHEN 'A' then 'Not yet processed'
WHEN 'B' then 'Partially processed'
WHEN 'C' then 'Completely processed'
END AS status
FROM vbak AS vbak INNER JOIN vbap AS vbap
ON vbak.vbeln = vbap.vbeln
INNER JOIN vbup AS vbup
ON vbup.vbeln = vbap.vbeln AND vbup.posnr = vbap.posnr
WHERE vbak.vbeln = iv_vbeln;
ENDMETHOD.
ENDCLASS.
Please support my work : sap.rohini988@gmail.com
Comments
Post a Comment