Could you check this code ??

Hi Guyz,
  Here is my piece of code.
FORM get_infotype_data TABLES pi_it0001_tbl      TYPE  t_it0001_tbl
                              pi_emp_info_tbl    TYPE  t_emp_info_tbl
                              pi_event_dates_tbl TYPE  t_event_dates_tbl
                              po_emp_tab_tbl     TYPE  t_emp_tab_tbl.
  DATA: l_it0001_tbl   TYPE t_it0001_tbl,
        l_it0001_str   TYPE t_it0001_str,
        l_emp_info_tbl TYPE t_emp_info_tbl,
        l_emp_info_str TYPE t_emp_info_str,
        l_event_dates_str TYPE t_event_dates_str,
        l_emp_tab_tbl  TYPE t_emp_tab_tbl,
        l_emp_tab_str  TYPE t_emp_tab_str.
  SORT: pi_it0001_tbl      BY  pernr,
        pi_emp_info_tbl    BY  pernr,
        pi_event_dates_tbl BY  pernr.
  LOOP AT pi_it0001_tbl INTO l_it0001_str.
    READ TABLE pi_emp_info_tbl
    WITH KEY pernr = l_it0001_str-pernr BINARY SEARCH.
    IF sy-subrc = 0 .
    clear l_emp_info_str.
      MOVE: l_emp_info_str-perid TO l_emp_tab_str-perid,
            l_emp_info_str-gbdat TO l_emp_tab_str-gbdat.
      CASE l_emp_info_str-gesch.
        WHEN '1'.
          MOVE 'M' TO l_emp_tab_str-gesch.
        WHEN '2'.
          MOVE 'F' TO l_emp_tab_str-gesch.
      ENDCASE.
    ENDIF.
    READ TABLE pi_event_dates_tbl WITH KEY pernr = l_it0001_str-pernr
    BINARY SEARCH.
    IF sy-subrc = 0.
      MOVE: l_event_dates_str-betrg TO l_emp_tab_str-betrg.
    ENDIF.
    MOVE l_emp_tab_str TO po_emp_tab_tbl.
  ENDLOOP.
ENDFORM.                                         " get_infotype_data
I am not getting any data in to the table po_emp_tab_tbl.
After rwading the table,  Getting sy-subrc = 0.
Please help me.

1. structure for both l_emp_tab_str and  po_emp_tab_tbl are different.
2. move one by one field to dest. structure.
3. check whether data is populating in the l_emp_tab_str .
4. as well as in int. table pi_it0001_tbl.
5. u defined the stru. for po_emp_tab_tbl as a work area.
wheterh it should be work area or table?
if its table, define table type

