Listener calls Function plus Arguments??
Hi guys,
Not sure if there's an easy way to do this, I'd like a
listener to call a function with arguments when triggered.
Currently, what I have looks like this:
object.addEventListener(errorTrigger, functionToCall);
public function functionToCall():void {
...you get my idea...
And, I'd really like to add some arguments to the function. I
realize that if I use:
object.addEventListener(errorTrigger,
functionToCall(myArgument));
then it will want
functionToCall to
return a
function name to be used. Hopefully, you're still with me on
this...
The reason I want to add the arguments, is because I have
three different listeners.
And I'd rather not have three different functions to deal
with them, I'd rather consolidate it into one function and use the
argument to distinguish the difference.
Rather than:
object.listener(error1, function1);
object.listener(error2, function2);
object.listener(error3, function3);
function1 ():void {}
function1 ():void {}
function1 ():void {}
I'd prefer something like:
object.listener(error1, function(1));
object.listener(error2, function(2));
object.listener(error3, function(3));
function(num):void {}
Hopefully, that all makes sense. Sorry, I'd post the code,
but it's way to long, and I'd rather not confuse anyone with
something else contained within it.
More than happy to try and cut it down if someone needs to
see the code though.
Cheers
Oz
Thanks for your efforts, I don't quite know whether it's what
I'm looking for though.
The events I am using are predefined by Flex's upload
function. So, this may help:
fileUpload.addEventListener(HTTPStatusEvent.HTTP_STATUS,
uploadError);
fileUpload.addEventListener(IOErrorEvent.IO_ERROR,
uploadError);
fileUpload.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
uploadError);
And I'd really like to add the parameters to the end, like
so:
fileUpload.addEventListener(HTTPStatusEvent.HTTP_STATUS,
uploadError(param));
fileUpload.addEventListener(IOErrorEvent.IO_ERROR,
uploadError(param));
fileUpload.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
uploadError(param));
Is this something that I have to cast to / extend apon the
existing events using your technique above? In essence, creating a
duplicate of this event?
Thanks
Oz.
Similar Messages
-
Call function with arguments in AS3
Hello!
I`m a new in Flex developing, and cannot understand same code
convention, im Java programmer.
How I can write correct function call in ActionScript, my
call: var goodsWnd:CreateGoodsWindow =
PopUpManager.createPopUp(this,
CreateGoodsWindow, true) as CreateGoodsWindow;
I wish call function above with argument, how I do that?
Where my class: public class CreateGoodsWindow extends
extends TitleWindow
public CreateGoodsWindow(data:Object)
}Use PopUpManager.addPopUp() instead of createPopUp().
addPopUp takes an object that has already been instantiated:
var createGoodsWindow:CreateGoodsWindow = new
CreateGoodsWindow(data);
PopUpManager.addPopUp(createGoodsWindow); -
(JavaScript, CS3) calling functions with arguments on click?
Hi all,
this is getting tricky:
I want to call a function when the user clicks on a button in my scripted application (a javascript window dialog).
Unfortunately, I need to pass several arguments to the function.
According to the scripting documentation, ".onClick" functions won't take arguments.
I would (somewhat reluctantly) work with (global) variables but the function itself is limited to variables within its own scope - blocking all variables set in main()
How should I approach this?
The basic idea is to have people set some settings in the UI and then do some things after they click ok.
The actual work is pretty complicated (replacing colors etc) and needs to be done to a lot of objects so it would make sense to do it in a function.
I'm pretty confused right now and don't know how to proceed.
Any hints are appreciated.
Many thanks,
MikeIt took some tinkering but I got it to work.
But I still don't see how I can access the whole DOM from within the onClick functions:
I can get to the dialog properties (this.parent.parent) but nevertheless don't have any way to access app.documents and such.
I was able to manage my way around by making the whole window a dialog instead of a window - thereby getting a return value from the OK button and being able to run the code from within main().
Still strange, though...
Cheers,
Mike -
Call function with select arguments
Hi Gurus,
I have problem to call function inside select statements as follow:
select a.ID_ELE2, a.ID_ELE3, a.DT_FIS_YR, c.NU_FIS_PER, c.dt,
(case
when c.ld is null then
GET_LD_CHECK (a.DT_FIS_YR,c.NU_FIS_PER, a.ID_ELE3, a.ID_ELE2) -- 1
-- GET_LD_CHECK ('2009',7, '8010', '7493') --- 2
else
c.ld
end ) description
from ACCOUNT a, TRANSACTION c
where a.DT_FIS_YR ='2009'
and a.ID_ELE3 <> '0000'
and c.TY_SRC not in ('CL', 'CN')
and a.DT_FIS_YR = c.nu_fis_yr
and a.AK = c.AK_FGCHAR
and trim(a.ID_ELE3) ='8010'
and c.NU_FIS_PER <> 14
order by 1,4,5,6
the 1 doesn't output result but the 2 it does! How can pass the select result to the function?
Thanks in advance for your help.
BenThe statement / function call seems to be ok. So there are not much chances left for your call to return different (=non) values.
1) It could be that you have different values in the column then during your test call.
2) Maybe your function raises an error and that error is supressed in some ugly WHEN OTHERS EXCEPTION => Solution: Get rid of the error handler.
3) datatype conversion. For example if a.dt_fis_yr is a number value, then you should test with number values and not with strings. GET_LD_CHECK (2009,7, '8010', '7493'). Same logic goes for the other paramters, make sure the datatype is correct and matches the function parameter. -
How to call function which return and out
My function specifcation is
FUNCTION GetGoogleScholarActivation (
pi_clnt_id IN google_scholar_status.clnt_id%TYPE,
pi_status_type IN ci_status_type_tab_type,
po_status OUT ci_status_tab_type,
po_date OUT ci_date_tab_type
RETURN NUMBER ;
where type is
TYPE ci_status_type_tab_type IS TABLE OF VARCHAR2 (1) INDEX BY BINARY_INTEGER;
TYPE ci_status_tab_type IS TABLE OF VARCHAR2 (10) INDEX BY BINARY_INTEGER;
TYPE ci_date_tab_type IS TABLE OF VARCHAR2 (8) INDEX BY BINARY_INTEGER;
I am trying to call function in SQL PLUS for testing as
declare
var number ( 10);
TYPE p_st1 IS TABLE OF VARCHAR2 (1) INDEX BY BINARY_INTEGER;
p_st p_st1 ;
type p_status1 IS TABLE OF VARCHAR2 (1) INDEX BY BINARY_INTEGER;
p_status p_status1 ;
TYPE p_date1 IS TABLE OF VARCHAR2 (8) INDEX BY BINARY_INTEGER;
p_date p_date1 ;
Begin
p_st(0) := 'A';
var := PQDKGOSH.GetGoogleScholarActivation(11920 , p_st, p_status ,p_date );
dbms_output.put_line ('Activation_status '|| p_status(0) );
dbms_output.put_line ('Activation_date '|| p_date(0) );
dbms_output.put_line ('Retun Value'|| var );
End;
but getting error PLS-00306: wrong number or types of arguments in call to
'GETGOOGLESCHOLARACTIVATION'
so how to test from SQL PlusHI
I tried to execute below like this
declare
var number ( 10);
p_st ci_status_type_tab_type ;
p_status ci_status_tab_type;
p_date ci_date_tab_type;
Begin
p_st(0) := 'A';
var := PQDKGOSH.GetGoogleScholarActivation(11920 , p_st, p_status ,p_date );
dbms_output.put_line ('Activation_status '|| p_status(0) );
dbms_output.put_line ('Activation_date '|| p_date(0) );
dbms_output.put_line ('Retun Value'|| var );
End;
still iget error
PLS-00201: identifier 'CI_STATUS_TYPE_TAB_TYPE' must be declared
becuse this declareation i did in package specification .
and i am trying to execute the function . -
Error while transforming XSLT by calling function with Reflection API
Hi,
I'm new to Reflection API. I want to call function from the jar file which is not in my application context. So I have loaded that jar ( say XXX.jar) file at runtime with URLClassLoader and call the function say [ *myTransform(Document document)* ]. Problem is that when I want to transform any XSLT file in that function it throws exception 'Could not compile stylesheet'. All required classes are in XXX.jar.
If I call 'myTransform' function directly without reflection API then it transformation successfully completed.
Following is code of reflection to invoke function
ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
URLClassLoader loader = new URLClassLoader(jarURLs, contextCL);
Class c = loader.loadClass(fullClasspath);
Constructor constructor = c.getDeclaredConstructor(constructorParamsClasses);
Object instance = constructor.newInstance(constructorParams);
Method method = c.getDeclaredMethod("myTransform", methodParamsClasses);
Object object = method.invoke(instance, methodParams);Following is function to be called with reflection API.
public Document myTransform ( Document document ) {
// Reference of Document (DOM NODE) used to hold the result of transformation.
Document doc = null ;
// DocumentBuilderFactory instance which is used to initialize DocumentBuilder to create newDocumentBuilder.
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance () ;
// Reference of DocumentBuilder used to create new Document (DOM NODE).
DocumentBuilder builder;
try {
// Initialize DocumentBuilder by using DocumentBuilderFactory instance.
builder = factory.newDocumentBuilder ();
// Initialize new document instance by using DocumentBuilder instance.
doc = builder.newDocument () ;
// Creates new DOMSource by using document (DOM NODE) which is coming through current transform() method parameter.
DOMSource domsource = new DOMSource ( document ) ;
// Creates new instance of TransformerFactory.
TransformerFactory transformerfactory = TransformerFactory.newInstance () ;
// Creates new Transformer instance by using TransformerFactory which holds XSLT file.
Transformer transformer = null;
********* exception is thrown from here onward ******************
transformer = transformerfactory.newTransformer (new StreamSource (xsltFile));
// Transform XSLT on document (DOM NODE) and store result in doc (DOM NODE).
transformer.transform ( domsource , new DOMResult ( doc ) ) ;
} catch (ParserConfigurationException ex) {
ex.printStackTrace();
} catch (TransformerConfigurationException ex) {
ex.printStackTrace();
} catch (TransformerException ex) {
ex.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
//holds result of transformation.
return doc ;
}Following is full exception stacktrace
ERROR: 'The first argument to the non-static Java function 'myBeanMethod' is not a valid object reference.'
FATAL ERROR: 'Could not compile stylesheet'
javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:829)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:623)
at com.actl.dxchange.utilities.Transformation.transform(Transformation.java:83)
at com.actl.dxchange.base.BaseConnector.transform(BaseConnector.java:330)
at com.actl.dxchange.connectors.KuoniConnector.doRequestProcess(KuoniConnector.java:388)
at com.actl.dxchange.connectors.KuoniConnector.hotelAvail(KuoniConnector.java:241)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
...........Hi,
Thanks for response.
Following is code for setting 'methodParamsClasses' array object. I do ensure that Document is not null and valid. My application is web application.
Document requestObj = /* my code for generating Document object*/
Object[] methodParams = new Object[]{requestObj}
Class[] methodParamsClasses = new Class[]{};
if (methodParams != null) {
methodParamsClasses = new Class[methodParams.length];
for (int i = 0; i < methodParams.length; i++) {
if (methodParams[i] instanceof Document) {
/************** if parameter is instance of Document then I set class type as "Document.class" ***********/
methodParamsClasses[i] = Document.class;
} else {
methodParamsClasses[i] = methodParams.getClass(); -
Is there a way to find out the caller function in ESTK?
Dear forum,
How do you find out the caller function?
I remember this question was asked on the forum before and, if memory serves me right, it was Peter Kahrel who answered it. Anyway, it was long ago and I can't find the post.
main();
function main() {
hello();
function hello() {
// Is it possible to find out that the caller function is 'main'?
Before making the post, I googled for it and found many suggestions, for example:
alert("caller is " + arguments.callee.caller.toString());
But nothing works for me.
Regards,
KasyanHere's a new version of the function:
function callerName() {
var arr = $.stack.split(/[\n]/),
callerName = arr[arr.length - 3].replace(/\(.*\)/, "")
return callerName;
I corrected the regex to remove the parentheses and everything in between.
The previous version returned the function's name with arguments, like so:
Result: ProcessTables([Paragraph:[object Paragraph]]) -
Use of Call Function Node vi, with char type pointer
I want to be able to use a certain function from C++ DLL, and I followed the TOOLS>>IMPORT>>SHARED LIBRARY(.dll) wizard. Where I located my header file and the dll file.
However i am getting an error (1097). This is the function with the paramaters:
void Function_Name(unsigned char *L, unsigned char *H, unsigned in Len, unsigned char Adr);
I don't think, that I configured my Call Function Node, correctly. How should i set the paramaters settings of the first 2? I have tried Numeric, unsigned (and signed) Int (32, 16), pass pointer value. to accomodate the first two varaibles.
Please someone help, what should I do to accomodate the unsigned char pointers, so that I can used the function in labVIEW?Hi Safe,
The error you're encountering has the following description (I'm sure you've already looked this up-posting here for clarity for other readers):
LabVIEW: An exception occurred within the external code called by a Call Library Function Node. This might have corrupted LabVIEW's memory. Save any work to a new location and restart LabVIEW.
Typically, this happens for one of just a few reasons:
Memory was overwritten (e.g. you passed a buffer of N bytes, but N+X bytes were modified, and an exception was thrown.
A bad pointer was passed. (This is probably not the case.)
Arguments were not passed to the function properly. (Calling conventions)
Function wasn't called from the proper thread.
Some other reason (only can be determined by inspecting in a debugger).
I've attached some pictures of how I'd configure the dialog, but there are two critical things you have to know: calling conventions and thread safety. Those are things defined by the DLL. In Windows, C vs. 'Standard' (a.k.a. Pascal) calling conventions MUST be correct, as they affect how arguments are passed on the stack. If this is wrong, then, for example, where arg1 is expected to be an unsigned char *, you may actually only pass an unsigned char. Dereferencing that number as a pointer will at best crash, at worst appear to be a valid address and silently corrupt memory.
I suggest double-checking the calling conventions. 'stdcall' is still quite common, but not the default setting in the Call Library Function dialog.
Best regards,
intvstefve
intvsteve
LabVIEW R&D
Attachments:
dllconfig11.JPG 40 KB
dllconfig21.JPG 41 KB -
Hotspot-clicking (Insert function) plus ALV Sorting
Hi,
I have a requirement where the ALV display has to be SORTED based on values entered/changed on a certain column. The sort works ok when used with a custom APPEND button for new records (always inserted at the bottom of the list).
However, it does not work correctly when used with the Hotspot-click (INSERT functionality). It looks like if you CLICK on a particular record onscreen, you are actually addressing the original record in that position before the SORT was effected.
Is the Hotspot-clicking (Insert functionality) possible with ALV sorting? The ideal solution would be to have the ALV sorted at PBO and also at PAI so that the user can change existing records and add new ones with the sorting being updated everytime ON_DATA_CHANGED is triggered.
Will appreciate any help on this.
Thanks!
MichaelHello Michael
Thanks for further specifying your requirements. I have created the sample variant ZUS_SDN_ALVGRID_HOTSPOT_SORT_1 which contains two differences as compared to its template:
Replace table VBAK with VBAP (so we have two levels of sorting: VBELN, POSNR)
Move SET_TABLE_FOR_FIRST_DISPLAY method call into PBO
When I click on the hotspot (VBELN) a new row entry for the order number is created. The sorting (VBELN, POSNR) is kept even though the new row has been appended to the itab.
*& Report ZUS_SDN_ALVGRID_HOTSPOT_SORT
*& Thread: Hotspot-clicking (Insert function) plus ALV Sorting
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1159431"></a>
REPORT zus_sdn_alvgrid_hotspot_sort.
TYPES: BEGIN OF ty_s_outtab.
INCLUDE TYPE vbap.
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
WITH DEFAULT KEY.
DATA: gt_outtab TYPE ty_t_outtab.
DATA:
gd_okcode TYPE ui_func,
gd_repid TYPE syrepid,
gt_sort TYPE lvc_t_sort,
gt_fcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo,
gs_variant TYPE disvariant,
go_docking TYPE REF TO cl_gui_docking_container,
go_grid TYPE REF TO cl_gui_alv_grid.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-DATA:
ms_sel_row TYPE lvc_s_row. " selected row
CLASS-METHODS:
handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING
er_data_changed
e_onf4
e_onf4_before
e_onf4_after
sender,
handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING
e_row_id
e_column_id
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_data_changed.
FIELD-SYMBOLS: <lt_outtab> TYPE ty_t_outtab.
BREAK-POINT.
ENDMETHOD. "handle_data_changed
METHOD handle_hotspot_click.
" define local data
DATA: ls_outtab TYPE ty_s_outtab,
ld_msg TYPE bapi_msg.
BREAK-POINT.
CLEAR: lcl_eventhandler=>ms_sel_row.
ms_sel_row = e_row_id.
READ TABLE gt_outtab INTO ls_outtab INDEX e_row_id-index.
CONCATENATE 'Selected Sales Order = ' ls_outtab-vbeln ' / '
ls_outtab-posnr
INTO ld_msg.
message i398(00) with ld_msg.
" Trigger PAI
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'INSERT'
* IMPORTING
* rc =
ENDMETHOD. "handle_hotspot_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
PARAMETERS:
p_vkorg TYPE vkorg DEFAULT '0001' OBLIGATORY.
START-OF-SELECTION.
** SELECT * FROM vbak INTO CORRESPONDING FIELDS OF TABLE gt_outtab
** UP TO 200 ROWS
** WHERE vkorg = p_vkorg.
SELECT * FROM vbap INTO CORRESPONDING FIELDS OF TABLE gt_outtab
UP TO 100 ROWS.
PERFORM init_controls.
* Build fieldcatalog and set hotspot for field KUNNR
PERFORM build_fieldcatalog.
PERFORM set_layout_and_variant.
PERFORM set_sorting.
" Register EDIT event
CALL METHOD go_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter
EXCEPTIONS
error = 1
OTHERS = 2.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
SET HANDLER:
lcl_eventhandler=>handle_data_changed FOR go_grid,
lcl_eventhandler=>handle_hotspot_click FOR go_grid.
* Link the docking container to the target dynpro
gd_repid = syst-repid.
CALL METHOD go_docking->link
EXPORTING
repid = gd_repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* ok-code field = GD_OKCODE
CALL SCREEN '0100'.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* SET TITLEBAR 'xxx'.
* Display data
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
i_bypassing_buffer = abap_true
is_variant = gs_variant
i_save = 'A'
* i_default = 'X'
is_layout = gs_layout
* is_print =
* it_special_groups =
* it_toolbar_excluding =
* it_hyperlink =
* it_alv_graphics =
* it_except_qinfo =
* ir_salv_adapter =
CHANGING
it_outtab = gt_outtab
it_fieldcatalog = gt_fcat
it_sort = gt_sort
* it_filter =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
** CALL METHOD go_grid->refresh_table_display
*** EXPORTING
*** IS_STABLE =
*** I_SOFT_REFRESH =
** EXCEPTIONS
** finished = 1
** OTHERS = 2.
** IF sy-subrc ne 0.
*** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
** ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'EXIT' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN 'INSERT'.
PERFORM insert_row.
WHEN OTHERS.
" Check for changed data at the frontend (= grid control)
CALL METHOD go_grid->check_changed_data( ).
ENDCASE.
CALL METHOD go_grid->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
finished = 1
OTHERS = 2.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form INIT_CONTROLS
* text
* --> p1 text
* <-- p2 text
FORM init_controls .
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
others = 6.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD go_docking->set_extension
EXPORTING
extension = 99999
EXCEPTIONS
cntl_error = 1
OTHERS = 2.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create ALV grid
CREATE OBJECT go_grid
EXPORTING
i_parent = go_docking
EXCEPTIONS
others = 5.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " INIT_CONTROLS
*& Form BUILD_FIELDCATALOG
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog.
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'VBAP' " 'VBAK'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
** LOOP AT gt_fcat INTO ls_fcat.
** CASE ls_fcat-fieldname.
** WHEN 'VBELN' OR
** 'ERDAT' OR
** 'ERZET' OR
** 'ERNAM' OR
** 'AUART' OR
** 'NETWR' OR
** 'WAERK'.
** CONTINUE.
** WHEN OTHERS.
** ls_fcat-no_out = abap_true.
** ENDCASE.
** MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
** ENDLOOP.
* Only non-key fields are editable
** ls_fcat-edit = 'X'.
** MODIFY gt_fcat FROM ls_fcat
** TRANSPORTING edit
** WHERE ( fieldname NE space ).
ls_fcat-hotspot = abap_true.
MODIFY gt_fcat FROM ls_fcat
TRANSPORTING hotspot
WHERE ( fieldname = 'AUART' OR
fieldname = 'VBELN' ).
** DELETE gt_fcat FROM 15 TO 99.
ENDFORM. " BUILD_FIELDCATALOG_KNB1
*& Form SET_LAYOUT_AND_VARIANT
* text
* --> p1 text
* <-- p2 text
FORM set_layout_and_variant .
CLEAR: gs_layout,
gs_variant.
gs_layout-cwidth_opt = abap_true.
gs_variant-report = syst-repid.
gs_variant-handle = 'GRID'.
ENDFORM. " SET_LAYOUT_AND_VARIANT
*& Form SET_SORTING
* text
* --> p1 text
* <-- p2 text
FORM set_sorting .
* define local data
DATA: ls_sort TYPE lvc_s_sort.
REFRESH: gt_sort.
CLEAR: ls_sort.
ls_sort-spos = 1.
ls_sort-fieldname = 'VBELN'.
ls_sort-up = abap_true.
APPEND ls_sort TO gt_sort.
CLEAR: ls_sort.
ls_sort-spos = 1.
ls_sort-fieldname = 'POSNR'.
ls_sort-up = abap_true.
APPEND ls_sort TO gt_sort.
ENDFORM. " SET_SORTING
*& Form INSERT_ROW
* text
* --> p1 text
* <-- p2 text
FORM insert_row .
* define local data
DATA: ls_outtab TYPE ty_s_outtab,
ld_order TYPE vbeln.
READ TABLE gt_outtab INTO ls_outtab
INDEX lcl_eventhandler=>ms_sel_row-index.
ld_order = ls_outtab-vbeln.
" Find last item of sales order
LOOP AT gt_outtab INTO ls_outtab
WHERE ( vbeln = ld_order ).
ENDLOOP.
" Create next item:
add 10 to ls_outtab-posnr.
" NOTE: added at the end of the list
APPEND ls_outtab TO gt_outtab.
" NOTE: insert new row AFTER selected row => works, too
** INSERT ls_outtab INTO gt_outtab
** INDEX lcl_eventhandler=>ms_sel_row-index.
ENDFORM. " INSERT_ROW -
Call function from data base with clob input parameter.
Hello,
In this project I use Jdev 11g.
I call function from database.
create or replace function get_fa_list (
p_fa_id_list in clob
return sys_refcursor
is
vCursor sys_refcursor;
begin
put_msg ('begin');
if p_fa_id_list is null then
put_msg ('CLOB is null!');
else
put_msg ('size CLOB: ' || dbms_lob.getlength (p_fa_id_list));
end if;
put_msg ('Save');
open vCursor for
select rownum as id, s.*
from (
select f.latitude, f.longitude, count (distinct f.res_id) as res_count, count (*) as fa_count, 16711680 as color, res_concat_distinct (f.res_id) as station_list
from mv_frequency_assignment f, table (SplitClob (p_fa_id_list, ',')) l
where f.ext_system = 'BI' and
f.ext_sys_id = l.column_value
group by f.latitude, f.longitude
) s;
put_msg ('Open and End');
return vCursor;
end get_fa_list;
I use TopLink in ejb.
i use follow code for call function and get result.
public List<TmpResPoints> findAllPointsBI(String p_id){
UnitOfWork uow = getSessionFactory().acquireUnitOfWork();
uow.beginEarlyTransaction();
StoredFunctionCall call = new StoredFunctionCall();
call.setProcedureName("get_fa_list");
call.useUnnamedCursorOutputAsResultSet();
ClobDomain c = new ClobDomain(p_id);
//System.out.println(c.toString());
call.addNamedArgumentValue("p_fa_id_list", c);
ReadAllQuery query = new ReadAllQuery();
query.setReferenceClass(TmpResPoints.class);
query.setCall(call);
List<TmpResPoints> result = (List<TmpResPoints>)uow.executeQuery(query);
uow.commit();
uow.release();
return result;
But size parameter "p_fa_id_list" is 0. (geting from temp table in Data base). this code in function >>
if p_fa_id_list is null then
put_msg ('CLOB is null!');
else
put_msg ('size CLOB: ' || dbms_lob.getlength (p_fa_id_list));
end if;)
How I can call this function from dataBase and get result?
thx,
Demka.What is the SQL generated?
The argument should just be the Clob value (a String) not the domain object.
Also try addNamedArgument, and then pass the named argument to the query.
James : http://www.eclipselink.org -
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 argumentsI 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. -
Which is the best way for a called function to identify caller class name.
Which is the best way for a called function to identify the caller class name .
1)Using sun.reflect.Reflection from called function
Class caller = Reflection.getCallerClass(2);
System.out.println("Caller Class Name ::"+caller.getName());2) Analyzing current threads stack trace from called function
StackTraceElement[] stElements=Thread.currentThread().getStackTrace();
System.out.println("Caller Class Name ::"+stElements[3].getClassName());Is there any alternate ways to achieve the same .Which is the best way ?
Called function doesn’t have any arguments, I don’t want t pass any arguments from caller function to called function.
Plz help.
With kind regards
Paul798185 wrote:
Which is the best way for a called function to identify the caller class name .
Is there any alternate ways to achieve the same.SecurityManager
// 0 is the anonymous SecurityManager class
// 1 is this class (also works in static context)
// 2 is calling class
static Class getClass(int i) {
return new SecurityManager() {
protected Class[] getClassContext() {
return super.getClassContext();
}.getClassContext(); -
Explain CALL FUNCTION 'BP_EVENT_RAISE'
Hi,
In transaction CO11n User Exit Name - CONFPP05 the following code is added;
CALL FUNCTION 'BP_EVENT_RAISE'
EXPORTING
eventid = 'ZMATBARPRNCO11'
EXCEPTIONS
bad_eventid = 1
eventid_does_not_exist = 2
eventid_missing = 3
raise_failed = 4
OTHERS = 5.
Could someone explain me the FM 'BP_EVENT_RAISE' and the Event ID 'ZMATBARPRNCO11'. How could I find 'ZMATBARPRNCO11' event.
Thanks,
KishanHi,
FM 'BP_EVENT_RAISE' is used to trigger Background Event.
Trigger an event in the background processing system. This function module is for use in programs written in ABAP/4. Triggering an event tells the background processing system to start any background jobs that were scheduled to wait for the event.
You can trigger an event with or without an event argument, a string that more precisely identifies an event. Jobs can be scheduled to wait for an event for the combination of event and a particular event argument.
EVENTID is just an identifier to locate the event.
You can find this event in transaction SWEL/SWE2 transactions.
Hope it helps.
Regards,
Shashank -
Passing procedures/functions as arguments ?
I doubt this is possible but just to make sure: can a procedure or function be passed as an argument to another (or even the same) procedure or function, like in functional programming ? This would help a lot cleaning up a convoluted if-then-else spaggeti piece of code I'm dealing with.
Thanks,
GeorgeIt depends on what exactly you want to do. You can pass a function as an argument to a procedure, or another function. The called function gets the result of the parameter function as the argument. You cannot pass a procedure as an argument because a procedure cannot be resolved to a scalar value or collection.
SQL> CREATE FUNCTION f (p_str IN VARCHAR2) RETURN VARCHAR2 AS
2 l_ret VARCHAR2(100);
3 BEGIN
4 l_ret := 'Hello '||p_str;
5 RETURN l_ret;
6 END;
7 /
Function created.
SQL> CREATE PROCEDURE p (p_str IN VARCHAR2) AS
2 BEGIN
3 DBMS_OUTPUT.Put_Line(p_str);
4 END;
5 /
Procedure created.
SQL> exec p(f('World!'))
Hello World!
PL/SQL procedure successfully completed.If you want to pass a procedure or function and have the called procedure execute that function then you will need to use dynamic sql.
HTH
John -
How to Disable or Remove the Click and Call Function
The Skype Click and Call function highlights phone and contact numbers on webpages and emails, and a Skype call can be executed by simply clicking the highlighted number. The easiest way to disable this is to remove or uninstall the Click to Call with Skype plugin, via Control Panel's Add/Remove or Uninstall Program function.
Click and Call feature can also be deactivated by disabling or removing the plugin through your browsers' manage add-ons/plugins options (actual procedure varies according the the browser type). Moreover, to re-enable this function, just download and install the Click and Call plugin again; Download Skype’s Click and Call plug-inBISability wrote:
I had to uninstall Skype Click-To-Call because after the last update, all Microsoft products copy/paste was broken, allowing only pasting of Unicode Text. As a programmer, this is serious really bad programmings and aweful beta testing and quality control. How many millions of people are affected by this? Priority one bug fix should be initiated and rolled out asap. the following was posted at skype.com back in April http://blogs.skype.com/garage/2012/04/skype_click_to_call_fix_for_of.html
plus there is now an even later release
http://www.skype.com/intl/en-us/get-skype/on-your-computer/click-to-call/windows/
Maybe you are looking for
-
After installing the latest version of ITunes I get an error message that says this application has failed to start because MSVCR80.dll was not found. how do I get Itunes to start working again?
-
Safari crashes every time I try to open.
I have had some major problems that started this morning. I am a new Mac user and would appreciate any help that can be given. In addition to this problem when I started my computer this morning all of my user preferences were wiped out. Background c
-
Sales Productions error!!
Guys did you know on the App Store, Numbers is in the Top Free categories BUT you still have to pay for it.... Apple are not advertising their products to the true value. They should give it to us for FREE if it in the Top Free categories!!
-
Regisrty keys HKEY_CLASSES_ROOT\Photoshop.Application\CLSID and \CurVer are not updated after upgrading to cc 2014 this cause to "cant create ActiveX object" error in VB Scripts win7 x64, ps cc 2014 x64 any ideas? thnks
-
How do I upgrade to lion?
Currently use snow leopard. Computer won't support mountain lion (has Intel Core duo processor, but needs "core 2" to run mountain lion). Don't want to scrap computer yet and want to upgrade to lion, but can't find anywhere to purchase lion to upgra