Query on internal table

hello all,
i am confusing how affectively we can use the internal table key words. observe the following two sample codes, plz clarify what is the difference between these two.
1.
REPORT z_sample_report1 .
TYPES: t_spfli
       TYPE STANDARD TABLE OF spfli.
DATA: itab_flinfo TYPE t_spfli,
      wa_flinfo LIKE LINE OF
      itab_flinfo.
SELECT * FROM spfli INTO TABLE itab_flinfo.
  READ TABLE itab_flinfo INTO wa_flinfo
         WITH KEY carrid = 'LH'
                  connid = '2463'.
  IF sy-subrc = 0.
WRITE:/ wa_flinfo-carrid,
        wa_flinfo-connid,
        wa_flinfo-cityfrom,
        wa_flinfo-cityto,
        wa_flinfo-deptime,
        wa_flinfo-arrtime.
  ENDIF.
2.
REPORT z_sample_report1 .
DATA: BEGIN OF itab_flinfo OCCURS 6.
        INCLUDE STRUCTURE spfli.
DATA: END OF itab_flinfo.
DATA: wa_flinfo like line of itab_flinfo.
SELECT * FROM spfli INTO TABLE itab_flinfo.
  READ TABLE itab_flinfo INTO wa_flinfo
         WITH KEY carrid = 'LH'
                  connid = '2463'.
  IF sy-subrc = 0.
WRITE:/ wa_flinfo-carrid,
        wa_flinfo-connid,
        wa_flinfo-cityfrom,
        wa_flinfo-cityto,
        wa_flinfo-deptime,
        wa_flinfo-arrtime.
  ENDIF.

hi,
   both declarations are same
   The difference comes when you want to add one more field to your internal table
  Say you want to add one more field say CHECK(1) to your internal table , you cannot add this using the first method but you can do this using the second method
DATA: BEGIN OF itab_flinfo OCCURS 6.
INCLUDE STRUCTURE spfli.
data : CHECK(1).
DATA: END OF itab_flinfo.

