‎2007 Mar 27 2:34 PM
Dear all experts,
can anybody please tell in detail how to pass an internal table to function module using function builder....
I am new to abap, can you please tell procedure stepwise...
Surely, points will be assigned to all help made by you.
waiting
Regards
Vinay.
‎2007 Mar 27 3:33 PM
Hi there. I'm not sure what you mean. Function builder (transaction SE37) is used to edit, display, or test function modules. Are you trying to test a function module, or do you need to know how to pass a table to the function module when you're calling it in a program? Which function module are you using, and what table are you trying to pass?
- April King
‎2007 Mar 27 4:44 PM
Dear April King ,
I am certified in bw, but im learning abap at my own..... its just project requirement.
I am in situation, where i have to pass data to function using internal table and process data inside function, and again take it back to main program....
your help will be really helpfull.....
hope you will reply...
waiting
Regards
Vinaly
‎2007 Mar 27 5:40 PM
Hmm, it would be easier to give you specifics if you would say which function module you are using. But in general terms, here is what you need to do. First go to transaction SE37 and display the function module that you want to use. If you go to the "Import" tab and the "Tables" tab you will see the fields that you need to pass to the function module. Then in your program (the one that is going to call the function module) you need to define the fields/tables for passing data the same way that they are defined in the function module. For instance, on the "Import" tab you may see a field with the parameter name NUMBER, typing LIKE, and associated type P0001-PERNR. So in your program you would define a field like this:
DATA number LIKE P0001-PERNR.
You need to do this for each field or table that the function module requires (to determine if it is required, look on the Import tab and see if the "Optional" box is checked; if it is not checked, then the field is required). You also need to define whichever of the fields on the "Export" tab that you want to use. Once you have all of the fields defined, you can move your data to them. Then call the function module. You can insert the code for this into your program by going in to edit your program in SE38 and then clicking on the "Pattern" button. Then on the pop-up window select "Function module", type in the name of the function module, and click on the green checkmark. Then make sure that all of the fields that you need are uncommented (remove the asterisk at the beginning of the line to uncomment it). After the function module call you can process the data that is returned to you in the exported fields. I hope this helps.
- April
‎2007 Mar 28 3:47 PM
Dear April King
I am able to pass internal table to function module.
This internal table is having structure equivalent to database table.
Now i want to pick up some coloumns from database table and i have to pass that to function module. Can i use structure in that case ?
If yes , can you please give any specific example ?
Waiting for reply..
Regards
Vinay.
‎2007 Mar 28 4:04 PM
Again, it would help if I knew which particular function module you were talking about Do you mean that you are getting information from a database using one function module, and that you need to turn around and pass part of that information to another function module? It depends on which particular tables you are talking about. Here is an example where you are first getting the infotype 0002 (personal data) records for an employee and then passing the birth date to a second function module to calculate the age. You might be able to use something like this:
DATA: infty_0002 TYPE STANDARD TABLE OF p0002,
it0002_line LIKE LINE OF infty_0002.
DATA p_pernr TYPE pernr-pernr.
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
pernr = p_pernr
infty = '0002'
begda = sy-datum
endda = sy-datum
TABLES
infty_tab = infty_0002
EXCEPTIONS
infty_not_found = 1
OTHERS = 2.
LOOP AT infty_0002 INTO it0002_line.
CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'
EXPORTING
begda = it0002_line-gbdat
endda = sy-datum
IMPORTING
c_years = num_years.
ENDLOOP.
If you need something that is more specifically related to your program, then you could post some of the code.
- April
‎2007 Oct 16 12:06 PM
first go to se37-function builder;before creating the function module,you need to create function group; a function group is nothing but related function modules;how to create a function group->go to GOTO ->Function Groups ->Create Group;Then function group is created;after that comming to the creation of function module;
give the name of functionmodule in the se37;and then you will be taken to the parameters field,in which it contain import parameters,export parameters,changing parameters,table parameters ,exception paameters, source code;
import parameters for inputting;
export parameters for outputiing;
changing for input,output,structures and tables and all type of parameters can be passed there;
table for passing internal table parameters;
exceptions for error handling other than the system errors;
source code is for writing the program depending the on the given parameters;
difference b/w changing and tables is->at changing when yuo give tables,it takes as tables and structures as structures;
where s in tables it takes tables and structures as internal tables;
now going to the inserting tables
iam taking mara table;
import parameter:
parameter name TYPE associated type
P_MATNR type mara-matnr
export parameter:
parameter name type spec associated type
MARA_TABLE TYPE MARA
MESSAGE LIKE BAPIRET2-MESSAGE
then go for sorce code and write these code
SELECT SINGLE * FROM MARA INTO MARA_TABLE WHERE MATNR = P_MATNR.
IF SY-SUBRC = 0.
MESSAGE = 'record is found '.
WRITE : MESSAGE.
ELSE.
MESSAGE = 'not found, enter valid values'.
WRITE : MESSAGE.
ENDIF.
‎2013 Dec 27 9:11 AM
‎2012 Dec 24 5:58 AM
Hi ,
Their is a tables tab in function module .
U can pass the internal table using that.
Regards ,
Mangesh Sonawane