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

include problem

Former Member
0 Likes
1,562

Hi,

i build program in se80 and i want to include another program ,

i try e.g.

report ztest_1

include ztest_2

i have error :

Each ABAP program can contain only one "REPORT", "PROGRAM", or "FUNCTION-POOL". statement.

how i avoid that?

Regards

1 ACCEPTED SOLUTION
Read only

bpawanchand
Active Contributor
0 Likes
1,449

Hi

May be you ahve written any REPORT statement in INclude Ztest2 remove it and check it out or else post the INCLUDE code so that I can help you

Regards

Pavan

12 REPLIES 12
Read only

bpawanchand
Active Contributor
0 Likes
1,450

Hi

May be you ahve written any REPORT statement in INclude Ztest2 remove it and check it out or else post the INCLUDE code so that I can help you

Regards

Pavan

Read only

0 Likes
1,449

hi,

REPORT  ztest_1.

*------------------------------------------------------------------*
* CLASS lcl_airplane DEFINITION *
*------------------------------------------------------------------*
CLASS lcl_airplane DEFINITION.
* Public section
  PUBLIC SECTION.
    TYPES: name_type(25) TYPE c.
    CONSTANTS: pos_1 TYPE i VALUE 30.
    METHODS: set_attributes IMPORTING
    im_name TYPE name_type
    im_planetype TYPE saplane-planetype,
    display_attributes.
    CLASS-METHODS: display_n_o_airplanes.
* Private section
  PRIVATE SECTION.
    DATA: name TYPE name_type,
    planetype TYPE saplane-planetype.
    CLASS-DATA: n_o_airplanes TYPE i.
ENDCLASS.                    "lcl_airplane DEFINITION


*------------------------------------------------------------------*
* CLASS lcl_airplane IMPLEMENTATION *
*------------------------------------------------------------------*
CLASS lcl_airplane IMPLEMENTATION.
* Method set_attributes
  METHOD set_attributes.
    name = im_name.
    planetype = im_planetype.
    n_o_airplanes = n_o_airplanes + 1.
  ENDMETHOD.                    "set_attributes
* Method display_attributes
  METHOD display_attributes.
    WRITE: / 'Name of the airplane: '(001), AT pos_1 name,
    / 'Plane type: '(002), AT pos_1 planetype.
  ENDMETHOD.                    "display_attributes
* Method display_n_o_airplanes
  METHOD display_n_o_airplanes.
    WRITE: /, / 'Total number of airplanes: '(ca1),
    AT pos_1 n_o_airplanes LEFT-JUSTIFIED, /.
  ENDMETHOD.                    "display_n_o_airplanes
ENDCLASS.                    "lcl_airplane IMPLEMENTATION

progarm Ztest2:

REPORT  ztest_2.

INCLUDE ztest_1.

Regards

Read only

0 Likes
1,449

Include program ztest_1

now try this code..


*------------------------------------------------------------------*
* CLASS lcl_airplane DEFINITION *
*------------------------------------------------------------------*
CLASS lcl_airplane DEFINITION.
* Public section
  PUBLIC SECTION.
    TYPES: name_type(25) TYPE c.
    CONSTANTS: pos_1 TYPE i VALUE 30.
    METHODS: set_attributes IMPORTING
    im_name TYPE name_type
    im_planetype TYPE saplane-planetype,
    display_attributes.
    CLASS-METHODS: display_n_o_airplanes.
* Private section
  PRIVATE SECTION.
    DATA: name TYPE name_type,
    planetype TYPE saplane-planetype.
    CLASS-DATA: n_o_airplanes TYPE i.
ENDCLASS.                    "lcl_airplane DEFINITION
 
 
*------------------------------------------------------------------*
* CLASS lcl_airplane IMPLEMENTATION *
*------------------------------------------------------------------*
CLASS lcl_airplane IMPLEMENTATION.
* Method set_attributes
  METHOD set_attributes.
    name = im_name.
    planetype = im_planetype.
    n_o_airplanes = n_o_airplanes + 1.
  ENDMETHOD.                    "set_attributes
* Method display_attributes
  METHOD display_attributes.
    WRITE: / 'Name of the airplane: '(001), AT pos_1 name,
    / 'Plane type: '(002), AT pos_1 planetype.
  ENDMETHOD.                    "display_attributes
* Method display_n_o_airplanes
  METHOD display_n_o_airplanes.
    WRITE: /, / 'Total number of airplanes: '(ca1),
    AT pos_1 n_o_airplanes LEFT-JUSTIFIED, /.
  ENDMETHOD.                    "display_n_o_airplanes
ENDCLASS.                    "lcl_airplane IMPLEMENTATION

progarm Ztest2:

REPORT  ztest_2.
 
INCLUDE ztest_1.

Read only

0 Likes
1,449

ztest_1 program

should be of type Include program. you change the type of the program also. May be it is Executable now, Change it to Include program in the attributes screen.

Read only

0 Likes
1,449

