SAP ABAP - Call AMDP With Select-Option

AMDP Code

CLASS zcl_amdp_acdoca DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.
  INTERFACESif_amdp_marker_hdb.
  TYPES:
        BEGIN OF ty_acdoca,
            RCLNT  type acdoca-RCLNT,
            rbukrs type acdoca-rbukrs,
            belnr type acdoca-belnr,
            gjahr type acdoca-gjahr,
            DOCLN type acdoca-DOCLN,
            racct type acdoca-racct,
            budat type acdoca-budat,
        END OF ty_acdoca.

  TYPESzz_acdoca TYPE STANDARD TABLE OF ty_acdoca.

  class-METHODS:
    get_acdoca
      IMPORTING
        VALUE(lv_whereTYPE string
      EXPORTING
        VALUE(et_acdocaTYPE zz_acdoca.
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.



CLASS ZCL_AMDP_ACDOCA IMPLEMENTATION.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_AMDP_ACDOCA=>GET_ACDOCA
* +-------------------------------------------------------------------------------------------------+
* | [--->] LV_WHERE                       TYPE        STRING
* | [<---] ET_ACDOCA                      TYPE        ZZ_ACDOCA
* +--------------------------------------------------------------------------------------</SIGNATURE>
    METHOD get_acdoca
        by DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT
        OPTIONS READ-ONLY USING ACDOCA.

        ITAB select DISTINCT RCLNTrbukrsbelnrgjahrDOCLNracctbudat FROM ACDOCA WHERE RLDNR '0L';

        et_acdoca APPLY_FILTER :ITAB:lv_where );
    endmethod.
ENDCLASS.


ABAP Code

*&---------------------------------------------------------------------*
*& Report YCALL_AMDP_WITH_SEL
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ycall_amdp_with_sel.
TABLES:
  acdoca.

TYPES:
  BEGIN OF ty_acdoca,
    RCLNT  type acdoca-RCLNT,
    rbukrs TYPE acdoca-rbukrs,
    belnr  TYPE acdoca-belnr,
    gjahr  TYPE acdoca-gjahr,
    docln  TYPE acdoca-docln,
    racct  TYPE acdoca-racct,
    budat  TYPE acdoca-budat,
  END OF ty_acdoca.

DATAlt_acdoca TYPE STANDARD TABLE OF ty_acdoca.

SELECT-OPTIONS:
  s_bukrs FOR acdoca-rbukrs,
  s_belnr FOR acdoca-belnr,
  s_gjahr FOR acdoca-gjahr.

START-OF-SELECTION.

  DATA(lv_wherecl_shdb_seltab=>combine_seltabs(
    it_named_seltabs VALUE #(
      name 'RBUKRS' dref REF #s_bukrs[] )
      name 'BELNR'  dref REF #s_belnr[] )
      name 'GJAHR'  dref REF #s_gjahr[] )
    )
    iv_client_field 'RCLNT'
  ).
  zcl_amdp_acdoca=>get_acdoca(
    EXPORTING
      lv_where lv_where
    IMPORTING
      et_acdoca lt_acdoca[]
  ).

  SORT lt_acdoca[] BY rbukrs belnr gjahr docln.

  cl_demo_output=>display_data(
    EXPORTING
      value lt_acdoca[]
  ).

Output






Comments

Popular posts from this blog

PHP MySql CRUD Dengan Konsep MVC

Laravel - Sistem Informasi Perpustakaan Sederhana Laravel

IT Asset Management Dengan PHP MySQL