Select variable in where condition

Hi Experts,
               A field is stored in SAP, we want to add the same in where condition while selecting data thru IC. please guide.

Hi, please clarify your question.
Regards Mikhail

Similar Messages

  • Select-options with where condition

    Hello ABAPers,
    I want to create a select-options like s_operid for vbpa-kunnr but with a condition specified is VBPA-KUNNR where VBPA-PARVW = 'WE'.
    Thanks in advance. Pls reply asap. Points will definitely be rewarded.
    Ritu

    hi,
    use this
    PARAMETERS : TAB_ID TYPE ZALOAD_PROD_COMB-TAB_ID OBLIGATORY.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR TAB_ID.
    DATA : BEGIN OF INT_TAB_ID OCCURS 0,
                TAB_ID TYPE ZALOAD_PROD_COMB-TAB_ID,
             END OF INT_TAB_ID.
      DATA : LOC_MAX TYPE ZALOAD_PROD_COMB-TAB_ID.
      CLEAR INT_TAB_ID.
      REFRESH INT_TAB_ID.
      SELECT MAX( TAB_ID) INTO (LOC_MAX) FROM ZALOAD_PROD_COMB.
      COUNT = LOC_MAX + 1.
      DO 10 TIMES.
        MOVE COUNT TO INT_TAB_ID-TAB_ID.
        APPEND INT_TAB_ID.
        COUNT = COUNT + 1.
      ENDDO.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
         RETFIELD            = 'TAB_ID'                        u201C Internal table field name
         DYNPPROG         = 'PROG_NAME                  u201C Program name
         DYNPNR              = SY-DYNNR
         DYNPROFIELD   =  'TAB_ID'                        u201C Field where u need F4 help
         VALUE_ORG       = 'S'
       WINDOW_TITLE  = u2018Any descriptionu2019
        TABLES
          VALUE_TAB      = INT_TAB_ID.                   u201C Internal table name
    Mark the post answered once ur problem is solved ....

  • SELECT-OPTIONS in WHERE condition

    Hi All,
    SELECT-OPTIONS : S_TCODE FOR TSTCT-TCODE.
    START-OF-SELECTION.
      SELECT * FROM TSTCT INTO TABLE IT_TSTCT
               WHERE TCODE = S_TCODE.
    The same code results in SYNTAX ERROR in 4.7c.
    In ECC 6.0, no such error resulted, but SUBRC is 4.
    Why is it like this in ECC 6.0?
    Regards,
    R.Nagarajan.

    hi,
    You are right in ECC 6 this will not give any error as long as you are referencing to the work area of the Select-option, but will start giving error as soon as you refer to the table using the [] command beside the select-option the it will give you a syntax error in ECC 6.0 also.
    The reason might be the unicode enabling started in ECC 6.0
    Hope That Helps
    Anirban M.

  • Concatenation error - when i use text column value in where condition.

    Hi,
    i am creating Materialized view using few columns from two tables and as per requirement i need to prepare select statement with where condition in another column.(new column)
    i tried like below....
    create materialized view MAIN
    refresh force on demand
    as
    select
    a.table_name,
    a.column_name,
    b.trial_name,
    'select * from '||a.table_name||' where '||a.column_name|| ' = '|| b.trial_name||';' "QUERY"
    from
    exp_csv_tB a,
    exp_csv_tr b;
    a.table name value is : monitoring_table
    a.column_name value is : study
    b.trial_name = fty777
    Materialized view created with extra column but it is not added '' (codes) to text value in where condition.
    output which i got is :
    select * from monitoring_table where study = fty777;
    but
    i need output like
    select * from monitoring_table where study = 'fty777';
    fty777 value should be in codes like 'fty777'. i read some articles but didnt get this example.
    please help.

    Try this:
    CREATE MATERIALIZED VIEW main
    REFRESH FORCE ON DEMAND
    AS
    SELECT
    a.table_name,
    a.column_name,
    b.trial_name,
    'select * from '||a.table_name||' where '||a.column_name|| ' = '''|| b.trial_name||'';'' "QUERY"
    FROM
    exp_csv_tb a,
    exp_csv_tr b;
    You have to give double single codes for semi-colons ..
    Regards..

  • I want to design my database to get data with specified criteria. How do I do it without supplying common 'Where' condition?

    I have more than 100 tables and each table have 2 fields CompanyID And LocationNo.
    for example there is a table like Sales which is containing details about tax invoices. in this table invoice number can be duplicate with CompanyID and Location number. 
    CompID LocNo InvoiceNo
    1           1        1
    1           1        2
    1           2        1
    2           1        1
    1           1        3
    I want to get all invoice data where CompanyID is 1 and LocationNo also 1.
    I know i can do this with simple where condition Where CompanyID=1 AND LocationNo=1. but there are more than 100 tables which are containing same fields and also i want to get only those data where CompanyID=1 AND LocationNo=1. so i cannot put where condition
    everywhere in the whole project to get specified data only.
    Is there any whay to create any datasource or ODBC connection that will help me to get data from only specified criteria.
    More Information
    I want to do something like Tally ODBC Server which is creates temporary ODCB server to retrive data from the tally database. This server retrieves only those data which transaction date is selected in Tally Software.

    Thanks Satheesh for your reply.
    Your idea is good.But, CompanyID and LocationNo can be different on differnt place. So, i cannot fix it with 1 or any other value.
    if any way to pass both parameter into sql connection. So, when i execute only select query without where condition it will returns only specified data.
    If you have used Tally then you know it creates ODBC server for its custom database. We can retrieve data into excel using TallyODBC_9000 connection. 
    This connection retrieves only those data which transaction date is selected in tally software.
    I want to do something like this.

  • Where condition

    Hi all,
    My 2nd select query is not working.
    Plz tell where i m wrong.
    if itab_lfa1[] is not initial.
    if p_bukrs is  initial.
      select lifnr bukrs
      from lfb1
      into  corresponding fields of table i_lfb1
      for all entries in itab_lfa1
      where lifnr =  itab_lfa1-lifnr.
      else.
      select lifnr bukrs
        from lfb1
      into  corresponding fields of table i_lfb1
      for all entries in itab_lfa1
      where lifnr =  i_lfa1-lifnr
        and bukrs eq p_bukrs.
      endif.
      endif.
    Showing the error msg in 2nd select this:
    The WHERE condition does not refer to the FOR ALL ENTRIES table.           
    But when we remove for all entries in itab_lfa1,
    then it show no error, but doesn,t able to pick all records.
    Best Regards,
    Aastha.

    hi,
    Check out in this way  ..
    call function 'CONVERSION_EXIT_ALPHA_INPUT'
              exporting
                      input = p_bukrs
              importing
                     output = p_bukrs.
    loop at itab_lfa1.
    call function 'CONVERSION_EXIT_ALPHA_INPUT'
              exporting
                      input = itab_lfa1-lifnr
              importing
                     output = itab_lfa1-lifnr.
      modify itab_lfa1 index sy-tabix.
    endloop.
    if not itab_lfa1[] is initial.
    select lifnr bukrs
    from lfb1
    into corresponding fields of table i_lfb1
    for all entries in itab_lfa1
    where lifnr = itab_lfa1-lifnr
    and bukrs = p_bukrs. " Assuming p_bukrs is declared as parameter
    endif.

  • Field symbols as Table name and in where condition in a select statement

    Hello All,
    I have a scenario where I need to get user input on table name and old field value and new field value. Then based on user input, I need to select the record from the database. The column name for all the tables in question is different in the database, however there data type is the same and have same values.
    I am not able to use a field symbol for comparing the old field value to fetch the relevant record in my where clause.
    I cannnot loop through the entire table as it has 10 millilon records, please advice on how to add the where clause as field symbol as the table name is also dynamically assigned.
    Here is my code:
    DATA: TAB       LIKE SY-TNAME,
          TAB_COMP1 LIKE X031L-FIELDNAME,
          TAB_COMP2 LIKE X031L-FIELDNAME,
          NO_OF_FLD TYPE N.
    DATA: BEGIN OF BUFFER,
            ALIGNMENT TYPE F,
            C(8000)   TYPE C,
          END OF BUFFER.
    FIELD-SYMBOLS: <WA>   TYPE ANY,
                  <COMP1> TYPE ANY,
                  <COMP2> TYPE ANY.
    GET TABLE NAME GIVEN BY USER IN LOCAL VARIABLE
      TAB = TAB_NAME.
    CREATE FIELD NAME BASED ON THE TABLE NAME ENTERED.
      CASE TAB_NAME.
      WHEN 'OIUH_RV_GL'.
          KEY FIELD
            TAB_COMP1  = 'GL_GL_SYS_NO'.
            NO_OF_FLD  = 1.
      WHEN 'OIUH_RV_OPSL'.
          KEY FIELD
            TAB_COMP1  = 'OPSL_GL_SYS_NO'.
            NO_OF_FLD  = 1.
      WHEN 'OIUH_RV_OTAX'.
          NOT THE ONLY KEY FIELD
            TAB_COMP1  = 'OTAX_GL_SYS_NO'.
            TAB_COMP2  = 'OTAX_TAX_POS_NO'.
            NO_OF_FLD  = 2.
      WHEN 'OIUH_RV_GTAX'.
          NOT THE ONLY KEY FIELD
            TAB_COMP1  = 'GTAX_GL_SYS_NO'.
            TAB_COMP2  = 'GTAX_TAX_POS_NO'.
            NO_OF_FLD  = 2.
      WHEN OTHERS.
            EXIT.
      ENDCASE.
    SET FIELD SYMBOL WITH APPROPRIATE TYPE TO BUFFER AREA.
    ASSIGN BUFFER TO <WA> CASTING TYPE (TAB).
    How to add where clause and remove the if condition in the select -- endselect
    SELECT * FROM (TAB) INTO <WA>. 
      ASSIGN COMPONENT TAB_COMP1 OF STRUCTURE <WA> TO <COMP1>.
      IF NO_OF_FLD = 2.
        ASSIGN COMPONENT TAB_COMP2 OF STRUCTURE <WA> TO <COMP2>.
      ENDIF.
      IF <COMP1> = OLD_SYS_NO.
        code for updating table would come here
          WRITE: 'MATCH FOUND'.
          EXIT.
      ENDIF.
    ENDSELECT.
    Please advice. Thanks much.
    Edited by: Shipra Jhunjhunwala on Jul 22, 2009 1:33 PM
    Edited by: Shipra Jhunjhunwala on Jul 22, 2009 1:34 PM
    Edited by: Shipra Jhunjhunwala on Jul 22, 2009 1:35 PM

    1. Create single column table for holding field name depending on the table entered.
    2. Take input from user: for e.g. table_name
    3. Using case load single column table with required fields
       for e.g.
      CASE TAB_NAME.
       WHEN 'OIUH_RV_GL'.
             Append 'GL_GL_SYS_NO' to KEY_FIELD --> KEY_FIELD is the single line internal table as mentioned in step 1.
       WHEN 'OIUH_RV_OPSL'.
             Append 'OPSL_GL_SYS_NO'.
       WHEN 'OIUH_RV_OTAX'.
             Append 'OTAX_GL_SYS_NO' to KEY_FIELD.
               APPEND 'OTAX_TAX_POS_NO' to KEY_FIELD.
       WHEN 'OIUH_RV_GTAX'.
             Append 'GTAX_GL_SYS_NO' to KEY_FIELD.
               APPEND 'OTAX_TAX_POS_NO' to KEY_FIELD.
       WHEN OTHERS.
          EXIT.
       ENDCASE.
       Now depending on the table name you have required column ready
    4. Create dynamic internal table using following sudo code
       Fill the fieldcatlog using the single column field table and DD03L table, See what all columns from DD03L you want to fill in field catlog table
       loop at internal table with all the fields.
        move it to field catalog.
        append field catalog.
       endloop.
    5. Pass this field catalog table to static method create_dynamic_table method
       DATA table TYPE REF TO DATA. --> data object for holding handle to dynamic internal table.
       call method cl_alv_table_create=>create_dynamic_table
       exporting
          it_fieldcatalog = fieldcatalog_tab
       importing
          ep_table = table.
    6. Now assign table reference to field symbol of type table.
       ASSIGN table->* to <field-tab>.
    7. Also create work area <field-wa> using refrence of table.
       create data object wa LIKE LINE OF <field-tab>.
       ASSIGN wa->* to <field-wa>.
    8. Also define field symbol for field name.
       for e.g. <field_name>
    4. Dynamic internal table is ready
    5. Now execute the select statement as follows:
       SELECT (KEY_FIELD)
         INTO <ITAB> --> created dynamically above
          FROM (TABLE_NAME)
         WHERE (WHERE).  --> WHERE is single line internal table having line type of CHAR72. So for every old value there will be one line
         Where condition is same as like we give in static way only difference in this case it will stored in internal table line wise.
        In this case you need to append all your where condition line by line in to WHERE.     
    5. To fill this dynamic internal table using ASSIGN COMPONENT <Comp_number> OF STRUCTURE <field-wa> TO <field-name>
       So in this case if first field of structure STRUCT1 is user_id then sudo-code will be
       loop at internal table containing list of fields into field_wa --> single column field table
           ASSIGN COMPONENT field_wa OF STRUCTURE <field-wa> TO <field>. "Here field_wa is wa area for single column internal table holding all the fieldnames.
           Now <field-name> points to user_id field. Move some value into it as nornally we do with variables.
           Move <your_new_value> to <field-name>. --> Assign new value
            or
            <field-name> = <your_new_value>.
       Endloop.
    6. After completing all the fields one row will be ready in <field_wa>.
       APPEND <field_wa> to <field_tab>.
    Hope this helps you.
    Thanks,
    Augustin.

  • Variable in the where condition how?

    Hello Expert Abapers,
    how to use a variable in the where condition..
    select * from (Var_tab_name)
    into itab
    where (var1) = 'A'
    but i know this expression where (var1) is not allowed, but what is the alternative to this.
    Thanks for any suggestions.
    BWer

    Hi,
    <b>Dynamic Conditions</b>
    To specify a condition dynamically, use:
    SELECT ... WHERE (<itab>) ...
    where <itab> is an internal table with line type C and maximum length 72 characters. All of the conditions listed above except for selection tables, can be written into the lines of <itab>. However, you may only use literals, and not the names of data objects. The internal table can also be left empty.
    If you only want to specify a part of the condition dynamically, use:
    SELECT ... WHERE <cond> AND (<itab>) ...
    You cannot link a static and a dynamic condition using OR.
    You may only use dynamic conditions in the WHERE clause of the SELECT stateme
    example:
    data: begin of myselection occurs 0,
         line(72),
           end of myselection.
    data char(1) value 'A'.
    myselection-line = 'var1 = char'.
    append myselection.
    select * from (Var_tab_name)
    into itab
    where (myselection) .
    Message was edited by: Svetlin Rusev

  • Select query with variable no of conditions

    Hi,
    I want to write a select query such that the conditions mentioned under WHERE clause can be variable .like :
    Select * from TABLE where F1 = var1 and F2 = var2 and F3 = var3.
    Now on the basis of some conditons the equations in where clause should be used.Say condition is variable value >6.
    Now in this case ,if
    var1 =7 var2 =3 var3 = 8 then the query shud behave like
    select * from TABLE where F1 = var1 and F3 = var3
    if :
    var1 =3 var2 = 4 var3 =3 the :
    select * from TABLE
    But only one query is to be wrote that satisfies all of these
    thanx
    Edited by: aachal on Feb 4, 2011 11:36 AM

    Hi Aachal,
    Use Dynamic select statement.
    Ex:
    data : lv_wherecond type string.
    Select * from TABLE where ( lv_wherecond ).
    Before Select stmt, code as follows.
    if var1 > 6.
           if lv_wherecond is initial.
              F1 = var1.
           else.
              concatenate lv_wherecond ' and F1 = var1'  into lv_wherecond.
           endif.
    elseif var 2 > 6.
            if lv_wherecond is initial.
               F2 = var2
            else.
               concatenate lv_wherecond ' and F2 = var2'  into lv_wherecond.
           endif.
    elseif var3 > 6.
          same as above ..
    endif.
    Hope it helps..
    Regards,
    Sravan Guduru.

  • How to select data from a table using a date field in the where condition?

    How to select data from a table using a date field in the where condition?
    For eg:
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
                                                      and bdatu = '31129999'.
    thanks.

    Hi Ramesh,
    Specify the date format as YYYYMMDD in where condition.
    Dates are internally stored in SAP as YYYYMMDD only.
    Change your date format in WHERE condition as follows.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and bdatu = <b>'99991231'.</b>
    I doubt check your data base table EQUK on this date for the existince of data.
    Otherwise, just change the conidition on BDATU like below to see all entries prior to this date.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and <b> bdatu <= '99991231'.</b>
    Thanks,
    Vinay
    Thanks,
    Vinay

  • URGENT: To change the where condition in select query at runtime ?

    Hi,
    I have to develop a report, 4 which I have created a selection screen with 7 Input Parameters whose value is to be filled by the user while executing the report.
    On the basis of this I do the desired selection of output.
    But the problem is that how do I write my select Query(where condition) if the user enetrs only 2 Input parameters or 3 or whatever he feels like.
    Pls help me out...

    hi,
    check this sample code.
    Here i am populating where condition at runtime.
    DATA: V_WHERE TYPE STRING.
    SELECTION-SCREEN BEGIN OF BLOCK INPUT WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS : S_VBELN FOR VBAK-VBELN,
                     S_ERDAT FOR VBAK-ERDAT.
    SELECTION-SCREEN END OF BLOCK INPUT.
    START-OF-SELECTION.
      PERFORM POPULATE_WHERE.
      PERFORM GET_VBAK_DATA.
    *&      Form  POPULATE_WHERE
    *       Populate Where
    FORM POPULATE_WHERE .
      IF NOT S_ERDAT[] IS INITIAL.
        CONCATENATE 'VBELN IN S_VBELN'
                    'AND'
                    'ERDAT IN S_ERDAT'
              INTO V_WHERE
              SEPARATED BY SPACE.
      ELSE.
        V_WHERE = 'VBELN IN S_VBELN'.
      ENDIF.
    ENDFORM.                    " POPULATE_WHERE
    *&      Form  GET_VBAK_DATA
    *       GET VBAK DATA
    FORM GET_VBAK_DATA .
      SELECT VBELN
             ERDAT
             VBTYP
             NETWR
             WAERK
             VKORG
             VTWEG
             SPART
        INTO CORRESPONDING FIELDS OF TABLE IT_VBAK
        FROM VBAK
        WHERE VBELN IN S_VBELN
        AND   ERDAT IN S_ERDAT.
       WHERE (V_WHERE).
    endform.
    Regards
    Sailaja.

  • How can i define a boolean variable with the condition if i got a specific text on a selected column?

    How can i define a boolean variable with the condition if i got a specific text on a selected column?
    Example:
    my select results:
    [id = 102] [Company = 'Microsoft']
    If i got microsoft in 'Company' i want to my another table with the columnName "Microsoft" get "true".
    Can you help me?

    That is called 2-table UPDATE.
    Example:
    http://www.sqlusa.com/bestpractices2005/updatewithcorrelatedsubquery/
    Kalman Toth Database & OLAP Architect
    Free T-SQL Scripts
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Dynamic select query with dynamic where condition

    Hi all,
    I want to use the dynamic select query with dynamic where condition. For that I used the below code but I am getting dump when using this code.
    Please advice, if there is any other way to achieve this requirement.
    Thanks,
    Sanket Sethi
    Code***************
    PARAMETERS: p_tabnam      TYPE tabname,
                p_selfl1      TYPE edpline,
                p_value       TYPE edpline,
                p_where1      TYPE edpline .
    DATA: lt_where    TYPE TABLE OF edpline,
          lt_sel_list TYPE TABLE OF edpline,
          l_wa_name   TYPE string,
          ls_where    TYPE edpline,
          l_having    TYPE string,
          dref        TYPE REF TO data,
          itab_type   TYPE REF TO cl_abap_tabledescr,
          struct_type TYPE REF TO cl_abap_structdescr,
          elem_type   TYPE REF TO cl_abap_elemdescr,
          comp_tab    TYPE cl_abap_structdescr=>component_table,
          comp_fld    TYPE cl_abap_structdescr=>component.
    TYPES: f_count TYPE i.
    FIELD-SYMBOLS : <lt_outtab> TYPE ANY TABLE,
    *                <ls_outtab> TYPE ANY,
                    <l_fld> TYPE ANY.
    struct_type ?= cl_abap_typedescr=>describe_by_name( p_tabnam ).
    elem_type   ?= cl_abap_elemdescr=>describe_by_name( 'F_COUNT' ).
    comp_tab = struct_type->get_components( ).
    comp_fld-name = 'F_COUNT'.
    comp_fld-type = elem_type.
    APPEND comp_fld TO comp_tab.
    struct_type = cl_abap_structdescr=>create( comp_tab ).
    itab_type   = cl_abap_tabledescr=>create( struct_type ).
    l_wa_name = 'l_WA'.
    CREATE DATA dref TYPE HANDLE itab_type.
    ASSIGN dref->* TO <lt_outtab>.
    *CREATE DATA dref TYPE HANDLE struct_type.
    *ASSIGN dref->* TO <ls_outtab>.
    * Creation of the selection fields
    APPEND p_selfl1 TO lt_sel_list.
    APPEND 'COUNT(*) AS F_COUNT' TO lt_sel_list.
    ** Creation of the "where" clause
    *CONCATENATE p_selfl1 '= '' p_value ''.'
    *            INTO ls_where
    *            SEPARATED BY space.
    *APPEND ls_where TO lt_where.
    * Creation of the "where" clause
    APPEND p_where1 TO lt_where.
    * Creation of the "having" clause
    l_having = 'count(*) >= 1'.
    * THE dynamic select
    SELECT          (lt_sel_list)
           FROM     (p_tabnam)
           INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>.
    *       WHERE    (lt_where).

    Hi Sanket,
    The above given logic of mine works for you, put the code in the If condition and try-
    just like below:
    IF NOT P_EBELN IS INITIAL.
    lt_where = '& = ''&'' '.
    REPLACE '&' WITH p_ebeln INTO lt_where.
    REPLACE '&' WITH field_value INTO lt_where.
    SELECT (lt_sel_list) INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>
    FROM (p_tabnam)
    WHERE (lt_where).
    ENDIF.
    thanks\
    Mahesh

  • Select query with optional where condition

    Hi,
    Can Anybody help me out in the following problem?
    I have the following query in a procedure.
    SELECT replace(shipper_name,'\',' ') as shipper,
    sum(teus / cntSailings) as teus
    FROM VW_CONTRIBUTION,
    VW_TOTAL_SAILINGS
    WHERE VW_CONTRIBUTION.dir = VW_TOTAL_SAILINGS.DIR
    AND VW_CONTRIBUTION.line = VW_TOTAL_SAILINGS.LINE
    AND VW_CONTRIBUTION.accounting_month = VW_TOTAL_SAILINGS.ACCOUNTING_MONTH
    AND VW_CONTRIBUTION.accounting_year = VW_TOTAL_SAILINGS.ACCOUNTING_YEAR
    AND VW_CONTRIBUTION.Principal = arg_principal
    AND VW_CONTRIBUTION.Dir = arg_direction
    AND VW_CONTRIBUTION.line in ( arg_service )
    AND VW_CONTRIBUTION.POL_country = arg_pol
    AND VW_CONTRIBUTION.POd_country = arg_pod
    AND VW_CONTRIBUTION.salesOffice = arg_SalesOffice
    AND VW_CONTRIBUTION.salesregion = arg_SalesRegion
    AND VW_CONTRIBUTION.cargo_type = arg_txtCargoType
    AND VW_CONTRIBUTION.eqgroup = arg_ContType
    AND VW_CONTRIBUTION.eq_size = arg_txtSize
    AND VW_CONTRIBUTION.acct_date between arg_from_date and arg_end_date
    GROUP BY shipper_name
    ORDER BY teus desc;
    Here some of the arguments are optional(Eg : VW_CONTRIBUTION.salesOffice, AND VW_CONTRIBUTION.eqgroup etc. ) and the values can be null. When they are null, I want them to be excluded from the where condition. Can anybody suggest me a solution for this?
    Thanks,
    Shalet.

    I guess i misunderstood your original question.
    The clause
    AND (VW_CONTRIBUTION.salesOffice = arg_SalesOffice OR VW_CONTRIBUTION.salesOffice IS NOT NULL)
    will cause the where clause to evaluate to FALSE anytime salesOffice IS NULL so the record will be excluded.
    I thought you were asking how to not compare the value if the field contained a NULL.
    Glad you found what you wanted.

  • Select with too many where conditions not working fine....equal to and not

    Hi Everyone,
      I am getting rows into internal table lt_mseg even if this where condition like this werks NE gs_t001w-werks in below code
    is true. It looks like it's not excluding if not equal to gs_t001w-werks. Is anything wrong in below code? please help me...
    SELECT * INTO TABLE gt_t005 FROM t005 WHERE xegld = 'X'.
    SELECT * FROM t001w INTO TABLE gt_t001w FOR ALL ENTRIES IN gt_t005
    WHERE ( land1 = gt_t005-land1 OR land1 = 'NO' ) AND vkorg NE 'LDE'.
    SELECT * FROM mkpf INTO TABLE gt_mkpf
    WHERE budat IN p_oextdt AND vgart = 'WL'.
    LOOP AT gt_mkpf INTO gs_mkpf.
    CHECK gt_t001w[] IS NOT INITIAL.
    SELECT * FROM mseg APPENDING TABLE lt_mseg
    FOR ALL ENTRIES IN gt_t001w
    WHERE mblnr = gs_mkpf-mblnr
    AND mjahr = gs_mkpf-mjahr
    AND bwart NE '641'
    AND xauto = ' '
    AND werks NE gs_t001w-werks
    AND kunnr = gt_t001w-kunnr.
    ENDLOOP.

    Hi Sany,
      Thanks for your reply. I f I remove  this LOOP AT gt_mkpf INTO gs_mkpf and use for all entries how can I exlude plants that I got from t001w?
       I used range here in below code now I am getting run time error in this loop, it says value table for IN itab operator has unexpected format....
    DATA:
          gt_t005 TYPE TABLE OF t005,
          gs_t005 LIKE LINE OF gt_t005,
          gt_t001w TYPE TABLE OF t001w,
          gt_rng_plant  type range of t001w,
          gs_rng  like line of gt_rng_plant,
          gs_t001w LIKE LINE OF gt_t001w,
          gt_mkpf  TYPE TABLE OF mkpf,
          gs_mkpf  LIKE LINE OF gt_mkpf .
    SELECT * INTO TABLE gt_t005 FROM t005  WHERE xegld = 'X'.
      SELECT * FROM t001w INTO  TABLE gt_t001w FOR ALL ENTRIES IN gt_t005
       WHERE ( land1 = gt_t005-land1 OR land1 = 'NO' ) AND vkorg NE 'LDE'.
      SELECT *  FROM mkpf INTO TABLE gt_mkpf
                  WHERE budat IN p_oextdt AND vgart = 'WL'.
      gs_rng-sign = 'I'.
      gs_rng-option = 'EQ'.
      LOOP AT gt_t001w INTO gs_t001w.
        gs_rng-low = gs_t001w-werks.
        gs_rng-high = gs_t001w-werks.
        APPEND gs_rng TO gt_rng_plant.
      ENDLOOP.
        LOOP AT gt_mkpf INTO gs_mkpf.
          SELECT * FROM mseg APPENDING TABLE lt_mseg
              FOR ALL ENTRIES IN gt_t001w
              WHERE mblnr = gt_mkpf-mblnr
                AND mjahr = gt_mkpf-mjahr
              AND bwart NE '641'
                AND xauto = ' '
                AND werks not in gt_rng_plant
                 AND kunnr = gt_t001w-kunnr.
        ENDLOOP.

Maybe you are looking for

  • I have to enter my details all the time in newly updated Aperture 3.4.3

    Hi, I have to enter all my details again and again in Aperture 3.4.3, any idea why? cheers

  • Auto-mapping across multiple domains

    I originally posted this in an O365 Exchange forum and was redirected here.  Any help is appreciated. Single E1/E3 O365 account with multiple domains having hosted email.  Automapping is working correctly only if the shared mailbox is from the first

  • Insertion of rows in multiple tables simultaneously

    hi there, here i have two tables.i need to enter data in that two tables at the same time. in the the common fields in the two tables are subid and qno. so my requirement is if i enter subid,qno in first table the same data has to be copied into the

  • How to stop/start an animation with setImageObserver()

    Hi, I have an animated gif that I want to use for when I'm waiting on a long operation (like the upper right icon on Netscape). The gif starts its animation without me telling it. I was doing some code like this: ImageIcon icon = ... JLabel label = n

  • Webservice scenario access url

    Hi Experts, Could you please tell me what all ways to access the webservice scenario. 1. Through java port. Example : http://<servername>:<b>50100</b>/XISOAPAdapter/MessageServlet?channel=:Business_service:CC 2. Through abap port. http://<servername>