Problem in select  statment & loop of itab.

Hi all,
      I am having on ITAB1  for, ex which is having five line items or more  .
iam also using select statment SINGLE statment for 7 times ,to select values for
different data base  table.
for ex,
loop at itab.
   1---> SELECT SINGLE Z_CTRY_ORIG INTO LS_PSHDESN-Z_CTRY_ORIG FROM ZLE_PART_MST
  WHERE                           WERKS        = ITAB1-LGNUM
  AND                                 MATNR        = ITAB1-MATNR .
2---
3---
4---
endloop
i want to remove from the loop statment  and i have to select  the datas ..
can any one sugesset some possible ways....
regards
veera

hi,
Solution:
Never use select single in loop at itab!! for that :
Solution 1:
say ur main table is ITAB and rferring  this u want to select data from other tables.
SELECT SINGLE Z_CTRY_ORIG INTO LS_PSHDESN-Z_CTRY_ORIG FROM ZLE_PART_MST
into table itab2
FOR ALL ENTRIES IN ITAB
WHERE WERKS = ITAB-LGNUM
AND MATNR = ITAB-MATNR.
With this what will hapeen , u will get all records in itab2 which u can update itab1(master) using loop.
solution 2:
Instead of all this use JOINs in select statement properly and u can fetch data in one shot this will reduce database load as well as abap load ( More than 3 joins in SELECT stmt  are not recommeded but can be used)
I believe this is perfect solution if and only if u are giving joins on KEY fields only.  Same is applied for wherer clause.
Hope this will help u, if not revert.
Jogdand M B

