INTERNAL TABLE UNIQUE CONTENTS

Hi to all
Plz tell me I want to select unique enteries from an internal table then then counting of that unique entrie.
For example
   ITAB
EBELN              
0026000060
0026000060
0026000060
0026000060
0026000061
0026000061
0026000061
0026000062
0026000062
0026000062
I NEED COUNT = 3.
THANKS

Hi Anubhav Gupta,
<b>Method one</b>
1) copy itab
itab2[] = itab[].
2) sort itab2
SORT itab2[] BY ebeln.
3) delete duplicates
delete adjacent duplicates FROM itab comparing ebeln.
4)get record
describe table itab2[] LINES num. "num will contain 3
<b>Method two</b>
sort itab by ebeln.
LOOP AT itab.
AT new ebeln.
  count = count +1
ENDAT.
ENDLOOP.
rgs

Similar Messages

  • How to Fill Internal Table with contents of Select-Option

    Hi all:
         There is a select-option s_matnr on the self-made screen.   An internal table t_int is declared in the program. The requirement is that users makes selection with multiple  material numbers.  I want to put the values of s_matnr  into internal table  t_int directly. Would you please tell me how?
         Thank you very much in advance.
    Edited by: dongdong guo on Jun 13, 2008 3:40 AM

    Hi,
    Select option works like an internal table only.
    For table selection you can use it directly using IN operator in where clause
    eg : where matnr IN s_matnr.
    Before that you may need to validate the content of the select-option. For that also you need to transfer the content to a new internal table.
    u can loop at the select-option.
    eq: loop at s_matnr.
          if s_matnr-low = 'MAT1'.
            condition.
          endif.
         endloop.
    if you just want to check whether any single valid material number exist in your user screen, then u can use a select single option with s_matnr directly.
      select single matnr from mara
                where matnr in s_matnr.
      select-option s_matnr behaves like an internal table with four fields.
    sign, option, low, high.

  • Std Internal Tables

    Hi, what are Standard Internal Tables and Standard reports, and can I have names of some 'Standard Internal Tables' and  'Standard Reports' plz ?
    Thnx.

    these are some of the standard reports\
    REKH0004
       SAP demo program that shows how to do  2d        3D, and 4D graphics.
    RGUGBR00 
    Substitution/Validation utility
    RHGEN00
         Regen PD and PA inconsistencies
    RHGRENZ0  
       Delimit IT1000 and related 1001s. Program                     will            delete any 1001 infotypes whose start date is after the delimit date.
    RHGRENZ1
    Extend the end date on delimited records. Very useful when you delimit a bunch of records incorrectly, and need to change the end date.
    RHGRENZ2
    Delimit IT1001 only.
    RKCTSEAR
    Search source code for up to two strings. Also see RSRSCAN1 and RPR_ABAP_SOURCE_SCAN.
    RPDTRA00
    List all HR transactions.
    RPR_ABAP_SOURCE_SCAN
    Search ABAP code for a string. Has many more options for selecting the ABAPs to search than RSRSCAN1 or RKCTSEAR.
    RPUAUD00
    HR Report to list all logged changes for an employee. Uses the PCL4 Audit Cluster.
    RPUAUDDL
    HR Report to delete audit data from the PCL4 Audit Cluster.
    RPUDELPN
    Delete all info for an employee number, including cluster data and infotypes
    RPUP1D00/10
    View/Delete data from PCL1 Cluster
    RPUP2D00/10
    View/Delete data from PCL2 Cluster
    RPUP3D00/10
    View/Delete data from PCL3 Cluster
    RPUP4D00/10
    View/Delete data from PCL4 Cluster
    RSABAPIV
    Mass print/display of ABAP/4 help text
    RSAVGL00
    Table adjustment across clients
    RSBDCBTC
    Submit a BDC job with an internal batch number and wait for the end of the batch input session.
    RSBDCDRU
    Prints the contents of a Batch Input session. No options for error transactions only.
    RSBDCOS0
    Execute UNIX commands. Looks similar to the old SAPMSOS0 program that disappeared in 3.0
    RSBDCSUB
    Release batch input sessions automatically
    RSBTCDEL
    Clean the old background job records
    RSSDOCTB
    R/3 Table Manual - prints a list of all fields in the selected tables with the field name and the field documentation.
    RSCLTCOP
    Copy tables across clients
    RSDBCREO
    Clean batch input session log
    RSINCL00
    Extended program list
    RSNASTED
    Process message control output for entries in the NAST table
    RSORAREL
    Get the Oracle Release
    RSPARAM
    Display all instance parameters
    RSPO0041
    Removing old spooling objects
    RSRSCAN1
    Search source code for a given string. Will also search includes. Also see RKCTSEAR and RPR_ABAP_SOURCE_SCAN.
    RSSNAPDL
    Clean the old ABAP error dumps
    RSTBSERV
    Compare a contents of a table between clients
    RSTXFCON
    Converts SAPScript page formats
    RSTXSCRP
    Save a SAPScript layout set to disk, and load it back into SAP.
    RSTXSCRP
    Transport SAPscript files across systems
    RSTXSCRP
    Upload and download SAPScript layout sets
    RSTXTPDF4
    Pass the spool number of a report's output to this program to have the output converted to PDF format.
    RSTXTRAN
    Add standard texts to a transport so they can be moved between systems.
    RSUSR003
    Check the passwords of users SAP* and DDIC in all clients
    RSUSR006
    List users last login
    RSWBO052
    Change development class of a sapscript (provided by Alan Cecchini)
    RSWBO060
    put objects into a request and transport it to any other system
    inernal tables
    INTERNAL TABLES IN ABAP:
    There are two ways of accessing the records in an internal table:
    By copying individual records into a work area. The work area must be compatible with the line type of the internal table.
    You can access the work area in any way, as long as the component you are trying to access is not itself an internal table. If one of the components is an internal table, you must use a further work area, whose line type is compatible with that of the nested table.
    When you change the internal table, the contents of the work area are either written back to the table or added as a new record.
    By assigning the individual data records to an appropriate field symbol. Once the system has read an entry, you can address its components directly via its address. There is no copying to and from the work area. This method is particularly appropriate for accessing large or complex tables.
    If you want to read more than one record, you must use a LOOP... ENDLOOP structure. You can then change or delete the line that has just been read, and the system applies the change to the table body. You can also change or delete lines using a logical condition.
    When you use the above statements with sorted tables, you must ensure that the sort sequence is maintained.
    Within a loop, the INSERT statement adds the data record before the current record in the table. If you want to insert a set of lines from an internal table into another index table, you should use the INSERT LINES OF variant instead.
    When you read single data records, you can use two further additions:
    In the COMPARING addition, the system compares the field contents of a data record with those in the work area for equality.
    In the TRANSPORTING addition, you can restrict the data transport to selected fields.
    Other statements for standard tables
    SORT [ASCENDING|DESCENDING]
    [BY [ASCENDING|DESCENDING] ..
    [ASCENDING|DESCENDING]][AS TEXT] [STABLE].
    These statements sort the table by the table key or the specified field sequence. If you do not use an addition, the system sorts ascending. If you use the AS TEXT addition, character fields are sorted in culture-specific sequence. The relative order of the data records with identical sort keys only remain constant if you use the STABLE addition.
    APPEND INTO SORTED BY .
    This statement appends the work area to the ranked list in descending order. The ranked list may not be longer than the specified INITIAL SIZE, and the work area must satisfy the sort order of the table.
    The statements listed here can be used freely with both standard and sorted tables.
    When you change a single line, you can specify the fields that you want to change using the TRANSPORTING addition. Within a loop, MODIFY changes the current data record.
    If you want to delete a set of lines from an index table, use the variant DELETE FROM... TO.. or WHERE... instead of a loop. You can program almost any logical expression after WHERE.
    The only restriction is that the first field in each comparison must be a component of the line structure (see the corresponding Open SQL statements). You can pass component names dynamically.
    If you want to delete the entire internal table , use the statement CLEAR .
    In the LOOP AT... ENDLOOP structure, the statements within the loop are applied to each data record in turn. The INTO addition copies entries one at a time into the work area.
    The system places the index of the current loop pass in the system field sy-tabix. When the loop has finished, sy-tabix has the same value that it had before the loop started.
    Inserting and deleting lines within a loop affects the following loop passes.
    Access to a hashed table is imple mented using a hash algorithm. Simplified, this means that the data records are distributed randomly but evenly over a particular memory area.. The addresses are stored in a special table called the hashing table .
    There is a hash function, which determines the address at which the pointer to a data record with a certain key can be found. The function is not injective, that is, there can be several data records stored at a single address. This is implemented internally as a chained list. Therefore, although the system still has to search sequentially within these areas, it only has to read a few data records (usually no more than three). The graphic illustrates the simplest case, that is, in which there is only one data record stored at each address.
    Using a hash technique means that the access time no longer depends on the total number of entries in the table. On the contrary, it is always very fast. Hash tables are therefore particularly useful for large tables with which you use predominantly read access.
    Data records are not inserted into the table in a sorted order. As with standard tables, you can sort hashed tables using the SORT statement:
    SORT [ASCENDING|DESCENDING]
    [BY [ASCENDING|DESCENDING] ..
    [ASCENDING|DESCENDING]][AS TEXT].
    Sorting the table can be useful if you later want to use a loop to access the table.
    You can use the statements listed here with tables of all three types. Apart from a few special cases, you can recognize the statements from the extra keyword TABLE. The technical implementation of the statements varies slightly according to the table type.
    As a rule, index access to an internal table is quickest. However, it sometimes makes more sense to access data using key values. A unique key is only possible with sorted and hashed tables. If you use the syntax displayed here, your program coding is independent of the table type (generic type specification, easier maintenance).
    With a standard table, inserting an entry has the same effect as appending. With sorted tables with a non-unique key, the entry is inserted before the first (if any) entry with the same key.
    To read individual data records using the first variant, all fields of that are key fields of must be filled. and can be identical. If you use the WITH TABLE KEY addition in the second variant, you must also specify the key fully. Otherwise, the system searches according to the sequence of fields that you have specified, using a binary search where possible. You can force the system to use a binary search with a standard table using the BINARY SEARCH addition.
    In this case, you must sort the table by the corresponding fields first. The system returns the first entry that meets the selection criteria.
    Similarly to when you read entries, when you change and delete entries using the key and a work area, you must specify all of the key fields.
    You can prevent fields from being transported into the work area during loop processing by using the TRANSPORTING NO FIELDS addition in the WHERE condition. (You can use this to count the number of a particular kind of entry.)
    Other statements for all table types
    DELETE ADJACENT DUPLICATES FROM
    [COMPARING .. | A L L F I E L }|ALL FIELDS}].
    The system deletes all adjacent entries with the same key field contents apart from the first entry. You can prevent the system from only comparing the key field using the COMPARING addition. If you sort the table by the required fields beforehand, you can be sure that only unique entries will remain in the table after the DELETE ADJACENT DUPLICATES statement.
    Searches all lines of the table for the string . If the search is successful, the system sets the fields sy-tabix and sy-fdpos.
    FREE .
    Unlike CLEAR, which only deletes the contents of the table, FREE releases the memory occupied by it as well.
    If you want to access your data using the index and do not need your table to be kept in sorted order or to have a unique key, that is, when the sequence of the entries is the most important thing, not sorting by key or having unique entries, you should use standard tables. (If you decide you need to sort the table or access it using the key or a binary search, you can always program these functions by hand.)
    This example is written to manage a waiting list.
    Typical functions are:
    Adding a single entry,
    Deleting individual entries according to certain criteria,
    Displaying and then deleting the first entry from the list,
    Displaying someone's position in the list.
    For simplicity, the example does not encapsulate the functions in procedures.
    The first thing we do in the example is to declare line and table type, from which we can then declare a work area and our internal table. We also require an elementary field for passing explicit index values.
    This example omits the user dialogs and data transport, assuming that you understand the principles involved. We really only want to concentrate on the table access:
    Adding new entries
    The data record for a waiting customer is only added to the table if it does not already exist in it. If the table had a unique key, you would not have had to have programmed this check yourself.
    Deleting single entries according to various criteria
    The criterion is the key field. However, other criteria would be possible - for example, deleting data records older than a certain insertion date reg_date.
    Displaying and deleting the first entry from the list
    Once a customer comes to the top of the waiting list, you can delete his or her entry. If the waiting list is empty, such an action has no effect. Consequently, you do not have to check whether there are entries in the list before attempting the deletion.
    Displaying the position of a customer in the waiting list
    As above, you do not need to place any data in the work area. We are only interested in the values of sy-subrc and sy-tabix. If the entry is not in the table, sy-tabix is set to zero.
    At this stage, let us return to the special case of the restricted ranked list:
    DATA {TYPE|LIKE} STANDARD TABLE OF ... INITIAL SIZE . ... APPEND INTO SORTED BY .
    When you choose to use a sorted table, it will normally be because you want to define a unique key.
    The mere fact that the table is kept in sorted order is not that significant, since you can sort any kind of internal table. However, with sorted tables (unlike hashed tables), new data records are inserted in the correct sort order. If you have a table with few entries but lots of accesses that change the contents, a sorted table may be more efficient than a hashed table in terms of runtime.
    The aim of the example here is to modify the contents of a database table. The most efficient way of doing this is to create a local copy of the table in the program, make the changes to the copy, and then write all of its data back to the database table. When you are dealing with large amounts of data, this method both saves runtime and reduces the load on the database server. Since the internal table represents a database table in this case, you should ensure that its records have unique keys.
    This is assured by the key definition. Automatic sorting can also bring further advantages.
    When you change a group of data records, only the fields price and currency are copied from the work area.
    This means that, with larger tables, the access time is reduced significantly in comparison with a binary search. In a loop, however, the hashed table has to search the entire table (full table scan). Since the table entries are stored unsorted, it would be better to use a sorted table if you needed to run a loop through a left-justified portion of the key.
    It can also be worth using a hashed table but sorting it. A typical use for hashed tables is to buffer detailed information that you need repeatedly and can identify using a unique key. You should bear in mind that you can also set up table buffering for a table in the ABAP Dictionary to cover exactly the same case. However, whether the tables are buffered on the application table depends on the size of the database table.
    Buffering in the program using hashed tables also allows you to restrict the dataset according to your own needs, or to buffer additional data as required.
    In this example, we want to allow the user to enter the name of a city, and the system to display its geographical coordinates.
    First, we fill our "buffer table" city_list with values from the database table sgeocity. Then, we read an entry from the hashed table, specifying the full key.
    The details are displayed as a simple list. At this point, it is worth repeating that you should only use this buffering technique if you want to keep large amounts of data locally in the program. You must ensure that you design your hashed table so that it is possible to specify the full key when you access it from your program.
    You can define internal tables either with (WITH HEADER LINE addition) or without header lines. An internal table with header line consists of a work area (header line) and the actual table body. You address both objects using the same name. The way in which the system interprets the name depends on the context. For example, the MOVE statement applies to the header line, but the SEARCH statement applies to the body of the table.
    To avoid confusion, you are recommended to use internal tables without header lines. This is particularly important when you use nested tables. However, internal tables with header line do offer a shorter syntax in several statements (APPEND, INSERT, MODIFY, COLLECT, DELETE, READ, LOOP).
    hope this is helpful
    do reward

  • A global internal table - retaing values of internal table

    Hi,
    I needed some help in the creation of a internal table whose content don't change in the recursive call to the method.
    I call a method  M1 which returns me an standard internal table (i1) as an import parameter and has two export parameters ( exp_p1,exp_p2).
    I call this method(m1) recursively in the method m1 itself. I find that when i call this mehtod m1 , second time the data that was there in the internal table M1 on first call of the method is cleared out.
    what shoudl i do , so that i can to reatin the the value of the internal table.
    Like for example , i have one record in the internal table in the first call to the method M1 and before the second call of method is made.
    Once the call to method M1 is made ( meaning to say a second call is made) ,the internal table contains zero records.
    while creating the internal table i use a the append keyword to add rows in the method.
    In Programming language 'C', for recursion function , if any variable is made as static, that variable retains it value during successive calls to the function.I am looking for something similar to it.
    Regards,
    Om

    Use a static class. 
    report zrich_0002.
    *       CLASS lcl_app DEFINITION
    class lcl_app definition.
      public section.
        <b>class-data:</b> it001 type table of t001.
        <b>class-data:</b> xt001 type t001.
        <b>class-methods:</b> get_data,
                       write_data.
    endclass.
    start-of-selection.
      call method lcl_app=>get_data.
      do 2 times.
        call method lcl_app=>write_data.
        skip 1.
      enddo.
    *       CLASS lcl_app IMPLEMENTATION
    class lcl_app implementation.
      method get_data.
        select * into table it001 from t001.
      endmethod.
      method write_data.
        loop at it001 into xt001.
          write:/ xt001-bukrs, xt001-butxt.
        endloop..
      endmethod.
    endclass.
    REgards,
    Rich Heilman

  • How to select set of unique data records from internal table

    Hi
    I am looking for a command in order to select all unique data-records from an internal table without using a loop. Does anybody know a command that could do this?
    <b><u>An illustrating example:</u></b>
    <i>Example:
    Table content
    a 1
    a 2
    a 3
    b 1
    b 2
    c 1
    c 2
    c 3
    d 1</i>
    So I am looking for a command that should provide a, b, c & d for the first column or 1, 2 & 3 for the second column<b></b>

    Hi,
    SELECT DISTINCT  MATNR
                    FROM MARA
                   into table i_mara.
    Best regards,
    Prashant

  • Why "Modify itab index sy-tabix." makes internal table content blank?

    We have an internal table itab which looks like to have the following content:
    A---B---C
    1----3----
    2----2----
    We would like to get the column C value in this internal table itab by summing Column A and Column B, and then fill C column values into this internal table. We know that the program would looks like:
    Loop at itab into wa_itab.
        wa_itab-C = wa_itab-A + wa_itab-B.
        Modify itab index sy-tabix.
    EndLoop.
    But after executing the above code, all itab becomes blank. Through debugging, find it's caused by the statement "Modify itab index sy-tabix.".  Could any ABAP expert here let us know the reason and we will give you reward points!

    hi,
    what you tried is correct.but instead of using
    modify itab index sy-tabix
    use
    modify itab index sy-tabix from wa_itab.
    the reason for blank data is you are not mentioning from where that record is to be updated.your specifying the record using index.one thing is no need to use index also because in a loop you are modifying so automatically it will take you to the record.
    try the following code.
    types:begin of it,
         a type i,
         b type i,
         c type i,
         end of it.
    data:itab type standard table of it.
    data:wa_itab type it.
    wa_itab-a = 3. wa_itab-b = 4.
    append wa_itab to itab.
    Loop at itab into wa_itab.
        wa_itab-C = wa_itab-A + wa_itab-B.
    Modify itab index sy-tabix from wa_itab.
    *you can use Modify itab from wa_itab.
    EndLoop.
    loop at itab into wa_itab.
    write:wa_itab-a,wa_itab-b,wa_itab-c.
    endloop.
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Apr 8, 2008 5:49 PM

  • Displaying the contents of internal table- in email Step of workflows

    Hello Folks,
    I wanted to display the contents of an internal table ( would contain a list of opportunites ), in an email sent throught the workflow:
    My idea was to LOOP AT <ITAB> into <WA> from an external program and then call the workflow for each content of the <WA>. This will be a problem as, if there are like 1000 records in the internal table, then workflows will be called 1000 times...sending 1000 emails..
    My requirement is that we need to send a single email to the single person, displaying the content of the internal table in the email body......
    My question
    1) Is this scenario possible through worflows ?
    2) If not, please provide an alternative ..
    Thanks
    Anand

    Do you mean to say that just by inserting the multiline element
    within the body of the 'Send email' step type, the contents
    of the multiline element is displayed automatically without
    we having to loop at it somehow ?
    Follow the below apporach,
    1. First create a multiline container element in the workflow conatiner.
    2. Populate the internla table , by using the bor methods and pass back the populated ITAB to the WF by using the binding concept.
    3. Now create a mail step in the workflow, you have the option of inserting the workflow container elements into the mail conten, so insert the multiline container element , then it prompts to select the option like a) Do you liek to display only first line b) Display the ITAB line by line c) Display ITAB lines continuously with out line break.
    4. based upon the requirement select any one of the options.
    Note: Make sure the line length of the ITAB won't excced 132 charecters, because the send mail step will consider only 132 characters.

  • Getting unique values from internal table

    Hi Gurus,
    From time to time I hit this problem and so far I havn't found any nice solution. I've an internal table with several fields. I would like to get all unique values for one (or several) of these fields. However let say that this table has a lot of entries so making a copy is not an option. Also changing this table in any way is forbiden.
    For example for table below I would like to get all unique values for field Number. In this case it would be 1,2,3,4.
    Name  | Number |
    name1 | 1|
    name2 | 2|
    name3 | 2|
    name4 | 3|
    name5 | 4|
    name5 | 3|
    Can anyone propose me better solution than going in the loop through all entries in table? Maybe there is some ABAP functionality that I don't know about?
    BR
    Marcin Cholewczuk

    Let's say that if I sort this table I won't be able to restore it to previous order which is important for me
    True...If you sort the table you won't be able to restore. So the only option is to copy/move all the records into another table.
    Sorting If you need to retrive unique values. I don't think without sorting the table would be a nice idea and proper programming to proceed ahead.
    Regarding logic, as replied earlier
    Either we can go with DELETE ADJACENT DUPLICATES or proceed as replied in my earlier post. There might be number of algorithms to resolve this. But we cannot go ahead without sorting or looping.

  • Transfer of Internal table contents to ftp server

    Hi,
    I have data in one internal table, which needs to transferred to file on ftp server,
    please tell me how to create file on ftp server, how should i transfer contents of this internal table to file on ftp server.
    please help me.

    Hi,
    Please refer following code, which create a log file in Ftp server,
    Step 1 Connect to Ftp server.
    SET EXTENDED CHECK OFF.
        g_slen = STRLEN( p_pwd ).
      CALL FUNCTION 'HTTP_SCRAMBLE'
        EXPORTING
          SOURCE      = p_pwd
          sourcelen   = g_slen
          key         = g_key
        IMPORTING
          destination = p_pwd.
      CALL FUNCTION 'FTP_CONNECT'
        EXPORTING
          user            = p_user        <----- Pass User ID
          password        = p_pwd  <---- Pass Password
          host            = p_host        <---- Pass IP Address
          rfc_destination = p_dest  <----- RFC destination SAPFTP
        IMPORTING
          handle          = g_hdl
        EXCEPTIONS
          not_connected   = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
        sy-msgty = 'E'.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    *   MESSAGE SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4 TYPE 'I'.
      ENDIF.
    Step 2  Reading file from FTP
    CALL FUNCTION 'FTP_SERVER_TO_R3'
      EXPORTING
        handle               = g_hdl
        fname                = p_fname   <---- File path
    *   CHARACTER_MODE       =
    IMPORTING
       BLOB_LENGTH          = l_xml_table_size
    TABLES
       BLOB                 = l_xml_table
    *   TEXT                 =
    EXCEPTIONS
       TCPIP_ERROR          = 1
       COMMAND_ERROR        = 2
       DATA_ERROR           = 3
       OTHERS               = 4
    Step 3 Write a file
    g_docid = l_filename.
    * **Transferring the data from internal table to FTP Server.
      DESCRIBE TABLE gt_log LINES l_count.
      g_slen = l_count * 275.
    CALL FUNCTION 'FTP_R3_TO_SERVER'
      EXPORTING
        handle               = g_hdl
        fname                = g_docid     <---File name
       BLOB_LENGTH          = g_slen   <---- Length
       CHARACTER_MODE       = 'X'
    TABLES
    *   BLOB                 =
       TEXT                 = gt_log
    EXCEPTIONS
       TCPIP_ERROR          = 1
       COMMAND_ERROR        = 2
       DATA_ERROR           = 3
       OTHERS               = 4

  • Download content of internal table to local file

    Hello SDN
    I have got a BSP application using pages with flow logic. What I want to do is downloading the content of an internal table to a local file, when a user triggers a certain event. In the event-handler "OnInputProcessing" I tried to use "CALL METHOD cl_gui_frontend_services=>gui_download" but this causes an error in the browser.
    Can anybody help me?
    Regards
    Markus
    Message was edited by: Markus Tschiderer

    hello markus,
    cl_gui_frontend_services can only be used in sapgui-applications.
    what you could do is to create a bsp-page that doesn't generate html, but only a list of data, separated by tabs and line-breaks. on the top of the bsp, you would have to set the mime-type to text/plain, so the browser will offer so save the file or open it in notepad.
    regards,
    norbert

  • The contents in a internal table

    Hi Experts,
    I have a doubt in filling the contents of an internal table with the database table fields reference.
    For eg: There is an internal table like this:
    data: begin of t_conditions occurs 0,
                 kschl like rv13a-kschl,
                 vkorg like komg-vkorg,
                 kunnr like komg-kunnr,
                 matnr like komg-matnr,
                 kbetr(15) type c,
                 datab(10) type c,
                 datbi(10) type c,
          end of t_conditions.
    in the above example, the "matnr" he has taken with the reference field "komg-matnr"..
    Please look at the following internal table:
    data: begin of t_material occurs 0,
                    matnr(18) type c,
                    matkl(9)  type c,
                    bismt(18) type c,
          end of t_material.
    In the above 2 examples the declaration of "matnr" field is diffrent from one with the other.
    in 1st eg., he has taken as: <b>matnr like komg-matnr</b>
    where as in the 2nd eg: <b>matnr(18) type c,</b>
    my question is: how can i know where to declare as in the 1st eg., and where to use like in the 2nd eg.,
    Please clarify.
    I greatly appreciate your help.
    Thanks,

    Hi sey
    If you see in the domain level both the DOMIAN's will be the same. So it doesn't matter. All the matnr will have a character type of size 18.
    for the programmer reference they will using the table name in which they want to select the data.
    i.e for the first ex. he will be selecting data from the KOMG table and in the second from the MARA table.
    but both the Matnr type are same.
    <b>there is a small change since the second ex doesn't use any table it is simply of type c. the difference is when you reference to any Data DICTIONARY object then it can contain certain conversion exits, etc. so it will apply for your reference data typr</b>
    regards
    kishore
    Message was edited by: Harikishore Sreenivasulu

  • Problem in displaying internal table contents to excel(color)

    Hello Gurus!!!!!
    The code is given below :-
    *& Module pool       ZDEMO_DOWNLD1
    PROGRAM  ZDEMO_DOWNLD1.
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
    DATA : f_name(120) type c,
           f_name1(120) type c.
    case sy-ucomm.
    when 'ATTACH'.
    CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
       DEF_FILENAME           = ' '
      DEF_PATH               = ' '
      MASK                   = ' '
      MODE                   = ' '
      TITLE                  = ' '
    IMPORTING
       FILENAME               = f_name
      RC                     =
    EXCEPTIONS
      INV_WINSYS             = 1
      NO_BATCH               = 2
      SELECTION_CANCEL       = 3
      SELECTION_ERROR        = 4
      OTHERS                 = 5
    *f_name = DEF_FILENAME.
    f_name1 = f_name.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    endcase.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
    SET PF-STATUS 'xxxxxxxx'.
    SET TITLEBAR 'xxx'.
    type-pools ole2.
    data: h_excel type ole2_object, " Excel object
    h_mapl type ole2_object, " list of workbooks
    h_map type ole2_object, " workbook
    h_zl type ole2_object, " cell
    h_f type ole2_object, " font
    h_interior type ole2_object. " Color
    *tables: spfli.
    DATA: ls_emp TYPE zpm_emp_det,
           lt_emp TYPE zpm_emp_det OCCURS 0,
           l_projectname TYPE zpm_emp_item_det-project_name,
           l_projectname_last TYPE zpm_emp_item_det-project_name,
           l_empid TYPE zpm_emp_item_det-empid,
           l_empid_last TYPE zpm_emp_item_det-empid.
    DATA: l_projectname_key TYPE lvc_nkey,
          l_role_of_emp_key TYPE lvc_nkey,
          l_last_key TYPE lvc_nkey.
    DATA :  lt_project_main TYPE TABLE OF zsach_pm ,
            ls_project_main TYPE zsach_pm,
            lt_project TYPE zsach_pm OCCURS 0,
            ls_project TYPE zsach_pm.
    internal table for excel headings
    DATA : BEGIN OF lt_project_ex OCCURS 0,
             line(50) TYPE c,
           END OF lt_project_ex.
    DATA: lt_project1 TYPE zsach_pm OCCURS 0,
          ls_project1 TYPE zsach_pm.
    DATA :   lt_project_temp TYPE zsach_pm OCCURS 0 ,
             ls_project_temp TYPE zsach_pm.
    DATA: lt_project2 TYPE zsach_pm OCCURS 0,
          ls_project2 TYPE zsach_pm.
    TYPES: BEGIN OF st_username,
           username TYPE zuser_names-username,
           END OF st_username.
    DATA: it_tab TYPE TABLE OF st_username,
          wa_tab TYPE st_username.
    data : lt_project_excel like zsach_pm occurs 0 with header line.
    *DATA: f_name TYPE string.
    data h type i.
    table of flights
    data: it_spfli like spfli occurs 10 with header line.
    *& Event START-OF-SELECTION
        SELECT empid
               project_name
               role_of_emp
               competancy
               manager
               price_category
               rate_per_hour
               first_day_pro
               last_day_pro
               ckey
         FROM zpm_emp_item_det
         INTO CORRESPONDING FIELDS OF TABLE lt_project.
        LOOP AT lt_project INTO ls_project.
        ENDLOOP.
        SELECT projectid project_name client begin_date end_date
          FROM zpm_project_det
          INTO CORRESPONDING FIELDS OF TABLE lt_project_temp FOR ALL ENTRIES IN lt_project
          WHERE project_name = lt_project-project_name.
        LOOP AT lt_project_temp INTO ls_project_temp.
          MODIFY lt_project FROM ls_project_temp TRANSPORTING
            projectid project_name client begin_date end_date
            WHERE project_name = ls_project_temp-project_name.
        ENDLOOP.
        SELECT empid
               employee_name
               designation
               employee_type
               date_of_joining
        FROM zpm_emp_head_det
        INTO CORRESPONDING FIELDS OF TABLE lt_project1 FOR ALL ENTRIES IN lt_project
        WHERE empid = lt_project-empid.
        LOOP AT lt_project1 INTO ls_project1.
          MODIFY lt_project FROM ls_project1 TRANSPORTING
                empid
                employee_name
                designation
                employee_type
                date_of_joining
             WHERE empid = ls_project1-empid.
        ENDLOOP.
    tell user what is going on
    call function 'SAPGUI_PROGRESS_INDICATOR'
    exporting
    PERCENTAGE = 0
    text = text-007
    exceptions
    others = 1.
    start Excel
    create object h_excel 'EXCEL.APPLICATION'.
    perform err_hdl.
    set property of h_excel 'Visible' = 1.
    perform err_hdl.
    tell user what is going on
    call function 'SAPGUI_PROGRESS_INDICATOR'
    exporting
    PERCENTAGE = 0
    text = text-008
    exceptions
    others = 1.
    get list of workbooks, initially empty
    call method of h_excel 'Workbooks' = h_mapl.
    perform err_hdl.
    add a new workbook
    call method of h_mapl 'Add' = h_map.
    perform err_hdl.
    tell user what is going on
    call function 'SAPGUI_PROGRESS_INDICATOR'
    exporting
    PERCENTAGE = 0
    text = text-009
    exceptions
    others = 1.
    output column headings to active Excel sheet
    perform fill_cell using 1 1 1 'Project ID'(001).
    perform fill_cell using 1 2 1 'Emp ID'(002).
    perform fill_cell using 1 3 1 'Project Name'(003).
    perform fill_cell using 1 4 1 'Client'(004).
    perform fill_cell using 1 5 1 'Begin Date'(005).
    perform fill_cell using 1 6 1 'End Date'(006).
    perform fill_cell using 1 7 1 'Role of Employee'(007).
    perform fill_cell using 1 8 1 'Module / Competancy'(008).
    perform fill_cell using 1 9 1 'Employee name'(009).
    perform fill_cell using 1 10 1 'Price Category'(010).
    perform fill_cell using 1 11 1 'Rate P/H'(011).
    perform fill_cell using 1 12 1 '1st day in project'(012).
    perform fill_cell using 1 13 1 'Last day in project'(013).
    perform fill_cell using 1 14 1 'Currency'(014).
    perform fill_cell using 1 15 1 'Manager'(015).
    perform fill_cell using 1 16 1 'Emp Type'(016).
    perform fill_cell using 1 17 1 'Designation'(017).
    perform fill_cell using 1 18 1 'Joining Date'(018).
    perform fill_cell using 1 19 1 'Last Date'(019).
    loop at lt_project into ls_project.
    *lt_project_excel[] = lt_project[].
    endloop.
    copy flights to active EXCEL sheet
    h = sy-tabix + 1.
    *perform fill_cell1 using h 1 0 ls_project-PROJECTID.
    *perform fill_cell1 using h 2 0 ls_project-EMPID.
    *perform fill_cell1 using h 3 0 ls_project-PROJECT_NAME.
    *perform fill_cell1 using h 4 0 ls_project-client.
    *perform fill_cell1 using h 5 0 ls_project-BEGIN_DATE.
    *perform fill_cell1 using h 6 0 ls_project-END_DATE.
    *perform fill_cell1 using h 7 0 ls_project-ROLE_OF_EMP.
    *perform fill_cell1 using h 8 0 ls_project-COMPETANCY.
    *perform fill_cell1 using h 9 0 ls_project-EMPLOYEE_NAME.
    *perform fill_cell1 using h 10 0 ls_project-PRICE_CATEGORY.
    *perform fill_cell1 using h 11 0 ls_project-RATE_PER_HOUR.
    *perform fill_cell1 using h 12 0 ls_project-FIRST_DAY_PRO.
    *perform fill_cell1 using h 13 0 ls_project-LAST_DAY_PRO.
    *perform fill_cell1 using h 14 0 ls_project-CKEY.
    *perform fill_cell1 using h 15 0 ls_project-MANAGER.
    *perform fill_cell1 using h 16 0 ls_project-EMPLOYEE_TYPE.
    *perform fill_cell1 using h 17 0 ls_project-DESIGNATION.
    *perform fill_cell1 using h 18 0 ls_project-DATE_OF_JOINING.
    *perform fill_cell1 using h 19 0 ls_project-LAST_WORKING_DAT.
    perform fill_cell1 using h 1 0 lt_project_excel-PROJECTID.
    perform fill_cell1 using h 2 0 lt_project_excel-EMPID.
    perform fill_cell1 using h 3 0 lt_project_excel-PROJECT_NAME.
    perform fill_cell1 using h 4 0 lt_project_excel-client.
    perform fill_cell1 using h 5 0 lt_project_excel-BEGIN_DATE.
    perform fill_cell1 using h 6 0 lt_project_excel-END_DATE.
    perform fill_cell1 using h 7 0 lt_project_excel-ROLE_OF_EMP.
    perform fill_cell1 using h 8 0 lt_project_excel-COMPETANCY.
    perform fill_cell1 using h 9 0 lt_project_excel-EMPLOYEE_NAME.
    perform fill_cell1 using h 10 0 lt_project_excel-PRICE_CATEGORY.
    perform fill_cell1 using h 11 0 lt_project_excel-RATE_PER_HOUR.
    perform fill_cell1 using h 12 0 lt_project_excel-FIRST_DAY_PRO.
    perform fill_cell1 using h 13 0 lt_project_excel-LAST_DAY_PRO.
    perform fill_cell1 using h 14 0 lt_project_excel-CKEY.
    perform fill_cell1 using h 15 0 lt_project_excel-MANAGER.
    perform fill_cell1 using h 16 0 lt_project_excel-EMPLOYEE_TYPE.
    perform fill_cell1 using h 17 0 lt_project_excel-DESIGNATION.
    perform fill_cell1 using h 18 0 lt_project_excel-DATE_OF_JOINING.
    perform fill_cell1 using h 19 0 lt_project_excel-LAST_WORKING_DAT.
    *endloop.
    disconnect from Excel
    *CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
    EXPORTING
       DOCUMENT_DATA                    =
      PUT_IN_OUTBOX                    = ' '
      SENDER_ADDRESS                   = SY-UNAME
      SENDER_ADDRESS_TYPE              = 'B'
      COMMIT_WORK                      = ' '
    IMPORTING
      SENT_TO_ALL                      =
      NEW_OBJECT_ID                    =
      SENDER_ID                        =
    TABLES
       PACKING_LIST                     =
      OBJECT_HEADER                    =
      CONTENTS_BIN                     =
      CONTENTS_TXT                     =
      CONTENTS_HEX                     =
      OBJECT_PARA                      =
      OBJECT_PARB                      =
       RECEIVERS                        =
    EXCEPTIONS
      TOO_MANY_RECEIVERS               = 1
      DOCUMENT_NOT_SENT                = 2
      DOCUMENT_TYPE_NOT_EXIST          = 3
      OPERATION_NO_AUTHORIZATION       = 4
      PARAMETER_ERROR                  = 5
      X_ERROR                          = 6
      ENQUEUE_ERROR                    = 7
      OTHERS                           = 8
    *IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    free object h_excel.
    perform err_hdl.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    FORM FILL_CELL *
    sets cell at coordinates i,j to value val boldtype bold *
    form fill_cell using i j bold val.
    call method of h_excel 'Cells' = h_zl exporting #1 = i #2 = j.
    perform err_hdl.
    set property of h_zl 'Value' = val .
    perform err_hdl.
    get property of h_zl 'Font' = h_f.
    perform err_hdl.
    set property of h_f 'Bold' = bold .
    perform err_hdl.
    SET PROPERTY OF h_f 'ColorIndex' = 11 .
    perform err_hdl.
    endform.
    *& Form fill_cell1
    text
    -->P_H text
    -->P_1 text
    -->P_0 text
    -->P_IT_SPFLI_CARRID text
    form fill_cell1 using i j bold val.
    call method of h_excel 'Cells' = h_zl exporting #1 = i #2 = j.
    perform err_hdl.
    set property of h_zl 'Value' = val .
    perform err_hdl.
    get property of h_zl 'Font' = h_f.
    perform err_hdl.
    set property of h_f 'Bold' = bold .
    perform err_hdl.
    SET PROPERTY OF h_f 'ColorIndex' = 14 .
    perform err_hdl.
    endform. " fill_cell1
    *& Form ERR_HDL
    outputs OLE error if any *
    --> p1 text
    <-- p2 text
    form err_hdl.
    if sy-subrc <> 0.
    write: / 'Error in OLE-Automation:'(010), sy-subrc.
    stop.
    endif.
    endform. " ERR_HDL
    Entire excel file is displayed ,but the problem is I want to display the excel file in one shot i.e not <b>line by line</b>
    Kindly suggest if there is any keyword or FM to display the contents in excel using internal table.
    It should not take much time. Just by executing code , the contents of internal table should be displayed.
    Helpful answers will be rewarded
    Thanks,
    Sachin

    Hi Kavitha,
    maybe it's not sophisticated enough for your requirement, but I found function XXL_FULL_API easy to use. This will give same functionality as 'download' button in ALV-Grid display.
    Regards,
    Christian

  • How to pass the contents of an internal table to the IDoc FIDCC2?

    Hi,
    I have an internal table. Using its contents, I have to create an Idoc and do GL posting.
    I have to use FIDCC2 Idoc and the function module IDOC_INPUT_FIDCC2.
    Can u please let me know how to pass the contents of the internal table into the idoc FIDCC2 and do the GL posting?
    Regards,
    Balaji. R

    Hi balaji,
    use function IDOC_INBOUND_FROM_FILE. This will do half the process.
    Documentation is missing, but program RSEINB00 explains something,
    also some links
    [http://help.sap.com/saphelp_nw70/helpdata/EN/dc/6b7f1543d711d1893e0000e8323c4f/frameset.htm]
    [RSEINB00 does not work in background]
    [RSEINB00 flat file to idoc uploading in XI]
    [Loading flat idoc via report RSEINB00 into integration server fails]
    Hope it helps.
    Regards,
    Clemens

  • Update the database table with the content of the internal table

    Hello!
      I have the next form:
      FORM erase_data.
    SELECT * FROM zadrress INTO CORRESPONDING FIELDS OF TABLE itab_adrress.
      DELETE TABLE itab_adrress: FROM zadrress,
                                 WITH TABLE KEY adrid = '456'.
      WRITE 'The information after the DELETE operation'
      COLOR 2.
      LOOP AT itab_adrress INTO wa_adrress .
        WRITE:/
               wa_adrress-adrid COLOR 5,
               wa_adrress-name COLOR 7,
               wa_adrress-email COLOR 5,
               wa_adrress-depart COLOR 7,
               wa_adrress-display COLOR 5.
      ENDLOOP.
      SKIP.
    LOOP AT itab_adrress INTO wa_adrress.
       MODIFY zadrress FROM wa_adrress.
       COMMIT WORK.
       IF sy-subrc = 0.
         WRITE 'OK !'.
         SKIP.
       ELSE.
         WRITE 'FAIL !'.
         SKIP.
       ENDIF.
    ENDLOOP.
      MODIFY zadrress FROM TABLE itab_adrress.
      UPDATE zadrress FROM TABLE itab_adrress.
    TRANSPORTING adrid, name, email, depart, display.
    INSERT zadrress FROM TABLE itab_adrress ACCEPTING DUPLICATE KEYS.
    PERFORM display_data .
    ENDFORM.                    "erase_data
    I see that my record is deleted  when I display the records from my internal table, but
    now I want to delete the record from database table.
       For that I want to move the content of the modified internal table in the database table. You can see the methods I tried (some of them commented), but nothing seems to work.
    Any advice ?
    Thank you.

    FORM erase_data.
    SELECT * FROM zadrress INTO CORRESPONDING FIELDS OF TABLE itab_adrress.
    DELETE TABLE itab_adrress: FROM zadrress,
    WITH TABLE KEY adrid = '456'.
    WRITE 'The information after the DELETE operation'
    COLOR 2.
    LOOP AT itab_adrress INTO wa_adrress .
    WRITE:/
    wa_adrress-adrid COLOR 5,
    wa_adrress-name COLOR 7,
    wa_adrress-email COLOR 5,
    wa_adrress-depart COLOR 7,
    wa_adrress-display COLOR 5.
    ENDLOOP.
    SKIP.
    LOOP AT itab_adrress INTO wa_adrress.
    MODIFY zadrress FROM wa_adrress.
    COMMIT WORK.
    IF sy-subrc = 0.
    WRITE 'OK !'.
    SKIP.
    ELSE.
    WRITE 'FAIL !'.
    SKIP.
    ENDIF.
    ENDLOOP.
    <b>DELETE FROM zadrress.</b>  "Make this change and try
    MODIFY zadrress FROM TABLE itab_adrress.
    UPDATE zadrress FROM TABLE itab_adrress.
    TRANSPORTING adrid, name, email, depart, display.
    INSERT zadrress FROM TABLE itab_adrress ACCEPTING DUPLICATE KEYS.
    PERFORM display_data .
    ENDFORM. "erase_data'.

  • UNIQUE Problem in pulling DATA from DATA base table to internal table

    Dear Experts,
    I am new to ABAP. I have a very basic question but looks a quite puzzling one to me. Hemnce I am posting it here.
    I am facing an unique problem in pulling data from database table and populating that data into internal table for further use.
    The data in the database table "Zlt_mita" with fields M1 (Employee Name, Type: Char20) and M2 (Employee Code, Type Char7) are:
    Plz refer the screenshot in the attached file:
    My Code:
    1) When I try to pull data from Dbase table by taking M2 as parameter.
         This code is succcessful and I am able to populate data in internal table it_dat.
    TYPES: Begin Of ty_DAT,
                     M1   TYPE  Zlt_mita-M1,
                     M2   TYPE  ZLT_mita-M2,
                 END  OF  ty_DAT.
    DATA: it_dat        TYPE STANDARD TABLE OF ty_dat with header line,
              wa_dat      TYPE   ty_dat.
    PARAMETERS: p_mitar    TYPE  Zlt_Mita-M2.
    SELECT           M1
                           M2
            FROM     ZLt_mita
            INTO       TABLE it_dat
            Where     M2 = p_mitar.
    Loop at it_dat into wa_dat.
       WRITE:/2 wa_dat-M1,
                  10 wa_dat-M2.
    ENDLOOP.
    2) When I try to pull data from Dbase table by taking M1 as parameter.
         This code is NOT succcessful and I am NOT able to populate data in internal table it_dat.
    TYPES: Begin Of ty_DAT,
                     M1   TYPE  Zlt_mita-M1,
                     M2   TYPE  ZLT_mita-M2,
                 END  OF  ty_DAT.
    DATA: it_dat        TYPE STANDARD TABLE OF ty_dat with header line,
               wa_dat      TYPE   ty_dat.
    PARAMETERS:    P_Mita    TYPE   ZLT_Mita-M1.
    SELECT           M1
                           M2
            FROM     ZLt_mita
            INTO       TABLE it_dat
            Where     M1 = P_Mita.
    Loop at it_dat into wa_dat.
       WRITE:/2 wa_dat-M1,
                 10 wa_dat-M2.
    ENDLOOP.
    Why is this happening when both M1 and M2 are Type Character fields.
    Looking forward for your replies.
    Regards
    Chandan Kumar

    Hi Chandan ,
    Database fetch is case sensitive ,So u need to give exact format in where condition.
    Make your parameter and database in same case so that you need not worry about case sensitivity .
    Check the lowecase check box in the domain .
    Then declare your parameter 
    PARAMETERS:
    P_Mita
    TYPE   ZLT_Mita-M1 LOWER CASE . 
    You can do the vice versa also by unchecking lowercase and giving Upper case instead of lower in parameter declartion .
    Regards ,
    Juneed Manha

