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: 

Getting error while giving inline declaration.

atslokesh
Explorer
0 Kudos
1,234

While giving Inline declaration, There was an syntax error.

7 REPLIES 7

jens_michaelsen
Participant
929

The topinclude of a function group is used for data declarations. The statement is not a declaration but an assignment of value. In topinclude the statement is not accessible.

N.B. The statement makes no sense, because gv_fiscal_year is initial.

Sandra_Rossi
Active Contributor
0 Kudos
929

Eagle eyes to see L...TOP inside the screenshot 😄

atslokesh
Explorer
0 Kudos
929

So we need to declare gv fiscal post not initial.

jens_michaelsen
Participant
929

No Sir, this statement is not possible in a topinclude of a function group. You can use your statement in a function module of this function group, but not in the data declaration of the topinclude.

matt
Active Contributor
929

I love that in the same place you have defined gv_ variables, you've also defined lv_ variables! Which are they? Global or local?

AmanSaxena
Participant
929

The error "Statement not accessible" typically occurs when a statement is not allowed in the current context or scope.

In your case, it seems that you are trying to perform a computation and assignment operation (`gv_previous_fyear = gv_fiscal_year - 1`) directly in the top include section.

To resolve this issue, you need to move the computation and assignment statement into a proper executable section, such as a subroutine, function module, or within an executable block of code.

For example, you can place the computation and assignment statement inside a subroutine or a method:

METHODS calculate_previous_fyear.

START-OF-SELECTION.
PERFORM calculate_previous_fyear.

FORM calculate_previous_fyear.
DATA: gv_fiscal_year TYPE numc4.
DATA(gv_previous_fyear) = gv_fiscal_year - 1.
...
ENDFORM.

Alternatively, you can place it within an executable block like this:

DATA: gv_fiscal_year TYPE numc4.
DATA(gv_previous_fyear) TYPE numc4.


START-OF-SELECTION.
gv_previous_fyear = gv_fiscal_year - 1.
...


Remember to ensure that the executable code is placed within a valid context such as a subroutine, function module, or an executable block.

ABAP Developer

Sumit_Holey
Participant
0 Kudos
929

To resolve this issue,

you need to write this statment in execution area i.e after star of selection.