Similar Messages

  • Querying iFS internal tables

    iFS 1.1.9.0.7
    I'm querying the internal tables to extract the path of a file (family or document) or a folder.
    If I execute this query with the id of the file (99999) the result is ok, but if i use the id of a folder (99999) the result is duplicated folders... try it please.
    What i must to do?
    Thank You.
    select a.*, b.*
    from (select leftobject, level nivel from ifssys.odm_relationship
    connect by rightobject = prior leftobject
    and rightobject <> leftobject
    start with rightobject = 99999) a, ifssys.odm_publicobject b
    where b.id = a.leftobject
    order by a.nivel desc

    It's OK i resolved the problem...
    Thanks.
    select a.*, b.*
    from (select leftobject, level nivel from ifssys.odm_relationship
    connect by rightobject = prior leftobject
    and rightobject <> leftobject
    start with rightobject = 99999
    and rightobject <> leftobject
    ) a, ifssys.odm_publicobject b
    where b.id = a.leftobject
    order by a.nivel desc

  • How to fetch the data from query to internal table ?

    Dear all ,
             I would like to fetch the query data(sq01) into my internal table ? is it possible to do that ?
    Best Regards,
    Carlos

    Hi
    Try this <b>RRW3_GET_QUERY_VIEW_DATA</b>
    Also, you can have a look at this...
    <a href="/people/durairaj.athavanraja/blog/2005/04/03/execute-bw-query-using-abap-part-ii Query results into Internal table</a>
    Regards
    Raj

  • SAP Query using internal table because of multiple records in KONV

    Hi
    Im using abap code to write to an internal table, how do you get the internal table fields to show in query report.
    Reason I have added abap code is I have a query for purchase order tables EKKO and EKPO. I would like to show any conditions attached to these purchase orders using EKKO-KNUMV = to KONV-KNUMV.
    Prolem is KONV can have multiple records. So added code to write records from KONV to a internal table. Problem is how do I get the internal table files to show in query report. Have added fields as additional fields and included them in the field group.   
    In info sturcture I have defined internal table in code 'DATA'  included  the select in 'Record procesing'
    Any help will be appreciated. Thanks

    Yes, and the problem is that sometimes that item has two of the same conditions.  One that SAP enters automatically and one that the end  user enters.  I want to understand how this is happening so that I can fix it.

  • How to Query Internal tables in PCR

    Hi Experts,
    When I tried by using operation u201CVAKEYu201D to query the Internal tables, but it was not working
    I would like to write one PCR in the Indian Payroll
    Please can anyone help me on the same?
    The requirement as below;
    u201CIf the DDNTK table filled with amount (Assume that DDNTK table may contains more than one WT)u201D
    u201CAdd this total amount (with same sign) to WT /110 net deductionsu201D
    Thanks in Advance!
    Thanks and Regards
    Cheera

    I have never worked with Indian Payroll and I am not aware of a function or operation that allows to check on table DDNTK,
    but you could check PCR XDPR and function PRDNT.

  • How to use aggregate function on internal table

    hi experts,
    I am beginner in abap.I want to use sum function on internal table.
    I have structure as follow:
    types: begin of ty_ftab,
           docno TYPE bkpf-belnr,
           comcode TYPE bkpf-bukrs,
           year TYPE bkpf-gjahr,
           line_itm type bsad-buzei,
           cust type bsad-kunnr,
           amt type bsad-dmbtr,
    end of ty_ftab.
    data: it_ftab type table of ty_ftab,
               wa_ftab type ty_ftab.
    i fetched data successfully into it_ftab from bkpf and bsad table and displyed into alv.
    now i want sum of amt using group by cust and want to display like
    cust        total_amt      
    in next screen...
    displying part is not important but how can i do sum of amt according to cust value? Is there in way to query on internal table?

    Hi,
    try this code,
    data : i_sort  TYPE TABLE OF slis_sortinfo_alv
      w_sort like LINE OF i_sort.
    sort it_ftab by cust.
    w_sort-subtot = 'X'.
    w_sort-fieldname = 'AMT'.
    w_sort-tabname = 'it_ftab'.
    APPEND w_sort to i_sort.
    In fieldcatalog :
    w_fcat-fieldname = 'AMT'.
    w_fcat-tabname  = 'it_ftab'.
    w_fcat-do_sum = 'X'.
    In REUSE_ALV_GRID_DISPLAY  FUNCTION MODULE  provide the it_sort.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    *  EXPORTING
    *    I_INTERFACE_CHECK                = ' '
    *    I_BYPASSING_BUFFER                = ' '
    *    I_BUFFER_ACTIVE                  = ' '
    *    I_CALLBACK_PROGRAM                = ' '
    *    I_CALLBACK_PF_STATUS_SET          = ' '
    *    I_CALLBACK_USER_COMMAND          = ' '
    *    I_CALLBACK_TOP_OF_PAGE            = ' '
    *    I_CALLBACK_HTML_TOP_OF_PAGE      = ' '
    *    I_CALLBACK_HTML_END_OF_LIST      = ' '
    *    I_STRUCTURE_NAME                  =
    *    I_BACKGROUND_ID                  = ' '
    *    I_GRID_TITLE                      =
    *    I_GRID_SETTINGS                  =
    *    IS_LAYOUT                        =
    *    IT_FIELDCAT                      =
    *    IT_EXCLUDING                      =
    *    IT_SPECIAL_GROUPS                =
        IT_SORT                          =  i_sort
    *    IT_FILTER                        =
    *    IS_SEL_HIDE                      =
    *    I_DEFAULT                        = 'X'
    *    I_SAVE                            = ' '
    *    IS_VARIANT                        =
    *    IT_EVENTS                        =
    *    IT_EVENT_EXIT                    =
    *    IS_PRINT                          =
    *    IS_REPREP_ID                      =
    *    I_SCREEN_START_COLUMN            = 0
    *    I_SCREEN_START_LINE              = 0
    *    I_SCREEN_END_COLUMN              = 0
    *    I_SCREEN_END_LINE                = 0
    *    I_HTML_HEIGHT_TOP                = 0
    *    I_HTML_HEIGHT_END                = 0
    *    IT_ALV_GRAPHICS                  =
    *    IT_HYPERLINK                      =
    *    IT_ADD_FIELDCAT                  =
    *    IT_EXCEPT_QINFO                  =
    *    IR_SALV_FULLSCREEN_ADAPTER        =
    *  IMPORTING
    *    E_EXIT_CAUSED_BY_CALLER          =
    *    ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          =
    *  EXCEPTIONS
    *    PROGRAM_ERROR                    = 1
    *    OTHERS                            = 2
      IF sy-subrc <> 0.
    * Implement suitable error handling here
      ENDIF.

  • How to Modify Internal table

    select  pernr dlart darbt subty
               into (loan-pernr , loan-ln_type,loan-ln_amt, loan-subty)
               from  pa0045
               where pernr  =  pernr-pernr
               and   subty in ('Y001' , 'Y011' , 'Y010' , 'Z001' , 'Z005' , 'Z006')
             and  begda  <     fisc_day.
    APPEND loan.
    ENDSELECT.
    SELECT   ZZTEL0144B ZZTEL0144B ZZTEL0147B ZZTEL0150B ZZTEL0153B ZZTEL0156B
           into (wa-ZZTEL0144B,wa-ZZTEL0144B,wa-ZZTEL0147B,wa-ZZTEL0150B, wa-ZZTEL0153B, wa-ZZTEL0156B)
    from pa9999
      WHERE pernr = loan-pernr
      and   subty in ('Y001' , 'Y011' , 'Y010' , 'Z001' , 'Z005' , 'Z006')
        and  begda  <     fisc_day.
    APPEND wa.
    ENDSELECT.
    in 1st Query i gett data related tothe PF loans . in 2nd query i got the data related to the balances and repayments. i have to apprend the 2nd query in internal table Loan. according to the respect records  kindly help me out

    >> is it possible to define internal table with header line.
    NO.. you have to create a work area & loop at the itab into this work area.. and you can modify the itab contents from this work area..
    ~Suresh

  • Dynamic query in where clause while looping in an internal table.

    Hi,
    Had a small question : How can i make a dynamic query for the WHERE clause while looping at an internal table.
    i want to implement a dynamic where clause query for the below example.
    it_cfx_col is an internal table and wa_cfx_col is a work area for it_cfx_col
      DATA :
      i_cfx_col TYPE TABLE OF cfx_col,
      wa_cfx_col LIKE LINE OF i_cfx_col.
    DATA : count TYPE i VALUE 0.
    DATA : l_where_clause TYPE string,
             l_where_clause2 TYPE string,
             l_name type string.
    l_name = 'NANDANOM'.
    l_scenario = 'collaboration'.
    LOOP AT it_cfx_col INTO wa_cfx_col
    WHERE CREATED_BY = l_name
    AND SCENARIO = l_scenario.
    count = count + 1.
    some business logic implemented using the work area wa_cfx_col
    endloop.
    Now i want to write a dynamic query for the where clause.
    DATA : count TYPE i VALUE 0.
      DATA : l_where_clause TYPE string,
             l_where_clause2 TYPE string,
             l_name type string.
    l_name = 'NANDANOM'.
    l_scenario = 'collaboration'.
      l_where_clause = 'CREATED_BY = l_name'.
      l_where_clause2 = 'AND SCENARIO = l_scenario'.
    if l_scenario is not initial.
      CONCATENATE  l_where_clause l_where_clause2
      INTO l_where_clause SEPARATED BY space.
    endif.
    LOOP AT i_cfx_col INTO wa_cfx_col
    WHERE (l_where_clause).
    count = count + 1.
    some business logic implemented using the work area wa_cfx_col
    endloop.
    when i compile this i get an error message as { Statement concluding with "...(l_where_clause)" ended unexpectedly}
    Even i changed the initilization of the variable  l_where_clause2 to [ l_where_clause2 = 'AND SCENARIO = l_scenario.'. ]
    added the end of line demarkation ".", but still i got the same error message.
    Is it a limtation in ABAP that i cannot write a dynamic query for the where clause while looping at an internal table?
    Regards,
    om

    Hi savita,
    there in no such 1 limitaion in abap for dynamic query .. i think the  error meassge is only beacuse of your synatx delcartaion.
    >> LOOP AT i_cfx_col INTO wa_cfx_col
       WHERE (l_where_clause).
       count = count + 1.
    some business logic implemented using the work     area    wa_cfx_col
       endloop.
    afted delclarataion also , in the where statement you should specify both the field name and value bname
       LOOP AT i_cfx_col INTO wa_cfx_col
       WHERE l_where_clause = 'CREATED_BY = l_name' .
       count = count + 1.
    hope it helps.
    regads
    priya.

  • SAP QUERY LOOPS AND INTERNAL TABLE

    Hi All, I have a query which i have made. It runs from Table EKPO which has PO details and what I want to do is now via ABAP Code pull through the total of goods receipt for the PO and Line Item into a field. Sounds Easy enough..Problem now,
    The table which contains the GR data is EKBE which agains a PO and Line Item can have many 101 movements and 102 movements so what I want is an ABAP Statent to basically sum up the total of 101 for the PO & LINE ITEMS and then minus this from the total of 102 for the PO & LINE ITEMS and post the result in to this new field I have created.
    I am pretty decent with ABAP Code in Querys I.e Select statements etc but from what I can see i need to create an internal table and do a loop and collect statement but I keep on failing due to not enough knowledge. Please can some one help me with this and provide me with the code and explanation as i would like to understand,
    POINTS WILL BE REWARDED
    Thanks
    Kind Regards
    Adeel Sarwar

    Hi,
    This is the full code i have entered but its not working. Any help would be appreciated. If you could rectify the code and internal tables that would be great.
    Thanks
    TABLES: EKBE.
    DATA: PurO LIKE EKPO-EBELN,
          POLI LIKE EKPO-EBELP.
    *New Table and Vars defined
    DATA:   BEGIN OF IT_EKBE,
              IT_EKBE LIKE EKBE,
            END OF IT_EKBE.
    DATA:  BEGIN OF IT_SUM OCCURS 0,
              EBELN TYPE EBELN,
              EBELP TYPE EBELP,
              DMBTR TYPE DMBTR,
              MENGE TYPE MENGE,
          END OF IT_SUM.
    CLEAR: QTYD.
    MOVE: EKPO-EBELN TO PurO,
          EKPO-EBELP TO POLI.
    SELECT * FROM EKBE INTO IT_EKBE
        WHERE EBELN = PurO
        AND   EBELP = POLI
        AND   BEWTP = 'E'
    LOOP AT IT_EKBE.
      MOVE CORRESPOING IT_EKBE TO IT_SUM.
      IF IT_EKBE-BWART = '102'.
        IT_SUM-DMBTR = IT_SUM-DMBTR * -1.
        IT_SUM-MENGE = IT_SUM-MENGE * -1.
      ENIDF.
      COLLECT IT_SUM.
      CLEAR IT_SUM.
    ENDLOOP.
    ENDSELECT.
    If sy-subrc = 0.
      QTYD = IT_SUM.
    ELSE.
      QTYD = 0.
    ENDIF.

  • Internal table in ABAP Query

    Hi all,
    Can we use internal table in ABAP/SAP Query (Infoset - SQ02)? If yes, Pls guide me on the same.
    Thanks in advance
    Regards
    Madhumathi A

    to my knowledge u can't use internal tables in ABAP query...it is a mix of tables...

  • Import internal table from query to report

    Hi,
    I have to import an internal table% G00 with its contents from a query in a custom report. I use the import statement but I do not acknowledgment the table. You can help me.
    thanks

    Hi,
    standard program behind the query does not have any EXPORT statement statement behind it so it does not make sense to IMPORT. It'll never IMPORT.
    You can use the following way:
        SUBMIT (report_name) USING SELECTION-SCREEN <sel_screen_number> EXPORTING LIST TO MEMORY AND RETURN.
    and then use
      CALL FUNCTION 'LIST_FROM_MEMORY'
        TABLES
          listobject = list_tab
        EXCEPTIONS
          not_found  = 1
          OTHERS     = 2.
      IF sy-subrc = 0 AND list_tab IS NOT INITIAL.
       CALL FUNCTION 'LIST_FREE_MEMORY'.
          CALL FUNCTION 'LIST_TO_ASCI'
            TABLES LISTOBJECT = list_tab
                          LISTASCI   = output.
         FREE MEMORY ID '%_LIST'.
      ENDIF.
    output is your output table.

  • Saving query view in a internal table

    Hello Experts,
    Is there anyway that we can trasfer all the query results to a table.
    What I am exactly looking is
    I want to transfer a query view to an internal table so that our destop team using java will then read the results from tables and convert to desirable format ( email, pdf etc)
    Please help me out to sort this issue as this became one of the major issues to be fixed.
    All inputs are much appreciated.
    Thanks and Regards
    Harish Mulaka

    Hello Sachin and Riccardo,
    Thank you very much for taking time to reply my question.
    Could you please elobarte on sending query output into PDF format.
    Riccardo,
    when performing an extract of a query with table option in RSCRM_BAPI.. In which table it stores the information and where can I find the results
    Can you please provide me if you have any document on RSCRM_BAPI
    Thanks and Regards,
    Harish

  • Query related to Internal Table

    Hi ,
          I have a small query related to internal table , can we dump millions of records to an internal .
    The actual requirment is like i need to develop a report in BI side where i have to dump records into an internal table  from PSA tables without filtering .
    Can we do so ....
    or do we have any other option to dump the data to an internal tables .
    need some tips on the same .
    Thanks ,
    VInay.

    Hello Vinay,
    I believe the following extract will give you a brief idea on the size limitations for an internal table.......
    Internal tables are dynamic data objects, since they can contain any number of lines of a particular type. The only restriction on the number of lines an internal table may contain are the limits of your system installation. <u><i>The maximum memory that can be occupied by an internal table (including its internal administration) is 2 gigabytes. A more realistic figure is up to 500 megabytes. An additional restriction for hashed tables is that they may not contain more than 2 million entries.</i></u>
    Hope it proved useful
    Reward if helpful
    Regards
    Byju

  • Internal table with same variable and one select query

    Hi,
    I am a new bee here with may be a silly question.
    I have a internal table as below.
    DATA: BEGIN OF IT_ORDERDETAILS OCCURS 0,
            VBELN LIKE VBAK-VBELN,        "Order number
            BSTNK LIKE VBAK-BSTNK,        "customer PO
            ERDAT LIKE VBAK-ERDAT,        " Order created date
            MATNR LIKE VBAP-MATNR,        "Sales order line item
            KWMENG LIKE VBAP-KWMENG,      "Quantity
            D_VBELN like likp-vbeln,      " delivery no
            POSNR like lips-posnr,        " delivery item
            KUNNR LIKE LIKP-KUNNR,        "ship quantity
      END OF IT_ORDERDETAILS.
    Where VBELN field is in VBAK and LIKP table.
    VBELN in VBAK table = order #
    VBELN in LIKP table is = Delivery #
    I want to use join to fetch data in single select query.
    Below is the select query
    SELECT VBAK~VBELN
            VBAK~BSTNK
            VBAK~ERDAT
            VBAP~MATNR
            VBAP~KWMENG
            likp~vbeln
            lips~posnr
            LIPS~VGBEL
          INTO (IT_ORDERDETAILSvbak, IT_ORDERDETAILSbstnk,     IT_ORDERDETAILSerdat, IT_ORDERDETAILSmatnr, IT_ORDERDETAILSkwmeng, IT_ORDERDETAILSd_vbeln,IT_ORDERDETAILSposnr, IT_ORDERDETAILSkunnr)
    FROM VBAK left outer JOIN VBAP ON ( VBAKVBELN = VBAPVBELN )
    left outer JOIN LIPS ON ( VBAKVBELN = LIPSVGBEL )
      join LIKP on ( LIPSVBELN = LIKPVBELN )
    WHERE VBAK~ERDAT IN CR_DATE.
    I am getting error in the query.
    Please suggest.
    Thanks,
    Rajesh

    Hi rajesh.nayakbola,
    although this is not quite the right place for this, let me give you some notes:
    1. Code should be
    formatted as code
    by markin it with mouse and use above &lt;&gt; button.
    2. Internal tables shoult not be declared using OCCURS clause - this is last century style
    3. Internal tables do not need and should not have a header line, they should use TYPES for declaration
    4. Data should not be declared using LIKE: If they refer to dictionary TYPES, use TYPE. LIKE is only mandatory for data objects declared in your program, i.e. DATA IT_some_ORDERDETAILS like IT_ORDERDETAILS.
    5. If you get an error here, never write "I am getting error" but copy and paste the error message fully.
    - The fields in brackets in  the INTO clause never have ~ character, there is no IT_ORDERDETAILS~vbak, only IT_ORDERDETAILS-vbeln
    It could be something like this:
    TYPES:
      BEGIN OF TY_ORDERDETAILS,
      VBELN TYPE VBAK-VBELN, "Order number
      BSTNK TYPE VBAK-BSTNK, "customer PO
      ERDAT TYPE VBAK-ERDAT, " Order created date
      MATNR TYPE VBAP-MATNR, "Sales order line item
      KWMENG TYPE VBAP-KWMENG, "Quantity
      D_VBELN TYPE likp-vbeln, " delivery no
      POSNR TYPE lips-posnr, " delivery item
      KUNNR TYPE LIKP-KUNNR, "ship quantity
    END OF TY_ORDERDETAILS.
    DATA:
      IT_ORDERDETAILS TYPE TABLE OF TY_ORDERDETAILS.
    SELECT VBAK~VBELN
      VBAK~BSTNK
      VBAK~ERDAT
      VBAP~MATNR
      VBAP~KWMENG 
      likp~vbeln AS D_VBELN
      lips~posnr
      LIKP~KUNNR
    INTO CORRSPONDING FIELDS OF TABLE IT_ORDERDETAILS
    FROM VBAK left outer JOIN VBAP ON ( VBAK~VBELN = VBAP~VBELN )
      left outer JOIN LIPS ON ( VBAK~VBELN = LIPS~VGBEL )
      join LIKP on ( LIPS~VBELN = LIKP~VBELN )
    WHERE VBAK~ERDAT IN CR_DATE.
    Regards,
    Clemens

  • Internal Table dynamic query

    Hello,
    I have an internal table which needs to be queried with set of attributes which change dynamically. How can I do it?
    Eg: Internal Table i_tab contains attributes a,b,c,d,e etc... Now I should extract a single line from the table based based on the values I supply for the attributes.
    Say if I give a=23 b='' c='abc' d='' e=''. Then the query should be able to return be the line where all the initial field attributes (here in this case b,d, and e) should not be considered for the query.
    It shoud be
    read table i_tab with key a= 23 c='abc'.
    The next time a query can be shooted with the foll values
    a='' b='SAP' c='ERP' d='' e=''.
    Then the query shd be
    read table i_tab with key b= 'SAP' c='ERP'.
    In short can I get the functionality of the "select statement dynamic search string"?
    select * from tab where ( search string ) .
    and search string would be generated dynamically based on the inputs?
    I would be really thankful if you can provide me an immediate answer.
    Thanks and Regards,
    Sandhya

    I think one of the simplest way is to define ranges for the variables a, b, c, d and e.
    ranges : r_a for a, r_b for b...r_e for e.
    refresh : r_a, r_b, r_c, r_d, r_e. 
    clear :  r_a, r_b, r_c, r_d, r_e. 
    if a is not initial.
       r_a-sign = 'I'.
       r_a-option = 'EQ'.
       r_a-low = value.
       append r_a.
    endif.
    ....similarly build for b, c, d and e.
    Loop at itab.
      check itab-a in r_a.
      check itab-b in r_b.
      check itab-e in r_e.
      move-corresponding itab to <b>urval</b>.
      exit.
    endloop.

Maybe you are looking for

  • Adobe Acrobat 8.0 Professional prompts Save As?

    Hello, We recently updated Adobe Acrobat Professional 8.0 and it's doing something that it didn't do before and we need to get rid of the option. Before: We'd click on Create PDF Click From Scanner... Comes up with a dialog box that's titled "Create

  • Open Item Management and parallel accounting

    We are using parallel accounting, there are two ledgers setup. With this setup, posing to leading ledger will automatically post an entries to non-leading ledger. Our user have this requirement, that for adjustment purpose, they just want to post to

  • Transaction code to know stock lying in quality inspection(for UD)

    Hi, Pl let me know transaction code to know stock agaisnt materials lying under quality inspection ( for UD ) for more than one materials or plant wise or pgrp wise or sloc wise .... Thanks Arul Murugan

  • Can I replace a cracked glass on the iPad

    Can I replace a cracked glass on the ipad

  • How can i use Java proxies?

    Hi, Q1. Where all can  java proxies be used?  Is it only in scenarios where a java appication(like jsp) is involved? I have a IDOC-XI-SFTP scenario. I have a java program that creates the SSH session and transfers files. I can use this as a Java Mapp