How to call this function in onload event

Hi All,
I would like to call this function on page load, how to achieve? Thanks in advance.
var siteUrl = '/sites/MySiteCollection';
function retrieveListItems() {
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('Announcements');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><Where><Geq><FieldRef Name=\'ID\'/>' +
'<Value Type=\'Number\'>1</Value></Geq></Where></Query><RowLimit>10</RowLimit></View>');
this.collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
function onQuerySucceeded(sender, args) {
var listItemInfo = '';
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
listItemInfo += '\nID: ' + oListItem.get_id() +
'\nTitle: ' + oListItem.get_item('Title') +
'\nBody: ' + oListItem.get_item('Body');
alert(listItemInfo.toString());
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

Try modifying as
<script language="javascript" type="text/javascript">
var siteUrl = 'http://mysite/sites/';
$(document).ready(function()
//Call your function here like
ExecuteOrDelayUntilScriptLoaded(retrieveListItems,"SP.js");
function retrieveListItems() {
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('Project_Issues_and_Risks');
var camlQuery = new SP.CamlQuery();
// camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name=\'Project_x0020_Code\'/>' +
// '<Value Type=\'Lookup\'>NGI-P1</Value></Eq></Where></Query><RowLimit>10</RowLimit></View>');
// <Query><Where><And><IsNotNull><FieldRef Name="ID" /></IsNotNull><IsNotNull><FieldRef Name="Title" /></IsNotNull></And></Where></Query>
camlQuery.set_viewXml('<View><Query><Where><And><Eq><FieldRef Name="Project_x0020_Code" /><Value Type="Lookup">NGI-P1</Value></Eq><Eq><FieldRef Name="Project_x0020_Issue_x0020_Status" /><Value Type="Choice">Issue</Value></Eq></And></Where></Query></View>');
this.collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
function onQuerySucceeded(sender, args) {
var listItemInfo = '';
var close = '';
var open = '';
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
listItemInfo += '\nID: ' + oListItem.get_id()+
'\nTitle: ' + oListItem.get_item('Close')+
'\nBody: ' + oListItem.get_item('Open');
close = oListItem.get_item('Close');
open = oListItem.get_item('Open');
alert(close);
alert(listItemInfo.toString());
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
</script>
<input id="Button1" type="button" value="Retrieve Data" OnClick="retrieveListItems()" />
Geetanjali Arora | My blogs |

Similar Messages

  • How to create RFC function module and how to call this function module

    Hi,
    i want to know step for creating RFC function module and then How to  use this function module from some other sap system.
    Thnaks,
    jigar

    Jigar,
    To implement a remote function module in ABAP, perform the following steps:
    Register the module as remotely callable in the RFC server system.
    In the function module Administration screen (transaction code SE37), set the field Can be called via REMOTE CALL. Registering a module as remote causes an RFC stub to be generated for it.
    Write the code for the function module.
    Create the destinations.....................
    Displaying, Maintaining and Testing Destinations
    To display, create or modify destinations, choose Tools ® Administration ® Administration ® Network ® RFC destinations or enter transaction code SM59.
    Remote Destinations are stored in table RFCDES. The RFCDES table describes logical destinations for remote function calls.
    It is not possible to maintain the RFCDES table directly.
    You can also access logical destinations via the Implementation Guide (IMG) by choosing Tools ® AcceleratedSAP ® Customizing ® Execute Project ® SAP Reference IMG.
    In the Implementation Guide, expand the following hierarchy structure:
    Basis
    Application Link Enabling (ALE)
    Sending and Receiving Systems
    Systems in Network
    Define Target Systems for RFC Calls
    Displaying Destinations
    The initial screen for this transaction displays a tree:
    Different connection types (i.e. partner systems or programs) are possible. For further information, see Types of Destinations.
    To display all information for a given destination, double-click it, or place the cursor on it and press F2 .
    To search for a destination, press the Find button and specify your selection. You get a list of all entries matching your selection. Place the cursor on the one you want, and press F2 or simply double-click the destination. All information for the given entry appears.
    Creating Destinations
    On the destinations overview screen (transaction code SM59), the connection types and all existing destinations are displayed in a tree structure.
    All available connection types are explained in Types of Destinations.
    To create a new RFC destination, press the Create button. A new screen is displayed with empty fields for you to fill in.
    If you want to create a new destination
    As you create a remote destination, you can specify a particular application server or a group of servers for a balanced distribution of system load.
    For details of the destination parameters, see Entering Destination Parameters.
    Changing Existing Destinations
    On the destinations overview screen (transaction code SM59), the connection types and all existing destinations are displayed in a tree structure.
    You can display all information for a given destination by double-clicking it or pressing F2 on it.
    To change an existing destination, double-click it, or place the cursor on it and press the Change button.
    For details of the destination parameters, see Entering Destination Parameters.
    Testing Destinations
    To test a destination, choose the appropriate function from the Test menu.
    Connection (also available via the Test connection pushbutton)
    Authorization (checks logon data)
    Local network (provides a list of application servers)
    You can use the CALL FUNCTION statement to call remote functions, just as you would call local function modules. However, you must include an additional DESTINATION clause to define where the function should run:
    CALL FUNCTION RemoteFunction
    DESTINATION Dest
    EXPORTING
    f1 =...
    f2 =...
    IMPORTING
    f3 =...
    TABLES
    t1 =...
    EXCEPTIONS......
    The field Dest can be either a literal or a variable: its value is a logical destination (for example, "hw1071_53") known to the local SAP System. Logical destinations are defined in the RFCDES table (or the TRFCD table in R/2 Systems) via transaction sm59 or the following menu path: Tools ® Administration, Administration ® Network ® RFC destinations. You can also access logical destinations via the Implementation Guide (IMG) by choosing Tools ® Customizing ® Enterprise IMG. In the Implementation Guide, you can then choose Cross-application components ® ALE ® Communication ® Define RFC destination.
    The remote function call concept, for example, allows you to access a function module in an R/2 System from an ABAP program in an R/3 System. If you want to read a customer record from your R/2 System’s database, create a remotely callable function module in the R/2 environment which retrieves customer records. Call this function from your R/3 System using a remote function call and listing the destination for the target R/2 System:
    Pls. reward if useful

  • How to Use this function

    I am not sure how to call this Function correctly and how to pass the IN parameter, I am still new and learning, please help!
    So far I have compiled it, and it compiled fine and saved it in my schema.
    It is supposed to be able to calculate the compression ratio for say TABLE_1234 to see how much space it would save if
    I used the COMPRESS option in 10G.
    CREATE OR REPLACE function Y775.compression_ratio (tabname varchar2)
    return number is
    pragma autonomous_transaction;
    -- sample percentage
    pct number := 0.000099;
    -- original block count (should be less than 10k)
    blkcnt number := 0;
    -- compressed block count
    blkcntc number;
    begin
    execute immediate ' create table TEMP_UNCOMPRESSED pctfree 0
    as select * from ' || tabname ||
    ' where rownum < 1';
    while ((pct < 100) and (blkcnt < 1000)) loop
    execute immediate 'truncate table TEMP_UNCOMPRESSED';
    execute immediate 'insert into TEMP_UNCOMPRESSED select * from ' ||
    tabname || ' sample block (' || pct || ',10)';
    execute immediate 'select
    count(distinct(dbms_rowid.rowid_block_number(rowid)))
    from TEMP_UNCOMPRESSED' into blkcnt;
    pct := pct * 10;
    end loop;
    execute immediate 'create table TEMP_COMPRESSED compress as
    select * from TEMP_UNCOMPRESSED';
    execute immediate 'select
    count(distinct(dbms_rowid.rowid_block_number(rowid)))
    from TEMP_COMPRESSED' into blkcntc;
    execute immediate 'drop table TEMP_COMPRESSED';
    execute immediate 'drop table TEMP_UNCOMPRESSED';
    return (blkcnt/blkcntc);
    end;
    /

    Ok, ok - so I have updated the function and it compiled, fine, but now nothing is returned, I thought that a number was returned ?
    CREATE OR REPLACE function Y775.compression_ratio (tabname varchar2)
    return number
    AUTHID CURRENT_USER
    is
    pragma autonomous_transaction;
    -- sample percentage
    pct number := 0.000099;
    -- original block count (should be less than 10k)
    blkcnt number := 0;
    -- compressed block count
    blkcntc number;
    begin
    execute immediate ' create table TEMP_UNCOMPRESSED pctfree 0
    as select * from ' || tabname ||
    ' where rownum < 1';
    while ((pct < 100) and (blkcnt < 1000)) loop
    execute immediate 'truncate table TEMP_UNCOMPRESSED';
    execute immediate 'insert into TEMP_UNCOMPRESSED select * from ' ||
    tabname || ' sample block (' || pct || ',10)';
    execute immediate 'select
    count(distinct(dbms_rowid.rowid_block_number(rowid)))
    from TEMP_UNCOMPRESSED' into blkcnt;
    pct := pct * 10;
    end loop;
    execute immediate 'create table TEMP_COMPRESSED compress as
    select * from TEMP_UNCOMPRESSED';
    execute immediate 'select
    count(distinct(dbms_rowid.rowid_block_number(rowid)))
    from TEMP_COMPRESSED' into blkcntc;
    execute immediate 'drop table TEMP_COMPRESSED';
    execute immediate 'drop table TEMP_UNCOMPRESSED';
    return (blkcnt/blkcntc);
    end;
    /

  • How to call a function having OBJECT type as Return type

    Hi,
    I've the following function returning OBJECT type.
    Pease advice me how to call this function
    CREATE OR REPLACE TYPE GET_EMP_OBJ is object
       ( emp_name varchar2(50) ,
         mgr_id   number,
         dept_id  number
    CREATE OR REPLACE FUNCTION get_emp(P_emp_no NUMBER )
      RETURN GET_EMP_OBJ  IS
      t_emp_info GET_EMP_OBJ ;
      v_ename  EMP.ename%TYPE;
      v_mgr    EMP.mgr%TYPE ;
      v_deptno EMP.deptno%TYPE;
      v_ename1  EMP.ename%TYPE;
      v_mgr1    EMP.mgr%TYPE ;
      v_deptno1 EMP.deptno%TYPE;
    BEGIN
      FOR rec IN ( SELECT ename , mgr , deptno
                     FROM emp )
      LOOP
         v_ename := rec.ename ;
         v_ename1 := v_ename1||'|'||v_ename ;
         v_mgr   := rec.mgr   ;
         v_mgr1  := v_mgr1||'|'||v_mgr ;
         v_deptno:= rec.deptno;
         v_deptno1 := v_deptno1||'|'||v_deptno ;
      END LOOP ;
      t_emp_info  := GET_EMP_OBJ (v_ename,v_mgr,v_deptno ) ;
      RETURN t_emp_info ;
    EXCEPTION WHEN OTHERS THEN
      DBMS_OUTPUT.put_line ('Error'||SQLCODE||','||SQLERRM ) ;
    END;The above function got created successfully.
    And i'm confused how to call this functions. I tried like below but didn't work
    DECLARE
      t_emp_info_1  GET_EMP_OBJ ;
    BEGIN
       t_emp_info_1 := get_emp(7566) ;
       for i in 1..t_emp_info_1.COUNT
          LOOP
             DBMS_OUTPUT.put_line ('Values are'||i.emp_name ) ;
         END LOOP;
    END;  

    SQL> CREATE OR REPLACE TYPE GET_EMP_OBJ is object
      2     ( emp_name varchar2(50) ,
      3       mgr_id   number,
      4       dept_id  number
      5     );
      6  /
    Type created.
    SQL> ed
    Wrote file afiedt.buf
      1  CREATE OR REPLACE FUNCTION get_emp(empno NUMBER )
      2    RETURN GET_EMP_OBJ  IS
      3    t_emp_info GET_EMP_OBJ ;
      4  BEGIN
      5    begin
      6      select get_emp_obj(ename, mgr, deptno) into t_emp_info
      7      from emp
      8      where empno = get_emp.empno;
      9    exception
    10      when no_data_found then
    11        t_emp_info := new get_emp_obj(null,null,null);
    12    end;
    13    return t_emp_info;
    14* END;
    SQL> /
    Function created.
    SQL> set serverout on
    SQL>
    SQL> declare
      2    t_emp_info  GET_EMP_OBJ ;
      3  BEGIN
      4     t_emp_info := get_emp(7566);
      5     DBMS_OUTPUT.put_line ('Values are: '||t_emp_info.emp_name||', '||t_emp_info.mgr_id||', '||t_emp_info.dept_id);
      6  END;
      7  /
    Values are: JONES, 7839, 20
    PL/SQL procedure successfully completed.
    SQL>

  • How to use this function call function 'REUSE_ALV_COMMENTARY_WRITE' in alv

    hi all
    thanks in advance
    how to use this function in alv programming
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    why use and what purpose use this function plz tell me details
    plz guide me
    thanks

    Hi
    see this exmaple code where i had inserted a LOGO by useing this FM
    *& Report  ZTEST_ALV_LOGO
    REPORT  ztest_alv_logo.
    TYPE-POOLS : slis.
    *ALV Formatting tables /structures
    DATA: gt_fieldcat TYPE slis_t_fieldcat_alv.
    DATA: gt_events   TYPE slis_t_event.
    DATA: gs_layout   TYPE slis_layout_alv.
    DATA: gt_page     TYPE slis_t_listheader.
    DATA: gs_page     TYPE slis_listheader.
    DATA: v_repid     LIKE sy-repid.
    *ALV Formatting work area
    DATA: w_fieldcat TYPE slis_fieldcat_alv.
    DATA: w_events   TYPE slis_alv_event.
    DATA: gt_bsid TYPE TABLE OF bsid WITH HEADER LINE.
    INITIALIZATION.
      PERFORM build_events.
      PERFORM build_page_header.
    START-OF-SELECTION.
    *perform build_comment.     "top_of_page - in initialization at present
      SELECT * FROM bsid INTO TABLE gt_bsid UP TO 10 ROWS.
    *perform populate_for_fm using '1' '3' 'BUKRS' '8' 'GT_BSID' 'Whee'.
    *USING = Row, Column, Field name, display length, table name, heading
    *OR
      PERFORM build_fieldcat.
      gs_layout-zebra = 'X'.
    *top of page event does not work without I_callback_program
      v_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program                = v_repid
          i_structure_name                  = 'BSID'
       i_background_id                   = 'ALV_BACKGROUND'
          i_grid_title                      = 'This is the grid title'
      I_GRID_SETTINGS                   =
          is_layout                         = gs_layout
          it_fieldcat                       = gt_fieldcat[]
          it_events                         = gt_events[]
        TABLES
          t_outtab                          = gt_bsid.
    Form..............:  populate_for_fm
    Description.......:  Populates fields for function module used in ALV
    FORM populate_for_fm USING p_row
                               p_col
                               p_fieldname
                               p_len
                               p_table
                               p_desc.
      w_fieldcat-row_pos      = p_row.          "Row Position
      w_fieldcat-col_pos      = p_col.          "Column Position
      w_fieldcat-fieldname    = p_fieldname.    "Field name
      w_fieldcat-outputlen    = p_len.          "Column Lenth
      w_fieldcat-tabname      = p_table.        "Table name
      w_fieldcat-reptext_ddic = p_desc.         "Field Description
      w_fieldcat-input        = '1'.
      APPEND w_fieldcat TO gt_fieldcat.
      CLEAR w_fieldcat.
    ENDFORM.                    " populate_for_fm
    *&      Form  build_events
    FORM build_events.
      DATA: ls_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = gt_events.
      READ TABLE gt_events
                 WITH KEY name =  slis_ev_user_command
                 INTO ls_event.
      IF sy-subrc = 0.
        MOVE slis_ev_user_command TO ls_event-form.
        APPEND ls_event TO gt_events.
      ENDIF.
      READ TABLE gt_events
                 WITH KEY name =  slis_ev_top_of_page
                 INTO ls_event.
      IF sy-subrc = 0.
        MOVE slis_ev_top_of_page TO ls_event-form.
        APPEND ls_event TO gt_events.
      ENDIF.
    ENDFORM.                    " build_events
    *&      Form  USER_COMMAND
    When user command is called it uses 2 parameters. The itab
    passed to the ALV is in whatever order it currently is on screen.
    Therefore, you can read table itab index rs_selfield-tabindex to get
    all data from the table. You can also check r_ucomm and code
    accordingly.
    FORM user_command USING  r_ucomm     LIKE sy-ucomm
                             rs_selfield TYPE slis_selfield.
      READ TABLE gt_bsid INDEX rs_selfield-tabindex.
    error checking etc.
      SET PARAMETER ID 'KUN' FIELD gt_bsid-kunnr.
      CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
    ENDFORM.                    "user_command
    *&      Form  top_of_page
    Your own company logo can go here if it has been saved (OAOR)
    If the logo is larger than the size of the headings in gt_page,
    the window will not show full logo and will have a scroll bar. Thus,
    it is a good idea to have a standard ALV header if you are going to
    use logos in your top of page.
    FORM top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = gt_page
          i_logo             = 'ENJOYSAP_LOGO'.
    ENDFORM.                    "top_of_page
    *&      Form  build_fieldcat
    *Many and varied fields are available here. Have a look at documentation
    *for FM REUSE_ALV_LIST_DISPLAY and REUSE_ALV_FIELDCATALOG_MERGE
    FORM build_fieldcat.
      w_fieldcat-fieldname  = 'BUDAT'.
      w_fieldcat-seltext_m  = 'Dte pst'.
      w_fieldcat-ddictxt(1) = 'M'.
      w_fieldcat-edit = 'x'.
    Can change the position of fields if you do not want them in order
    of the DDIC or itab
    w_fieldcat-row_pos = '1'.
    w_fieldcat-col_pos = '10'.
      APPEND w_fieldcat TO gt_fieldcat.
      CLEAR w_fieldcat.
    ENDFORM.                    " build_fieldcat
    *&      Form  build_page_header
          gt_page is used in top of page (ALV subroutine - NOT event)
          *H = Header, S = Selection, A = Action
    FORM build_page_header.
    For Headers, Key is not printed and is irrelevant. Will not cause
    a syntax error, but is not used.
      gs_page-typ  = 'H'.
      gs_page-info = 'Header 1'.
      APPEND gs_page TO gt_page.
      gs_page-typ  = 'H'.
      gs_page-info = 'Header 2'.
      APPEND gs_page TO gt_page.
    For Selections, the Key is printed (bold). It can be anything up to 20
    bytes. It gets printed in order of code here, not by key value.
      gs_page-typ  = 'S'.
      gs_page-key  = 'And the winner is:'.
      gs_page-info = 'Selection 1'.
      APPEND gs_page TO gt_page.
      gs_page-typ  = 'S'.
      gs_page-key  = 'Runner up:'.
      gs_page-info = 'Selection 2'.
      APPEND gs_page TO gt_page.
    For Action, Key is also irrelevant.
      gs_page-typ  = 'A'.
      gs_page-info = 'Action goes here'.
      APPEND gs_page TO gt_page.
    ENDFORM.                    " build_page_header

  • How to call a function with event

    How do I call a function with a event inside it?
    function showTopTen(e:Event):void
        highscoreData = new XML(e.target.data);
        trace("Hiscores: " + highscoreData.item[0].name.text() + " - " + highscoreData.item[0].score.text())
    //showTopTen();  ..??

    Could you indicate why you would want to?
    The eventhandler you show here uses the properties of the event object passed as an argument.
    The way I read it it is data retrieved from a server so your app won't know anything about is untill it is loaded from the server which should be done with an URLLoader object which in it's turn calls your eventHandler when the Event.COMPLETE is triggered.
    something like:
    var urlLoader = new URLLoader();
    urlLoader.addEventListener( Event.COMPLETE, showTopTen )
    urlLoader.load( new URLRequest( "http:// etc." ) );
    to me would seem the proper method to have the function execute.

  • How to call a method in onload using jsf

    Hi
    i have task where i neeed to retrive datas from database on page onload . i have written retriving code in backing bean but how to call that
    method on onload in jsf.......
    Can anybody help ???????????
    thanks

    public class firstbean{
         list mylist = new ArrayList();
         firstbean(){
         new firstcontroller().retriveData()
    public class firstcontroller{
         public void retriveData(){
              // I need to get first bean object reference to assign the retived data to my list variable(mylist)
              // but iam getting first bean object object as nulll
              Object object =
                   FacesContext
                   .getCurrentInstance()
                   .getExternalContext()
                   .getSessionMap()
                   .get("FirstBean");
              FirstBean firstBean = (FirstBean)object;
              // firstBean = null its coming
              firstBean.mylist = new FirstDao().getdata();
    this is my code how to implement the onload function in this login . here when i try accesss my first bean reference is showing as null . so aim not able to assign the retrived data in to mylist variable

  • How to call javascript function?

    Hi,
    How to call javascript function for SAP button
    control onclick event?
    Thanks in advance.

    Hi Sundar,
      u can call java script  in design mode.
      Add this code in ur design part inside body and call the function as
    <sap:button id="a" onSelect="javascript:go();"
    Add inside body:
      <script language="javascript>
    function go(){
    alert("hai");
      </script>
    Regards,
    Vinoth.M

  • How to use this function in crm5.2 -   /CEM/ENT_IMPORT_DATAFROMEXCEL

    i am having a problem regarding how to use this function to import values from an excel sheet.
    in call funtion what to specify at place of ct_ent_action = ?
    CALL FUNCTION '/CEM/ENT_IMPORT_DATAFROMEXCEL'
      CHANGING
        CT_ENT_ACTION       =
    EXCEPTIONS
      FILE_ERROR          = 1
      IMPORT_ERROR        = 2
      OTHERS              = 3
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    Hi
    The use of Standard Parner functions are as follows:
    1. Ordering Address (OA): The PO will be sent this vendor and not the main vendor.
    2. Goods Supplier (WL): In case of return deliveries, Goods will be returned to thsi vendor's address
    3. Invoicing party (RS): The payment will be made to this vendor.
    Hope this clarifies.
    Thansk

  • How to call javascript function from PL/SQL procedure

    Can anybody advice me how to call javascript function from PL/SQL procedure in APEX?

    Hi,
    I have a requirement to call Javascript function inside a After Submit Process.
    clear requirement below:
    1. User selects set of check boxes [ say user want to save 10 files and ticks 10 checkboxes]
    2. user clicks on "save files" button
    3. Inside a After submit process, in a loop, i want to call a javascript function for each of the file user want to save with the filename as a parameter.
    Hope this clarify U.
    Krishna.

  • How to call this procedure in my report to print my procedure output

    Hi,
    i have a table named letter,it contains 2 columns named as letter_id and letter_content.
    select * from letter;
    letter_id letter_content
    103 Dear MFR
    103 This is in regards to the attached DM List
    103 Please Credit us after reviewing it.
    103 Thanks
    103 Regards
    103 xxxx
    108 Dear customer
    108 This is to inform that ur DM List is as follows
    108 Credit us according to the Dm after reviewing it.
    108 Thanks
    108 Regards
    108 xxxx
    now my requirement is,i need send a parameter as letter_id to a procedure or function in pl/sql in oracle,the output should be as follows:
    if we will pass parameter(letter_id) = 103 then it displays as follows:
    Dear MFR
    This is in regards to the attached DM List.Please Credit us after reviewing it.
    Thanks
    Regards,
    XXXXX.
    if we will pass parameter(letter_id) = 108 then it should displays as follows:
    Dear customer,
    This is to inform that ur DM List is as follows. Credit us according to the Dm after reviewing it.
    Thanks
    Regards,
    XXXXX.
    the procedure for my requirement is like below.now my problem is how to call this procedure in my report.so that if i will send a parameter as letter_id then it should get my report stated above.
    CREATE OR REPLACE PROCEDURE letter_text ( p_letter_id letter.letter_id%TYPE , p_letter_contents_out OUT SYS_REFCURSOR )
    IS
    BEGIN
    OPEN p_letter_contents_out
    FOR
    SELECT letter_content
    FROM letter
    WHERE letter_id = p_letter_id
    ORDER BY line_seq;
    END letter_text;
    which you might call with something like
    SQL> var results refcursor
    SQL> exec letter_text(103, :results)
    PL/SQL procedure successfully completed.
    SQL> print :results;
    CONTENT
    Dear MFR
    this is in regards to the attached DM List
    Please credit us after reviewing it
    thanks
    Regards
    EXP
    6 rows selected.
    so, the same out put i need to get it in a report.
    Thanks

    Thanks for ur suggestions.
    i have 2 select statements.1st query is the main query for the report.so i used it at the time of report created with datablock.
    now my 2nd query is
    select letter_content
    from ( select content_seq,
         content || case content_seq
    when 2 then
    ' ' || lead(content) over (partition by letter_id order by content_seq)
    end as letter_content
    from exp_letter_contents
         where letter_id = 103)
    where content_seq <> 3;
    i had taken 2parameters 1 for the main query and 2nd is for the above query(parameter is letter_id).
    now i have to write the above select statement in the report.
    so i had taken a field object in the report and then i had written this code in before report trigger.
    function letter_contentFormatTrigger return boolean is
    begin
    select letter_content
    from ( select content_seq,
                        content ||
                        case content_seq when 2 then
                             ' ' || lead(content) over (partition by letter_id order by content_seq)
                        end as letter_content
              from exp_letter_contents
              where letter_id = 103)
    where content_seq <> 3;
    return (letter_content);
    end;
    when i tried to compile it.i got an error as follows :
    error 103 at line6,column 5
    encountered the symbol "CASE" when expecting one of the following:
    (- + mod null <an identifier>
    <a double-quoted delimited-identifier><a bind variable> avg...etc
    so,where can i write this select statement.
    i am using oracle reports6i
    Message was edited by:
    user579585

  • How to call java function in Oracle forms?

    Hi I am having Oracle 9i with 10g Developer Suite.
    I am new to Oracle forms..
    I had one function in java getDatas()..
    How can I call this function in Oracle Forms..
    Pls help
    Thanks

    Thanks Francois,
    I want to display values from my java code in the Forms..
    For that purpose only i am installing 10g Developer Suite..
    The below is java code..
    public class DBTest {
              public static String callDB(int id,String name){
              String ss="Hai";
              Connection con=null;
              try{
                   Class.forName("oracle.jdbc.driver.OracleDriver");
                   con = DriverManager.getConnection("url","id","pwd");
                   Statement st=con.createStatement();
                   System.out.println("Connected...");
              int r=st.executeUpdate("Insert into FORM_TEST VALUES('"+id+"','"+name+"')");
                   if(r==1){
                        ss="Inserted Sucessfully";
                   else{
                        ss="Insertion Failed";
              }catch(final Exception e){
              System.out.println(e);
              return ss;
         public static void main(String[] args) {
              int empid=102;
              String empname="Gilbert";
              String resultStr=callDB(empid,empname);
              System.out.println(resultStr);
    I want to dispaly Inserted or Insertion Failed in Oracle Forms..
    As per Gerd Volberg suggestion, i had placed DBTest.jar in
    E:\DevSuite\forms\java\DBTest.jar
    and in formsweb.cfg the below jar is added..
    archive_jini=frmall_jinit.jar,DBTest.jar
    But in Fomrs Builder-->Program-->Import Java Classes-->Oracle
    org,ice,com and subnodes are available.
    But my jar is not available..
    Is my way is coorect?
    Pls provide soln..
    Thanks

  • How to call oracle function from ejb3

    i'm trying to call an oracle query-function from ejb3.
    The oracle function:
    create or replace FUNCTION getSecThreadCount(secId in NUMBER,avai in NUMBER)
    RETURN SYS_REFCURSOR is cur SYS_REFCURSOR;
    m_sql VARCHAR2(250);
    BEGIN
    m_sql:='select count(thrId) from thread where secId='|| secid||'
    and thrAvai='|| avai;
    open cur for m_sql;
    return cur;
    END;
    I'v tried several ways to call it,but all failed:
    1. the calling code:
    public Object getSectionThreadCount(int secId,int avai){
              Query query=manager.createNativeQuery("{call getSecThreadCount(?,?) }");     
              query.setParameter(1, secId);
              query.setParameter(2, avai);
              return query.getSingleResult();
    but i got the exception:
    Exception in thread "main" javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    Caused by: java.sql.SQLException: ORA-06550: row 1, col 7:
    PLS-00221: 'GETSECTHREADCOUNT' not procedure or not defined
    ORA-06550: row 1, col 7:
    PL/SQL: Statement ignored
    2. the calling code:
    @SqlResultSetMapping(name = "getSecThreadCount_Mapping")
    @NamedNativeQuery(name = "getSecThreadCount",
    query = "{?=call getSecThreadCount(:secId,:avai)}",
    resultSetMapping = "getSecThreadCount_Mapping",
    hints = {@QueryHint(name = "org.hibernate.callable", value = "true"),
              @QueryHint(name = "org.hibernate.readOnly", value = "true")})
    public Object getSectionThreadCount(int secId,int avai){
              Query query=manager.createNamedQuery("getSecThreadCount");     
              query.setParameter("secId", secId);
              query.setParameter("avai", avai);
              return query.getSingleResult();
    but i run into the exception:
    Exception in thread "main" javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    Caused by: java.sql.SQLException: lost in index IN or OUT parameter:: 3
    By the way, i have successfully called the function from hibernate. And i use oracle 11g, JBoss5 RC1.
    Could anyone tell me how to call the function from EJB3?
    Thanks.

    Here's a working model:
    package.procedure: (created in example schema scott)
    CREATE OR REPLACE package  body data_pkg as
      type c_refcursor is ref cursor;
      -- function that return all emps of a certain dept
      function getEmployees ( p_deptId in number
      return c_refcursor
      is
        l_refcursor c_refcursor;
      begin
         open l_refcursor
        for
              select e.empno as emp_id
              ,        e.ename as emp_name
              ,        e.job   as emp_job
              ,        e.hiredate as emp_hiredate
              from   emp e
              where  e.DEPTNO = p_deptId;
        return l_refcursor;
      end getEmployees;
    end data_pkg;
    /entity class:
    package net.app.entity;
    import java.io.Serializable;
    import java.util.Date;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.NamedNativeQuery;
    import javax.persistence.QueryHint;
    import javax.persistence.SequenceGenerator;
    import javax.persistence.Table;
    @SuppressWarnings("serial")
    @Entity
    @Table (name="emp")
    @SequenceGenerator(name = "EmployeeSequence", sequenceName = "emp_seq")
    @NamedNativeQuery( name = "getEmpsByDeptId"
                   , query = "{ ? = call data_pkg.getEmployees(?)}"
                   , resultClass = Employee.class
                   , hints = { @QueryHint(name = "org.hibernate.callable", value = "true")
                          , @QueryHint(name = "org.hibernate.readOnly", value = "true")
    public class Employee implements Serializable
        @Id
        @Column(name="emp_id")
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EmployeeSequence")
        private int id;
        @Column(name="emp_name")
        private String name;
        @Column(name="emp_job")
        private String job;
        @Column(name="emp_hiredate")
        private Date hiredate;
        // constructor
        public Employee (){}
        // getters and setters
        public int getId()
         return id;
    etc...session bean:
    package net.app.entity;
    import java.util.ArrayList;
    import java.util.List;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import javax.persistence.Query;
    import net.app.entity.Employee;
    import net.app.iface.ScottAdmin;
    @Stateless
    public class ScottAdminImpl implements ScottAdmin
        @PersistenceContext
        private EntityManager entityManager;
        @SuppressWarnings("unchecked")
        public List<Employee> getEmployeesByDeptId(int deptId)
         ArrayList<Employee> empList;
         try
             Query query = entityManager.createNamedQuery("getEmpsByDeptId");
             query.setParameter(1, deptId);
             empList = (ArrayList<Employee>) query.getResultList();
             return empList;
         catch (Exception e)
             e.printStackTrace(System.out);
             return null;
    }client:
    package net.app.client;
    import java.util.List;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import net.app.entity.Employee;
    import net.app.iface.ScottAdmin;
    public class ScottClient
        public static void main(String[] args)
         try
             // create local interface
             InitialContext ctx = new InitialContext();
             ScottAdmin adminInterface = (ScottAdmin) ctx.lookup("ScottAdminImpl/remote");
             // select employees by deptno
             int deptno = 20;
             List<Employee> empList = adminInterface.getEmployeesByDeptId(deptno);
             // output
             System.out.println("Listing employees:");
             for (Employee emp : empList)
              System.out.println(emp.getId() + ": " + emp.getName() + ", " + emp.getJob() + ", " + emp.getHiredate());
         catch (NamingException e)
             e.printStackTrace(System.out);
    }Basically you just ignore the refcursor outbound parameter.
    This is a stored function, have yet to try outbound refcursor parameters in stored procedures...
    Edited by: _Locutus on Apr 2, 2009 2:37 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to call a function of BRFplus application to another BRFplus applicatio

    Hello Experts,
    I am new to BRF+ subject.
    I have a doubt on this.
    Doubt:- I have two BRF+ application. for example application1 and application2.
                in application1 i have created a function<zfunc1> and attached one descision table to the function<zfunc1>(every thing is done in  application1).
                i want to call the above function<func1> in application2 .
    could anybody help me on this, how to acheive this functionality.
    thanks
    rakshar

    Hi Rakshar,
    You can define the access level of the function as Global if you would like to access it from a different application .
    By default the access level will be Application.
    Thanks and Regards,
    Rama.

  • How to call a function every 45 minutes?

    Hi..
    How to call a function after 45 minutes evry day..
    That function returns a value.
    Which is best? Thread or using timestamp?
    Regards

    Hello Joe,
    I heard of this website, gurgle something, that actually let's you put in words like "java" and "scheduling" and it will spit out other websites that mention these terms. Fascinating stuff, hopefully I'll find the time to test it someday soon..
    Lucky for you I have an article discussing solutions to your problem in my bookmarks:
    http://www.ibm.com/developerworks/web/library/j-schedule.html
    With kind regards
    Ben

Maybe you are looking for

  • IPod gets stuck when it starts play mostly after deep sleep

    Hi, I have a problem with my 60G Video iPod: Most of the times it gets stuck completely when I start use it after deep sleep (it hasn't been used for night etc.). The problem is very consistent: 1. I turn it on. 2. Start playing some song. 3. See the

  • Can't print more than 1 on both my hp printers

    hi, I have 2 printers, an hp CP2025dn and a Photosmart C7280. Neither of them will print more than one of any document, no matter what I put in the box. It just started happening, I used to be able to print more than one copy. I am running windows 7

  • Migrating from HP to Solaris

    Hi All, Could any of you please point me to some document/whitepaper for migrating an Oracle 9i database currently on a HP server to an Oracle 9i database on Sun? Regards, Sriraman

  • Canvas zoom and Button List

    I wanted to put a Zoom to 100% button in my Canvas Button Bar, but FCP will not let me drag any of the zoom buttons from the Button List into the Canvas Button Bar. I just wanted to confirm that other people are seeing this before I submit a feedback

  • Cannot find CS6 offline help file

    Hi, When I try to opne the Dreamweaver CS6 help file by clicking on help in the help menu or F1 Dreamweaver opens the site http://helpx.adobe.com/de/dreamweaver/topics.html but not the offline help file. I can see that the Adobe help applcation gets