Maybe you are looking for

  • How to connecttwo external 19" LCD panels over DVI to MBP

    Hi, Is it possible to connect two 19" LCD panels over DVI to a MBP and run them as a single extended desktop? I've not been able to find an answer in the many posting and I get the impression its possible, but I'm not sure. I get more doubtful when I

  • Some thoughts on the dearth of training materials for the new MCSE certifications

    Mostly this is venting... while it would be nice to see some remediation, I have no such expectations. Given that Windows Server 2012 was GA 15 months ago, I'm severely disappointed at the lack of published training guides targeted to the MCSA and MC

  • Hide Excel Chart Legend Using LabVIEW Report Generation Toolkit or Active

    Hello Eveyone: I work on the report generation toolkit in labview and creat the report in excle. I create the chart into report but I can't hide the chart legend or change the font size using report generation toolkit. I appriciate you guys time. Tha

  • Dual Graphics cards 7300 & 8800 in 1st gen

    Does it work to have both video cards in my mac pro. so i can dual boot. the newly released 8800 gt only works w/ leopard. so i plan to install leopard on a seperate drive. and then just use the original 7300 card for tiger? anyone know?

  • Ilife serial number

    I've entered every number I found on the box and keep getting an error message. My iweb is not downloading my new pages to my folder. In fact, it reverted to the old version of my web site when I viewed the published folder. It's been screwry ever si