‎2005 Oct 04 12:27 PM
Hello, I'm new in this community and I also have my first question.
First of all I've got to say sorry for my bad english and I hope that everybody here can understand me.
My name is Christian and I work for an pharmaceutical company in Germany. We run SAP R/3 in Release 4.6B.
Soon the time has come to go to a new release. Probably release 6.40.
My problem is as followed:
I've got to create a dynamic call of an function module.
At the beginning I have only the name of the function module, with is give by the user as a parameter e.g..
Then I make a select on the table FUPARAREF which contains all parameters (like import and export e.g.) for every function module. Now I already have a basis for the dynamic function module call.
But there follows a big problem which is a barricade for my project.
I don't know how to call the function module with a dynamic amount of export-parameters.
For those who don't know what I mean a little example:
*Start of source code
REPORT ZTEST.
declare the input parameter 'FNAME' in the selection
screen
PARAMETER FNAME LIKE FUPARAREF-FUNCNAME DEFAULT 'CS_WHERE_USED_MAT'
OBLIGATORY.
Here I select the import parameters of the above given
function module into an internal table.
I don't list it here because everybody should now how it looks like
Here I want to call the dynamic function module using the data-element 'FNAME'.
Now there follows my barricade:
How can I dynamically use the above selected import parameters to give them to function call?
CALL FUNCTION FNAME
EXPORTING ???.
*End of source code
I hope that you can understand my problem and also that one of you knows an answer for me.
Thank you in advance for your help.
Christian
‎2005 Oct 04 12:32 PM
Hi Christian,
First of all : not that bad your English....
Here is an extract from the Help :
<b>Addition 6</b>
... PARAMETER-TABLE itab
Effect
With this addition, the interface of a function module can be dynamically supplied with parameters. The addition PARAMETER-TABLE excludes parallel use of the static additions 1 through 5.
The parameter table itab must be a sorted table of the table type ABAP_FUNC_PARMBIND_TAB or of the line type ABAP_FUNC_PARMBIND. These types are defined in the type group ABAP in the ABAP dictionary. The table has the following four columns:
NAME For the name of the formal paramter
KIND for the type of parameter passing
VALUE of the type REF TO DATA for the value of the actual parameter
TABLES_WA of the type REF TO DATA for the value of the table work area, if a TABLES parameter is passed.
The columns NAME and KIND form the unique table key. For each non-optional parameter, you must fill exactly one line of the internal table.
In NAME, you must specify the name of the parameter, and in KIND the parameter type. For the parameter type, you must use solely the following constants from the type group ABAP:
Modules
ABAP_FUNC_EXPORTING for EXPORTING parameters
ABAP_FUNC_IMPORTING for IMPORTING parameters
ABAP_FUNC_CHANGING for CHANGING parameters
ABAP_FUNC_TABLES for TABLES parameters
The descriptions correspond to the caller's view. If the specified and actual parameter types do not correspond to each other, the system initiates, at runtime, an exception that cannot be handled.
For the value of the actual parameter, the reference in the column VALUE of the table line must point to a data object that contains the required value. For this you can use the command GET REFERENCE OF f INTO g.
If internal tables are passed to the TABLES parameter of a function module, that is, the column KIND contains the constant ABAP_FUNC_TABLES, the reference in the column VALUE must point to the table body of the internal table. In addition to the table body, you can pass on a reference to a table work area suitable for the type in the column TABLES_WA. This work area fills the header line of the formal parameter TABLES in the function module. In this way, it is possible, as in the static case, to pass internal tables with the header line, that is, table body and header line, to the TABLES parameter.
Example
type-pools ABAP.
data NAME type STRING value `ABAP_DOCU_SHOW`.
data PARA_TAB type ABAP_FUNC_PARMBIND_TAB.
data PARA_LINE like line of PARA_TAB.
data AREA(4) type C.
data OBJECT(30) type C.
AREA = 'ABAP'.
PARA_LINE-NAME = 'AREA'.
PARA_LINE-KIND = ABAP_FUNC_EXPORTING.
get reference of AREA into PARA_LINE-VALUE.
append PARA_LINE to PARA_TAB.
OBJECT = 'CLASS'.
PARA_LINE-NAME = 'NAME'.
PARA_LINE-KIND = ABAP_FUNC_EXPORTING.
get reference of OBJECT into PARA_LINE-VALUE.
append PARA_LINE to PARA_TAB.
call function NAME
parameter-table PARA_TAB.
In this example, the function module ABAP_DOCU_SHOW is called dynamically in full form, whereby its IMPORTING parameters AREA and NAME are supplied with data.
Message was edited by: Guillaume Garcia
‎2005 Oct 04 12:32 PM
Hi Christian,
First of all : not that bad your English....
Here is an extract from the Help :
<b>Addition 6</b>
... PARAMETER-TABLE itab
Effect
With this addition, the interface of a function module can be dynamically supplied with parameters. The addition PARAMETER-TABLE excludes parallel use of the static additions 1 through 5.
The parameter table itab must be a sorted table of the table type ABAP_FUNC_PARMBIND_TAB or of the line type ABAP_FUNC_PARMBIND. These types are defined in the type group ABAP in the ABAP dictionary. The table has the following four columns:
NAME For the name of the formal paramter
KIND for the type of parameter passing
VALUE of the type REF TO DATA for the value of the actual parameter
TABLES_WA of the type REF TO DATA for the value of the table work area, if a TABLES parameter is passed.
The columns NAME and KIND form the unique table key. For each non-optional parameter, you must fill exactly one line of the internal table.
In NAME, you must specify the name of the parameter, and in KIND the parameter type. For the parameter type, you must use solely the following constants from the type group ABAP:
Modules
ABAP_FUNC_EXPORTING for EXPORTING parameters
ABAP_FUNC_IMPORTING for IMPORTING parameters
ABAP_FUNC_CHANGING for CHANGING parameters
ABAP_FUNC_TABLES for TABLES parameters
The descriptions correspond to the caller's view. If the specified and actual parameter types do not correspond to each other, the system initiates, at runtime, an exception that cannot be handled.
For the value of the actual parameter, the reference in the column VALUE of the table line must point to a data object that contains the required value. For this you can use the command GET REFERENCE OF f INTO g.
If internal tables are passed to the TABLES parameter of a function module, that is, the column KIND contains the constant ABAP_FUNC_TABLES, the reference in the column VALUE must point to the table body of the internal table. In addition to the table body, you can pass on a reference to a table work area suitable for the type in the column TABLES_WA. This work area fills the header line of the formal parameter TABLES in the function module. In this way, it is possible, as in the static case, to pass internal tables with the header line, that is, table body and header line, to the TABLES parameter.
Example
type-pools ABAP.
data NAME type STRING value `ABAP_DOCU_SHOW`.
data PARA_TAB type ABAP_FUNC_PARMBIND_TAB.
data PARA_LINE like line of PARA_TAB.
data AREA(4) type C.
data OBJECT(30) type C.
AREA = 'ABAP'.
PARA_LINE-NAME = 'AREA'.
PARA_LINE-KIND = ABAP_FUNC_EXPORTING.
get reference of AREA into PARA_LINE-VALUE.
append PARA_LINE to PARA_TAB.
OBJECT = 'CLASS'.
PARA_LINE-NAME = 'NAME'.
PARA_LINE-KIND = ABAP_FUNC_EXPORTING.
get reference of OBJECT into PARA_LINE-VALUE.
append PARA_LINE to PARA_TAB.
call function NAME
parameter-table PARA_TAB.
In this example, the function module ABAP_DOCU_SHOW is called dynamically in full form, whereby its IMPORTING parameters AREA and NAME are supplied with data.
Message was edited by: Guillaume Garcia
‎2005 Oct 04 12:45 PM
Hi Christian,
I think You need the following syntax
CALL FUNCTION func
PARAMETER-TABLE
ptab
EXCEPTION-TABLE
etab.
where ptab contains all your parameters and etab all exceptions (if needed). You have to populate these tables first.
I found this in the help. For the complete example just have a look.
Best Regards
Rene
‎2005 Oct 04 6:33 PM
Hello and thank you all for your answers.
I've got a problem to find the explainment for "PARAMETER-TABLE" in the SAP Help of our System (release 46B). Is is possible that I can use this "new function" only in a later release?
I think that the "PARAMETER-TABLE" is just what I want, or better: just what I need.
I try to find something in the SAP online help, because I think it's much "up to date" than our local version.
I'm happy that I found so excellent and quick help.
Thank you.
Christian
‎2005 Oct 04 7:03 PM
Hi,
maybe it is easier and much faster to find it in the ABAP-Keyworddocumentation. But I don't know if it is already in 46B. I am working here on NW04 and found it quickly.
Kind Regards
Rene
‎2005 Dec 07 7:46 PM
Hello Christian,
I got the same problem in version 46c and i resolved it by using GENERATE SUBROUTINE instruction and i used SAP function 'FUNCTION_IMPORT_DOKU' to get those parameters functions .
Regards,
Jacques
types: typ_code(72) type c.
data: lst_code_source type typ_code.
data: lit_code_source type standard table of typ_code.
data: l_PROG(8), l_MSG(120), l_LIN(3), l_WRD(10), l_OFF(3).
data: l_nom_fonction type rs38l-name value
'ABR_ABRECHNUNGSEINHEIT_ABRECHN',
lit_dokumentation type standard table of funct,
lit_exception_list type standard table of rsexc,
lit_export_parameter type standard table of rsexp,
lit_import_parameter type standard table of rsimp,
lit_changing_parameter type standard table of rscha,
lit_tables_parameter type standard table of rstbl,
l_no_exception(1) type n.
field-symbols: 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Former dynamiquement le CALL FUNCTION !!!
append 'REPORT TESTJACQUES.' to lit_code_source.
append 'FORM EXECUTER_CALL_FUNCTION.' to lit_code_source.
append ' ' to lit_code_source.
Faire un traitment pour ramasser les type-pools de la fonction si
une donnée a besoin d'un type en particulier
append 'type-pools: fvink.' to lit_code_source.
Définition des paramètres EXPORT
if not lit_export_parameter is initial.
loop at lit_Export_parameter assigning -parameter
into lst_code_source separated by space.
Ajouter le TYPE si nous parlons de TYPE sinon comme le LIKE
if not -dbfield
into lst_code_source separated by space.
endif.
Ajouter le POINT dans le DATA
concatenate lst_code_source
'.'
into lst_code_source.
append lst_code_source to lit_code_source.
ENDLOOP.
endif.
Définition des paramètres IMPORT
if not lit_import_parameter is initial.
loop at lit_import_parameter assigning -parameter
into lst_code_source separated by space.
Ajouter le TYPE si nous parlons de TYPE sinon comme le LIKE
if not -dbfield
into lst_code_source separated by space.
endif.
Ajouter le DEFAULT dans le DATA
if not -default
into lst_code_source separated by space.
endif.
endif.
Ajouter le POINT dans le DATA
concatenate lst_code_source
'.'
into lst_code_source.
append lst_code_source to lit_code_source.
Faire l'assignation de la variable Système !!!
if -default
'.'
into lst_codE_source separated by space.
append lst_code_source to lit_code_source.
endif.
ENDLOOP.
endif.
Définition des paramètres CHANGING
if not lit_changing_parameter is initial.
loop at lit_changing_parameter assigning -parameter
into lst_code_source separated by space.
Ajouter le TYPE si nous parlons de TYPE sinon comme le LIKE
if not -dbfield
into lst_code_source separated by space.
endif.
Ajouter le DEFAULT dans le DATA
if not -default
into lst_code_source separated by space.
endif.
endif.
Ajouter le POINT dans le DATA
concatenate lst_code_source
'.'
into lst_code_source.
append lst_code_source to lit_code_source.
Faire l'assignation de la variable Système !!!
if -default
'.'
into lst_codE_source separated by space.
append lst_code_source to lit_code_source.
endif.
ENDLOOP.
endif.
Définition des paramètres TABLES
if not lit_tables_parameter is initial.
loop at lit_tables_parameter assigning 0.
WRITE: / 'Error during generation in line', l_lin,
/ l_msg,
/ 'Word:', l_wrd, 'at offset', l_off.
ELSE.
WRITE: / 'The name of the subroutine pool is', l_prog.
SKIP 2.
endif.
perform executer_call_function in program (l_prog) if found.