Regarding COLLECT stmt usage in an ABAP Program.

Hi All,
Could anyone please explain if the COLLECT statement really hampers the performance of the program, to a large extent.
If it is so, please explain how the performance can be improved with out using the same.
Thanks & Regards,
Goutham.

COLLECT allows you to create unique or summarized datasets. The system first tries to find a table entry corresponding to the table key. (See also Defining Keys for Internal Tables). The key values are taken either from the header line of the internal table itab, or from the explicitly-specified work area wa. The line type of itab must be flat - that is, it cannot itself contain any internal tables. All the components that do not belong to the key must be numeric types ( ABAP Numeric Types).
Notes
COLLECT allows you to create a unique or summarized dataset, and you should only use it when this is necessary. If neither of these characteristics are required, or where the nature of the table in the application means that it is impossible for duplicate entries to occur, you should use INSERT [wa INTO] TABLE itab instead of COLLECT. If you do need the table to be unique or summarized, COLLECT is the most efficient way to achieve it.
If you use COLLECT with a work area, the work area must be compatible with the line type of the internal table.
If you edit a standard table using COLLECT, you should only use the COLLECT or MODIFY ... TRANSPORTING f1 f2 ... statements (where none of f1, f2, ... may be in the key). Only then can you be sure that:
-The internal table actually is unique or summarized
-COLLECT runs efficiently. The check whether the dataset
already contains an entry with the same key has a constant
search time (hash procedure).
If you use any other table modification statements, the check for entries in the dataset with the same key can only run using a linear search (and will accordingly take longer). You can use the function module ABL_TABLE_HASH_STATE to test whether the COLLECT has a constant or linear search time for a given standard table.
Example
Summarized sales figures by company:
TYPES: BEGIN OF COMPANY,
        NAME(20) TYPE C,
        SALES    TYPE I,
      END OF COMPANY.
DATA: COMP    TYPE COMPANY,
      COMPTAB TYPE HASHED TABLE OF COMPANY
                                WITH UNIQUE KEY NAME.
COMP-NAME = 'Duck'.  COMP-SALES = 10. COLLECT COMP INTO COMPTAB.
COMP-NAME = 'Tiger'. COMP-SALES = 20. COLLECT COMP INTO COMPTAB.
COMP-NAME = 'Duck'.  COMP-SALES = 30. COLLECT COMP INTO COMPTAB.
Table COMPTAB now has the following contents:
          NAME    | SALES
          Duck    |   40
          Tiger   |   20

