2008 Feb 18 7:00 PM
"Like any other processing block, subroutines cannot be nested. You should therefore place your subroutine definitions at the end of the program, especially for executable programs (type 1). In this way, you eliminate the risk of accidentally ending an event block in the wrong place by inserting a FORM...ENDFORM block."
I have read this in some documentation.. but i didnt get that point.? sub routines can be nested as i know.. but in this it wa mentioned as it cant be nested. what does that mean??
"Like any other processing block, subroutines cannot be nested. You should therefore place your subroutine definitions at the end of the program, especially for executable programs (type 1). In this way, you eliminate the risk of accidentally ending an event block in the wrong place by inserting a FORM...ENDFORM block."
I have read this in some documentation.. but i didnt get that point.? sub routines can be nested as i know.. but in this it wa mentioned as it cant be nested. what does that mean??
2008 Feb 18 7:06 PM
I think it means that you can't do this...
FORM TEST.
FORM TEST_ME.
ENDFORM.
ENDFORM.
Greetings,
Blag.
2008 Feb 18 8:00 PM
Yes we can nested the sub routines.
Perform <sub_name1>
form <sub_name1>
..............
..............
Perform <sub_name2>
..............
endform.
form <sub_name2>
...................
....................
endform.
2008 Feb 18 9:14 PM
Hi Sandeep,
In addition to to what Blag said, if you write the FORM..... ENDFORM before completing the event block, that event maybe terminated and the statements after the endform will be inaccessible. This throws up an error in unicode programs.
hence they should always be written at the end of the code.
Cheers
~goldie.
2008 Feb 18 10:55 PM
Hi goldie I didnt get your point.. can you explain it more clear !
2008 Feb 19 3:00 PM
I will give you an example
START-OF-SELECTION.
perform func1.
perform func2.
FORM func1.
.
ENDFORM.
perform func3.
FORM func2.
.
.
write:/ 'something'.
ENDFORM.
FORM func3.
ENDFORM.
In the above case the perform func3 is never called, because we are writing the output in func2.
As a result that statement will become inaccessible and throws up an error in unicode programs.
In older versions we would only get a warning.
Think this explains it. If not I will send you a real live example.
~goldie.
2008 Feb 19 3:18 PM
ya goldie,
I got your point to some extent but still kind of vague actually what do you mean by event block ..form.. endform is one event block right
...if i write code like this..
START-OF-SELECTION.
perform func1.
perform func2.
perform func3.
FORM func1.
write 'sandeep'.
ENDFORM.
FORM func2.
write:/ 'something'.
ENDFORM.
perform func3.
FORM func3.
write 'san'.
ENDFORM.
then also it is not calling FUN3..?? i was thinking after executing fun1 fun2 it should go for next statemnt that is perform fun3 right?
Edited by: Sandeep Manukonda on Feb 19, 2008 4:19 PM
2008 Feb 19 4:10 PM
Hi sandeep,
The first time you call func3, it will be executed.
but the second perform func3 will throw an error, because that is the statement which is not accessible.
If you remove it from the current place and write it under perform func3, you wont have any problem.
You will see 'SAN' 2 times in the output (that is what your code is suppposed to do now right??).
goldie.
2008 Feb 19 4:19 PM
no goldie its not executing the program.. it is showing an error..like statement(second perform fun3) is not accessible...
2008 Feb 19 4:23 PM
thats what I told you.
take the second perform func3, and write it under first perform func3.
perform func1.
perform func2.
perform func3.
perform func3.
FORM func1.
ENDFROM.
.......
.
..
This is how it should be.
2008 Feb 19 4:24 PM
as you said why second perform fun3 throws an error..?? why it is not accessible?
after end form of fun2 it should execute perform fun3 which calls form .. endform ..isnt it taht way?
2008 Feb 19 4:28 PM
ya its correct .. but i was wondering why it wot work in other way ...like writing perform fun3 after endform of fun2..
why it wont call perform in the sequence..
i have got confusion goldie.. from this i came to know you are the right person to solve my q..
can you please calrify me?
i didnt get taht point ?? what do you mean by statement is not accessible if it is betwwen events..
2008 Feb 19 4:40 PM
Sandeep,
You have to understand that your problem was only with the second perform func3.
The first was correct.
I guess it is like this.
After the endform, the ABAP editor looks for the next perform. there will be no problem if they are in sequence like func1, func2 and first func3.
but if it encounters a FORM, it stops looking or terminates the event (here Start-of-selection).
Thats why the second perform func3 was not even encountered and hence inaccessible.
but if you want to make it accessible, you have to write in a sequence in the same event block or make it accessible using another event like END-OF-SELECTION.
I havent tried the other option, so if you try it out and find my hypothesis true... let me know
This is the only explanation I can come up with. I am new to SAP, its been only 3 months now.
So sorry if I cant explain better.
Cheers,
~goldie.
2008 Feb 19 5:32 PM
Thats awesome... im almost clarified ...ya i too know that probrlem is only with the second func3..
so if it encounters first form it wont look for anter perform..right?
before you said you can give me one real time example what abt that?
2008 Feb 19 6:00 PM
perform func1.
perform func2.
perform func3.
FORM func1.
write 'sandeep'.
ENDFORM.
FORM func2.
write:/ 'something'.
ENDFORM.
FORM func3.
write 'san'.
ENDFORM.
Then it works fine, because the form---endform statements should be the last statements.
So after the form statement we can't use the perform statement.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |