Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

OOPS Program for rectification.

Hi Experts!!

This program is syntatically correct. But output not Coming.

Prerequisite : Screen no 100

Container Name: Container.

&----


*& Report ZSAP_OBJECT *

*& *

&----


*& *

*& *

&----


REPORT zsap_object .

----


  • CLASS select_display_sflight DEFINITION

----


*

----


CLASS select_display_sflight DEFINITION.

PUBLIC SECTION.

TYPES: BEGIN OF s_sflight_tab,

connid TYPE sflight-connid,

carrid TYPE sflight-carrid,

END OF s_sflight_tab.

CLASS-METHODS class_constructor.

METHODS: constructor IMPORTING i_carrid TYPE sflight-carrid

i_connid TYPE sflight-connid

EXCEPTIONS nothing_found,

display_flights.

PRIVATE SECTION.

CLASS-DATA list TYPE REF TO cl_gui_alv_grid.

DATA: sflight_tab1 TYPE standard TABLE OF s_sflight_tab,

  • with unique key carrid,

  • sflight_Tab type sflight_tab1,

wa_tab TYPE s_sflight_tab.

ENDCLASS. "select_display_sflight DEFINITION

----


  • CLASS select_display_sflight IMPLEMENTATION

----


*

----


CLASS select_display_sflight IMPLEMENTATION.

METHOD: class_constructor.

CREATE OBJECT list

EXPORTING i_parent = cl_gui_container=>screen0.

ENDMETHOD. "class_constructor

METHOD constructor.

*select carrid connid into corresponding fields of table sflight_tab1

*from sflight

  • where carrid = i_carrid and

  • connid = i_connid.

*

SELECT carrid connid FROM sflight

INTO CORRESPONDING FIELDS OF wa_tab WHERE carrid = i_carrid AND

connid = i_connid.

    • comments<b>

<u>I want to move data from wa_tab to sflight_tab1**</b></u>

*move-corresponding wa_tab to sflight_Tab1.

ENDSELECT.

if sy-subrc = 0.

*sflight_tab = wa_tab.

*sflight_tab-connid = wa_tab-connid.

else.

RAISE nothing_found.

ENDIF.

ENDMETHOD. "constructor

"constructor

METHOD display_flights.

CALL METHOD list->set_table_for_first_display

EXPORTING

i_structure_name = 'SFLIGHT'

CHANGING

it_outtab = sflight_tab1.

  • it_outtab = wa_tab.

CALL SCREEN 100.

ENDMETHOD. "display_flights

ENDCLASS. "select_display_sflight IMPLEMENTATION

SELECTION-SCREEN BEGIN OF SCREEN 500.

PARAMETERS: p_carrid TYPE sflight-carrid,

p_connid TYPE sflight-connid.

SELECTION-SCREEN END OF SCREEN 500.

DATA: BEGIN OF ref_tab_line,

carrid TYPE sflight-carrid,

connid TYPE sflight-connid,

oref TYPE REF TO select_display_sflight,

END OF ref_tab_line,

ref_tab LIKE SORTED TABLE OF ref_tab_line WITH UNIQUE KEY carrid connid.

START-OF-SELECTION.

DO.

CALL SELECTION-SCREEN 500 STARTING AT 10 10.

IF sy-subrc <> 0.

LEAVE PROGRAM.

ENDIF.

ref_tab_line-carrid = p_carrid.

ref_tab_line-connid = p_connid.

READ TABLE ref_tab INTO ref_tab_line FROM ref_tab_line.

IF sy-subrc <> 0.

CREATE OBJECT ref_tab_line-oref

EXPORTING i_carrid = p_carrid

i_connid = p_connid

EXCEPTIONS nothing_found = 4.

IF sy-subrc = 4.

MESSAGE i888(sabapdocu) WITH 'no data'.

ENDIF.

ENDIF.

CALL METHOD ref_tab_line-oref->display_flights.

ENDDO.<u></u>

Thanks in Advance.

Former Member
Former Member replied

Hello Anil

The error is located in the CLASS_CONSTRUCTOR method.

CLASS select_display_sflight IMPLEMENTATION.

METHOD: class_constructor.
  CREATE OBJECT list    " TYPE REF TO cl_gui_alv_grid
    EXPORTING i_parent = cl_gui_container=>screen0.
ENDMETHOD. "class_constructor

The parent of an grid instance always must be a container (e.g. docking container). Thus, simply change your method as following:

METHOD class_constructor.

  CREATE go_docking
    EXPORTING
     parent = cl_gui_container=>screen0
     ratio    = 90.

  CREATE go_grid
     EXPORTING
       parent = go_docking.

" Link the docking container to the screen -> NOTE: In this case no
" custom container is required as screen element.
  CALL METHOD go_docking->link
    EXPORTING
      repid = syst-repid
      dynnr = '0100'
"      container = ' '     " optional
           .

ENDMETHOD.

For a sample report (<b>ZUS_SDN_TWO_ALV_GRIDS</b>) have a look at thread

sample alv program using classes & methods ..but not using container

Regards

Uwe

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question