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: 

Methods to solve this syntax error

Former Member
0 Kudos

Hi friends,

I am doing a user exit. In that iam including my code in a Include say 'ZXXX' in that i have 2 includes 'ZXX1' and 'ZXX2' ( one for PBO and one for PAI )..... i ve written my codes inside and when iam activating the include it gives me the following error ???? what iam missing / what ive given extra / what should i do???

Error :

" EACH ABAP PRORAM CAN CONTAIN ONLY ONE "REPORT" OR "PROGRAM" OR "FUNCTION-POOL" STATEMENT" ..................

Expecting ur answers.....(any small idea will surely help me and others too)

Hope my question is clear .....

thanks in advance .............................

_________________

Cheers,

Kripa .,

Upcoming New Abaper......

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Kripa,

You said you are implementing a user-exit. At the same time you are saying you are using other two includes for PBO and PAI, it doesn't make sense. These includes are part of a function module and I have never seen anybody write PAI or PBO modules inside a function module.

I may be wrong, I am assuming you have PAI and PBO modules inside these includes.

Cheers,

Sanjeev

16 REPLIES 16

Former Member
0 Kudos

Your includes shall be of type include (check that you do not have 'REPORT' statement in these includes and their program type is not of 'executable'.).

cheers,

0 Kudos

Also, make sure that there is no PROGRAM statement in your includes.

Regards,

Rich Heilman

Former Member
0 Kudos

Hey,

I have a Include program say A, and in that i ve two inlcudes of program B and C ( All A,B,C are of the same Type I only ) in that B and C are the PBO and PAI inlcudes of Program A. So as per u ve said, i ve checked the types and everything is of Type I and no other Report / Program name is included in the program.

So ?????????? now what could i do ????

Thanks & regards,

Former Member
0 Kudos

If you have 3 includes then it means that you have no program or report or module pool program....

Error :

" EACH ABAP PRORAM CAN CONTAIN ONLY ONE "REPORT" OR "PROGRAM" OR "FUNCTION-POOL" STATEMENT" ..................

FYI..this error also means that you must have one of these stmts in an ABAP program.

I guess program 'A' should be a module pool program and not just simple include that you have mentioned.

And please remember that SAP's error messages means both ways.

Like in this case this error means it should not have more than 1 REPORT / PROGRAM stmt and also that it must have 1 stmt at least.

I will suggest you create the module pool program 'A' properly through transaction SE80.

Cheers,

Ram

Former Member
0 Kudos

Hi Kripa,

You said you are implementing a user-exit. At the same time you are saying you are using other two includes for PBO and PAI, it doesn't make sense. These includes are part of a function module and I have never seen anybody write PAI or PBO modules inside a function module.

I may be wrong, I am assuming you have PAI and PBO modules inside these includes.

Cheers,

Sanjeev

0 Kudos

Ok ..i didn't notice that you are using these includes in an user-exit.

you should put your includes in the top include (where you also declare global variables ) of user-exit function module and not within the function module code (not in z include called within the FM )

Cheers,

Ram

Former Member
0 Kudos

Hi,

I think its better to tell the whole process which iam doing ( i dont know whether the steps are right as this is the first time iam tryig to implement a user-exit!). So what ever could be the mistake which u encounter in my steps please let me know so that i could correct that!

My requirement is:

1. To add a field in ME51N transaction in the valuation tab, Say a field which captures the text 'AAA' which could be given by the user....

My Understanding and implementation:

1. Got the user exit name to be 'MEREQ001' ( Tcode SMOD )

2 Added a field 'ZZXXX' in the table EBAN and activated the table.

3. From SE80 --> in the function group XM02,created a screen ( of type subscreen '0111' ) and placed a table field text box of name and attributes of

'EBAN-ZZXXX' .....

4. Double clicked the screen '0111' and in that i ve writen some code for its PBO and PAI ......

5. Code in PBO .......MODULE STATUS_0111.

MODULE STATUS_0111 OUTPUT.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

TABLES : EBAN.

EBAN-ZZPAYMENT = "TEST PAYMENT".

ENDMODULE. " STATUS_0111 OUTPUT

6. Code in PAI .......... USER_COMMAND_0111 INPUT

----


***INCLUDE ZXM02I01 .

----


&----


*& Module USER_COMMAND_0111 INPUT

&----


  • text

----


MODULE USER_COMMAND_0111 INPUT.

CLASS-POOL

  • An object is created for the class IF_PURCHASE_REQUISITION_ITEM

CREATE OBJECT IF_PURCHASE_REQUISITION_ITEM.

  • As i want to import the value from the subscreen to a value thruogh

  • a function GET_DATA

  • Creating a reference variable

DATA : CREF_IF_PR_ITEM TYPE REF TO

IF_PURCHASE_REQUISITION_ITEM.

  • Local variable declaration

data : l_mereq_item type mereq_item.

  • T_NATR_PAY is the new extended field...

if not CREF_IF_PR_ITEM is initial.

l_mereq_item = CREF_IF_PR_ITEM->get_data( ).

if ( ci_ebandb-ZZPAYMENT ne l_mereq_item-ZZPAYMENT ).

move-corresponding ci_ebandb to l_mereq_item .

call method

CREF_IF_PR_ITEM->set_data( l_mereq_item ).

