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

Doubts in oops concept

Former Member
0 Likes
837

hi all,

in OOPs we have to create our own screens in a report. is it mandatory?I saw some sample programs where Screens r created.

how will we get this method in SE38 [ABAP editor]

1) call method o_grid->set_table_for_first_display

exporting

is_variant = w_variant

i_save = 'A'

changing

it_outtab = itab

it_fieldcatalog = i_fieldcat

exceptions

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

others = 4.

if sy-subrc 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

2) create object g_custom_container

exporting container_name = g_container.

.3) do u guys have sample programs on OOPS?

Naming conventions of used in OOPS and some material on OOPS .

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
811

Hi,

1) and 2) questions

In oops reports we need to create screen . On that we need to place

Custom control: For example custom control name: g_container.

First we need to get a custom container object, for that thing

DATA: O_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

O_GRID TYPE REF TO CL_GUI_ALV_GRID,

“ get the custom container object

Create object o_cont

Exporting

Container_name = g_container (custom control name in screen)

If sy-subrc = 0.

“ to make use of custom container object get the alv grid object

Create object o_grid

Exporting

I_parent = o_cont (Custom container object)

“ To make use of alv grid object to display the data using the method set_table_for_first_display.

Simple oops alv program:

REPORT ZCL_SALES_GRID .

TABLES: VBAK.

data: O_sALES_GRID type ref to ZCL_SALES_GRID.

constants: c_contrainer type char32 value 'SALES_CONTAINER'.

SET SCREEN 100.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'ZCL_SALES_GRID'.

  • SET TITLEBAR 'xxx'.

IF O_SALES_GRID IS INITIAL.

CREATE OBJECT O_SALES_GRID

EXPORTING

IM_CONT = c_contrainer.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

CASE SY-UCOMM.

WHEN 'DISP'.

CALL METHOD O_SALES_GRID->POPULATE_DATA

EXPORTING

P_VBELN = VBAK-VBELN.

CALL METHOD O_SALES_GRID->SHOW_DATA.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Module GET_DATA INPUT

&----


  • text

----


MODULE GET_DATA INPUT.

CALL METHOD O_SALES_GRID->POPULATE_DATA

EXPORTING

P_VBELN = VBAK-VBELN.

CALL METHOD O_SALES_GRID->SHOW_DATA.

ENDMODULE. " GET_DATA INPUT

For oops programs give u r mail id.

If it is helpful rewards points

Regards

Pratap.M

hi all,

in OOPs we have to create our own screens in a report. is it mandatory?I saw some sample programs where Screens r created.

how will we get this method in SE38 [ABAP editor]

1) call method o_grid->set_table_for_first_display

exporting

is_variant = w_variant

i_save = 'A'

changing

it_outtab = itab

it_fieldcatalog = i_fieldcat

exceptions

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

others = 4.

if sy-subrc 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

2) create object g_custom_container

exporting container_name = g_container.

.3) do u guys have sample programs on OOPS?

Naming conventions of used in OOPS and some material on OOPS .

6 REPLIES 6
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
811

Basically, yes if you are using the class CL_GUI_ALV_GRID, it is the best approach to create the screen and embed the container, but you don't absolutly have to. You can embed it into a docking container attached to the selection screen, like this.




report zrich_0001 .

tables: mara.

data: begin of i_alv occurs 0,
      matnr type mara-matnr,
      mtart type mara-mtart,
      MATKL type mara-matkl,
      groes type mara-groes,
      maktx type makt-maktx,
      end of i_alv.

data: alv_container  type ref to cl_gui_docking_container.
data: alv_grid       type ref to cl_gui_alv_grid.
data: layout    type lvc_s_layo.
data: fieldcat  type lvc_t_fcat.

parameters: p_check.

initialization.

  perform get_data.

at selection-screen output.

  data: variant type  disvariant.
  data: repid type sy-repid.

  repid = sy-repid.

  variant-report = sy-repid.
  variant-username = sy-uname.

  layout-zebra = 'X'.
  layout-edit_mode = 'X'.

  check alv_container is initial.

  create object alv_container
              exporting repid     = repid
                        dynnr     = sy-dynnr
                        side      = alv_container->dock_at_left
                        extension = 1500.

  create object alv_grid
         exporting
               i_parent          =  alv_container.

*  ALV Specific. Data selection.
*  Populate Field Catalog
  perform get_fieldcatalog.

  call method alv_grid->set_table_for_first_display
      exporting
           is_layout              = layout
           is_variant             = variant
           i_save                 = 'U'
           i_structure_name       = 'I_ALV'
      changing
           it_outtab       = i_alv[]
           it_fieldcatalog = fieldcat[].


start-of-selection.


************************************************************************
* FORM GET_DATA
************************************************************************
form get_data.

  select * into corresponding fields of table i_alv
        from mara
          inner join makt
            on mara~matnr = makt~matnr
                   up to 100 rows
               where makt~spras = sy-langu.

  sort i_alv ascending by matnr.

endform.

