SAP ABAP Interview Questions (41 - 50)

41. What is REUSE_ALV_GRID_DISPLAY?

REUSE_ALV_GRID_DISPLAY is a standard function module used to display data in ALV Grid format. It provides built-in features like sorting, filtering, totals, column customization, and Excel download without much coding. It is part of the classic ALV (function module-based) approach and widely used in reports.

* REUSE_ALV_GRID_DISPLAY example
DATA: itab TYPE TABLE OF zemp.

SELECT * FROM zemp INTO TABLE itab.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    i_structure_name = 'ZEMP'   "DDIC structure
  TABLES
    t_outtab         = itab.

42. What is the difference between ALV Grid and ALV List?

ALV Grid(CL_GUI_ALV_GRID) is a modern, interactive control displayed inside a custom screen (container). It supports advanced features like editable cells, drag & drop, dynamic refresh, event handling, and better UI flexibility. It is mainly used in dialog programs where user interaction is high.

* ALV Grid (simplified)
CALL METHOD cl_gui_alv_grid=>set_table_for_first_display
  CHANGING
    it_outtab = itab.

ALV List (REUSE_ALV_LIST_DISPLAY) is a classical list-based output displayed using standard list processing. It supports basic features like sorting, filtering, and totals, but has limited interactivity compared to Grid. It is mostly used in simple reports where advanced UI is not required.

* ALV List
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
  TABLES
    t_outtab = itab.

43. What is the purpose of the ALV Event Handling?

ALV Event Handling is used to capture and respond to user actions in an ALV report. These actions include clicking a row, double-clicking a field, pressing buttons, or changing data in editable cells. It allows developers to make ALV reports more interactive and dynamic.

* ALV Event Handling example
FORM user_command USING r_ucomm TYPE sy-ucomm
                        rs_selfield TYPE slis_selfield.

  IF r_ucomm = '&IC1'.   "Double click
    WRITE: / 'Row clicked:', rs_selfield-value.
  ENDIF.

ENDFORM.

ALV Event Handling makes reports interactive instead of just display-only.

44. What is Field Catalog in ALV?

A field catalog tells ALV how each column should be displayed. It defines things like column heading, field name, output length, editability, and formatting. Without a proper field catalog, ALV may not show the columns exactly the way you want.

* ALV Field Catalog example
DATA: lt_fcat TYPE slis_t_fieldcat_alv,
      ls_fcat TYPE slis_fieldcat_alv.

ls_fcat-fieldname = 'EMP_ID'.
ls_fcat-seltext_m = 'Employee ID'.
APPEND ls_fcat TO lt_fcat.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    it_fieldcat = lt_fcat
  TABLES
    t_outtab    = itab.

45. What is Layout in ALV?

The layout in ALV controls the visual appearance of the report, such as zebra pattern, totals, column optimization, and selection mode. It helps improve readability and the overall user experience. Users can also save their preferred layout in many ALV reports for future use.

46. What is the difference between User Exit and BADI?

User Exit is a traditional enhancement technique provided by SAP using predefined includes or function exits. We can add custom code at specific points, but usually only one implementation is allowed.

* User Exit (example - include)
INCLUDE ZX...  "Add custom logic here

BADI (Business Add-In) is an object-oriented enhancement technique based on interfaces and classes. It allows multiple implementations and provides better flexibility and control.

* BADI implementation
METHOD if_ex_badi_name~method.
  WRITE 'Custom Logic'.
ENDMETHOD.

47. What is Enhancement Framework?

The Enhancement Framework is the SAP mechanism used to add custom logic to standard SAP code without modifying the original code directly. This is important because direct modifications can create upgrade issues later.

48. What is the difference between Implicit and Explicit Enhancement?

Implicit enhancements are predefined enhancement points automatically available in standard SAP code (like start/end of programs, forms, methods). You don’t see them explicitly, but you can still add custom logic at those locations. They are useful when no explicit enhancement option is provided.

* Implicit Enhancement (at end of program)
ENHANCEMENT 1 Z_IMPLICIT.
  WRITE 'Custom Logic'.
ENDENHANCEMENT.

Explicit enhancements are clearly defined enhancement points or sections created by SAP developers in the code. You can directly see and use them to insert your custom logic.

* Explicit Enhancement
ENHANCEMENT-POINT Z_POINT SPOTS ES_SPOT.
ENHANCEMENT 1 Z_EXPLICIT.
  WRITE 'Custom Logic'.
ENDENHANCEMENT.

49. What is Debugger in ABAP?

The ABAP Debugger is a tool used to run a program step by step and inspect what is happening internally. It helps developers check variable values, internal table contents, conditions, and control flow.

* Debugging code example
BREAK-POINT.
WRITE: / 'Debugger will stop here'.

50. What is the difference between Watchpoint and Breakpoint?

A breakpoint is used to pause program execution at a specific line of code. It helps you step through the program line by line to understand the flow and debug issues. It is triggered every time the program reaches that line.

* Breakpoint example
BREAK-POINT.
WRITE: / 'Debugger will stop here'.

A watchpoint is used to pause execution when a variable’s value changes or meets a condition. It is useful when you don’t know where the issue occurs but want to track a variable. It triggers only when the specified condition is met.

* Watchpoint example
DATA lv_count TYPE i.

lv_count = lv_count + 1.  "Watchpoint triggers when value changes