ex_changed = 'X'.

endif.

*endif.

ENDMODULE. " USER_COMMAND_0111 INPUT

7. Then i activated .... at that time only i got the syntax error.... hope the question is clear now !!

note :

I may be wrong in the way of implememnting the user exit also ..... please correct me if iam wrong and if anyone of u could guide me properly to implement the user exit for the transaction ME51N ... it could be of a great help !!!

Expecting ur answers !! .......

Thanks in Advance !!!!

Revert back if the question is still not clear !!!

.... kripa ( New upcoming abaper )

0 Kudos

the problem is with the class-pool statement.

read the following

The CLASS-POOL statement must be the first statement of a standalone program, after any Include programs have been called. It introduces a class pool. Class pools are maintained in the Class Builder in the ABAP Workbench. A main programfor a global class, including a CLASS-POOL statement, is generated automatically. The MESSAGE-ID addition to the CLASS-POOL statement has the same meaning as for the REPORT statement.

regards,

PJ

Former Member
0 Kudos

Hi PJ,

Its nice to c ur reply here also ! thanks !!

I now commented the statement " CLASS-POOL " , and tried to activate .... its saying some other errors too ..... " FIELD IF_PURCHASE_REQUISITION_ITEM IS UNKNOWN. It is neither in one of the specified tables nor defined by the "data" statement ....." So what could i do now .....

I have a big doubt whether my implementation steps are right ????

Thanks in advance !!

...kripa...(New Upcoming Abaper)

0 Kudos

hi,

thats because ur field has not been defined. u r using the create object statement but have u defined the object in question using a data statement.

thats y it says the field is not known...

regards,

PJ

former_member181959
Contributor
0 Kudos

I think this error is due to multiple report or program statements.

Read and modify your code in such a way that only one such statements exists.

I hope I will solve the problem.

Regards,

Prasad.

Former Member
0 Kudos

Hi PJ,

Could u please tell me how to define then ??? .. where to define ??? the IF_PURCHASE_REQUISITION_ITEM is a class .... so clear me in defining and using the methods of this class .. iam not able to get that !!

Hi Prasad,

This is a user exit ... and ive written codes in the includes which are created when i ve created the subscreen '0111' .... so is that possible for me to define the code in one include ( as how u ve said ) in this ???? if yes how should i do that !!

Thanks in advance !!

...kripa...(New Upcoming Abaper)

0 Kudos

u say IF_PURCHASE_REQUISITION_ITEM is a class...and u have done

create object IF_PURCHASE_REQUISITION_ITEM

u r using the same name for object and class....it will work but to avoid confusion ...if u can change the object name....neways...here is what u need to do...

(I have changed the object name....do it the way u want)

DATA :

IF_PURCHASE_REQUISITION_ITEM_OBJ TYPE REF to IF_PURCHASE_REQUISITION_ITEM .

CREATE OBJECT IF_PURCHASE_REQUISITION_ITEM_OBJ.

.......<ur further code> (if u change the name of object....do it at all subsequent places in the code, however u can even proceed without changing the name)

try it...

regards,

PJ

Former Member
0 Kudos

In your program the method set_data is accessed by the object CREF_IF_PR_ITEM.

Assuming that this methos is in the class IF_PURCHASE_REQUISITION_ITEM,

Your declaration should be as follows.

DATA : CREF_IF_PR_ITEM TYPE REF TO

IF_PURCHASE_REQUISITION_ITEM.

CREATE OBJECT CREF_IF_PR_ITEM.

Regards,

Usha

Former Member
0 Kudos

Hi PJ,

Thanks ....

Ive changed the code now .... But still an error exist ...

the following is my changed code !!!!

----


***INCLUDE ZXM02I01 .

----


&----


*& Module USER_COMMAND_0111 INPUT

&----


  • text

----


MODULE USER_COMMAND_0111 INPUT.

tables : eban.

  • Creating a reference variable

DATA : CREF_IF_PR_ITEM TYPE REF TO

IF_PURCHASE_REQUISITION_ITEM.

  • An object is created for the class IF_PURCHASE_REQUISITION_ITEM

CREATE OBJECT CREF_IF_PR_ITEM.

  • As i want to import the value from the subscreen to a value thruogh

  • a function GET_DATA

  • Local variable declaration

data : l_mereq_item type mereq_item.

  • T_NATR_PAY is the new extended field...

  • if not CREF_IF_PR_ITEM is initial.

l_mereq_item = CREF_IF_PR_ITEM->get_data( ).

if ( ci_ebandb-ZZPAYMENT ne l_mereq_item-ZZPAYMENT ).

move-corresponding ci_ebandb to l_mereq_item .

call method

CREF_IF_PR_ITEM->set_data( l_mereq_item ).

ex_changed = 'X'.

endif.

*endif.

ENDMODULE. " USER_COMMAND_0111 INPUT

The following error came:

1. " CREF_IF_PR_ITEM is not an object reference "

2. " Field CI_EBANDE-ZZPAYMENT is unknown .... It is neither defined in the tables or in the data statement"

So ???????????? now what could i do ???

Thanks in advance !!!

0 Kudos

Hi Usha,

I ve done the same changes as how u ve told .... but still iam missing something !!!

Thanks !!!1