Dump at select stmt

the program is dumping at the below stmt.
*--  Check whether any entry is present in the the table BSIP
  SELECT * INTO LS_BSIP FROM BSIP
          WHERE (LT_SEL_DATA).
LT_SEL_DATA is declared as
  TYPES : BEGIN OF T_SEL_DATA,
            FIELD(72) TYPE C,
          END   OF T_SEL_DATA.
  DATA : LT_SEL_DATA TYPE STANDARD TABLE OF T_SEL_DATA WITH HEADER LINE.
. So the dump is because of the no data in LT_SEL_DATA ?
Shall I put below code to solve the dump ?
IF NOT LT_SEL_DATA[] IS INITIAL.
  SELECT * INTO LS_BSIP FROM BSIP
          WHERE (LT_SEL_DATA).
ENDIF .
Thanks IN ADV

The below is dump analysis...
Can any body  also explain how it selects from bsip table id  LT_SEL_DATA is declared as FIELD(72) TYPE C, ?
SELECT * INTO LS_BSIP FROM BSIP
WHERE (LT_SEL_DATA).
====================================
Error analysis
The current ABAP/4 program attempted to execute an ABAP/4 Open SQL
statement containing a WHERE condition of the form WHERE (itab) or
WHERE ... AND (itab). The part of the WHERE condition specified at
runtime in the internal table itab is incorrectly parenthesized.
How to correct the error
If the error occurred in a non-modified SAP program, you may be
able to find a solution in the SAP note system.
If you have access to the note system yourself, use the following
search criteria:
"SAPSQL_WHERE_PARENTHESES"
"SAPLZADI_F_DUPLICATE_INV_CHECK " or "LZADI_F_DUPLICATE_INV_CHECKU01 "
"Z_ADI_F_DUPLICATE_INVOICE_CHK"
If you cannot solve the problem yourself, please send the
following documents to SAP:
1. A hard copy print describing the problem.
   To obtain this, select the "Print" function on the current screen.
