A Select statement with Appending table statement in it.

Hi,
  How can I use a select statement with a <Appening table> statement in it.
SELECT DISTINCT <field Name>
                FROM <DB table name>
                APPENDING TABLE <itab>
                WHERE <fieldname> EQ <Itab1-fieldname>
                  AND <fieldname> EQ <itab2-fieldname>.
Can I use the above select statement.If I'm using this...how this works?
Regards
Dharmaraju

Hi, Dharma Raju Kondeti.
I found this in the SAP online help, hope this can help you.
Specifying Internal Tables
When you read several lines of a database table, you can place them in an internal table. To do this, use the following in the INTO clause:
SELECT ... INTO|APPENDING [CORRESPONDING FIELDS OF] TABLE <itab>
                          [PACKAGE SIZE <n>] ...
The same applies to the line type of <itab>, the way in which the data for a line of the database table are assigned to a table line, and the CORRESPONDING FIELDS addition as for flat work areas (see above).
The internal table is filled with all of the lines of the selection. When you use INTO, all existing lines in the table are deleted. When you use APPENDING; the new lines are added to the existing internal table <itab>. With APPENDING, the system adds the lines to the internal table appropriately for the table type. Fields in the internal table not affected by the selection are filled with initial values.
If you use the PACKAGE SIZE addition, the lines of the selection are not written into the internal table at once, but in packets. You can define packets of <n> lines that are written one after the other into the internal table. If you use INTO, each packet replaces the preceding one. If you use APPENDING, the packets are inserted one after the other. This is only possible in a loop that ends with ENDSELECT. Outside the SELECT loop, the contents of the internal table are undetermined. You must process the selected lines within the loop.
Regards,
feng.
Edited by: feng zhang on Feb 21, 2008 10:20 AM

