Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

class

Former Member
0 Likes
354

how to create a screen in a class (for example BADI)

1 REPLY 1
Read only

Former Member
0 Likes
292

The user then views the data required. Compare your existing program to SAP standard program.

At the specific request of the customer, you are to enhance this function to allow the user

Follow the steps to accomplish that:-

Create a subscreen area in your main program(calling program). Let, the name is ‘SUB’.

Then, create a BADI definition for a single-use BADI( single implementation) from SE18.

After that, create two methods as shown below with the parameters mentioned:-

The specifications for the method are as follows:-

Method:

PUT_DATA_IN_SCREEN

GET_DATA_FROM_SCREEN

Parameter: Type: Reference type:

MATERIALS IMPORTING MARA

MATERIALS EXPORTING MARA

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

Then, in the tab for subscreens, enter the name of the calling program,screen number, subscreen area.

The code of the calling program should be changed as follows:-

Top Include:-

DATA : w_prog type program ,

w_dynnr type dynnr.

data : l_badi type ref to YIF_EX_SUBMATQRY.

PBO events:-

MODULE STATUS_1001 OUTPUT.

IF l_badi IS INITIAL.

CALL METHOD cl_exithandler=>get_instance

CHANGING

instance = l_badi.

ENDIF.

CALL METHOD cl_exithandler=>set_instance_for_subscreens

EXPORTING

instance = l_badi.

w_prog = sy-repid.

w_dynnr = sy-dynnr.

CALL METHOD cl_exithandler=>get_prog_and_dynp_for_subscr

EXPORTING

exit_name = 'YSUBMATQRY'

calling_program = w_prog

calling_dynpro = w_dynnr

subscreen_area = 'SUB'

IMPORTING

called_program = w_prog

called_dynpro = w_dynnr.

CALL METHOD l_badi->put_data_in_screen

EXPORTING

materials = mara.

ENDMODULE. " STATUS_1001 OUTPUT

You 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.

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_IN_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.

The screen flow logic of the calling program should call the subscreen:-

PROCESS BEFORE OUTPUT.

MODULE STATUS_1001.

call subscreen SUB including w_prog w_dynnr.

1.1.1.1 Develop the program to be called

Then, create a module pool program with a subscreen and put the elements in the subscreen. This program will be the called program. Let, the program be YSUBMATCALLED with subscreen 1002.

The program will be as follows:-

PROGRAM YSUBMATCALLED .

tables : mara.

DATA: l_badi TYPE REF TO YIF_EX_SUBMATQRY,

w_mara TYPE mara.

&----


*& Module STATUS_1002 OUTPUT

&----


  • text

----


MODULE STATUS_1002 OUTPUT.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

IF l_badi IS INITIAL.

CALL METHOD cl_exithandler=>get_instance_for_subscreens

CHANGING

instance = l_badi

EXCEPTIONS

OTHERS = 6.

ENDIF.

CALL METHOD l_badi->get_data_from_screen

IMPORTING

materials = mara.

SELECT SINGLE mtart

meins

FROM mara

into (mara-mtart,mara-meins)

WHERE matnr = mara-matnr .

ENDMODULE. " STATUS_1002 OUTPUT

&----


*& Module USER_COMMAND_1002 INPUT

&----


  • text

----


MODULE USER_COMMAND_1002 INPUT.

CALL METHOD l_badi->put_data_in_screen

EXPORTING

materials = mara.

ENDMODULE. " USER_COMMAND_1002 INPUT

1.1.1.2 Create a BADI Instance

Finally, create an instance of the BADI. Mention the following lines of code for the methods:-

method YIF_EX_SUBMATQRY~PUT_DATA_IN_SCREEN .

me->YIF_EX_SUBMATQRY~materials = materials.

endmethod.

method YIF_EX_SUBMATQRY~GET_DATA_FROM_SCREEN .

materials = me->YIF_EX_SUBMATQRY~materials.

endmethod.

In the subscreens tab page of SE19, mention clearly the calling and called program information as shown below:-