Skip to Content
Author's profile photo Paulo Cesar de Biasi Vantini

BAdI enhancement definition and implementation

Objective

The objective of this document is to show how to crate a BAdI from its definition to its implementation and how to use it as an

enhancement through a sample program using the flight model tables.

We´ll create a BAdI definition, its implementation class and a report to be enhanced.

This BAdI enhancement allows the user in a report to double-click a row from a list of flights and access its detailed list.

BAdI Definition

Create the following interface with the method ‘lineselection’ with the corresponding parameters:

Then create the classic BAdI Definition in SE18 according to the screen below:

BAdI Implementation

In SE19 create the BAdI implementation as follows:

Assign the class name ZCL_IM_BC425_IM and the code for lineselection method:

Activate your implementation.

Report

Finally, use the code below for creating the report:

REPORT  ZSAPBC425_BADI.

DATA: wa_spfli TYPE spfli,
       it_spfli TYPE TABLE OF spfli WITH KEY carrid connid.

*reference variable for BAdI
DATA: exit_ref TYPE REF TO zif_ex_bc425.

*selection screen
SELECTION-SCREEN BEGIN OF BLOCK carrier WITH FRAME TITLE textcar.
   SELECTOPTIONS: so_carr FOR wa_spflicarrid.
SELECTION-SCREEN END OF BLOCK carrier.

STARTOFSELECTION.

CALL METHOD cl_exithandler=>get_instance
   CHANGING
     instance = exit_ref.

SELECT *
   FROM spfli
   INTO CORRESPONDING FIELDS OF TABLE it_spfli
   WHERE carrid IN so_carr.

ENDOFSELECTION.

   LOOP AT it_spfli INTO wa_spfli.

     WRITE: / wa_spflicarrid,
              wa_spfliconnid,
              wa_spflicountryfr,
              wa_spflicityfrom,
              wa_spflicountryto,
              wa_spflicityto,
              wa_spflideptime,
              wa_spfliarrtime.

     HIDE: wa_spflicarrid,
           wa_spfliconnid.

     ENDLOOP.

AT LINESELECTION.

   CHECK NOT wa_spflicarrid IS INITIAL.

   CALL METHOD exit_ref->lineselection
       EXPORTING
         i_carrid = wa_spflicarrid
         i_connid = wa_spfliconnid.

   CLEAR wa_spfli.

Results

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.