Dynamic length-input in a where condition for a itab-attribut

Hi,
i want to loop from a itab in a dynamic way:
NOT Dynmaic:
loop at itab into wa where attribute1(5) = attribute2.
endloop.
Dynamic:
loop at itab into wa where attribute1(p_parameter) = attribute2.
endloop.
Unfortunately the syntaxcheck send me the following message if i try to use that code:
  'The lengthinput 'p_parameter' ist not a numeric literal nor a numeric constant.'
What can i do?

Hi,
Now i understood your problem.
You can try this work around
DATA:it TYPE TABLE OF mara,
     wa TYPE mara.
DATA:r TYPE RANGE OF matnr.
DATA:w LIKE LINE OF r.
PARAMETERS:p_i TYPE i.
w-sign = 'I'.
w-option = 'CP'.
w-low+p_i(*) = '*'.
w-low+0(p_i) = 'ABC'.  "Pass you attribute2 here
APPEND w TO r.
START-OF-SELECTION.
  SELECT * FROM mara INTO TABLE it UP TO 10 ROWS.
  LOOP AT it INTO wa WHERE matnr IN r.
  ENDLOOP.

Similar Messages

  • Dynamic component in WHERE-condition for LOOP AT ?

    i want to make
    loop at itab where  (dynamic field) > 0
    how i can make it...
    Edited by: Thomas Zloch on Mar 2, 2010 2:47 PM

    I thought it's funny.
    And the problem can maybe be solved by using a completely dynamic where-condition, not just a dynamic component.
    http://help.sap.com/abapdocu_70/en/ABAPLOOP_AT_ITAB_COND.htm#!ABAP_ADDITION_4@4@
    Thomas
    P.S. meaningless subject enhanced, and please take the time to say hi and please when asking for help. Thanks.

  • Where condition for a column in BMM

    Hi Gurus,
    I have a requirement where in the BMM(The LTS for this logical table is say 'Fact'), I need a logical column with the following definition.
    count(Dim.status) where Dim.status = ' Accepted' (I didnt add the Dim table to the LTS yet, should I?)
    I know that we can do a count(Dim.status) in the column source . but for the where Dim.status = ' Accepted' part im not sure what to do.
    Should I bring the Dim table as a LTS and define the 'where' condition in the content tab? will that work?
    but what if I have another logical column where I need dim.Status = 'Declined'( we have many more status)
    Plz help

    The suggest statement as Filter(count(Fact.Dollars) Using("dim.status = 'accepted'))
    is based on Answers, this would care about the column is available in Subject Area or not thats it.
    The same kind of functionality can get the using rpd.
    There you might need to map/add (fact source properties and then map using pencil icon on 11g add button in 10g) the dim table to the fact
    so that you can get the expression based on physical columns as
    case when dim.status = 'accepted' then Fact.Dollars else 0 end
    use Aggregate tab for sum;
    Since you are using Fact.Dollars it suppose to be sum, ROW_WIDs go by counts
    Hope this helps :) for more Qs send email
    If helps mark

  • Where condition for reading infotype while using ldb

    hi
    i want to read info from infotype p0000
    using where condition eg: for pernr = ' '.
    i am using LDB pnp.
    how can i put the where condition while using macro
    rp-provide-from-last.
    regards
    cs

    in fact you don't have to get the values, you only need to tell to the program to take them into account :
    GET PRPS.
      CHECK SELECT-OPTIONS.

  • DMEE - error in conditions for node: node attribute missing for ref. ID

    Hi,
    I've got an error 'error in conditions for node XXX: node attribute missing for ref. ID XXXXX' - may I kindly ask you to suggest where this attribute need to be specified.
    thanks in advance.
    BR
    Renatas

    Hi Renatas ,
    When using Reference IDs for Conditioning in DMEE you should give  node attribute in the  2nd field of the  conditioning ....
    look the below example
    Arg1-1     Arg1-2     T     O     Arg2-1     Arg2-2     T      O
    E2E     1A     3     =     SPACE          1     
    DMEE: node attribute as a comparison value
    Definition
    Node attribute to be used in a condition. The following values are possible:
    1: contents in output format
    1A: contents in internal format
    2: length
    3: counter reading
    4: counter reading of segments per file (only for DMEE format tree)
    5: counter reading of segments with CR/LF (only for DMEE format tree)
    Regards,
    Komaravolu

  • Only key fields of table-cluster in where-condition for better performance?

    Hi,
    Say my cluster table is having following key fields: KEY1, KEY2, KEY3, KEY4.
    And, my table-cluster is having following key fields: KEY1, KEY2, PAGENO .. [PAGENO is always there in a table-cluster].
    Now, I have two versions of my (Open SQL) SELECT-WHERE clause:
    a) SELECT *
        WHERE KEY1 EQ LV_KEY1
             AND KEY2 EQ LV_KEY2
             AND KEY3 EQ LV_KEY3.
    b) SELECT *
        WHERE KEY1 EQ LV_KEY1
             AND KEY2 EQ LV_KEY2.
    Please guide me whether version (a) or version (b) will be executed faster? In case of version (b), I will have to filter data using ABAP code corresponding to KEY3.
    Regards,
    Kamlesh Dhera H. R.

    I think most experienced ABAPrs would tell you to try both, compare runtimes, and use the one that's more efficient.  SAP provides "get run time field <fieldname of type i>.  Get run time at start, get run time at end, and subtract start from end to get the time in microseconds (1 second / 1,000,000 ).
    Run several times to minimize effect of buffering and system load activity, and you'll see which method produces lower run time.

  • Am unable to get the data from Sys.databases when i use where condition for column owner_sid

     
    Hi all,
    Help me here when i try am unable to get a data,Can some one help me with a query to get.
    If it cant be done can i know why..
     select * from Sys.databases
      where owner_sid='0x01'
    What am trying is to get a login
    names from syslogin
    table with respect to Sid.
    Select a.name,b.name,a.owner_sid from Sys.databases a
      Join Syslogins b
      on a.owner_sid = b.sid
      where owner_sid like '0x01'
    Thanks all in Advance.....

    Below are a couple of examples of how to accomplish the task.  Note that SID is varbinary so the literal should not be enclosed in quotes.
    SELECT
    a.name AS DatabaseName
    ,b.name AS OwnerName
    ,a.owner_sid AS OwnerSID
    FROM sys.databases a
    JOIN sys.server_principals b ON
    a.owner_sid = b.sid
    WHERE owner_sid = 0x01;
    SELECT
    a.name AS DatabaseName
    ,SUSER_SNAME(owner_sid) AS OwnerName
    ,a.owner_sid AS OwnerSID
    FROM sys.databases a
    WHERE a.owner_sid = 0x01;
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

  • For all entries Where condition character length partilally has to be used

    Hi,
    I need to fetch all the data reocrds of one internal table into the other with the condition that in one of the field of first internal table only partial length of the character has to be used as a where condition.
    Example:
    Select xxxx
              yyyyy
              zzzzz
    into it_tab2
    for all entries in itab1
    where field2 = itab1-field1(4).
    where field1 of itab1 has length of 8 and field2 belongs to itab2.
    As it throws the error msg :
    it will ignore the length restriction mentioned in where condition of the for all entries

    Hi.
    If you are trying to fetch from any database table based on your modified table use this logic.
    Dfine another internal table same as itab1, with field one lenght as 4 char.
    ex:
    data: begin of it_tab2.
            field1(4),
    end of it_tab2.
    loop at it_tab1.
    it_tab2 = itab1+0(4).
    append it_tab2.
    clear it_tab2.
    endloop.
    now you can fetch from database table....using it_tab2.
    Select xxxx
    yyyyy
    zzzzz
    into it_tab3
    for all entries in itab2
    where field2 = itab2-field1(4).
    If you only want to move the entries form one internal table to another internal table and truncate the field1 of itab1.
    then no need to use any for all entries...
    apply this logic
    data: begin of it_tab2.
            field1(4),
    end of it_tab2.
    loop at it_tab1.
    it_tab2 = itab1+0(4).
    append it_tab2.
    clear it_tab2.
    endloop.
    Regards,
    Satish

  • How to pass where condition to report for condition

    hello people ,
    i want to pass where condition for the report statement .
    for example ,
    select ename from emp
    i want to pass parameter carry <where deptno=40>
    thanks

    Good Morning oracleuser,
    If we understood correctly, Bind references (or bind variables) should use this issue.
    a>select ename from emp where deptno= :Dept_Number
    If you have any more questions, please post it.
    Otherwise:
    Mark Helpful or Answer accordingly.

  • Single SQl Query with different where conditions

    Experts,
    I have a requirement to design a report. Here are the details
    I have Report table layout
    Profit center Gross sales (This Year) Gross Sales (Last Year) % change Year of Year
    The Report has a selection of entering the Start Date.
    I have a single table in oracle which has profit center and Gross Sales Values on daily basis.
    I want to write a single sql query to calculate both Gross Sales current year and Gross Sales Last Year. I can calculate Gross Sales Current Year by putting the where condition for start date = Current Year Date which i pass through report. I want to calculate the Gross Sales Last Year in the Same query by putting the different where condition i.e start date = Last Year date based on the date input.
    I dont know how to put two where conditions in single query for two different columns.
    Any help will be appreciated.
    Thanks in advance
    Regards
    Santosh

    instead of changing your where clause couldn't you just determine the yearly totals from your table and then use the lag statement to get last years total?
    something like this?
    I just made up 10,000 days worth of sales and called it fake table it is supposed to represent a variant of the table you were describing as your base table.
    with fake_table as
    ( select trunc(sysdate + level) the_day,
    level daily_gross_sales
    from dual
    connect by level < 10001
    select yr, year_gross_sale, lag(year_gross_sale) over (order by yr) prev_year_gross_sale,
    (year_gross_sale - lag(year_gross_sale) over (order by yr))/year_gross_sale * 100 percent_change
    from
    (select distinct yr, year_gross_sale from
    select the_day,
    daily_gross_sales,
    extract(year from the_day) yr,
    extract(year from add_months(the_day,12)) next_yr,
    sum(daily_gross_sales) over (partition by extract(year from the_day)) year_gross_sale
    from fake_table
    order by yr
    )

  • Single quote in dynamic where condition

    BAPI_STUDENT_IDENTIFIC_ADD has a field called IDENTIFICATIONNUMBER.  This field is later used in a dynamic where condition and causes a short dump when it contains a single quote.  I will change the program that calls the BAPI to check for single quotes, but is there anything else I need to check for to ensure a correct where condition?
    Thanks,
    Dan

    Hi Dan,
    The best way to ensure correctness of syntax of a dynamic where condition is:
    Run the program in debugging mode, Get the Query that is generated dynamically and write it to some other ABAP program and perform syntax check.
    This will help you to remove all the syntax errors.
    Regards,
    Darshil

  • 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

  • Using where condition with dynamic internal table

    Hi Friends.
    How to use where condition with dynamic internal table ?
    Regards,
    Amit Raut

    Hai Amit
    REPORT  ZDYNAMIC_SELECT                         .
    TABLES: VBAK.
    DATA: CONDITION TYPE STRING.
    DATA: BEGIN OF ITAB OCCURS 0,
    VBELN LIKE VBAK-VBELN,
    POSNR LIKE VBAP-POSNR,
    END OF ITAB.
    SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
    CONCATENATE 'VBELN' 'IN' 'S_VBELN.'
    INTO CONDITION SEPARATED BY SPACE.
    SELECT VBELN POSNR FROM VBAP INTO TABLE ITAB
    WHERE (CONDITION).
    LOOP AT ITAB.
    WRITE 'hello'.
    ENDLOOP.
    Thanks & Regards
    Sreenivasulu P

  • Dynamic where condition - Problem

    Hi All,
    I have a problem in a select statement where I use a dynamic condition.It gives me a dump
    SAPSQL_WHERE_PARENTHESES
    CX_SY_DYNAMIC_OSQL_SYNTAX.
    Please find the below code which I implemented.
      *SELECT * FROM ZXR5*
               WHERE (SOURCE).
    The value of SOURCE is 'MATNR EQ '000000000000200066'.
    When I checked the help, it is advised to use a CATCH exception which I did as below:
    TRY.
      *SELECT * FROM ZXR5*
               WHERE (SOURCE).
      CATCH cx_sy_dynamic_osql_error.
        MESSAGE `Wrong WHERE condition!` TYPE 'I'.
    ENDTRY.
    Now, the select statement gives an exception and is not executing to fetch the values.
    I need some input on the above issue. Any help on this would be greatly appreciated.
    Regards,
    Rajmohamed.M

    Hi Vijay,
    I tried the same and all the time, the select statement gives me an exception and wont proceed.
      TRY.
        SELECT * FROM ZXR5
                 INTO TABLE <L_ZXR5>
                 WHERE (SOURCE).
        CATCH cx_sy_dynamic_osql_error.
        MESSAGE `Wrong WHERE condition!` TYPE 'I'.
      ENDTRY.
    Regards,
    Raj

  • Dynamic Where Conditions

    SELECT ... WHERE (codsyntax).
    the consyntax should have one or combination of the value
    1) txps = 'a~pspid = waparm-pspid'.
    2) txpo = 'b~posid = waparm-posid'.
    3) txau = 'c~aufnr = waparm-aufnr'.
    the input options:
    1)  codsyxtax = txps
    2)  codsyxtax = txpo
    3)  codsyxtax = txau
    4)  codsyxtax = txps and txpo
    5)  codsyxtax = txps and txau
    6)  codsyxtax = txpo and txau
    7)  codsyxtax = txps and txpo and txau
    i'm tried to something like this, just i think is quite messy. thanks you
    if waparm-pspid is not initial and waparm-posid is initial.
        concatenate whercond txps into whercond separated by space.
    elseif waparm-pspid is not initial and waparm-posid is not initial.
       concatenate whercond txps into whercond separated by space.
       concatenate whercond 'and' into whercond separated by space.
    endif.

    hi augustarian,
    i'll store this into an internal table. from the data. it can be seen there a BLANK input. so the blank input should not be included into WHERE connditions. i tried to do something like this:
    PSPID         POSID     AUFNR     PSY     PUS        cond_syx
    aa-aa-aa     a1                           I001                  if proj~pspid = itparm-pspid and prps~posid = itparm~posid and ....
    bb-bb-bb                   b1                         E009     if proj~pspid = itparm-pspid and aufk~aufnr = itparm~paufnr and ....
    cc-cc-cc                                                             if proj~pspid = itparm-pspid
    and implement with FOR ALL ENTERIES, but at the WHERE conditions i failed to put the CONF_SYX. please comment and give opinions. Thanks you very much.

