C call function without knowing parameters
I need to write a function that is given a function pointer, and a list of types (integers that represent a type). I can obtain the values to pass to the function pointer, but am wondering how to call it. This needs to happen at run time and i dont know how many arguments i will have. e.g.
void call_function(void (*func)(),int types[],void *args[]){
int i;
for(i=0;types[i]!=0;i++){
// Add this argument
// call the function with the arguments
I just found passing a function pointer was the best way to do something interesting with my WM.
I had a function that selected and called a window tiling function.
But when I started adding multimonitor support, I needed a function that did a few housekeeping bits, then tiled each monitor. It was ugly and repetative until I had the first function pass a pointer to the tiling funtion to the monitor function. The monitor function loops through monitors and calls whichever function it was passed.
But back OT. I may have misread the first time. Are you writing just the calling function, or are you also writing the function that is being passed as a function pointer? If you are only doing the former, you cannot do this. You must call a function with the correct number of arguments - unless it was declared as a variadic function. If you are writing that function to - then see va_args, and you can do this.
In either case - this may be a good place for some inline assembly. May being the operative word there - I do a good bit of C, and have dabbled in assembly, but I've never really combined the two. But as I understand it, you should be able to push your arguments to the stack, then call the function. This is how arguments are passed afterall.
Similar Messages
-
Passing enums to functions without knowing the specific enum type
My application needs the function invocation feature by using reflection mechanism. The function parameters are restricted to string, int, float and enums. I am facing problems with enums.
Is there a way to invoke the function by passing specific enum type as parameter to the function.
For eg:
public void doProcess(int i, COLOR.RED){
I should be able to invoke the above function using reflections. How dynamic casting to COLOR can be done is the question here?The application takes XML file as an input. This file has processing instructions. The processing instruction provides data about the class name, function name and parameters specifications like
Classname_FunctionName("String param", 123, COLOR.RED)
The application should invoke the corresponding library function by passing these parameters after assessing the correct types. -
Invoke RFC function without input parameters
Is it possible to invoke RFC function that doesn't have input parameters? It returns all data from reference.
Hi Denis,
pls keep in mind that no reference parameter is allowed in RFC, you have to check that "Pass Value" flag.
Thanks
Luis -
I have a function that performs DML. I am calling the function from toplink with the following. I get an error
ORA-14551: cannot perform a DML operation inside a query when I try to execute this function. Is there another way to call functions without using select From dual?
String queryFunc = "SELECT " +
"CCU.adjPaymentTrans(#caseID, #obligorPIN, #ccuPIN, #transCd, #payorTp) " +
"FROM dual";
SQLCall sqlCallFunc = new SQLCall(queryFunc);
ValueReadQuery valueReadFunc = new ValueReadQuery(sqlCallFunc);
valueReadFunc.addArgument("caseID");
valueReadFunc.addArgument("obligorPIN");
valueReadFunc.addArgument("ccuPIN");
valueReadFunc.addArgument("transCd");
valueReadFunc.addArgument("payorTp");
valueReadFunc.bindAllParameters();
Vector theArgumentValuesFunc = new Vector(6);
theArgumentValuesFunc.add(caseID);
theArgumentValuesFunc.add(obligorPIN);
theArgumentValuesFunc.add(ccuPIN);
theArgumentValuesFunc.add(transCd);
theArgumentValuesFunc.add(payorTp);
Number amountReversed = (Number)uow.executeQuery(valueReadFunc, theArgumentValuesFunc);Normally DML is only done from stored procedures, not stored functions, you may want to consider changing the function to a procedure.
To call a function that does DML, you must call the function through a PLSQL call. If you did not require the return value, the code would be:
>>
String queryFunc = "begin " +
"CCU.adjPaymentTrans(#caseID, #obligorPIN, #ccuPIN, #transCd, #payorTp);" +
"end;";
SQLCall sqlCallFunc = new SQLCall(queryFunc);
DataModifyQuery modifyFunc = new DataModifyQuery(sqlCallFunc);
>>
If you require the return value, then the SQL would be:
>>
String queryFunc = "begin ? = " +
"CCU.adjPaymentTrans(?, ?, ?, ?, ?);" +
"end;";
>>
However this would have to be executed through a CallableStatement in JDBC. TopLink currently only supports executing stored procedures as callable statements, so you would need to execute this directly through JDBC. You could also convert the function to a procedure, or wrap the function with a procedure. I believe TopLink 10.1.3 will have support for a StoredFunctionCall that can call DML stored functions.
To get a JDBC connection from a TopLink session uses,
UnitOfWork uow = session.acquireUnitOfWork();
uow.beginEarlyTransaction()
uow.getAccessor().getConnection();
uow.commit(); -
I ordered a new phone and shipped it to a friend in Dubai, UAE. without knowing i have to activate it by making 5minutes calls, please i need a way to activate it without sending it back to the US..any help? this has been very frustrating for me this past few days
scottxx,
That was very nice of you to provide your friend with a new phone! I am sorry to say that the device will not be able to activate while in Dubai. For a device to activate it must connect to the VZW network to become active. I apologize for any inconvenience.
LindseyT_VZW -
Calling a function and passing parameters via Variables
I've got an XML file that is loading in data and is calling functions.
I've figured out how to call the methods from classes with variables set from the XML file:
var functionToCall:String = xml.functions.func[0].to_fire.toString();
myClass[functionToCall]();
This calls the function perfectly.
I was wondering if there is anyway to pass parameters into the function as well through variables. Some functions may have no parameters, some functions could have 5... so the xml could be like this:
<functions>
<func>
<to_fire>function1</to_fire>
<param>
<value>true</value>
<type>Boolean</type> <!-- Must be set to Boolean, String or Number -->
</param>
</func>
<func>
<to_fire>function2</to_fire>
<param/>
</func>
<func>
<to_fire>function3</to_fire>
<param>
<value>false</value>
<type>Boolean</type> <!-- Must be set to Boolean, String or Number -->
</param>
<param>
<value>My String Value</value>
<type>String</type> <!-- Must be set to Boolean, String or Number -->
</param>
<param>
<value>10</value>
<type>Number</type> <!-- Must be set to Boolean, String or Number -->
</param>
</func>
</functions>
whats the best way to set something like this up?how would I set something like that up?
in the class:
public function myFunction(_param1:String, _param2:Number):void {
then to call it, would ParamTypes be cast as an array or object or something?
var functionVariable:String = "myFunction";
myClass[functionVariable](??);
Or do I structure the XML file in some way to pass in the information? -
How to get info from calling Function Module without passing it.
Hi,
I am facing a problem like from calling function module i want values of some variables and i dont want to change the import and export parameters, is there any way to get it done...
Thanks in advance...Hi,
It is possible only if you can find the memory id of the varibale.
You can find out it by debugging
<removed by moderator>
Edited by: Mike Pokraka on Aug 4, 2008 9:37 AM -
Functional module table parameters values not getting displayed in Java sys
Hi,
We are calling the Table parameter through Java code from functional
module ZCRM_ICSS_PROJ_CUST_USR is not giving any rows value .If I execute
the same functional module with passing the import parameter value User
id: MLDL010 its giving value in CRM.
I am checking Function module( Remote enabled ) in Debugging mode,
before displaying values it is raising message like
SY-MSGNR - 005
SY-MSGTY - CRM_LINK
in T100 Table
SPRSL : EN
ARBGB : CRM_LINK
MSGNR : 005
TEXT :'No Links corresponding to the specified data could be determined'
Is that related to any communication problem CRM & JAVA ICSS System ?
Regards,
Pavan.The message in simple English just means that "You are doing something really bad" !!! It is absolutely not the communication problem, but understanding problem.
Though you may be executing the same function using SE37 or in the webshop application through JCo, the runtime context is different and without knowing what exactly your Z rfc is doing, it is very difficult to help. To start with, the userid - that is who is running the RFC is different in both situations. In SE37, it is the logon user and in the web, depending upon whether the connection is stateless or stateful, it could be the anonymous ICSS user or the logged in user. Here again, if you have used UME, it is the user id and if you have used ALIAS user, then it is the alias user id. This is just an example. Your runtime context can be different due to many other reasons too.
So, to make this simpler - what is that you are trying to do?
BTW, try not to create multiple threads for the same issue.. -
Uncatchable exception: BSP calling Function Module
Hi all,
currently i'm facing a very weird problem. My application class calls function module
HR_INFOTYPE_OPERATION. Normally, in case of an error, the function module gives you back a return parameter. But if i call it from my BSP, the processing doesn't leave the function module. It directly throws an exception ERROR_MESSAGE_STATE instead of writing the message into parameter return.
If i call the function module with the same parameters from a report, it works fine and the error message is written to return parameter without throwing an exception.
What am i doing wrong? I don't want that exception and need to go on with filled parameter result.
Regards
Mark-AndréHi MA,
try using ERROR_MESSAGE in the exceptions list, like this.
CALL FUNCTION 'func_name'
EXPORTING
string = text
pos = position
IMPORTING
string1 = text1
string2 = text2
EXCEPTIONS
string1_too_small = 1
string2_too_small = 2
ERROR_MESSAGE = 3
OTHERS = 4.
Cheers
Graham Robbo -
How to fill data when call function of sap standard script form?
Hi every experts,
<Priority Normalized>
In our system, when we log in 'FR', we can print purchase order in language Franch,in t_code:ME22N. And when logging in 'EN', we can print it in language English, in ME22N. The English form is just only translated from Franch, with all same structure and frame. The form is done by script form.
And when logging in 'ZH', we create a new program, calling function smartform, instead of translating from EN language. Because of different structure and frame, I don't know the way to write script, so I print puchase order by smartform, when logging in 'ZH'.
But I have a new issue. Our MM module consultant needs me to print Chinese form if one condition, print English form in other condition.
So I have no idea to solve it. Because in my program, I get data to fill smartform and call function of smartform. And I don't know how to get data to fill script form. I only know the function name, 'OPEN_FORM' 'WRITE_FORM' 'CLOSE_FORM'.....
If I only call the several functions, I will get only frame without no data. So who can tell me how to do????
<Urgency downgraded>
Edited by: Suhas Saha on Jul 26, 2011 3:34 PM
Edited by: Vinod Kumar on Jul 26, 2011 4:09 PMHi,
Normally if we look in NACE transaction, you can see that upto five different FORMS can be assigned to a single output type . i.e. for each form there will be a seperate routine through which it gets called. But it all start from the first form only.
so you need to write your code in the ENTRY of the first form and if it does not satisfy do not go for processing of it but just exit of that form ENTRY. so that it will take you to next form.
hope this helps.
Thanks,
Venkatesh -
How to use CALL FUNCTION '/1BCDWB/SF00000014' in smartform urgent
hiiiiiiiii
Iam doing classical report n i want my output to be printed in smartform.
So my output is in IT_FINAL table.In smartform in Form Interface Table column i had declare :::
Parameter Name: IT_FINAL
Type Assignment:LIKE
Associated Type:ZSD_FINAL ( Its a structure of IT_FINAL)
And in SE38..iam using...............
data: FM_NAME1 type RS38L_FNAM.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZCSF_SDPRSR03_PR'
importing
FM_NAME = FM_NAME1.
CALL FUNCTION FM_NAME1
EXPORTING
IT_FINAL = IT_FINAL.
So while running its giving dump..
I DONT KNOW HOW TO USE THE ABOVE FUNCTION MODULE.
CALL FUNCTION '/1BCDWB/SF00000014'
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS =
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS =
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO =
JOB_OUTPUT_OPTIONS =
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Please suggest me with example if possible......URGENT.
(Rewards if solved)
Regards.Hi
see the below doc and do accordingly
How to create a New smartfrom, it is having step by step procedure
http://sap.niraj.tripod.com/id67.html
step by step good ex link is....
http://smoschid.tripod.com/How_to_do_things_in_SAP/How_To_Build_SMARTFORMS/How_To_Build_SMARTFORMS.html
Here is the procedure
1. Create a new smartforms
Transaction code SMARTFORMS
Create new smartforms call ZSMART
2. Define looping process for internal table
Pages and windows
First Page -> Header Window (Cursor at First Page then click Edit -> Node -> Create)
Here, you can specify your title and page numbering
&SFSY-PAGE& (Page 1) of &SFSY-FORMPAGES(Z4.0)& (Total Page)
Main windows -> TABLE -> DATA
In the Loop section, tick Internal table and fill in
ITAB1 (table in ABAP SMARTFORM calling function) INTO ITAB2
3. Define table in smartforms
Global settings :
Form interface
Variable name Type assignment Reference type
ITAB1 TYPE Table Structure
Global definitions
Variable name Type assignment Reference type
ITAB2 TYPE Table Structure
4. To display the data in the form
Make used of the Table Painter and declare the Line Type in Tabstrips Table
e.g. HD_GEN for printing header details,
IT_GEN for printing data details.
You have to specify the Line Type in your Text elements in the Tabstrips Output options.
Tick the New Line and specify the Line Type for outputting the data.
Declare your output fields in Text elements
Tabstrips - Output Options
For different fonts use this Style : IDWTCERTSTYLE
For Quantity or Amout you can used this variable &GS_ITAB-AMOUNT(12.2)&
5. Calling SMARTFORMS from your ABAP program
REPORT ZSMARTFORM.
Calling SMARTFORMS from your ABAP program.
Collecting all the table data in your program, and pass once to SMARTFORMS
SMARTFORMS
Declare your table type in :-
Global Settings -> Form Interface
Global Definintions -> Global Data
Main Window -> Table -> DATA
Written by : SAP Hints and Tips on Configuration and ABAP/4 Programming
http://sapr3.tripod.com
TABLES: MKPF.
DATA: FM_NAME TYPE RS38L_FNAM.
DATA: BEGIN OF INT_MKPF OCCURS 0.
INCLUDE STRUCTURE MKPF.
DATA: END OF INT_MKPF.
SELECT-OPTIONS S_MBLNR FOR MKPF-MBLNR MEMORY ID 001.
SELECT * FROM MKPF WHERE MBLNR IN S_MBLNR.
MOVE-CORRESPONDING MKPF TO INT_MKPF.
APPEND INT_MKPF.
ENDSELECT.
At the end of your program.
Passing data to SMARTFORMS
<b>call function 'SSF_FUNCTION_MODULE_NAME'</b>
exporting
formname = 'ZSMARTFORM'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = FM_NAME
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
if sy-subrc <> 0.
WRITE: / 'ERROR 1'.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
<b>call function FM_NAME</b>
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS =
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS =
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO =
JOB_OUTPUT_OPTIONS =
TABLES
GS_MKPF = INT_MKPF
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Smartform
you can check this link here you can see the steps and you can do it the same by looking at it..
http://smoschid.tripod.com/How_to_do_things_in_SAP/How_To_Build_SMARTFORMS/How_To_Build_SMARTFORMS.html
SMARTFORMS STEPS.
1. In Tcode se11 Create a structure(struct) same like the Internal table that you are going to use in your report.
2. Create Table type(t_struct) of stracture in se11.
3. In your program declare Internal table(Itab) type table of structure(struct).
4. Define work area(wa) like line of internal table.
5. Open Tcode Smartforms
6. In form Global setting , forminterface Import parameter define Internal table(Itab) like table type of stracture(t_struct).
7. In form Global setting , Global definitions , in Global data define Work area(wa) like type stracture(struct).
8. In form pages and window, create Page node by default Page1 is available.
9. In page node you can create numbers of secondary window. But in form there is only one Main window.
10. By right click on page you can create windows or Go to Edit, Node, Create.
11. After creating the window right click on window create table for displaying the data that you are passing through internal table.
12. In the table Data parameter, loop internal internal table (Itab) into work area(wa).
13. In table there are three areas Header, Main Area, Footer.
14. Right click on the Main area create table line by default line type1 is there select it.
15. Divide line into cells according to your need then for each cell create Text node.
16. In text node general attribute. Write down fields of your work area(wa) or write any thing you want to display.
17. Save form and activate it.
18. Then go to Environment, function module name, there you get the name of function module copy it.
19. In your program call the function module that you have copied from your form.
20. In your program in exporting parameter of function pass the internal table(itab).
SAP Smart Forms is introduced in SAP Basis Release 4.6C as the tool for creating and maintaining forms.
SAP Smart Forms allow you to execute simple modifications to the form and in the form logic by using simple graphical tools; in 90% of all cases, this won't include any programming effort. Thus, a power user without any programming knowledge can
configure forms with data from an SAP System for the relevant business processes.
To print a form, you need a program for data retrieval and a Smart Form that contains the entire from logic. As data retrieval and form logic are separated, you must only adapt the Smart Form if changes to the form logic are necessary. The application program passes the data via a function module interface to the Smart Form. When activating the Smart Form, the system automatically generates a function module. At runtime, the system processes this function module.
You can insert static and dynamic tables. This includes line feeds in individual table cells, triggering events for table headings and subtotals, and sorting data before output.
You can check individual nodes as well as the entire form and find any existing errors in the tree structure. The data flow analysis checks whether all fields (variables) have a defined value at the moment they are displayed.
SAP Smart Forms allow you to include graphics, which you can display either as part of the form or as background graphics. You use background graphics to copy the layout of an existing (scanned) form or to lend forms a company-specific look. During printout, you can suppress the background graphic, if desired.
SAP Smart Forms also support postage optimizing.
Also read SAP Note No. 168368 - Smart Forms: New form tool in Release 4.6C
What Transaction to start SAP Smart Forms?
Execute transaction SMARTFORMS to start SAP Smart Forms.
Key Benefits of SAP Smart Forms:
SAP Smart Forms allows you to reduce considerably the implementation costs of mySAP.com solutions since forms can be adjusted in minimum time.
You design a form using the graphical Form Painter and the graphical Table Painter. The form logic is represented by a hierarchy structure (tree structure) that consists of individual nodes, such as nodes for global settings, nodes for texts, nodes for output tables, or nodes for graphics.
To make changes, use Drag & Drop, Copy & Paste, and select different attributes.
These actions do not include writing of coding lines or using a Script language.
Using your form description maintained in the Form Builder, Smart Forms generates a function module that encapsulates layout, content and form logic. So you do not need a group of function modules to print a form, but only one.
For Web publishing, the system provides a generated XML output of the processed form.
Smart Forms provides a data stream called XML for Smart Forms (XSF) to allow the use of 3rd party printing tools. XSF passes form content from R/3 to an external product without passing any layout information about the Smart Form.
SmartForms System Fields
Within a form you can use the field string SFSY with its system fields. During form processing the system replaces these fields with the corresponding values. The field values come from the SAP System or are results of the processing.
System fields of Smart Forms
&SFSY-DATE&
Displays the date. You determine the display format in the user master record.
&SFSY-TIME&
Displays the time of day in the form HH:MM:SS.
&SFSY-PAGE&
Inserts the number of the current print page into the text. You determine the format of the page number (for example, Arabic, numeric) in the page node.
&SFSY-FORMPAGES&
Displays the total number of pages for the currently processed form. This allows you to include texts such as'Page x of y' into your output.
&SFSY-JOBPAGES&
Contains the total page number of all forms in the currently processed print request.
&SFSY-WINDOWNAME&
Contains the name of the current window (string in the Window field)
&SFSY-PAGENAME&
Contains the name of the current page (string in the Page field)
&SFSY-PAGEBREAK&
Is set to 'X' after a page break (either automatic [Page 7] or command-controlled [Page 46])
&SFSY-MAINEND&
Is set as soon as processing of the main window on the current page ends
&SFSY-EXCEPTION&
Contains the name of the raised exception. You must trigger your own exceptions, which you defined in the form interface, using the user_exception macro (syntax: user_exception <exception name >).
Example Forms Available in Standard SAP R/3
SF_EXAMPLE_01
Simple example; invoice with table output of flight booking for one customer
SF_EXAMPLE_02
Similar to SF_EXAMPLE_01 but with subtotals
SF_EXAMPLE_03
Similar to SF_EXAMPLE_02, whereby several customers are selected in the application program; the form is called for each customer and all form outputs are included in an output request
Advantages of SAP Smart Forms
SAP Smart Forms have the following advantages:
1. The adaption of forms is supported to a large extent by graphic tools for layout and logic, so that no programming knowledge is necessary (at least 90% of all adjustments). Therefore, power user forms can also make configurations for your business processes with data from an SAP system. Consultants are only required in special cases.
2. Displaying table structures (dynamic framing of texts)
3. Output of background graphics, for form design in particular the use of templates which were scanned.
4. Colored output of texts
5. User-friendly and integrated Form Painter for the graphical design of forms
6. Graphical Table Painter for drawing tables
7. Reusing Font and paragraph formats in forms (Smart Styles)
8. Data interface in XML format (XML for Smart Forms, in short XSF)
9. Form translation is supported by standard translation tools
10. Flexible reuse of text modules
11. HTML output of forms (Basis release 6.10)
12. Interactive Web forms with input fields, pushbuttons, radio buttons, etc. (Basis-Release 6.10)
Regards
Anji -
HI ALL
WHERE CAN I FIND ALL THE FUNCTION MODULES USED IN ABAP AND I ALSO NEED EXPLANATIONS ....CAN ANYONE HELP
WITH REGARDS
VIJAYHi,
You can use the table TFDIR to see all the fun modules in ABAP.
see the doc and links for further details
Function Modules;
Check this matter.
Function Modules are Glopbal ABAP programs created by SAP for reusable purpose.they have IMPORT,EXPORT and TABLE parameters, and EXCEPTIONS to through when error occurs.
You can create them from TCode SE37.
Go through the following doc:
Function modules are cross-program, reusable procedures that are organized into function groups, and whose functions are implemented between the statements FUNCTION and ENDFUNCTION. Function modules and their interfaces are created in the Function Builder.
Function Module Interfaces
The parameter interface of a function module is defined in the Function Builder. It includes the definition of interface parameters and the specification of exceptions that can be triggered by a function module. The Function Builder automatically generates comment lines below the FUNCTION statement in the source code of the function module, which represent the interface of the function module with the following syntax:
Syntax
... [IMPORTING parameters]
[EXPORTING parameters]
[CHANGING parameters]
[TABLES table_parameters]
[{RAISING|EXCEPTIONS} exc1 exc2 ...]
The syntax and semantics of IMPORTING, EXPORTING, CHANGING, RAISING, and EXCEPTIONS mainly correspond to the definition of method interfaces with [CLASS-]METHODS. The additional option of defining table parameters using TABLES is obsolete.
Interface parameters
The interface parameters are defined on the relevant tab pages in the Function Builder.
IMPORTING parameters are input parameters. When the function module is called, a suitable actual parameter must be specified for every non-optional input parameter. The content of the actual parameter is passed to the input parameter when the call is made. The content of an input parameter for which 'pass by reference' is defined cannot be changed in the function module.
EXPORTING parameters are output parameters. When the function module is called, a suitable actual parameter can be specified for every output parameter. The content of an output parameter that is defined for 'pass by value' is transferred to the actual parameter if the function module is completed without errors. An output parameter that is defined for pass by reference is not initialized when the function module is called.
CHANGING parameters are input and output parameters. When the function module is called, a suitable actual parameter must be specified for every non-optional input or output parameter. When the function module is called, the content of the actual parameter is passed to the input/output parameter, and when the function module is completed, the content of the input/output parameter is passed to the actual parameter.
TABLES parameters are table parameters. Table parameters are obsolete CHANGING parameters that are typed as standard tables with a header line. If an internal table without a header line or a table body is passed as an actual parameter to a formal parameter of this type, an empty local header line is generated in the function module. If an internal table with a header line is used as an actual parameter, both the table body and the header line are passed to the function module. Pass by value is not possible in formal parameters defined using TABLES. Formal parameters defined with TABLES can be replaced by formal parameters defined with CHANGING. A local work area can be created for the internal table in the function module by using the addition LIKE LINE OF itab of the DATA statement.
Exceptions
The exception of a function module are defined on the Exceptions tab page in the Function Builder. Here you can select exception classes to define whether class-based exceptions are declared or non-class-based exception are defined. Class-based exceptions are represented in the above syntax by RAISING, and non-class-based exceptions are represented by EXCEPTIONS.
The addition RAISING is used to declare class-based exceptions that can be propagated from the function module to the caller. Exceptions in the categories CX_STATIC_CHECK and CX_DYNAMIC_CHECK must be explicitly declared, otherwise a propagation can lead to an interface violation. A violation of the interface leads to the treatable exception CX_SY_NO_HANDLER. Exceptions of the category CX_NO_CHECK are implicitly always declared. The declaration of exceptions of the category CX_STATIC_CHECK is statically checked in the syntax check. For exceptions of the category CX_DYNAMIC_CHECK, the check is not performed until runtime. In a function module in which class-based exceptions are declared with the RAISING addition, the statement CATCH SYSTEM-EXCEPTIONS cannot be used. Instead, the relevant treatable exceptions should be handled in a TRY control structure.
The addition EXCEPTIONS is used to define a list of non-class-based exceptions that can be triggered in the function module using the statements RAISE or MESSAGE RAISING. Exceptions defined in this way - as with formal parameters - are bound to the function module and cannot be propagated. If an exception of this type is triggered in a function module, and no return value has been assigned to it with the homonymous addition EXCEPTIONS of the CALL FUNCTION statement when the call was made, this leads to a runtime error.
Note
For new developments after release 6.10, SAP recommends that you work with class-based exceptions that are independent of the function module.
RFC is a technology which is used to access a functions (Modules) from
the remote systems.
If a function module is set as remote enabled which can be access from
the remote system via RFC.Eg: U can access the Remote enabled function modules in ur VB,Webdynpro,Java,Visual composer program.
A function module can be set as remote enabled by SE37->Go to ur FM->click the option Button "remote enabled".
But Normal function modules can not accessd from the remote system.
Good Example for RFC enabled function module is : BAPI(Business Application Programming Interface)
Note: All BAPIs are Remote enabled but not all remote enabled function modules are BAPI.
CALLING A FUNCTION MODULE:
1)In U ABAP Editor --> Click "Patter" ---> Selection Option Button "Call Function"
--> Write the Corresponding FM name --> Hit Enter
2)The appropriate import ,export Parameters will be displayed in ur editor
3)Pass the Values Here.
Also check these links.
Check this link:
http://help.sap.com/saphelp_erp2004/helpdata/en/9f/db988735c111d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/ef/d94b78ebf811d295b100a0c94260a5/frameset.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/43/41341147041806e10000000a1553f6/frameset.htm
Check this link:
http://help.sap.com/saphelp_erp2004/helpdata/en/9f/db988735c111d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/ef/d94b78ebf811d295b100a0c94260a5/frameset.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/43/41341147041806e10000000a1553f6/frameset.htm
See the following links:
http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/26/64f623fa8911d386e70000e82011b8/content.htm
reward if useful
regards,
Anji -
Simulation model which call functions in an other dll...
I have a C simulation model that I implement like NI Model Framework template (NI_VStand_Model_Framework_Guide.pdf ). If I use this simple model I can deploy on my PXI. But I must call functions which are in an other dll. When I call functions in other DLL I can't deploy because Veristand specify that the model is not compatible.
NI VeriStand: The specified compiled model is not compatible with NI VeriStand.
=========================
NI VeriStand: NI VeriStand Engine.lvlib:VeriStand Engine Wrapper (RT).vi >> NI VeriStand Engine.lvlib:VeriStand Engine.vi >> NI VeriStand Engine.lvlib:VeriStand Engine State Machine.vi >> Model Execution.lvlib:Initialize Model Loop Data.vi >> SIT Model API.lvlib:Initialize Model.vi >> SIT Model API.lvlib:Load Model DLL.vi
<append>=========================
NI VeriStand: Failed to load c:\ni-rt\NIVeriStand\Models\LD1_T1.dll
If I use DLL Checker there is no bad import. How to add a simulation model in veristand which call function in an other DLL?Thank you for your answer.
I know how to import a dll in veristand. My Dll is LD1_T1. I can import it in Veristand without error. But this DLL depends of an other dll (addition.dll) as you can see in the print screen.
When I try to deploy to my PXI I have an error message of compatibility.
NI VeriStand: The specified compiled model is not compatible with NI VeriStand.
=========================
NI VeriStand: NI VeriStand Engine.lvlib:VeriStand Engine Wrapper (RT).vi >> NI VeriStand Engine.lvlib:VeriStand Engine.vi >> NI VeriStand Engine.lvlib:VeriStand Engine State Machine.vi >> Model Execution.lvlib:Initialize Model Loop Data.vi >> SIT Model API.lvlib:Initialize Model.vi >> SIT Model API.lvlib:Load Model DLL.vi
<append>=========================
NI VeriStand: Failed to load c:\ni-rt\NIVeriStand\Models\LD1_T1.dll
For LD1_T1.dll I have use NI Model Framework template (NI_VStand_Model_Framework_Guide.pdf ).
If I check my Dll with dll checker it's ok but I can't deploy.
Please somebody have an idee to deploy my model ? -
Call Function in CL_RSPLS_CR_EXIT_BASE to derive values
Dear all,
we want to derive the location from item (material). If item gebinns with "EMU" then location is 2. If item beginns with "X" then locations is "68" and so on.
To realise we chose characteristic relationship with derivation and based on "Exit Class".
we copied the Class "CL_RSPLS_CR_EXIT_BASE" to "Z_CL_RSPLS_CR_EXIT_BASE". Now we want to call a function method "IF_RSPLS_CR_METHODS~DERIVE" like:
implement your derivation algorithm here:
field-symbols: <l_chavl> type any.
assign component 'BW_LAGER' of structure c_s_chas to <l_chavl>.
CALL FUNCTION 'Z_ST_BW_LAGER'
The function look like:
FUNCTION Z_ST_BW_LAGER.
""Lokale Schnittstelle:
*" EXPORTING
*" REFERENCE(BW_LAGER) TYPE /BIC/OIBW_LAGER
lesen
But we did not know wich are the IMPORTING (like I_INFOPROV ?) parameters to fecht the values for the data. In BW-BPS we have UPC_Y_AREA, UPC_Y_VARIABLE, UPY_Y_CHANM and so on. Wich are the same in BI-integrated planning.
Regards,
Daniel MeyerDear all,
we use this code:
field-symbols: <l_chavl> type any.
DATA: LAGER(2).
assign component '/BIC/P_RMRESC' of structure c_s_chas to <l_chavl>.
IF <l_chavl>+0(3) = 'EMU'.
LAGER = '2'.
ELSEIF <l_chavl>+0(1) = 'O'.
LAGER = '1'.
ENDIF.
<l_s_buf>+2(15) = <l_chavl>.
assign component '/BIC/BW_LAGER' of structure c_s_chas to <l_chavl>.
<l_chavl> = LAGER.
<l_s_buf>+0(2) = <l_chavl>.
But now we have the problem, how to write ist back to the buffer? If we debugg it, we see in this code:
IF o_use_buffer = rs_c_true.
o_r_is_valid->* = l_is_valid.
IF o_r_is_valid->* = rs_c_true.
INSERT <l_s_buf> INTO TABLE <l_th_buf>.
c_s_chas = <l_s_buf>.
ELSE.
IF e_t_mesg IS SUPPLIED.
o_r_s_mesg->* = l_s_mesg.
APPEND l_s_mesg TO e_t_mesg.
ENDIF.
INSERT <l_s_buf> INTO TABLE <l_th_buf>.
RAISE EXCEPTION TYPE cx_rspls_failed
EXPORTING
msgid = l_s_mesg-msgid
msgty = l_s_mesg-msgty
msgno = l_s_mesg-msgno
msgv1 = l_s_mesg-msgv1
msgv2 = l_s_mesg-msgv2
msgv3 = l_s_mesg-msgv3
msgv4 = l_s_mesg-msgv4.
ENDIF.
ENDIF.
that o_r_is_valid->* has no value, so he goes to the ELSE-part.
Could anyone help?
Regards,
Daniel -
Call function..Destination
Hi Experts,
My requirement is to call a RFC Java function in SAP. The Java function is an encryption function which has 4 parameters (Password, Message, Strength128, Strength256). I need to pass the data for the parameters from SAP to JAVA. With the help of SDN, I tried to call this function in ABAP. A destination named 'INTEGRATION' is created in SM59, with the registered Program ID 'ASEncryptionHelper'. ASEncryptionHelper is the Java function name and the program ID is registered with this name only. The following is the code I wrote in my report
DATA: XPASS TYPE STRING.
XPASS = 'PASS'.
CALL FUNCTION 'ASENCRYPTIONHELPER' DESTINATION 'INTEGRATION'
EXPORTING
PASSWORD = XPASS
MESSAGE = XML_RESULT
STRENGTH128 = ' '
STRENGTH256 = 'X'
I have created a RFC function module in my SAP system with the name ASENCRYPTIONHELPER
FUNCTION ASENCRYPTIONHELPER.
""Local Interface:
*" IMPORTING
*" VALUE(PASSWORD) TYPE STRING
*" VALUE(MESSAGE) TYPE STRING
*" VALUE(STRENGTH128) TYPE BOOLEAN
*" VALUE(STRENGTH256) TYPE BOOLEAN
ENDFUNCTION.
When I execute the program I get a runtime error "Bean ASENCRYPTIONHELPER not found on host HOSTNAME".
I am not able tofigure out the exact problem.
Also I wanted to know whether the way I am coding is right. Do I need to create a RFC function module in SAP also as I did above?
Does the Uppercase of the function 'ASENCRYPTIONHELPER' matter? In SM59 the program id is mentioned as 'ASEncryptionHelper'.
I tried to change the function name with 'ASEncryptionHelper' in the CALL FUNCTION, but then I get another error, "JCO.Server could not find server function 'ASEncryptionHelper' '. What is wrong? I am confused.
Please guide.
Thanks
Anu.Hi,
I didn't get your requirement wxatly but you can do as below,
What I am assuming is you have a java batch file at your desktop and you want to encrypt the file through this batch file execution from SAP.
Now to execute the batch file at runtime and to pass data at runtime you can use below function module
W_RFCENCRY = 'C:\Encrypt\enc.exc C:\Encrypt\test.txt'.
W_RFCDEST = 'ZRFC'.
CALL FUNCTION 'RFC_REMOTE_PIPE'
DESTINATION W_RFCDEST
EXPORTING
COMMAND = W_RFCENCRY
EXCEPTIONS
COMMUNICATION_FAILURE = 1
SYSTEM_FAILURE = 2
OTHERS = 4.
Here ZRFC is the RFC created in SM59 as below
1) select TCP/IP and create ZRFC
in program option type as below C:\RfcSdk\bin\rfcexec.exe
Note: RFCDSK folder is required to execute the batch file at your workstation at path specified as above
2) In activation type select start on front end work station radio button.
Now save the RFC and check the connection, same will be there if RFC SDK folder is available as specified in the program option
In W_RFCENCRY give the inputs that you want to pass with the batch file.
here I have mentioned as 'C:\Encrypt\enc.exc C:\Encrypt\test.txt'. in the program where C:\Encrypt\enc.exc is the path for batch file and C:\Encrypt\test.txt is the path of the file on the work station which is to be encrypted.
Hope this will help you, I think at your end batch file can be different and inputs to be passed in the batch file can also be different.
Maybe you are looking for
-
Mac Mail Smart Folders triplicate messages (Gmail-based mail server)
I can't get Mail Smart Folders to work well with my Virginmedia mail server, which seems to use a Gmail type of system. (I'm using IMAP). It is easy to set up an instruction to select mail e.g. from defined individuals only, or any other qualifier. H
-
Can I use a wildcard in mail filter?
Is it possible to use a wildcard in Rules to eliminate certain emails? I want to automatically delete emails that have a certain word in them -- and have set up a rule to do so -- but a few still sneak through by having that certain word as part of a
-
Lightroom problem with CR2 images
I have LR loaded on my MacBook Pro and everything was alright in terms of LR operation. I use a 5D MKII camera and always shoot in RAW (CR2). I always download images from the Card to the HDD and then import it to LR. However, CR2 Raw files are not g
-
Using html:select with mutiple
hy, guys!I need some help:I am developing a form were I use a heml:select wich have to use the mutiple selecting function( the user could select more then one option)it looks like this: <html:select property="sectors" multiple="true" size="3" ><html:
-
Cfgrid updating issue with multiple records
I have a cfgrid within cfform, it fetches the records and shown in the screen properly. refer screenshot. have a new field "sortfield" as a editable field and updating the record as 1,2,3,4 (instead - 1,6,2,4) but after updated in the db. The datas u