Create AMDP class and fetch data based on student branch
Refer - Introduction to AMDP
Step 1: Right click on ABAP project -- New -- ABAP class.
Step 2: Select package, Give class name and description.
Step 3: Click and next and click on finish.
Step 4: Write Code.
CLASS ycl_ab_amdp_stu DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES: if_amdp_marker_hdb.
TYPES: begin of ls_stu,
stu_id TYPE ystu_id,
stu_name TYPE ystu_name,
stu_branch TYPE ystu_branch,
stu_marks TYPE ystu_marks,
END OF ls_stu.
TYPES: lt_stu TYPE TABLE of ls_stu.
METHODS: fetch_data IMPORTING VALUE(stu_bra) TYPE ystu_branch
EXPORTING VALUE(lt_data) TYPE lt_stu.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS ycl_ab_amdp_stu IMPLEMENTATION.
METHOD fetch_data BY DATABASE PROCEDURE FOR HDB
LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING YTL_AB_STU_DET.
lt_data = select stu_id,
stu_name,
stu_branch,
stu_marks
from YTL_AB_STU_DET
where stu_branch =:stu_bra;
ENDMETHOD.
ENDCLASS.
Step 5: Calling AMDP class in report.
REPORT YR_CALL_AMDP_STU.
PARAMETERS: p_branch TYPE ystu_branch.
START-OF-SELECTION.
data: lf_obj TYPE
ref to ycl_ab_amdp_stu.
create OBJECT lf_obj.
CALL METHOD ycl_ab_amdp_stu=>fetch_data
EXPORTING
stu_bra = p_branch
IMPORTING
lt_data = data(lt_stu).
cl_demo_output=>display_data( name = 'Student
Details' value = lt_stu ).
Table data.
Input.
Output.
********************************Thank You*****************************
Comments
Post a Comment