Similar Messages

  • Key/Text table - usage in an ABAP program

    Hi Abapers!
    I need help about usage of key and text tables.
    I have created key and text table and now i want to use them in the abap program. My problem is, that i don't know how to properly read data into internal table from these two tables, so i can show these data in the table control. I also want to know how to save data from text boxes into key and text table (text boxes: txtid, txtlang, txttext).
    Key Table:
    name: ztbl1
    fields: mandt, id
    key fields: mandt, id
    Text table:
    name: ztbl2
    fields: mandt, lang, id, text
    key fields: mandt, lang, id
    Tables are connected together as they should be.
    And i don't want to use sm30 for editing table data.
    Regards,
    Egi

    My Dear,
    u are loosing the concept of Text table...
    Text table are generally used for multi lingual F4 (i.e you enter vaious F4 list to be displayed for a perticular field when a user from differenct lang log on)
    for eg...
    in urr text table u have .. 2 key itemm
    item_code     ||      lang     ||     text
    10111         ||      E        ||     Eng_Chicken
    10111         ||      D        ||     Chickeno (translation from eng to germen)
    10111         ||        F      ||     Ghoose..
    so when a user with logon lang as 'E' will log on and when he press F4 on item_code he ill see Eng_chicken
    but when a user with logon lang as 'D' will log on and when he press F4 on item_code he ill see Chickeno not Eng_chicken..
    i hope u understood the whole concept...
    No rewards Plz...

  • Regarding text attachment in Email in ABAP program

    Hello...
    Need your expertise in one of the issues. Requirement is seems to be simple
    but i am stuck up at this moment. i have refereed SDN with Several code but
    some point its not giving the proper solution. So its a request to you please
    do not provide any SDN link for reference as i am very much tried all of them.
    please share piece of code.
    Requirement : Need to develope one ABAP program, Email text attachment with Header line.thought its
    very simple but still facing difficulties.
    i have tried many code either its showing Data in single line without new line , in one of the Codes
    data is coming in successive line but there is lot of spacing within Words means all alphabates are tab
    separated. coud you please provide ,me the proper solution for this.
    in  one of the codes is working fine for excel but when Txt extension done data is not coming in successive line all
    data is coming in single line.
    Ex. Text file should contain 1 head and 4 colunns and Data size 50..
    Thanks
    Nishi

    Hi,
    Another option....
    Some sample code using cl_bcs .
    Note the use of cl_abap_char_utilities=>cr_lf .
    FORM mail_1_prep_10
    USING
        it_data         TYPE table
      CHANGING
        ob_document_bcs TYPE REF TO cl_document_bcs .
      DATA: txt_line TYPE string .
      DATA: txt_data TYPE string .
    * Create some text data .
      DO 20 TIMES .
        txt_line = '' .
        DO 10 TIMES .
          CONCATENATE txt_line '|' 'some data 01' '|'   INTO txt_line .
        ENDDO .
        CONCATENATE txt_line cl_abap_char_utilities=>cr_lf INTO txt_line .
        CONCATENATE txt_data txt_line INTO txt_data .
      ENDDO .
    * Mail stuf....
      DATA: it_solix TYPE solix_tab .
      CALL METHOD cl_bcs_convert=>string_to_solix
        EXPORTING
          iv_string = txt_data
        IMPORTING
          et_solix  = it_solix.
      DATA: attachment_subject TYPE so_obj_des .
      DATA: attachment_type TYPE so_obj_tp .
      attachment_subject = 'Some text data' .
      attachment_type = 'txt' .
      TRY.
          CALL METHOD ob_document_bcs->add_attachment
            EXPORTING
              i_attachment_type    = attachment_type
              i_attachment_subject = attachment_subject
              i_att_content_hex    = it_solix.
        CATCH cx_document_bcs .
      ENDTRY.
    ENDFORM .                    "mail_1_prep_10
    regards.
    This is how I see it in my mail :

  • Getting memory usage details in ABAP program

    Hello,
    Is there any method to get the memory used by the program and control the program like restricting the memory usage to some limit or any other control measures which can be taken in the program itself if the memory usage by the program exceeds a maximum limit. Or kindly let me know where i can find the details.

    Hi,
    > Is there any method to get the memory used by the program
    investigate the methods of class cl_abap_memory_utilities (e.g. GET_TOTAL_USED_SIZE)
    >and control the program like restricting the memory usage to some limit
    report rsmemory can change the systemwide quotas
    >or any other control measures which can be taken in the program itself if the memory
    >usage by the program exceeds a maximum limit
    needs to be implemented manually if neede program specific...
    Kind regards,
    Hermann

  • Question regarding Collections Library Usage/Behaviour

    Hi All,
    I am trying to write a dynamic JSON formatter based on my business logic. I am trying something like this:
    Code:
    JSONArray testArray= new JSONArray();
    JSONObject obj1 = new JSONObject();
    obj1.put("TestKey","Test Value");
    testArray.add(obj1);This works perfectly with the JSONObject showing up in the JSONArray.
    However, when I try an anonymous class or simultanous JSONObject.put() inside JSONArray. The size of the array is updated but not the ENTRY i.e. I cant see any Key Value pair updated inside the array.
    Code:
    import org.json.simple.JSONObject;
    import org.json.simple.JSONValue;
    import org.json.simple.JSONArray;
    JSONArray testArray= new JSONArray();
    JSONObject obj1 = new JSONObject();
    testArray.add(obj1.put("TestKey","TestValue"));
    [OR]
    testArray.add(new JSONObject().put("TestKey","TestValue"));In follow up with them same discussion, when I try the following snippet:
    public static void main(String[] args)
           Set<HashMap<String,String>> testObj = new HashSet<HashMap<String,String>>();
            test.add((HashMap)(new HashMap().put("test","value")));       
        }I still can't see any HshMap object created in testObj. I want to know why is it failing this way?
    Thank you all in advance.
    Note: Please excuse me if this post is not allowed here. I am posting it here as the API for JSON formatting i.e.JSONArray and JSONObject classes are straightforward extensions to ArrayList and HashMap.
    Harsh
    Edited by: codeNombre on Aug 26, 2010 6:23 PM

    test.add((HashMap)(new HashMap().put("test","value")));        You're making an incorrect assumption about what HashMap.put() returns. Check it.

  • How can i find item category usage in abap program

    HI, EXPERTS
    I HEARD USAGE MAINTAINED IN ABAP PROGRAM .
    ANY ONE KNOW WHERE I CAN FIND ABAP PROGRAM FOR ITEM CATEGORY USAGE??
    THANKS.^
    Edited by: jong seok Lee on Feb 2, 2010 10:01 AM

    Hi,
    Item Category Usage: An item categories usage is defined by SAP when creating a sales order, The system determines for example, that the usage refers to a text item as oppossed to a deliverable item when you enter text in the order item rather than  a material number. Based on this usage, the system will use the item category determination to propose an item category.
    You can also find the usage in Custoemer material info record (T.Code VD51), if you want to determine any customer specific item category you may use the usage field in Custoemr master info record.
    You can devlop an user exit to determine the item category based upon usage field as well.
    regrads
    Vivek.

  • SAP naming conventions: customer DDIC objects, ABAP programming

    SAP Note 16466 Customer name range for SAP objects contains the SAP naming conventions for customer DDIC objects. Rule of thumb is that the names reserved for customer objects start with 'Y' or 'Z'. However, this note contains the naming convention for DDIC objects only.
    ABAP Code Inspector (transaction SCI) contains the following naming convention for ABAP programming:
    - Global types: T_
    - Global constants: C_
    - Global data: gv_
    - Global field-symbols: FS_
    - Global parameters: P_
    - Global select-options: S_
    - Global field-groups: FS_
    - Local types: LT_
    - Local constants: LC_
    - Local data: v_
    - Local field-symbols: LFS_
    This is the only place I know for ABAP programming naming convention. Does SAP has somewhere else any additional naming convention guidelines for ABAP programming?
    Thanks in advance for your help.
    Regards,
    Jarmo Tuominen

    Naming convention guidelines for ABAP programming is available in here: [Manage Successful Customer Development|https://websmp206.sap-ag.de/~sapidb/011000358700004444532001E].
    Naming Data Types and Objects
    The names of data types and objects have the form: <Classifier>_<Data type>_<Descriptor>.
    The names of data types and objects have up to 30 characters.
    Exceptions: names of input parameters and select options have up to 8 characters, and <Data type> and _ are omitted.
    First component: Classifier
    T Data type
    C  Constant
    G  Global data object
    L  Local data object
    FS Field symbol
    P  Input parameter
    S  Select option
    P  Formal parameter in form
    FM Formal parameter in function
    Second component: Data Type
    <t> Elementary data type, optionally followed by length
    C<n> Type C of length <n>
    N<l> Type N of length <n>
    X<l> Type X of length <n>
    D    Type D
    T    Type T
    I    Type I
    P<d> Type P with <d> decimals
    F    Type F
    WA  Work area
    IT  Internal table
    Third component: Descriptor
    Use meaningful English names. Later, your code may be maintained or analyzed by a programmer or support consultant who is not familiar with another language.
    Use only alphanumeric characters (A-Z and 0-9) and separate words with underscores (_). Hyphens are reserved for separating components in structured data types.
    Examples:
    G_I_COUNTER (global counter)
    T_IT_BOOKING_LIST (type for list of bookings)
    G_IT_BOOKINGS (global internal table of bookings)
    PSMOKER (input parameter for smoker flag: note omission of data type and _ for brevity)
    Edited by: Jarmo Tuominen on Feb 21, 2011 2:13 PM

  • Issue regarding [Work Flow] Business Object Event Raise in ABAP Program

    Hi All,
    I have one issue regarding [Work Flow] Business Object Event Raise in ABAP Program.
    Actual TDS is as below:
    If E message type written, raise Business object BUS2005 (Production order) Event PickShortage for production order passing warehouse, transfer request
    (BUS2065 Object key) in event container. Also include table of text version of error
    messages for this set of Transfer
    Request.
    Can anybody tell me how can i write it technically in ABAP Code.
    Can anybody solve this issue!
    Thanks in advance.
    Thanks,
    Deep.

    Hi,
    Can anybody solve above posted issue!
    Thanks,
    Deep.

  • Regarding structure of abap program

    hi,
    can any one exaplain to me what is the structure of the abap program.
    thank&regards,
    ramnaresh

    Hi..
    This is the Structure of ABAP program.
    REPORT <NAME>.
    **Global Data definitions
    TYPES:
    DATA:
    **Selection Screen Definition
    SELECT-OPTIONS
    PARAMETERS
    **Event Blocks
    INITIALIZATION .
       perform X.
    START-OF-SELECTION.
       perform Y.
    ****Form routines definition
    FORM X.
    ENDFORM.
    FORM Y.
    ENDFORM.
    <b><REMOVED BY MODERATOR></b>
    Message was edited by:
            Alvaro Tejada Galindo

  • Regarding [Work Flow] Business Object Event  Raise in ABAP Program

    Hi All,
    I have one issue regarding [Work Flow] Business Object Event Raise in ABAP Program.
    Actual TDS is as below:
    If E message type written, raise Business object BUS2005 (Production order) Event PickShortage for production order passing warehouse, transfer request
    (BUS2065 Object key) in event container.  Also include table of text version of error
    messages for this set of Transfer
    Request.
    Can anybody tell me how can i write it technically in ABAP Code.
    Can anybody solve this issue!
    Thanks in advance.
    Thanks,
    Deep.

    Hi,
    Can anybody solve above posted issue!
    Thanks,
    Deep.

  • Regarding ABAP program to read and manipulate data from Excel file....

    Hi,
    I want to write a ABAP program which will read Excel file which has three columns viz: Col A, Col B and Col C.
    If there is no data in Col B and Col C for a given record in Column A, then progam should print all those records on screen with write statement.
    Regards,
    Rajesh.

    Hi
    Check
    PARAMETERS: filename LIKE rlgrap-filename MEMORY ID M01,
    begcol TYPE i DEFAULT 1 NO-DISPLAY,
    begrow TYPE i DEFAULT 1 NO-DISPLAY,
    endcol TYPE i DEFAULT 100 NO-DISPLAY,
    endrow TYPE i DEFAULT 32000 NO-DISPLAY.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
    filename = filename
    i_begin_col = begcol
    i_begin_row = begrow
    i_end_col = endcol
    i_end_row = endrow
    TABLES
    intern = intern
    EXCEPTIONS
    inconsistent_parameters = 1
    upload_ole = 2
    OTHERS = 3.
    After getting Records in INTERN TABLE  You can loop it to check where columns B & C are empty  and store them in another table .
    LOOP AT intern.
    IF INTERN  B and C has value  .
    CONTINUE
    ELSE .
    MOVE THEM INTO ANOTHER TABLE ITAB .
    ENDIF .
    ENDLOOP.
    THEN LOOP ITAB .
    WRITE : ' '
    ENDLOP .
    Hope this Helps .
    Praveen

  • How to check frequency of ABAP program usage

    Dear Experts,
    How to find out the frequency of ABAP programs executed by users? the reason is because we want to do a housekeeping on all the ABAP reports that we have developed over the years, we want to deactivate those reports that are no longer executed by the user within 1 year. Anyone can give suggestion?
    I already tried using SM36, but this is only for those programs scheduled in background or immediate, how about those programs running on foreground?

    Hello,
    You can use the trxn SM20N. But bear in mind some prior config needs to be in place for the logging to be active (trxn SM19).
    For further details on SM20 read this: [Security Audit Log|http://help.sap.com/SAPhelp_nw70/helpdata/en/2c/c59d37d373243de10000009b38f8cf/frameset.htm]
    @Sap Fan: STAD can be used in case the audit log is not available (e.g., due to missing config) but afaik there is a limitation on the date range you can provide.
    BR,
    Suhas
    Edited by: Suhas Saha on Sep 7, 2010 9:39 AM

  • Regarding Matchcode object in ABAP programs

    hi experts,
    we have Addon abap programs using Matchcode objects in R3 4.6C with OS unix.
    1-I Would like to know whether the Sorting order of Match code values will change if we change OS from UNIX to solaris.
    I heard that due to Locales, Sorting order for match code likely to get affected due to OS dependencies.
    Please suggest me if its true how to solve this prob
    Thanks.
    Baasha.

    Who tells you that??? The OS has nothing to do with the sort of match code values....Maybe but don't think so....Different DB Engines could make that.....But in my experience....That never happened...
    Greetings,
    Blag.

  • Performance issue in abap program

    hi,
    how can we improve the performance of  abap program

    hi,
    read the follwing links
    ABAP provides few tools to analyse the perfomance of the objects, which was developed by us.
    Run time analysis transaction SE30
    This transaction gives all the analysis of an ABAP program with respect to the database and the non-database processing.
    SQL Trace transaction ST05
    by using this tool we can analyse the perfomance issues related to DATABASE calls.
    Perfomance Techniques for improve the perfomance of the object.
    1) ABAP/4 programs can take a very long time to execute, and can make other processes have to wait before executing. Here are some tips to speed up your programs and reduce the load your programs put on the system:
    2) Use the GET RUN TIME command to help evaluate performance. It's hard to know whether that optimization technique REALLY helps unless you test it out.
    3) Using this tool can help you know what is effective, under what kinds of conditions. The GET RUN TIME has problems under multiple CPUs, so you should use it to test small pieces of your program, rather than the whole program.
    4) Generally, try to reduce I/O first, then memory, then CPU activity. I/O operations that read/write to hard disk are always the most expensive operations. Memory, if not controlled, may have to be written to swap space on the hard disk, which therefore increases your I/O read/writes to disk. CPU activity can be reduced by careful program design, and by using commands such as SUM (SQL) and COLLECT (ABAP/4).
    5) Avoid 'SELECT *', especially in tables that have a lot of fields. Use SELECT A B C INTO instead, so that fields are only read if they are used. This can make a very big difference.
    6) Field-groups can be useful for multi-level sorting and displaying. However, they write their data to the system's paging space, rather than to memory (internal tables use memory). For this reason, field-groups are only appropriate for processing large lists (e.g. over 50,000 records). If you have large lists, you should work with the systems administrator to decide the maximum amount of RAM your program should use, and from that, calculate how much space your lists will use. Then you can decide whether to write the data to memory or swap space.
    Use as many table keys as possible in the WHERE part of your select statements.
    7)Whenever possible, design the program to access a relatively constant number of records (for instance, if you only access the transactions for one month, then there probably will be a reasonable range, like 1200-1800, for the number of transactions inputted within that month). Then use a SELECT A B C INTO TABLE ITAB statement.
    8) Get a good idea of how many records you will be accessing. Log into your productive system, and use SE80 -> Dictionary Objects (press Edit), enter the table name you want to see, and press Display. Go To Utilities -> Table Contents to query the table contents and see the number of records. This is extremely useful in optimizing a program's memory allocation.
    9) Try to make the user interface such that the program gradually unfolds more information to the user, rather than giving a huge list of information all at once to the user.
    10) Declare your internal tables using OCCURS NUM_RECS, where NUM_RECS is the number of records you expect to be accessing. If the number of records exceeds NUM_RECS, the data will be kept in swap space (not memory).
    11) Use SELECT A B C INTO TABLE ITAB whenever possible. This will read all of the records into the itab in one operation, rather than repeated operations that result from a SELECT A B C INTO ITAB... ENDSELECT statement. Make sure that ITAB is declared with OCCURS NUM_RECS, where NUM_RECS is the number of records you expect to access.
    12) If the number of records you are reading is constantly growing, you may be able to break it into chunks of relatively constant size. For instance, if you have to read all records from 1991 to present, you can break it into quarters, and read all records one quarter at a time. This will reduce I/O operations. Test extensively with GET RUN TIME when using this method.
    13) Know how to use the 'collect' command. It can be very efficient.
    14) Use the SELECT SINGLE command whenever possible.
    15) Many tables contain totals fields (such as monthly expense totals). Use these avoid wasting resources by calculating a total that has already been calculated and stored.
    Some tips:
    1) Use joins where possible as redundant data is not fetched.
    2) Use select single where ever possible.
    3) Calling methods of a global class is faster than calling function modules.
    4) Use constants instead of literals
    5) Use WHILE instead of a DO-EXIT-ENDDO.
    6) Unnecessary MOVEs should be avoided by using the explicit work area operations
    see the follwing links for a brief insifght into performance tuning,
    http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_Introduction.asp
    http://help.sap.com/saphelp_nw2004s/helpdata/en/d1/801f7c454211d189710000e8322d00/frameset.htm
    regards
    Rohan

  • Tcode to find the load in server is 20 users run a particular ABAP program

    I want to find the load in the SAP Server (in terms of CPU Usage, memory usage) if a particular Query or ABAP program is executed by 20 users.
    Pls let me knwo the Tcode for the same
    As per my understanding ST03 can be used to view the report of previous information only.

    Balaji
    You have the analyze the load while 20 users executing the following transaction code.
    OS06 - operting system monitor and click on detailed analysis where you can monitor the various instances
    if do you find the other transaction which will show you load of current program being used by 20 users, please share with the expert communitiy to help to other users.
    REgards
    Anwer Waseem

Maybe you are looking for

  • How to hide subfolders in Outlook view in iPhone

    Need to hide all subfolders tht comes over from Outlook into my iPhone, takes forever to scroll down when all is showing. Is there a way?

  • FF not keeping a constant connection

    I've had this problem for about 2 months now. Give or take a few weeks. My Firefox Build 7.0.1 will not hold a constant internet connection. I will rule out possible stuff. Internet connection to my PC is constant with a 30 MB/s connection. Does not

  • AS/400 and Oracle integrated

    Hi, I have to integrate an AS/400 Server with DB2 Database with Oracle. I have read something about Oracle Access Management for AS/400 here: http://www.oracle.com/technology/products/gateways/am4as400.htm. But I can not find where to download it. Wh

  • Acrobat professional xi switches itself off

    I have a problem with adobe acrobat professional xi program. Everything was working normally, when from one day to the other, to use the program, it closes itself after a short period of time, ie I put create a pdf and after a while when you open the

  • Row Calculation Line Height Issue: Not Same Height as Column Lines

    Hi, I am using BI 4.1 SP4 with Microsoft SQL Server 2012. When building calculations, I have noticed that the height of the line (in the rows section) is not the same as the line in the columns section. It is slightly larger. By the third calculation