Sum in internal tabel

VALU     STOCK     rate
1M     0     0
1.5M     70     0
10M     200     0
10.5M     300     0
11M     0     0
11.5M     130     0
12M     20     12/30/2008
12.5M     50     0
13M     39     0
13.5M     2     12/30/2008
2M     33     0
2.5M     200     0
3M     11     12/30/2008
4M     22     0
5M     No stock     12/30/2008
8M     100     0
8.5M     97     0
9M     12     20-Nov
9.5M     99     0
1M     22     0
1.5M     22     0
10M     33     0
10.5M     22     0
11M      0     12/30/2008
11.5M     22     0
12M     22     0
12.5M     12     0
Now I want to add up all the stock depending on valu. and if the total is 0 it should take the current date.

types: begin of t_it,
           value type...
           stock type...
           rate type...
          end of t_it.
data: it type table of t_it with key value with header line.
"now populate your table it
"now just use collect
loop at it.
  collect it.
  if it-value is initial.
    write sy-datum.
  endif.
endloop.

Similar Messages

  • USING SUM IN INTERNAL TABLE

    plz give me a simple example for using SUM in internal table and do some calculations in the same internal table.

    HI
    CHECK WITH THIS
    Syntax
    SUM.
    Effect
    The statement SUM can only be specified within a loop starting with LOOP, and is only considered within a AT- ENDAT control structure. Prerequisites for using the statement SUM include using the addition INTO in the LOOP statement, and that the specified work area wa is compatible with the row type of the internal table. In addition, SUM cannot be used when the row type of the internal table itab contains components that are tables.
    The statement SUM calculates the component total with the numeric data type (i, p, f) of all rows in the current control level and assigns these to the components of the work area wa. In the control levels FIRST, LAST, and outside of an AT-ENDAT control structure, the system calculates the sum of numeric components of all rows in the internal table.
    Example
    Control level processing for creating a list. At the end of line groups, the total of reserved places is calculated and issued.
    DATA: sflight_tab TYPE SORTED TABLE OF sflight
                      WITH UNIQUE KEY carrid connid fldate,
          sflight_wa  LIKE LINE OF sflight_tab.
    SELECT *
           FROM sflight
           INTO TABLE sflight_tab.
    LOOP AT sflight_tab INTO sflight_wa.
      AT NEW connid.
        WRITE: / sflight_wa-carrid,
                 sflight_wa-connid.
        ULINE.
      ENDAT.
      WRITE: / sflight_wa-fldate,
               sflight_wa-seatsocc.
      AT END OF connid.
        SUM.
        ULINE.
        WRITE: / 'Sum',
                  sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
        SKIP.
      ENDAT.
      AT END OF carrid.
        SUM.
        ULINE.
        WRITE: / 'Carrier Sum',
                  sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
        NEW-PAGE.
      ENDAT.
      AT LAST.
        SUM.
        WRITE: / 'Overall Sum',
                  sflight_wa-seatsocc UNDER sflight_wa-seatsocc.
      ENDAT.
    ENDLOOP.
    Hope this solves ur problem....
    <b>do reward if useful....</b>
    regards
    dinesh

  • Sum in internal table issue

    Dear Experts,
    I have a Qty field which needs to be summed up when material no, po no and size are same in my internal table
    Eg: PO no     Mat no     Size      Qty
          111          001          L          10
          111          001          L          20
    needs to be shown as
          111          001          L          30
    I have tried using the collect statement in several ways but unfortunately ddnt work out. Any suggestions?

    Although Farid's sugegestion of looping and over two tables and summing would work I don't there is any reason to desist with your original approach of using the collect statement. The collect statment is designed exactly for this purpose and would be more efficient than two nested loops. As described before the folloiwng code should work the correct data elements inserted instead of the descriptions
    types: BEGIN OF tys_structure,
             po_num type po_num,
             mat_no type mat_no,
             size type sizw,
             qty type qty,
            END OF tys_structure.
    data: lt_table type standard table of tys_structure
               with non-unique key matnr, po_no, size,
             ls_workarea type type_structure.
    collect ls_workarea into lt_table.
    One additional note, It would probably be better to use a unique key of a sorted or hashed table if you only want the results to be aggreagted by material no, po no and size. I suggested a non-unique key of a standard table here because it is more flexible and i don't know what elese you might want to do with this table in your code. 

  • Sum in Internal Tables

    Dear Friends,
    I AM WRITING A REPORT TO SHOW THE ALL THE POs WHOSE GRs HAS BEEN DONE BUT NOT THE IRs.
    LIKE :-
    Serial_no    Vendor_no    vendor_name     Po_no         ItemNo       GR_no          Ref_Doc_num          Amount
    I GOT THE REPORT BUT NOW MY USER SAYS ....
    HE WANTS one recod (Serial_no) if po_no and GR_no and ref_doc_num are same with Amount summed up.
    so that serial number will be less and and he will get the total amount of the pending GR.
    I am not getting the logic how shall I sum up the amounts comapring po, gr and Ref doc no.
    Regards,
    jeevan.

    Thanks for your replies. but i am not getting that......
    i have an internal table with POs ..item nos...grs..ref no..... anmount..
    now i have to get it in another internal table where there will be only Serialno .. po.no.gr..and ref and amount summed up all the similar ref numbers.
    here is code.. its not optimized...but see... i have included
    *& Report  ZMMR_TEST2
    REPORT  ZMMR_TEST2.
    TABLES : EKKO, EKBE, LFA1.
    TYPE-POOLS : SLIS.
    DATA : begin of IT_ekbe4 OCCURS 1  ,
            i_index type i,
            lifnr TYPE ekko-lifnr,
            name1 TYPE lfa1-name1,
            no_name type string,
            ebeln TYPE ekbe-ebeln,
            ebelp TYPE ekbe-ebelp,
            belnr TYPE ekbe-belnr,
            xblnr TYPE ekbe-xblnr,
            dmbtr TYPE ekbe-dmbtr,
            bewtp TYPE ekbe-bewtp,
            bwart TYPE ekbe-bwart,
            menge type ekbe-menge,
           end of IT_ekbe4.
    DATA : it_ekbe like ekbe occurs 1 with header line,
          it_ekbe2 like ekbe occurs 1 with header line,
          it_ekbe3 like it_ekbe4 occurs 1 with header line.
    DATA : V_TABIX LIKE SY-TABIX.
    *DATA : it_ekbe4 type standard table of s_ekbe4 initial size 0,
           wa_ekbe4 type s_ekbe4.
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid.
    *selection screen.
    select-options : s_date for ekbe-budat.
    PARAMETERS DOC_TYP LIKE EKKO-BSART.
    *Start-of-selection.
      select a~ebeln a~ebelp a~bewtp a~bwart a~xblnr a~dmbtr a~belnr
                b~lifnr
                c~name1
                into  (it_ekbe4-EBELN, it_ekbe4-ebelp, it_ekbe4-bewtp,
    it_ekbe4-bwart, it_ekbe4-xblnr, it_ekbe4-dmbtr, it_ekbe4-belnr,
    it_ekbe4-lifnr, it_ekbe4-name1)
                from ekbe as a
                inner join ekko as b
                on a~ebeln = b~ebeln
                inner join lfa1 as c
                on b~lifnr = c~lifnr
                where a~budat in s_date
                and a~bewtp = 'E'
                and a~bwart in ('101','102', '122')
                and b~bstyp = 'F'
                and b~bsart  = DOC_TYP
                and b~ekorg = '1000'
         select ebeln ebelp bewtp bwart
                  from ekbe
                  into (it_ekbe2-EBELN , it_ekbe2-ebelp , it_ekbe2-bewtp ,
    it_ekbe2-bwart)
                  where ebeln = IT_EKBE4-EBELN
                  and ebelp = it_ekbe4-ebelp
                  and bewtp = 'Q'.
          APPEND IT_EKBE2.
        ENDSELECT.
         APPEND IT_EKBE4.
      ENDSELECT.
      LOOP AT IT_EKBE4.
        V_TABIX = SY-TABIX.
        READ TABLE IT_EKBE2 WITH KEY EBELN = IT_EKBE4-EBELN ebelp =
    it_ekbe4-ebelp.
        IF SY-SUBRC = 0.
          DELETE IT_EKBE4 INDEX V_TABIX.
        ENDIF.
        ENDLOOP.
        clear v_tabix.
      LOOP AT IT_EKBE4.
        if ( it_ekbe4-bwart = '102' or it_ekbe4-bwart = '122' ).
          it_ekbe4-dmbtr = it_ekbe4-dmbtr * -1.
        endif.
           it_ekbe3-i_index = sy-tabix.
           it_ekbe3-ebeln = it_ekbe4-ebeln.
           it_ekbe3-ebelp = it_ekbe4-ebelp.
           it_ekbe3-belnr = it_ekbe4-belnr.
           it_ekbe3-xblnr = it_ekbe4-xblnr.
           it_ekbe3-dmbtr = it_ekbe4-dmbtr.
           it_ekbe3-lifnr = it_ekbe4-lifnr.
           it_ekbe3-name1 = it_ekbe4-name1.
           concatenate it_ekbe4-name1 '/' it_ekbe4-lifnr into  it_ekbe3-no_name.
    *separated by space.
           append it_ekbe3. "YOU TOLD THIS TO BE COLLECT."
          Collect it_ekbe3 into it_ekbe3.
      ENDLOOp.
    sub totals.
    *loop at it_ekbe3.
    *collect
    *endloop.
    loop at it_ekbe3.
    write:/ it_ekbe3-ebeln , 'gr', it_ekbe3-belnr , 'ref', it_ekbe3-xblnr, 'amount', it_ekbe3-dmbtr.
    endloop.

  • Convert Internal tabel to pdf and send email

    Hi all,
    I have report in internal table and I need to email this report as an pdf attchment.
    It need not to be pdf file, can be any format but printer friendly.
    I am using function module SO_NEW_DOCUMENT_ATT_SEND_API1 but not able to send report as pdf. But I can able to send as RAW file but it is not printer friendly.
    How can I do this?
    Thanks
    Shiva.

    Hi,
    You can send the PDF using OOPS abap classes and methods
    for sending it in mail .
    Regards
    Mansi

  • Only first line in a internal tabel should appear in output

    Hi,
    I have a requirement.
    I loop at an internal table and that tabl (list_selected_records) records.
      Loop at list_of_selected_nodes into wa_selected_nodes.
        node = wa_selected_nodes-node_id.
        node_level = wa_selected_nodes-node_level.
        read table ex_list_of_texts
                           into wa_list_of_texts
                           with key node_id = node
                           binary search.
        IF sy-subrc eq 0.
          node_text = wa_list_of_texts-text.
        ENDIF.
          node_level = node_level - 1.
    Selecting Text for Node selected (Business Scenario)
    READ TABLE list_of_all_nodes into wa_all_nodes WITH KEY NODE_LEVEL = node_level
                         BINARY SEARCH.
    if sy-subrc = 0.
    SELECT SINGLE TEXT FROM TTREET into texts WHERE ID    EQ wa_all_nodes-tree_id
                                AND   SPRAS EQ 'EN  '.
    IF NOT TEXTS IS INITIAL.
      wa_final-texts = texts.
    append wa_final to it_final.
    CLEAR WA_FINAL.
    endif.
    endif.
      endloop.
    This is my code.
    Now from the select single stmt i fetch a text and add it to be internal table . Once i fetch a one record the loop should be ended and a new iteration for for a second guid should start.
    Once one record , first record is fetched for texts, only that shd appear in alv output but not other. but the loop should contnue for other fields. Please help
    Thanks in Advance.
    SS

    Hi Swarna,
    Use control event AT-NEW inside the loop. This event will triger only once for every new node_id.
    Loop at list_of_selected_nodes into wa_selected_nodes.
    AT-NEW node_id.
    node = wa_selected_nodes-node_id.
    node_level = wa_selected_nodes-node_level.
    read table ex_list_of_texts
    into wa_list_of_texts
    with key node_id = node
    binary search.
    IF sy-subrc eq 0.
    node_text = wa_list_of_texts-text.
    ENDIF.
    node_level = node_level - 1.
    Selecting Text for Node selected (Business Scenario)
    READ TABLE list_of_all_nodes into wa_all_nodes WITH KEY NODE_LEVEL = node_level
    BINARY SEARCH.
    if sy-subrc = 0.
    SELECT SINGLE TEXT FROM TTREET into texts WHERE ID EQ wa_all_nodes-tree_id
    AND SPRAS EQ 'EN '.
    IF NOT TEXTS IS INITIAL.
    wa_final-texts = texts.
    append wa_final to it_final.
    CLEAR WA_FINAL.
    endif.
    endif.
    ENDAT.
    endloop.
    Thanks & Regards,
    Parameswaran.K

  • Passing internal tabel values to a variable

    Hi experts,
                    I wanna pass the values of an internal table eg itab to a variable of character type of lenth 1000. the values in itab are of different types.
    plz suggest me how solve this.
    regards,
    alson.

    Hi..,
    use the field-symbols....
    (This code is for an itab which contains more than one field... )
    <b>
    data:
      w_line(1000),
      w_field(40) type c.
    table to hold all the records resulted from concatenating fields....
    data
      t_file like standard table
               of w_line
          initial size 0.
    field-symbols <fs>.
    loop at itab into wa_itab.
      do.
        assign component sy-index of structure wa_itab to <fs>.
        if sy-subrc ne 0.
          exit.
        endif.
        w_field = <fs>.
        condense w_field no-gaps.
        if sy-index eq 1.
          w_line = w_field.
        else.
          concatenate w_line ' ' w_field into w_line.
        endif.                             " If sy-index eq 1.
      enddo.                               " Do.
      append w_line to t_file.
    endloop.               
    </b>
    if u have itab onli with one field
    then...
    <b>data:
      w_line(1000),
      w_field(40) type c.
    loop at itab.
    w_field = itab-field.
    concatenate w_line w_field into w_line.
    endloop.</b>
    reward if it helps u..
    sai ramesh

  • Abap internal tabel to xml

    Hi All,
    I have generated xml file from internal table and need to display in excel as a report..but i need to add the custom column names and other formating options..could any one help  me how to generate the xml with those column headings or attributes.
    <?xml version="1.0" encoding="iso-8859-1" ?>
    - <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    - <asx:values>
    - <OUTPUT>
    - <item>
      <MANDT>040</MANDT>
      <ZPRDBRN>HCPTOOLSUS</ZPRDBRN>
      <DESCRP>Current Open Deliveries</DESCRP>
      <ZPTDAT>2008-12-19</ZPTDAT>
      <ZHTUSOR>527</ZHTUSOR>
      <ZHTUSIT>3753</ZHTUSIT>
      <ZHTUSQT>43973</ZHTUSQT>
      <ZHTUSNT>1623976.22</ZHTUSNT>
      <ZHPRTOR />
      <ZHPRTITM />
      <ZHPRTQT />
        </item>
    appreciate your help..
    thanks,
    Suresh.

    Hello Suresh,
    May be you can try this piece of code:
    *& Report  Z_SPLIT_TABLE
    REPORT  Z_SPLIT_TABLE.
    TYPES:
      BEGIN OF TY_VBAK,
        VBELN TYPE VBELN_VA,
        VBTYP TYPE VBTYP,
        ERDAT TYPE ERDAT,
      END OF TY_VBAK,
      BEGIN OF TY_XML,
        DATA TYPE REF TO DATA,
        XML  TYPE STRING,
      END OF TY_XML.
    DATA:
      V_ROWS      TYPE I,
      IT_VBAK     TYPE STANDARD TABLE OF TY_VBAK,
      V_FILENAM   TYPE STRING,
      V_FILEPATH  TYPE STRING,
      V_SIZE      TYPE I,
      IT_DATA     TYPE REF TO DATA,
      IT_XML      TYPE STANDARD TABLE OF TY_XML,
      WA_XML      TYPE TY_XML,
      CL_ZIP      TYPE REF TO CL_ABAP_ZIP.
    DATA:
      V_DATA     TYPE REF TO DATA,
      V_XML      TYPE XSTRING,
      V_ZIPFILE  TYPE XSTRING,
      IT_BINFILE TYPE STANDARD TABLE OF X255.
    FIELD-SYMBOLS:
      <FS_TAB> TYPE TABLE,
      <FS>     TYPE ANY.
    PARAMETERS:
      P_DATA TYPE NUMC2 DEFAULT '25',
      P_FILE TYPE LOCALFILE DEFAULT
                  'C:\Documents and Settings\ssaha\Desktop\'.
    START-OF-SELECTION.
      V_ROWS = P_DATA.
      SELECT VBELN VBTYP ERDAT UP TO V_ROWS ROWS
      INTO TABLE IT_VBAK
      FROM VBAK
      WHERE ERDAT <= '20081231'
      OR    ERDAT >  '20080901'.
      IF SY-SUBRC = 0.
    *   Create DATA reference of the internal table
        GET REFERENCE OF IT_VBAK INTO IT_DATA.
    *   Transfer the contents of this to the data table
        WA_XML-DATA = IT_DATA.
        CONCATENATE SY-DATUM SY-UZEIT '.txt' INTO WA_XML-XML.
        APPEND WA_XML TO IT_XML.
        CLEAR WA_XML.
      ENDIF.
    END-OF-SELECTION.
      CREATE OBJECT CL_ZIP.
      LOOP AT IT_XML INTO WA_XML.
        UNASSIGN: <FS_TAB>, <FS>.
        ASSIGN WA_XML-DATA->* TO <FS_TAB>.
        CREATE DATA V_DATA LIKE LINE OF <FS_TAB>.
        ASSIGN V_DATA->* TO <FS>.
    *   Create the XML Transformation
        CALL TRANSFORMATION ID
        SOURCE <FS> = <FS_TAB>
        RESULT XML V_XML.
    *   Add the XML file to ZIP folder
        CALL METHOD CL_ZIP->ADD( NAME    = WA_XML-XML
            CONTENT = V_XML )
    *      EXPORTING
      ENDLOOP.
      V_ZIPFILE = CL_ZIP->SAVE( ).
    *    RECEIVING
    *      ZIP = V_ZIPFILE.
      CLEAR V_SIZE.
      CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
        EXPORTING
          BUFFER        = V_ZIPFILE
        IMPORTING
          OUTPUT_LENGTH = V_SIZE
        TABLES
          BINARY_TAB    = IT_BINFILE.
      V_FILEPATH = P_FILE.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          BIN_FILESIZE            = V_SIZE
          FILENAME                = V_FILEPATH
          FILETYPE                = 'BIN'
        TABLES
          DATA_TAB                = IT_BINFILE
        EXCEPTIONS
          FILE_WRITE_ERROR        = 1
          NO_BATCH                = 2
          GUI_REFUSE_FILETRANSFER = 3
          INVALID_TYPE            = 4
          NO_AUTHORITY            = 5
          UNKNOWN_ERROR           = 6
          HEADER_NOT_ALLOWED      = 7
          SEPARATOR_NOT_ALLOWED   = 8
          FILESIZE_NOT_ALLOWED    = 9
          HEADER_TOO_LONG         = 10
          DP_ERROR_CREATE         = 11
          DP_ERROR_SEND           = 12
          DP_ERROR_WRITE          = 13
          UNKNOWN_DP_ERROR        = 14
          ACCESS_DENIED           = 15
          DP_OUT_OF_MEMORY        = 16
          DISK_FULL               = 17
          DP_TIMEOUT              = 18
          FILE_NOT_FOUND          = 19
          DATAPROVIDER_EXCEPTION  = 20
          CONTROL_FLUSH_ERROR     = 21
          OTHERS                  = 22.
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    I written this code to generate a ZIP file instead it generated an XML file ) I am still working on it.
    But since you need an XML file i hope this helps.
    BR,
    Suhas

  • How many types of internal tabels?

    hi all,
    how many types of internal tbels ,
    how they are differetiate ?
    regards.
    raj

    Hi,
    Three Types of Internal Table:
    1.Standard Table
    2.Sorted Table
    3.Hashed Table
    Standard Table - the most commonly used type of table.
    The key access to a standard table uses a sequential search. The time required for an access is linearly dependent on the number of entries in the internal table.
    You should usually access a standard table with index operations.
    You can sort and resort this table anytime. You can have duplicate records in them. Recommend that when accessing these tables, you sort them by a key and then READ via a BINARY SEARCH - better performance. When you write to this table the record is "appended" to the end of the table. In order to maintain the sort sequence (if any) you must use the SORT command again.
    Sorted table - this table has a defined sort sequence. You cannot resort. You can have duplicates.
    The table is always stored internally sorted by its key. Key access to a sorted table can therefore use a binary search. If the key is not unique, the entry with the lowest index is accessed. The time required for an access is logarithmically dependent on the number of entries in the internal table.
    Index accesses to sorted tables are also allowed. You should usually access a sorted table using its key.
    When you READ these tables, SAP automatically tries to use a BINARY SEARCH. Because you use a Binary Search, the retrieval time isexpodential to the number of records. When you write a record to this table the table is resorted.
    Hashed Table - this table has a defined key.
    The table is internally managed with a hash procedure. All the entries must have a unique key. The time required for a key access is constant, that is it does not depend on the number of entries in the internal table.
    When you write to the table it uses a hashing algorithm to identify where the record is stored (think if this as writing the location of a page in an index of a book). When you READ this table the system looks up this "index" and retrieves the record. Because of this the retrieval time is constant. Writing to this type of table takes the most time as it needs to calculate the hashing algorithm.
    Personally I generally use Standard Tables as they are the most flexible table available. It lets me resort my data anyhow I like any time I like. I very rarely use a Sorted Table.
    I use Hashed Tables as "buffer" tables. Let's say for example I want to retrieve HR data for a number of sales reps. To get HR data I need to use FM 'HR_READ_INFOTYPE'. This takes time. So what I do is read my hashed table to see if I have already got the data (very quick). If I don't have the data, I hit the FM and update my hashed table for next time. By using the hashed table in this way I reduce the number of FM calls I need to make.
    /people/harry.dietz/blog/2005/10/28/performance-improvement-hints-3-internal-table--fill-and-read
    http://www.sap-img.com/abap/what-are-different-types-of-internal-tables-and-their-usage.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/frameset.htm
    Regards,
    Padmam.

  • Summing the internal table values

    Hi Experts,
    I have requirement in report to add the values in the internal table based on document no.
    for example
    Document no         date                         Amount                Exchange Rate
    190000012         05.04.2009                     100                                1
    190000012         05.04.2009                     200                                1
    190000012         05.04.2009                     300                                1
    190000013         05.04.2009                     100                                1
    190000013         05.04.2009                     200                                1
    190000014         05.04.2009                     100                                1
    If i use Collect or  On change statements , the exchange rate is also adding
    Document no         date                         Amount                Exchange Rate
    190000012         05.04.2009                     600                                3
    190000013         05.04.2009                     300                                2
    190000014         05.04.2009                     100                                1
    But i want to add only the amount field not the exchange rate .Please suggest me the best solutions.
    I want to display as
    Document no         date                         Amount                Exchange Rate
    190000012         05.04.2009                     600                                1
    190000013         05.04.2009                     300                                1
    190000014         05.04.2009                     100                                1
    Thanks in advance
    satish

    hi,
    check this
    Sort itab by documentno.
    Loop at itab1.
    on change of itab1-dcno.
    clear total.
    move itab1-docno to itab2-docno.
    itab2-total = itab-amont.
    move itab1-total to itab2-total.
    move itab1-date to itab2-date.
    move itab1-rate to itab2-rate.
    flag = '  '.
    append itab2.
    clear itab2.
    else.
    itab2-total = itab2-total + itab-amont.
    endon
    Endloop.
    it will work for  adjest append statement according to the out put .
    ~linganna

  • Get edited data ou of grid back into internal tabel

    Hi dear all,
    after the help of so brilliant tutors i now can edit my ALV Grid, but I dont't know how i can get the content of the edited rows back into the internal table (it_outtab). I studied several methods, but for example the method SAVE_DATA is private, so I can't use it out of my program.
    Many  many thanks in advance for th friendly colleague who knows the answer.
    Dorothea.

    Hello Dorothea
    If you just want that your itab contents reflects the data on the editable ALV grid then the simplest solution is to call the appropriate method at PAI:
    " Your dynpro flow logic may look like this:
    PROCESS BEFORE OUTPUT.
      MODULE STATUS_0100.
    PROCESS AFTER INPUT.
      MODULE USER_COMMAND_0100.
    *& Module USER_COMMAND_0100 INPUT
    * text
    MODULE user_command_0100 INPUT.
      CALL METHOD go_grid->check_changed_data( ).  " retrieves changes from editable ALV grid
                                                                                " and updates itab, e.g. gt_outtab
    " NOTE: If you do not need to validate the changed data there is no need
    "            to define an event handler method.
    CASE gd_okcode.
    WHEN 'BACK' OR
    'END' OR
    'CANC'.
    SET SCREEN 0. LEAVE SCREEN.
    WHEN OTHERS.
    ENDCASE.
    CLEAR: gd_okcode.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    You may want to have a look at ALV GRID Problem with reading contents and my dicussion with David Halitsky in Where/how would you add the actual DB update to BCALV_EDIT_03?.
    Regards
      Uwe

  • Append a record to internal table

    hello:
    when i execute the code below,there is a runtime error." In die sortierte interne Tabelle (Typ SORTED_TABLE)
      "PROGRAM=ZJOIN_INTER_TABLEDATA=T_ITAB1" sollte an
    Position 1 eine Zeile eingefügt bzw. geändert werden.
    Dadurch wurde die für die Tabelle durch ihren Schlüssel festgelegte
    Sortierreihenfolge zerstört."
    how can i resolve it?which one can tell me?Thanks very much
    REPORT  ZJOIN_INTER_TABLE.
    DATA:BEGIN OF WA_ITAB,
            COL1 TYPE I,
            COL2(10) TYPE C,
          END OF WA_ITAB.
    DATA:T_ITAB1 LIKE SORTED TABLE OF WA_ITAB WITH NON-UNIQUE KEY COL1.
    WA_ITAB-COL1 = 10.
    WA_ITAB-COL2 = 'col2'.
    APPEND WA_ITAB TO T_ITAB1.
    WA_ITAB-COL1 = 9.
    WA_ITAB-COL2 = 'col2'.
    APPEND WA_ITAB TO T_ITAB1.

    hi
    kindly go thro the lines.
    syntax:
    DATA itab {TYPE tabkind OF linetype|LIKE tabkind OF lineobj}
              WITH [UNIQUE|NON-UNIQUE] keydef
              [INITIAL SIZE n] [WITH HEADER LINE].
    The system creates an internal table with table type tabkind. Since there is no generic field definition, you cannot use the table types ANY TABLE or SORTED TABLE.
    The construction of the table lines is defined by linetype (if you are using a TYPE reference) or by the type of the referred object lineobj (if you are using a LIKE reference). If you specify the line type, you can also use REF TO to refer to a reference type.
    The same rules apply to UNIQUE and NON-UNIQUE as apply to the TYPES definition. You may only omit this specification with standard tables.
    If you do not specify an INITIAL SIZE, the system assumes a default value of INITIAL SIZE 0.
    i think now u r clear... now yr code will work.
    DATA:BEGIN OF WA_ITAB,
    COL1 TYPE I,
    COL2(10) TYPE C,
    END OF WA_ITAB.
    DATA:T_ITAB1 like TABLE OF WA_ITAB WITH NON-UNIQUE KEY COL1.
    WA_ITAB-COL1 = 10.
    WA_ITAB-COL2 = 'col2'.
    APPEND WA_ITAB TO T_ITAB1.
    WA_ITAB-COL1 = 9.
    WA_ITAB-COL2 = 'col2'.
    APPEND WA_ITAB TO T_ITAB1.

  • Left ouer join with internal table

    Good morning to everybody
    I need created a internal table with 2 internal table but 1 is primary.
    I tried use "left outer join" but it allows  only with table and not with internal tabel
    I would to be this result
    a             a xxx
    b                         
    c             c zzz
    d             d sss
    e
    f              f ttt
    How can i do it?
    Thanks a lot for your support
    Beste regatrds

    Hi,
    The following code is for your reference:
    data: begin of wa1,
          key type c,
          end of wa1.
    data: begin of wa2,
          key type c,
          var(3) type c,
          end of wa2.
    data: begin of wa3,
          key1 type c,
          key2 type c,
          var(3) type c,
          end of wa3.
    data: itab1 like standard table of wa1,
          itab2 like standard table of wa2,
          itab3 like standard table of wa3.
    wa1-key = 'a'.
    append wa1 to itab1.
    wa1-key = 'b'.
    append wa1 to itab1.
    wa1-key = 'c'.
    append wa1 to itab1.
    wa1-key = 'd'.
    append wa1 to itab1.
    wa1-key = 'e'.
    append wa1 to itab1.
    wa1-key = 'f'.
    append wa1 to itab1.
    clear wa1.
    wa2-key = 'a'.
    wa2-var = 'zzz'.
    append wa2 to itab2.
    wa2-key = 'c'.
    wa2-var = 'yyy'.
    append wa2 to itab2.
    wa2-key = 'd'.
    wa2-var = 'ttt'.
    append wa2 to itab2.
    wa2-key = 'f'.
    wa2-var = 'sss'.
    append wa2 to itab2.
    clear wa2.
    loop at itab1 into wa1.
      read table itab2 into wa2
      with key key = wa1-key
      binary search.
      if sy-subrc = 0.
        wa3-key1 = wa1-key.
        wa3-key2 = wa2-key.
        wa3-var = wa2-var.
        append wa3 to itab3.
        clear wa3.
      else.
        append wa1 to itab3.
      endif.
    endloop.
    loop at itab3 into wa3.
      write:/ wa3-key1, wa3-key2,wa3-var.
    endloop.
    Hope it helps.
    Regards,
    Chris Gu

  • Set operations on Internal tables.

    Hi,
      Last week i had to enhance a program that has a internal table with some records. I need to find populate a table with the records in the internal table. But before populating i must find out the difference in the records (i.e) the extra records in the internal table compared with the records in the database table and then i have to append those records in the internal table again and then insert the internal table records into database table. while doing it i need to create another internal table with records in database table and then loop at it to find the extra records and rest of the logic goes on.
      At this point of time it clicked in my mind "WHY DON'T WE HAVE SET OPERATIONS ON TWO INTERNAL TABELS(UNION, INTERSECTION, MINUS)".
      Now i am doing some study how to implemnt it. Before that i want to find out whether that functionality exists in ABAP or anybody of youo gurus have done similar work on it.
    Pls help me in proceeding with my work.

    Hi Arul,
    There is no special aided SET operations upon internal tables in ABAP. Concerning your particular task I would say that you can try INSERT statement for each record in your internal table without preliminary comparing them with DB table. If there is a record in DB table with the same key then sy-subrc after INSERT will be non zero (actually 4) and no real insert would occur. So, only those records would be inserted which have no counterpart in DB table.
    Best regards, Sergei

  • Duplicate Entries in Internal Tables

    Hallo Friends,
    It Would be nice if some one let me know, if there is a way in ABAP to select the duplicates records in an internal tables.
    Lets say I have two internal tabels, itabA have following structure:
    BNAME  |          WORKAREA   |   ROLES
    abc |             wa1 |          ro1
    cde  |            wa1 |          ro1
    cde  |      wa3 |          rol..
    abc  |      wa2 |          rol2
    xyz |       wa1 |          rol3
    xyz  |      wa3  |         rol2..
    the itabB have the following structure:
    WORKAREA |      ROLES|  
    wa1   |         rol1
    wa2  |        rol1
    wa3  |          rol1
    wa4  |          rol1
    Now problem is, I need to select the common WorkAreas from itabA ( which is commom in all BNAME ) in above example it will be workarea wa1. as it is commom in all i.e ( abc ,cde and xyz). I need to select this commom workarea, and then mark it with some flage in itabB ( to display that this workarea is common among the users...)
    Would be nice if some one let me know, is there any way I can select the duplicate rows in an internal table or I have to go one by one and then do some kind of comparision.
    Many thanks,
    Thx in advance....
    Haider

    Hi marek,
    below information might help you.
    The first criterion for comparing internal tables is the number of lines they contain. The more lines an internal table contains, the larger it is. If two internal tables contain the same number of lines, they are compared line by line, component by component. If components of the table lines are themselves internal tables, they are compared recursively. If you are testing internal tables for anything other than equality, the comparison stops when it reaches the first pair of components that are unequal, and returns the corresponding result.
    DATA: BEGIN OF LINE,
    COL1 TYPE I,
    COL2 TYPE I,
    END OF LINE.
    DATA: ITAB LIKE TABLE OF LINE,
    JTAB LIKE TABLE OF LINE.
    DO 3 TIMES.
    LINE-COL1 = SY-INDEX.
    LINE-COL2 = SY-INDEX ** 2.
      APPEND LINE TO ITAB.
    ENDDO.
    MOVE ITAB TO JTAB.
    LINE-COL1 = 10. LINE-COL2 = 20.
    APPEND LINE TO ITAB.
    IF ITAB GT JTAB.
    WRITE / 'ITAB GT JTAB'.
    ENDIF.
    APPEND LINE TO JTAB.
    IF ITAB EQ JTAB.
    WRITE / 'ITAB EQ JTAB'.
    ENDIF.
    LINE-COL1 = 30. LINE-COL2 = 80.
    APPEND LINE TO ITAB.
    IF JTAB LE ITAB.
    WRITE / 'JTAB LE ITAB'.
    ENDIF.
    LINE-COL1 = 50. LINE-COL2 = 60.
    APPEND LINE TO JTAB.
    IF ITAB NE JTAB.
    WRITE / 'ITAB NE JTAB'.
    ENDIF.
    IF ITAB LT JTAB.
    WRITE / 'ITAB LT JTAB'.
    ENDIF.
    The output is:
    ITAB GT JTAB
    ITAB EQ JTAB
    JTAB LE ITAB
    ITAB NE JTAB
    ITAB LT JTAB
    This example creates two standard tables, ITAB and JTAB. ITAB is filled with 3 lines and copied to JTAB. Then, another line is appended to ITAB and the first logical expression tests whether ITAB is greater than JTAB. After appending the same line to JTAB, the second logical expression tests whether both tables are equal. Then, another line is appended to ITAB and the third logical expressions tests whether JTAB is less than or equal to ITAB. Next, another line is appended to JTAB. Its contents are unequal to the contents of the last line of ITAB. The next logical expressions test whether ITAB is not equal to JTAB. The first table field whose contents are different in ITAB and JTAB is COL1 in the last line of the table: 30 in ITAB and 50 in JTAB. Therefore, in the last logical expression, ITAB is less than JTAB.
    reward with points and close the thread if your question is solved
    regards,
    venu.

Maybe you are looking for

  • How to generate a report direct in PDF with oracle developer 6i

    hi all Please help me about this issue. THAT How to generate a report directly in PDF using oracle developer 6i. Regards Yousuf Ahmed Siddiqui

  • Error when creating a transport via a correction in charm

    Hi Folks.. I am getting an error when I attempt to create a transport using a correction from a change document which is created from a service desk message.  I am able to go through the entire process upto creating the transport in the satellite sys

  • How to configure MDB as Durable Subscriber

              I can't seem to find any documentation on how to set up an MDB as a Durable Subscriber.           I tried using the Edit EJB Descriptor link in the console. I then drilled down           to Message Driven Destination. For Subscription Durab

  • Email attachment will not open

    I tap the space beside the attachment (within the email) and the download bar reaches the end.  The next screen states the following: "Empty Slideshow ToGo Project" and the screen is frozen.  The only way to get back to email is to use the Blackberry

  • Function Module to drop index

    Hi all,    Is there any function module which drop index of cube, as that we have a function module to drop the index of ods (SSM_PROCESS_ODS_DROP_INDEXES). Any kind of tips will be appreciated. Thanks in advance. Regards, Babu