Passing Structures
How can I pass structures across C and Java, while calling native methods. e.g I've to pass myStruct from C to Java or vice versa
struct myStruct
long along;
char* astring;
short ashort;
is there any possible way of doin' it or Native Methods support only intrinsic data types as arguments (intrinsic data types like int, short etc etc).
Of course, there is a way. You should, however, decide on where to keep the main copy of your instance within C as struct or with an analogously constructed Java class.
If you choose to hold your main copy as C struct, you also have to define a Java class, which does not contain these fields but only wraps the C struct with appropriate getters and setters. These are native methods called by Java to access the struct members. One field is still required in your Java class, which somehow holds the native pointer to the struct of a particular instance. A long or int will do on most platforms.
The other approach is to hold all the data within the Java object. Only define native methods for operations you cannot perform in Java. Those native methods construct the C struct at runtime to pass this copy to the native functions that require it. If the native functions your are trying to call only take fields of this struct as arguments, the wrapping JNI method even becomes simpler. In any case, do not forget to copy modified values back into the Java instance.
http://java.sun.com/docs/books/tutorial/native1.1/index.html
http://java.sun.com/docs/books/tutorial/native1.1/implementing/field.html
Similar Messages
-
Pass structure or array into a custom tag?
Is it possible to pass a CF structure or array to a custom
tag (C++/MFC) as an argument? Is it possible to create a CF array
or structure *from* a custom tag?Passing a structure out is as easy as using a period in the
variable name in your SetVariable() call.
For example,
pRequest->SetVariable ("SPP_zResults.bHadErroredPts", "0");
pRequest->SetVariable ("SPP_zResults.dMax",
"3.14159265");
Passing a struct in may be just as easy, I haven't ever
needed to try it.
Let us know if it works. -
Pass structure, internal table from workitem to BSP
Hi All,
I have a requirement where a BSP application is to be called from the workitem.
How can i pass a structure or an internal table from the workitem to the BSP application?In the BSP application mark the check box AUTO on the PAGE ATTRIBUTES tab and this makes the value available in the displayed URL of the BSP application.
the documention mentation provided by SAP regarding this option is
A page attribute marked as automatic is automatically supplied with a value from the calling URL or the navigation from another page. However there must exist a parameter of the same name with value in the URL or navigation interface.
here your navigation interface is WF_EXTSRV that you have already defined make the parameter as Exporting and when you get the URL read the URL and by using the OFFSET concept you can read the value of the element that you want in the BSP application -
Pass Structured table into dynamic table parameter in public method
Ladies and Gentlemen,
I have a requiremet to pass (1 at a time) any number of tables into a reuseable method in a custom class. The Method code is as follows:
method CREATE_OUTBOUND_FILE.
* Importing VALUE( IV_PATHNAME ) TYPE PATHEXTERN File Destination
* Importing VALUE( IT_FILE_RECORD ) TYPE REF TO DATA Table with Output
* Importing VALUE( IV_RECORD_STRUCTURE ) TYPE STRING OPTIONAL Record Structure
* Importing VALUE( IV_DELIMITER ) TYPE STRING File Delimiter
* Exporting VALUE( EV_RECORD_CNT ) TYPE STRING Record Count
Data:
ls_line_cnt(6) type n,
lt_data_struc type zty_ddic_struc_T,
ls_string type string.
field-SYMBOLS: <fs_string> type any.
* Open Dataset for outputting file details
Open dataset iv_pathname for output in text mode encoding default.
Assign ls_string to <fs_string> CASTING TYPE (iv_record_structure).
loop at it_file_record into <fs_string>.
transfer <fs_string> to iv_pathname.
Add 1 to ls_line_cnt.
clear <fs_string>.
endloop.
ev_record_cnt = ls_line_cnt.
where IV_PATHNAME = output destination & filename
IT_FILE_REC = data table
IV_RECORD_STRUCTURE = is ddic structure definition for the data table
IV_DELIMITER = file delimiter, in this case, let's say it's C (for CSV)
and EV_RECORD_CNT is a count of numbe of records processed.
Lets say, for example, I wish to load data from table SFLIGHT into the method when program A is executed. Then another time I wish to excute Program B which is passing in data of table SFLCONN2. I hope that by using the "type ref to data" defintion, I can pass the table contents through. Is this true?
Secondly, I'm getting a syntax error saying that "IT_FILE_RECORD" is not defined as a table (and therefore can't be looped at), and therefore can't be read. How can I access the data in this table in preparation for output.
Any assistance or thoughts would be greatly appreciated.
Regards,
SteveHi Stephen ,
Graham already gve part of the solution.
If you declare
Importing VALUE( IT_FILE_RECORD ) TYPE REF TO DATA
it does not make sense to declare to pass by VALUE because you will not change this refernce in the method. Calling this method, you must pass a refefernce.
data:
lr_ref type ref to data.
get reference of <your itab here> into lr_ref.
CREATE_OUTBOUND_FILE( ...IT_FILE_RECORD = lr_ref ... )
In the method, it goes as graham explained.
Anyway, I would declare the table parameter as
Importing IT_FILE_RECORD TYPE TABLE
The your code could work, but you will have troube with any non-character fields in the tables.
Regards,
Clemens -
Pass structure of values for Job submit
Hi,
I need sytax to submit a job
Right now I am using this code to send 4 parameters.
I need to send these 4 in a structure.
<b>submit Ztestjob USER sy-uname
via job p_jobnm
number p_jobcount
with afko-rsnum eq afko-rsnum
with aufnr_d eq aufnr_d
with sernr_d eq sernr_d
with p_lmnga eq p_lmnga
AND RETURN.</b>
So I have to pass a structure of values into the BGprogram through a submit and do a couple of loops in the BGPROGRAM.
I need the syntax for submit .
I also need to know how to catch the structure with values in the BGPROGRAM.
Anyone please answer ASAP
Message was edited by:
ramana peddu
Message was edited by:
ramana peddu
Message was edited by:
ramana peddu
Message was edited by:
ramana pedduHi,
If want to pass an internal table...
Then create a dummy select-options...
And then pass the values in the select-options..
Then in the submitted program you can use the select-options internal table..
Thanks,
Naren -
Passing structure to smart forms
Hi experts,
Can we pass more than one structure to smart form . If it is possible pls let me know the procedure...
Thanks.you can pass any number of structure in smartform defined as importing parameter in function module.
But you have to define that struture of similar type in se11.
then write in form interface like:;
itab1 like ziitab1.
where zitab1 structure which is similar type to itab1 defined using se11. -
Newbie: Passing Structures between DLLs via Java
A fairly high level question for you good people:
I have two DLLs. The first DLL is called by Java via JNI, and needs to return something akin to a C Structure (say an int, a double and a string for simplicity).
My Java code does not need to do anything with this data, except pass it to a second DLL for more processing (the second DLL for example needs to do something with just the double and the string).
My question is, is this sort of thing practical to do using JNI (I have the DLLs already but can easily add the JNIEXPORT etc functions) ?
(I have used JNI for a passing single values and arrays back and forth, but nothing with anything akin to structures).
Many thanks in advance.
DaveMy Java code does not need to do anything with this
data, except pass it to a second DLL for more
processing (the second DLL for example needs to do
something with just the double and the string).
My question is, is this sort of thing practical to do
using JNI (I have the DLLs already but can easily add
the JNIEXPORT etc functions) ?
Somewhere in memory a hunk is reserved for this. Your code does it or some external piece does.
You have a pointer to that.
It is very important that the memory does NOT go away until you tell it to.
You cast the pointer to a long and return that to java. Your java piece keeps track of that.
It passes the long off to the other dll. That dll casts it back to what is needed (a pointer) and uses it.
If the second dll disposes of the pointer then you are done. If not then you must dispose of the pointer.
If you want to keep it then you should add a 'destroy()' method in java that frees the pointer (native call) appropriately. This is also one of the few time where using finalize is probably appropriate as well. -
Hi,
I have a problem, I need pass a structure to start a process of the workflow throug a url. I tried
http://ebsapdev01:50000/webdynpro/dispatcher/sap.com/cafeugpuiinst/AInstantiation?process.template.id=E6493830EAE911DC82590019B9EEDB34&userName=&ContentType=&IdRole=&Application_Name=1111111111&JobFunctionName.2=111111&Application_Name=22222222JobFunctionName.2=222222222&process.autostart=t&Size=&&I_USER=&NameApp=&Name=&Company_Name=&email_address=&Content=
I repeat the parameters &Application_Name= and &JobFunctionName.2=, but not worked.
Thanks
IvoHi Shyam,
I wrote following udf to create url at runtime,but even though i was able to ping the oanda application but it was not accepting the query which was there in url begining with ?fxmlrequest=..... so it was giving an error in moni as "Please specify the client id" while if i open same url through Internet explorer it was fetching the data and was giving required output.I was passing date as input parameter (a) in my udf.
//write your code here
String s1,s2,url;
MappingTrace trace;
trace = container.getTrace();
s1 = "http://www.oanda.com/cgi-bin/fxml/fxml?fxmlrequest=<convert><client_id>ABC</client_id><expr>USD</expr><exch>GBP</exch><date>";
s2 = "</date></convert>";
url = s1 + a + s2;
trace.addInfo(url);
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey parmValue;
// TargetURL
parmValue = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/HTTP", "TargetURL");
conf.put(parmValue, url);
return ""; -
I want to pass a structure to my VB application. I'm not sure how to define the method signature in the VB app. For now, I have declared it as:
Public Sub setPatientExamData(sPatientData As Object)This turns into a IDispatch ** in the C++ code:
virtual /* [id] */ HRESULT STDMETHODCALLTYPE setPatientExamData(
/* [out][in] */ IDispatch __RPC_FAR *__RPC_FAR *sPatientData) = 0;My structure is defined as:
struct PatientData
BSTR procSchedID;
BSTR patientName;
}In the C++ code:
PatientData m_PatData;
populate the m_PatData
PatientData *x = &m_PatData;
dispatch->setPatientExamData((IDispatch **)&x);This doesn't seem to work on the other side but I'm not sure if it's because this code is incorrect or the VB code is.
What I would really like to do is have the VB signature look like:
Public Sub setPatientExamData(sPatientData As PatientData)and define the PatientData structure on the VB side equivalent to the the structure on the Java side. I can not seem to compile the idl (to generate the .c and h files) for the Java .h file without getting an error.
Perhaps this is even being posted to the wrong forum....> Perhaps this is even being posted to the wrong forum....
Yes, this part of your project is just generic C++-to-VB, or maybe just C++-to-COM, not involving JNI.
If your overall goal is just to call from Java into VB/COM, then there are some 3rd party products available for that. too Search the archive of this forum.
-slj- -
Passing structures bet top level functions and DLL's
I need to access information stored in a structure(manipulated within a DLL)
from
the calling function. I defined the structure in the DLL include file and
#include "dll_include.h"
in the source code. The dll function manulipates the contents of the structure
as desired; however,
I can not get access to that structure from the calling function. If anyone
has any ideas, I would
certainly appreciate the help
PhilHi Phil
I think the key for this problem is simply to export that structure in the
dll that you want to access from the other app.
for example if you write in your dll_include.h file something like this:
typedef struct
ULONG ID;
CHAR Name[32];
} MY_APP_PERSON,*P_MY_APP_PERSON;
typedef void (*SET_PERSON)(void);
then in your dll source write:
#include "dll_include.h"
DLLEXPORT MY_APP_PERSON DllPerson;
DLLEXPORT void SetPerson()
DllPerson.ID = 3;
lstrcpy(DllPerson,"Daniel A.B");
In your other application which uses this dll write:
#include "dll_include.h"
static P_MY_APP_PERSON AppPerson;
static SET_PERSON SetPerson;
void main()
HINSTANCE dllHandle;
dllHandle=LoadLibrary("Persons.dll");
if(dllHandle)
AppPerson=(P_MY_APP_PERSON)GetProcAddress(dllHandle,"DllPerson");
SetPerson=(SET_PERSON)GetProcAddress(dllHandle,"SetPerson");
// Watch here with the debbuger the AppPerson structure state it
will probably containt dirty data
SetPerson();
// Now watch again the value of AppPerson and see it was changed
by calling SetPerson
Phil Spratt wrote in message
news:[email protected]..
>
> I need to access information stored in a structure(manipulated within a
DLL)
> from
> the calling function. I defined the structure in the DLL include file and
> #include "dll_include.h"
> in the source code. The dll function manulipates the contents of the
structure
> as desired; however,
> I can not get access to that structure from the calling function. If
anyone
> has any ideas, I would
> certainly appreciate t
he help
> Phil -
I'm working on an authentication page and I'm setting user
variables inside a structure. When I use a structure to set user
variables and redirect to a landing page, the structure data does
not persist. When I use sessions for each user variable, the
structure persists. I'd prefer to use a structure, but what am I
missing here? How do I get the structure to persist?Put the structure into the session so it persists
<cfscript>
session.piuser = structNew();
session.piuser.authenticated = 1;
session.piuser.username = auth_user.displayname;
</cfscript>
For any variable to exist from one request to another it must
be in one
of the persistent scopes. Whether the variable is simple or
complex,
you must place it into the session, application or server
scope for it
to be available on future requests.
The one issue to this is that the cookie and client scopes do
not allow
complex variables without translation. But that is not often
an issue.
But when it arises, WDDX can be used to good effect. -
How to Pass table-structure-fields data to BRF PLUS Application
Dear Eperts,
i have a question related to BRF Plus management through abap program.
In brf plus application end, Field1,field2,field3 these 3 are importing parameters.
Table1->structure1->field4,field5 this is the table,with in one structure is there and 2 fields.
in my abap program, i am getting values of fields let us take field1,field2,field3,field4,field5.
And my question is
1) How to pass fields to BRF Plus application from abap program.
2)How to pass Table data to BRF Plus application from abap program.
3)How to pass Structure data to BRF Plus application from abap program.
4)How to get the result data from BRF Plus application to my abap program.
And finally , how to run FDT_TEMPLATE_FUNCTION_PROCESS.
How do i get the code automatically when calling the function in brf plus application.
Regards
venkata.Hi Venkat,
As said by Jocelyn Dart, you need to go through BRF+ tutorials.
-->You can see a on of the tutorial from the below link
http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/media/uuid/50879cee-f9b5-2e10-039e-b2d6c4b10e6b -
Dear All,
We have got a problem trying to pass structured XML string to BPEL via JMS. The partner process just computes the result (an XML string) and sends it to a JMS queue. The JMS content contains the XML structure (string) that we want to pass. When we try to assign the JMS content to the BPEL variable it seems to work but, when we try to address an element, the process fails.
In my opinion this behaviour is due to the forced assignment of an XML formatted string to a BPEL XML object. So we tried to find samples on this topic. Any help is welcomed. Thanks and Regards,You can't execute xpath query on a string, i would suggest converting that xml string into dom element and set the variable. there is an easy way to achieve this bpel.
Use the parseEscapedXML('xml-string') xpath function, you can look at [orabpel-home]/samples/references/XPathFunction sample on how its getting used.
In your case,you might need to use getVariableData() to get the xml string content and use this parseEscapedXML() to convert to element. like below:
<copy>
<from expression="ora:parseEscapedXML(string(bpws:getVariableData('your-variable', 'part', '/a/b'))))"/>
<to variable="your-variable" part="part", query="/a/b/c"/>
</copy> -
How to pass table data to brf plus application through abap program
Dear All,
i have a question related to BRF Plus management through abap program.
In brf plus application end, Field1,field2,field3 these 3 are importing parameters.
Table1->structure1->field4,field5 this is the table,with in one structure is there and 2 fields.
in my abap program, i am getting values of fields let us take field1,field2,field3,field4,field5.
And my question is
1) How to pass fields to BRF Plus application from abap program.
2)How to pass Table data to BRF Plus application from abap program.
3)How to pass Structure data to BRF Plus application from abap program.
4)How to get the result data from BRF Plus application to my abap program.
And finally , how to run FDT_TEMPLATE_FUNCTION_PROCESS.
How do i get the code automatically when calling the function in brf plus application.
Regards
venkata.Hi Prabhu,
Since it is a Custom Fm i cant see it in my system.
Look if u want to bring data in internal table then there could be two ways::
1) your FM should contain itab in CHANGING option , so that u can have internal table of same type and pass through FM,
2) read values one by one and append to internal table.
Thanks
Rohit G -
Call Library Function with C structure
I have been given a MS C++ DLL that I need to call from LabVIEW. The input (and output) to the DLL are pointers to "C" data structures.
The LabVIEW "Call Library Function" VI allows you to add input parameters and define their type (I.e. Numeric, Array, String, etc.) However, "C data structure" is not one of the options. Is there a way in LabVIEW to call/use a MS C++ DLL that requires a data structure as an input and returns a data structure as the output?It is possible to pass structures to called DLLs in LabVIEW. Typically the structure will be passed through the means of a cluster. Please see the link below for more information on calling external code in LabVIEW.
Using External Code in LabVIEW
You can also find a great example VI on calling DLLs in the LabVIEW example finder. Search for the keyword DLL and open up Call DLL.vi. This example shows most of the common ways to pass data between LabVIEW and external code.
Regards,
Matt F
Keep up to date on the latest PXI news at twitter.com/pxi
Maybe you are looking for
-
Mid 2011 MacBook air vertical lines on display
While sending à webform today my air display all of à sudden displayed à bunch of vertical lines. I couldnt see anything so i held power button down to restart and it restarted to gray screen no apple logo but 2 vertical lines representing my 2 login
-
Screen Sharing and Authentication
During deployment, I used this command to bind my clients to the directory server: yes | dsconfigldap [-fvxsgemSN] -a myservername -n "myservername" -c $computerid -u diradmin -p mydiradminpass -l localadmin -q localadmin's pass after doing this, I c
-
Hi experts, I am trying to send an excel file as attachment . I have a column called remarks which is way too long. So i need to Wrap the text Can any one help me out in this? CONCATENATE DUMMY BUKRS WERKS it_inv-bstnk_vf IT_INV-ORT01 VEHNO 'SUGAR'
-
Re: HP Probook 4520s with wifi problems !
my name-vedant eknath ekawde buletooth drawars download hp probook 4520s
-
Can anyone out there tell me how to find my serial number on the PS app? Where is it?