2010 Sep 27 2:27 PM
Hi Experts,
I have a requirement in user-exit where i have to use some lines of code in several times. So i want to use Perform and perform inside the exit (i.e. Include ZXXX). But it is not recognizing the form part of the ubroutime and gives error.
Please let me know how to use the Perform and form statement in the exit or is there any way to write repeated code once but used no of times in exit program.
Thanks
Ajit
Hi Experts,
I have a requirement in user-exit where i have to use some lines of code in several times. So i want to use Perform and perform inside the exit (i.e. Include ZXXX). But it is not recognizing the form part of the ubroutime and gives error.
Please let me know how to use the Perform and form statement in the exit or is there any way to write repeated code once but used no of times in exit program.
Thanks
Ajit
2010 Sep 27 2:44 PM
Yes, that's easy, but you didn't mention what the problem/syntax error is with your code, the user exit that you're using, or paste your form call in your post? Wouldn't that get you a better answer?
2010 Sep 27 2:56 PM
Hi jatin,
first write Perform <Subroutin>.
Now double click on this subroutine name, system will provide you options of areas to create form......endform (Subroutine).
You can create a sub routine over there and system will call it.
2010 Oct 04 7:55 AM
Hi,
It seems to be we can't use "perform" and "Form" statement in side the customer Exit. As customer Exit written inside some predefinded Include Program which is generally again in some function Module.
I tried to use "Perform" and "Form" in side the Include program as usual we define subroutine but it says the below error message.
Incorrecting Nesting: Before the statement " FORM" , the structure introduced by "FUNCTION" must be concluded with the "ENDFUNCTION".
And as in my 2nd observation, I tried with different way to define subroutine by double clicking on the subroutine name. Generally system gives option to define subroutine in some system suggested "Include program" or in the "same program". But i found the Same program option is not comming. It indicates that We can't use perform and form in the customer exit. i.e include oprogram
Only i can go with the include program Options.
My question was can't we use Perform and Form in the customer-exit( Include program). From the above observation it is not Posiible. If I am wrong then let me know the correct answer.
I have never used the include program for defining subroutine In the customer EXit case expecially . Is it OK to go with this, as we have to keep track this separate Include program always.
Thanks
Ajit
2010 Oct 04 8:03 AM
Of course it is possible. Did you try UMANGmehta's proposal? ( And have a think about what an INCLUDE means ).
matt
2010 Oct 04 8:06 AM
Hi,
as per my knowledge it is not possible to create subroutines in a customer exit .. You can create includes and write your code in it without using sub-routines.. One of the reason why subroutines are not allowed is the flow logic of the program might be missed, thats why we get error.
Regards,
Nagaraj
2010 Oct 04 9:43 AM
I'm sorry, but this is utter nonsense. I just went into a CMOD exit, into the include ZXRSRU01. Typed PERFORM my_form. Double clicked on my_form. Was prompted to create an include called ZXRSRF01. Created my form in that. Saved it all. Activated. No problem.
This is exactly what UMANGmehta proposed
It is possible to create a subroutine in a CMOD user-exit program. Subroutines ARE allowed, and SHOULD be used within exits. Not using subroutines in complex exits is REALLY BAD PROGRAMMING
I really do despair sometimes.
Edited by: Matt on Oct 4, 2010 11:53 AM - toned down the harshness...
2010 Oct 04 10:20 AM
Hi ,
Matt,Thanks for the information.. But then similar kind of issue faced one of my friend where he was unable to create a form ..endform..it was giving syntax error as specified. as per my friend it is not possible , Moreover i basically create include and write rather than subroutine, this is where the gap is..
Regards,
Nagaraj
2010 Oct 04 10:52 AM
I'm sorry, I was overly harsh there. Please accept my apologies. But I do despair sometime!
Consider the structure of a function group and it should be clear - you need to remember that INCLUDES are just repositories of code. If you take the contents out of the include and put them into the main program, then this is what you get:
function-pool xrsr.
* Global data definition.
function exit_saplrrs0_001.
....
* the source code within the zxrsru01 include.
...
endfunction.Now, what you're trying to do, is create a form in your include. You can't do that, because you end up with:
function-pool xrsr.
* Global data definition.
function exit_saplrrs0_001.
....
perform xyz.
...
form xyz.
endform.
endfunction.And you can't have a FORM defined inside a function module definition. The solution is to put it outside the function module. If you follow the process suggested above, you end up with
function-pool xrsr.
* Global data definition.
function exit_saplrrs0_001.
....
perform xyz.
...
endfunction.
form xyz. " This will be in LXRSRF01
endform.Do you see how it works now?
2010 Oct 04 10:52 AM
Hi,
I have also tried from my side and able to create subroutine.. in a customer exit.. I am wrong in my earlier answer, sorry for that.
This is what i have done...
I have used the inckide include zxpbeu04 which is inside the function exit (EXIT_SAPLHRBEN00FEATURE_004).
Double click on it.
Now write PERFORM sub_create2. double click on it. You will be asked to create the subroutine..Click on yes.ZXPBEF01 will be created.You will get one warning message (In program ZXPBEZZZ, an "INCLUDE ZXPBEF01"
statement will be inserted).. Press Enter. Now save it.
Now press on activate button (Choose both ZXPBEF01, ZXPBEU04 and ZXPBEZZZ). if you choose only ZXPBEU04 , YOU will get the error.
Please choose all the includes and then press on activate button..the error will disappear.
Matt.. I am sorry for my reply, i could have checked before i give the answer.. Thanks for sharing this information.
Regards,
Nagaraj
2010 Oct 04 10:56 AM
That's ok. We all learn new stuff each day. To the original poster - any credit should go to UMANGmehta, as he suggested the solution first.
matt
2010 Oct 04 10:56 AM
No issues Matt.. It was my mistake . I didn't checked it , i just replied.. . I tried from my side and it's working..I have put it in my earlier post..
Thanks again.
Regards,
Nagaraj
2010 Oct 04 12:31 PM
Hi Matt,
Thanks for the appriciation.
I think we all are learning and sharing our knowledge is really a great thing...
2013 Oct 02 7:48 PM
I had the same problem today and this answer solved it like a charm, great answer.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |