ERPClimb logoERPClimb
ALV Reports
ABAP Developmentintermediate 10 min read

ALV Reports Part 3: OO ALV with CL_GUI_ALV_GRID and a Custom Container

Preview · a free account unlocks the full lesson

Key takeaway

Build the classic OO ALV used in most custom transactions: screen 100 with a custom control, CL GUI CUSTOM CONTAINER, CL GUI ALV GRID, LVC field catalog and layout, set table for first display, PBO/PAI modules and refresh table display.

In this lessonShow sections

Visual overview

ALV Reports Part 3: OO ALV with CL_GUI_ALV_GRID and a Custom Container — learning sheetFlow: Create report ZALV_GRID_OO with screen 100 (custom control CC_ALV) and status STATUS_100 (BACK, EXIT, CANCEL) → Paste the code example and activate everything → Add a REFRESH function in the status: re-select data and call refresh_table_display. Key ideas: BUILDING BLOCKS; FIELD CATALOG AND LAYOUT (LVC); FIRST DISPLAY AND REFRESH; SCREEN FLOW. Watch out: Create container and grid only once (IF go_grid IS INITIAL); later use refresh_table_display.ERPClimb.com / ABAP / LESSON 3/10 / LEARNING SHEETALV Reports Part 3: OO ALV with CL_GUI_ALV_GRID and aCustom Container1 · HOW IT FLOWS1Create reportZALV_GRID_OO with screen100 (custom control…2Paste the code exampleand activate everything3Add a REFRESH function inthe status: re-selectdata and call…2 · KEY IDEAS EXPLAINEDBuilding BlocksScreen 100 (SE51 or from SE80) with a CustomControl element named e.g. CC_ALV.GUI status (SE41) with BACK/EXIT/CANCEL functions,set in PBO.Field Catalog And Layout (Lvc)LVC_FIELDCATALOG_MERGE with i_structure_namebuilds lvc_t_fcat from DDIC; then adjust coltext,outputlen, do_sum.lvc_s_layo: zebra, cwidth_opt, sel_mode ('A' formulti-row selection), grid_title.First Display And RefreshCalled once. After changing gt_out, callgo_grid->refresh_table_display( ) — optionallywith is_stable to keep scroll position.Screen FlowPBO: SET PF-STATUS, SET TITLEBAR, create ALV ifinitial.3 · REMEMBER · WATCH OUTRememberCL_GUI_ALV_GRID is a GUI control placed in a container on your owndynpro screen.Flow: CALL SCREEN 100 → PBO creates container + grid once →set_table_for_first_display → PAI handles OK codes.It uses LVC types (lvc_t_fcat, lvc_s_layo) — not the SLIS types ofREUSE_ALV.!Watch outCreate container and grid only once(IF go_grid IS INITIAL); later userefresh_table_display.4 · IN A REAL PROJECTA support ticket reported that a custom goods receipt transaction became slower each time the user pressedRefresh, and eventually the GUI froze. The PBO module created a new container and grid on every screen roundtrip, stacking dozens of controls. The fix was the standard pattern: create container and grid only IF go_grid…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Parts 1 and 2 covered full-screen ALVs that needed no screen of their own. CL_GUI_ALV_GRID is different: it is a GUI control placed in a container on your own dynpro screen, which gives you full control — events (covered in Parts 6 and 8), editing (Part 9), and even several grids on a single screen.

Building it requires a few pieces to come together. First, a screen — screen 100, created in SE51 or from SE80 — needs a Custom Control element on it, named something like CC_ALV. A GUI status, created in SE41, defines the BACK, EXIT and CANCEL functions, and gets set during PBO. The container itself is created with CL_GUI_CUSTOM_CONTAINER EXPORTING container_name = 'CC_ALV'. — or, as an alternative that needs no screen element at all, CL_GUI_DOCKING_CONTAINER. The grid itself is then created with CL_GUI_ALV_GRID EXPORTING i_parent = go_container.

The field catalog and layout here use LVC types rather than the SLIS types from REUSE_ALV: it uses LVC types (lvc_t_fcat, lvc_s_layo) — not the SLIS types of REUSE_ALV. LVC_FIELDCATALOG_MERGE, given i_structure_name, builds an lvc_t_fcat from the DDIC, after which individual entries can be adjusted for coltext, outputlen or do_sum. The layout structure lvc_s_layo covers things like zebra striping, cwidth_opt for automatic column widths, sel_mode set to 'A' for multi-row selection, and grid_title.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Referenced SAP objects

Reviewed reference pages for the objects this page mentions.

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.