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

Getting error while giving inline declaration.

atslokesh
Explorer
0 Likes
3,604

While giving Inline declaration, There was an syntax error.

7 REPLIES 7
Read only

jens_michaelsen
Participant
3,299

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.

Read only

Sandra_Rossi
Active Contributor
0 Likes
3,299

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

Read only

atslokesh
Explorer
0 Likes
3,299

So we need to declare gv fiscal post not initial.

Read only

jens_michaelsen
Participant
3,299

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.

Read only

matt
Active Contributor
3,299

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

Read only

AmanSaxena
Participant
3,299

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
Read only

Sumit_Holey
Participant
0 Likes
3,299

To resolve this issue,

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