ztest_1 should be of type include program so it should not contain any report statement.


* Include  ztest_1
 
*------------------------------------------------------------------*
* CLASS lcl_airplane DEFINITION *
*------------------------------------------------------------------*
CLASS lcl_airplane DEFINITION.
* Public section
  PUBLIC SECTION.
    TYPES: name_type(25) TYPE c.
    CONSTANTS: pos_1 TYPE i VALUE 30.
    METHODS: set_attributes IMPORTING
    im_name TYPE name_type
    im_planetype TYPE saplane-planetype,
    display_attributes.
    CLASS-METHODS: display_n_o_airplanes.
* Private section
  PRIVATE SECTION.
    DATA: name TYPE name_type,
    planetype TYPE saplane-planetype.
    CLASS-DATA: n_o_airplanes TYPE i.
ENDCLASS.                    "lcl_airplane DEFINITION
 
 
*------------------------------------------------------------------*
* CLASS lcl_airplane IMPLEMENTATION *
*------------------------------------------------------------------*
CLASS lcl_airplane IMPLEMENTATION.
* Method set_attributes
  METHOD set_attributes.
    name = im_name.
    planetype = im_planetype.
    n_o_airplanes = n_o_airplanes + 1.
  ENDMETHOD.                    "set_attributes
* Method display_attributes
  METHOD display_attributes.
    WRITE: / 'Name of the airplane: '(001), AT pos_1 name,
    / 'Plane type: '(002), AT pos_1 planetype.
  ENDMETHOD.                    "display_attributes
* Method display_n_o_airplanes
  METHOD display_n_o_airplanes.
    WRITE: /, / 'Total number of airplanes: '(ca1),
    AT pos_1 n_o_airplanes LEFT-JUSTIFIED, /.
  ENDMETHOD.                    "display_n_o_airplanes
ENDCLASS.                    "lcl

Now include it in ur program



REPORT  ztest_2.
 
INCLUDE ztest_1.

Read only

0 Likes
1,449

Hi Joyjit Ghosh ,

Thanks i try it ( to put include in Ztest_1 instead report) but i have Error:

Recursive INCLUDE nesting in program "Ztest_1". It contains an

INCLUDE statement which calls itself or a previously read program

("Ztest_1").

Regards

Read only

0 Likes
1,449

No need to put the include in the same include. Follow the same that I mentioned earlier...

ztest_1 should be of type include program so it should not contain any report statement.

    • Include ztest_1 << This is just a comment not any statement*

----


  • CLASS lcl_airplane DEFINITION *

----


CLASS lcl_airplane DEFINITION.

  • Public section

PUBLIC SECTION.

TYPES: name_type(25) TYPE c.

CONSTANTS: pos_1 TYPE i VALUE 30.

METHODS: set_attributes IMPORTING

im_name TYPE name_type

im_planetype TYPE saplane-planetype,

display_attributes.

CLASS-METHODS: display_n_o_airplanes.

  • Private section

PRIVATE SECTION.

DATA: name TYPE name_type,

planetype TYPE saplane-planetype.

CLASS-DATA: n_o_airplanes TYPE i.

ENDCLASS. "lcl_airplane DEFINITION

----


  • CLASS lcl_airplane IMPLEMENTATION *

----


CLASS lcl_airplane IMPLEMENTATION.

  • Method set_attributes

METHOD set_attributes.

name = im_name.

planetype = im_planetype.

n_o_airplanes = n_o_airplanes + 1.

ENDMETHOD. "set_attributes

  • Method display_attributes

METHOD display_attributes.

WRITE: / 'Name of the airplane: '(001), AT pos_1 name,

/ 'Plane type: '(002), AT pos_1 planetype.

ENDMETHOD. "display_attributes

  • Method display_n_o_airplanes

METHOD display_n_o_airplanes.

WRITE: /, / 'Total number of airplanes: '(ca1),

AT pos_1 n_o_airplanes LEFT-JUSTIFIED, /.

ENDMETHOD. "display_n_o_airplanes

ENDCLASS. "lcl

Now include it in ur program

REPORT ztest_2.

INCLUDE ztest_1.

Read only

0 Likes
1,449

Hi,

Thanks i try it but i have error :

REPORT/PROGRAM statement missing, or program type is INCLUDE.

Regards

Read only

0 Likes
1,449

Make the program ztest_1 type should be Include program.

From menu Go to ->Attributes then change the Program type to Include program and activate it and check now..

Read only

Former Member
0 Likes
1,449

May be in ur inlcude program ztest_2, report or program statement is present..pl. remove it....and check the syntax.Hope it will solve ur problem.

Read only

Former Member
0 Likes
1,449

> report ztest_1

> include ztest_2

if ztest_2 contains any REPORT STATEMENT then you get the same error.

Read only

Former Member
0 Likes
1,449

hi,

In your include ztest_2. go to attribute and change your program type. make it include rather than executable. than only u can able to include this into your report ztest_1 .

hope this might help u.