Similar Messages

  • Problem with Selection Criteria with 2 or statements.

    I have a report with 2 or statements in the selection criteria:
    like "US IT GFS INFOSYS*" or
    like "US IT GFS INFOSYS*" or
    like "US IT GFS INFOSYS*"
    I am just trying to do do a count of records. The details has the record # and am doing a distinct count. If I rearrange this or statement, then I get a different count. The above statement gives me a count of 1136. If I rearrange the statement to:
    like "US IT GFS INFOSYS*" or
    like "US IT GFS INFOSYS*" or
    like "US IT GFS INFOSYS*"
    I only get 192 records. I don't understand why?  Please help.

    Cara,
    When Crystal evaluates an or statement it will stop evaluating after one of the clauses is true. Since the first or clause is returning data, true, it is not evaluating the other 2 clauses. When you change the order I am assuming that the first clause is returning data though different from the original record selection.
    You may want to consider using a command object or stored procedure to generate the filter as SQL should evaluate all the or clauses.

  • With temp table statement

    what is the impact of using this with statement. e.g.
    with
    view_temp as
    (select * from view_table)
    select * from view_temp....
    it cause long running queries..it says below:
    NSERT /*+ APPEND BYPASS_RECURSIVE_CHECK */ INTO "SYS"."SYS_TEMP_0FD9D6607_25EEFA14" SELECT /*+ */ "view_table"
    Anyone could explain?

    Subquery factoring ("with table_name as (...)") allows the optimizer to choose to put the factored query into a system temp table if it feels that that would be best.
    see: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10002.htm#i2077142
    If you think the optimizer shouldn't be sorting the results in a temp table to use elsewhere, you should look at why the optimizer thinks that it's the best option. Somewhere your stats are not up to date, or your query and/or view need tuning... If the latter, and you need help in tuning your statement(s), then read this first: HOW TO: Post a SQL statement tuning request - template posting
    Edited by: Boneist on 30-Jun-2009 11:51

  • Problem with append table

    Hi,
    i want to insert a line into a internal table ; the type of table is a type of table for example Z_MYSTRUCT. Z_MYSTRUCT is a type of line so to insert a new line into my table i can't do this :
    data : l_new type Z_MYSTRUCT.
    l_new-field1 = 'value'.
    append l_new into mytable.
    How can i do this ?
    Regards

    Thanks for prompt reply.
    I have an requirement where in transaction MIGO. when user clicks on POST button, at that time the data should be e-mailed to the Vendor.
    So for that i have created a Z implementation of BADI MB_MIGO_BADI.
    Now in that i have written a Function Module name as Z_SENDMAIL.
    where i have table paramater which is of type BCSY_TEXT which is again of LINE type of SOLI.
    Now the data of MIGO is filled in table IT_MSEG which is paramter of Method POST_DOCUMENT of  MB_MIGO_BADI.
    So problem comes that how should i fill the data in my line type table of Function Module.
    For your information i am sending you the FM.
    FUNCTION Z_SENDMAIL.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(FROM) TYPE  ADR6-SMTP_ADDR OPTIONAL
    *"     REFERENCE(TO) TYPE  ADR6-SMTP_ADDR OPTIONAL
    *"     REFERENCE(SUBJECT) TYPE  SO_OBJ_DES
    *"     REFERENCE(FLAG) TYPE  CHAR1 OPTIONAL
    *"  EXPORTING
    *"     REFERENCE(RETURNCODE) TYPE  SY-SUBRC
    *"  TABLES
    *"      IT_TEXT TYPE  BCSY_TEXT
    *"      IT_EMAILS STRUCTURE  SOMLRECI1 OPTIONAL
    TYPES : BEGIN OF TS_REC,
                RECIPIENT        TYPE REF TO IF_RECIPIENT_BCS,
              END OF TS_REC.
      DATA : IS_T1(255)          TYPE C,
             IT_REC             TYPE TABLE OF TS_REC,
             IS_REC             TYPE TS_REC,
             W_EMAIL            TYPE ADR6-SMTP_ADDR,
             W_TEXT             TYPE BCSY_TEXT,
             W_DOCUMENT         TYPE REF TO CL_DOCUMENT_BCS,
             W_SENDER           TYPE REF TO IF_SENDER_BCS,
             W_RECIPIENT        TYPE REF TO IF_RECIPIENT_BCS,
             W_SENT_TO_ALL      TYPE OS_BOOLEAN,
             W_OREF             TYPE REF TO CX_ROOT,
             W_TEXT1            TYPE STRING,
             W_SEND_REQUEST     TYPE REF TO CL_BCS,
             W_TABIX            TYPE SY-TABIX.
      CONSTANTS:  C_TYPE      TYPE SO_OBJ_TP VALUE 'RAW',
                  C_LENGTH    TYPE SO_OBJ_LEN VALUE '12',
                  C_X         TYPE C VALUE 'X'.
      FROM = [email protected]'.
      TRY.
    create persistent send request
          W_SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
          LOOP AT IT_TEXT INTO IS_T1.
            APPEND IS_T1 TO W_TEXT.
            CLEAR IS_T1.
          ENDLOOP.
          W_DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
          I_TYPE = C_TYPE
          I_TEXT = W_TEXT
          I_LENGTH = C_LENGTH
          I_SUBJECT = SUBJECT ).
    add document to send request
          CALL METHOD W_SEND_REQUEST->SET_DOCUMENT( W_DOCUMENT ).
    set sender
    note: this is necessary only if you want to set the sender
    different from actual user (SY-UNAME). Otherwise sender is
    set automatically with actual user.
    sender = cl_sapuser_bcs=>create( sy-uname ).
          W_SENDER = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( FROM
          CALL METHOD W_SEND_REQUEST->SET_SENDER
            EXPORTING
              I_SENDER = W_SENDER.
    add recipient (e-mail address)
    create recipient - please replace e-mail address !!!
          IF TO IS NOT INITIAL .
            W_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(
            TO ).
            CALL METHOD W_SEND_REQUEST->ADD_RECIPIENT
               EXPORTING
                 I_RECIPIENT = W_RECIPIENT
             i_copy      = c_x
                 I_EXPRESS   = C_X.
            W_SEND_REQUEST->SET_SEND_IMMEDIATELY( 'X' ).
            CALL METHOD W_SEND_REQUEST->SEND(
            EXPORTING
            I_WITH_ERROR_SCREEN = C_X
            RECEIVING
            RESULT = W_SENT_TO_ALL ).
            COMMIT WORK.
          ENDIF.
        CATCH CX_SY_ARITHMETIC_ERROR INTO W_OREF.
          RETURNCODE = 4.
          W_TEXT1 = W_OREF->GET_TEXT( ).
        CATCH CX_ROOT INTO W_OREF.
          RETURNCODE = 4.
          W_TEXT1 = W_OREF->GET_TEXT( ).
      ENDTRY.
      LOOP AT IT_EMAILS.
        TRY.
            CLEAR W_EMAIL.
            W_EMAIL = IT_EMAILS-RECEIVER.
            W_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(
             W_EMAIL ).
            IS_REC-RECIPIENT = W_RECIPIENT.
            APPEND IS_REC TO IT_REC.
          CATCH CX_ADDRESS_BCS.
            RETURNCODE = 4.
        ENDTRY.
      ENDLOOP.
      LOOP AT IT_REC INTO IS_REC.
        TRY.
            W_SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
            W_DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
            I_TYPE = C_TYPE
            I_TEXT = W_TEXT
            I_LENGTH = C_LENGTH
            I_SUBJECT = SUBJECT ).
    add document to send request
            CALL METHOD W_SEND_REQUEST->SET_DOCUMENT( W_DOCUMENT ).
    set sender
    note: this is necessary only if you want to set the sender
    different from actual user (SY-UNAME). Otherwise sender is
    set automatically with actual user.
    sender = cl_sapuser_bcs=>create( sy-uname ).
            W_SENDER = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(
            FROM ).
            CALL METHOD W_SEND_REQUEST->SET_SENDER
              EXPORTING
                I_SENDER = W_SENDER.
            CALL METHOD W_SEND_REQUEST->ADD_RECIPIENT
              EXPORTING
                I_RECIPIENT = IS_REC-RECIPIENT
                I_EXPRESS   = C_X.
            W_SEND_REQUEST->SET_SEND_IMMEDIATELY( 'X' ).
            CALL METHOD W_SEND_REQUEST->SEND(
            EXPORTING
            I_WITH_ERROR_SCREEN = C_X
            RECEIVING
            RESULT = W_SENT_TO_ALL ).
           COMMIT WORK.
          CATCH CX_SY_ARITHMETIC_ERROR INTO W_OREF.
            RETURNCODE = 4.
            W_TEXT1 = W_OREF->GET_TEXT( ).
          CATCH CX_ROOT INTO W_OREF.
            RETURNCODE = 4.
            W_TEXT1 = W_OREF->GET_TEXT( ).
        ENDTRY.
      ENDLOOP.
      IF FLAG = 'X'.
        IF TO IS NOT INITIAL.
          IT_EMAILS-RECEIVER = TO.
          APPEND IT_EMAILS TO IT_EMAILS.
        ENDIF.
      ENDIF.
    ENDFUNCTION.
    So pls help me out asap its very Urgent.......
    Regards,
    DS

  • Variant for selection screen with the Table control entries in another Tab

    Hi Guys,
      The requirement is to create a variant for the two tabs on a selection screen.
      First tab contains the select options and the second contains table control for making entries.
      So will it be possible to create a variant when the user makes entries in the fields in one tab and the table on other tab?

    You wrote
    Utilizing the "Save as variant" option from the selection screen itself works out perfectly, but this variant cannot be transported.
    But, give the variant a name beginning with "CUS&" and this variant will be transported. Variant beginning with "CUS&" or "SAP&" are so-called "system variant" and are  transported automatically. You can then copy the transaction code and use this new variant in the new transaction.
    Regards,
    Raymond

  • Select Problem with Joined tables

    Hello everyone I have the following Query
    SELECT
        OBJEKTI.OBJEKAT_ID OBJEKAT_ID,
        OBJEKTI.ADRESA ADRESA,
        OBJEKTI.POVRSINA POVRSINA,
        OBJEKTI.BROJ_IZVRSILACA BROJ_IZVRSILACA,
        OPREMLJENOSTI.OPREMLJENOST_ID OPREMLJENOST_ID,
        OPREMLJENOSTI.PULT PULT,
        OPREMLJENOSTI.REKLAMA REKLAMA,
        OPREMLJENOSTI.MOKRI_CVOR MOKRI_CVOR,
        OPREMLJENOSTI.WC_ZA_IGRACE WC_ZA_IGRACE,
        OPREMLJENOSTI.WC_ZA_OSOBLJE WC_ZA_OSOBLJE,
        OPREMLJENOSTI.VENTILATOR VENTILATOR,
        OPREMLJENOSTI.OSVJETLJENJE OSVJETLJENJE,
        OPREMLJENOSTI.VRSTA_BROJILA VRSTA_BROJILA,
        OPREMLJENOSTI.ELEKTRO_INSTALACIJE ELEKTRO_INSTALACIJE,
        OPREMLJENOSTI.VODO_INSTALACIJE VODO_INSTALACIJE,
        OPREMLJENOSTI.TELEFONSKE_INSTALACIJE TELEFONSKE_INSTALACIJE,
        OPREMLJENOSTI.GRIJANJE_ID GRIJANJE_ID,
        OPREMLJENOSTI.POD_ID POD_ID,
        OPREMLJENOSTI.PROZORI_VRATA_ID PROZORI_VRATA_ID,
        OPREMLJENOSTI.OBJEKAT_ID OBJEKAT_ID1,
        TEHNICKE_OPREMLJENOSTI.TEH_OPR_ID TEH_OPR_ID,
        TEHNICKE_OPREMLJENOSTI.ONLINE_KLADIONICA ONLINE_KLADIONICA,
        TEHNICKE_OPREMLJENOSTI.PANO PANO,
        TEHNICKE_OPREMLJENOSTI.NOSACI NOSACI,
        TEHNICKE_OPREMLJENOSTI.TV_LCD TV_LCD,
        TEHNICKE_OPREMLJENOSTI.TV_TELETEXT TV_TELETEXT,
        TEHNICKE_OPREMLJENOSTI.APARATI_IGRE APARATI_IGRE,
        TEHNICKE_OPREMLJENOSTI.EVONA EVONA,
        TEHNICKE_OPREMLJENOSTI.NOVOMATIC NOVOMATIC,
        TEHNICKE_OPREMLJENOSTI.RULET RULET,
        TEHNICKE_OPREMLJENOSTI.BILIJAR BILIJAR,
        TEHNICKE_OPREMLJENOSTI.KLIMA KLIMA,
        TEHNICKE_OPREMLJENOSTI.OBJEKAT_ID OBJEKAT_ID2,
        PONUDE.PONUDA_ID PONUDA_ID,
        PONUDE.ONLINE_TERMINAL ONLINE_TERMINAL,
        PONUDE.SRECKE SRECKE,
        PONUDE.ONLINE_KLADIONICA ONLINE_KLADIONICA1,
        PONUDE.APARATI_IGRE APARATI_IGRE1,
        PONUDE.RULET RULET1,
        PONUDE.BILIJAR BILIJAR1,
        PONUDE.OBJEKAT_ID OBJEKAT_ID3
    FROM
        OBJEKTI,
        OPREMLJENOSTI,
        TEHNICKE_OPREMLJENOSTI,
        PONUDE
    WHERE
    (PONUDE.OBJEKAT_ID=OBJEKTI.OBJEKAT_ID AND TEHNICKE_OPREMLJENOSTI.OBJEKAT_ID=OPREMLJENOSTI.OBJEKAT_ID) OR (OPREMLJENOSTI.OBJEKAT_ID=OBJEKTI.OBJEKAT_ID AND TEHNICKE_OPREMLJENOSTI.OBJEKAT_ID=OPREMLJENOSTI.OBJEKAT_ID)
    ORDER BY OBJEKTI.OBJEKAT_IDThe problem I get is no matter what WHERE clause I use I get doubled values which makes no sense. I checked in the tables and I don't have any doubled values. Each Opremljenost has 1 objekat (there are 2 rows each with its own Objekat) and the same applies to the other 2 tables (PONUDE and TEHNICKE OPREMLJENOSTI) but for some reason they double up the values. If I run it without a where clause at all I get some values repeat itself up to 4 times. Does anyone have a clue what is wrong with my query?

    You are joining a parent table (OBJEKTI) with three child tables (the other three: PON, TEH, OPR).
    Whenever you do that, you will always get duplication of child-rows, if there are multiple child-rows for a parent-row in any of the three child tables.
    For example, let P be a parent table, with two child tables, say C1 and C2.
    Contents:
    Table P:
    p1
    Table C1 (has two rows for row p1):
    1 p1
    2 p1
    Table C2 (has three rows for row p1):
    10 p1
    20 p1
    30 p1If you now do this:
    select P.*,C1.*,C2.*
    from P, C1, C2
    where [join P with C1]  and [join P with C2]Then your result set will look like this:
    P.p1  C1.1  C1.p1  C2.10  C2.p1
    P.p1  C1.1  C1.p1  C2.20  C2.p1
    P.p1  C1.1  C1.p1  C2.30  C2.p1
    P.p1  C1.2  C1.p1  C2.10  C2.p1
    P.p1  C1.2  C1.p1  C2.20  C2.p1
    P.p1  C1.2  C1.p1  C2.30  C2.p1As you can see every C1 row is duplicated three times in the resultset (due to join with C2).
    And every C2 row is duplicated two times in the resultset (due to join with C1).
    This is simply what happens if you join a parent table with multiple child tables...
    Question now is: what is the expected result that you are looking for?

  • Cursor in if statement with two sql statements

    if
    :v_project_number ='ALL'
    then
    cursor c1 is select * from gl_je_lines gjl
    where   nvl(gjl.attribute10,1) in(select decode(:v_project_number,'ALL',nvl(gjl.attribute10,1),:v_project_number) from dual)   
    else if
    :v_project_number !='ALL'
    then
    cursor c1 is select * from gl_je_lines gjl  
    end if;
    this is giving error can any one help me to achive above requirement

    Hi,
    No need for 'if then' modify your cursor as follows:
    cursor c1 is select * from gl_je_lines gjl
    where   decode(:v_project_number,'ALL','A',nvl(gjl.attribute10,1)) =decode(:v_project_number,'ALL','A',:v_project_number);
    if :v_project_number is 'ALL' then it checks the character 'A' in both the side so the query returns all rows.  On the other hand if :v_project_number is not equeal to 'ALL' strictly it compares the contents of gjl.attribute10 with :v_project_number.

  • Getting an error message while trying to use a ZTABLE with TABLES statement

    Hi All,
    I wanted to use a ZTable with the TABLES statement, but it is throwing an error saying " Ztable must be a flat structure. you cannot use internal tables, strings, references or structures as components."
    What might be the reason for this error??
    Thanks in advance.

    This Ztable, is this a transparent table (structure) or is it a table type?
    In case of table type, you should use USING or CHANGING parameter.
    Might be better to paste part of your code here, and do not forget to tell how this Ztable is defined (Data dictionary or even local type).

  • Difference between tables statement and work area

    Hi
    i would like know the difference between these statement.
    tables: vttk.
    data :itab type standard table of vttk,
             wa_itab like line of vttk.
    what will happen with the table statement keyword ???
    whether any difference between the ouput created through tables and wa_itab statement???

    Hi
    HI,
    INTERNAL Table and it's background:
    ===================================
    Internal table acts as a container which is used to store the record sets. That is used to store the data fetched from the database table.
    So due to performance reason every time access to database would not be so good and decrease the performance. So you just select the data from the database and store it in the intermediate table. This table is called INTERNAL TABLE. So it's an replica of the database. The design foes like this,
    PRESENTATION SERVER <> APPLICATION SERVER <>
    DATABASE SERVER.
    So everytime gain accessing to database results in high resource usage and bad permformance.
    So always play around with internal tables. So obviously the whenever you access the data in the INTERNAL TABLE, the application server will be used.
    WORK AREA:
    ==========
    When ever you loop at the internal table, the current record should be stored in a temporary work place. That is called WORK AREA.
    LOOP AT ITAB INTO WORKAREA.
    ENDLOOP.
    ITAB :An internal table
    WORKAREA:An instance of internal table
    Go thru the link below
    Internal tables
    appending internal tables.
    <b>Reward if usefull</b>

  • Dynamic select-statement with ranges

    Good morning experts,
    I just wanted to know if this is possible:
    I had a report with a selection-screen where I can enter a table-name and one ore more filed-names (separated by ;).
    After that, I create a table like my entered (for example MARA)
    CREATE DATA gt_table TYPE TABLE OF (p_tab).
    ASSIGN gt_table->* TO <gt_table>.
    Then I split my entered fields (at and for each filed I made a selection (with function COMPLEX_SELECTIONS_DIALOG).
    Result of this is for each field a range-tab which I write in a new table - first column is the name of the field, second column is a range-tab:
    TYPES: BEGIN OF t_ranges,
              sign TYPE tkeppllevs-sign,
              opt  TYPE tkeppllevs-opt,
              low  TYPE rsdslow,
              high TYPE rsdslow,
            END OF t_ranges.
    DATA: BEGIN OF gs_conditions,
            fieldname TYPE string,
            ranges    TYPE TABLE OF t_ranges.
    DATA: END OF gs_conditions.
    DATA: gt_conditions LIKE TABLE OF gs_conditions.
    Now I want to make a select on the entered table (MARA).
    So I make a loop on my gt_conditions:
    LOOP AT gt_conditions INTO gs_conditions.
      l_index = sy-tabix.
    CONCATENATE 'gt_conditions[' l_index ']-ranges' INTO l_condition.
      CONDENSE l_condition NO-GAPS.
      CONCATENATE gs_conditions-fieldname 'IN' l_condition INTO lt_condition SEPARATED BY space.
      IF sy-tabix > 1.
        CONCATENATE 'AND' lt_condition INTO lt_condition SEPARATED BY space.
      ENDIF.
      APPEND lt_condition.
    ENDLOOP.
    If I look at it after the loop, it looks correct:
    MATNR IN gt_conditions[1]-ranges
    AND ERSDA IN gt_conditions[2]-ranges
    But this wont work because of "gt_conditions[1]-ranges". I know, i can work with the "table in table", because gs_conditions-ranges works (I already tested this).
    Has anybody any idea how to make my idea work?

    @Hymavathi:
    Error is the following:
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SEMANTICS', was
    not caught and
    therefore caused a runtime error.
    The reason for the exception is:
    The current ABAP program has tried to execute an Open SQL statement
    which contains a WHERE, ON or HAVING condition with a dynamic part.
    The part of the WHERE, ON or HAVING condition specified at runtime in
    a field or an internal table, contains the invalid value
    "GT_CONDITIONS[1]-RANGES".
    @Hymavathi, second time:
    This is the whole code for the select:
    LOOP AT gt_conditions INTO gs_conditions.
      l_index = sy-tabix.
      CONCATENATE 'gt_conditions[' l_index ']-ranges' INTO l_condition.
      CONDENSE l_condition NO-GAPS.
      CONCATENATE gs_conditions-fieldname 'IN' l_condition INTO lt_condition SEPARATED BY space.
      IF sy-tabix > 1.
        CONCATENATE 'AND' lt_condition INTO lt_condition SEPARATED BY space.
      ENDIF.
      APPEND lt_condition.
    ENDLOOP.
    SELECT * FROM (p_tab)
       INTO TABLE <gt_table>
            WHERE (lt_condition).
    You can see, the select is after the loop. So gs_conditions-ranges wouldn't be right, then the where statement would only use the last range-tab from my table gt_conditions. (loop at...endloop => gs-conditions-range = last gt_conditions-range).

  • How to use a select statement with chinese characters?

    I am currently developing a java servlet<using tomcat 4.x> which allows me to use select statement to retrieve results from the Microsoft SQL Server 2000 database. I am using a simple form to get the parameter for querying. The main problem i'm facing is that there are chinese information in the SQL database, but i can't retrieve it through the sql statement with the chinese characters input<thru the form with the help of NJ STAR>in the WHERE condition. When i execute the statement, it returns me no results even though the rows are present in the database.
    Does anyone have the solution to using chinese words in the WHERE clause of the select statement to retrieve results with columns which contains chinese characters? Please help me. Thanks everyone. :)
    PS: when i cut and paste those characters in the sql database and paste onto java.. it is ??? in questionmarks.. but when i paste them into excel 2000.. its shown as chinese chars again..
    please heelppp~~

    Greetings,
    PS: when i cut and paste those characters in thesql
    database and paste onto java.. it is ??? in
    questionmarks.. but when i paste them into excelThis is why the SELECT is not returning any results.
    You need to set the character encoding set on your
    statement and parameters for the characters to be
    properly translated. Refer to the charsetName
    parameter in the String class constructor in your API
    docs and also to
    $JDK_DOCS/guide/intl/encoding.doc.html in your JDK
    documentation.
    2000.. its shown as chinese chars again..Because Office programs are performing the same kind
    of character translation with the appropriate MS APIs.
    please heelppp~~Regards,
    Tony "Vee Schade" Cookis it possible for you to show me some coding examples? i don't really understand what is to be done in order to set the char set and what does it really do.. tried reading up but still dun understand.. :(
    pardon my shallow knowledge of java..
    ok..
    The thing is when i used an insert statement with chinese characters of GBK format hardcoded into the java servlet and then i use the insert statement to insert the chars into the database, it cannot be seen as a chinese word when i off the NJStar. and then it can be searched out with my current form of servlet.. below is my coding of the servlet..
    note: i've set my html file to charset = GBK
    //prototype of Search engine...
    //workable for GBK input and output...
    import java.io.*;
    import java.io.OutputStream;
    import java.io.IOException;
    import javax.servlet.http.*;
    import javax.servlet.ServletException;
    import java.util.*;
    import java.sql.*;
    import java.nio.charset.Charset;
    public class SearchBeta extends HttpServlet {
         private Vector musicDetails = new Vector();
         private String query = "";
         public void service (HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException, UnsupportedEncodingException {
              query = req.getParameter ("T1");
              System.out.println("before:"+query);
              String type = req.getParameter ("D1");//type
              query = req.getParameter ("T1");
              //query = "������";
              System.out.println("after:"+query);
              getResults(type,query);
              System.out.println("locale = :"+req.getLocale());
              res.setContentType ("text/html;charset=GBK");
              PrintWriter out = res.getWriter();
              out.println("<html>");
              out.println("<head>");
              out.println("<body bgcolor = \"black\">");
              out.println("<font face = \"comic sans ms\" color=\"Cornsilk\">");
              if (query.length()==0)
                   out.println ("Please key in your search query.");
              else if (musicDetails.size()==0)
                   out.println ("Sorry, no results matching your search can be found.");
              else {
                   out.println("<center>");
                   out.println("<table cellspacing = \"50\">");
                   int i = 0;
                   //Display the details of the music
                   while (i<musicDetails.size()) {
                        Results details = (Results)musicDetails.get(i);
                        String dbArtist = "";
                        String dbAlbum = "";
                        String dbTitle = "";
                        String dbCompany = "";
                        dbAlbum = details.getAlbum();
                        dbTitle = details.getTitle();
                        dbCompany = details.getCompany();
                        dbArtist = details.getArtist();
                        try{
                             dbAlbum = new String(dbAlbum.getBytes("ISO-8859-1"),"GBK");
                             dbTitle = new String(dbTitle.getBytes("ISO-8859-1"),"GBK");
                             dbCompany = new String(dbCompany.getBytes("ISO-8859-1"),"GBK");
                             dbArtist = new String(dbArtist.getBytes("ISO-8859-1"),"GBK");//correct translation.
                        catch(UnsupportedEncodingException e){
                             System.out.print(e);
                             e.printStackTrace();
                        String dbImage_loc = details.getImage();
                        out.println("<tr>");
                             out.println("<td><table>");
                                  out.println("<img src=C:\\Program Files\\Apache Group\\Tomcat 4.1\\webapps\\examples\\ThumbNails\\"+dbImage_loc+">");
                             out.println("<tr>");
                                  out.println("<th><font color=\"violet\"> Artist: </font></th>");
                                  out.println("<td><font color=\"Cornsilk\">"+dbArtist+"</font></td>");
                             out.println("</tr>");
                             out.println("<tr>");
                                  out.println("<th><font color=\"violet\"> Title: </font></th>");
                                  out.println("<td><font color=\"Cornsilk\">"+dbTitle+"</font></td>");
                             out.println("</tr>");
                             out.println("<tr>");
                                  out.println("<th><font color=\"violet\"> Company: </font></th>");
                                  out.println("<td><font color=\"Cornsilk\">"+dbCompany+"</font></td>");
                             out.println("</tr>");
                             System.out.println("album: "+ dbAlbum);
                             out.println("<tr>");
                                  out.println("<th><font color=\"violet\"> Album: </font></th>");
                                  out.println("<td><font color=\"Cornsilk\">"+dbAlbum+"</font></td>");
                             out.println("</tr>");
                             System.out.println("company: "+ dbCompany);
                             out.println("</table></td>");
                        out.println("</tr>");
                        i++;
                   out.println("</table>");
                   out.println("</center>");
              out.println("</font>");
              out.println("</body>");
              out.println("</head>");
              out.println("</html>");
              out.close();
              //to remove all the elements from the Vector
              musicDetails.removeAllElements();
         //get Searched Music Details and store in Results object which is stored in musicDetails vector
         public void getResults (String type, String searchQuery) {
              try {
                   Class.forName ("com.microsoft.jdbc.sqlserver.SQLServerDriver");
                   Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=music","sa","kokkeng");
                   Statement stmt = con.createStatement();
                   String query = "SELECT * FROM MusicDetails WHERE "+type+" = '"+searchQuery+"'";
                   ResultSet rs = stmt.executeQuery(query);
                   while (rs.next()) {
                        String artist = rs.getString("Artist");
                        String title = rs.getString("Song");
                        String company = rs.getString("Company");
                        String album = rs.getString("Album");
                        String image_loc = rs.getString("Image");
                        Results details = new Results (artist,title,company,album,image_loc);
                        musicDetails.add(details);
                   stmt.close();
                   con.close();
              catch (Exception e) {
                   System.out.println(e.getMessage());
                   e.printStackTrace();
    with the above servlet i created, i can search out the data in the database which i've inserted through the insert statement. I still can't search for things i've keyed into the database directly using NJStar..
    thank you so much for helping.. really hope any one else who knows the answer to this will reply too... thank you all so much...
    -KK

  • Why we use Tables statement in case of using SELECT-OPTIONS:

    hi all,
    Why we use Tables statement in case of using the following coding in an ABAP program ...
    tables: vbak.
    SELECT-OPTIONS: s1 for vbak-vbeln.
    here if we dont provide the tables statement why it does not work ????
    pls answwer ....???

    Hi
    This statement is not allowed in classes and declares a data object table_wa as a table work area whose data type is adopted from the identically named structured data type table_wa from the ABAP Dictionary. table_wa must be defined as a flat structure in the ABAP Dictionary. You can specify database tables or Views for table_wa.
    Work table areas declared with TABLES are interface work areas and should only be declared in the global declaration section of a program for the following purpose:
    reward if usefull
    The statement TABLES is required for exchanging data between screen fields that were defined in a program screen when transferring from the ABAP Dictionary and the ABAP program. For the screen event PBO, the content of the table work area is transferred to identically named screen fields; for PAI, the system adopts the data from identically named screen fields.
    In executable programs, flat table work areas can be used for adopting data that were provided for the event GET table_wa from a linked logical database. TABLES is synonymous with the statement NODES for this purpose.
    Work table areas declared with TABLES behave like the data declared with the addition COMMON PART, meaning the data are used by the programs of a program group.
    Table work areas declared with TABLES can be declared in subroutines and
    function modules. However, this is not recommended. A table work area declared in a procedure is not local but belongs to the context of a framework program. The table work area can be viewed starting from the declaration in the framework program and lives as long as the framework program. In contrast to normal program-global data, the content of the table work areas declared in subroutines and function modules is stored temporarily when these subroutines and function modules are called. Value assignments that were made during runtime of the procedure are preserved until the procedure is completed. When exiting the procedure, the table work areas are filled with the contents that they contained when the procedure was called. Table work areas declared in procedures behave like global data to which the statement LOCAL is applied in the procedure.
    The form TABLES * is obsolete.

  • Dynamic SQL Statement with table name

    Dear all
    i like to have a SQL statement with a dynamic tablename. Is this possible? If yes, how?
    should be something like "select * from <mytablename>"
    Thank you
    Herbert

    Yes this is possible. use the below reference code for this.
    data: g_tablename type w_tabname,
            gv_dref TYPE REF TO data.
    FIELD-SYMBOLS: <g_itab> TYPE STANDARD TABLE.
    gv_tabname = p_tablename (take table name form selection screen or as per ur requirement)
    CREATE DATA gv_dref TYPE TABLE OF (g_tabname).
    ASSIGN gv_dref->* TO <g_itab>.
    now use the below select query to fetch the data
      SELECT * FROM (gv_tabname) INTO TABLE <g_itab>.
    Hope this will help

  • Need to Improve  pefromance for select statement using MSEG table

    Hi all,
    We are using a select statement using MSEG table
    which takes a very long time to run the program which is scheduled in back ground.
    Please see the history below.;
    1) Previously this program was using SELECT-ENDSELECT statement inside the loop i.e.
    LOOP AT I_MCHB.
    To get Material Doc. Details
          SELECT MBLNR
                 MJAHR
                 ZEILE INTO (MSEG-MBLNR,MSEG-MJAHR,MSEG-ZEILE)
                 UP TO 1 ROWS
                 FROM MSEG
                WHERE CHARG EQ I_MCHB-CHARG
                 AND  MATNR EQ I_MCHB-MATNR
                 AND  WERKS EQ I_MCHB-WERKS
                 AND  LGORT EQ I_MCHB-LGORT.
          ENDSELECT.
    Endloop.
    The program was taking 1 hr  for  20 k data
    2)The above statement was replaced by ALL ENTRIES to remove the SELECT-ENDSELECT from the loop.
    ***GET MATERIAL DOC NUMBER AND FINANCIAL YEAR DETAILS FROM MSEG TABLE
        SELECT MBLNR
               MJAHR
               ZEILE
               MATNR
               CHARG
               WERKS
               LGORT
                   INTO TABLE I_MSEG
                   FROM   MSEG
                   FOR ALL ENTRIES IN I_MCHB
                   WHERE CHARG EQ I_MCHB-CHARG
                   AND   MATNR EQ I_MCHB-MATNR
                   AND   WERKS EQ I_MCHB-WERKS
                   AND   LGORT EQ I_MCHB-LGORT.
    3)After getting the further technical analysis from BASIS team , And with the suggestion to optimize the program by changing the INDEX RANGE SCAN to
           MSEG~M.
    SELECT MBLNR
               MJAHR
               ZEILE
               MATNR
               CHARG
               WERKS
               LGORT
                   INTO TABLE  I_MSEG
                   FROM   MSEG
                   FOR ALL ENTRIES IN I_MCHB
                   WHERE MATNR EQ I_MCHB-MATNR
                   AND   WERKS EQ I_MCHB-WERKS
                   AND   LGORT EQ I_MCHB-LGORT.
    At present the program is taking 3 to 4 hrs in back ground .
    The table is complete table scan using index
    MSEG~M.
    Please suggest to improve the performance of this
    many many thanks
    deepak

    The benchmark should be the join, and I can not see how any of your solutions can be faster than the join
    SELECT   .....
                  INTO TABLE  ....
                  UP TO 1 ROWS
                  FROM mchb as a
                  INNER JOIN mseg as b
                  ON    amatnr EQ bmatnr
                  AND  awerks  EQ bwerks
                  AND  algort    EQ blgort
                  And   acharg  EQ bcharg
                  WHERE a~ ....
    The WHERE condition must come from the select on MCHB, the field list from the total results
    you want.
    If you want to compare, must compare your solutions plus the select to fill I_MCHB.
    Siegfried
    Edited by: Siegfried Boes  on Dec 20, 2007 2:28 PM

  • Select distinct statement with various alias

    Hi everybody,
    I'm trying to put a select distinct statement in a query with two different alias for two different tables; like that:
    select distinct a.ma_name||'.'||a.ma_first_name d,
    a.ma_first_name||'.'||a.ma_name r
    from ma_main a, manager_liste b
    where (UPPER(b.manager_first_name||'.'||b.manager_name) = :APP_USER or
    (case when 'X'=:APP_USER or 'Y'=:APP_USER
    then 1
    else 0
    end) = 1)
    order by a.ma_name
    But it doesn't work. Can anybody help?
    Thx a lot!
    Jan

    hi,
    this is the error:
    1 error has occurred
    LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.
    and the table manager_liste and ma_main are varchar tables.
    how can i make it work, so that my select list with submit does only show distinct names. Because right now it shows each name about 10 times....

Maybe you are looking for

  • Returning goods back to Vendor in R/3

    DEAR SAP GURU's:  Good Day!  I am on a project at the moment and I have never heard of returning goods back to the (started in the middle) vendor as they are doing.  I am not saying it is wrong, but some new requirements for sending material out for

  • Problems saving changes in image size

    I have some digital files that I need to resize for printing. Most need to be sized to print full-frame on 8.5 by 11 inch sheets of paper, while the others need to be full-frame on 5 by 7 paper. I'm using a trial version of PS Elements. I call up the

  • ClassNotFoundException in Cluster

    Hello,           I have 8 instances of weblogic6.1sp1 running on aix. running           physically on 2 seperate machines(4 instances on 1 physically           machine). I have a .ear that is deployed to the master. in the .ear is           a .jar wi

  • Lenovo X220 and low volume [specially in Linux]

    Hi everybody, i've googled this issue and found it affects other users, but didn't find any solution. Problem is the audio level of my Lenovo X220 is very low, in the sense that there must be zero noise in the room to be able to hear the sound. I fou

  • Clearing 1.14 update from iTunes in order to try again

    Hi, The latest iphone update seems corrupt, and will not apply itself. iTunes reports that there is an update for my iphone, but when I choose to update, it fails. Seeing as the update has already downloaded - I assume that I have had a bad download.