Hi ABAP guru's how to call a subroutine which i have written in my layout set into se38. You may find it more useful if the ABAP program reads the table without using the.ABAP - Classic Functions Subroutines. This section we will take a look at subroutines and functions. Subroutines allow a programmer to break the program into self- contained blocks of code, this allows for easy debugging, changes in one subroutine wont affect other subroutines (unless used by another subroutine), and the complexity of the program is broken down into small manage parts. Function modules are a separate piece of code that can be called from your ABAP program they can even be written by another company, SAP provides a vast library of function modules that can be used to deal with specific tasks, for example file uploading and downloading. Subroutines. Lets start with subroutines, SAP call a subroutine a form, they can be declared within the program itself or used by using a include statement, they are invoked by using the perform command.
You can pass data to and from a form with parameters, variables or constants, which can then be used inside the form. The scope of variable determines if it can be used within a form for example global or local. The perform command allows you to execute a form which has been defined, perform does not need to occur prior to the physical location of the form. The syntax of perform is PERFORM syntax PERFORM < form> . The below information display how the code is laid out, you can see the forms being called and where the form code goes, the layout is easy to understand, however you can make it more complex than it need to be by calling forms within forms, try not go to deep otherwise it makes it hard for someone else to read Subroutine layout PERFORM REPORT. You should group all the forms at the end of a program this makes it easy for other developers to read your code, the only statement after a formend block is another form statement. PERFORM (ABAP Keyword) PERFORM is a keyword used in SAP ABAP programming.This tutorial covers its introduction & syntax details. If you call a subroutine of a program prog, the system loads the program prog Note Runtime. ABAP - Calling suroutine of other program. Create another program with name ZTEST. Let's see an example. FORM example PERFORM PAGE. When passing values to a form you can pass them via reference or by value. Passing Variables ## Pass the variables by reference, which if you change the variable it will be reflect when passing it ##. FORM PAGE. Global variables can be accessed anywhere in the program local variables can only be access inside the specific form (subroutine). GLOBAL and LOCAL VARIABLE example DATA: GLOBAL. When you call a form the program has to create the local variables, then when you call the form again those variables have to be re- created, this can be slow, to persist the variable between calling forms you can use the statics option, this means the local variable is only created once, the same rules apply it still a local variable and cannot be used outside is own form (subroutine). To note a statics variable will maintain its value between form calls. STATICS example FORM TEST1. DATA: STATICS LOCAL. You obtain the function module and then you can call it from your program, SAP comes with many function modules that you can use and thus saves you time having to rewrite the code. Function modules are run by using the call command, some function modules require you to pass arguments others might not, you will generally have to read up on the function to see how it works. I will cover the following. Using the function module screen. Creating a custom function module. Using function modules in your ABAP code. Some useful function modules that come with SAPFirst lets look at the function module screen using transaction code SE3. The right- hand screenshot display some of the existing modules (there are thousands of them), they are grouped in functionality to make it easy to find a specific module. When you do find a module that you want you can display it and have a look at the source code, import and export parameters, etc. This helps you understand what is needed to run the module inside your program, some may even come with documentation. Only experience and the web will help you find modules that may help you, plus you can ask other ABAP developers, try not to revent the wheel, there no need to spend days on writing something when there is a function module that already does what you require. You can also test function modules to see if the desired outcome is what you want, plus you can test your own, simple select the function you want to test and select the the test button (left- hand screenshot), then enter the import parameters (middle screenshot) and you will get the results (right- hand screenshot). To create your own function module you need to give it a name, it must start with a Z which means its a user defined module, you will be asked to enter a function group the module belongs to and a short text describing the module, once completed you will be taken to the function builder screen which will be blank. I have covered how to use the builder screen in the practical introduction section, read this screen to get an idea on how to build a small application. Once you have created you. R function module how do you use it in your programs, by using the call function command, I will use the G.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2016
Categories |