Create Internal table with fields coming as query result of multiple tables

Hi
I want to create internal table with the fileds which come as a result of a select query from multiple tables

My code is something like this. I need  the data from various fields of diff tables depending on the excel file. This data is then to be put in a internal table
*& Report  Z_EXTC
report  z_extc.
type-pools : abap.
parameter: objname(25) type c.
data : idetails type abap_compdescr_tab,
       xdetails type abap_compdescr.
data : ref_table_des type ref to cl_abap_structdescr.
data: p_table type string.
data:l_string type string,
     l_filename(200) type c,
     dy_line  type ref to data,
     xfc type lvc_s_fcat,
     ifc type lvc_t_fcat.
types:begin of itab,
     tabname type dd03l-tabname,
     fieldname type dd03l-fieldname,
     end of itab.
types:begin of atab,
      tabname type dd03l-tabname,
      cnt type string,
      end of atab.
field-symbols: <dyn_table> type table,
               <dyn_table1> type standard table,
               <dyn_wa>,
               <dyn_field>.
data: dy_table type ref to data,
      dy_table1 type ref to data.
data: itab1 type itab occurs 0 with header line.
data atab1 type atab occurs 0 with header line.
data frstrec type i value 0.
data lastrec type i value 0.
l_string = ''.
call function 'GUI_UPLOAD'
  exporting
    filename                      = 'C:\excel_files\FIELDS_CC.TXT'
   filetype                      = 'TXT'
   has_field_separator           = 'X'       .
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
*Refresh itab1.
loop at itab1.
  on change of: itab1-tabname.
    if lastrec = 1.
      move l_string to atab1-cnt.
   move itab1-tabname to atab1-tabname.
      append atab1.
      l_string = ''.
    endif.
    move itab1-tabname to atab1-tabname.
    frstrec = 1.
  endon.
  if frstrec = 1.
    concatenate l_string itab1-fieldname into l_string separated by
space.
    lastrec = 1.
  endif.
*write:/ itab1-tabname,40 itab1-fieldname.
endloop.
move l_string to atab1-cnt.
append atab1.
loop at atab1.
  write:/ atab1-tabname,5 atab1-cnt.
endloop.