Similar Messages

  • Problem in Select Statment

    I have two tables
    <b>TAB1</b>
    <u>F1</u>     <u>F2</u>
    A1     AA
    A2     AA
    A3     BB
    A4     AA
    A5     AA
    <b>TAB2</b>
    <u>F1</u>     <u>F2</u>     <u>F3</u>
    B1     AA     D1
    B2     BB     D1
    B3     CC     D1
    B4     AA     D2
    B5     AA     D3
    B6     BB     D1
    B7     AA     D1
    B8     DD     D1
    I use following statement
    Select F1 from TAB1 where TAB1.F2 in (Select F2 from TAB2)
    It’s working properly with my requirement.
    My problem is now I want to get field F1 in TAB2 also. How can I get this?
    Finally I needed result is
    T<u>AB1-F1</u>     <u>TAB2-F1</u>
    A1          B1     
    A2          B1
    A3          B2
    A4          B1
    A5          B1
    Basically I want,  when TAB1-F2  data in TAB2-F2 field I want get TAB2-F1 field also.

    hi Nelson.
    Syntax
    ... [(] {dbtab_left [AS tabalias_left]} | join
    {[INNER] JOIN}|{LEFT [OUTER] JOIN}
    {dbtab_right [AS tabalias_right] ON join_cond} [)] ... .
    Effect
    The join syntax represents a recursively nestable join expression. A join expression consists of a left-hand and a right- hand side, which are joined either by means of [INNER] JOIN or LEFT [OUTER] JOIN . Depending on the type of join, a join expression can be either an inner ( INNER) or an outer (LEFT OUTER) join. Every join expression can be enclosed in round brackets. If a join expression is used, the SELECT command circumvents SAP buffering.
    On the left-hand side, either a single database table, a view dbtab_left, or a join expression join can be specified. On the right-hand side, a single database table or a view dbtab_right as well as join conditions join_cond can be specified after ON. In this way, a maximum of 24 join expressions that join 25 database tables or views with each other can be specified after FROM.
    AS can be used to specify an alternative table name tabalias for each of the specified database table names or for every view. A database table or a view can occur multiple times within a join expression and, in this case, have various alternative names.
    The syntax of the join conditions join_cond is the same as that of the sql_cond conditions after the addition WHERE, with the following differences:
    At least one comparison must be specified after ON.
    Individual comparisons may be joined using AND only.
    All comparisons must contain a column in the database table or the view dbtab_right on the right-hand side as an operand.
    The following language elements may not be used: BETWEEN, LIKE, IN.
    No sub-queries may be used.
    For outer joins, only equality comparisons (=, EQ) are possible.
    If an outer join occurs after FROM, the join condition of every join expression must contain at least one comparison between columns on the left-hand and the right-hand side.
    In outer joins, all comparisons that contain columns as operands in the database table or the view dbtab_right on the right-hand side must be specified in the corresponding join condition. In the WHERE condition of the same SELECT command, these columns are not allowed as operands.
    Resulting set for inner join
    The inner join joins the columns of every selected line on the left- hand side with the columns of all lines on the right-hand side that jointly fulfil the join_cond condition. A line in the resulting set is created for every such line on the right-hand side. The content of the column on the left-hand side may be duplicated in this case. If none of the lines on the right-hand side fulfils the join_cond condition, no line is created in the resulting set.
    Resulting set for outer join
    The outer join basically creates the same resulting set as the inner join, with the difference that at least one line is created in the resulting set for every selected line on the left-hand side, even if no line on the right-hand side fulfils the join_cond condition. The columns on the right-hand side that do not fulfil the join_cond condition are filled with null values.
    Example
    Join the columns carrname, connid, fldate of the database tables scarr, spfli and sflight by means of two inner joins. A list is created of the flights from p_cityfr to p_cityto. Alternative names are used for every table.
    PARAMETERS: p_cityfr TYPE spfli-cityfrom,
    p_cityto TYPE spfli-cityto.
    DATA: BEGIN OF wa,
    fldate TYPE sflight-fldate,
    carrname TYPE scarr-carrname,
    connid TYPE spfli-connid,
    END OF wa.
    DATA itab LIKE SORTED TABLE OF wa
    WITH UNIQUE KEY fldate carrname connid.
    SELECT ccarrname pconnid f~fldate
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM ( ( scarr AS c
    INNER JOIN spfli AS p ON pcarrid = ccarrid
    AND p~cityfrom = p_cityfr
    AND p~cityto = p_cityto )
    INNER JOIN sflight AS f ON fcarrid = pcarrid
    AND fconnid = pconnid ).
    LOOP AT itab INTO wa.
    WRITE: / wa-fldate, wa-carrname, wa-connid.
    ENDLOOP.
    Example
    Join the columns carrid, carrname and connid of the database tables scarr and spfli using an outer join. The column connid is set to the null value for all flights that do not fly from p_cityfr. This null value is then converted to the appropriate initial value when it is transferred to the assigned data object. The LOOP returns all airlines that do not fly from p_cityfr.
    PARAMETERS p_cityfr TYPE spfli-cityfrom.
    DATA: BEGIN OF wa,
    carrid TYPE scarr-carrid,
    carrname TYPE scarr-carrname,
    connid TYPE spfli-connid,
    END OF wa,
    itab LIKE SORTED TABLE OF wa
    WITH NON-UNIQUE KEY carrid.
    SELECT scarrid scarrname p~connid
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM scarr AS s
    LEFT OUTER JOIN spfli AS p ON scarrid = pcarrid
    AND p~cityfrom = p_cityfr.
    LOOP AT itab INTO wa.
    IF wa-connid = '0000'.
    WRITE: / wa-carrid, wa-carrname.
    ENDIF.
    ENDLOOP.
    we r using 2 type of joins in abap they are
    1) inner join.
    this will join 2 tables using an common fiend and return the result with field values wich are common in both the tables
    itab1 itab2
    a b c a d
    1 2 3 1 5
    2 3 4 3 6
    after innerjoining itab1 n itab2 on field a we wil get the o/p as
    a b c d
    1 2 3 5
    only common field is taken..
    2)left outer join
    here it wil work in opossite way it will give values whic are not common
    itab1 itab2
    a b c a d
    1 2 3 1 5
    2 3 4 3 6
    after left outer joining itab1 n itab2 on field a we wil get the o/p as
    a b c d
    2 3 4
    only fields which are not common is taken from the left table..other field(d here) wil be empty
    I think it will help u.
    Reward Points if helpful.
    regards,
    Amber s

  • Problem in select statment writing

    Hi,
    I have two tables.
    P_PLAN_ITEM_DTL --> A table
    P_SCHDLE_ITEM_UPLOAD --> B table
    A and B tables contain same structure.
    A table contain Lot of records. B contain data or may not contanain data.
    If B contain records then data should filter based on B table
    If B contain doest not contain records then data should come from A table.
    Please do the needful.

    Hi,
    MST wrote:
    Hi,
    I have two tables.
    P_PLAN_ITEM_DTL --> A table
    P_SCHDLE_ITEM_UPLOAD --> B table
    A and B tables contain same structure.
    A table contain Lot of records. B contain data or may not contanain data.
    If B contain records then data should filter based on B table
    If B contain doest not contain records then data should come from A table.That sounds like a job for an outer join, and the NVL (or COALESCE) function.
    See {message:id=9360002}

  • 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.

  • Performace problem in a select statment how to imporve the performance

    fist select statment
    SELECT    a~extno
              a~guid_lclic       " for next select
              e~ctsim
              e~ctsex
    *revised spec 3rd
              f~guid_pobj
              f~amnt_flt
              f~amcur
              f~guid_mobj
              e~srvll     "pk
              e~ctsty     "PK
              e~lgreg  "PK
      INTO TABLE gt_sagmeld
      FROM /SAPSLL/LCLIC  as a
      INNER JOIN /sapsll/tlegsv as e on elgreg = algreg
    * revised spec 3rd
      inner join /sapsll/legcon as f on fguid_lclic = aguid_lclic   " for ccngn1 selection
      inner join /sapsll/corcts as g on gguid_pobj = fguid_pobj
                               where   a~extno in s_extno.
      sort gt_sagmeld by guid_lclic guid_pobj.
    lgreg ctsty srvll
      delete adjacent duplicates from gt_sagmeld comparing guid_lclic guid_pobj.
    it selects about 20 lakh records
    belos select statment whichs is taking time as it is based on the entreis of gt_sagmeld
    select /sapsll/corpar~guid_mobj
                /sapsll/corpar~PAFCT
                but000~bpext
                but000~partner
                /sapsll/corpar~parno
                into table gt_but001
        from    /sapsll/corpar
        INNER join but000  on  but000partner = /sapsll/corparparno
        for all entries in gt_sagmeld
        where  /sapsll/corpar~guid_mobj = gt_sagmeld-guid_mobj
        and    /sapsll/corpar~PAFCT = 'SH'.
       SELECT /sapsll/cuit~guid_cuit         " PK
              /sapsll/cuit~QUANT_FLT         " to be displayed
              /sapsll/cuit~QUAUM             " to be displayed
              /sapsll/cuit~RPTDT             " to be displayed
             /sapsll/cuhd~guid_cuhd         " next select
              /sapsll/cuit~guid_pr           " next select
      INTO table gt_sapsllcuit
      FROM  /sapsll/cuit
    inner join /sapsll/cuhd on /sapsll/cuitguid_cuhd = /sapsll/cuhdguid_cuhd
      FOR all entries in gt_sagmeld
      WHERE /sapsll/cuit~guid_cuit = gt_sagmeld-guid_pobj.
      Delete adjacent duplicates from gt_sapsllcuit[].
           if not gt_sapsllcuit[] is initial.

    hi navenet
    that didnt worked
    we need to try ur range options
    but not sure what you told in the last mail as not clear with range can u pls eloboragte more i am pasting the full code here
    SELECT     a~extno
               a~guid_lclic       " for next select but000
               e~ctsim
               e~ctsex
               e~srvll
               e~ctsty
               e~lgreg
      INTO TABLE gt_sagmeld
      FROM /SAPSLL/LCLIC  as a
      INNER JOIN /sapsll/tlegsv as e on elgreg = algreg
                               where   a~extno in s_extno.
    sort gt_sagmeld by guid_lclic.
    delete adjacent duplicates from gt_sagmeld comparing all fields.
      IF not gt_sagmeld[] is initial.
      SELECT  /sapsll/legcon~guid_lclic
              /sapsll/legcon~guid_pobj
              /sapsll/legcon~amnt_flt
              /sapsll/legcon~amcur
               but000~bpext
               *revised spec
               /sapsll/corpar~PAFCT
              /sapsll/legcon~guid_mobj
             /sapsll/cuit~guid_cuit
      INTO TABLE gt_but000
      FROM /SAPSLL/LEGCON
      for all entries in gt_sagmeld
      where /SAPSLL/legcon~guid_lclic = gt_sagmeld-guid_lclic.
            IF NOT GT_BUT000[] IS INITIAL.
           sort gt_but000 by guid_mobj.
           delete adjacent duplicates from gt_but000 comparing guid_mobj.
         select /sapsll/corpar~guid_mobj
                /sapsll/corpar~PAFCT
                /sapsll/corpar~parno
                into table gt_but001
        from    /sapsll/corpar
        for all entries in gt_but000
        where  /sapsll/corpar~guid_mobj = gt_but000-guid_mobj.
       and    /sapsll/corpar~PAFCT = 'SH'.
    DELETE gt_but001 where PAFCT <> 'SH'.
    *sort gt_corpar by parno.
    *delete adjacent duplicates from gt_corpar comparing parno.
    *select gd000~partner
          gd000~bpext
         from gd000 into table gt_but001
    for all entries in gt_corpar
    where  gd000~partner = gt_corpar-parno.
    my ultimat aim is to select bpext from gd000
    can u please explain how to use ranges here and what is the singnificance and how ill i read the data from the final  table if we use ranges
    regards
    Nishant

  • Select statment problem

    Hi all,
    I am trying to put select statment into another select statment.
    Select column1
    ,column2
    ,column3
    ,(select column1 from table1,table2,table3 where condotions...)
    ,column4
    from table 1.
    its giving me error.
    Please help me...its urgent.
    Surender

    SQL> select deptno,dname,(select ename from emp) from dept;
    select deptno,dname,(select ename from emp) from dept
    ERROR at line 1:
    ORA-01427: single-row subquery returns more than one row
    SQL> select deptno,dname,(select ename from emp where empno=7934) from dept
    DEPTNO DNAME (SELECTENA
    10 ACCOUNTING MILLER
    20 RESEARCH MILLER
    30 SALES MILLER
    40 OPERATIONS MILLER
    In your case subquery is returning more than one row. It should not be.
    -aijaz
    Message was edited by:
    [email protected]

  • Problem with Select statement.

    DATA: wa_usr05   TYPE usr05.
    The select statement always gives sy-subrc = 0
    even if there is no entry with parid = 'ZRD'.
    On successful it fills the structure wa_usr05 as
    MANDT     C     3      ACC
    BNAME     C     12      SCL
    PARID     C     20      X
    PARVA     C     18
    but mandt is 310.
    USR05 is a pool table and has mandt field.
            SELECT SINGLE bname
                          parid
                          parva
                FROM usr05
                INTO wa_usr05
                WHERE bname = sy-uname AND
                      parid = 'ZRD'    AND
                      parva = 'x'  OR  parva = 'X'.
    Let me know the reason and solution to the problem.

    SELECT SINGLE * FROM usr05
    INTO wa_usr05
    WHERE bname = sy-uname AND
    parid = 'ZRD' AND
    parva = <b>'X'</b> .
    Use single * as u have defined the wa+usr05 as usr05.
    Else.
    DATA: i_usr05 TYPE STANDARD TABLE of usr05.
    SELECT * FROM USR05
             INTO TABLE usr05
             WHERE bname = sy-uname AND
             parid = 'ZRD' AND
            parva = <b>'X'</b> .
    Then loop at itab and write data.
    Hope this solves ur query.
    Reward points if this helps.
    Message was edited by:
            Judith Jessie Selvi

  • Checking the select statment

    hi,
    the select statment is
    SELECT SINGLE * FROM edidc WHERE docnum = l_docnum AND direct = '1' AND status = '3' AND mestyp = 'OILSHL'.
    there is an entry in the table edidc for the mentioned conditions.
    but it is returning sy-subrc = 4.
    please check what  is the wrong in the statement and provide me the solution for that.
    it is very urgent......
    thanks in advance....

    <b>please  use the below  program for getting it</b>  ....
    REPORT ZTES_12 .
    TABLES  : edidc .
    SELECT-OPTIONS  :  l_docnum  FOR edidc-docnum .
    DATA :   ITAB   TYPE  TABLE OF  edidc ,
             ITAB_WA   LIKE  edidc .
    SELECT  * FROM edidc INTO TABLE ITAB  WHERE docnum  IN l_docnum AND
    direct = '1'
    AND status = '29' AND mestyp = 'MATQM'.
    LOOP AT  ITAB  INTO  ITAB_WA .
    WRITE / : ITAB_WA-docnum .
    ENDLOOP.
    reward  points if it is usefull .....
    Girish

  • Problem in Selection Screen.

    Dear Experts,
    I am facing a problem in Selection Screen.
    <b>I have 2 radio buttons ,</b>
    <b>Radio Button 1</b> - Choosing the file from desktop and
    <b>Radio Button 2</b> - Executing from Database
    Under Option1 - i have a <b>FILE</b> parameter which is <b><u>Mandatory.</u></b>
    Problem Case -
    <b>when I choose option 2, Option 1 should be disabled. in the sense the file name which is mandatory here should not be mandatory . Currently, when i choose option 2 - i have to provide some dummy characters in the file parameter because the file parameter is mandatory, and <u><b>I want to avoid this.</b></u>
    Please see the entire code .</b>
    REPORT ZTEST.
    DATA: LV_FILE_PATH(20) TYPE  C.
    DATA: LV_MASK(20)      TYPE  C VALUE   ',*.XLS ,*.XLS.     '.
    *-- Macro to put radiobutton on selection screen
    *-- &1 - radiobutton parameter name
    *-- &2 - text element (description)
    *-- &3 - radiobutton group
    DEFINE MAKE_RADIOBUTTON.
      SELECTION-SCREEN BEGIN OF LINE.
      PARAMETERS: &1 RADIOBUTTON GROUP &3.
      SELECTION-SCREEN COMMENT 3(60) &2.
      SELECTION-SCREEN END OF LINE.
    END-OF-DEFINITION.
    SELECTION-SCREEN BEGIN OF BLOCK A0 WITH FRAME TITLE T000.
    * From Config File
    MAKE_RADIOBUTTON RB_1  ALL_DATA SRC.
    SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE T001.
    * Config file from Presentation server
    PARAMETERS: P_FILE1   LIKE T390D-DBNAME  OBLIGATORY. "
    SELECTION-SCREEN END OF BLOCK A1.
    * From database table
    MAKE_RADIOBUTTON RB_2 INC_DOWN SRC.
    SELECTION-SCREEN END OF BLOCK A0.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE1.
      CALL FUNCTION 'WS_QUERY'
           EXPORTING
                QUERY  = 'CD'  "// Current Directory
           IMPORTING
                RETURN = LV_FILE_PATH.
      CALL FUNCTION 'WS_FILENAME_GET'
           EXPORTING
                DEF_FILENAME     = 'TA_DOWNLOAD.MDB'
                DEF_PATH         = LV_FILE_PATH
                MASK             = LV_MASK
                MODE             = 'O'
           IMPORTING
                FILENAME         = P_FILE1
           EXCEPTIONS
                INV_WINSYS       = 1
                NO_BATCH         = 2
                SELECTION_CANCEL = 3
                SELECTION_ERROR  = 4
                OTHERS           = 5.
    INITIALIZATION.
      ALL_DATA = 'From Desktop     : ? '.
      INC_DOWN = 'From Database    : ?'.
      T000     = 'Configuration Upload'.
    Please help
    Thanks

    Hi
    You should do some modifications like these:
    DEFINE MAKE_RADIOBUTTON_1.
      SELECTION-SCREEN BEGIN OF LINE.
      PARAMETERS: &1 RADIOBUTTON GROUP &3 USER-COMMAND &4.
      SELECTION-SCREEN COMMENT 3(60) &2.
      SELECTION-SCREEN END OF LINE.
    END-OF-DEFINITION.
    DEFINE MAKE_RADIOBUTTON_2.
      SELECTION-SCREEN BEGIN OF LINE.
      PARAMETERS: &1 RADIOBUTTON GROUP &3.
      SELECTION-SCREEN COMMENT 3(60) &2.
      SELECTION-SCREEN END OF LINE.
    END-OF-DEFINITION.
    SELECTION-SCREEN BEGIN OF BLOCK A0 WITH FRAME TITLE T000.
    From Config File
    MAKE_RADIOBUTTON_1 RB_1  ALL_DATA SRC AAA.
    SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE T001.
    Config file from Presentation server
    PARAMETERS: P_FILE1   LIKE T390D-DBNAME MODIF ID FIL. "
    SELECTION-SCREEN END OF BLOCK A1.
    From database table
    MAKE_RADIOBUTTON_2 RB_2 INC_DOWN SRC.
    SELECTION-SCREEN END OF BLOCK A0.
    AT SELECTION-SCREEN OUTPUT.
      IF RB_2 = 'X'.
        LOOP AT SCREEN.
          IF SCREEN-GROUP1 = 'FIL'.
            SCREEN-ACTIVE = 0.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.
    Max

  • Performance problem with selecting records from BSEG and KONV

    Hi,
    I am having performance problem while  selecting records from BSEG and KONV table. As these two tables have large amount of data , they are taking lot of time . Can anyone help me in improving the performance . Thanks in advance .
    Regards,
    Prashant

    Hi,
    Some steps to improve performance
    SOME STEPS USED TO IMPROVE UR PERFORMANCE:
    1. Avoid using SELECT...ENDSELECT... construct and use SELECT ... INTO TABLE.
    2. Use WHERE clause in your SELECT statement to restrict the volume of data retrieved.
    3. Design your Query to Use as much index fields as possible from left to right in your WHERE statement
    4. Use FOR ALL ENTRIES in your SELECT statement to retrieve the matching records at one shot.
    5. Avoid using nested SELECT statement SELECT within LOOPs.
    6. Avoid using INTO CORRESPONDING FIELDS OF TABLE. Instead use INTO TABLE.
    7. Avoid using SELECT * and Select only the required fields from the table.
    8. Avoid nested loops when working with large internal tables.
    9. Use assign instead of into in LOOPs for table types with large work areas
    10. When in doubt call transaction SE30 and use the examples and check your code
    11. Whenever using READ TABLE use BINARY SEARCH addition to speed up the search. Be sure to sort the internal table before binary search. This is a general thumb rule but typically if you are sure that the data in internal table is less than 200 entries you need not do SORT and use BINARY SEARCH since this is an overhead in performance.
    12. Use "CHECK" instead of IF/ENDIF whenever possible.
    13. Use "CASE" instead of IF/ENDIF whenever possible.
    14. Use "MOVE" with individual variable/field moves instead of "MOVE-
    CORRESPONDING" creates more coding but is more effcient.

  • Problem with Select

    Hi All,
    I am Facing one problem in select query. My requirement is as follows.
    User Screen will Have 4 Fileds.
    Country Code, Zip Code From, Zip Code To, Delivery Area.
    All are Parameter's only.
    For Example ZTABLE having below Entries.
    US  12345-6787  12345-6789   AKRON             AKRON/CANTON
    Once User try to create new entry by Click on SAVE, Below Possiblities are there.
    Case 1: US  12345-6787  12345-6789   AKRON             AKRON/CANTON ( Error Message)
    Case 2: US  12345-6786  12345-6787   AKRON             AKRON/CANTON ( Error Message)
    Case 3: US  12345-6789  12345-6790   AKRON             AKRON/CANTON ( Error Message)
    Case 4: US  12345-6789  12345-6790   AKRON             AKRON/CANTON ( Error Message)
    Case 5: US  12345-6786  12345-6787   AKRON             AKRON/CANTON ( Error Message)
    Case 6: US  12345-6785  12345-6786   AKRON             AKRON/CANTON ( Record Need To Insert)
    Case 7: US  12345-6785  12345-6785   AKRON             AKRON/CANTON ( Record Need To Insert)
    Case 8: US  12345-6790  12345-6790   AKRON             AKRON/CANTON ( Record Need To Insert)
    Case 9: US  12345-6790  12345-6791   AKRON             AKRON/CANTON ( Record Need To Insert)
    Case 10: US  12345-6788  12345-6788   AKRON             AKRON/CANTON ( Error Message)(This Condition is Failing)
    Case 11: US  12345-6788  12345-6789   AKRON             AKRON/CANTON ( Error Message)(This Condition is Failing)
    In the above cases 10 and 11 is failing.
    I am using the below select statment.
    SELECT SINGLE * FROM zdt_sd_dlv_zcode   WHERE mandt = sy-mandt
                                              AND land1 = g_land1
                                              AND ( post_code_from GE g_pbox_from AND post_code_from LE g_pbox_to )
                                              OR ( post_code_to GE g_pbox_from AND post_code_to LE g_pbox_to ).
    Friends can anyone give me some valuable inputs to solve this problem.
    Points will reward.
    Thanks in Advance,
    Srinivas.

    Please use Select-options instead of Parameters so that you can use complex "and" and "or" in your select statements.
    for eg:if you are declaring parameters like this below.
    parameters post_code1  LIKE adrc-post_code1.
    change to
    select-options post_code1 for  adrc-post_code1 no intervals.
    siddu

  • Qurey in select statment

    Hi ,
           How can i use select qurey using where clause with 9*....
    Example :
            SELECT matnr  FROM mara into it_mara 
                                                      WHERE  matnr = p_material number.
    ie , This is parameter in selection screen -here defaultly giving as below
    p_material number = '9*'.
    i have used the above select but it failed .can any one help me sort out this ?
    Regards
    Maha

    Hi,
    Try this its working, i have checked:-
    DATA : BEGIN OF itab OCCURS 0,
           matnr TYPE mara-matnr,
           END OF itab.
    DATA : v_matnr TYPE mara-matnr.
    v_matnr = '9%'.
    SELECT matnr FROM mara INTO TABLE itab WHERE matnr LIKE v_matnr.
    WRITE : sy-subrc.
    LOOP AT itab.
      WRITE: / itab-matnr.
    ENDLOOP.
    Hope this solves your issue.
    Regards,
    Tarun

  • Problem with Select in Production

    hi all,
    My Select query is working fine in Devlopment server, but it is going to Dump in Production. In ST05, it is showing time-out error, may be due to heavy data, i guess.  Is there any way to modify this query sothat it wont go to Dump in Production.  Plz have a look:
    select a~budat as sdate
             a~vkont as contAcc
             a~xblnr as contract
             b~hkont as subTrans
             b~betrw as amount
             c~ktext as product
             d~vkbez as customer
             e~zzdepot as depot
        into corresponding fields of table iData
        from dfkkop as a
        inner join dfkkopk as b
           on aopbel = bopbel
          and aopupk = bopupk
        left join cskt as c
           on ckostl = bkostl
        inner join fkkvkp as d
           on dvkont = avkont
        inner join but000 as e
           on epartner = dgpart
        where
          a~vkont in rAcc
          and a~budat in rDate
          and a~hvorg =  'CMS'
          and a~bukrs in sobukrs
          and a~tvorg in rComp
          and a~opupz =  000
          and zzdepot in rDepot.
    rDate, rComp, rDepot, sobukrs are select-options in ****selection screen
    Thanks in advance,
    Regards,
    HKM

    Hi,
          remove inner join and use all entries and follow below steps
    1) Remove corresponding from select satement
    2) Remove * from select
    3) Select field in sequence as defined in database
    4) Avoid unnecessary selects
    i.e check for internal table not initial
    5) Use all entries and sort table by key fields
    6) Remove selects ferom loop and use binary search
    7) Try to use secondary index when you don't have
    full key.
    8) Modify internal table use transporting option
    9) Avoid nested loop . Use read table and loop at itab
    from sy-tabix statement.
    10) free intrenal table memory when table is not
    required for further processing.
    11)
    Follow below logic.
    FORM SUB_SELECTION_AUFKTAB.
    if not it_plant[] is initial.
    it_plant1[] = it_plant[].
    sort it_plant1 by werks.
    delete adjacent duplicates from it_plant1 comparing werks
    SELECT AUFNR KTEXT USER4 OBJNR INTO CORRESPONDING FIELDS OF TABLE I_AUFKTAB
    FROM AUFK
    FOR ALL ENTRIES IN it_plant1
    WHERE AUFNR IN S_AUFNR AND
    KTEXT IN S_KTEXT AND
    WERKS IN S_WERKS AND
    AUART IN S_AUART AND
    USER4 IN S_USER4 AND
    werks eq it_plant1-werks.
    free it_plant1.
    Endif.
    ENDFORM. "SUB_SELECTION_AUFKTAB
    Regards
    amole

  • I have a problem in select-options

    hi frns,
             i am facing a big problem in select-options
    the requirement is such that
    i have 2 select-options
    one for matnr and the other for maktx
    so wen the clent select matnr with f4
    in the maktx the similar description should come by using f4
    pls help me out

    hi,
    TYPES DECLARATION
    types: begin of tp_marc,
            matnr type marc-matnr,
            werks type marc-werks,
          end of tp_marc.
    INTERNAL TABLE AND WORK AREA DECLARATION
    data: t_marc type standard table of tp_marc,
          wa_marc type tp_marc.
    data : dd like table of dselc with header line. "*--- IMPORTANT
    data : ft like table of dfies with header line.
    data : t_makt like table of makt with header line.
    parameters : matnr like makt-matnr .
    parameters : maktx like makt-maktx.
    at selection-screen output.
      loop at screen.
        if screen-name = 'MAKTX'.
          screen-input = 0.
          modify screen.
        endif.
      endloop.
    at selection-screen on value-request for matnr.
    SELECT matnr maktx  FROM makt INTO TABLE makt up to 500 rows.
      select *
       from makt
        up to 500 rows
      into table t_makt
      where spras = syst-langu.
      if sy-subrc <> 0.
        message 'INVALID MATERIAL NUMBER' type 'E'.
      endif.
    IMPORTANT
      refresh dd.
    dd-fldname = 'MATNR'.
    dd-dyfldname = 'MATNR'.
    append dd.
      dd-fldname = 'MAKTX'.
      dd-dyfldname = 'MAKTX'.
      append dd.
    *------- IMPORTANT
      refresh ft.
      ft-tabname = 'MAKT'.
      ft-fieldname = 'MATNR'.
      append ft.
      ft-tabname = 'MAKT'.
      ft-fieldname = 'MAKTX'.
      append ft.
      call function 'F4IF_INT_TABLE_VALUE_REQUEST'
      exporting
    ddic_structure = 'T001' "*----- IMPORTANT IF STANDARD STRUCT
      retfield = 'MATNR'
      dynpprog = sy-repid
      dynpnr = sy-dynnr
      dynprofield = 'MATNR'
      value_org = 'S'
      tables
      field_tab = ft "*---- IMPORTANT
      value_tab = t_makt
      dynpfld_mapping = dd "* IMPORTANT
      exceptions
      parameter_error = 1
      no_values_found = 2
      others = 3.
      start-of-selection.
      select matnr
             werks
             from marc
             into table t_marc
             where matnr = matnr.
      if sy-subrc <> 0.
        message :'no results IN MARC' type 'E'.
      endif.
      write: at 1(36) sy-uline.
      format intensified on color = 7.
      new-line.
      write :sy-vline,at 10 'MATERIAL NUMBER',at 29 sy-vline, at 30 'PLANT',sy-vline.
      new-line.
      write: at 1(36) sy-uline.
      format intensified off color = 4.
      loop at t_marc into wa_marc.
        new-line.
        write :sy-vline,at 10 wa_marc-matnr ,sy-vline, at 30 wa_marc-werks, at 36 sy-vline.
      endloop.
      new-line.
      write: at 1(36) sy-uline.
    reward points if useful.
    regards,
    Vinod Samuel.

  • Problem in selecting records

    Hi, everyone.
    I have a problem in selecting records.  In this case, I want to select records from database
    LFA1,and the components of this table are LIFNR,ERDAT,LOEVM ,and so on.The type of LIFNR is char(10).There is a internal table:tab_cdhdr , the elements of tab_cdhdr are: objectid,udate and change_ind.The type of objectid is char(50).
    And the select-rule is that: LIFNR = objectid. So I write like this:
    select   lifnr
                 erdat
                 loevm
    form     lfa1
    into       tab_lfa1
    for all entries in tab_cdhdr
    where   lfa1 = tab_cdhdr-objectid+0(10).
    But there is a warning: When using FOR ALL ENTRIES IN the specifyed length for "OBJECTID" is ignored in this condition.
    Can you help me to solve this problem?
    Thanks.

    Hi Feng..
    If you dont want to change the Internal table TAB_CDHDR, Then declare another internal table (TEMPTAB_CDHDR.) with the same structure but Objectid with only 10 chars.
    IF TAB_CDHDR[] IS NOT INITIAL.
    LOOP AT TAB_CDHDR.
    MOVE-CORRESPONDING TAB_CDHDR TO TEMPTAB_CDHDR.
    APPEND TEMPTAB_CDHDR.
    ENDLOOP.
    select lifnr
    erdat
    loevm
    form lfa1
    into tab_lfa1
    for all entries in tab_cdhdr
    where lfa1 = TEMPtab_cdhdr-objectid.
    ENDIF.
    Sure ... this will work for u.....
    REWARD IF HELPFUL.