Similar Messages

  • Could anyone check this code for errors for me??

    Hi! Could someone please tell me if you see any problems with this code?? a friend wants me to check it for errors, but can't find any. I just wanted to make sure, because there are probably a lot of better scripters than me reading this. Please answer soon!!
    heres the code:
    stop();
    addEventListener(Event.ENTER_FRAME, preLoad);
    function  preLoad(e:Event):void{
    var bytestoLoad):Number = loaderInfo.bytesTotal; 
    var numberLoaded:Number = loaderInfo.bytesLoaded;
    if (bytestoLoad ==  numberLoaded) {
    removeEventListener)Event.ENTER_FRAME, preLoad) 
    gotoAndStop(2);
    }else {
    preLoader.preLoaderFill.scaleX =  numberLoaded/bytestoLoad;
    preLoader.bytePercent.text = Math.floor  (numberLoaded/bytestoLoad*100) + "%";
    Thanks!!
    -Sammy

    I ran it on debug mode and changed it to this? see any problems now? or are they fixed? It looks to me like it took some actions out, I hope that doesn't
    effect it....
    stop();
    addEventListener(Event.ENTER_FRAME, preLoad);
    function preLoad(e:Event):void{
    var bytestoLoad):Number = loaderInfo.bytesTotal;
    var numberLoaded:Number = loaderInfo.bytesLoaded;
    if (bytestoLoad == numberLoaded) {
    removeEventListener)Event.ENTER_FRAME, preLoad)
    gotoAndStop(2);
    i'm kinda new to flash ((I started as a lua scripter (on Roblox)) so I'm a little confused about this. Thanks for the help!!

  • Could error check this code

    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.lang.Math.*;
    import javax.swing.*;
    public class YValue extends JApplet implements ActionListener
        JTextField xminField;
        JTextField xmaxField;
        JTextField iterField;
        JTextArea xyvalArea;
        JLabel xminLabel;
        JLabel xmaxLabel;
        JLabel iterLabel;
        JLabel xyvalLabel;
        JButton calcButton;
        public void init()
            setBounds(500, 500, 500, 500);
            Container pane = getContentPane();
            pane.setLayout(null);
            xminField           = new JTextField();
            xminField.setBounds(70, 10, 60, 25);
            xmaxField           = new JTextField();
            xmaxField.setBounds(70, 40, 60, 25);
            iterField          = new JTextField();
            iterField.setBounds(70, 70, 60, 25);
            xyvalArea          = new JTextArea();
            xyvalArea.setEditable(true);
            xyvalArea.setBounds(10, 130, 200, 200);
            JScrollPane scrollPane = new JScrollPane(xyvalArea);
            scrollPane.setBounds(10, 130, 200, 200);
            pane.add(scrollPane);
            xminLabel           = new JLabel("X - Min:");
            xminLabel.setBounds(10, 10, 60, 25);
            xmaxLabel           = new JLabel("X - Max:");
            xmaxLabel.setBounds(10, 40, 60, 25);
            iterLabel          = new JLabel("Iteration:");
            iterLabel.setBounds(10, 70, 60, 25);
            xyvalLabel          = new JLabel("X, Y - Values:");
            xyvalLabel.setBounds(10, 100, 100, 25);
            calcButton          = new JButton("Calculate:");
            calcButton.addActionListener(this);
            calcButton.setBounds(150, 40, 90, 20);
            pane.add(xminLabel);
            pane.add(xminField);
            pane.add(xmaxLabel);
            pane.add(xmaxField);
            pane.add(iterLabel);
            pane.add(iterField);
            pane.add(xyvalLabel);
            pane.add(xyvalArea);
            pane.add(calcButton);
            setContentPane(pane);
              setVisible( true );
        public void actionPerformed(ActionEvent e)
              xyvalArea.setText("");
              // get values from fields and convert to float
              String xminStr      = xminField.getText();                         // get input as string
              int xmin           = Integer.parseInt(xminStr);               // convert to integer
              float xminFl      = Float.valueOf(xminStr).floatValue();     // convert to float
              String xmaxStr      = xmaxField.getText();                         // get input as string
              int xmax           = Integer.parseInt(xmaxStr);               // convert to integer
              String iterStr      = iterField.getText();                         // get input as string
              int iter           = Integer.parseInt(iterStr);               // convert to integer
              float iterFl      = Float.valueOf(iterStr).floatValue();     // convert to float
              // create variables for purposes of calculating distance between two X values
              int neg      = -1;                                                  // create variable with value minus one
              neg           = (xmin * neg);                                        // multiply minimum X value by -1 to get positive value
              int length      = (neg + xmax);                                        // add minimum and maximum X values to get distance between them
              float xmin2Fl = (xminFl * xminFl);                              // minimum X value squared reamins constant
              // loop which lasts the distance between two X values
              for(int i = 0; i<=length; i = i + iter)
                   float xmin2tmp      = (xminFl * xminFl);                    // current x2
                   float xmin3tmp     = (xmin2Fl - xmin2tmp);                    // minimum x2 minus current x2
                   double y           = Math.sqrt(xmin3tmp);                    // get square root of x2 - x*x
                   String output      = ("(" + xminFl +", "+ y + ")");     // output (x, y)
                   xyvalArea.append(output + "\n");                         // append to textArea with a new line
                   xminFl = (xminFl + iterFl);                               // move X value to next iterval point
    }the scroll bar wont work at all and a white box the size of the text area appears in the top left corner when i run the applet every so often...
    any help would be great.
    cheers

    this is whats happening..
    i copied .java file to new location, compiled and ran, still screws up every few times i run it.
    what is:
    http://img191.imageshack.us/img191/2439/whatis7sb.jpg
    what should:
    http://img191.imageshack.us/img191/5854/whatshud7md.jpg

  • Could you check our source? (To determine the PR type and number range)

    Hello.
    We use SRM Server5.5 with Classic Scenario.
    We will use the BADI BBP_SC_TRANSFER_BE to determine the PR type and number range according to your recommend.
    We have two PR type in R/3.
    1) KGPR
    2) KTR1
    As you know that shopping cart has no type. So we add customer field to mapping to R/3 PR type and this field has two values.
    1)     PR01: mapping to KGPR
    2)     PR02: mapping to KTR1
    We will use the method GROUP_RQ to determine the PR type.
    If customer field is PR01, PR type is determined KGPR
    If customer field is PR002, PR type is determined KTR1.
    To determine the PR number range, we will use the method GET_NUMBER_OR_RANGE.
    If PR type is KGPR, Choose the No key 12
    If PR type is KTR1, Choose the No key 16.
    Configuration step:
    1.     Maintain the PR number range in SRM.
    No key: 12  (for KGPR) internal NR
    No range: 2520000000 – 2529000000
    No key: 16 (for KTR1) internal NR
    No range: 2560000000 – 2569000000
    2.     Maintain the PR number range in R/3
    No key: 12  (for KGPR) Ext NR
    No range: 2520000000 – 2529000000
    No key: 16 (for KTR1) Ext NR
    No range: 2560000000 – 2569000000
    3.     Assign the PR number range to PR type in R/3
    KGPR – 12 (EXT)
    KTR1 – 16 (EXT)
    4.     Maintain the attribute in SRM
    Document type in R/3
          Add KGPR and KTR1
    We developed this logic, but it’s not working.
    LOOP AT ct_proc_item INTO ls_proc_item “ Where is no date in ct_proc_item:
    We can not find out the reason.
    Could you check our source?
    METHOD if_ex_bbp_sc_transfer_be~group_rq.
      DATA:
           ls_proc_item           TYPE bbps_procurement,
           lv_number_int          TYPE bbp_item_no,
           ls_item                TYPE bbp_pds_transfer_item,
           lv_group_counter       TYPE numc5,
      CONSTANTS:
          lc_on(1)               VALUE 'X'.
      SORT ct_proc_item BY obj_to_gen.
      CLEAR: lv_group_counter.
    LOOP AT ct_proc_item INTO ls_proc_item  
    where obj_to_gen eq iv_object_to_generate.
    get item data which includes customer fields
        MOVE ls_proc_item-preq_item TO lv_number_int. " convert
        READ TABLE it_item INTO ls_item WITH KEY number_int = lv_number_int.
        IF sy-subrc = 0.
          IF ls_item-pr_type EQ 'PR01'.
            ls_proc_item-doc_type = 'KGRP'.
          ELSEIF ls_item-pr_type EQ 'PR02'.
            ls_proc_item-doc_type = 'KTR1'.
          ENDIF. " lv_cust_field
          lv_group_counter = lv_group_counter + 1.   " increase counter
          ls_proc_item-group_1 = lv_group_counter.
          MODIFY ct_proc_item FROM ls_proc_item
                 TRANSPORTING group_1.
        ENDIF.  " sy-subrc
      ENDLOOP.
      cv_method_active = lc_on.
    ENDMETHOD.
    method IF_EX_BBP_SC_TRANSFER_BE~GET_NUMBER_OR_RANGE.
      if is_item-pr_type = 'PR01'.
         CV_NUMBER_RANGE = '12'.
         CV_NUMBER = '2520000000'.
      elseif is_item-pr_type = 'PR02'.
         CV_NUMBER_RANGE = '16'.
         CV_NUMBER = '2560000000'.
      endif. " is_proc_item / is_item
    Thank you
    Best Regard
    SH

    Hi
    Please find some suitable sample code, which might help you out.
    method IF_EX_BBP_SC_TRANSFER_BE~GET_NUMBER_OR_RANGE .
    * IV_OBJECT_TO_GENERATE
    *   '1' Reservation
    *   '2' Purchase Requsition (BANF)
    *   '3' Purchase Order
    *   '4' Customer Object
    * 1. current item data are in structures
    *    - IS_ITEM shopping cart item data including Customer Fields
    *    - IS_PROC backend relevant item purchasing data
    * 2. accounting data in tables
    *    - IT_ACCOUNT all shopping cart account. data with Customer Fields
    *    - IT_PROC_ACCOUNT backend relevant accounting data for current item
    *  - key criteria between this tables are
    *    - it_proc_account-preq_item
    *                     -serial_no (numc 2)
    *    - guid from is_item
    *    - it_account-p_guid
    *                -accno(numc 4)
    * A) example to use current item data + item customer fields
    *  if is_proc_item-DOC_TYPE = 'ABCD' AND
    *     is_item-<field of CI_BBP_ITEM> = .
    * set own number range
    *  CV_NUMBER_RANGE = .
    ** set own number
    ** .. ==> if initial SAP Standard with no.range will be processed
    *  CV_NUMBER = .
    *  endif. " is_proc_item / is_item
    * B) example to use only proc_account no accounting customer fields
    *data:
    *     ls_proc_account   type bbp_bapipogna.
    *  loop at it_proc_account
    *            into ls_proc_account.
    *    if ls_proc_account-BUS_AREA = '9988'.
    ** set own number range
    *  CV_NUMBER_RANGE = .
    ** set own number
    ** .. ==> if initial SAP Standard with no.range will be processed
    *  CV_NUMBER = .
    *     endif. " ls_proc_account
    *  endloop.
    * C) example to use only accounting customer fields, no other accounting
    *data:
    *     ls_account        type bbp_pds_acc.
    *  loop at it_account
    *            into ls_account
    *            where p_guid = is_item-guid.
    *    if ls_account-<field of CI_BBP_ACC> = .
    ** set own number range
    *  CV_NUMBER_RANGE = .
    ** set own number
    ** .. ==> if initial SAP Standard with no.range will be processed
    *  CV_NUMBER = .
    *   endif. " ls_account
    *  endloop.
    * D) example to use proc_account + customer fields for accounting
    *data:
    *     lv_serial_no      type bbp_bapipogna-serial_no,  " sequence num 2
    *     lv_acc_no         type bbp_pds_acc-acc_no,       " sequence num 4
    *     ls_proc_account   type bbp_bapipogna,
    *     ls_account        type bbp_pds_acc.
    *  loop at it_proc_account
    *            into ls_proc_account.
    *    move ls_proc_account-serial_no to lv_acc_no.
    *    read table it_account
    *         into ls_account
    *         with key p_guid = is_item-guid
    *                  acc_no = lv_acc_no.
    *    if sy-subrc = 0.
    **     if ls_account-<field of CI_BBP_ACC> = .
    ** set own number range
    **  CV_NUMBER_RANGE = .
    ** set own number
    ** .. ==> if initial SAP Standard with no.range will be processed
    **  CV_NUMBER = .
    **      endif. " ls_account
    *    endif. " sy-subrc
    *  endloop.
    endmethod.
    method IF_EX_BBP_SC_TRANSFER_BE~GROUP_RQ .
    * 1. current item data are in structures
    *    - IT_ITEM all shopping cart item data including Customer Fields
    *    - IT_PROC_ITEM backend relevant item data of current log.system
    *    key criteria between this tables are:
    *    - IT_ITEM-NUMBER_INT (numc 10)
    *    - IT_PROC_ITEM       (numc  5)
    * 2. accounting data in tables
    *    - IT_ACCOUNT all shopping cart account. data incl. Customer Fields
    *    - IT_PROC_ACCOUNT backend relevant accounting data for current item
    *  - key criteria between this tables are
    *    - it_proc_account-preq_item (numc 5)
    *                     -serial_no (numc 2)
    *    - is_item-guid
    *             -number_int (numc 10)
    *    - it_account-p_guid
    *                -accno(numc 4)
    constants:
          lc_on(1)               VALUE 'X'.
    * A) example to use only proc_item with NO customer fields
    *         group requisitions by backend document type
    *data: lv_doc_type            TYPE esart,
    *      ls_proc_item           type BBPS_PROCUREMENT,
    *      lv_group_counter       type numc5.
    *    clear lv_group_counter.
    *    clear lv_doc_type.
    *    SORT ct_proc_item BY obj_to_gen doc_type.
    *    LOOP AT ct_proc_item
    *            into ls_proc_item
    *            WHERE obj_to_gen EQ iv_object_to_generate.
    ** new group criteria?
    *      if lv_doc_type ne ls_proc_item-doc_type.     " backend doc.type
    *        lv_group_counter = lv_group_counter + 1.   " increase counter
    *        lv_doc_type      = ls_proc_item-doc_type.       " save criteria
    *      endif.
    *      ls_proc_item-group_1 = lv_group_counter.
    *      modify ct_proc_item from ls_proc_item
    *             transporting group_1.
    *    ENDLOOP.
    * B) example to use item customer fields
    * data:
    *      ls_proc_item           type BBPS_PROCUREMENT,
    *      lv_cust_field          type <field of ci_bbp_item>.
    *      lv_number_int          type BBP_ITEM_NO,
    *      ls_item                type BBP_PDS_TRANSFER_ITEM.
    *    clear lv_group_counter.
    *    clear lv_cust_field .
    *    SORT ct_proc_item BY obj_to_gen.
    *    LOOP AT ct_proc_item
    *            into ls_proc_item
    *            WHERE obj_to_gen EQ iv_object_to_generate.
    ** get item data which includes customer fields
    *      move ls_proc_item-preq_item to lv_number_int. " convert
    *      read table it_item
    *           into ls_item
    *           with key number_int = lv_number_int.
    *      if sy-subrc = 0.
    **       new group criteria?
    *        if lv_cust_field ne 'XYZ'.
    *         lv_group_counter = lv_group_counter + 1.   " increase counter
    *         lv_cust_field = ls_item-<field of ci_bbp_item>."save criteria
    *        endif. " lv_cust_field
    *        ls_proc_item-group_1 = lv_group_counter.
    *        modify ct_proc_item from ls_proc_item
    *               transporting group_1.
    *      endif.  " sy-subrc
    *    ENDLOOP.
    * C) example to use accounting data with customer fields
    *            group requisitions by backend document type
    *data: lv_doc_type            TYPE esart,
    *      ls_proc_item           type BBPS_PROCUREMENT,
    *      lt_account             type BBPT_PD_ACC,
    *      ls_account             type bbp_pds_acc,
    *      ls_item                type BBP_PDS_TRANSFER_ITEM,
    *      lv_number_int          type BBP_ITEM_NO,
    *      lv_account_flag        type c,
    *      lv_group_counter       type numc5.
    *    clear lv_group_counter.
    *    clear lv_doc_type.
    *    SORT ct_proc_item BY obj_to_gen doc_type.
    *    lt_account[] = it_account[].
    *    SORT lt_account BY p_guid acc_no.
    *    LOOP AT ct_proc_item
    *            into ls_proc_item
    *            WHERE obj_to_gen EQ iv_object_to_generate.
    ** get accounting customer fields for this item
    *    clear lv_account_flag.
    ** ..first get item guid
    *    move ls_proc_item-preq_item to lv_number_int.
    *    read table it_item
    *         into ls_item
    *         with key number_int = lv_number_int.
    *    if sy-subrc = 0.
    *      loop at lt_account
    *           into ls_account
    *           where p_guid = ls_item-guid.
    *        if ls_account-<field of CI_BBP_ACC> = .
    *           lv_account_flag = lc_on.
    *        endif.
    *      endloop.
    *    endif. " sy-subrc it_item
    ** new group criteria?
    *      if lv_doc_type ne ls_proc_item-doc_type OR     " backend doc.type
    *         lv_account_flag = lc_on.                    " accounting
    *        lv_group_counter = lv_group_counter + 1.   " increase counter
    *        lv_doc_type      = ls_proc_item-doc_type.       " save criteria
    *      endif.
    *      ls_proc_item-group_1 = lv_group_counter.
    *      modify ct_proc_item from ls_proc_item
    *             transporting group_1.
    *    ENDLOOP.
    * !!!! set flag that BADI was processed
    * .. ==> no SAP Standard grouping will be processed
        cv_method_active = lc_on.
    endmethod.
    Hope this will help.
    Please reward suitable points, incase it suits your requirements.
    Regards
    - Atul

  • May you check this simple select case...

    Guys, please, can you check this stupid code? I'm totally shattered and maybe I don't see the simple thing...
    with cte as (
    SELECT CORE FROM IMPORTOIL group by core)
    ,cte2 as
    (select core , mps, technology
    from cte xx right join GeneratorTypo gt on xx.core=gt.mps)
    select core, mps, technology , case core when null then 'Import ' else technology end from cte2
    even if I got several core NULL it retrieve for the select case only the technology and never the 'Import'. Pratically, if ( I miss 2012 wit the simple iif) the core is null write the same value that there is in technology otherwise write 'Import'...what's
    wrong with that?

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Nothing here is correct! 
    Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. You also need to learn the syntax for a CASE expression: 
    CASE WHEN core IS NULL THEN 'IMPORT ' ELSE technology END
    The CASE expression is an *expression* and not a control statement; that is, it returns a value of one data type. SQL-92 stole the idea and the syntax from the ADA programming language. Here is the BNF for a <case specification>:
     <case specification> ::= <simple case> | <searched case>
     <simple case> ::=
        CASE <case operand>
          <simple when clause>...
          [<else clause>]
        END
     <searched case> ::=
        CASE
          <searched when clause>...
          [<else clause>]
        END
     <simple when clause> ::= WHEN <when operand> THEN <result>
     <searched when clause> ::= WHEN <search condition> THEN <result>
     <else clause> ::= ELSE <result>
     <case operand> ::= <value expression>
     <when operand> ::= <value expression>
     <result> ::= <result expression> | NULL
     <result expression> ::= <value expression>
    The searched CASE expression is probably the most used version of the expression. The WHEN ... THEN ... clauses are executed in left to right order. The first WHEN clause that tests TRUE returns the value given in its THEN clause. And, yes, you can nest CASE
    expressions inside each other. If no explicit ELSE clause is given for the CASE expression, then the database will insert a default ELSE NULL clause. If you want to return a NULL in a THEN clause, then you must use a CAST (NULL AS <data type>) expression.
    I recommend always giving the ELSE clause, so that you can change it later when you find something explicit to return. 
    The <simple case expression> is defined as a searched CASE expression in which all the WHEN clauses are made into equality comparisons against the <case operand>. For example
      CASE iso_sex_code
      WHEN 0 THEN 'Unknown'
      WHEN 1 THEN 'Male'
      WHEN 2 THEN 'Female'
      WHEN 9 THEN 'N/A'
      ELSE NULL END
    could also be written as:
      CASE 
      WHEN iso_sex_code = 0 THEN 'Unknown'
      WHEN iso_sex_code = 1 THEN 'Male'
      WHEN iso_sex_code = 2 THEN 'Female'
      WHEN iso_sex_code = 9 THEN 'N/A'
      ELSE NULL END
    There is a gimmick in this definition, however. The expression
     CASE foo
     WHEN 1 THEN 'bar'
     WHEN NULL THEN 'no bar'
     END
    becomes 
     CASE WHEN foo = 1 THEN 'bar'
          WHEN foo = NULL THEN 'no_bar'  -- error!
          ELSE NULL END 
    The second WHEN clause is always UNKNOWN. 
    The SQL-92 Standard defines other functions in terms of the CASE expression, which makes the language a bit more compact and easier to implement. For example, the COALESCE () function can be defined for one or two expressions by
    1) COALESCE (<value exp #1>) is equivalent to (<value exp #1>) 
    2) COALESCE (<value exp #1>, <value exp #2>) is equivalent to 
       CASE WHEN <value exp #1> IS NOT NULL 
            THEN <value exp #1> 
            ELSE <value exp #2> END
    then we can recursively define it for (n) expressions, where (n >= 3), in the list by 
    COALESCE (<value exp #1>, <value exp #2>, . . ., n), as equivalent to:
       CASE WHEN <value exp #1> IS NOT NULL 
            THEN <value exp #1> 
            ELSE COALESCE (<value exp #2>, . . ., n) 
       END
    Likewise, NULLIF (<value exp #1>, <value exp #2>) is equivalent to:
       CASE WHEN <value exp #1> = <value exp #2> 
            THEN NULL 
            ELSE <value exp #1> END
    It is important to be sure that you have a THEN or ELSE clause with a data type that the compiler can find to determine the highest data type for the expression. 
    A trick in the WHERE clause is use it for a complex predicate with material implications. 
    WHERE CASE 
          WHEN <search condition #1> 
          THEN 1  
          WHEN <search condition #2> 
          THEN 1  
          ELSE 0 END  = 1
    Gert-Jan Strik posted some exampels of how ISNULL() and COALESCE() on 2004 Aug 19
    CREATE TABLE #t(a CHAR(1));
    INSERT INTO #t VALUES (NULL);
    SELECT ISNULL(a,'abc') FROM #t; 
    SELECT COALESCE(a, 'abc') FROM #t; 
    DROP TABLE #t;
    He always use COALESCE, with the exception of the following type of 
    situation, because of its performance consequences: 
    SELECT ..., 
      ISNULL((SELECT COUNT(*)  -- or other aggregate 
               FROM B 
              WHERE B.key = A.key), 0) 
    FROM A;
    Likewise, Alejandro Mesa came up with this example:
    SELECT 13 / COALESCE(CAST(NULL AS INTEGER), 2.00); -- promote to highest type (decimal)
    SELECT 13 / ISNULL(CAST(NULL AS INTEGER), 2.00); -- promote to first type (integer)
    >> if (I miss 2012 with the simple iif) the core is null write the same value that there is in technology otherwise write 'Import'... what's wrong with that? <<
    Why do you want to write non_ANSI/ISO dialect? Do you like your spreadsheets that much? :(
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Could you please check this code

    Hi There,
    The scenario here is :
    I have written this piece of code but its not showing desired result .I think the problem is in the AVGRANGE.
    Please look into this and let me know if I am doing anything wrong.
    I need to accomplish this task ,if employee E1 & E2 are in Entity1 in Grade S in forecast1 and now in forecast 2 a new employee namely E3 has come in this new forecast and whether he belongs to same entity can be identified by a new account say "F",If "F" is present for that Employee in that particular entity means he belongs to that Entity .Then I need to calculate.
    "P" value for E3 for a month=Avg of "P" value for E1 & E2 in Entity1 in Grade S for that month.
    I think this code is calculating for invalid combination also.
    FIX (&CurrFctScenario,&CurrFctVersion,&CurrYear)
    FIX (&SeedCurrency)
    FIX(@descendatns("Entity"),@descendatns(GRADE),@Descendants(Employee)
    FIX (&CurrMonth:"MAY"
    , &SeedHSP
    "P"(
    IF ( "F"!=#Missing AND "P"==#Missing)
    @AVGRANGE(SKIPNONE,"P",@children(Employee)->@currmbr(Grade)->@currmbr(entity));
    ENDIF;
    ENDFIX
    ENDFIX
    One more thing as I am testing this code for say two three employees then its working fine but as I am uisng @children(Employee) then I am getting error message
    Error: 1012704 Dynamic Calc processor cannot lock more than [200] ESM blocks during the calculation, please increase CalcLockBlock setting and then retry(a small data cache setting could also cause this problem, please check the data cache size setting).
    Is there any other way of doing this calculation?
    Edited by: user10760185 on Jun 1, 2011 5:35 AM

    Thanks a lot Alp...
    Please find the logic of the calculation below:
    In forecast1,here E1=employee,S1=Grade,P1=Account member
    E1->S1->Entity1->P1= 100
    E2->S1->Entity1->P1=200
    In forecast2,E3,a new employee has come and if he/she belongs to S1 and Entity1 ,then the value should be
    If (E3->F!->@currmbr(grade)->@currmbr(entity)=#Missing AND P1==#Missing)
    E3->S1->Entity1->P1= (100+200)/2
    I will read the document and will check my cache settings.
    Edited by: user10760185 on Jun 1, 2011 11:36 PM

  • Could you provide example code for interactive form

    Dear all.
    I have got document at link below
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c2567f2b-0b01-0010-b7b5-977cbf80665d
    In that document it has some part of abap code.
    Could you have full example code for interactive form online and offline?
    Thank you very much.

    Hi,
    Go to the following link to know more about adobe interactive form.
    http://wwwimages.adobe.com/www.adobe.com/enterprise/partners/pdfs/bwp_interactive_forms_adobe.pdf
    The following link contains a offline application in ABAP. You can try it.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c2567f2b-0b01-0010-b7b5-977cbf80665d
    For further questions, check the follow
    https://www.sdn.sap.com/irj/sdn/adobe
    Improving the Performance of Adobe® LiveCycleu2122 Designer Forms(scripting)
    http://www.adobe.com/devnet/livecycle/articles/lc_designer_perf_guidelines.pdf
    Interactive Forms Based on Adobe Software: Overview
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e635e290-0201-0010-a9be-9e8e4ce04770
    Adobe Interactive Forms
    http://www.saplounge.be/Files/media/pdf/Huberland-Interactive-Forms-2007.10.10.pdf
    Taking interactive forms to next level
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8c103c36-0301-0010-cda8-f6b381bedb6e
    Introduction to Adobe PDF Library SDK(PDFL SDK)(Simply scroll the document)
    http://partners.adobe.com/public/developer/en/webseminars/PDFL_WebSeminar.pdf
    Creating Interactive forms in webdynpro for java
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5f27e290-0201-0010-ff82-c21557572da1
    PDF-Based Print Forms/SAP Interactive Forms by Adobe
    http://help.sap.com/saphelp_nw04s/helpdata/en/c8/4adf7ba13c4ac1b4600d4df15f8b84/frameset.htm
    Date Objects in Adobe Designer
    http://help.sap.com/saphelp_nw04/helpdata/en/dd/60694fddb74ad88cdb7d2a094f3dd2/frameset.htm
    Checking and Testing a PDF-Based Print Form
    http://help.sap.com/saphelp_nw04s/helpdata/en/c2/1fe9aa4d7b413e8515f90b73729e97/frameset.htm
    Architecture
    http://help.sap.com/saphelp_nw04/helpdata/en/f2/21021b911f4c0cae11459a4ce0bc62/frameset.htm
    http://www.nl4b.com/Adobe/Invitation_SAPBrussels_Q407.pdf
    Hope this helps!!
    Regards,
    Arafat

  • URGENT Check this code for me please

    Dear whoeverthisreads, please read and see at the bottom my sourcecode, or whatever I could make of it until (even with help) I failed to see any solution. Please copy, paste and run to see if you can manage to adjust the program to make it work in the way as described. And I think I made it unnecessarily complicated. Whatever you can do for me, I will be very, very grateful.
    Prem Pradeep, email: [email protected]
    (A beginning dutch Java student who is running out of time and hope)
    Catalogue Manager
    Specification:
    a) Develop an object to represent to encapsulate an item in a catalogue. Each CatalogueItem has three pieces of information: an alphanumeric catalogue code, a name, and a price (in dollars and cents), that excludes sales tax. The object should also be able to report the price, inclusive of a 15% sales tax, and the taxed component of the price.
    b) Work out a way to be able to support the inc tax/ex tax price accessors, and the tax component accessor, without needing to store any additional information in the object.
    c) Use an array of 5 CatalogueItem items to store data. (You may assume that no imported goods will be recorded.)
    d) Write a driver program that prompts for three sets of user input (catalogue number, description and price), to be stored in the atalogueItem instance.
    e) The data are to be read for each item in a single line. The data lines will be in the format:
    CatNo:Description:Price
    Use a StringTokenizer object to separate these data lines into their components.
    f) Review the class definition of CatalogueItem, and use modifiers where appropriate to:
    � Ensure that data is properly protected;
    � Ensure that the accessors and mutators are most visible;
    � The accessors and mutators for the catalogue number and description cannot be overridden.
    � The constant for the tax rate is publicly accessible, and does not need an instance of the class
    present in order to be accessible.
    As well as a summary, the program should also calculate and display:
    � All of the cheapest and most expensive item(s) in the catalogue. In the case of more than one
    item being the cheapest (or most expensive), they should all be listed.
    � A total of the pre-tax worth of the goods in the catalogue.
    � The average amount of tax on the items in the catalogue.
    A sample execution of the program may be as follows (output should be tabulated):
    Enter five items of data:
    AA123: Telephone: 52.00
    ZJ282: Pine Table: 98.00
    BA023: Headphones: 23.00
    ZZ338: Wristwatch: 295.00
    JW289: Tape Recorder: 23.00
    LISTING OF ALL GOODS
    Cat      Description      ExTax           Tax           IncTax ~
    ZJ282      pine Table           98.00           14.70           112.70
    AA123 Telephone           52.00           7.80           59.80
    BA023 Headphones      23.00           3.45           26.45
    ZZ338      Wristwatch      295.00      44.25      339.25
    JW289 Tape Recorder      23.00           3.45           26.45
    CHEAPEST GOODS IN CATALOGUE
    Cat      Description      ExTax           Tax           IncTax
    BA023 Headphones           23.00           3.45           26.45
    JW289 Tape Recorder      23.00           3.45           26.45
    MOST EXPENSIVE GOODS IN CATALOGUE
    Cat      Description      ExTax           Tax           IncTax
    ZZ338      Wristwatch      295.00      44.25      339.25
    TOTAL PRE-TAX WORTH OF CATALOGUE ITEMS:      491.00
    AVERAGE AMOUNT OF TAX PAYABLE PER ITEM:      14.73
    The next code is what I could make of it�until I got terribly stuck...
    //CatalogueItem.java
    import java.io.*;
    import java.text.DecimalFormat;
    import java.util.StringTokenizer;
    public class CatalogueItem {
    private static final double TAXABLE_PERCENTAGE = 0.15;
    private String catalogNumber;
    private String description;
    private double price;
    /** Creates a new instance of CatalogueItem */
    public CatalogueItem() {
    catalogNumber = null;
    description = null;
    price = 0;
    public CatalogueItem(String pCatalogNumber, String pDescription, double pPrice) {
    catalogNumber = pCatalogNumber;
    description = pDescription;
    price = pPrice;
    void setCatalogNumber(String pCatalogNumber) {
    catalogNumber = pCatalogNumber;
    String getCatalogNumber() {
    String str = catalogNumber;
    return str;
    void setDescription(String pDescription) {
    description = pDescription;
    String getDescription() {
    String str = description;
    return str;
    void setPrice(String pPrice) {
    price = Double.parseDouble(pPrice);
    double getPrice() {
    double rprice = price;
    return formatDouble(rprice);
    double getTaxAmount(){
    double rTaxAmount = price * TAXABLE_PERCENTAGE;
    return formatDouble(rTaxAmount);
    double getIncTaxAmount() {
    double rTaxAmount = price * (1 + TAXABLE_PERCENTAGE);
    return formatDouble(rTaxAmount);
    double formatDouble(double value) {
    DecimalFormat myFormatter = new DecimalFormat("###.##");
    String str1 = myFormatter.format(value);
    // System.out.println("String is " + str1);
    // System.out.println("The format value : " + value);
    return Double.parseDouble(str1);
    public static void main(String[] args) throws IOException {
    final int MAX_INPUT_SET = 5;
    final String strQ = "Enter five items of data:";
    CatalogueItem[] catalogList = new CatalogueItem[MAX_INPUT_SET];
    String strInput;
    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    String header = "Cat\tDescription\tExTax\tTax\tInc Tax";
    String lines = "---\t-----------\t------\t---\t-------";
    // Input of five items with three data each, delimiter ":"
    for (int i = 0; i < MAX_INPUT_SET; i++) {
    catalogList[i] = new CatalogueItem();
    System.out.print(strQ);
    strInput = stdin.readLine();
    StringTokenizer tokenizer = new StringTokenizer(strInput, ":" );
    String inCatNo = tokenizer.nextToken();
    String inDescr = tokenizer.nextToken();
    String inPrice = tokenizer.nextToken();
    catalogList.setCatalogNumnber(inCatNo);
    catalogList[i].setDescription(inDescr);
    catalogList[i].setPrice(inPrice);
    // Listing of all goods
    System.out.println("LISTING OF ALL GOODS");
    System.out.println(header);
    System.out.println(lines);
    for (int i = 0; i < MAX_INPUT_SET; i++) {
    System.out.println(
    catalogList[i].getCatalogNumber() + "\t" +
    catalogList[i].getDescription() + "\t" +
    catalogList[i].getPrice() + "\t" +
    catalogList[i].getTaxAmount() + "\t" +
    catalogList[i].getIncTaxAmount());
    // This should pick the cheapest and most expensive goods in catalogue, but
    // this code is not good:
    // In the case of more than one item being the cheapest (or most expensive),
    // they should all be listed.
    double cheapest = cataloguelist[1].getPrice();
    double mostExpensive = cataloguelist[1].getPrice();
              for(int i=2; i< MAX_INPUT_SET; i++){
                   if (cataloguelist[i].getPrice < cheapest)
              cheapest = i;}
              for(int i=2; i< MAX_INPUT_SET; i++){
                   if (cataloguelist[i].getPrice > mostExpensivet)
              mostExpensive = i;}
    // Lists cheapest goods (not complete enough)
    i = cheapest;
    System.out.println("CHEAPEST GOODS IN CATALOGUE");
    System.out.println(header);
    System.out.println(lines);
    System.out.println(
    catalogList[i].getCatalogNumber() + "\t" +
    catalogList[i].getDescription() + "\t" +
    catalogList[i].getPrice() + "\t" +
    catalogList[i].getTaxAmount() + "\t" +
    catalogList[i].getIncTaxAmount());
    // Lists most expensive goods (not complete enough)
    i = mostExpensive;
    System.out.println("MOST EXPENSIVE GOODS IN CATALOGUE");
    System.out.println(header);
    System.out.println(lines);
    System.out.println(
    catalogList[i].getCatalogNumber() + "\t" +
    catalogList[i].getDescription() + "\t" +
    catalogList[i].getPrice() + "\t" +
    catalogList[i].getTaxAmount() + "\t" +
    catalogList[i].getIncTaxAmount());}}
    // Generates and shows total pre-tax worth of catalogue items (how??)
    // generates and shows amount of tax payable per item (how??)

    How is this:
    import java.io.*;
    import java.text.*;
    import java.util.*;
    public class Cat
         Vector items = new Vector();
    public Cat()
    public void read(String fname)
         FileReader     fr;
        BufferedReader br;
         String         str ="";
        try
             fr = new FileReader(fname);
            br = new BufferedReader(fr);
            while ((str = br.readLine()) != null && items.size() < 30)
                   if (!str.trim().equals(""))
                        StringTokenizer tokenizer = new StringTokenizer(str, ":");
                     String n = tokenizer.nextToken().trim();
                        String d = tokenizer.nextToken().trim();
                        String s = tokenizer.nextToken().trim();
                        double p = Double.parseDouble(s);
                        items.add(new Item(n,d,p));
            fr.close();
        catch (FileNotFoundException e)
            System.out.println("Input file cannot be located, please make sure the file exists!");
            System.exit(0);
        catch (IOException e)
            System.out.println(e.getMessage());
            System.out.println("Application cannot read the data from the file!");
            System.exit(0);
    public void displayAll()
         for (int j=0; j < items.size(); j++)
              Item item = (Item)items.get(j);
              System.out.println(item.toString());
    public void sort()
         Collections.sort(items);     
    public class Item implements Comparable
         String       number, description;
         double       price,pricep;
         final double TAXRATE = 0.15;
    public Item(String number, String description, double price)
         this.number      = number;
         this.description = description;
         this.price       = price;
         this.pricep      = price * TAXRATE;
    public int compareTo(Object o1)
         String o = ((Item)o1).number;
         return(number.compareTo(o));
    public String toString()
         DecimalFormat df = new DecimalFormat("#.00");     
         String        p1 = df.format(TAXRATE*price);
         String        p2 = df.format(TAXRATE*price+price);
         String s = number+"\t "+description+"\t"+price+"\t"+p1+"\t"+p2+"\t" ;
         return(s);
    public static void main (String[] args)
         Cat catalog = new Cat();
         catalog.read("C31.dat");
         String reply = "";
         BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
         while (!reply.equals("e"))
              System.out.println("");
            System.out.println("CATALOGUE MANAGER: MAIN MENU");
            System.out.println("============================");
            System.out.println("a) display all goods        b) display cheapest/dearest goods");
            System.out.println("c) sort the goods list      d) search the good list");
            System.out.println("e) quit");
            System.out.print("Option:");
              try
                   reply = stdin.readLine();
              catch (IOException e)
                System.out.println("ERROR:" + e.getMessage());
                System.out.println("Application exits now");
                System.exit(0);
              if (reply.equals("a")) catalog.displayAll();
              if (reply.equals("c")) catalog.sort();
    Noah

  • How could I fix this code

    Hii 2 all
    How could I change this statement for parameters list,, so the client_name can contain spaces ??
    add_parameter(p_id,'p_client_name',TEXT_PARAMETER, '''' || :cntrl.client_name || '''');
    cause it couldn't print and give syntax error when the :cntrl.client_name contains any spaces !!!!
    please help
    thanks:)

    First I must apologize, I asked you to test something that was not needed... for a moment I thought we were talking about web.show_document, that's why I asked you to test with double-quotes..
    Regarding your problem, Manu is right, there is not need to wrap around the parameter in quotes..
    add_parameter(p_id,'p_client_name',TEXT_PARAMETER, :cntrl.client_name);I have to ask you the same question that Manu asked you before, where are you using this parameter?
    In your Report you must be using in a piece of PL/SQL code, we need you to post that code...
    Edited by: Rodolfo Ferrari on Sep 10, 2009 4:44 PM

  • Can someone check this code?

    What I am trying to achieve is an "active" button state. I
    have six buttons. When one is clicked, i need it to change to a
    color which denotes that it is the active button.
    someone provided me with this code, but I can't seem to get
    it to work. I followed the directions precisely.
    The directions were as follows:
    One thing I think you could do is create another invisible
    layer of buttons above all your other buttons. You could make them
    all invisible, unless a button is clicked.
    Let's say your original layer of buttons is called a_but,
    b_but, and c_but.
    Then you could have another invisible layer of buttons called
    invA_but, invB_but, and invC_but. This layer of buttons would each
    be the color you want displayed while the button is selected. The
    code would look something like-
    invA_but._visible=false;
    invB_but._visible=false;
    invC_but._visible=false;
    a_but.onRelease=function(){
    invA_but._visible=true;
    invB_but._visible=false;
    invB_but._visible=false;
    b_but.onRelease=function(){
    invA_but._visible=false;
    invB_but._visible=true;
    invC_but._visible=false;
    c_but.onRelease=function(){
    invA_but._visible=false;
    invB_but._visible=false;
    invC_but._visible=true

    invA_but, invB_but, and invC_but refer to instance names for
    your buttons, not layer names as suggested in the description. It
    should work if you have the instance names for the buttons right. I
    would probably add code to make the nomal state invisible instead
    of just having the active button covering the inactive one. EX:
    a_but.onRelease=function(){
    invA_but._visible=true; //show the buttons active state
    a_but._visible = false; //hide the off state of the button
    invB_but._visible=false; //hides the active state of button b
    invC_but._visible=false; //hides the active state of button c

  • I hear static, do you?  Could you check please?

    I have an 80 gig classic and have been wrestling with sound quality issues.
    I ripped some music using LAME at 320 kBit/s using EAC and it plays fine on my old Rio Carbon. But at precisely the same spot in the track every time, when a loud chorus starts to sing, my iPod will have some static mixed in with the voices. I've re-ripped the track using various encodings, iTunes, iTunes lossless etc, and the results are always the same at the same spot. I've tried different ear buds, including my Shure E3c's, still iPod static. The static always follows the iPod, the Carbon always sounds fine.
    This isn't the only track either. It's actually quite common and usually occurs during louder notes or voices. Even from pristine scratchless freshly ripped CDs.
    Is this common? The track in my example is from The Lord of the Rings, the Two Towers, Foundations of Stone, at precisely 2:30 to 2:35 into the track, just as the chorus starts to singe. If someone who has an iPod and this track, could you listen and check, I would greatly appreciate it. I hope it's just my iPod, because then I can exchange it as defective.
    Thanks, thanks, thanks!

    To exemplify what I mean, I've create a 5 second MP3 cut of the area with static. I then used my PC to record that clip being played by my iPod and by my old player.
    I've uploaded these clips to me website.
    The 5 second source MP3 clip is here: http://www.lunarorbit.net/CausesStaticOniPodsOnly.mp3
    When played on a computer, there is no static.
    My old MP3 player's recording is here: http://www.lunarorbit.net/NoniPodNoStatic.wav
    Sounds the same, doesn't it?
    And my poor iPod's recording with static is here: http://www.lunarorbit.net/iPodStatic.wav
    Listen carefully with headphone. Do you hear it?
    Is it just my iPod?

  • Can you optimize this code with bit shifting?

    Hi there,
    I was wondering if anyone could make this code run faster, by implementing bitshifting techniques. I'd really appreciate it, and thanks!
        public void scaleImage(Image source, Image dest) { 
            int sourceWidth = source.getWidth();
            int sourceHeight = source.getHeight();
            int thumbWidth = dest.getWidth();
            int thumbHeight = dest.getHeight();
            Graphics g = dest.getGraphics();
            int dx, dy = 0;
            for (int y = 0; y < thumbHeight; y++) {
                for (int x = 0; x < thumbWidth; x++) {
                    g.setClip(x, y, 1, 1);
                    dx = x * sourceWidth / thumbWidth;
                    dy = y * sourceHeight / thumbHeight;
                    g.drawImage(source, x - dx, y - dy, Graphics.LEFT | Graphics.TOP);
        }Message was edited by:
    conlanrios

    your method reminds me this stuff:
    http://www.java-tips.org/java-me-tips/midp/displaying-images-as-thumbnails-on-j2me-devices.html
    you can have a look to this article:
    http://developers.sun.com/techtopics/mobility/reference/techart/design_guidelines/image_resizing.html

  • Would you explain this code

    I do not understand the following code. Especially, why this code use v_status_date(unassigned variable value)?
    First, IF V_TSS.STATUS_DATE > V_STATUS_DATE OR V_STATUS_DATE IS NULL THEN
    Second, ELSIF V_TSS.STATUS_DATE = V_STATUS_DATE THEN
    How come compare v_status_date with v_tss.status_date?
    I couldn't find any assigned value for v_status_date in this code.
    ----------original code----------
    FUNCTION GET_TS_STATUS(P_ETS_ID NUMBER)
              RETURN VARCHAR2 IS
              CURSOR C_TSS IS
                   SELECT TSS.STATUS_CODE, TSS.STATUS_DATE
                   FROM STATUS TSS, SHEETS ETS
                   WHERE ETS.ID = P_ETS_ID
                   AND ETS.ID = TSS.ID;
              V_STATUS_CODE VARCHAR2(10) := NULL;
              V_STATUS_DATE DATE;
         BEGIN
              FOR V_TSS IN C_TSS LOOP
              IF V_TSS.STATUS_DATE > V_STATUS_DATE OR V_STATUS_DATE IS NULL THEN
                   V_STATUS_CODE := V_TSS.STATUS_CODE;
                   V_STATUS_DATE := V_TSS.STATUS_DATE;
              ELSIF V_TSS.STATUS_DATE = V_STATUS_DATE THEN
                   IF V_TSS.STATUS_CODE = 'APPROVED' THEN
                        V_STATUS_CODE := 'APPROVED';
                   ELSIF V_TSS.STATUS_CODE = 'VERIFIED' AND V_STATUS_CODE <> 'APPROVED' THEN
                        V_STATUS_CODE := 'VERIFIED';
                   ELSIF V_TSS.STATUS_CODE = 'SUBMIT' AND V_STATUS_CODE NOT IN ('APPROVED', 'VERIFIED') THEN
                        V_STATUS_CODE := 'SUBMIT';
                   ELSIF V_TSS.STATUS_CODE = 'WORKING' AND V_STATUS_CODE NOT IN ('SUBMIT', 'APPROVED', 'VERIFIED') THEN
                        V_STATUS_CODE := 'WORKING';
                   END IF;
              END IF;
              END LOOP;
              RETURN NVL(V_STATUS_CODE, 'NONEXIST');
         END;

    The function returns the status for a given id with the highest priority for the maximum date
    As far as I can see, you could simplify this code to something like this
    FUNCTION GET_TS_STATUS(P_ETS_ID in SHEETS.ID%type) RETURN STATUS.STATUS_CODE%type
    IS
      CURSOR C_TSS IS
        SELECT TSS.STATUS_CODE,
               TSS.STATUS_DATE
        FROM   STATUS TSS,
               SHEETS ETS
        WHERE  ETS.ID = P_ETS_ID
        AND    ETS.ID = TSS.ID
        ORDER BY TSS.STATUS_DATE desc,
                 decode( TSS.STATUS_CODE, 'APPROVED', 4
                                          'VERIFIED', 3
                                          'SUBMIT'  , 2
                                          'WORKING' , 1
                                                    , 0) asc
      V_STATUS_CODE STATUS.STATUS_CODE%type;
    BEGIN
      OPEN  c_tss;
      FETCH c_tss_ INTO v_status_code;
      CLOSE c_tss;
      RETURN NVL(V_STATUS_CODE, 'NONEXIST');
    END GET_TS_STATUS;

  • Check this code

    PLEASE compile this code on your pc and add some new items then try to update it using update button and we will see my problem clearly which
    is:
    I have a main window ,by clicking on (add new item) , another window
    open to fill the form
    on clicking on (save to file),my form will be saved in text file.
    if I open this text file using notepad for example,then I found my data
    stored but concatenated ,although I add to the saved string "\n"
    [hint:you will find two ## to direct u to this line in my code text]
    if I change it to "\n\n" then my data is stored in separate lines which
    I need.
    the Problem that when I read the saved file by clicking on "update data
    item" ,the returned
    data in the form is not as saved
    my code::
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    public class dataDictionary extends JFrame implements ActionListener
    JButton addItem,updateItem,searchItem,exit;
    JFileChooser filechooser;
    JTextField text1 ;
    JTextField text2 ;
    JTextField text3 ;
    JTextArea area4 ;
    JButton saveFile;
    public dataDictionary()
    super("Main Window");
    setSize(400,200);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    addItem = new JButton("add new item");
    updateItem = new JButton("update data item");
    searchItem = new JButton("search for item");
    exit = new JButton ("Exit Program");
    addItem.addActionListener(this);
    updateItem.addActionListener(this);
    searchItem.addActionListener(this);
    exit.addActionListener(this);
    JLabel label = new JLabel("Data Dictionary Program");
    JPanel pane = new JPanel();
    pane.setLayout(new GridLayout(5,1,10,10));
    pane.add(label);
    pane.add(addItem);
    pane.add(updateItem);
    pane.add(searchItem);
    pane.add(exit);
    setContentPane(pane);
    setVisible(true);
    public dataDictionary (String name)
    super(name);
    setSize(350,500);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    text1 = new JTextField (30);
    text2 = new JTextField (30);
    text3 = new JTextField (30);
    area4 = new JTextArea (10,30);
    saveFile = new JButton("save to file");
    JLabel label1 = new JLabel ("Name");
    JLabel label2 = new JLabel ("Type");
    JLabel label3 = new JLabel ("Date");
    JLabel label4 = new JLabel ("Description");
    saveFile.addActionListener(this);
    JPanel pane =new JPanel();
    pane.add(label1);
    pane.add(text1);
    pane.add(label2);
    pane.add(text2);
    pane.add(label3);
    pane.add(text3);
    pane.add(label4);
    pane.add(area4);
    pane.add(saveFile);
    setContentPane(pane);
    area4.setLineWrap(true);
    area4.setWrapStyleWord(true);
    setVisible(true);
    public static void main (String[] args)
    dataDictionary main = new dataDictionary();
    public void actionPerformed (ActionEvent ave )
    Object ob = ave.getSource();
    if(ob == addItem )
    dataDictionary f= new dataDictionary( "form");
    if(ob==saveFile )
    String a = text1.getText()+"\n"+text2.getText()+"\n"+text3.getText() +"\n"+area4.getText();
    String f =text1.getText();
    saveInFile(a,f);
    JOptionPane.showMessageDialog(null,"The New Data Item save correctly");
    if(ob == updateItem)
    dataDictionary form= new dataDictionary ("form");
    File file = getAFileToOpen();
    writeFileToEditor(file);
    if(ob == searchItem)
    if(ob == exit)
    System.exit(0);
    public File getAFileToOpen()
    File file = null;
    File currentdirectory = new File(".");
    JFileChooser filechooser = new JFileChooser(currentdirectory);
    int replycode = filechooser.showOpenDialog(null);
    if (replycode == JFileChooser.APPROVE_OPTION){
    file = filechooser.getSelectedFile();
    return file;
    public void writeFileToEditor(File file)
    try{
    FileReader filereader = new FileReader(file);
    BufferedReader bufferedreader = new BufferedReader(filereader);
    String lineread = "";
    text1.setText(bufferedreader.readLine());
    text2.setText(bufferedreader.readLine());
    text3.setText(bufferedreader.readLine());
    while ((lineread = bufferedreader.readLine()) != null){
    area4.setText(lineread + "\n");
    filereader.close();
    }catch (IOException ioe){
    System.err.println("IOException: " + ioe.getMessage());
    public void saveInFile(String s,String fileName)
    try{
    File f=new File(fileName+".txt");;
    FileWriter fw = new FileWriter(f);
    StringReader sr = new StringReader(s);
    BufferedReader br = new BufferedReader(sr);
    String lineread = "";
    while((lineread=br.readLine()) != null )
    fw.write(lineread+"\n\r");
    fw.flush();
    fw.close();
    catch(IOException io){
    System.err.println();
    }

    This can't be called a good design but works fine and sound.
    Study this code and compare it against your original code.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    public class BlackHorse extends JFrame implements ActionListener{
      JButton addItem,updateItem,searchItem,exit;
      JFileChooser filechooser;
      JTextField text1 ;
      JTextField text2 ;
      JTextField text3 ;
      JTextArea area4 ;
      JButton saveFile;
      BlackHorse form;
      public BlackHorse(){
        super("Main Window");
        setSize(400,200);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        addItem = new JButton("add new item");
        updateItem = new JButton("update data item");
        searchItem = new JButton("search for item");
        exit = new JButton ("Exit Program");
        addItem.addActionListener(this);
        updateItem.addActionListener(this);
        searchItem.addActionListener(this);
        exit.addActionListener(this);
        JLabel label = new JLabel("Data Dictionary Program");
        JPanel pane = new JPanel();
        pane.setLayout(new GridLayout(5,1,10,10));
        pane.add(label);
        pane.add(addItem);
        pane.add(updateItem);
        pane.add(searchItem);
        pane.add(exit);
        setContentPane(pane);
        setVisible(true);
        form = new BlackHorse("form");
      public BlackHorse (String name){
        super(name);
        setSize(350,500);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        text1 = new JTextField (30);
        text2 = new JTextField (30);
        text3 = new JTextField (30);
        area4 = new JTextArea (10,30);
        saveFile = new JButton("save to file");
        JLabel label1 = new JLabel ("Name");
        JLabel label2 = new JLabel ("Type");
        JLabel label3 = new JLabel ("Date");
        JLabel label4 = new JLabel ("Description");
        saveFile.addActionListener(this);
        JPanel pane = new JPanel();
        pane.add(label1);
        pane.add(text1);
        pane.add(label2);
        pane.add(text2);
        pane.add(label3);
        pane.add(text3);
        pane.add(label4);
        pane.add(area4);
        pane.add(saveFile);
        setContentPane(pane);
        area4.setLineWrap(true);
        area4.setWrapStyleWord(true);
        setVisible(false);
      public static void main (String[] args){
        BlackHorse main = new BlackHorse();
      public void actionPerformed (ActionEvent ave ){
        Object ob = ave.getSource();
        if (ob == addItem ){
          form.setVisible(true);
          form.text1.setText("");
          form.text2.setText("");
          form.text3.setText("");
          form.area4.setText("");
        else if (ob == saveFile){
          String a = text1.getText() + "\n"
                     + text2.getText() +"\n"
                     + text3.getText() +"\n"
                     + area4.getText() + "\n"; // just in case ....
          String f = text1.getText();
          saveInFile(a,f);
          JOptionPane.showMessageDialog(null,"The New Data Item save correctly");
        else if(ob == updateItem){
          form.setVisible(true);
          File file = getAFileToOpen();
          writeFileToEditor(file);
        else if(ob == searchItem){
        else if(ob == exit){
          System.exit(0);
      public File getAFileToOpen(){
        File file = null;
        JFileChooser filechooser = new JFileChooser(".");
        int replycode = filechooser.showOpenDialog(null);
        if (replycode == JFileChooser.APPROVE_OPTION){
          file = filechooser.getSelectedFile();
        return file;
      public void writeFileToEditor(File file){
        try{
          BufferedReader br = new BufferedReader(new FileReader(file));
          String lineread = "";
          form.text1.setText(br.readLine());
          form.text2.setText(br.readLine());
          form.text3.setText(br.readLine());
          form.area4.setText("");
          while ((lineread = br.readLine()) != null){
            form.area4.append(lineread + "\n");
          br.close();
        catch (IOException ioe){
          System.err.println("IOException: " + ioe.getMessage());
      public void saveInFile(String s, String fileName){
        try{
          File f = new File(fileName+".txt");
          PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(f)));
          StringReader sr = new StringReader(s);
          BufferedReader br = new BufferedReader(sr);
          String lineread = "";
          while ((lineread = br.readLine()) != null){
            pw.println(lineread);
          pw.close();
        catch(IOException io){
          System.err.println();
    }

  • Check this code once, Is therea any remedy to this Script?

    1 declare
    2 i number(2):=1;
    3 id number(2);
    4 name varchar2(25);
    5 begin
    6 loop
    7 id:=&id;
    8 name:='&name';
    9 insert into emp_ramu values(id,name);
    10 i:=i+1;
    11 exit when i>=5;
    12 end loop;
    13* end;
    SQL> /
    Enter value for id: 10
    old 7: id:=&id;
    new 7: id:=10;
    Enter value for name: 20
    old 8: name:='&name';
    new 8: name:='20';
    PL/SQL procedure successfully completed.
    SQL> select * from emp_ramu;
    ID NAME
    10 20
    10 20
    10 20
    10 20
    This code asking me to supply the values for id and name only once, when i gave the values for id and name it is inserting 4 times (same values) into the table....Is there any way, so that this loop executes 4 times and asks us values four times?

    Same problem as on thread How can We avoid Default Prompting for scanning Values into variables?
    You're missing a fundamental fact that SQL*Plus and PL/SQL code does not mix.
    A PL/SQL block is send to the Oracle server process servicing you. It is parsed and executed there.
    Now this block contains SQL*Plus substitution variables - those one with the & sign. Before SQL*Plus transmits the block, it sees that there are these variables. It prompts you for the values. Then it substitutes the variables with the values - and submits this changed block of PL/SQL code to the server to execute.
    At the PL/SQL engine side - it cannot deal with any non-PL/SQL code. It does not know SQL*Plus commands. Just as it does not know C/C++ or Delphi or Powerbuilder or whatever client command or language set being used.
    Nor can that server process, potentially running on a server platform a 1000km away, on some weird operating system, hack across the network, into your PC and magically prompt you to enter some values for the next loop iteration.
    Server code runs on the server (PL/SQL). Client code/commands on the client (SQL*Plus). Do not confuse or mix the two. Standard client-server principles applies.

Maybe you are looking for

  • Print Change Text in PO

    Hi All,          I have replaced standard script(MEDRUCK) with Zsmart form for PO printing. when user change in any line of PO, like he have changed quantity. for this change a text message as **PO quantity changed** print in standard script. Now I w

  • Why do i keep getting the "internet connection timeout" error message?

    i have been upgrading a few standard itunes albums to itunes plus versions through my 3g mobile broadband connection, while not exactly a fast process, it was working fine until i started to get a backlog of 3 or 4 albums which were waiting in a queu

  • Syncing photos from the iPhoto library to iPad.

    I'm trying to sync some photos to my ipad 2 using itunes from the iphoto library, but when I tries to sync my photos to my ipad, there's a error message says "unable to sync ipad. Can not find the necessary files" But I have a iPod and it syncs just

  • OCR in Acrobat

    Hello,   I need the capability of OCR pdf. Can I use Acrobat engine or any other DLL. What is the experience or suggestion? Thanks, Sow

  • How to seperate Power Pivot Data Model and Power Pivot Report from Single Workbook.

    HI  Team, Initially, We have created Power Pivot report in workbook, containing Source Data Model as well. Now, we want to convert workbook having model as Shared Data Model, and all report needs to be part of single workbook. I want to implement one