Similar Messages

  • How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?

    1. How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?
    When multiple tables are involved , and the actual number of rows returned is more than what the explain plan tells. How can I find out what change is needed  in the stat plan  ?
    2. Does rowsource statistics gives some kind of  understanding of Extended stats ?

    You can get Row Source Statistics only *after* the SQL has been executed.  An Explain Plan midway cannot give you row source statistics.
    To get row source statistics either set STATISTICS_LEVEL='ALL'  in the session that executes theSQL OR use the Hint "gather_plan_statistics"  in the SQL being executed.
    Then use dbms_xplan.display_cursor
    Hemant K Chitale

  • Fill a table with data coming from an RFC

    Hello everyone:
    I've followed the Weblog "How many lines of java code did i write for a simple Web Dynpro?"
    /people/durairaj.athavanraja/blog/2004/10/17/how-many-lines-of-java-code-did-i-write-for-a-simple-web-dynpro
    I've called an RFC and created a table with data coming from it (which is also a table). My question is, if in this table there's a field named "UserType" there are two possible values for this field:
    "userA"
    "userB"
    How can I get the table only show me the "userA" registers? The RFC does return all of the users, but when filling the table, can I put an if-else somewhere on my code?
    Thanks a lot
    Alejandro

    Hi Alejandro,
    Referring to the link provided "The logic of the filter process is not implemented in Web Dynpro. The application developer must implement the action to be executed."
    We would have to implement the action onFilter in the controller implementation. Ideally, we fill the data retrieved from backend into a List (java.util.List) (this could be done on init of view) and then subset the list after meeting the criteria in the action handler(say
    onActionFilterData(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent).
    Having done this, you may bind the output list back to the node (shown in table)
    Regards,
    Chaitanya

  • Table with fields containig more thn 300 characters

    Hello Friends,
    i want to create one ZTABLE and intht i want a field tht can store more thn 300 characters.
    i have used string data type for the same but while activating the table its giving me error saying :
    " Table contains more than 3 long string fields"
    Pls suggest...
    Sunny

    hi 
    sunny  ,
                You can create table with field more than 300 characters   but there should be one more field
    which has to be primary key .
    such as
    create table ztest
    in that create field MANDT  type clnt size 3  primary key
    name type String  .
    then change technical settings according to requirement .
    Delivery maintenance 
    delivery class and  Data Browser/Table View M
    according to requirement  .
    Before activating table save technical setting  and then activate .
    Regards
    deepak

  • Steps to create Internal Order with AUC Number

    Dear All,
              We need to create internal order with AUC number.Kindly provide us the steps to do the configurations. Kindly guide the steps to be followed for creating internal orders with AUC number and way to do the settlement.

    Dear Kishore,
    I am doing the following steps in creating internal orders:
      1) Using the tcode KO01, choosing the order type as GEN i am creating an internal order. At the time of creating an internal order i need to give AUN number. Hence i am going to Extras--> Asset Under Construction by giving the investment profile. When i enter it nothing is happening. I am unable to create AUC no manually.
    Since i am a beginner, plz guide me to create AUC no while creating internal order.

  • How to pass query result to HTML table?

    Hi,
      i want to get the query result in HTMl table instead of Display Grid. how to do it? i searched in help, it suggests use icommand to do this. but i dont know how to pass the select query result to HTML table.. please help me.
    -senthil

    Hi Senthil,
    You can create an icommand query. You can then use the icommand retrieval methods to capture and manipulate the query data.
    (http://help.sap.com/saphelp_xmii115/helpdata/en/Applet_Reference_Details/iCom
    mand_Reference.htm)
    Basically what we did was, use the getColumnCount() and getRowCount() methods, once you have these two numbers you can set two for loops and use String getValue(int ColID, int RowID) , within the for loops you can generate the inner html content and write the values either in a html table or html form (which is what we did). This seems to work well, I'm still playing around with it and may post this approach on sdn by end of this week.
    Mahwish

  • Xcelsius with XMLA or XML Query Result Set

    Hi Experts,
    I want a direct connection from Xcelsius to my BW-Data. Because the new connection, coming with Fix Pack 2.1 is only avaiable for EHP 1 for NW 7.0 I tried to configure with XMLA and XML Query Result Set.
    This Document tells the necessary steps: How to integrate Xcelsius 2008 with SAP NetWeaver BI without Integration Kit.pdf.
    When I test my XML connection over http://<host>:<port>/TXmla/srvlet/TestXmla my Cubes will display.
    So I do a Webservice-Connection with WSDL-URL. At Input-Values there are some entries like CUBE_NAME, CATALOG_NAME...
    Output values arent avalible. How do I use these elements to show my Data in Xcelsius?
    My Problem with the XML Query Result Set Connection is, that when I Log On to VC the following error appears:
    You are not authorized to view the requested resource.
    So I get the authorisationobjects: S_DEVELOP and S_RS_COMP as describe in 'How To... Resolve Visual Composer Issues'.
    What values have I to enter by S_RS_COMP? And how can I enter my External Service in S_SERVICE. At the type WS the service isnt't avaiable.
    Regards,
    Jan

    To use XMLA web service you need a wrapper function build to convert the XMLA output to the Xcelsius format. There are some documents available in SDN on how to do this.
    You can use Live Office or Query as a Web service option to connect from Xcelsius to BW.
    S_RS_COMP is the query ID which you are trying to access, S_SERVICE you can either give * or try to set up authorization log and see the expected value.

  • Howto: Save prediction query results to relational table

    I believe saving prediction query results to relational tables is possible (the BI studio does it!). I am not clear on how to do this w/o the BI studio, which means if I write a DMX query and want to store its output to a relational table, how do I do it?
    Tips, anyone?
    Thanks!

    a) You can write some code do this on the client-side. Use ADOMD.NET in your C# app to execute the DMX query and fetch a data reader, open up another connection to your relational database and write rows of data to the second connection as you read them from the first.
    b) You can create a linked server to your Analysis Server instance in your SQL Server relational server instance and then execute a "SELECT * INTO <newtable> FROM OPENQUERY(<linkedserver>, <DMX query>)" T-SQL statement from your relational database connection.

  • How to store query results into a table

    I want to store the query results to a table. Is there a way to automatically redirect output to a table without using a PL/SQL script.

    Run the following step only once unless you want to create the tabX everytime
    Create tabX as select x,y,z from tabY;
    Next time when you want to store the new results, run the following statement
    Insert into tabX select x,y,z from tabY;

  • How to create an internal table with fields from different sources

    Hi.
    I need to create an internal table where some of the fields are from a database table, and the other fields are user specified. How do i do that?
    Example:
    DB table ZTAB with fields ZTAB-FIELD1, ZTAB-FIELD2.
    I want to create an internal table ITAB with the fields ZTAB-FIELD1, ZTAB-FIELD2 from ZTAB. In addition, I also want to have one more field RECORD_NO, which is not from ZTAB. How do I do it? Could I do something like below?
    DATA BEGIN OF ITAB.
            INCLUDE STRUCTURE ZTAB.
    DATA RECORD_NO TYPE I.
    DATA END OF UPLINE.
    Or, are there more efficient way of doing it? Thanks.

    hi KIan,
    go:
    general type
    TYPE : BEGIN OF ty_itab,
               field1 TYPE ztab-field1,
               field2 TYPE ztab-field2,
    *your own fields here:
               field TYPE i,
               field(30) TYPE c,
               END OF ty_itab.
    work area
    DATA : gw_itab TYPE ty_itab.
    internal table
    DATA : gt_itab TYPE TABLE OF ty_itab.
    hope this helps
    ec

  • Sum for Dynamic Fields in a Dynamic Table with Field Symbol

    Hi All,
    I currently have an report which I am looking to update with some totals.  The information is currently output in an ALV which is fed data from a dynamic table defined with a field symbol.  The modification that needs to be applied is a summation per currency code where each of the fields to be summed is a dynamically named field at runtime.  I am now just looking to see if anyone has any recommendations on how to obtain these totals it would be appreciated.  I have no problem doing the leg work in piecing the solution together but am just stuck on which approach I should be investigating here.  I have looked into several options but do to the fact that the totals are for dynamic fields in a dynamic table and it is a field symbol I am having some difficulties thinking of the easiest approach to obtain these totals.
    Below is a simple sample of what the report currently looks like and what we are looking to add.
    ====================================================================================
    As-Is Report:
    DETAILED DATA ALV
    Company Code  |  Plant  |  2006 Total  |  2007 Total  |  2008 Total |  CURRENCY
    0001          |   ABCD  |    1,500     |    1,200     |    1,700    |    USD
    0001          |   BCDE   |    2,300     |    4,100     |    3,600    |    GBP
    0003          |   DBCA  |    3,200     |    1,600     |    6,200    |    USD
    Addition 1:
    TOTALS PER CURRENCY
    Currency                |  2006 Total  |  2007 Total  |  2008 Total |
    USD              |    4,700     |    2,800     |    7,900    |
    GBP                       |    2,300     |    4,100     |    3,600    |
    Addition 2:
    CONVERSIONS TO USD
                                          |  2006 Curr   |  2006 USD    |  2008 Curr   |  2006 USD   |
    USD                       |  4,700 USD   |  4,700 USD   |  7,900 USD  |  7,900 USD  |
    GBP   (1.5GBP/1 USD)    |  2,300 GBP   |  1,150 USD   |  2,300 GBP  |  1,800 USD  |
    ====================================================================================
    Any recommendations will be appreciated.

    Hi,
    We cannot use the key word SUM in the loop at assigning statement.
    The way i see is
    When  you are creating the first dynamic internal table , create one more with  the structure below:
    Currency | 2006 Total | 2007 Total | 2008 Total |
    Then while populating the data into first itab,also move the contents to the second itab using collect statement.

  • AMDP exporting table with fields from various sources

    I am writing an AMDP that has an output table a list of employees and attributes.  These attributes have various sources with various keys.  If I cannot with any practicality construct this table with a single select statement, which given my search criteria, I probably can't, must I break my output table into multiple output tables that can be created with a single select?
    I declare the structure of output table et_employees in the class as something like
          BEGIN OF ty_employee,
            emp_id(12)    TYPE c,
            emp_name(80)  TYPE c,
            org_unit(8)   TYPE c,
            region(5)     TYPE c,
            country(3)    TYPE c,
            jb_prf_as     TYPE c,
            sol_gr_as     TYPE c,
            snippet(1000) TYPE c,
            score         TYPE integer,
          END  OF ty_employee,
          tt_employes type table of ty_employee.
    As far as I can tell, I cannot do an update et_employees in the method to modify individual fields.  I can only do the select statement.
    I see my choices as
    elaborate select statement that I may or may not be able to construct (haven't thought this through but it may be doable)
    more than one output table
    create multiple local tables and then do a join on them for the output table.
    I am seeing the last one as my best option.
    To throw in an unrelated issue, AMDP procedure cannot seem to cope with a table that begins with a slash, e.g., /MRSS/D_SQP_ESTR.  The USING statement is o.k. but any access in a select or inner join gets an error.

    Hi Deborah,
    let me do some assumptions on your problem and then try to help you:
    Assumption A: You only like to query data from tables, which, I simply assume, are available in the ABAP data dictionary. In this case, I don't think there is a performance gain with AMDPs compared to OpenSQL, so just use OpenSQL and do joins on the relevant tables, leading to exaclty one resultset in the output.
    Assumption B: You need the AMDP because you have a good reason and you like to query data from tables employee_source_a and employee_source_b for your resultset. In case yes, you can e.g. use  "temporary" tables (don't declare them explicitly), e.g. use the construct like:
    lt_employee_source_a =  select ...from employee_source_a ...;
    lt_employee_source_b = select ... from employee _source_b...;
    et_employee = select ... from :lt_employee_source_a ... (inner/left outer) join lt_employee_source_b on...;
    Or you could use the CE_JOIN function if that suits your SQLScript development better.
    To elaborate a query statement for et_employee for without the lt_xxx tables is hard to say from your question - it should be posible if there are no nasty aggregations/calculations which prevent it :-).
    There's no need to use two resultsets in the output in case that's not what you need in the application.
    The option to have several resultsets is rather a feature of DB Procedures, which allow for several resultsets while a view/OpenSQL query can only give you one resultset.
    Conclusion: You answered your question yourself, the last option seems to be the best option :-).
    Concerning the "slash issue": Guessing around I'd propose to use quote the table name like "/MRSS/D_SQP_ESTR"... but just a guess. Could you please post the error message or open a second discussion on the issue?
    Cheers,
      Jasmin

  • Updating Oracle table with info from Sybase query

    I hope this is the correct forum for this question.
    I am fairly new to Java and JDBC. I am trying to figure out what the best method for updating information in Oracle tables with data from a Sybase table. I would prefer to use Oracle’s transparent gateway but this is not an option my company will pay for so I am creating a java stored procedure and using JDBC to connect to the Sybase database.
    The process I think I need to go thru is
    1.     Query an Oracle table to get the records that need to be updated and the “key” information to query the Sybase table with.
    2.     Use that result to query the Sybase database to get the fields that need to be updated in the Oracle table for those records.
    3.     Update the records on the Oracle table with the data from the Sybase query.
    I know I can just do this procedurally, row-by-row, but I was wondering if anyone knows of a way to accomplish this with SQL and no loops. Is there a way to make a result set available as a “SQL table” for another JDBC query?
    Basically what I would like to do is:
    OraQuery = “ select sybinfo from sometable where updated_date = null”;
    Statement orastmt1 = OraConn.createStatement();
    ResultSet Orars1 = orastmt1.executeQuery (OraQuery);
    SybQuery = “select update_date, sybinfo from sybtable where sybinfo = Orars1.sybinfo”;
    Statement sybstmt = SybConn.createStatement();
    ResultSet Sybrs = sybstmt1.executeQuery (SybQuery);
    OraUpdate = “update (select update_date from sometable, Sybrs where sometable.sybinfo = Sybrs.sybinfo) set update_date = Sybrs.update_date”;
    Statement orastmt2 = OraConn.createStatement();
    ResultSet Orars2 = orastmt2.executeQuery (OraUpdate);
    This may not be possible but if anyone has done something similar and wouldn’t mind sharing I would appreciate it. If there is a “better” way of accomplishing this I am open to suggestions.
    Thanks

    you can try using cachedRowSet() for the Oracle side query.
    The rows in this could be populated using the sybase side query's resultset and then all of this could updated into Oracle in one shot.

  • Dynamic table with field type table

    Hi,
    I´m using "cl_alv_table_create=>create_dynamic_table" to create a dynamic table for ALV Grid.
    But...I need to use colors in ALV, then I need to declare a field type LVC_S_SCOL in dynamic table from "cl_alv_table_create=>create_dynamic_table".
    How can I declare this in fieldcat?
    The code:
    Creating dynamic table
    DATA: table_agrup TYPE REF TO data,
            line_agrup  TYPE REF TO data.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = t_fieldcat
        IMPORTING
          ep_table                  = table_agrup
        EXCEPTIONS
          generate_subpool_dir_full = 1
          OTHERS                    = 2.
        ASSIGN table_agrup->* TO .
    Printing ALV
      CALL METHOD obj_grid->set_table_for_first_display
        EXPORTING
          is_variant                    = w_variant
          i_save                        = 'A'
          is_layout                     = w_layout
        CHANGING
          it_outtab                     =
          it_fieldcatalog               = t_fieldcat
          it_sort                       = t_sort
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
    Thanks.

    It is not possible with the  METHOD cl_alv_table_create=>create_dynamic_table to include another table inside that newly generated table.
    I have tried to do it with the code and I got the dynamic table created after at the end of the program.
    In the code,
    <DYN_TABLE> has same effect as your <table> variable
    <DYN_WA> has same effect as your <HEADER>
    REPORT  ZTEST_NP_DYNAMIC.
    DATA: DY_TABLE TYPE REF TO DATA,
          DY_LINE  TYPE REF TO DATA.
    FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
                   <DYN_WA>,
                   <DYN_FIELD>.
    FIELD-SYMBOLS: <FS> TYPE ANY.
    * To generate the Dyanmic table with the COLOR
    DATA: LS_SOURCE TYPE STRING.
    DATA: LT_SOURCE LIKE STANDARD TABLE OF LS_SOURCE WITH HEADER LINE.
    DATA: L_NAME LIKE SY-REPID.
    DATA: L_MESSAGE(240) TYPE C,
          L_LINE TYPE I,
          L_WORD(72) TYPE C.
    DATA: L_FORM(30) TYPE C VALUE 'TABLE_CREATE'.
    LT_SOURCE = 'REPORT ZTEST_SUBROUTINE_POOL.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'FORM  TABLE_CREATE USING I_FS TYPE ANY.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'DATA: BEGIN OF LT_GENTAB OCCURS 0.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'DATA: BUKRS TYPE BUKRS. '.
    APPEND LT_SOURCE.
    LT_SOURCE = 'DATA: BKTXT TYPE BKTXT. '.
    APPEND LT_SOURCE.
    * you can add your fields here.....
    LT_SOURCE = 'DATA: COLOR TYPE lvc_t_scol. '.
    APPEND LT_SOURCE.
    LT_SOURCE = 'DATA: END OF LT_GENTAB.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'DATA: POINTER TYPE REF TO DATA.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'CREATE DATA POINTER LIKE STANDARD TABLE OF LT_GENTAB.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'I_FS = POINTER.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'ENDFORM. '.
    APPEND LT_SOURCE.
    L_NAME = 'ZTEST_SUBROUTINE_POOL'.
    CATCH SYSTEM-EXCEPTIONS GENERATE_SUBPOOL_DIR_FULL = 9.
      GENERATE SUBROUTINE POOL LT_SOURCE NAME L_NAME
               MESSAGE L_MESSAGE LINE L_LINE WORD L_WORD.  "#EC CI_GENERATE
    ENDCATCH.
    IF NOT L_MESSAGE IS INITIAL.
      MESSAGE E000(0K) WITH L_MESSAGE L_LINE L_WORD.
    ENDIF.
    ASSIGN DY_TABLE TO <FS>.
    PERFORM (L_FORM) IN PROGRAM (L_NAME) USING <FS>.
    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>.
    Write: 'bye'.
    Regards,
    Naimesh Patel

  • Create internal order with reference - Do not copy distribution rule group

    Hi,
    I'm creating an internal order with reference to another order through tcode KO01. When i will display the new internal order, i already have distribuion rule group that was copied from the reference order. To delete the incorrect distribution rule group i execute tcode KO02, however this information do not appear in tcode KO02.
    What should be done to delete this settlement rule? I do not want to copy the settlement rules from the old internal order.
    Thanks in advance.
    Regards,
    Ana Fernandes

    Hi.
    'What should be done in order to do not copy this information when i create the internal order with reference?'
    in tcode kot2_opa do not maintain Settlement profile for Order category 3
    Also go to KOM2 and delete Settlement rule for order, from which you copying.
    'in table COBRB i can see the information however i can not delete it. The validy period is empty.'-in su53 check authority

