Variable for entire where clause

Is it possible to use a variable for the entire where clause in a PL/SQL select statement?
I have a where clause stored as a string in the database and I want to use that entire string as a variable, but my procedure will not compile because it is missing the relational operator.
SELECT whereclause FROM clausetable WHERE clause = 'TEST'; will return this string: column1 = 'abc'
Here's my procedure:
create or replace
PROCEDURE TESTWC
(c_out OUT sys_refcursor )
AS
BEGIN
DECLARE
v_whereclause VARCHAR2(255);
BEGIN
SELECT whereclause
INTO v_whereclause
FROM clause_table
WHERE clause = 'TEST';
DBMS_OUTPUT.PUT_LINE(v_whereclause);
OPEN c_test FOR SELECT * FROM dpacsoftware WHERE v_whereclause;
NULL;
END;
END TESTWC;

Is it possible to use a variable for the entire where clause in a PL/SQL select statement?Unfortunately yes.
I have a where clause stored as a string in the databaseThis is a really bad idea, like storing the source for half your program in a text file with a bunch of Java or C or FORTRAN code and opening, reading, compiling and linking at run time.
It is slow, slow, slow as you can expect, and dangerous and insecure, since someone could have put a format C: command in your source file, or something equivalently nasty to a database.

Similar Messages

  • NVL with host variables in a where clause

    Does anyone know if using a host variable in a WHERE clause with
    the NVL function will actually work if the host variable is null
    without using the indicator variable too?
    In other words if the variable ":new_prmy_numb" which was
    selected previously is actually null, will the NVL know that it
    is null without the indicator variable being listed also? The
    person at our company who has this in their code says it works
    and the rest of us don't see how.
    Example:
    SELECT recd_a_id from ADDR
    WHERE
    NVL(prmy_numb,' ') = NVL(:new_prmy_numb,' ')

    well firstly have you tried it to see if it works? That would seems to be a rather obvious step, I would imagine.
    Anyway, I don't see anything wrong with the code, except that it might be optimized better ...
    SELECT recd_a_id from ADDR
    WHERE
    (prmy_numb = :new_prmy_numb
    or (:new_prmy_numb is null and prmy_numb is null))
    ... might stand more chance of using an index on the column prmy_numb

  • Parsing an input parameter for the where clause or record select value

    In my limited CR experience, I've always used a command database connection so that I can write my own SQL.  However, now I have to parse a  pipe delimited parameter to get my value for the where clause, so I'm selecting several tables and joining them through the Database Expert Links tab.  All works fine, but after doing that and then parsing the parameter with the below formula in the Select Expert, I notice that there is no where clause in the SQL query, and although the report eventually displays the proper values, it runs through thousands of records first.  Here is my Select Expert - Record formula:
    StringVar array Parm1;
    Parm1 := Split({?DATA_AREA}, "|");
    {SO_ORDERS.CASE_ID} = Parm1[2]
    If I change "Parm1[2]" on the last line to a valid Case ID, then there is a where clause in the SQL and the report generates immediately. 
    It seems like the record select formula is applied AFTER all of the records (without a where clause) are searched when I use the parsed parameter value, but when I hard code a valid value, it places that into the where clause BEFORE the sql is executed.  Is there a way to get the parameter parsed first and then use that parsed value in the SQL where clause?
    Thanks.
    Bill

    Yes crystal will run the query first to get 100% data and then applies record selection condition. To increase the performance you need to pass the where condition at the command level instead of report level. So you need to create a report using add command like this
    select * from tablename where field={?Parameter}
    {?Parameter} is a command level parameter.
    Now insert this report as a subreport in another report which has no connection but has a parameter
    {?DATA_AREA} and create a formula like this in the main report
    Split({?DATA_AREA}, "|")[2]
    Now right click on the subreport and go to change subreport links and add this formula from main report and link this to sub report parameter {?Parameter} without linking any database field from the subreport.
    Now your subreport runs with the where clause to get the data.
    Regards,
    Raghavendra

  • Using bind variable in dynamic where clause and concatenate with query

    Hi,
    In my procedure i am framing where clause dynamically with bind variable,When i am concatenate this with my sql query for REF CURSOR i got sql command not properly ended exception.
    Is it possible to pass values to the bind variable through the dynamic variable/value?
    Please advise
    Thanks in advance
    Siva
    IF in_applicationId IS NOT NULL THEN
              optional_where := optional_where || ' AND a.APPLICATION_ID like '||':e%';
              optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'||',in_queue_id'||',in_applicationId';
         END IF;
    My query is like this
    open Out_Main FOR SelectQuery USING optional_using

    Thanks for reply,
    In my procedure, i suppose to frame the where clause with bind dynamically according to the input parameters. so that i am framing the values of the bind variables also dynamically like this,
    Please advise...
    IF in_assignedAppFlag IS NOT NULL THEN
              IF in_assignedAppFlag = 'Y' THEN
                   optional_where := optional_where || ' AND b.ASSIGNED_TO = :b' ;
              optional_using := ' in_appFuncGroup'||',in_currentUserID';          
              ELSe
                   IF in_isSupervisor = 0 THEN
                        optional_where := optional_where || ' AND (b.ASSIGNED_TO = :b'||' OR b.ASSIGNED_TO = ''-1'' OR b.ASSIGNED_TO IS NULL)';
              optional_using := ' in_appFuncGroup'||',in_currentUserID';
                   END IF;
              END IF;
         ELSE
              IF in_isSupervisor = 0 THEN
                   optional_where := optional_where || ' AND (b.ASSIGNED_TO = :b'||' OR b.ASSIGNED_TO = ''-1'' OR b.ASSIGNED_TO IS NULL)';
                   optional_using := ' in_appFuncGroup'||',in_currentUserID';
              END IF;
         END IF;
         IF in_appFuncGroup IS NOT NULL THEN
              optional_where := optional_where || ' AND e.APP_FUNC_GROUP= :c';
              optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup';
         END IF;
         IF in_queue_id IS NOT NULL THEN
              optional_where := optional_where || ' AND b.QUEUE_ID = :d';
              optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'||',in_queue_id';
         END IF;
         IF in_applicationId IS NOT NULL THEN
              optional_where := optional_where || ' AND a.APPLICATION_ID like '||':e%';
              optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'||',in_queue_id'||',in_applicationId';
         END IF;
         IF in_sourceCode IS NOT NULL THEN
              optional_where := optional_where || ' AND e.APP_SOURCE_CODE like '||':f%';
              optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'
              ||',in_queue_id'||',in_applicationId'||',in_sourceCode';
         END IF;
         IF in_logo IS NOT NULL THEN
              optional_where := optional_where || ' AND appProds.PRODUCT_TYPE like '||':g%';
              optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'
              ||',in_queue_id'||',in_applicationId'||',in_sourceCode'||',in_logo';
         END IF;
         IF in_firstName IS NOT NULL THEN
              optional_where := optional_where || ' AND upper(a.FIRST_NAME) like upper(:h%)';
              optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'
              ||',in_queue_id'||',in_applicationId'||',in_sourceCode'||',in_logo'||',in_firstName';
         END IF;
         IF in_surName IS NOT NULL THEN
              optional_where := optional_where || ' AND upper(a.SURNAME) like upper(:i%)';
              optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'
              ||',in_queue_id'||',in_applicationId'||',in_sourceCode'||',in_logo'||',in_firstName'||',in_surName';
         END IF;
         IF in_retreival_id IS NOT NULL THEN
              optional_where := optional_where || ' AND e.RETREIVAL_ID like :j%';
              optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'
              ||',in_queue_id'||',in_applicationId'||',in_sourceCode'||',in_logo'||',in_firstName'||',in_surName'||',in_retreival_id';
         END IF;

  • How to use a lexical variable in a WHERE clause and as a function argument.

    Hello,
    My report has a lexical variable which has values like 'and id in (1,3,4)'. I want to use this variable in two separate queries. In the first, it is used in the WHERE clause, something like:
    .. where date is not null &var;
    In the second query, the variable is used in a function call, something like:
    select * from table (my_function(&var));
    The trouble is that the first query works when the value of the variable is unquoted, but for the second query the value should be quoted.
    Does anyone have an idea how I could solve this problem?
    Thanks in advance,
    Frans
    Message was edited by:
    fransie

    http://tkyte.blogspot.com/2006/06/varying-in-lists.html
    Presents many options.

  • Using a report value for a where clause in other report

    Hi All,
    i'm getting kinda nuts here. I created a page with three reports.
    First report show the name of the user who logged in with his/her whole name. Second report shows the year, week, begin/end date of the week for the user in the first report. The third report show the hours the user worked in the week selected in the second report.
    The link between first and second report is on column report. Somehow i managed it to work with second_report.mdw_code = :P3_ACRONIEM. I have no idea were this P3_ACRONIEM item is coming from, while i have no items in my page whatsoever. Now i need to link the second report to the third report. I have to use the second_report.mdw_code, second_report.year and second_report.week but i have no idea how to link these together. Any idea's? (Like making items, but then i have no idea how to link that item to the value in the second report). Please help.
    Kind regards,
    Dave
    The link between the first and the second i could get it to work with :P3_ACRONIEM. I have no idea where this ITEM is coming from, because i have no items in my page (and it's the only page in the application). Then

    Hi Dave,
    If I understand you correctly, you have a one report that lists users, a second report that lists dates and a final report that shows hours worked?
    If so, you may find it easiest to have hidden fields on your page and base the second and third reports on these using appropriate WHERE clauses. (I generally put hidden fields in a region in the "After Header" position)
    So, if the first report contains a USER_ID field, have a hidden field called P1_USER_ID. The link on the first report will branch back to the same page and set the value of P1_USER_ID to #USER_ID# The second report can then use WHERE USER_ID = :P1_USER_ID. When the page reloads, the second report redisplays and is filtered to show only those records relating to the selected USER_ID in the first report.
    To extend this, if the second report contains WEEK_NUMBER, it should have a link that branches back to the same page and sets a hidden P1_WEEK_NUMBER field with #WEEK_NUMBER#. The third report should when have WHERE WEEK_NUMBER = :P1_WEEK_NUMBER AND USER_ID = :P1_USER_ID. You can, if need be, have and set more than one hidden field during each link.
    Regards
    Andy

  • How to bind a VO :variable in a WHERE clause to a page parameter

    Hello,
    I have a VO. This VO has a variable :v in the WHERE clause of the query.
    This VO is used by different UI components in a page (a table, a tree). The page already has a parameter defined in his properties #{viewScope.myparam}
    What I want is to bind :v to the #{viewScope.myparam}, so that I can specify :v from a parameter in the URL, so that the table immeditaly shows the proper results.
    Is there a way to Bind :v to #{viewScope.myparam} directly in the VO definition in the model project? (It seems it is not possilble)
    The other alternative is to use ExecuteWithParams, but in this case I do not know how to perform the query without user actions in a trasparent way. I dont want to associate execute operations to UI components.
    thanks

    Hi,
    +Is there a way to Bind :v to #{viewScope.myparam} directly in the VO definition in the model project? (It seems it is not possilble)+
    No, this can't be done
    The other alternative is to use ExecuteWithParams, but in this case I do not know how to perform the query without user actions in a trasparent way. I dont want to associate execute operations to UI components.
    If you are within a bounded task flow or in an unbounded task flow that does not have this page as its first view (home page) then you can drag and drop executeWithParams as a method call activity. The attribute then should be saved in the pageFlowScope (not the viewScope).
    In addition I would use a ViewCriteria instead of "hard wiring" the bind variable to the VO definition. You can then - in the AM data model section - associate the View Criteria with the VO instance yo use in the UI
    Frank

  • How to use an UNIX shell variable in sql where clause

    Hi ,
    In my shell script first I get the Date and time from the system into the shell variable.At the end of the shell script I need to run a sql script in which I want to use the variable value in the where clause . Is there any way we can use a shell variable value in SQl script ?. Any help is greatly appriciated .
    Thanks in advance,
    Sampath

    Try the following
    In Unix
    SQLPLUS <username>/<password> @MyScript.sql <UNIX_Variable>
    In SQL*Plus
    Reference the variable as &1
    select *
    from MyTable
    where MyDate = to_date('&1','<date_format>');

  • Selecting values for query where clause

    hi guys, this is possibly a silly question but not sure if i am approaching the solution in the correct mannor.
    At the top of my form i have text box which the user fills in various values. These values are then used to refine the query results in the block below. I know i can go into the datablock being queried and set the where clause to equal the value of the text boxes above but i dont feel this is the right place to do it.
    If i do it that way when the text box above is blank it returns no reults when infact i want to query everything if the values are left blank. So should i put it in pre query? if so what way should it be done?
    Any help would be greatly appreciated.
    Thanks.

    Hello,
    If i do it that way when the text box above is blank it returns no reults when infact i want to query everything if the values are left blank. So should i put it in pre query? if so what way should it be done?Not really if you use like below in block's where clause...
    db_field_name1=NVL(:form_field_name1,db_field_name1) AND
    db_field_name2=NVL(:form_field_name2,db_field_name2)-Ammad

  • UPDATE using a second table for the Where Clause

    Hi There,
    Hoep someone can help me!
    I am attempting to update a field in Tbl.1 to a known value. However, i want to use another table to specify WHICH records to update.
    in this case i want to use table early_provider to obtain the value 'HCR' then pass that to the UPDATE clause in order to SET early_provisions.type_name = 'HOMC'
    I hope this makes sense.
    UPDATE EARLY_PROVISIONS eps
    SET TYPE_NAME = (SELECT *
    FROM EARLY_PROVIDER ep
    WHERE PROVIDER_TYPE = 'HCR'
    WHERE EP.PROVIDER_ID = EPS.PROVIDER_ID);
    I need to be able to include the field value 'HOMC in this statement but am not sure how, or if i am barking up the wrong tree.
    Much appreciated in advance
    PFG

    PFGMcAvoy wrote:
    Karthick_Arp
    Thanks. this seems to only update 15 rows of which already exist in the table early_provisions and filed type_name!
    I should be selecting about 200 recordsd from early_provider that have the provider_type = 'HCR'
    ??I don't know your data. So i cant answer that. But for what you asked i think thats the correct UPDATE statement. So i think you have to investigate your data to find what is going on.

  • Using a date variable in a where clause

    Hi,
    I need to run a select query which contains the following
    e.g
    String query = SELECT APP_DATE, APP_TIME, APP_TYPE, a.CUST_NO
    FROM APPOINTMENTS a, PATIENT_DETAILS p
    WHERE APP_DATE = " + appDate + " and p.CUST_NO = a.CUST_NO
    appData is a java.sql.Date format and contain the date i want to find. The error i get is "Operator = doesn't apply to the types <DATE> and <INT>"
    I have also read somewhere that this would return the date at midnight and therefore would not match, how can i fix this. I am using JDataStore for development.
    Thanks
    Rudy

    you want something like this
    SimpleDateFormat df = new SimpleDateFormat ("yyyy-MM-dd");
    String sql = "SELECT * FROM Table WHERE appDate='" + df.format(appDate) + "';";     
    Or if you used prepared statements, you could pass the java.sql.Date to it without the need to convert.

  • Two variables in the where clause

    DECLARE @Id VARCHAR(100)
    DECLARE @NO VARCHAR(100)
    SET @Id = 'IN'
    SET @No = 10
    SELECT *
    FROM DBName.sys.indexes I
    JOIN DBName.sys.tables T ON T.Object_id = I.Object_id
    WHERE T.name like '%' +@Id + '_' +@NO+'%'
    I need something like the above query that works.

    Question is vague
    Cant understand what you're really looking for as posted query has no obvious errors
    Can you give some sample data and explain what you're trying to get as output
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Cursor did not return data if using variables in the where clause

    ENV: report builder 9.0.4.3.0, DB 10g, OS XP
    table and data ctvctyp:
    ctvctyp_code    ctvctyp_code_pred
       CO               Z1
       FE                   Z1
    FUNCTION get_case_type(case_type VARCHAR2) RETURN VARCHAR2 IS
      cursor  type_cur is
        select ctvctyp_code
        from ctvctyp
        where ctvctyp_code_pred = :P_case_type; -- if use 'Z1', it will return 'CO','FE'
                                                -- but if 'Z1' is passed in as case_type, it returns null.
      temp_type     VARCHAR2(4);
      return_type   VARCHAR2(200);
      counter       NUMBER;
    BEGIN
         return_type := '';
         counter := 0;
         srw.message(20,'in case_type is '||case_type);
         open type_cur;
         LOOP
              FETCH type_cur INTO temp_type;
              EXIT WHEN type_cur%NOTFOUND;
              counter := counter+1;
              if temp_type is NULL then
                   srw.message(20,'temp type is null');
              else
                srw.message(20,temp_type);
              end if;
              if counter = 1 then
                   return_type := ''''||temp_type||'''';
              else
                   return_type := return_type||','''||temp_type||'''';
              end if;     
         END LOOP;
         return return_type;
    END;
    In my p_casetype validation trigger:
    function P_CaseTypeValidTrigger return boolean is
         tempCaseType   VARCHAR2(200);
         return_type    VARCHAR2(200);
    begin
        :P_CASETYPE := 'Z1'
        return_type := get_case_type;   --- I got null returned.
      return (TRUE);
    end;
    But in sqlplus:
    declare a bind variable :P_casetype := 'Z1';
    select get_case_type from dual;
    returns:   'FE','MI'

    cursor type_cur is
    select ctvctyp_code
    from ctvctyp
    where ctvctyp_code_pred = _{color:#0000ff}*:P_case_type;*_{color}Shouldn't be this :p_casetype instead of :p_case_type?

  • Select multiple summations for different where clauses

    Hello,
    I have table with invoice amounts of an article stored per period per year.
    The table looks like this:
    YEAR number(4) #pk
    PERIOD number(2) #pk
    ART number(12) #pk
    AMOUNT number(10,2)
    Suppose i have stored following info
    YEAR PERIOD ART AMOUNT
    2001 11 455 100.00
    2001 12 455 150.00
    2002 1 455 300.00
    2002 2 455 200.00
    2002 12 455 700.00
    2003 1 455 220.00
    I want to select the total amounts per article per year
    and the total amounts per article per previous years
    in ONE SELECT statement
    When performing the follwing select i dont get the right information:
    select a.year
    , a.art
    , sum(a.amt) year_amt
    , nvl(sum(b.amt)) previous_years_amt
    from app_inv a
    , app_inv b
    where b.YEAR (+) <= ( a.year - 1 )
    and b.ART (+) = b.art
    group
    by a.year
    , a.art
    Results in:
    YEAR ART YEAR_AMT PREVIOUS_YEARS_AMT
    2001 455 250 0
    2002 455 2400 750
    2003 455 1100 1450
    But i expected
    YEAR ART YEAR_AMT PREVIOUS_YEARS_AMT
    2001 455 250 0
    2002 455 1200 250
    2003 455 220 1450
    The cause is a cartesian product because i omit the
    column PERIOD, but adding that extra where
    (b.PERIOD (+) = a.period) isn't also succesful:
    YEAR ART YEAR_AMT PREVIOUS_YEARS_AMT
    2001 455 250 0
    2002 455 1200 150
    2003 455 220 300
    Does anyone know how format this into 1 select statement resulting in on record per year per article.
    Thanks in advance
    Auke Quist.

    Thanks, your select works, but just for one article
    When storing multiple articles over multiple years/periods
    i don't get the expected result.
    create table app_inv
    ( YEAR number(4) not null
    , PERIOD number(2) not null
    , ART number(12) not null
    , AMOUNT number(10,2) not null
    delete app_inv
    insert into app_inv values ( 2001, 11, 455, 100.00 )
    insert into app_inv values ( 2001, 12, 455, 150.00 )
    insert into app_inv values ( 2002, 1, 455, 300.00 )
    insert into app_inv values ( 2002, 2, 455, 200.00 )
    insert into app_inv values ( 2002, 12, 455, 700.00 )
    insert into app_inv values ( 2003, 1, 455, 220.00 )
    insert into app_inv values ( 2001, 10, 475, 100.00 )
    insert into app_inv values ( 2001, 11, 475, 150.00 )
    insert into app_inv values ( 2002, 3, 475, 300.00 )
    insert into app_inv values ( 2002, 4, 475, 200.00 )
    insert into app_inv values ( 2002, 5, 465, 700.00 )
    insert into app_inv values ( 2003, 1, 475, 220.00 )
    Prompt select statement works for 1 article
    SELECT a.year
    , a.art
    , sum(a.amount) year_amt
    , sum(sum(a.amount))
    OVER (ORDER by a.year, a.art ROWS UNBOUNDED PRECEDING)
    - sum(a.amount) AS previous_years_amt
    FROM app_inv a
    WHERE a.art=455
    GROUP BY a.year
    , a.art
    order by a.art
    Prompt select statement fails for more than 1 article
    SELECT a.year
    , a.art
    , sum(a.amount) year_amt
    , sum(sum(a.amount))
    OVER (ORDER by a.year, a.art ROWS UNBOUNDED PRECEDING)
    - sum(a.amount) AS previous_years_amt
    FROM app_inv a
    GROUP BY a.year
    , a.art
    order by a.art
    Are you able to help me further on, or anyone else?
    Note i'm using 8.1.7.1.1 RDBMS
    Thanks in advance
    Auke Quist

  • Dynamic itab with Dynamic Where clause

    Hi, Dear All,
    Can someone provide a code extract for Dynamic where clause, i had already done with dynamic itab for a given set of fields, and i need to add where clause dynamically for a given field for a given range of values.
    select (i_fields) into table <dyn_table>
                      from (p_table)
                     where (v_where).
    In the above except the where clause, everything is done. Please help me.
    with best regards
    Mahesh

    Hi,
    here is the code extract for your reference.Pl. correct me.
    with regards
    REPORT  Z_DYN_ITAB                              .
    TYPE-POOLS: SLIS.
    DATA:NAME(100) TYPE C.
    TYPES: BEGIN OF ITAB_TYPE,
            WORD(20),
          END   OF ITAB_TYPE.
    DATA: ITAB TYPE STANDARD TABLE OF ITAB_TYPE WITH HEADER LINE.
    DATA: vg_fields(255) TYPE c,
          i_fields LIKE TABLE OF vg_fields.
    DATA: it_fcat TYPE slis_t_fieldcat_alv,
          is_fcat LIKE LINE OF it_fcat,
          ls_layout TYPE slis_layout_alv.
    DATA: it_fieldcat TYPE lvc_t_fcat,
          is_fieldcat LIKE LINE OF it_fieldcat.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>,
                   <dyn_field>.
    data: dy_table type ref to data.
    data: dy_line type ref to data,
          xfc type lvc_s_fcat.
    DATA: v_where TYPE string, " Variable for storing where clause.
          v_dynamic(18) TYPE c, "variable to store select option datatype
          o_field TYPE REF TO cx_root," object to catch exception
          text TYPE string. "string variable to store exception text.
    CONSTANTS: c_var(15) TYPE c VALUE ' IN S_RANGE'.
    selection-screen begin of block b1 with frame.
    parameters: p_table(30) type c default 'T001',
                p_name(100) type c,
                p_field(10) TYPE c. " Parameter to capture field name.
    SELECT-OPTIONS: s_range FOR v_dynamic. " Select-option for range.
    selection-screen end of block b1.
    start-of-selection.
    NAME = p_name.
    SPLIT NAME AT ',' INTO TABLE ITAB.
    LOOP AT ITAB.
    is_fcat-fieldname = itab-word.
    is_fcat-tabname = p_table.
    APPEND is_fcat to it_fcat.
    ENDLOOP.
    LOOP AT it_fcat INTO is_fcat.
      is_fieldcat-fieldname = is_fcat-fieldname.
      is_fieldcat-tabname = is_fcat-tabname.
      APPEND is_fieldcat TO it_fieldcat.
      CONCATENATE is_fieldcat-tabname is_fieldcat-fieldname INTO
            vg_fields SEPARATED BY '~'.
      APPEND vg_fields TO i_fields.
    ENDLOOP.
    perform create_dynamic_itab.
    perform get_data.
    Create dynamic internal table and assign to FS
    form create_dynamic_itab.
    call method cl_alv_table_create=>create_dynamic_table
    exporting
    it_fieldcatalog = it_fieldcat
    importing
    ep_table = dy_table.
    assign dy_table->* to <dyn_table>.
    Create dynamic work area and assign to FS
    create data dy_line like line of <dyn_table>.
    assign dy_line->* to <dyn_wa>.
    endform.
    form get_data.
    Select Data from table.
    CONCATENATE p_field c_var INTO v_where.
    TRY.
    select (i_fields) into table <dyn_table>
                      from (p_table)
                     where (v_where).
    if sy-dbcnt = 0.
    write : text-t02.
    endif.
    *Write out data from table.
    Loop at <dyn_table> into <dyn_wa>.
    do.
    assign component sy-index of structure <dyn_wa> to <dyn_field>.
    if sy-subrc <> 0.
      exit.
    endif.
    if sy-index = 1.
      write:/ <dyn_field>.
    else.
      write: <dyn_field>.
    endif.
    enddo.
    endloop.
    Exception Catching.
    CATCH cx_root INTO o_field.
    text = o_field->get_text( ).
    Calling Function to give information message regarding Exception
    CALL FUNCTION 'POPUP_TO_INFORM'
    EXPORTING
    titel = text-t03
    txt1 = text
    txt2 = text-t04.
    TXT3 = ' '
    TXT4 = ' '
    LEAVE TO LIST-PROCESSING.
    ENDTRY.
    endform.

Maybe you are looking for

  • Get message: local logical system is not defined - in trans. vl01n

    Hi experts, i got this message after i saving data in trans. vl01n. what should i do to not see this message after i save data in this transaction? thanks, dana.

  • Help installing Windows 7RC

    I am hoping that someone here can help me. I am trying to install Windows 7RC, but ran in a road block. I have a late 2007 MacBook with 2gig ram. When I try to start up the computer with the Windows 7RC (just downloaded from MS) I get following on my

  • Language Swithing

    Dear All, i am working on bilingual project. And my some of the fileds are in arabic. The problem i am facing is when ever i got focus on arabic field i use ALT+SHIFT key to change the input stat to arabic and when i go to english filed again then ag

  • Netweaver Developer Studio 7.3 "JVM terminated exit code = -1"

    Hello, the developer studio can not be started and the error which is shown is "jvm terminated. exit code = -1" My system is windows7, I am using oracle java 1.6, NWDS  (7.3 SP01). This is my .ini file: -vm C:\Program Files\Java\jdk1.6.0_21\bin\ -sta

  • APEX Installation Problem

    I have a virtualized environment with Windows XP as host and RHEL-4 as guest. I installed 10g Release 2 on Linux and Oracle HTTP Server on XP. Before installing APEX and configuring DAD File everything was fine. After that HTTP Server stopped respond