Maybe you are looking for

  • Attempting to use several url parameters in one url

    Problem: I can either pass along the picture ID parameter or the album ID parameter to the next page, but never both I have a URL parameter for the picture ID, and I have another for the album ID, which determines also the directory where the picture

  • Outlook 2003 Folders

    I use Outlook on PC for managing a number of email accounts (NOT Gmail) 5 of which are also linked to my 8520. I do not have Outlook on the BB. The email accounts are directly linked. In practice a new email arrives on the BB before it appears in Out

  • Conditonal text in tables

    I'm using X5 RoboHelp HTML. I have applied a CBT to a row in a table. The text disappears, as it should, but the empty table row is left behind. How can I get the table row to disappear? Thank you, Dawn

  • Interactive Reports using Collections

    I need to prepare queries dynamically using PLSQL on apex 3.2; Since interactive reports are currently supported only using SQL queries , I am storing the results in a collection and then retrieving the results from the collection. I got this working

  • I CAN'T DOWNLOAD THE FILMS RENTED. THE DOWNLOAD IS STOPPED FAR BEFORE THE DOWNLOAD IS COMPLETED AND DISAPPEAR THE POSSIBILITY TO DOWNLOAD AGAIN

    I CAN'T DOWNLOAD THE FILMS RENTED. THE DOWNLOAD IS STOPPED FAR BEFORE THE DOWNLOAD IS COMPLETED AND DISAPPEAR THE POSSIBILITY TO DOWNLOAD AGAIN