Skip to main content

Belajar ABAP Part 7: ALV Report (ABAP List Viewer)

Belajar ABAP Part 7: ALV Report (ABAP List Viewer)

Belajar ABAP Part 7: ALV Report (ABAP List Viewer)

Setelah mempelajari Part 6: Open SQL, sekarang kita masuk ke tahap yang lebih keren: menampilkan data dengan ALV Report. ALV (ABAP List Viewer) adalah fitur standar SAP untuk menampilkan tabel data dengan tampilan grid yang interaktif, lengkap dengan sorting, filter, dan export Excel.

Mengapa ALV?

  • Standar tampilan SAP → konsisten di semua modul.
  • Sudah built-in fitur filter, sort, dan export.
  • Menghemat waktu developer → tidak perlu coding manual untuk UI list.

Cara Membuat ALV Report

Ada 2 cara populer untuk membuat ALV:

  1. Menggunakan function module REUSE_ALV_GRID_DISPLAY (cara klasik).
  2. Menggunakan class CL_SALV_TABLE (cara modern, OOP style).

Contoh ALV dengan REUSE_ALV_GRID_DISPLAY


REPORT zalv_classic.

TABLES: mara.

DATA: lt_mara TYPE TABLE OF mara,
      ls_mara TYPE mara.

" Ambil data material
SELECT * FROM mara UP TO 20 ROWS INTO TABLE lt_mara.

" Tampilkan pakai ALV
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    i_structure_name = 'MARA'
  TABLES
    t_outtab         = lt_mara
  EXCEPTIONS
    program_error    = 1
    OTHERS           = 2.

IF sy-subrc <> 0.
  WRITE: / 'Error ALV'.
ENDIF.

Hasilnya: tabel MARA ditampilkan dalam grid interaktif ALV.

Contoh ALV dengan CL_SALV_TABLE (Modern OOP)


REPORT zalv_salv.

DATA: lt_mara TYPE TABLE OF mara.

" Ambil data material
SELECT * FROM mara UP TO 20 ROWS INTO TABLE lt_mara.

" Buat ALV pakai class SALV
DATA(lo_alv) = cl_salv_table=>factory( lt_mara ).
lo_alv->display( ).

Keunggulan CL_SALV_TABLE:

  • Lebih singkat, lebih bersih (OOP style).
  • Mudah dikembangkan (misalnya custom fungsi, filter, dll).

Fitur Tambahan ALV

  • Export ke Excel/CSV.
  • Sort dan filter otomatis.
  • Subtotals dan totals.
  • Toolbar interaktif.

Kesimpulan

ALV adalah standar SAP untuk menampilkan data tabel. Untuk kode lama biasanya dipakai REUSE_ALV_GRID_DISPLAY, tapi untuk kode baru disarankan pakai CL_SALV_TABLE yang lebih modern.

👉 Lanjut ke: Belajar ABAP Part 8: Enhancement & BADI

Comments

Popular posts from this blog

How to Create a REST API in SAP ABAP — Step-by-step Guide

How to Create a REST API in SAP ABAP — Step-by-step Guide Summary: This tutorial shows how to build a REST API in SAP ABAP by creating a handler class, configuring SICF service, registering endpoints with cl_rest_router , implementing endpoint logic (example GET method), and testing the API. Based on an internal implementation reference. Why expose REST APIs from SAP? REST APIs allow SAP systems to integrate with web, mobile, and external services using standard HTTP and JSON payloads. Implementing REST endpoints in ABAP provides secure, reusable, and maintainable integration points for modern applications. Prerequisites Access to an SAP system with authorization to create classes (SE24) and SICF services (SICF). Familiarity with ABAP object-oriented concepts and basic SAP transaction codes. ABAP classes CL_REST_RESOURCE , CL_REST_ROUTER and utilities like /UI2/CL_JSON . High-level overview (4 steps) Create an API handler class (e.g. ZCL_API_HANDLER ). R...

SAP ABAP - User Exit Set Batch Characteristic Value In MIGO Goods Receipt

Customer Exit  :  MBCFC004 ( EXIT_SAPMM07M_004) Set Up Customer Exit for Classification of User-Defined Characteristics You use SAP enhancement MBCFC004 EXIT_SAPMM07M_004, which contains function module exit EXIT_SAPMM07M_004 to classify user-defined characteristics automatically during goods movements in Inventory Management. This is only possible for characteristics which are not assigned values during quality inspection. Requirements 1. The class of the batch to be classified must be known.  This means that a class must be assigned either to the material or at least to one batch of this material. 2. The exit call must be activated for the respective movement type in activity Activate batch classification during goods movements in IM using indicator 'Extended classification' . Open tcode OMC...

IT Asset Management Dengan PHP MySQL

Pada postingan kali saya akan share sebuah aplikasi IT Asset management yang fungsinya untuk memonitoring semua Asset khusus IT, contohnya : Laptop/komputer , Printer, Router, Hardisk, dll. Dalam aplkasi ini kita bisa mengetahui Asset IT posisinya dimana dan digunakan oleh siapa. untuk data-data yang dibutuhkan antara lain : 1. data kategori asset dalam menu ini kita bisa meng-input jenis2 kategory asset : tambah kategori asset : 2. data department 3. data karyawan 4. data department per karyawan 5. data asset location  6. data satuan asset dan untuk transaksi yang ada dalam aplikasi ini adalah,  1. create asset, pada menu create asset ini kita akan mengalokasikan sebuah asset ke karyawan/personnel tampilannya seperti berikut: setelah klik tombol save akan muncul seperti dibawah : untuk melihat detail asset yang sudah dibuat tadi, kita bisa pilih...