Maybe you are looking for

  • Importing AVI into FCE has out of sync audio, but not in iMovie?

    Hi all, I'ave searched around and can't seen to find this issue in other parts of the forum, so thought I would try posting up. I'm using a GoPro camera which creates AVI files at 27fps, 512 x 384, Mono Audio, 8.0KHz, 32-bit Floating Point. I'm total

  • Older MacPro or new imac?

    Hi, I need a mac for use with adobe creative cloud (Mostly photoshop and illustrator). I have 2 options 1) a reconditioned Mac Pro 3.1 with 2x Xeon 2.8Ghz procs, 6Gb RAM, updated OS, 1TB HDD or 2) a new 21.5" imac (i5 2.7Ghz 8Gb RAM). Which is best?

  • How can I use external tables with directories not on Oracle host?

    Oracle 11.2.0.2 We have developers using C# to populate global temporary tables (two one header and detail with 1 to many relationbship between these two tables). The process of using C# was blowing up memory on Windows. As an alternative I requested

  • Does Lion Mail send saved Drafts like Notes?

    After saving an email as "Draft", I also received it in my Inbox. However, my Sent items box does not contain the email. Is this normal?

  • Changing the first item being focused in a window

    Hello fellow programmers. I'm developing an application that contains a number of radio buttons as well as a PLAY and STOP button. I would like the PLAY button to be focused whenever the window is opened. I was able to get this done by calling the re