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

object

Former Member
0 Likes
620

hello friends,

i am not getting how to write the oops objects........can u pls give me a sample..b'coz max we will write with oops alv objects...how can we write .

thanks,

regards.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
504

Check BCALV* for demo programs on alv oops.

Check this PDF document..

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d97...

Use following link for oops alv material.

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf

Regards,

Maha

2 REPLIES 2
Read only

Former Member
0 Likes
504

Hi,

Process to create ALV with OOPs:

Step 1:

Create a container. There are 2 type of containers: docking and custom.

Go to SE38.Create a program. Use Pattern button to create object for docking container. Click ABAP Object Pattern radio button. Click Create object radio button. Give Instance as o_docking and class as cl_gui_docking_contianer.

Step 2:

Create a grid inside the container.

Use Pattern button to create the same. Make the parent of grid as container.

Click ABAP Object Pattern radio button. Click Create object radio button. Give Instance as o_grid and class as cl_gui_alv_grid. Create object o_grid.

Step 3:

Call the function lvc_fieldcatalog_merge to get the field catalog.

Pass the structure name.

Step 4:

Call the method of grid set_table_for_first_display to display the output.

Click ABAP Object Pattern radio button. Click Call Method radio button. Give Instance as o_grid and Class/Interface as cl_gui_alv_grid and Method as set_table_for_first_display.

w_variant-report = sy-repid.

Call method o_grid->set_table_for_first_display

Step 5:

Fill the internal table itab with values by using logic.

select * from mara into table itab up to 100 rows.

call screen 9000.

Create a screen by double clicking 9000 in the above line. Fill the description for the screen. In the flow logic, uncomment the PBO and PAI module and create those in main program (for simplicity).

Step 6:

Create GUI status. Create GUI Title if required. That can be done by using display object List (CtrlShiftF5).Then in left side, right click the program and create GUI Status and Title.

Step 7:

Free the memory occupied once the BACK, EXIT or CANCEL button is clicked. Use Pattern button to call the method FREE of cl_gui_alv_grid and cl_gui_docking_container.

Click ABAP Object Pattern radio button. Click Call Method radio button. Give Instance as o_grid and Class/Interface as cl_gui_alv_grid and Method as Free.

Similarly Click Call Method radio button. Give Instance as o_docking and Class/Interface as cl_gui_docking_container and Method as Free.

SAMPLE PROGRAM:

This example is implemented using local classes, since selection screens belong to an ABAP program, and cannot be defined or called in global classes. Below are the definitions of the two selection screens and three classes:

*******************************************************************

  • Global Selection Screens

*******************************************************************

SELECTION-SCREEN BEGIN OF: SCREEN 100 TITLE TIT1, LINE.

PARAMETERS MEMBERS TYPE I DEFAULT 10.

SELECTION-SCREEN END OF: LINE, SCREEN 100.

*----


SELECTION-SCREEN BEGIN OF SCREEN 200 TITLE TIT2.

PARAMETERS: DRIVE RADIOBUTTON GROUP ACTN,

STOP RADIOBUTTON GROUP ACTN,

GEARUP RADIOBUTTON GROUP ACTN,

GEARDOWN RADIOBUTTON GROUP ACTN.

SELECTION-SCREEN END OF SCREEN 200.

*******************************************************************

  • Class Definitions

*******************************************************************

CLASS: C_BIKER DEFINITION DEFERRED,

C_BICYCLE DEFINITION DEFERRED.

*----


CLASS C_TEAM DEFINITION.

PUBLIC SECTION.

TYPES: BIKER_REF TYPE REF TO C_BIKER,

BIKER_REF_TAB TYPE STANDARD TABLE OF BIKER_REF

WITH DEFAULT KEY,

BEGIN OF STATUS_LINE_TYPE,

FLAG(1) TYPE C,

TEXT1(5) TYPE C,

ID TYPE I,

TEXT2(7) TYPE C,

TEXT3(6) TYPE C,

GEAR TYPE I,

TEXT4(7) TYPE C,

SPEED TYPE I,

END OF STATUS_LINE_TYPE.

CLASS-METHODS: CLASS_CONSTRUCTOR.

METHODS: CONSTRUCTOR,

CREATE_TEAM,

SELECTION,

EXECUTION.

PRIVATE SECTION.

CLASS-DATA: TEAM_MEMBERS TYPE I,

COUNTER TYPE I.

DATA: ID TYPE I,

STATUS_LINE TYPE STATUS_LINE_TYPE,

STATUS_LIST TYPE SORTED TABLE OF STATUS_LINE_TYPE

WITH UNIQUE KEY ID,

BIKER_TAB TYPE BIKER_REF_TAB,

BIKER_SELECTION LIKE BIKER_TAB,

BIKER LIKE LINE OF BIKER_TAB.

METHODS: WRITE_LIST.

ENDCLASS.

*----


CLASS C_BIKER DEFINITION.

PUBLIC SECTION.

METHODS: CONSTRUCTOR IMPORTING TEAM_ID TYPE I MEMBERS TYPE I,

SELECT_ACTION,

STATUS_LINE EXPORTING LINE

TYPE C_TEAM=>STATUS_LINE_TYPE.

PRIVATE SECTION.

CLASS-DATA COUNTER TYPE I.

DATA: ID TYPE I,

BIKE TYPE REF TO C_BICYCLE,

GEAR_STATUS TYPE I VALUE 1,

SPEED_STATUS TYPE I VALUE 0.

METHODS BIKER_ACTION IMPORTING ACTION TYPE I.

ENDCLASS.

*----


CLASS C_BICYCLE DEFINITION.

PUBLIC SECTION.

METHODS: DRIVE EXPORTING VELOCITY TYPE I,

STOP EXPORTING VELOCITY TYPE I,

CHANGE_GEAR IMPORTING CHANGE TYPE I

RETURNING VALUE(GEAR) TYPE I

EXCEPTIONS GEAR_MIN GEAR_MAX.

PRIVATE SECTION.

DATA: SPEED TYPE I,

GEAR TYPE I VALUE 1.

CONSTANTS: MAX_GEAR TYPE I VALUE 18,

MIN_GEAR TYPE I VALUE 1.

ENDCLASS.

*******************************************************************

If u want to know more about OOPs concept look at the below link:

http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm

reward if useful

thanks and regards

suma sailaja pvn

Read only

Former Member
0 Likes
505

Check BCALV* for demo programs on alv oops.

Check this PDF document..

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d97...

Use following link for oops alv material.

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf

Regards,

Maha