Source code extract
001310              INTO LT_SEL_DATA-FIELD.
001320       APPEND LT_SEL_DATA.
001330     ENDIF.
001340
001350     CLEAR LT_SEL_DATA.
001360     CONCATENATE 'AND SHKZG NE '''
001370                  LV_SHKZG
001380                  ''''
001390            INTO LT_SEL_DATA-FIELD.
001400     APPEND LT_SEL_DATA.
001410
001420
001430     IF I_XBLNR IS INITIAL.
001440
001450   *    Include the field for Amount in local currency in the selection
001460   *    criteria on BSIP table
001470       LV_WRBTR = I_WRBTR.
001480       CONDENSE LV_WRBTR.
001490
001500       CLEAR LT_SEL_DATA.
001510       CONCATENATE 'AND WRBTR = '''
001520                   LV_WRBTR
001530                   ''''
001540              INTO LT_SEL_DATA-FIELD.
001550       APPEND LT_SEL_DATA.
001560
001570     ENDIF.
001580
001590   *    Check whether any entry is present in the the table BSIP
001600     SELECT * INTO LS_BSIP FROM BSIP
     >             WHERE (LT_SEL_DATA).
001620
001630   *    Check credit memos or not
001640       CHECK NOT ( I_SHKZG = LC_DB_IND AND LS_BSIP-SHKZG EQ SPACE ).
001650
001660   *    Check if BSIP entry refers to the same document or not
001670       CHECK NOT ( I_BELNR = LS_BSIP-BELNR AND
001680                   I_BUKRS = LS_BSIP-BUKRS AND
001690                   I_GJAHR = LS_BSIP-GJAHR ).
001700
001710   *    Get the reverse document number for the document selected
001720       CLEAR LV_STBLG.
001730       SELECT SINGLE STBLG
001740         INTO LV_STBLG
001750         FROM BKPF
001760        WHERE BELNR = LS_BSIP-BELNR
001770          AND BUKRS = LS_BSIP-BUKRS
001780          AND GJAHR = LS_BSIP-GJAHR.
001790
001800   *     Only if NO Vendor Invoice reversal has taken place, throw

Similar Messages

  • Dump with select stmt

    Hi All,
    Do you see anything wrong with this select stmt, it is giving me short dump.
    DATA: BEGIN OF it_output OCCURS 0,
          check TYPE c,
          vbeln LIKE likp-vbeln,
          lfdat LIKE likp-lfdat,
          kunnr LIKE likp-kunnr,
          knkli LIKE likp-knkli,
          netwr LIKE vbak-netwr,
          END OF it_output.
    SELECT LIKPVBELN LIKPLFDAT LIKPKUNNR LIKPKNKLI VBAK~NETWR
              FROM LIKP
              INNER JOIN VBAK ON LIKPVBELN = VBAKVBELN
              INTO TABLE IT_OUTPUT
              WHERE LIKP~LFDAT IN S_LFDAT
              AND LIKP~KUNNR IN S_KUNNR
              AND LIKP~LIFSK = P_LIFSK.
    Thanks
    Veni.

    Hi
    DATA: BEGIN OF it_output OCCURS 0,
    One error is here:
    <b>*check TYPE c,</b>
    vbeln LIKE likp-vbeln,
    lfdat LIKE likp-lfdat,
    kunnr LIKE likp-kunnr,
    knkli LIKE likp-knkli,
    netwr LIKE vbak-netwr,
    <b>check type c,</b>
    END OF it_output.
    SELECT LIKPVBELN LIKPLFDAT LIKPKUNNR LIKPKNKLI VBAK~NETWR
    FROM LIKP
    Another error is here
    <b>*INNER JOIN VBAK ON LIKPVBELN = VBAKVBELN</b>
    INNER JOIN LIPS ON LIKPVBELN = LIPSVBELN
    INNER JOIN VBAK ON LIPSVGBEL = VBAKVBELN
    INTO TABLE IT_OUTPUT
    WHERE LIKP~LFDAT IN S_LFDAT
    AND LIKP~KUNNR IN S_KUNNR
    AND LIKP~LIFSK = P_LIFSK.
    The link between sales order and delivery is in the item data, field is LIPS-VGBEL
    Max

  • Use of Select stmts with Update stmts

    Hi,
    I want to execute the following update stmt...
    UPDATE Test1_tab a
    SET a.invpln_seq_no = (SELECT b.seq_no
    FROM Test2_tab b
    WHERE b.contract_id = a.contract_id
    AND b.date_from = a.period_from_date)
    WHERE a.invpln_seq_no != (SELECT b.seq_no
    FROM Test2_tab b
    WHERE b.contract_id = a.contract_id
    AND b.date_from = a.period_from_date)
    Here the problem is I have used 'SELECT b.seq_no FROM Test2_tab b WHERE b.contract_id = a.contract_id AND b.date_from = a.period_from_date' twice, one in the SET clause and the other one in WHERE clause...But it is the same SELECT stmt...So this same Select stmt runs twice when I run the whole update stmt I guess. Is there a way to do the above update, where it runs the SELECT stmt only once...
    Any input is highly appreciated...
    Thanks And Best Regards,
    /Dinesh...

    Then you can use Merge statement instead.
    try this
    merge into test1_tab t1
    using
    (SELECT a.rowid,b.seq_no SEQ_DEST
    FROM test1_tab a,test2_tab b
    WHERE b.contract_id = a.contract_id
    AND  b.date_from = a.period_from_date
    AND a.invpln_seq_no != b.seq_no) t2
    ON (t1.rowid=t2.rowid)
    WHEN MATCHED THEN
    UPDATE SET t1.invpln_seq_no=t2.seq_destor if you are sure that sno is a unique key with out any duplicates and if you are going to perform one time manual update then you can use an undocumented hint /*+ bypass_ujvc */ to do this.
    *DO NOT include this code if you are about to add it in a production procedure or a function
    UPDATE /*+ bypass_ujvc */ (SELECT a.invpln_seq_no SEQ_SRC,b.seq_no SEQ_DEST FROM test1_tab a,test2_tab  b
    WHERE b.contract_id = a.contract_id
    AND  b.date_from = a.period_from_date
    AND a.invpln_seq_no != b.seq_no)
    SET SEQ_SRC = SEQ_DESTRegards,
    Prazy

  • Reg different kinds of select stmts

    Hi All,
    Hope all are doing gud,
    cud any tell me different kinds of select stmts ????
    regards,
    abc xyz

    hi,
    SELECT
    Basic form
    SELECT result [target] FROM source [where] [GROUP BY fields] [ORDER BY order].
    Effect
    Retrieves an extract and/or a set of data from a database table or view (see Relational database ). SELECT belongs to the OPEN SQL command set.
    Each SELECT command consists of a series of clauses specifying different tasks:
    The SELECT result clause specifies
    whether the result of the selection is a table or a single record,
    which columns the result is meant to have and
    whether the result is allowed to include identical lines.
    The INTO target clause specifies the target area into which the selected data is to be read. If the target area is an internal table, the INTO clause specifies
    whether the selected data is to overwrite the contents of the internal table or
    whether the selected data is to be appended to the contents and
    whether the selected data is to be placed in the internal table all at once or in several packets.
    The INTO clause can also follow the FROM clause.
    You can omit the INTO clause. The system then makes the data available in the table work area (see TABLES ) dbtab . If the SELECT clause includes a "*", the command is processed like the identical SELECT * INTO dbtab FROM dbtab statement. If the SELECT clause contains a list a1 ... an , the command is executed like SELECT a1 ... an INTO CORRESPONDING FIELDS OF dbtab FROM dbtab .
    If the result of the selection is meant to be a table, the data is usually (for further information, see INTO -Klausel ) read line by line within a processing loop introduced by SELECT and concluded by ENDSELECT . For each line read, the processing passes through the loop once. If the result of the selection is meant to be a single record, the closing ENDSELECT is omitted.
    The FROM source clause the source (database table or view ) from which the data is to be selected. It also determines
    the type of client handling,
    the behavior for buffered tables and
    the maximum number of lines to be read.
    The WHERE where clause specifies the conditions which the result of the selection must satisfy. It thus determines the lines of the result table. Normally - i.e. unless a client field is specified in the WHERE clause - only data of the current client is selected. If you want to select across other clients, the FROM clause must include the addition ... CLIENT SPECIFIED .
    The GROUP-BY fields clause combines groups of lines together into single lines. A group is a set of lines which contain the same value for every database field in the GROUP BY clause.
    The ORDER-BY order clause stipulates how the lines of the result table are to be ordered.
    Each time the SELECT statement is executed, the system field SY-DBCNT contains the number of lines read so far. After ENDSELECT , SY-DBCNT contains the total number of lines read.
    The return code value is set as follows:
    SY-SUBRC = 0 At least one line was read.
    SY_SUBRC = 4 No lines were read.
    SY-SUBRC = 8 The search key was not fully qualified.
    (nur bei SELECT SINGLE ). The returned single record is any line of the solution set.
    Example
    Output the passenger list for the Lufthansa flight 0400 on 28.02.1995:
    TABLES SBOOK.
    SELECT * FROM SBOOK
      WHERE
        CARRID   = 'LH '      AND
        CONNID   = '0400'     AND
        FLDATE   = '19950228'
      ORDER BY PRIMARY KEY.
      WRITE: / SBOOK-BOOKID, SBOOK-CUSTOMID,   SBOOK-CUSTTYPE,
               SBOOK-SMOKER, SBOOK-LUGGWEIGHT, SBOOK-WUNIT,
               SBOOK-INVOICE.
    ENDSELECT.
    Performance
    In client/server environments, storing database tables in local buffers (see SAP buffering ) can save considerable amounts of time because the time required to make an access via the network is much more than that needed to access a locally buffered table.
    Notes
    A SELECT command on a table for which SAP buffering is defined in the ABAP/4 Dictionary is normally satisfied from the SAP buffer by bypassing the database. This does not apply with
    - <b>SELECT SINGLE FOR UPDATE
    - SELECT DISTINCT in the SELECT clause ,
    - BYPASSING BUFFER in the FROM clause ,
    - ORDER BY f1 ... fn in the ORDER-BY clause ,
    - aggregate functions in the SELECT clause ,
    - when using IS [NOT] NULL WHERE condition ,</b>
    or if the generic key part is not qualified in the WHERE-Bedingung for a generically buffered table.
    Authorization checks are not supported by the SELECT statement, so you must program these yourself.
    In dialog systems, the database system locking mechanism cannot always guarantee to synchronize the simultaneous access of several users to the same dataset. In many cases, it is therefore advisable to use the SAP locking mechanism .
    Changes to data in a database are only finalized after a database commit (see LUW ). Prior to this, any database update can be reversed by a database rollback (see Programming transactions ). At the lowest isolation level (see the section on the "uncommitted read" under Locking mechanism ), this can result in the dataset selected by the SELECT command not really being written to the database. While a program is selecting data, a second program can add, change or delete lines at the same time. Then, the changes made by the second program are reversed by rolling back the database system. The selection of the first program thus reflects only a very temporary state of the database. If such "phantom data" is not acceptable for a program, you must either use the SAP locking mechanism or at least set the isolation level of the database system to "committed read" (see Locking mechanism ).
    In a SELECT-ENDSELECT loop, the CONTINUE statement terminates the current loop pass prematurely and starts the next.
    If one of the statements in a SELECT ... ENDSELECT loop results in a database commit, the cursor belonging to the SELECT ... ENDSELECT loop is lost and the processing terminates with a runtime error. Since each screen change automatically generates a database commit, statements such as CALL SCREEN , CALL DIALOG , CALL TRANSACTION or MESSAGE are not allowed within a SELECT ... ENDSELECT loop.
    Related OPEN CURSOR , FETCH und CLOSE CURSOR
    SELECT clause
    Variants
    1. <b>SELECT [SINGLE [FOR UPDATE] | DISTINCT] *
    2. SELECT [SINGLE [FOR UPDATE] | DISTINCT] s1 ... sn
    3. SELECT [SINGLE [FOR UPDATE] | DISTINCT] (itab)</b> Effect
    The result of a SELECT statement is itself a table . The SELECT clause describes which columns this table is supposed to have.
    In addition, you can use the optional addition SINGLE or DISTINCT if you want only certain lines of the solution set to be visible for the calling program:
    SINGLE The result of the selection is a single record . If this record cannot be uniquely identified, the first line of the solution set is selected. The addition FOR UPDATE protects the selected record against parallel changes by other transactions until the next database commit occurs (see LUW and Database locking ). If the database system detects a deadlock, the result is a runtime error.
    DISTINCT Any lines which occur more than once are automatically removed from the selected dataset.
    Note
    To ensure that a record is uniquely determined, you can fully qualify all fields of the primary key by linking them together with AND in the WHERE condition.
    Note
    Performance
    The additions SINGLE FOR UPDATE and DISTINCT exclude the use of SAP buffering .
    The addition DISTINCT requires sorting on the database server and should therefore only be specified if duplicates are likely to occur.
    Variant 1
    SELECT [SINGLE [FOR UPDATE] | DISTINCT] *
    Effect
    In the result set, the columns correspond exactly in terms of order, ABAP/4 Dictionary type and length to the fields of the database table (or view ) specified in the FROM clause .
    Example
    Output all flight connections from Frankfurt to New York:
    TABLES SPFLI.
    SELECT * FROM SPFLI
             WHERE
               CITYFROM = 'FRANKFURT' AND
               CITYTO   = 'NEW YORK'.
      WRITE: / SPFLI-CARRID, SPFLI-CONNID.
    ENDSELECT.
    Example
    Output all free seats on the Lufthansa flight 0400 on 28.02.1995:
    TABLES SFLIGHT.
    DATA   SEATSFREE TYPE I.
    SELECT SINGLE * FROM SFLIGHT
                    WHERE
                      CARRID   = 'LH '      AND
                      CONNID   = '0400'     AND
                      FLDATE   = '19950228'.
    SEATSFREE = SFLIGHT-SEATSMAX - SFLIGHT-SEATSOCC.
    WRITE: / SFLIGHT-CARRID, SFLIGHT-CONNID,
             SFLIGHT-FLDATE, SEATSFREE.
    Variant 2
    SELECT [SINGLE [FOR UPDATE] | DISTINCT] s1 ... sn
    Effect
    The order, ABAP/4 Dictionary type and length of the columns of the result set are explicitly defined by the list s1 ... sn . Each si has the form
    ai or ai AS bi .
    Here, ai stands either for
    a field f of the database table or
    a aggregate print.
    bi is an alternative name for the i-th column of the result set.
    When using INTO CORRESPONDING FIELDS OF wa in the INTO clause , you can specify an alternative column name to assign a column of the result set uniquely to a column of the target area.
    An aggregate print uses an aggregate function to group together data from one or all columns of the database table. Aggregate prints consist of three or four components:
    An aggregate function immediately followed by an opening parenthesis DISTINCT (optional) The database field f A closing parenthesis
    All components of a print must be separated by at least one blank.
    The following aggregate functions are available:
    MAX Returns the greatest value in the column determined by the database field f for the selected lines. Specifying DISTINCT does not change the result. NULL values are ignored unless all values in a column are NULL values. In this case, the result is NULL .
    MIN Returns the smallest value in the column determined by the database field f for the selected lines. Specifying DISTINCT does not change the result. NULL values are ignored unless all values in a column are NULL values. In this case, the result is NULL .
    AVG Returns the average value in the column determined by the database field f for the selected lines. AVG can only apply to a numeric field. NULL values are ignored unless all values in a column are NULL values. In this case, the result is NULL .
    SUM Returns the sum of all values in the column determined by the database field f for the selected lines. SUM can only apply to a numeric field. NULL values are ignored unless all values in a column are NULL values. In this case, the result is NULL .
    COUNT Returns the number of different values in the column determined by the database field f for the selected lines. Specifying DISTINCT is obligatory here. NULL values are ignored unless all values in a column are NULL values. In this case, the result is 0
    COUNT( * ) Returns the number of selected lines. If the SELECT command contains a GROUP BY clause , it returns the number of lines for each group. The form COUNT(*) is also allowed.
    If ai is a field f , MAX( f ) , MIN( f ) or SUM( f ) , the corresponding column of the result set has the same ABAP/4 Dictionary format as f . With COUNT( f ) or COUNT( * ) , the column has the type INT4 , with AVG( f ) the type FLTP .
    If you specify aggregate functions together with one or more database fields in a SELECT clause, all database fields not used in one of the aggregate functions must be listed in the GROUP-BY clause . Here, the result of the selection is a table.
    If only aggregate functions occur in the SELECT clause, the result of the selection is a single record. Here, the SELECT command is not followed later by an ENDSELECT .
    Notes
    This variant is not available for pooled tables and cluster tables .
    If the SELECT clause contains a database field of type LCHAR or LRAW , you must specify the appropriate length field immediately before.
    Notes
    Performance
    Specifying aggregate functions excludes the use of SAP buffering .
    Since many database systems do not manage the number of table lines and therefore have to retrieve this at some cost, the function COUNT( * ) is not suitable for checking whether a table contains a line or not. To do this, it is best to use SELECT SINGLE f ... for any table field f .
    If you only want to select certain columns of a database table, you are recommended to specify a list of fields in the SELECT clause or to use a View .
    Examples
    Output all flight destinations for Lufthansa flights from Frankfurt:
    TABLES SPFLI.
    DATA   TARGET LIKE SPFLI-CITYTO.
    SELECT DISTINCT CITYTO
           INTO TARGET FROM SPFLI
           WHERE
             CARRID   = 'LH '       AND
             CITYFROM = 'FRANKFURT'.
      WRITE: / TARGET.
    ENDSELECT.
    Output the number of airline carriers which fly to New York:
    TABLES SPFLI.
    DATA   COUNT TYPE I.
    SELECT COUNT( DISTINCT CARRID )
           INTO COUNT FROM SPFLI
           WHERE
             CITYTO = 'NEW YORK'.
    WRITE: / COUNT.
    Output the number of passengers, the total weight and the average weight of luggage for all Lufthansa flights on 28.02.1995:
    TABLES SBOOK.
    DATA:  COUNT TYPE I, SUM TYPE P DECIMALS 2, AVG TYPE F.
    DATA:  CONNID LIKE SBOOK-CONNID.
    SELECT CONNID COUNT( * ) SUM( LUGGWEIGHT ) AVG( LUGGWEIGHT )
           INTO (CONNID, COUNT, SUM, AVG)
           FROM SBOOK
           WHERE
             CARRID   = 'LH '      AND
             FLDATE   = '19950228'
           GROUP BY CONNID.
      WRITE: / CONNID, COUNT, SUM, AVG.
    ENDSELECT.
    Variant 3
    SELECT [SINGLE [FOR UPDATE] | DISTINCT] (itab)
    Effect
    Works like SELECT [SINGLE [FOR UPDATE] | DISTINCT] s1 ... sn if the internal table itab contains the list s1 ... sn as ABAP/4 source code, and like SELECT [SINGLE [FOR UPDATE] | DISTINCT] * , if itab is empty. The internal table itab can only have one field which must be of type C and cannot be more than 72 characters long. itab must appear in parentheses and there should be no blanks between the parentheses and the table name.
    Note
    With this variant, the same restrictions apply as for SELECT [SINGLE [FOR UPDATE] | DISTINCT] s1 ... sn .
    Example
    Output all Lufthansa flight routes:
    TABLES: SPFLI.
    DATA:   FTAB(72) OCCURS 5 WITH HEADER LINE.
    REFRESH FTAB.
    FTAB = 'CITYFROM'. APPEND FTAB.
    FTAB = 'CITYTO'.   APPEND FTAB.
    SELECT DISTINCT (FTAB)
           INTO CORRESPONDING FIELDS OF SPFLI
           FROM SPFLI
           WHERE
             CARRID   = 'LH'.
      WRITE: / SPFLI-CITYFROM, SPFLI-CITYTO.
    ENDSELECT.
    check this one:
    http://www.sts.tu-burg.de/teaching/sap_r3/ABAP4/select.htm

  • Problem in Select stmt in loop

    Hi all,
    Pls provide your suggestions for the following code.
    LOOP at ITAB.
    select * from zxyz into corresponding fields of table ITAB_FINAL
    where fromdate eq date1
              todate eq date2
              MATNR eq ITAB-matnr.
    ENDLOOP.
    My question is that for a particular entry in itab , select stmt is executed and some 5 to 6 line item is selected into itab_final. Now in second loop , again select stmt is executed and again some line item will be selected , BUT will this selection will replace the earlier entry in ITAB_FINAL OR the entry in SUCCESSIVE loop will be APPENDED ?
    Please suggest your valuable suggestion on this problem
    Thanks in advance,
    Regards,
    Vivek

    Hi,
    There is no need to loop if you are using FOR ALL ENTRIES
    select * from zxyz into corresponding fields of table ITAB_FINAL
    for all entries in itab
    where matnr eq itab-matnr
    and fromdate eq date1
    and todate eq date2.

  • Select stmt taking long time.

    Hi,
    This select stmt is taking very long time to execute. Can you please guide me to improve it.
    SELECT LIKPVBELN LIKPLFDAT LIKPKUNNR LIKPKNKLI VBAK~NETWR
              FROM LIKP
              INNER JOIN LIPS ON LIKPVBELN = LIPSVBELN
              INNER JOIN VBAK ON LIPSVGBEL = VBAKVBELN
              INTO CORRESPONDING FIELDS OF TABLE IT_OUTPUT
              WHERE LIKP~LFDAT IN S_LFDAT
                    AND LIKP~KUNNR IN S_KUNNR
                    AND LIKP~LIFSK = P_LIFSK.
    Thanks
    Veni.

    >> SELECT LIKPVBELN LIKPLFDAT LIKPKUNNR LIKPKNKLI VBAK~NETWR
    >> FROM LIKP
    >> INNER JOIN LIPS ON LIKPVBELN = LIPSVBELN
    >> INNER JOIN VBAK ON LIPSVGBEL = VBAKVBELN
    >> INTO CORRESPONDING FIELDS OF TABLE IT_OUTPUT
    >> WHERE LIKP~LFDAT IN S_LFDAT
    >> AND LIKP~KUNNR IN S_KUNNR
    >> AND LIKP~LIFSK = P_LIFSK.
    Based on the select that you have in your post, this is what I see.
    As output, you only need fields from LIKP and only one field from VBAK.
    All your fields on the WHERE clause is on LIKP data.
    You only need LIPS for the Sales document number.
    Can you please make a copy of your program and try this below code?
    It would be interesting to see if the extra vgbel sort would help.
    TYPES:
      BEGIN OF TY_LIKP,
        VBELN TYPE LIKP-VBELN,
        LFDAT TYPE LIKP-LFDAT,
        KUNNR TYPE LIKP-KUNNR,
        KNKLI TYPE LIKP-KNKLI,
        NETWR TYPE VBAK-NETWR,
        VGBEL TYPE LIPS-VGBEL,
      END OF TY_LIKP.
    DATA:
      I_LIKP TYPE STANDARD TABLE OF TY_LIKP
        INITIAL SIZE 0
        WITH HEADER LINE,
      BEGIN OF I_VGBEL OCCURS 0,
        VGBEL TYPE LIPS-VGBEL,
      END OF I_VGBEL,
      BEGIN OF I_VBAK OCCURS 0,
        VBELN TYPE VBAK-VBELN,
        NETWR TYPE VBAK-NETWR,
      END OF I_VBAK.
    FIELD-SYMBOLS:
      <FS_LIKP> TYPE TY_LIKP.
    SELECT LIKP~VBELN LIKP~LFDAT LIKP~KUNNR LIKP~KNKLI LIPS~VGBEL
      INTO CORRESPONDING FIELDS OF TABLE I_LIKP
      FROM LIKP
      JOIN LIPS ON LIPS~VBELN EQ LIKP~VBELN
      WHERE LIKP~LFDAT IN S_LFDAT
      AND   LIKP~KUNNR IN S_KUNNR
      AND   LIKP~LIFSK EQ P_LIFSK.
    IF I_LIKP[] IS NOT INITIAL.
      LOOP AT I_LIKP ASSIGNING <FS_LIKP>.
        CLEAR I_VGBEL.
        I_VGBEL-VGBEL = <FS_LIKP>-VGBEL.
        APPEND I_VGBEL.
      ENDLOOP.
      SORT I_VGBEL.
      DELETE ADJACENT DUPLICATES FROM I_VGBEL.
      IF I_VGBEL[] IS NOT INITIAL.
        SELECT VBELN NETWR INTO TABLE I_VBAK
          FROM VBAK
          FOR ALL ENTRIES IN I_VGBEL
          WHERE VBELN EQ I_VGBEL-VGBEL.
        SORT I_VBAK BY VBELN.
        FREE I_VGBEL.
        LOOP AT I_LIKP ASSIGNING <FS_LIKP>.
            CLEAR I_VBAK.
            READ TABLE I_VBAK WITH KEY VBELN = <FS_LIKP>-VGBEL
                                       BINARY SEARCH.
            IF SY-SUBRC EQ 0.
              <FS_LIKP>-NETWR = I_VBAK-NETWR.
    * Note that you don't need to do the Modify statement here
    * because of the field symbol
            ENDIF.
          ENDIF.
        ENDLOOP.
    * Just ignore I_LIKP-VGBEL from all your reporting needs
      ENDIF.
    ENDIF.

  • Count (*)  for select stmt take more time than  execute a that sql stmt

    HI
    count (*) for select stmt take more time than execute a that sql stmt
    executing particular select stmt take 2.47 mins but select stmt is using the /*+parallel*/ (sql optimer) in that sql  command for faster execute .
    but if i tried to find out total number of rows in that query it takes more time ..
    almost 2.30 hrs still running to find count(col)
    please help me to get count of row faster.
    thanks in advance...

    797525 wrote:
    HI
    count (*) for select stmt take more time than execute a that sql stmt
    executing particular select stmt take 2.47 mins but select stmt is using the /*+parallel*/ (sql optimer) in that sql  command for faster execute .
    but if i tried to find out total number of rows in that query it takes more time ..
    almost 2.30 hrs still running to find count(col)
    please help me to get count of row faster.
    thanks in advance...That may be because your client is displaying only the first few records when you are running the "SELECT *". But when you run "COUNT(*)", the whole records has to be counted.
    As already mentined please read teh FAQ to post tuning questions.

  • Select stmt offset - how can I use select stmt to fetch data.

    kna1-name2 contains store#XXXXXXX where XXXXXXX is a store number.  example : store#3564261.
    I must fetch this.  how can i fetch this ?
    Can I use
    WHERE substr(name2,7,10) CS gt_soldto1-store_no
    or can I use
    WHERE name2+7(10) CS gt_soldto1-store_no
    along with for all entries IN gt_soldto1
    in the below select stmt.
        *SELECT *               
          FROM kna1
          INTO corresponding fields of TABLE gt_kna1
         FOR ALL ENTRIES IN gt_soldto1
          WHERE substr(name2,7,10) as gt_soldto1-store_no
          OR      j_3astcu    = gt_soldto1-store_no
    THANKS IN ADV

    Easiest way would be to create another field in your table gt_soldto1 as NAME2.
    update all entries in gt_SOLD2-NAME2 as  cocatenation of  'store#' + gt_SOLD2-STORE_no
    then use your select statment
    SELECT *
    FROM kna1
    INTO corresponding fields of TABLE gt_kna1
    FOR ALL ENTRIES IN gt_soldto1
    WHERE  NAME2 =   gt_soldto1-name2

  • How to convert update,delete statement into select stmt

    Hi all,
         I have a field called dml_stmt, i am getting the dml statement has input from the user.
         My requirement is, if user is giving "update set col_name = 'xyz' from table_name where codition = 'aa'", before updating the table, i need to get old values from the table and put it in the audit table
         For that,i need to convert those update statement into select stmt and need to execute the query to get the data and then i will put it in the audit table..
         can anyone guide how to convert the update or delete stmt into select(need to write in pl/sql)
    Please do needfull things ......
    Regards,
    Jame

    Maybe I'm missing something, but why would auditing help here? It sounds like the user wants to know the prior values of the data, not the SQL UPDATE statement that was issued. Auditing would tell you that a table was updated, fine-grained auditing would tell you what the UPDATE statement was, but you'd need something else to capture the state of the data prior to the update.
    Depending on why putting triggers on every table was discounted, you may also want to take a look at using Workspace Manager or Total Recall (in 11g) to track a history of data changes. But triggers would be the common solution to this sort of problem.
    Justin

  • Error  with select stmt.

    Hi All,
    I am getting this error , can you please tell me what I am doing wrong with the select stmt.
    SELECT AFKDAT ANETWR B~KZWI1
                         FROM VBRK AS A INNER JOIN VBRP AS B ON
                              AVBELN = BVBELN
                              INTO (IOUT-FKDAT, IOUT-NETWR, IOUT-KZWI1)
                              WHERE B~VBELN = IOUT-VBELV
                              AND   B~POSNR = ISDOC-POSNR.
    Incorrect nesting: Before the statement "ENDIF", the structure          
    introduced by "SELECT" must be concluded by "ENDSELECT". -
    Thanks
    Veni.

    Hi All,
    I tried INTO CORRESPONDING FIELDS OF IOUT
    but with this also same error is comming. I am sending part of code.
    Please help me.
    Thanks
    Veni.
    TABLES: VBAK, VBAP, KNA1, VBRK, VBRP, VBFA.
    DATA: BEGIN OF ISDOC OCCURS 0,
            VBELN LIKE VBAK-VBELN,
            POSNR LIKE VBAP-POSNR,
            KUNNR LIKE VBAK-KUNNR,
            ERDAT LIKE VBAK-ERDAT,
            BSTNK LIKE VBAK-BSTNK,
            MATNR LIKE VBAP-MATNR,
            ARKTX LIKE VBAP-ARKTX.
    DATA: END OF ISDOC.
    DATA: BEGIN OF IOUT OCCURS 0,
            VBELN LIKE VBAK-VBELN,
            POSNR LIKE VBAP-POSNR,
            KUNNR LIKE VBAK-KUNNR,
            NAME1 LIKE KNA1-NAME1,
            ERDAT LIKE VBAK-ERDAT,
            BSTNK LIKE VBAK-BSTNK,       
            MATNR LIKE VBAP-MATNR,
            ARKTX LIKE VBAP-ARKTX,
            VBELV LIKE VBRP-VBELN,
            FKDAT LIKE VBRK-FKDAT,
            NETWR LIKE VBRK-NETWR,
            KZWI1 LIKE VBRP-KZWI1.
    DATA: END OF IOUT.
    FORM getdata.
      SELECT A~VBELN B~POSNR A~KUNNR A~ERDAT A~BSTNK B~MATNR B~ARKTX
             FROM VBAK AS A INNER JOIN VBAP AS B ON A~VBELN = B~VBELN
             INTO TABLE ISDOC
             WHERE A~AUART IN SAUART
             AND A~ERDAT IN SERDAT
             AND A~KUNNR IN SKUNNR.
               SORT ISDOC BY VBELN POSNR.
      LOOP AT ISDOC.
        MOVE-CORRESPONDING ISDOC TO IOUT.
        CLEAR: KNA1.
        SELECT SINGLE * FROM KNA1 WHERE KUNNR = ISDOC-KUNNR.
        IF SY-SUBRC = 0.
          MOVE KNA1-NAME1 TO IOUT-NAME1.
        ENDIF.
        SELECT VBELN INTO IOUT-VBELV FROM VBFA WHERE VBELV = ISDOC-VBELN
                                               AND   POSNV = ISDOC-POSNR
                                               AND   VBTYP_N = 'O'.
          IF SY-SUBRC = 0.
            SELECT A~FKDAT A~NETWR B~KZWI1
                   FROM VBRK AS A INNER JOIN VBRP AS B ON A~VBELN = B~VBELN
                   INTO CORRESPONDING FIELDS OF IOUT
    *               (IOUT-FKDAT, IOUT-NETWR, IOUT-KZWI1)
                         WHERE B~VBELN = IOUT-VBELV
                         AND   B~POSNR = ISDOC-POSNR.
              APPEND IOUT.
              CLEAR IOUT.
            ENDIF.
          ENDLOOP.
        ENDFORM.                    " getdata

  • RE: Using BAPI in place of select stmt..

    Hi Experts,
    We alway use Select stmt to fetch the datas and display it, so is there any way to use available BAPI's  to select data and display the resultant output?if so can you given one simple example...

    1. Did you ever re-visited your queries
    Total Questions:  32 (30 unresolved) 
    I will suggest to close them by rewarding/answering with your solutions, if they are solved.
    2. Seeing your queries I dont think, you try to search the forum before posting a query. Start using it from today.
    3. Read rules of engagements before posting queries.
    Now for this one, if you search for BAPIs, their usage and their documentation you can understand this one by yourself.

  • Query on select stmt

    hi,
    below is the extraction logic
    1.     Select all invoice documents from Table VBRK where Sales Organization VBRK-VKORG, Distribution Channel VBRK- VTWEG and Division VBRK-SPART matches to Sales Organization, Distribution Channel and Division specified in the selection parameters and SD Document Catergory VBRK- VBTYP <> N u2013 Invoice Cancellation type S1 and S2.
    2.     Select all invoice documents from the above where all Sold-to party/Ship-to party customers VBRK-KUNAG and payer customers VBRK-KUNRG matches to Sold-to party/Ship-to party and payer specified in the selection parameters
    how to write the select stmts for the abluve logic??.
    thank you in advance.

    Hi.
    I will lock this thread. This is not a question that should be discussed in this forum. Your specification is so close to real code that even without any ABAP knowledge a look into some demo programs and the online help for 'SELECT' will solve it.
    As Martin said: If you tried it and have any particular problems then we can discuss them here.
    Best regards,
    Jan Stallkamp

  • Entity remove triggering select stmts on private owned relationships

    Hi All,
    When ever we do an entityManager.remove on an entity and commit, the eclipse link is doing a realAllQuery.execute (Select stmt) on each of the privateOwned entities of the given entity(irrespective of whether they are present or not) before actually deleting them .
    This is very much redundant especially if there are large number of entities to delete/cascade delete and each has multiple number of private owned rels - Lots of SELECT SQls , and time taken for these select sqls is very much higher than actual delete stmts. Is there a way to remove the private owned rels without selecting them.
    We are using the ecliselink 2.3.1 version.
    BTW
    This readAllQuery.execute on private owned entitites is triggered during CollectionMapping.recordPrivateOwnedRemovals method of eclipse link during commit.
    Any Input or suggestion greatly appreciated.
    Thanks,
    Sriram

    EclipseLink needs to load an object's private owned relationship to delete the objects, otherwise it does not know which objects to delete.
    The private owned objects can have their own private owned objects and dependent relationships that need to be deleted as well.
    EclipseLink does perform a delete-all optimization for a privately owned OneToMany where the target does not have any dependent relationships (or inheritance/multiple tables/ locking).
    This will occur for a simple OneToMany but most have relationships of their own that prevents the optimization.
    This optimization can also be configured using the @DeleteAll annotation.
    EclipseLink also supports delete cascading on the database, if you have created your foreign key constraint to cascade on delete, or are using EclipseLink to create your schema.
    If you use @CascadeOnDelete, then the related objects should not be loaded.
    If you still think you have more SQL than you think is correct, please include your object model code, and the SQL log for the delete.

  • Updating results of a select stmt

    Hello gurus,
    Can anybody throw some light on the usage of the following update stmt, in terms of its perfomance ?
    "UPDATE (&lt;SELECT stmt&gt;)
    SET &lt; column &gt; = &lt; value &gt;
    WHERE &lt; column &gt; &lt; condition &gt;"
    In my case, the select stmt that I plan is use is a join of 6 tables & it looks something like this :
    UPDATE (
    select t2.order_id, t1.price,t5.discount, t4.original_price
    from table1 t1, table2 t2, table3 t3, table4 t4, table5 t5, table6 t6
    where t1.order_loc_id = t2.order_loc_id
    and t1.prod_id = t4.prod_id
    and t1.prod_id = t5.prod_id
    and t5.id = t6.id
    and t3.id = t6.hdr_nbr
    and t3.order_id = t2.order_id
    and round((t1.price+t5.discount),2) &gt; round(t4.original_price,2)
    and t4.invnm = 'INVN'
    and t2.order_id = 6
    ) p
    SET p.price = (p.original_price - p.discount)
    WHERE p.order_id = 6;
    I was wondering if this stmt would be hv any performance issue ?
    Also, would all the tables in the select hv a lock on them ? (not quite sure how the table/row get locked) ?
    Regards,
    Madhu.

    You don't need the WHERE order_id = 6 in your outer statement as it's also in the inner statement.
    Also, you must have all the proper primary key or unique indexes in place or you will get the "...maps to non-key preserved table" error.
    I was wondering if this stmt would be hv any performance issue ?There's no way we can tell. You have to post explain plans and traces. Same as any other sql statement.

  • Select stmt issue, performance tuning.

    Hi Group,
    I have a question.
    There is a select stmt which is using inner join, and its taking good amoutn of time to get executed. I was told to tune the performance of that query. And my TL suggested me to use ranges in that select stmt, like the sign, option, low, high.
    Could you please help me out on this issue? Urgent.
    Thank you in advance.
    Regards,
    P. Varun Kumar.

    They are suggesting to use ranges rather than For all entries.
    Here is the query:
    SELECT b~kunnr
             b~zz_echan_reg
             a~title
             a~first_name
             a~last_name
             a~email_addr INTO TABLE gt_ecustomers
                          FROM zyd_contacts AS a
                         INNER JOIN kna1 AS b
                            ON ayd_kunnr = bkunnr
                         WHERE zz_echan_reg EQ 'X' OR zz_echan_reg EQ 'A'
                           AND zzcap_divert EQ space
                           AND email_addr   NE space.
    Please check this out.
    Thanks again for any help in advance.

Maybe you are looking for

  • Crystal Report error exporting to Word

    My company recently deployed a Microsoft Security Patch to our workstations that's causing a problem with Crystal Reports. When exporting a Crystal report to a Word file (from a VB 6 application) the following error is generated when opening the file

  • Firefox mobile does not work in Samsung Fascinate, only get a blank screen for any search.

    I downloaded Firefox Mobile to my Samsung Fascinate. I had no problem with the download or installation. When I tried to do a search, all I got was a blank screen in the Firefox window. The Samsung Fascinate is set up to run only Bing. It does not li

  • Update to RoboHelp Dropping all Files/Content

    Hi, My colleague has now encountered the same problem as I described here: http://forums.adobe.com/message/5300528#5300528 Here is the content of her report: "A similar problem that happened earlier to Derek is now happening to me. I was generating t

  • Interaction Center  sorting

    Hi frnds,   I have an issue.  Currently the Agent Inbox is displaying 300 items in descending order of creation date ( recent date first ). But the issue is that the search is picking up the last 300 items , ignoring others and displaying them in des

  • HCM F&P: Error in process object reading

    Hi Experts, I am working on Employee Transfer scenario. So I copied the standard Process ORG_CHANGE and made the changes in Workflow, Form scenario and Form according to my reqirement . But when the Reciever manager opens the form it is throwing one