ABAP BADI SCREEN ENHANCEMENTS DEFINATION

This topic is in continuation with ABAP BADI SCREEN ENHANCEMENTS PART .It will be more convenient to if you go through that first if you are new to this blog.

Here is the step by step procedure for screen enhancement definitions using BADI .

1. Create the following methods.

The methods PUT_DATA_TO_SCREEN and GET_DATA_FROM_SCREEN are required for data transport. These methods are called from within the program of the application at PBO or PAI .

Here is the screen shot for defining the methods mentioned above and you can click it for enlarging.


2. Create an instance attribute in the interface. This attribute is used for passing data.


3. Write the code for the call of the screen enhancement in the program of the application:

Top Include:

DATA: program Type program,
dynpro Type dynnr.
exit type ref to if_ex_badi_screen
The variable for the object reference is created using data and typed to the interface.

PBO:

MODULE initialize OUTPUT.
CLEAR: sflight, ok_code.
IF exit IS INITIAL.
CALL METHOD cl_exithandler=>get_instance
CHANGING
instance = exit.
ENDIF.
CALL METHOD cl_exithandler=>set_instance_for_subscreen
EXPORTING
instance = exit.
ENDMODULE.

The factory method is used to create an instance of the adapter class. You then declare the instance using the public static method SET_INSTANCE_FOR_SUBSCREEN to allow the data for display on the screen to be used in the function group of the user or in the module pool.

MODULE data_for_subscreen OUTPUT.

program = sy-repid.
dynpro = sy-dynnr.
CALL METHOD cl_exithandler=>get_prog_and_dynp_for_subscr
EXPORTING
exit_name = 'BADI_SCREEN'
calling_program = program
calling_dynpro = dynpro
subscreen_area = 'SUB'
IMPORTING
called_program = program
called_dynpro = dynpro.
CALL METHOD exit->put_data_to_screen
EXPORTING
flight = sflight
EXCEPTIONS
reserved = 01.
ENDMODULE.

PAI:

MODULE user_command_0200 INPUT.
CASE save_ok.
WHEN 'BACK'.
SET SCREEN 100.
WHEN 'SAVE'.
PERFORM save_flights.
WHEN '+EXT'.
CALL METHOD exit->get_data_from_screen
IMPORTING
flight = sflight
EXCEPTIONS
reserved = 01.
ENDCASE.
ENDMODULE.

The method GET_PROG_AND_DYNP_FOR_SUBSCR and the input/output parameters specified above are used to determine the name of the customer program and the name of the subscreen. The method PUT_DATA_TO_SCREEN which is called at PBO as well as the method GET_DATA_FROM_SCREEN which is called at PAI are used to transport the data to be displayed.

These methods are implemented by the user:

When you define a screen enhancement, you are strongly recommended to provide sample code for the methods PUT_DATA_TO_SCREEN and GET_DATA_FROM_SCREEN. This code is automatically copied when you create an implementation and can be added to if required. The user of the BAdI definition should not be responsible for the data transport.

Y

Billing and payment process in erp sap abap

No comments :

Post a Comment