Can we pass IT table name dynamically to READ and SORT stmt

Hello All,
  i have a requirement in which i am passing table name using a variable and want to read the same table: so my question is can we execute read and sort stmt with dynamic IT name. please see below for explaination.
v_itname = <it_2>.
now read using variable
READ table ( v_itname ) with key <field>.
and
SORT ( v_itname ) by (otab).
thanks
Mani

Hi ,
This can be done. Please refer to the  codes below. Please note that the code will work if the itabs are of type standard table else it may dump.
You just need to replace the variables form the values from your internal table.
DATA: v_table1(10) TYPE c VALUE 'I_MARA',
      v_field(10)  TYPE c VALUE 'MATNR',
      i_mara TYPE STANDARD TABLE OF mara.
FIELD-SYMBOLS : <fs_tab>   TYPE STANDARD TABLE,
                <fs_field> TYPE ANY.
DATA: otab TYPE abap_sortorder_tab,
oline TYPE abap_sortorder.
SELECT * UP TO 10 ROWS
  FROM  mara
  INTO TABLE i_mara.
IF sy-subrc = 0.
  ASSIGN (v_table1) TO <fs_tab>.
  IF sy-subrc = 0.
    oline-name = v_field.
    APPEND oline TO otab.
    SORT <fs_tab> BY (otab).
    READ TABLE <fs_tab>
    WITH KEY (v_field) = '000000000020000989' "
    BINARY SEARCH
    TRANSPORTING NO FIELDS.
    IF sy-subrc = 0.
    ENDIF.
  ENDIF.
ENDIF.
Regards,
Dev.

