Application Development 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: 

Cannot access object inside include.

Former Member
0 Kudos

"Here is my code...

*&---------------------------------------------------------------------*
*& Report ZMS_TEST14
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

INCLUDE ZMS_TEST14_TOP . " global Data

* INCLUDE ZMS_TEST14_F01 . " FORM-Routines

INITIALIZATION.

AT SELECTION-SCREEN.


INCLUDE ZMS_TEST14_CI01. " Definition and implementation of lcl_po class..

START-OF-SELECTION.
data: po type ref to lcl_po.
create object po.

CALL METHOD po->get_sflight.


INCLUDE ZMS_TEST14_O01 . " PBO-Modules
INCLUDE ZMS_TEST14_I01 . " PAI-Modules

-----------------------------------------------------------------------------------------------------

"My problem is I cannot access object po in my PBO-Modules..

"Here is my PBO-Module code..

*&---------------------------------------------------------------------*
*& Include ZMS_TEST14_O01
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_9003 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*

MODULE STATUS_9003 OUTPUT.
SET PF-STATUS 'SELECT PO'.
SET TITLEBAR 'SELECT PO'.

CREATE OBJECT OB_CONT
EXPORTING
* PARENT =
CONTAINER_NAME = 'CONTAINER'.


CREATE OBJECT OB_GRID
EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
I_PARENT = ob_cont.


set HANDLER po->add_toolbar_but for ob_grid.

set HANDLER po->add_double_click for ob_grid.
set HANDLER po->add_menu_but for ob_grid.
set HANDLER po->add_user_command_insert for ob_grid.

CALL METHOD OB_GRID->SET_TABLE_FOR_FIRST_DISPLAY
CHANGING
IT_OUTTAB = it_sflight
IT_FIELDCATALOG = it_fld.

ENDMODULE. " STATUS_9003 OUTPUT

"_________________________________________________________

And I keep getting error Field PO is unknown ....

1 ACCEPTED SOLUTION

bertrand_delvallee
Active Participant

Hello,

Your mistake is to consider screen 9003, container ob_cont and grid OB_GRID as one "big display object".

Screen 9003 only have to deal with status GUI, title GUI and GUI exit functions.

MODULE status_9003 OUTPUT.
 SET PF-STATUS 'SELECT PO'.
 SET TITLEBAR 'SELECT PO'.
ENDMODULE.    

MODULE user_command_0100 INPUT.
CASE sy-ucomm.
      WHEN 'BACK'.
        SET SCREEN 0.
        LEAVE SCREEN.
      WHEN 'EXIT'.
        SET SCREEN 0.
        LEAVE SCREEN.
      WHEN 'CANCEL'.
        SET SCREEN 0.
        LEAVE SCREEN.
    ENDCASE.
ENDMODULE.

And, in upper level (in your main program as you posted it) :

CREATE OBJECT OB_CONT
EXPORTING
* PARENT =
CONTAINER_NAME = 'CONTAINER'.

CREATE OBJECT OB_GRID
EXPORTING
I_PARENT = ob_cont.

set HANDLER po->add_toolbar_but for ob_grid.
set HANDLER po->add_double_click for ob_grid.
set HANDLER po->add_menu_but for ob_grid.
set HANDLER po->add_user_command_insert for ob_grid.

CALL METHOD OB_GRID->SET_TABLE_FOR_FIRST_DISPLAY
CHANGING
IT_OUTTAB = it_sflight
IT_FIELDCATALOG = it_fld.

CALL SCREEN 9003.

Best regards

Bertrand

6 REPLIES 6

Sandra_Rossi
Active Contributor
0 Kudos

Make sure "INCLUDE ZMS_TEST14_O01" is not entered in the ZMS_TEST14_TOP include too.

0 Kudos

I have called screen in my INCLUDE ZMS_TEST14_CI01. " Definition and implementation of lcl_po class..

Is that making it not reachable??

what should i do? its working fine if i use whole code in the same program. I mean if i use whole code inside my PBO module outside in the same report at the same place it will work fine.please help..

pokrakam
Active Contributor
0 Kudos

Please post code using code formatting

horst_keller
Product and Topic Expert
Product and Topic Expert

Activate it all despite the errors and check then if the error is still there.

If that doesn't help, show it to an experienced colleague of yours. It is difficult to solve such include problems without looking directly at them - although they are mostly trivial.

Sandra_Rossi
Active Contributor
0 Kudos

Is it a syntax error?

Or is it a short dump?

Please post the exact message, and indicate at which line of the source code and include it corresponds.

bertrand_delvallee
Active Participant

Hello,

Your mistake is to consider screen 9003, container ob_cont and grid OB_GRID as one "big display object".

Screen 9003 only have to deal with status GUI, title GUI and GUI exit functions.

MODULE status_9003 OUTPUT.
 SET PF-STATUS 'SELECT PO'.
 SET TITLEBAR 'SELECT PO'.
ENDMODULE.    

MODULE user_command_0100 INPUT.
CASE sy-ucomm.
      WHEN 'BACK'.
        SET SCREEN 0.
        LEAVE SCREEN.
      WHEN 'EXIT'.
        SET SCREEN 0.
        LEAVE SCREEN.
      WHEN 'CANCEL'.
        SET SCREEN 0.
        LEAVE SCREEN.
    ENDCASE.
ENDMODULE.

And, in upper level (in your main program as you posted it) :

CREATE OBJECT OB_CONT
EXPORTING
* PARENT =
CONTAINER_NAME = 'CONTAINER'.

CREATE OBJECT OB_GRID
EXPORTING
I_PARENT = ob_cont.

set HANDLER po->add_toolbar_but for ob_grid.
set HANDLER po->add_double_click for ob_grid.
set HANDLER po->add_menu_but for ob_grid.
set HANDLER po->add_user_command_insert for ob_grid.

CALL METHOD OB_GRID->SET_TABLE_FOR_FIRST_DISPLAY
CHANGING
IT_OUTTAB = it_sflight
IT_FIELDCATALOG = it_fld.

CALL SCREEN 9003.

Best regards

Bertrand