************************************************************************
*      Form  Get_Fieldcatalog - Set Up Columns/Headers
************************************************************************
form get_fieldcatalog.

  data: ls_fcat type lvc_s_fcat.
  refresh: fieldcat.

  clear: ls_fcat.
  ls_fcat-reptext    = 'Material Number'.
  ls_fcat-fieldname  = 'MATNR'.
  ls_fcat-ref_table  = 'I_ALV'.
  ls_fcat-outputlen  = '18'.
  ls_fcat-fix_column = 'X'.
  ls_fcat-key        = 'X'.
  ls_fcat-col_pos    = '1'.
  append ls_fcat to fieldcat.

  clear: ls_fcat.
  ls_fcat-reptext    = 'Material Type'.
  ls_fcat-fieldname  = 'MTART'.
  ls_fcat-ref_table  = 'I_ALV'.
  ls_fcat-outputlen  = '10'.
  ls_fcat-fix_column = 'X'.
  ls_fcat-key        = 'X'.
  ls_fcat-col_pos    = '2'.
  append ls_fcat to fieldcat.

  clear: ls_fcat.
  ls_fcat-reptext    = 'Material Group'.
  ls_fcat-fieldname  = 'MATKL'.
  ls_fcat-ref_table  = 'I_ALV'.
  ls_fcat-outputlen  = '12'.
  ls_fcat-col_pos    = '3'.
  append ls_fcat to fieldcat.

  clear: ls_fcat.
  ls_fcat-reptext    = 'Size'.
  ls_fcat-fieldname  = 'GROES'.
  ls_fcat-ref_table  = 'I_ALV'.
  ls_fcat-outputlen  = '30'.

  ls_fcat-col_pos    = '4'.
  append ls_fcat to fieldcat.

  clear: ls_fcat.
  ls_fcat-reptext    = 'Material Description'.
  ls_fcat-fieldname  = 'MAKTX'.
  ls_fcat-ref_table  = 'I_ALV'.
  ls_fcat-outputlen  = '40'.

  ls_fcat-col_pos    = '5'.
  append ls_fcat to fieldcat.

endform.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
812

Hi,

1) and 2) questions

In oops reports we need to create screen . On that we need to place

Custom control: For example custom control name: g_container.

First we need to get a custom container object, for that thing

DATA: O_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

O_GRID TYPE REF TO CL_GUI_ALV_GRID,

“ get the custom container object

Create object o_cont

Exporting

Container_name = g_container (custom control name in screen)

If sy-subrc = 0.

“ to make use of custom container object get the alv grid object

Create object o_grid

Exporting

I_parent = o_cont (Custom container object)

“ To make use of alv grid object to display the data using the method set_table_for_first_display.

Simple oops alv program:

REPORT ZCL_SALES_GRID .

TABLES: VBAK.

data: O_sALES_GRID type ref to ZCL_SALES_GRID.

constants: c_contrainer type char32 value 'SALES_CONTAINER'.

SET SCREEN 100.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'ZCL_SALES_GRID'.

  • SET TITLEBAR 'xxx'.

IF O_SALES_GRID IS INITIAL.

CREATE OBJECT O_SALES_GRID

EXPORTING

IM_CONT = c_contrainer.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

CASE SY-UCOMM.

WHEN 'DISP'.

CALL METHOD O_SALES_GRID->POPULATE_DATA

EXPORTING

P_VBELN = VBAK-VBELN.

CALL METHOD O_SALES_GRID->SHOW_DATA.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Module GET_DATA INPUT

&----


  • text

----


MODULE GET_DATA INPUT.

CALL METHOD O_SALES_GRID->POPULATE_DATA

EXPORTING

P_VBELN = VBAK-VBELN.

CALL METHOD O_SALES_GRID->SHOW_DATA.

ENDMODULE. " GET_DATA INPUT

For oops programs give u r mail id.

If it is helpful rewards points

Regards

Pratap.M

Read only

0 Likes
811

Thanks alot.

one more doubt , below call method we have to wirte exporting ,changing exceptions directly or some other method is retreive o_grid->set_table_for_first_display directly. KI means to say,we will call function module we use PATTERN to retrieve whole struture of it...how we can do with call method.

call method o_grid->set_table_for_first_display

exporting

is_variant = w_variant

i_save = 'A'

changing

it_outtab = itab

it_fieldcatalog = i_fieldcat

exceptions

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

others = 4.

if sy-subrc 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

This is my Mail Id : [email protected]

Once again thanks for ur answers..

Read only

0 Likes
811

hai Pratap ,

I'm sending my Mail id to u :[email protected]

Read only

0 Likes
811

Hi,

Click on Pattern,

Selct the radio button

ABAP Object Patterns

Click on enter key

Slect the radio button

Call method

We need to pass the

Instance : o_grid

class : cl_gui_alv_grid

method: set_table_for_first_display

Like above u can call any method using patterns in report program.

I sent the example programs

If it is helpful rewards points

Regards

Pratap.M

Read only

0 Likes
811

Thanks Pratap,

I reward points for u..

Thanks once again..