Maybe you are looking for

  • Can not get Netboot working across subnets

    On the same subnet all my images work correctly, but once I try to netboot form a different subnet it doesn't work anymore.  I am correctly using the bless command, and I have tried both specifying the server (to get the default image) and specifying

  • Using older version as default

    Hi! I installed CS5.5 and kept older version CS4 on my mac. Now I can't change CS4 as a default application on my .indd files, I have tried using command+i -> CS4 and also an app called "RCDefaultApps 2.1" with no help. Every time I double click an -

  • I have finally converted to MAC and now I need my purchased music!!!!!!

    Help! I have a mac now and cleaned out and dismantled my PC. I have logged on to iTunes on my mac and my library is EMPTY! how can I access all of my purchased music? Is it gone forever? I appreciate any help!

  • Can i use my 3g on my ipad2 to my mac book pro like a iphone?

    I personally live in a bording  school, so it would be great if i could use the 3g on my ipad2 to teahter it to my mac book pro. If so how do i do it? Thanks in advance

  • Problem in debug ?

    Hi,    I write the logic for my requirement for moving the posting date. Logic is :            CASE I_ERKRS.                   WHEN 'M200'.                     MOVE-CORRESPONDING I_ITEM to CE0_M200.                     IF NOT CE0_M200-fkart is initia