Similar Messages

  • How to pass the table name dynamically in xml parsing

    Hi All,
    I have created one procedure for parsing xml file which is working perfectly.
    FORALL i IN t_tab.first .. t_tab.last
             INSERT INTO Test_AP VALUES t_tab(i);Now I want to put the table name dynamically+. For that I have added one query and modify above code as follow:-
    I have already declare dml_str varchar2(800) in declaration part.
    Query is as follows:-
    select table_name into tab_name from VERSION_DETAILS where SUBVERSION_NO=abc;  -- here abc is variable name which contains values.
    FORALL i IN t_tab.first .. t_tab.last
              dml_str := 'INSERT INTO ' || tab_name || ' values :vals';
              EXECUTE IMMEDIATE dml_str USING t_tab(i);But it's not working. How I will resolve this or through which way I achieved the intended results. Anyone can guide me on this matter.
    Thanks in advance for your help...

    Hi,
    But it's not working.Don't you think it would help to give the error message?
    Put the assignment before FORALL.
    FORALL only accepts one subsequent DML statement (static or dynamic SQL) :
    dml_str := 'INSERT INTO ' || tab_name || ' values :vals';
    FORALL i IN t_tab.first .. t_tab.last          
    EXECUTE IMMEDIATE dml_str USING t_tab(i);

  • CAN I PASS A TABLE NAME AS A VARIABLE IN THE FROM CLAUSE?

    For some reason, I am trying to use a variable name containing the actual table name in the from clause and it won't allow me. I keep getting the error saying I need to declare the variable I'm using eventhough I've used it in another statement that is not the FROM clause.
    Example
    SELECT count(col1), sum(col2)
    FROM v_table_name;
    v_table_name was declared as:
    v_tablename VARCHAR2(20);
    v_tablename := real_table_name;
    Is it not allowed to use variables in the FROM clause or am I missing something here?

    You can use the Forms "From Clause Query" as the datasource for the data block. Then you can change the QUERY_DATA_SOURCE_NAME using set_block_property, so you can use any SQL statement you like. Of course you must name/alias the columns in a consistent manner so that the number of database items on the block matches those being queried.

  • How to populate table name dynamically to a ref cursor

    Hi,
    I came accross with a requirement that in ref cursor how can i pass the table name
    for ex
    open ref_cur for select * from emp;Like that i've some 100 tables , instead of typing each and every time the table name
    that should be dynamically changed
    Like below
    open ref_cur for select * from &tbl_nm;How can i do that??
    Thank you

    I assume you are using SQL*Plus:
    SQL> variable ref_cur refcursor;
    SQL> begin
      2      open :ref_cur for select * from &tbl_nm;
      3  end;
      4  /
    Enter value for tbl_nm: emp
    old   2:     open :ref_cur for select * from &tbl_nm;
    new   2:     open :ref_cur for select * from emp;
    PL/SQL procedure successfully completed.
    SQL> print ref_cur
         EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 12/17/1980 00:00:00        800                    20
          7499 ALLEN      SALESMAN        7698 02/20/1981 00:00:00       1600        300         30
          7521 WARD       SALESMAN        7698 02/22/1981 00:00:00       1250        500         30
          7566 JONES      MANAGER         7839 04/02/1981 00:00:00       2975                    20
          7654 MARTIN     SALESMAN        7698 09/28/1981 00:00:00       1250       1400         30
          7698 BLAKE      MANAGER         7839 05/01/1981 00:00:00       2850                    30
          7782 CLARK      MANAGER         7839 06/09/1981 00:00:00       2450                    10
          7788 SCOTT      ANALYST         7566 04/19/1987 00:00:00       3000                    20
          7839 KING       PRESIDENT            11/17/1981 00:00:00       5000                    10
          7844 TURNER     SALESMAN        7698 09/08/1981 00:00:00       1500          0         30
          7876 ADAMS      CLERK           7788 05/23/1987 00:00:00       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 12/03/1981 00:00:00        950                    30
          7902 FORD       ANALYST         7566 12/03/1981 00:00:00       3000                    20
          7934 MILLER     CLERK           7782 01/23/1982 00:00:00       1300                    10
    14 rows selected.
    SQL> begin
      2      open :ref_cur for select * from &tbl_nm;
      3  end;
      4  /
    Enter value for tbl_nm: dept
    old   2:     open :ref_cur for select * from &tbl_nm;
    new   2:     open :ref_cur for select * from dept;
    PL/SQL procedure successfully completed.
    SQL> print ref_cur
        DEPTNO DNAME          LOC
            10 ACCOUNTING     NEW YORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
    SQL> SY.

  • HOw can i show a table(name given in parameters) in a report program

    I made a report in which there is a paremeter asking for a table name ....
    PARAMETERS TBLLE_NAME(10) OBLIGATORY.
    Now when I enter the table namke then how can i show its values....
    HINT:- We have to use fiels symbols....AND THE USER CAN ENTER ANY DDIC TABLE NAME having some records ...........

    You can display the contents of the DB table inputted using ALV.
    Pass the Structure name as the DB table name inputted.
    Use CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE to create the dynamic table of the same structure as the DB table passed.
    Once the above steps are done, the internal table with data can be displayed using ALV.
    Reward points for all helpful answers.
    Thanks,
    Balaji

  • How to use table name dynamically in report  procedure

    Hello every body
    I want to use table name dynamically means at runtime i want to pass table name.
    I can do this by lexical parameter in main query.
    But my problem is that i want to crate new format trigger or new function that use 1 cursor in which that lexical parameter : table name is used.
    so how to do that?
    i can not use that lexical parameter it is giving error.
    please help me how to do that.

    Call a database function which you pass the lexical parameter. Then in the database function you use dynamic sql or the execute immediate option to build the SQL string.
    Return the information from this function to build your business logic on in your format trigger.
    Marcos

  • Problem in using table name dynamically in PL/SQL

    I tried to create a procedure to use table name dynamically and got the following error. Anything wrong with my procedure?
    NFADV>declare
      2   cnt number;
      3   cursor cur is select table_name from user_tables where table_name in ('EMP','DEPT');
      4  begin
      5   for c1 in cur
      6   loop
      7    execute immediate select count(*) into cnt from c1.table_name;
      8      dbms_output.put_line('Count is : '||cnt);
      9   end loop;
    10  end;
    11  /
    declare
    ERROR at line 1:
    ORA-06550: line 7, column 21:
    PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
    ( - + case mod new not null <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> avg
    count current exists max min prior sql stddev sum variance
    execute forall merge time timestamp interval date
    <a string literal with character set specification>
    <a number> <a single-quoted SQL string> pipe
    <an alternatively-quoted string literal with character set specification>
    <an alternatively-quo
    ORA-06550: line 8, column 5:
    PLS-00103: Encountered the symbol "DBMS_OUTPUT"
    ORA-06550: line 8, column 45:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
    . ( , * % & - + / at mod remainder rem <an identifier>
    <a double-quoted delimited-identifier> <an exponent (**)> as
    from into || multiset bulkThanks and Regards
    Kaustubh

    Hi,
    The wrong part is in execute immediate, it should be as follows:
    execute immediate ('select count(*) from '|| c1.table_name)
    into cnt
    (not tested)
    Regards
    AK

  • Can we pass Internal tables to workflow container?

    workflow container has a size limitation, we need to pass any infotype to the workflow container, so can we pass internal tables to workflow container or is there any alternate solution?
    Thanks in Advance
    Hari

    Hi,
    Check the <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/a6/9bac935f2c11d194a40000e82dec10/frameset.htm">Multiline Container Element Definition.</a>
    Regards
    <i><b>Raja Sekhar</b></i>

  • Table name to find customer and which sales area he belongs to?

    Table name to find customer and which sales area he belongs to?

    Hi suchita,
    You can find these information Sales area he belongs and all in the table of  KNVV , take the customer number from customer master  KNA1-KUNNR  put it in KNVV-KUNNR. you can find all the  sales details.
    if you need more info send breaf requirement.
    if helpful award the points
    Regards
    Ram

  • Whats the table name which connects BP and customer group code?

    Hi,
    Please let me know the table name which connects BP and its customer group code, i tried CRMM_BUT_SET0010 but i am not sure how to get "GUID for sets of business part"
    regards
    Vinay

    Hi Vinay
    Try instead table vision CRMV_BUT_SET0010. There you can use as search criteria the business partner number.
    However, if you want to understand the partner relation with guid_set value, just study how this table vision join is built.
    Kind regards,
    Garcia

  • Pass a variable name to a subroutine and use a method on it...

    How do I pass a variable name to a subroutine and then call a method on it?
    I have several swing text fields in a JForm. When someone enters a string in any of these fields, I want to check whether it is a number and, if now, clear that individual field and display a popup warning.
    So, I want to do something like....
    String stringcheck(String str, sometype variablename) {
            try {
                Integer.parseInt(str);
            } catch (NumberFormatException e) {
                JOptionPane.showMessageDialog(jPanel2, "These fields must be integer numbers.");
                variablename.setText("");
    }

    prometheuzz wrote:
    tsith wrote:
    prometheuzz wrote:
    NickSchurch wrote:
    thanks prometheuzz. I'm returning a string cos there are some other parts to the subroutine.Ah, now I understand.
    Well, good to hear you found a solution to it.You know, you really should have seen that from post 1.
    No offense, but seriously - does he have to draw you a picture?!
    I probably wouldn't understand the picture either: I'm not much of an art critic. Unless the OP is [Bob Ross|http://www.bobross.com/], his paintings, I understand.
    "I'm returning a string 'cos there's a happy tree over there, and I think I'll put a happy rock right here"

  • Table Names which stores GRN and GRIR Details of a PO

    Hi Friends,
    I want table names which stores GRN and GRIR details of a PO.
    Thanks in advance
    Expecting ur answers,
    Cheers;-)
    R.Kripa.

    Hi,
    From MKPF get the gr for PO.
    if you see VGART = 'WE' and BLART = 'WE' then you get all MBLNR s GR related PO's. and using those go to MSEG table and get MSEG-EBELN and MSEG-EBELP
    this is the flow...
    MKPF to it_mkpf where VGART = 'WE' and BLART = 'WE'.
    from
    MSEG get EBELN,EBELP for all entries of MKPF and get PO's corresponding GR's
    i hope it is clear...
    Regards
    vijay

  • Can`t open document on Illustrator but adobe reader and photoshop opens it, why?

    Can`t open document on Illustrator but adobe reader and photoshop opens it, it is a problem with the text font Futura T-Bold. How to open it on Illustrator?

    I downloaded the file, and:
    It is not a Photoshop PDF.
    I get the same result attempting to open in Illustrator; mangled font substitution. That's because I don't have one or more of the exact fonts used in the document installed on my computer, and I suspect the same is true of yours.
    The fact that it opens without issue in Reader and Photoshop is essentally meaningless, (or at least it's not an inidication that it also should open without issue in Illustrator, which is what your original post seems to imply). Reader displays the correct fonts because subsets of them are embedded in the PDF for use by Reader. Photohop just rasterises the whole page, so there is no font data needed.
    If you had the fonts, you wouldn't get the substitution in Illustrator. It works that way for any PDF.

  • How can we get the table name...

    Hi All,
    How can we get the actual table name for an argument if its datatype is %ROWTYPE.
    For Ex :
    function ACCOUNT_UPDATE (account_no number,
    person person%rowtype,
    amounts dbms_describe.number_table,
    trans_date date)
    return accounts.balance%type;
    In the above function 'ACCOUNT_UPDATE', for argument person the datatype is 'person%rowtype'.
    Is there any way to get the name from Data Dictionary tables.
    I tried using All_Arguments and DBMS_DESCRIBE, I can able to get all the individual fields of %ROWTYPE by I could not able to know the exact table name thru the DD.
    my requirement is dynamically I need to declare a variable for the argument datatype.
    Your help is highly appreciated.
    Thanks

    hi vinay,
    this is the easiest way to find the tablename of a particular field.
    t.code:XD01.
    enter.
    select the kunnr field.
    press F1.
    the top of the screen u will get 'Technical setting icon.
    select that one.then u will get tablename,fieldname,parameter id also.
    if helps give the rewards.
    regards,
    akash.k

  • How can we pass the catalogue name to ECC?

    Hello,
    We would like to pass the catalogue name across to the ECC PO item for reporting purposes. We have created a new Z field on the PO item table. We are using the classic scenario and are creating POs directly from the shopping cart after approval.
    We are struggling to find a way to pass the value of the catalogue name, which is held as atandard in the shopping cart structure in SRM, to the field on the ECC PO. Can anyone advise?
    Thanks

    Hi Paul,
    You could use the Badi BBP_CATALOG_TRANSFER to assign the iv_webservice_id to a specific CUST_FIELD[X] coming from the catalog and then map this through to your customer defined field from SC -> PO etc. This would probably be the easiest way to do this.
    Regards,
    Jason

Maybe you are looking for

  • Sales order crestion for a PO---error msg

    Hello, For a single PO, i am able to create a number of sales order. Is there a way i can rewstrict the system by throwing an exception/warning message. Sanjay

  • Update Managed Metadata field in SharePoint 2013 Designer Workflow for O365

    Hi Guys, I need to update the managed metadata field in SharePoint Custom List using Workflow but its not working. I have also tried to use the HTTP WebService POST Operation but no luck. Am doing this for a SharePoint Online (O365) Site. Has anyone

  • Which iphoto app comes with ios8

    Which photo app comes with ios 8 ?  Did they get rid of the iPhoto app, light blue with picture of palm trees?  The only photo app on my iphone is the app with white background and colorful flower petals.

  • User Agent Strings for Office 365 Install and Updates

    In my organization, we restrict internet access to a specific list of approved applications by user agent string; however, it seems the user agent string for Office 365 (2013) applications has changed over time causing installs and updates of Office

  • How do I install XFCE4?

    I would think it would be something like "pacman -S xfce4", but after searching the older forum messages - it looks a lot more complicated than that.  One message looked like I had to download about 20 pieces and compile from scratch using "abs". Is