Calling a c# function with a ref parameter to a struct
public struct TestStruct
public bool Value;
public class Functions
void Flip(ref TestStruct testStruct)
testStruct.Value = !testStruct.Value;
I'm trying to call the from c++ like this
TestStruct ^ testStruct = gcnew TestStruct();
Functions ^ functions = gcnew Functions();
functions->Flip(testStruct);
This gives an compiler error saying "cannot convert parameter 1 from 'TestStruct ^' to 'TestStruct %'
I know that this is the correct syntax if TestStruct was a class and not a struct. But i'm using a third party library so changing from struct to class is not an options.
Anybody know how to make this call.
Found the answer:
functions->Flip(*testStruct);
Hi Grarup,
I took a stab at getting this to run and compile and this is what I came up with. Let me know if this helps at all.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
class Program
static void Main(string[] args)
Console.WriteLine("\"True\" or \"False\"?");
bool boolVal = bool.Parse(Console.ReadLine());
Functions f = new Functions();
TestStruct t = new TestStruct() { Value = boolVal };
f.Flip(ref t);
Console.WriteLine(string.Format("Flipped value = {0}: ", t.Value));
Console.ReadLine();
public struct TestStruct
public bool Value;
public class Functions
public void Flip(ref TestStruct testStruct)
testStruct.Value = !testStruct.Value;
Best of luck.
Similar Messages
-
How to create a function with ref_cursor as parameter in OWB 10.1
Hi,
Can any one help me how to create a function with ref_cursor as parameter in OWB 10.1.?
Its urgent. Please help me.
Thanks,
SivHi David,
Thanks for your reply.
Before going for this function, I need to create a package in transformation node in owb module.
My package is as follows,
Create or replace package 123
type xxx is RECORD ( parameters);
type yyy is RECORD (parameters);
type aaa is table of yyy;
type bbb is REF CURSOR return xxx;
type ccc is record (parameters);
type ddd is ref cursor return eee;
END;
How can I create the above kind of package manually in OWB 10.1 (Should not to import the package)
Please help me its urgent.
Thanks,
Siv -
Difficulties replacing some BC functionality with XI (refer to example)
<b>Difficulties replacing some BC functionality with XI (refer to example)</b>
I am transferring all interface processing from BC to XI and am having difficulties replacing some of the current BC functionality. Please refer to my example below
<b>Current process</b>
<b>SAP R/3</b>
SAP R/3 executes an abap that extracts certain data. This data is passed via a remote function which is configured to point to Business Connector
<b>Business Connector</b>
Business Connector takes control and the relevant package does some internal processing then calls the remote enabled function BAPI_ACC_BILLING_POST
<b>SAP R/3</b>
Control is returned to SAP R/3 to post the data and on completion control is returned to Business Connector
<b>Business Connector</b>
Business Connector again takes control where some more processing is done to generate an xml version of the data prior to returning control back to SAP R/3
<b>SAP R/3</b>
Control is returned to the abap immediately following the call to the remote function and processing completes
The initial synchronous call from SAP R/3 to Business Connector remains open whilst Business Connector executes a subsequent synchronous call to SAP R/3.
Finally the initial synchronous call in SAP R/3 completes
<b>Proposed Process</b>
I am transferring all interface processing from BC to XI and am having difficulties replacing some of the current BC functionality. In this instance I can set up the initial synchronous call via an XI Integration Process (sync/async bridge). This allows me to perform subsequent asynchronous calls prior to closing the synchronous bridge
I have successfully performed synchronous calls to SAP R/3 from XI for different scenarios and have set up the XI design and config in the same manner
When I try to perform the synchronous posting back to SAP R/3 from within the SA bridge I get the message Message is incomplete. No Sender found
Unlike BC, it appears that XI does not allow me to perform the synchronous posting back to SAP R/3 from within the SA bridge.
<b>Refer to</b> http://help.sap.com/saphelp_nw04/helpdata/en/83/d2a84028c9e469e10000000a1550b0/frameset.htm <b>for the SAP description</b> To enable the communication between a synchronously calling business system (synchronous outbound interface) and an asynchronously called business system (asynchronous inbound and outbound interface), you can define a sync/async bridge in an integration process. You can only define one sync/async bridge for each integration process.
How can I replace the current BC functionality using XI?
Regards,
MikeHi all,
I cannot replicate the current BC functionality in XI
So I will take this opportunity to simplify and improve the design for XI --> R/3
Regards,
Mike -
How can I Create function with an out Parameter
how all
how can I Create function with an out Parameter
I try to create it it sucess but how can I CALL it , it give me error
please I want A simple example
thanks3rd post on same question by same user :
Re: how can I Create function with an out Parameter
how can I Create function with an out Parameter -
After install Lightroom 5.3 we cannot resized a pict in export function with "bord etroit" parameter. It's good with "bord large"!...
Regards
JacquesDanCarr wrote:
I'm sure this was working in the previous version......
Yep - new bug in Lr5.3 (presumably will be fixed in Lr5.4).
More info here:
http://feedback.photoshop.com/photoshop_family/topics/publish_service_harddisk_ignores_ima ge_sizing_resize_to_fit_short_edge_setting_when_source_image_is_a_dng_on_lightroom -
How to call a Stored Procedure with a REF CURSOR output parameter
I am looking forward an example that call a stored function/procedure with a REF CURSOR output parameter and get the result.
In other words, I have a stored function/procedure that execute a SELECT statement using the OCI library and then it could get the values of each column and each row.
I put a code snippet, it have only the main thing to call a simple stored procedure and print the name of each column of the cursor, but I couldn´t to print out the values in the table that call the stored procedure.
I understand that the next step, it is to call a OCIStmtFetch.
How to associate the cursor with the OCIStmtFetch?
If you need more information, only tell me.
I am using ANSI C with HP-UX Operative System (C for HP-UX) and Oracle 10g.
Regards.
Antonio Garcia
/* callOracleSP */
#include <stdio.h>
#include <string.h>
#include <oci.h>
#include <stdlib.h>
char* pConnectChar ="server";
char* pUsernameChar = "user";
char* pPasswordChar = "passwd";
char* sqlCharArray1 = "BEGIN SP_GETCITIES(:s, :c); END;";
int retval;
ub4 parmcnt=0;
ub4 pos2=0;
text *pcoln[20];
ub4 namelen[20];
char state_key[5];
OCIStmt* pOciStatement;
OCIStmt* pOciStatCursor;
OCIError* pOciError;
OCIEnv* pOciEnviron;
OCIServer* pOciServer;
OCISession* pOciSession;
OCISvcCtx* pOciServiceContext;
OCIBind* pOciBind[500];
OCIParam* pOciParam;
int main()
retval = OCIEnvCreate(&pOciEnviron, OCI_DEFAULT, NULL, NULL, NULL, NULL,0,NULL);
retval = OCIEnvInit(&pOciEnviron, OCI_DEFAULT, 0, NULL);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciError, OCI_HTYPE_ERROR, 0, NULL);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciServiceContext, OCI_HTYPE_SVCCTX, 0, NULL);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatement, OCI_HTYPE_STMT, 0, NULL);
retval = OCILogon(pOciEnviron,pOciError,&pOciServiceContext,(unsigned char *)pUsernameChar,
strlen(pUsernameChar), (unsigned char *)pPasswordChar, strlen(pPasswordChar),
(unsigned char *)pConnectChar,strlen(pConnectChar));
printf("OCILogon retval=%d\n",retval);
retval = OCIStmtPrepare(pOciStatement, pOciError, (unsigned char *)sqlCharArray1,strlen(sqlCharArray1),
OCI_NTV_SYNTAX, OCI_DEFAULT);
printf("StmtPrepare retval=%d\n",retval);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatCursor, OCI_HTYPE_STMT, 0, NULL);
retval = OCIBindByPos(pOciStatement,&pOciBind[0], pOciError, (ub4) 1, (void *)&state_key,
(sb4) sizeof(state_key), SQLT_STR, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
retval = OCIBindByPos(pOciStatement,&pOciBind[1], pOciError, (ub4) 2, (void *)&pOciStatCursor,
(sb4) 0, SQLT_RSET, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
strcpy(state_key,"CA");
retval = OCIStmtExecute(pOciServiceContext, pOciStatement, pOciError, (ub4)1, (ub4) 0,
(OCISnapshot *)NULL, (OCISnapshot *)NULL, (ub4) OCI_DEFAULT);
printf("StmtExecute retval=%d\n",retval);
/* How to get the values of the cursor? */
/* Get number of parameters of the Cursor */
OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &parmcnt,(ub4 *) 0,
(ub4)OCI_ATTR_PARAM_COUNT, pOciError);
printf("\nNumber of parameters of the cursor = %d\n",parmcnt);
for (int pos = 1; pos <= (int)parmcnt; pos++)
OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &pos2,(ub4 *) 0,
(ub4)OCI_ATTR_CURRENT_POSITION, pOciError);
retval = OCIParamGet((void *)pOciStatCursor, (ub4)OCI_HTYPE_STMT, pOciError, (void **)&pOciParam,
(ub4) pos );
OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &pcoln[pos-1],(ub4 *) &namelen[pos-1],
(ub4) OCI_ATTR_NAME,(OCIError *)pOciError );
for (int i = 1; i <=(int)parmcnt; i++)
printf("Column %i\tNAME = %.*s\n",i,namelen[i-1],pcoln[i-1]);
return 0;
This is the script that create the table, insert records and create the stored procedure
CREATE TABLE CITIES (
STATE_CODE VARCHAR2(2) NULL,
CITY_CODE NUMBER(15,5) NULL,
CITY_NAME VARCHAR2(30) NULL
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('CA', 30, 'SAN DIEGO')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('CA', 40, 'SACRAMENTO')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('FL', 10, 'MIAMI')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('FL', 20, 'ORLANDO')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('NY', 10, 'NEW YORK')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('NY', 20, 'ALBANY')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('CA', 10, 'LOS ANGELES')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('CA', 20, 'SAN FRANCISCO')
CREATE OR REPLACE PACKAGE globalPkg AUTHID CURRENT_USER AS
/* The following are T/SQL specific global variables. */
TYPE RCT1 IS REF CURSOR;/*new weak cursor definition*/
END globalPkg;
CREATE OR REPLACE PROCEDURE SP_ADDCITY(
P_STATE_CODE IN VARCHAR,
P_CITY_CODE IN NUMBER,
P_CITY_NAME IN VARCHAR2,
P_RETURN IN OUT NUMBER)
AS
StoO_error INTEGER;
StoO_selcnt INTEGER;
StoO_rowcnt INTEGER;
StoO_errmsg VARCHAR2(255);
BEGIN
StoO_rowcnt := 0;
StoO_error := 0;
StoO_selcnt := 0;
P_RETURN := 0;
INSERT INTO CITIES (STATE_CODE, CITY_CODE, CITY_NAME)
VALUES (P_STATE_CODE, P_CITY_CODE, P_CITY_NAME);
StoO_rowcnt := SQL%ROWCOUNT;
EXCEPTION
WHEN TOO_MANY_ROWS THEN
StoO_rowcnt := 2;
WHEN OTHERS THEN
StoO_rowcnt := 0;
StoO_selcnt := 0;
StoO_error := SQLCODE;
StoO_errmsg := SQLERRM;
IF StoO_error != 0 THEN
BEGIN
P_RETURN := 1;
RETURN;
END;
END IF;
END;
CREATE OR REPLACE PROCEDURE SP_GETCITIES(
STATE_KEY IN VARCHAR,
RC1 IN OUT globalPkg.RCT1)
AS
StoO_error INTEGER;
StoO_selcnt INTEGER;
StoO_rowcnt INTEGER;
StoO_errmsg VARCHAR2(255);
BEGIN
StoO_rowcnt := 0;
StoO_error := 0;
StoO_selcnt := 0;
OPEN RC1 FOR
SELECT STATE_CODE, CITY_CODE, CITY_NAME
FROM CITIES
WHERE STATE_CODE = STATE_KEY
ORDER BY CITY_CODE;
StoO_rowcnt := SQL%ROWCOUNT;
EXCEPTION
WHEN OTHERS THEN
StoO_rowcnt := 0;
StoO_error := SQLCODE;
StoO_errmsg := SQLERRM;
END;
/Hi Mark,
Thanks for your recommendations.
I change the code with OCIDefineByPos, one for each parameter from cursor and then use the OCIStmtFetch.
I don´t receive a error when call OCIDefineByPos, but when I call OCIStmtFetch receive a -1 error number.
What is wrong with the code?
The script is the same.
I need your help!
Best Regards!
Antonio Garcia (Mexico)
This the new code:
#include <stdio.h>
#include <string.h>
#include <oci.h>
#include <stdlib.h>
char* pConnectChar ="ORAC617";
char* pUsernameChar = "C617_005_DBO_01";
char* pPasswordChar = "Tempora1";
char* sqlCharArray1 = "BEGIN SP_GETCITIES(:s, :c); END;";
int retval;
ub4 parmcnt=0;
ub4 pos2=0;
sb2 *c_indp;
text *pcoln[20], *name,*name2;
ub4 namelen[20],len;
ub2 type,size;
char state_key[5];
OCIDefine *pdef;
OCIBind *p_bnd;
ub1 **c_buf;
OCIStmt* pOciStatement; /* Statement handle */
OCIStmt* pOciStatCursor; /* Statement handle */
OCIError* pOciError; /* Error handle */
OCIEnv* pOciEnviron; /* Environment handle */
OCIServer* pOciServer; /* Server handle */
OCISession* pOciSession; /* Session handle */
OCISvcCtx* pOciServiceContext; /* Service Context handle */
OCIBind* pOciBind[500]; /* Bind handle */
OCIParam* pOciParam; /* Param handle */
int OCI_Fetch(OCIStmt *p_select,OCIError *p_err, int *piOcc)
int iOcc, rc;
rc=OCIStmtFetch(p_select,p_err,1,OCI_FETCH_NEXT,OCI_DEFAULT);
printf("rc fetch %i",rc);
if(rc==0&&piOcc!=NULL){
printf("entro al if");
iOcc=*piOcc;
*piOcc=iOcc+1;
return rc;
int main()
int pos,i=0,rc;
retval = OCIEnvCreate(&pOciEnviron, OCI_DEFAULT, NULL, NULL, NULL, NULL,0,NULL);
printf("EnvCreate retval=%d\n", retval);
retval = OCIEnvInit(&pOciEnviron, OCI_DEFAULT, 0, NULL);
printf("EnvInit retval=%d\n",retval);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciError, OCI_HTYPE_ERROR, 0, NULL);
printf("HandleAlloc OCI_HTYPE_ERROR retval=%d\n",retval);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciServiceContext, OCI_HTYPE_SVCCTX, 0, NULL);
printf("HandleAlloc OCI_HTYPE_SVCCTX retval=%d\n",retval);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatement, OCI_HTYPE_STMT, 0, NULL);
printf("HandleAlloc OCI_HTYPE_STMT retval=%d\n",retval);
retval = OCILogon(pOciEnviron,pOciError,&pOciServiceContext,(unsigned char *)pUsernameChar,
strlen(pUsernameChar), (unsigned char *)pPasswordChar, strlen(pPasswordChar),
(unsigned char *)pConnectChar,strlen(pConnectChar));
printf("OCILogon retval=%d\n",retval);
retval = OCIStmtPrepare(pOciStatement, pOciError, (unsigned char *)sqlCharArray1,strlen(sqlCharArray1),
OCI_NTV_SYNTAX, OCI_DEFAULT);
printf("StmtPrepare retval=%d\n",retval);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatCursor, OCI_HTYPE_STMT, 0, NULL);
printf("HandleAlloc OCI_HTYPE_STMT retval=%d\n",retval);
retval = OCIBindByPos(pOciStatement,&pOciBind[0], pOciError, (ub4) 1, (void *)&state_key,
(sb4) sizeof(state_key), SQLT_STR, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
retval = OCIBindByPos(pOciStatement,&pOciBind[1], pOciError, (ub4) 2, (void *)&pOciStatCursor,
(sb4) 0, SQLT_RSET, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
strcpy(state_key,"CA");
retval = OCIStmtExecute(pOciServiceContext, pOciStatement, pOciError, (ub4)1, (ub4) 0,
(OCISnapshot *)NULL, (OCISnapshot *)NULL, (ub4) OCI_DEFAULT);
printf("StmtExecute retval=%d\n",retval);
c_buf=(ub1 **)calloc(sizeof(ub1 *),3);
c_indp=(sb2 *)calloc(sizeof(sb2 *),3);
// Get number of parameters of the Cursor
OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &parmcnt,(ub4 *) 0,
(ub4)OCI_ATTR_PARAM_COUNT, pOciError);
printf("\nNumber of parameters of the cursor = %d\n",parmcnt);
for (pos = 1; pos <= (int)parmcnt; pos++)
OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &pos2,(ub4 *) 0,
(ub4)OCI_ATTR_CURRENT_POSITION, pOciError);
retval = OCIParamGet((void *)pOciStatCursor, (ub4)OCI_HTYPE_STMT, pOciError, (void **)&pOciParam,(ub4) pos );
// Get the column name
OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &name,(ub4 *) &len, (ub4) OCI_ATTR_NAME,(OCIError *)pOciError );
// Get the column datatype
OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &type,(ub4 *)0,(ub4)OCI_ATTR_DATA_TYPE,(OCIError *)pOciError);
// Get the column size
OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &size,(ub4 *)0,(ub4)OCI_ATTR_DATA_SIZE,(OCIError *)pOciError);
printf("Column %i\tNAME = %.*s \ttype %d \tsize %d\n",pos,len,name,type,size);
// OCIDefine ByPos, one for each parameter
// c_buf store the STATE_CODE, CITY_CODE and CITY_NAME columns from the cursor
rc=OCIDefineByPos(pOciStatCursor,&pdef,(OCIError *)pOciError,pos,c_buf[pos-1],size+1,(ub2)type,(dvoid *)c_indp[pos-1],(ub2 *)0,(ub2 *)0,OCI_DEFAULT);
printf("OCIDefineByPos retval=%d\n,rc);
// call OCIStmtFetch. In the next line, I receive the error
rc=OCIStmtFetch(pOciStatCursor,pOciError,1,OCI_FETCH_NEXT,OCI_DEFAULT);
printf("rc fetch %i",rc);
return 0;
{code} -
Xdk: calling java function with a CharSequence parameter
When using xdk version 10.1.0.2.0_production, you can not call a javamethod with a CharSequence parameter.
Sun documentation:
Interface CharSequence
All Known Implementing Classes:
CharBuffer, String, StringBuffer
This prevents us from calling a method like
java.util.regex.Pattern.matches(String, CharSequence)
Converting the parameter to a normal string would solve the problem.
Example to illustrate the issue:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes" xmlns:Pattern="http://www.oracle.com/XSL/Transform/java/java.util.regex.Pattern">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:if test="Pattern:matches('...','123')">
<xsl:text>MATCH</xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
results in the following stacktrace:
oracle.xml.parser.v2.XPathException: Extension function error: Error invoking 'matches':'java.lang.NullPointerException'
at oracle.xml.parser.v2.XSLExtFunctions.callStaticMethod(XSLExtFunctions.java:113)
at oracle.xml.parser.v2.XPathExtFunction.evaluateMethod(XPathExtFunction.java:296)
at oracle.xml.parser.v2.XPathExtFunction.evaluate(XPathExtFunction.java:223)
at oracle.xml.parser.v2.XSLCondition.testCondition(XSLCondition.java:185)
at oracle.xml.parser.v2.XSLCondition.processAction(XSLCondition.java:165)
at oracle.xml.parser.v2.XSLNode.processChildren(XSLNode.java:403)
at oracle.xml.parser.v2.XSLTemplate.processAction(XSLTemplate.java:191)
at oracle.xml.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:507)
at oracle.xml.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:484)
at oracle.xml.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:256)
at oracle.xml.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:146)
at oracle.xml.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:218)
at XSLSample.main(XSLSample.java:75)
Message was edited by:
user449717Hi Grarup,
I took a stab at getting this to run and compile and this is what I came up with. Let me know if this helps at all.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
class Program
static void Main(string[] args)
Console.WriteLine("\"True\" or \"False\"?");
bool boolVal = bool.Parse(Console.ReadLine());
Functions f = new Functions();
TestStruct t = new TestStruct() { Value = boolVal };
f.Flip(ref t);
Console.WriteLine(string.Format("Flipped value = {0}: ", t.Value));
Console.ReadLine();
public struct TestStruct
public bool Value;
public class Functions
public void Flip(ref TestStruct testStruct)
testStruct.Value = !testStruct.Value;
Best of luck. -
How to call a function with generic table parameter
Hi everybody
I need to call function module RSAR_ODS_API_GET (from BW). It recive an internal table with request ids and should return in E_T_DATA "unstructured" data from the psa and in E_T_RSFIELDTXT the description of the data structure, I guess
from sap help only thing I have reggarding how to use the function module is :
"You can call up the function module RSAR_ODS_API_GET with the list of request IDs given by the function module RSSM_API_REQUEST_GET. The function module RSAR_ODS_API_GET no longer recognizes InfoSources on the interface, rather it recognizes the request IDs instead. With the parameter I_T_SELECTIONS, you can restrict reading data records in the PSA table with reference to the fields of the transfer structure. In your program, the selections are filled and transferred to the parameter I_T_SELECTIONS.
The import parameter causes the function module to output the data records in the parameter E_T_DATA. Data output is unstructured, since the function module RSAR_ODS_API_GET works generically, and therefore does not recognize the specific structure of the PSA. You can find information on the field in the PSA table using the parameter E_T_RSFIELDTXT."
unfortunately I when running de report bellow, I get a dump which says:
Function parameter "E_DATA" is unknown
in the definition of the interface E_DATA has no type, which means it can recive any table type, right?
So I have two questions?
1) How to get the code working
2) How do I use the parameter E_T_RSFIELDTXT to parse the data returned in E_DATA
by debuging RSSM_API_REQUEST_GET for this code I found it try to put an internal table with the struct of the database table /BIC/B0000151000 in E_DATA
Thanks a lot for any help
rgds
my test report is:
REPORT ZTEST_PSA_API.
TABLES: /BIC/B0000151000 .
TYPE-POOLS: RSSM.
TYPES: BEGIN OF STC_REQ_LINE,
sign(1),
option(2),
low TYPE rsa_request,
high TYPE rsa_request,
END OF STC_REQ_LINE,
IT_REQUEST TYPE STC_REQ_LINE OCCURS 0.
DATA: lit_request TYPE RSSM_T_API_REQUEST_GET WITH HEADER LINE,
lc_system TYPE RSSM_T_API_LOGSYS,
lit_request1 TYPE IT_REQUEST WITH HEADER LINE.
DATA: lc_dtarget_name TYPE RSA_ODSNAME,
lit_meta_data TYPE RSARC_T_RSFIELDTXT.
DATA: lt_psa_data LIKE /BIC/B0000151000 OCCURS 0.
CALL FUNCTION 'RSSM_API_REQUEST_GET'
EXPORTING
I_SOURCE = '2LIS_13_VDITM'
I_TYP = 'D'
I_DATEFROM = '20060627'
IMPORTING
E_T_REQUEST = lit_request[]
E_T_LOGSYS = lc_system
EXCEPTIONS = 1.
READ TABLE lit_request.
lit_request1-sign = 'I'.
lit_request1-option = 'EQ'.
lit_request1-low = lit_request-request .
APPEND lit_request1 .
break-point .
CALL FUNCTION 'RSAR_ODS_API_GET'
EXPORTING
I_T_REQUEST = lit_request1[]
IMPORTING
E_ODSNAME = lc_dtarget_name
E_T_RSFIELDTXT = lit_meta_data
TABLES
E_DATA = lt_psa_data
EXCEPTIONS
NO_DATA_FOUND = 1
PARAMETER_FAILURE = 2
REQUEST_NOT_AVAILABLE = 3
NO_REQUEST_FOUND = 4
NO_FIELDS_TO_ODS = 5
NO_ODS_FOUND = 6
PACKAGE_LOCKED_BY_LOADING = 7 .Try to pass table parameter without "[]" :
CALL FUNCTION 'RSAR_ODS_API_GET'
EXPORTING
I_T_REQUEST = lit_request1
IMPORTING
E_ODSNAME = lc_dtarget_name
E_T_RSFIELDTXT = lit_meta_data
TABLES
E_DATA = lt_psa_data -
Complicated PL/SQL questions that involves function with in type parameter
Hello,
I have a question about functions with in-parameters. In the HR schema, I need to get the minimum salary of the job_id that is mentioned as an in-parameter.
this is what I am thinking but I dont know if it's correct or not or what should I do next!
create or replace function get_min_salary (i_job_id in varchar2)
return number
as
min_sal jobs.min_salary%type;
begin
SELECT min_salary INTO min_sal
FROM jobs
where job_id = i_job_id;
RETURN min_sal;
end get_min_salary;if the i_job_id which is the in type parameter does not have a minimum salary then use the following function to register an error:
create or replace procedure insert_error (i_error_code in number,
i_error_message in varchar2)
as
begin
insert into error_table (error_user, error_date, error_code, error_message)
values (user,sysdate,i_error_code,i_error_message);
end insert_error;This function is basically to say that an error has occured and to register that error, at the same time I need to print out the error using the dbms_out.put_line.
Any ideas of how to do that?
Thanks in advance>
minimum salary of the job_id
>
may be
SELECT min(min_salary) INTO min_sal
FROM jobs
where job_id = i_job_id;
if the i_job_id which is the in type parameter does not have a minimum salary then use the following function to register an error:why error?
This function is basically to say that an error has occured and to register that error, at the same time I need to print out the error using the dbms_out.put_line.
create or replace procedure insert_error (i_error_code in number,
i_error_message in varchar2)
as
begin
insert into error_table (error_user, error_date, error_code, error_message)
values (user,sysdate,i_error_code,i_error_message);
-- this
dbms_out.put_line('this');
end insert_error; -
How to call a Stored Function with OUT parameter of %rowType from Java
Hi everyone,
I'm getting crazy trying to make this work.
I have a function (not developed by me) in Oracle 10g declared in this way:
type tab_RLSSP is table of TB_RLSSP_STOSTPRPAR_CL%ROWTYPE index by binary_integer;
FUNCTION DBF_PERL_LISTA_PRATICHE (
p_id_va IN NUMBER,
p_seq_partita IN NUMBER,
p_trattamento IN CHAR,
lrec_RLSSP OUT tab_RLSSP ) RETURN NUMBER;
And here is the code snipplet of my java method:
sql="{? = call "+SCHEMA+PACKAGE+"."+FUNCTION_LIST+"(?,?,?,?)}";
cs=connection.prepareCall(sql);
cs.registerOutParameter(1, OracleTypes.NUMBER);
cs.setLong(2,idVATitolare);
cs.setLong(3,seqPartita);
cs.setString(4,trattamento);// Caso Decesso
cs.registerOutParameter(5, OracleTypes.OTHER);
cs.executeQuery();
result = (ResultSet) cs.getObject(5);
if (result.next())
listaPratiche.add(readPraticaPartita(result));
The result (exception thrown at executeQuery with statement generated as
SQL : {? = call PEDBA.DBK_PERL_RATEI_SUPPLETIVI.DBF_PERL_LISTA_PRATICHE(?,?,?,?)}:
java.sql.SQLException: ORA-06550: line 1, column 13:
PLS-00306: wrong number or types of arguments in call to 'DBF_PERL_LISTA_PRATICHE'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Changing to :
sql="{call ? := "+SCHEMA+PACKAGE+"."+FUNCTION_LISTA+"(?,?,?,?)}";
leading to
SQL : {call ? := call PEDBA.DBK_PERL_RATEI_SUPPLETIVI.DBF_PERL_LISTA_PRATICHE(?,?,?,?)}
don't change anything.
What's wrong? Any suggestion?
Edited by: 957158 on 5-set-2012 9.06>
Taking for granted that it works, I wonder what's different, probably the output is defined as Cursor...
>
You mean because of this line?
cs.registerOutParameter(5,OracleTypes.CURSOR);You can either use a cursor or use a function that returns a SQL type instead of the PL/SQL type.
Here is sample code using a cursor
CREATE OR REPLACE TYPE SCOTT.local_type IS OBJECT (
empno NUMBER(4),
ename VARCHAR2(10));
CREATE OR REPLACE TYPE SCOTT.local_tab_type IS TABLE OF local_type;
CREATE OR REPLACE PACKAGE SCOTT.test_refcursor_pkg
AS
TYPE my_ref_cursor IS REF CURSOR;
-- add more cursors as OUT parameters
PROCEDURE test_proc(p_ref_cur_out OUT test_refcursor_pkg.my_ref_cursor);
END test_refcursor_pkg;
CREATE OR REPLACE PACKAGE BODY SCOTT.test_refcursor_pkg
AS
PROCEDURE test_proc(p_ref_cur_out OUT test_refcursor_pkg.my_ref_cursor)
AS
l_recs local_tab_type;
BEGIN
-- Get the records to modify individually.
SELECT local_type(empno, ename) BULK COLLECT INTO l_recs
FROM EMP;
-- Perform some complex calculation for each row.
FOR i IN l_recs.FIRST .. l_recs.LAST
LOOP
DBMS_OUTPUT.PUT_LINE(l_recs(i).ename);
END LOOP;
-- Put the modified records back into the ref cursor for output.
OPEN p_ref_cur_out FOR
SELECT * from TABLE(l_recs);
-- open more ref cursors here before returning
END test_proc;
END;
SET SERVEROUTPUT ON SIZE 1000000
DECLARE
l_cursor test_refcursor_pkg.my_ref_cursor;
l_ename emp.ename%TYPE;
l_empno emp.empno%TYPE;
BEGIN
test_refcursor_pkg.test_proc (l_cursor);
LOOP
FETCH l_cursor
INTO l_empno, l_ename;
EXIT WHEN l_cursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(l_ename || ' | ' || l_empno);
END LOOP;
CLOSE l_cursor;
END;
/ -
Calling a stored procedure with an XmlType parameter.
I am attempting to execute a stored function via a named query. The stored procedure has a single parameter of Oracles 'xmltype', and also returns an xmltype. For example this dummy function
function testXML(xml_in xmltype) return xmltype is
begin
return xml_in;
end;
Is it possible to make the named query call with an oracle.xdb.XMLType or oracle.xdb.dom.XDBDocument? I cannot find any examples of this being done. I also want the returning xmltype to be converted into a Java class.
Another question - will I need to work with a conversion manager to achieve this?Local Exception Stack:
Exception [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): oracle.toplink.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Invalid column typeError Code: 17004
Call:BEGIN ? := TestPackage.testXML(XML_IN=>?); END;
bind => [=> RESULT, oracle.xml.parser.v2.XMLDocument@1a64732 => XML_IN]
Query:DataReadQuery()
at oracle.toplink.exceptions.DatabaseException.sqlException(DatabaseException.java:290)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:570)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:442)
at oracle.toplink.threetier.ServerSession.executeCall(ServerSession.java:453)
at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:117)
at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:103)
at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:174)
at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeSelect(DatasourceCallQueryMechanism.java:156)
at oracle.toplink.queryframework.DataReadQuery.executeNonCursor(DataReadQuery.java:118)
at oracle.toplink.queryframework.DataReadQuery.executeDatabaseQuery(DataReadQuery.java:110)
at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:603) -
Can not call a static function with-in a instance of the object.
Another FYI.
I wanted to keep all of the "option" input parameters values for a new object that
i am creating in one place. I thought that the easiest way would be to use a
static function that returns a value; one function for each option value.
I was looking for a way to define "constants" that are not stored in
the persistent data of the object, but could be reference each time
the object is used.
After creating the static functions in both the "type" and "body" components,
I created the method that acutally receives the option input values.
In this method I used a "case" statement. I tested the input parameter
value, which should be one of the option values.
I used a set of "WHEN conditions" that called the same
static functions to get the exact same values that the user should
pass in.
When I try to store this new version, I get the error:
"PLS-00587: a static method cannot be invoked on an instance value"
It points to the first "when statifc_function()" of the case function.
This seems weird!
If I can call the static method from the "type object" without creating
and instance of an object, then why can't I call it within the body
of a method of an instance of the object type?
This doesn't seem appropriate,
unless this implementation of objects is trying to avoid some type
of "recursion"?
If there is some other reason, I can not think of it.
Any ideas?Sorry for the confusion. Here is the simplest example of what
I want to accomplish.
The anonymous block is a testing of the object type, which definition follows.
declare
test audit_info;
begin
test := audit_info(...);
test.testcall( audit_info.t_EMPLOYER() );
end;
-- * ========================================== * --
create or replace type audit_info as object
( seq_key integer
, static function t_EMPLOYER return varchar2
, member procedure test_call(input_type varchar2)
instantiable
final;
create or replace type body audit_info
as
( id audit_info
static function t_EMPLOYER return varchar2
as
begin
return 'EMPLOYER';
end;
member procedure test_call(input_type varchar2)
as
begin
CASE input_type
WHEN t_EMPLOYER()
select * from dual;
WHEN ...
end case;
end;
end;
The error occurs on the "WHEN t_EMPLOYER()" line. This code is only
an example.
Thanks. -
How to define a function with table type parameter
Hello All,
Here is the requirement ..
cursor c is select first_name, last_name , ssn from employee ;
TYPE employee_type IS TABLE OF c%rowtype;
tbl_employee_type employee_type;
I want to pass the parameter to a function the ssn -: tbl_employee_type(1).ssn
how the formal parameter should be declared
===========================
function chk_notnull_blank ( ? ) return boolean is
BEGIN
if ( colname is NOT NULL and colname in ( -8E14, -7E14, -6E14, -5E14, -4E14, -3E14, -2E14, -1E14, -1E9 )) then
RETURN TRUE ;
else
RETURN FALSE ;
end if;
END chk_notnull_blank;
======================
pls advice
thanks/kumarYou cannot define a generic argument in a function,
but you can overload several funtions with the same name and different types of arguments in a package,
in this way (not tested):
create table employees as
select employee_id ssn, first_name, last_name from hr.employees;
create or replace
PACKAGE chk
IS
cursor c is select first_name, last_name , ssn from employees ;
TYPE employee_type IS TABLE OF c%rowtype;
TYPE employee_ssn_type IS TABLE OF employees.ssn%TYPE;
TYPE employee_num_type IS TABLE OF number;
FUNCTION chk_notnull_blank ( colname employees.ssn%TYPE) RETURN boolean;
FUNCTION chk_notnull_blank ( colnames employee_type) RETURN boolean;
FUNCTION chk_notnull_blank ( colnames employee_ssn_type) RETURN boolean;
FUNCTION chk_notnull_blank ( colnames employee_num_type) RETURN boolean;
END chk;
create or replace
PACKAGE BODY chk
IS
FUNCTION chk_notnull_blank ( colname employees.ssn%TYPE) RETURN boolean IS
BEGIN
if ( colname is NOT NULL and colname in ( -8E14, -7E14, -6E14, -5E14, -4E14, -3E14, -2E14, -1E14, -1E9 )) then
RETURN TRUE ;
else
RETURN FALSE ;
END IF;
END chk_notnull_blank;
FUNCTION chk_notnull_blank ( colnames employee_type) RETURN boolean IS
BEGIN
FOR i IN colnames.FIRST .. colnames.LAST LOOP
IF NOT chk_notnull_blank( colnames( i ).ssn )
THEN
RETURN FALSE;
END IF;
END LOOP;
RETURN true;
END chk_notnull_blank;
FUNCTION chk_notnull_blank ( colnames employee_ssn_type) RETURN boolean
IS
BEGIN
FOR i IN colnames.FIRST .. colnames.LAST LOOP
IF NOT chk_notnull_blank( colnames( i ) )
THEN
RETURN FALSE;
END IF;
END LOOP;
RETURN TRUE;
END chk_notnull_blank;
FUNCTION chk_notnull_blank ( colnames employee_num_type) RETURN boolean
IS
BEGIN
FOR i IN colnames.FIRST .. colnames.LAST LOOP
IF NOT chk_notnull_blank( colnames( i ) )
THEN
RETURN FALSE;
END IF;
END LOOP;
RETURN TRUE;
END chk_notnull_blank;
END chk;I assumed in this example that if the argument of the function chk_notnull_blank is of the table (collection) type,
then the function returns true if all table elements pass the check, otherwise it returns false. -
Call pl-sql function with parameters All
I want to call a procedure inside Discoverer; i know how to do that. I have three page elements ; when i choose specific value for each one my function work properly.
When i choose <All> like a value for any page element ; funtion doesn't run properly. We decide to display the input value when i call function; when i choose <All> value i can't see the value of the parameter. I put nvl(P1,'ABC') and i can't see the value of the parameter.
In Discovere; when we choose <All> value what is the real value or character used to call function.
Thanks
Marcsee my function
FUNCTION "F_SSDW_TEMPS_NET_FONCT_MIN"("P_NO_CENTRE_DISTR" IN NUMBER,
"P_ID_QUART_TRAVAIL" IN NUMBER,
"P_CODE_EQUIPEMENT" IN VARCHAR2 ,
"P_DATE_TRANSACTION" IN DATE ) RETURN VARCHAR2 IS
CURSOR CRS_TEMPS_NET_FONCT_MIN IS
SELECT SUM(NVL(EFF_REMPL.TEMPS_NET_FONCT_MIN,0))
FROM SSDW_EFF_REMPL EFF_REMPL,
SSDW_EFF_REMPL_QUART_TRAVAIL EFF_QUART
WHERE EFF_REMPL.NO_CENTRE_DISTRIBUTION = P_NO_CENTRE_DISTR
and EFF_REMPL.id_quart_travail = EFF_QUART.ID_QUART_TRAVAIL_CENTRE_DISTR
and EFF_QUART.quart_travail = P_ID_QUART_TRAVAIL
AND EFF_REMPL.CODE_EQUIPEMENT = decode(UPPER(P_CODE_EQUIPEMENT),'TOUS',EFF_REMPL.CODE_EQUIPEMENT, P_CODE_EQUIPEMENT )
AND TRUNC(EFF_REMPL.DATE_TRANSACTION) = TRUNC(P_DATE_TRANSACTION);
V_TEMPS_NET_FONCT_MIN NUMBER;
BEGIN
OPEN CRS_TEMPS_NET_FONCT_MIN;
FETCH CRS_TEMPS_NET_FONCT_MIN INTO V_TEMPS_NET_FONCT_MIN;
CLOSE CRS_TEMPS_NET_FONCT_MIN;
RETURN ('ZZ'||to_char(P_CODE_EQUIPEMENT||'ZZ');
END;
I know how to use a function inside discoverer; my question is ; for my four input parameters ( each one correspond to a page-element )
My question is ; if i decide to choose to select the value <All> for equipement code; what will be the real value passed in parameter to my function.
Like you can see in my code ; i decide to return the parameter in value.
When i select <All> the output parameter equal nothing ; i see absoltely nothing in screen ; i don't see 'ZZ'
Thanks
Marc -
How to call a oracle procedure with in/out parameter frm unix shell script?
Hi,
I need to call an oracle stored procedure from unix script. The procedure has 1 input parameter and 2 output parameter. Please send me the syntax for the same. Based on the output values of procedure, I have to execute some more commands in unix script.
Thanks and regards
AAn example :
TEST@db102 SQL> select ename, job from emp
2 where empno = 7902;
ENAME JOB
FORD ANALYST
TEST@db102 SQL> create or replace procedure show_emp (
2 v_empno in number,
3 v_ename out varchar2,
4 v_job out varchar2 )
5 is
6 begin
7 select ename, job into v_ename, v_job
8 from emp
9 where empno = v_empno;
10 end;
TEST@db102 SQL> /
Procedure created.
TEST@db102 SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[ora102 work db102]$ IN=7902
[ora102 work db102]$ set `sqlplus -s test/test@db102 << !
var out1 varchar2(30);
var out2 varchar2(30);
set pages 0
set feed off
exec show_emp($IN,:out1,:out2);
print
exit
`[ora102 work db102]$ echo $1 $2
FORD ANALYST
[ora102 work db102]$
Maybe you are looking for
-
Problem with selectOneMenu in Datatable
Hi I have the following datatable that binds correctly to a set of Game objects. I need to have a dropdown with the numbers 1 to 10 as items which is bound to each dataItem's newRating field. However there is some problem with the dropdown that i can
-
Are we able to create a new enhancement in the existing project
Hi all, I have created a project for an enhancement using an exit FM. And now I need to enhance with another exit FM, is it possible for me to use the same project for the second one also.or do I need to create another project for the second enhancem
-
How to export data to .csv and send that file to folder using sql commands?
Really hoping someone can provide some code sample or point me in the right direction (with examples using sql). I am using oracle 11g with plsql developer. My requirement is that the data retrieval should be automatic. That means when query a data i
-
TooManyObjectsException: JBO-25013 but with autosubmit
Hi all! I have this problem with my dialog ADF form. I have two combos with districts and counties. When i have autosubmit on create it gives me this error when i select some district to filter my counties table. I don't want him to insert on combo s
-
PMS RGB Values Different in Illustrator & PhotoShop
Hello, Forum; I'm stumped here. I'm working on a project that has me going back & forth between PhotoShop & Illustrator, working in PMS color. I've noticed that the RGB values for a given PMS are significantly different between the two environments.