Reg int table declaration

Hi,
        What does the following statement mean?
t_tab       TYPE STANDARD TABLE OF tp_tab
                           WITH NON-UNIQUE DEFAULT KEY,
What is the use of using "NON-UNIQUE DEFAULT KEY"?
Thanks,
Chinmaye

........... With [UNIQUE | NON-UNIQUE] { {KEY comp1 comp2 ...}
                          | {DEFAULT KEY} } ... .
Definition of a table key in an internal table.
You use UNIQUE and NON-UNIQUE to specify whether the table key is unique or not. For a table key specified with UNIQUE, a row with a certain key field content can only occur once in an internal table of this type. You can only use NON-UNIQUE for standard tables , UNIQUE for hashed tables, and both for sorted tables.
The key fields can be alternatively defined as follows:
Bulleted list of individual components comp1 comp2 ... of the row type behind KEY. Prerequisite is that the row type is structured and that the components are neither table types nor table types containing components.
If the entire table row is defined as a key, you can only specify the pseudo component table_line behind KEY as the only component comp. This is possible for any row types.
Specify the standard key DEFAULT KEY. The standard key fields of a structured row type are all fields that are neither numeric (i, p, f) nor table types. The standard key for non-structured row types is the entire table row if the row type itself is not a table type. If there is no relevant component that applies and the row type itself is a table type, the standard key remains empty. This is only possible for standard tables.
The table key does not have to be specified in the statement TYPES and does not have to be unique. If a table key is not or only partially specified, then the resulting table type is generic and can only be used for typing formal parameters or field symbols. The individual table types are differentiated as follows:
If no key is specified for standard tables, the table type to the key fields is generic. The addition NON-UNIQUE is always implicitly extended for standard tables.
If no key is specified for sorted tables, the table key is completely generic. If only the additions UNIQUE and NON-UNIQUE are omitted, the table key is only generic in regards to uniqueness.
If no key is specified for hashed tables, the table key is completely generic. If the additions UNIQUE and NON-UNIQUE are omitted, the table key is only generic in regards to uniqueness. As hashed tables can only be defined with the addition UNIQUE, a warning is issued by the syntax check.
For the generic table types ANY TABLE and INDEX TABLE, you can specify a key without specifying the uniqueness.

Similar Messages

  • Collecting all the records in the item int table where the same matnr

    Hi All,
    I have two internal tables with records as below.
    HEADER INTERNAL table
    material num       plant
       50410              LV01
       50411              AN01
       50412              AN01
       50413              LV01
    ITEM TABLE
    Material num           stor loc
    50410                     ER01
    50410                     ALQW
    50410                     WFDD
    50412                     ER01
    50413                    ER01
    50413                     XK01
    I want to move this to final internal table, here the record 50411 is not there in second int table still i want to move to final table.
    in the final int table record should be as follows
    material          plant        stor loc
    50410            LV01        ER01
    50410            LV01        ALQW
    50410            LV01        WFDD
    50411            AN01      
    50412            AN01       ER01
    50413            LV01        ER01
    50413            LV01        XK01
    I'm not getting the full records in the final int table.How to do this.
    Thanks & Regards,
    Sabu

    Hi Sabu,
    You can get the data in final internal table as follows :
    **First Declare the Final Internal table as :
    types : begin of wy_final,
               matnr like mara-matnr,             " Material Number
               werks like mseg-werks,            " Plant
               lgort like mseg-lgort,                 "  Storage Location
               end of wy_final.
    data : wt_final type standard table of wy_final with header line.
    **Declare a temporary Header Internal Table
    wt_header_temp[]  =  wt_header[].
    Then loop at Item table as it has multiple entries for same material Number
    loop at wt_item.
    **Then read Header Table  for mapping material Number & picking the corresponding Plant.
    read table wt_header with key matnr = wt_item-matnr.
    if sy-subrc eq 0.
    wt_final-matnr = wt_item-matnr.
    wt_final-werks = wt_header-werks.
    wt_final-lgort = wt_item-lgort.
    append wt_final.
    clear wt_final.
    endif.
    read table wt_header_temp with key matnr = wt_item-matnr.
    if sy-subrc eq 0.
    delete wt_header_temp.
    endif.
    endloop.
    loop at wt_header_temp.
    read table wt_final with key matnr = wt_header_temp-matnr.
    if sy-subrc ne 0.
    wt_final-matnr = wt_header_temp-matnr.
    wt_final-werks = wt_header_temp-werks.
    append wt_final.
    clear wt_final.
    endif.
    endloop.
    sort wt_final by matnr.
    I Think this would probably solve your purpose.
    Thanks & Regards,
    Bhavika
    Edited by: bhavika kumar on Mar 19, 2009 5:46 AM

  • How to get common datas from two int.tables

    hi,
    please tell me , how to i will get the common datas between two int. tables
    & place them in third int. table.
    give me syntax.
    regards
    subhasis.

    Hi Subhasis,
    <b>SORT :</b></u>
    SORT itab.
    Extras:
    1. ... BY f1 f2 ... fn
    2. ... ASCENDING
    3. ... DESCENDING
    4. ... AS TEXT
    5. ... STABLE
    The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Field symbols not allowed as sort criterion.
    Effect
    The entries in the internal table are sorted in ascending order using the key from the table definition (DATA, TYPES).
    Addition 1
    ... BY f1 f2 ... fn
    Effect
    Uses the sort key defined by the sub-fields f1, f2, ..., fn of the table itab instead of the table key. The fields can be of any type; even number fields and tables are allowed.
    You can also specify the sort fields dynamically in the form (name). If name is blank at runtime, the sort field is ignored. If itab is a table with a header line, you can also use a field symbol pointing to the header line of itab as a dynamic sort criterion. A field symbol that is not assigned is ignored. If a field symbol is assigned, but does not point to the header line of the internal table, a runtime error occurs.
    If the line type of the internal table contains object reference variables as components, or the entire line type is a reference variable, you can use the attributes of the object to which a reference is pointing in a line as sort criteria (see Attributes of Objects as the Key of an Internal Table.
    You can address the entire line of an internal table as the key using the pseudocomponent TABLE_LINE. This is particularly relevant for tables with a non-structured line type when you want to address the whole line as the key of the table (see also Pseudocomponent TABLE_LINE With Internal Tables).
    If you use one of the additions 2 to 5 before BY, it applies to all fields of the sort key by default. You can also specify these additions after each individual sort field f1, f2, ..., fn. For each key field, this defines an individual sort rule which overrides the default.
    Addition 2
    ... ASCENDING
    Effect
    Sorts in ascending order. This is also the default if no sort order is specified directly after SORT. For this reason, it is not necessary to specify ASCENDING explicitly as the default sort order.
    With the addition BY, you can also specify ASCENDING directly after a sort field to define ascending order explicitly as the sort sequence for this field.
    Addition 3
    ... DESCENDING
    Effect
    Sorts in descending order. If the addition comes right after SORT, DESCENDING is taken as the default for all fields of the sort key.
    With the addition BY, you can also specify DESCENDING directly after a sort field.
    Addition 4
    ... AS TEXT
    Effect
    Text fields are sorted appropriate to the locale. This means that the relative order of characters is defined according to the text environment being used.
    When an internal mode is opened (in other words, when a roll area is opened), the text environment is automatically set to the logon language specified in the user master record. If necessary, however, you can change the text environment explicitly in your program by using a SET-LOCALE statement.
    If the addition comes directly after itab, locale-specific rules are used for all fields of the sort key where the type of these fields is C or W. After the sort, the sequence of entries usually does not match the sequence which results otherwise, without using the addition AS TEXT, i.e. with binary sorting.
    With the addition BY, you can also specify AS TEXT directly after a sort field, provided it is of type C or W, or a structured type. Otherwise, a runtime error occurs. In sort fields with a structured type, AS TEXT only affects subcomponents with type C or W.
    In case of an invalid character, a SYSLOG message is written, and the respective record is inserted at the end.
    Note
    Please keep the rules for site-specific sorting in mind.
    Example
    Sort a name table with different keys:
    TYPES: BEGIN OF PERSON_TYPE,
             NAME(10)   TYPE C,
             AGE        TYPE I,
             COUNTRY(3) TYPE C,
           END OF PERSON_TYPE.
    DATA: PERSON TYPE STANDARD TABLE OF PERSON_TYPE WITH
                      NON-UNIQUE DEFAULT KEY INITIAL SIZE 5,
          WA_PERSON TYPE PERSON_TYPE.
    WA_PERSON-NAME    = 'Muller'. WA_PERSON-AGE = 22.
    WA_PERSON-COUNTRY = 'USA'.
    APPEND WA_PERSON TO PERSON.
    WA_PERSON-NAME    = 'Moller'. WA_PERSON-AGE = 25.
    WA_PERSON-COUNTRY = 'FRG'.
    APPEND WA_PERSON TO PERSON.
    WA_PERSON-NAME    = 'Möller'. WA_PERSON-AGE = 22.
    WA_PERSON-COUNTRY = 'USA'.
    APPEND WA_PERSON TO PERSON.
    WA_PERSON-NAME    = 'Miller'. WA_PERSON-AGE = 23.
    WA_PERSON-COUNTRY = 'USA'.
    APPEND WA_PERSON TO PERSON.
    SORT PERSON.
    Now, the sequence of the table entries is as follows:
    Miller  23  USA
    Moller  25  FRG
    Muller  22  USA
    Möller  22  USA
    If, for example, you apply German sort rules where the umlaut comes directly after the letter 'o' in the sort, the data record beginning with 'Möller' would not be in the right place in this sequence. It should come second.
    Provided a German-language locale is set (e.g. sorting is according to German grammatical rules, see also SET LOCALE), you can sort the names according to German rules as follows:
    SORT PERSON BY NAME AS TEXT.
    Now, the sequence of table entries is as follows:
    Miller  23  USA
    Moller  25  FRG
    Möller  22  USA
    Muller  22  USA
    Further examples:
    SORT PERSON DESCENDING BY COUNTRY AGE NAME.
    Now, the sequence of table entries is as follows:
    Miller  23  USA
    Möller  22  USA
    Muller  22  USA
    Moller  25  FRG
    SORT PERSON DESCENDING BY AGE ASCENDING NAME AS TEXT.
    Now, the sequence of table entries is as follows:
    Muller  22  USA
    Möller  22  USA
    Miller  23  USA
    Moller  25  FRG
    Addition 5
    ... STABLE
    Effect
    Uses a stable sort, that is, the relative sequence of entries that have the same sort key remains unchanged.
    Unlike additions 2 to 4, you cannot use this addition directly after a sort field.
    Notes
    General:
    The number of sort fields is restricted to 250.
    The sort process is only stable if you use the STABLE addition. Otherwise, a predefined sequence of fields used to sort a list is not usually retained.
    It does not make sense to use the SORT command for a SORTED TABLE. If the table type is statically declared, the system returns a syntax error if you try to SORT the table. If the table type is not statically declared (for example, because the table was passed to a FORM routine as an INDEX TABLE in a parameter), and the system can interpret the SORT statement as an empty operation, it ignores the statement. This is the case when the key in the BY clause corresponds to the beginning of the table key. Otherwise, a runtime error occurs.
    To delete all duplicate entries from a sorted internal table (e.g. just after SORT), you can use the DELETE ADJACENT DUPLICATES FROM itab statement.
    When using the addition AS TEXT, the sequence of entries after the sort does not usually match the sequence resulting from a binary sort, i.e. if the addition AS TEXT is not specified. The consequence of this is that after the SORT, you are not allowed to access with the READ TABLE itab ... BINARY SEARCH statement.
    If you still want to access data sorted apppropriate to the locale with a binary search, you can do this by including an additional component in the table where you can explictly store the data formatted using the CONVERT TEXT ... INTO SORTABLE CODE statement. This is also recommended for performance reasons if you have to re-sort the table several times according to locale-specific criteria.
    If the internal table has more than 2^19 lines or is larger than 12 MB, the system sorts it physically using an external auxiliary file. You can specify the directory in which the file should be created using the SAP profile parameter DIR_SORTTMP. By default, the system uses the SAP data directory (SAP profile parameter DIR_DATA).
    Notes
    Performance:
    The runtime required to sort an internal table increases with the number of entries and the length of the sort key.
    Sorting an internal table with 100 entries with a 50 byte key requires about 1300 msn (standardized microseconds). Using a 30-byte key, the runtime is about 950 msn.
    If one of the specified sort criteria is itself an internal table, SORT may sometimes take much longer.
    The runtime increases if you use a stable sort.
    Physical sorting reduces the runtime required for subsequent sequential processing.
    Reward If Useful.
    Regards,
    Chitra

  • Is it possible to change the order of the fields in the int table?

    Hello
    Is it possible to change the order of the fields in the int table?
    Lets say itab has the following fields :
    F1, F2, F3
    I would like to see it as F2 F3 F1
    Thanks

    >
    Comandante Che Guevara wrote:
    > Lets say itab has the following fields : F1, F2, F3
    >
    > I would like to see it as F2 F3 F1
    What do you mean by "like to see" ? You can WRITE the fields in any order you want. If you want to display the internal table in an ALV you can manipulate the fieldcatalog.
    If you want something else other than display the field, you have to explain your req. in detail.
    BR,
    Suhas

  • Error in ABAP Report TABLES declaration

    Hi,
    I am a Basis administrator and trying to write a small program for archiving.
    I get a folowing error when user the following statement in a report -
    TABLES: RSDAARCHREQ.
    The error is as follows -
    "RSDAARCHREQ" must be a flat structure. You cannot use internal tables,
    strings, references, or structures as components. -
    I can include all the other tables requred but somehow this particular table gives me this error which I have never encountered earlier. This is BI 7.0 and it is standard SAP transparent table.
    Please help me.
    I will appreciate it.
    Regards,
    Sume

    Hi Sume,
    Do not declare RSDAARCHREQ in tables.
    If you want a internal table  declare in the below mentioned way .
    data: it_RSDAARCHREQ TYPE STANDARD TABLE OF RSDAARCHREQ.
    select * into table
    it_RSDAARCHREQ
      from RSDAARCHREQ.
    Regards
    Naresh

  • DIFF: Field string ,Structure and Internal table declaration

    Hai,
           what is the diference between  Field string ,Structure in ABAP program and Internal table declaration and how it will work ?
    Thank you
    ASHOK KUMAR.

    hi,
    Look this u will get a good idea.
    *& Report  ZTYPES                                                      *
    REPORT  ZTYPES                                                  .
    * Table declaration (old method)
    DATA: BEGIN OF tab_ekpo OCCURS 0,             "itab with header line
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
    END OF tab_ekpo.
    *Table declaration (new method)     "USE THIS WAY!!!
    TYPES: BEGIN OF t_ekpo,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
    END OF t_ekpo.
    DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,      "itab
          wa_ekpo TYPE t_ekpo.                    "work area (header line)
    * Build internal table and work area from existing internal table
    DATA: it_datatab LIKE tab_ekpo OCCURS 0,      "old method
          wa_datatab LIKE LINE OF tab_ekpo.
    * Build internal table and work area from existing internal table,
    * adding additional fields
    TYPES: BEGIN OF t_repdata.
            INCLUDE STRUCTURE tab_ekpo.  "could include EKKO table itself!!
    TYPES: bukrs  TYPE ekpo-werks,
           bstyp  TYPE ekpo-bukrs.
    TYPES: END OF t_repdata.
    DATA: it_repdata TYPE STANDARD TABLE OF t_repdata INITIAL SIZE 0,   "itab
          wa_repdata TYPE t_repdata.                 "work area (header line)
    Regards
    Reshma

  • Internal table declaration - work area and body

    Hi all
    I have declared my internal table in my program as
    data : itab_wa type ZRESULT_LINE,
           itab    type ZRESULT_ROW.
    Where ZRESULT_LINE and ZRESULT_ROW are the structure and table types.
    Now I want to add
    data: TCOLOR TYPE SLIS_T_SPECIALCOL_ALV.
    in my internal table declaration. How can I do this. Please remember I need to have work area and body in my internal table as I have used work area and body in my code.
    Waiting..............
    Message was edited by: Raju Boda

    HI,
    See the Declarion types of workarea and Internal tables
    * Table declaration (old method)
    DATA: BEGIN OF tab_ekpo OCCURS 0,             "itab with header line
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
    END OF tab_ekpo.
    *Table declaration (new method)     "USE THIS WAY!!!
    TYPES: BEGIN OF t_ekpo,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
    END OF t_ekpo.
    DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,      "itab
          wa_ekpo TYPE t_ekpo.                    "work area (header line)
    * Build internal table and work area from existing internal table
    DATA: it_datatab LIKE tab_ekpo OCCURS 0,      "old method
          wa_datatab LIKE LINE OF tab_ekpo.
    * Build internal table and work area from existing internal table,
    * adding additional fields
    TYPES: BEGIN OF t_repdata.
            INCLUDE STRUCTURE tab_ekpo.  "could include EKKO table itself!!
    TYPES: bukrs  TYPE ekpo-werks,
           bstyp  TYPE ekpo-bukrs.
    TYPES: END OF t_repdata.
    DATA: it_repdata TYPE STANDARD TABLE OF t_repdata INITIAL SIZE 0,   "itab
          wa_repdata TYPE t_repdata.                 "work area (header line
    you need to maintain same structure for both workarea as well Internal table
    Regards
    Sudheer

  • PL/SQL TABLE declarations must currently use binary_integer indexes

    Hi,
    I am having procedure written in form6i, this procedure is having pl/sql table datatyep "v_suppmesg orcl.err_message.error_tabtype;" this pl/sql datatype is defined in database and the procedure in database is not having any error in it.
    But when i am compling my form its giving me error
    PL/SQL TABLE declarations must currently use binary_integer indexes
    and error point is *"i_rowindex"* in the sentance given below.
    *"SET_GROUP_CHAR_CELL (g_suppress_error_colid, v_rowindex, v_suppmesg(i_rowindex));"*
    PROCEDURE PRC_A IS
    v_rowindex NUMBER (5,0) := 1;
    v_suppmesg orcl.err_message.error_tabtype;
    BEGIN
    g_suppress_error_rgid := FIND_GROUP (g_suppress_error_rgname);
    IF ID_NULL (g_suppress_error_rgid)
    THEN
    g_suppress_error_rgid := CREATE_GROUP (g_suppress_error_rgname, GLOBAL_SCOPE);
    g_suppress_error_colid := ADD_GROUP_COLUMN ( g_suppress_error_rgid
    , g_suppress_error_colname
    , CHAR_COLUMN
    , 15);
    orcl.err_message.get_messages (v_suppmesg);
    FOR i_rowindex IN 1..v_suppmesg.count
    LOOP
    ADD_GROUP_ROW (g_suppress_error_rgid, END_OF_GROUP);
    SET_GROUP_CHAR_CELL (g_suppress_error_colid, v_rowindex, v_suppmesg(i_rowindex));
    v_rowindex := v_rowindex + 1;
    END LOOP;
    ELSE
    g_suppress_error_colid := FIND_COLUMN (g_suppress_error_rgname||'.'||g_suppress_error_colname);
    END IF;
    END Init_Suppress_Message;
    can anyone tell me what's wrong in this.

    I have the folowing compiling and executing fine (Forms 10.1.2):
    DECLARE
      type t1 is table of VARCHAR2(100) index by BINARY_INTEGER ;
      tab t1;
      rg_id RecordGroup;
      gc_id GroupColumn; 
    BEGIN
         tab(1) := 'One' ;
         tab(2) := 'Two' ;
         tab(3) := 'Three' ;
         rg_id := FIND_GROUP ('RG10');
         IF ID_NULL (rg_id)
         THEN
              rg_id := CREATE_GROUP ('RG10', GLOBAL_SCOPE);
              gc_id := ADD_GROUP_COLUMN ( 'RG10'
              , 'COL1'
              , CHAR_COLUMN
              , 15);
              --orcl.err_message.get_messages (v_suppmesg);
              FOR i IN 1..tab.count
              LOOP
              ADD_GROUP_ROW ('RG10', END_OF_GROUP);
              SET_GROUP_CHAR_CELL ('RG10.COL1', i, tab(i));
              END LOOP;
         END IF;
    END;Francois

  • How to avaoid tables declaration in abap object 's

    Hi Folks,
    I realised that in abap objects we should not declare tables statement, instead we have to declare wa type dbtable. But my qsn is i am using select single * from dbtable in at selection-screen for validation, in that situation in that situation how to avoid table declaration, i tried with select single * dbtable into wa , but still its asking table declaration.
    Pls help me out, thanks.
    Regards
    Vishal

    <b>method GET_VENDOR_4_USER .
    Get the Vendor for the User
    data: x_lfa1 type lfa1.
      clear vendor.
      select
        lifnr
        into VENDOR
        from  zsiacvendor
        up to 1 rows
        where bname = sy-uname.
      endselect.
    get the name of the vendor
      select single *
               into x_lfa1
               from lfa1
              where lifnr = vendor.
    endmethod.</b>
    The above code works fine for me.

  • To populate dynamically created int table with data from other table

    Hi everybody,
    I have already created an internal table dynamically, but now want to populate it with data from another IT depending on the plant name.
    My dynamic int table contains fields with plant name like '8001' ,'8002' and so on.
    no I want to read data from the other table and depending on bwkey which contains similar data like plant name , want to append to this new dynamic int table through read key statement.
    I cannot reference the field name hard coded as it does not allow field symbol reference to be hard coded.
    Pls help.

    Hi,
    Check the code below:
    REPORT  ztestdyn.
    TYPE-POOLS : slis.
    TABLES: yyle0003.
    DATA:
      g_exit    TYPE c,
      g_save    VALUE 'A',               "For parameter I_SAVE
      g_repid   LIKE sy-repid,           "For program name
      g_variant TYPE disvariant.         "For parameter IS_VARIANT
    *Tables
      DATA: d_ref TYPE REF TO data,
            d_ref1 TYPE REF TO data,
            i_alv_cat1 TYPE TABLE OF lvc_s_fcat,
            ls_alv_cat1 LIKE LINE OF i_alv_cat1.
      DATA: BEGIN OF total_tab OCCURS 0 ,
            tknum TYPE yyle0003-tknum,
            quantity TYPE p,  "yyle0003-QUANTITY,
            END OF total_tab.
      DATA: BEGIN OF g_scandata_tab OCCURS 0.
              INCLUDE STRUCTURE yyle0003.
      DATA: END OF g_scandata_tab.
      DATA: g_yyle0003_tab LIKE yyle0003 OCCURS 0 WITH HEADER LINE.
      DATA: g_itab1 TYPE TABLE OF yyle0003.
      DATA: wa_itab1 LIKE g_scandata_tab.
      TYPES: BEGIN OF itab2,
             tknum TYPE yyle0003-tknum,
             vhilm TYPE yyle0003-vhilm,
             quantity TYPE p,
             END OF itab2.
      DATA: g_itab3 TYPE TABLE OF itab2.
      DATA: wa_itab3 TYPE itab2.
      DATA: g_itab5 TYPE TABLE OF itab2.
      DATA: wa_itab5 TYPE itab2.
      DATA: g_itab4 TYPE TABLE OF itab2.
      DATA: wa_itab4 TYPE itab2.
      DATA: gv_wa TYPE REF TO data.
      DATA : wa_tab TYPE itab2.
      DATA: BEGIN OF itab6 OCCURS 0,
             vhilm TYPE yyle0003-vhilm,
             quantity TYPE p,
             END OF itab6.
    ******************Start of Internal Table Definition *******************
      DATA:
            g_custom_container_0100 TYPE REF TO cl_gui_custom_container,
            g_alv_grid_0100    TYPE REF TO cl_gui_alv_grid,
            g_container_0100   TYPE scrfname VALUE 'LIST',
            g_mylayout         TYPE lvc_s_layo,
            ok_code            LIKE sy-ucomm.
      FIELD-SYMBOLS :<f_fs> TYPE table,
                     <f_fs11> TYPE table,
                     <f_fs1> TYPE table,
                     <f_fs3> TYPE ANY,
                     <f_fs4> TYPE ANY,
                     <f_field> TYPE ANY,
                     <f_fs5> TYPE ANY.
      FIELD-SYMBOLS: <fs_wa> TYPE ANY.
      DATA: l_var TYPE i,
            l_i   TYPE i.
      DATA: l_var1 TYPE char20,
            l_var2 TYPE char20.
    DATA: l_TOTAL TYPE I,
          L_FILL TYPE i,
          L_TOT  TYPE I.
    DATA: l_int TYPE i,
           l_sum TYPE i.
    FIELD-SYMBOLS: <f_fs2> TYPE  itab2, "
                     <f_fs6> TYPE ANY,
                     <f_fs7> TYPE ANY.
      DATA: l_var3 TYPE char15.
      DATA: l_quant TYPE p.
    FIELD-SYMBOLS: <f_fs8> LIKE itab6, "
                     <f_fs9> TYPE ANY,
                     <f_fs10> TYPE ANY.
    FIELD-SYMBOLS : <f_fs12> TYPE ANY,
                      <f_fs13> TYPE ANY.
      SORT g_scandata_tab BY tknum vhilm.
      LOOP AT g_scandata_tab INTO wa_itab1.
        MOVE-CORRESPONDING wa_itab1 TO wa_itab3.
        APPEND wa_itab3 TO g_itab3.
      ENDLOOP.
      LOOP AT g_itab3 INTO wa_itab3.
        COLLECT wa_itab3 INTO g_itab4.
      ENDLOOP.
      LOOP AT g_itab4 INTO wa_itab4.
        MOVE-CORRESPONDING wa_itab4 TO wa_itab5.
        MOVE-CORRESPONDING wa_itab4 TO itab6.
        APPEND wa_itab5 TO g_itab5.
        COLLECT itab6.
      ENDLOOP.
      CLEAR wa_itab3.
      SORT g_itab4 BY tknum vhilm.
      DELETE ADJACENT DUPLICATES FROM g_itab4 COMPARING vhilm.
      DESCRIBE TABLE g_itab4 LINES l_var.
      l_i = '2'.
      ls_alv_cat1-fieldname = 'TKNUM'.
      ls_alv_cat1-col_pos = 1.
      ls_alv_cat1-coltext ='ShipmentNo.'.
      APPEND ls_alv_cat1 TO i_alv_cat1.
      DATA: l_var4(10) TYPE c,
            l_var5(10) TYPE c,
            l_fieldname(20) TYPE c..
      LOOP AT g_itab4 INTO wa_itab4.
        IF l_var >= 1.
          CONDENSE wa_itab4-vhilm NO-GAPS.
          ls_alv_cat1-fieldname = wa_itab4-vhilm. "l_fieldname.
          ls_alv_cat1-col_pos = l_i.
          ls_alv_cat1-coltext = wa_itab4-vhilm.
          ls_alv_cat1-do_sum  ='X'.
          APPEND ls_alv_cat1 TO i_alv_cat1.
          CLEAR : ls_alv_cat1, l_fieldname.
          l_i = l_i + 1.
        ENDIF.
        AT LAST.
          ls_alv_cat1-fieldname = 'TOTAL'. "l_fieldname.
          ls_alv_cat1-col_pos = l_i.
          ls_alv_cat1-coltext = 'TOTAL'.
          ls_alv_cat1-do_sum  ='X'.
          APPEND ls_alv_cat1 TO i_alv_cat1.
          CLEAR : ls_alv_cat1, l_fieldname.
        ENDAT.
        SORT i_alv_cat1 BY fieldname.
        DELETE ADJACENT DUPLICATES FROM i_alv_cat1.
      ENDLOOP.
      SORT i_alv_cat1 BY col_pos.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = i_alv_cat1
        IMPORTING
          ep_table = d_ref.
      ASSIGN d_ref->* TO <f_fs>.
      CREATE DATA gv_wa LIKE LINE OF <f_fs>.
      ASSIGN gv_wa->* TO <fs_wa>.
      DELETE ADJACENT DUPLICATES FROM <f_fs> COMPARING ALL FIELDS.
        LOOP AT itab6.
        CLEAR wa_itab5.
        wa_itab5-tknum = 'Total'.
        MOVE-CORRESPONDING itab6 TO wa_itab5.
        APPEND wa_itab5 TO g_itab5.
        CLEAR wa_itab5.
      ENDLOOP.
         DESCRIBE TABLE g_itab5 LINES L_TOT.
           LOOP AT TOTAL_TAB.
          L_TOTAL = L_TOTAL + total_tab-quantity.
         ENDLOOP.
      LOOP AT g_final ASSIGNING <f_fs2>.
        ASSIGN COMPONENT 'TKNUM' OF STRUCTURE <f_fs2> TO <f_fs6>.
        ASSIGN COMPONENT 'TKNUM' OF STRUCTURE <fs_wa> TO <f_fs7>.
        <f_fs7> = <f_fs6>.
        CONDENSE <f_fs2>-vhilm NO-GAPS.
        ASSIGN COMPONENT 'VHILM' OF STRUCTURE <f_fs2> TO <f_fs3>.
        ASSIGN COMPONENT 3 OF STRUCTURE <f_fs2> TO <f_fs4>.
        MOVE <f_fs3> TO l_var1.
        ASSIGN COMPONENT l_var1 OF STRUCTURE <fs_wa> TO <f_fs5>.
        <f_fs5> =  <f_fs4>.
        CLEAR total_tab-quantity.
        READ TABLE total_tab WITH KEY tknum = <f_fs6>.
        IF sy-subrc = 0.
          ASSIGN total_tab-quantity TO <f_fs12>.
          ASSIGN COMPONENT 'TOTAL' OF STRUCTURE <fs_wa> TO <f_fs13>.
          <f_fs13> = <f_fs12>.
        ENDIF.
        L_FILL = L_FILL + 1.
        IF L_FILL = L_TOT.
         ASSIGN L_TOTAL TO <f_fs12>.
          ASSIGN COMPONENT 'TOTAL' OF STRUCTURE <fs_wa> TO <f_fs13>.
          <f_fs13> = <f_fs12>.
        ENDIF.
        AT END OF <f_fs2>-tknum.
          APPEND <fs_wa> TO <f_fs>.
          CLEAR  <fs_wa>.
        ENDAT.
      ENDLOOP.
      CLEAR: <f_fs6>,
              <f_fs7>.
      CLEAR <fs_wa>.
    CALL SCREEN 0100.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'ZVKS'.
      SET TITLEBAR 'ZVKS'.
      CHECK sy-ucomm IS INITIAL.
      SORT g_scandata_tab BY tknum vhilm.
      CREATE OBJECT g_custom_container_0100
             EXPORTING container_name = g_container_0100
             EXCEPTIONS
               cntl_error = 1
               cntl_system_error = 2
               create_error = 3
               lifetime_error = 4
               lifetime_dynpro_dynpro_link = 5.
      CREATE OBJECT g_alv_grid_0100
             EXPORTING i_parent = g_custom_container_0100.
      g_mylayout-grid_title = 'Display Scanning data'.
      CALL METHOD g_alv_grid_0100->set_table_for_first_display
        CHANGING
          it_outtab                     = <f_fs>
          it_fieldcatalog               = i_alv_cat1
                    EXCEPTIONS
                      invalid_parameter_combination = 1
                      program_error                 = 2
                      too_many_lines                = 3
                      OTHERS                        = 4.
      IF sy-subrc <> 0.
                  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    Regards
    Kannaiah

  • REG:Internal table and Database table

    Hi Xperts,
    Can you tell me /give me a sample code so as to
    Compare the data present in the database table and internal table.i.e
    Wheher the data in the db table matches with the data in the internal table
    Thanks.

    Hello,  
    First make sure that data is there in the internal table
    TABLES : Declare your table example MARA, VBAK etc
    TYPES: BEGIN OF ITAB1,
    Declare your fields here
    example
    v_mat(10) type c,
    v_code(5) type I,
    END OF ITAB1.
    IF NOT ITAB[] is INITIAL.
    LOOP AT
    END IF.
    To compare the data with DB tables, read the database table and copy into the internal table ITAB2
    Then compare the ITAB and ITAB1
    IF ITAB1[] = ITAB2[]
    END IF
    See these links for [Creating Internal Tables|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3660358411d1829f0000e829fbfe/content.htm]
    [Comparing Internal Tables|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3841358411d1829f0000e829fbfe/content.htm]
    See this for more about [Processing Internal Tables|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb36ae358411d1829f0000e829fbfe/content.htm]
    Declaring the internal table in ABAP objects
    [Thanks|http://chandranonline.blogspot.com/]
    [Chandran|http://chandranonline.blogspot.com/]

  • OO ABAP inerenal table and tables declarations?

    Hi All,
    1.I am new to OO ABAP, can any one give me clear idea how to declare Internal tables, work area and table declarations and how to use and read them?
    2. I am having a problem,
    I declare a table like this
    IT_CRMD_ORDERADM_H TYPE TABLE OF CRMD_ORDERADM_H.
    and in the perform statement
    Pefrom using
    IT_CRMD_ORDERADM_H[]
    and in form ( i need to read and select a record from this table)
    can any one give me solution how to do this?
    thanks for ur time.
    sandhya

    Hai Sandhya
    Go through the following Code
    *& Report  ZABAP_OBJ_01                                          *
    report  zabap_obj_01                      .
    parameters : p_vbeln like vbap-vbeln obligatory,
                 p_matnr like mara-matnr.
    <b>types : begin of ty_vbap,
            vbeln type vbap-vbeln,
            matnr type vbap-matnr,
            arktx type vbap-arktx,
            end of ty_vbap.</b>
          CLASS sales_order DEFINITION
    class sales_order definition.
      public section.
        data : v_matnr type mara-matnr,
               v_vbeln type vbap-vbeln.
        events : no_data_found.
        methods : constructor importing vbeln type vbap-vbeln
                                        matnr type mara-matnr optional,
                  get_vbap_details,
                  disp_vbap_details,
                  Handle_no_data_found
                  for event no_data_found of sales_order.
    <b>    data : it_vbap type standard table of ty_vbap.</b>
    endclass.                    "sales_order DEFINITION
          CLASS sales_order IMPLEMENTATION
    class sales_order implementation.
      method get_vbap_details.
        clear : it_vbap.
        refresh : it_vbap.
        select  vbeln
                matnr
                arktx
                from vbap
                into table it_vbap
                where vbeln = p_vbeln.
        if sy-subrc <> 0.
          raise event no_data_found.
        endif.
      endmethod.                    "get_vbap_details
      method constructor.
        clear : v_vbeln,
                v_matnr.
        v_vbeln = vbeln.
        v_matnr = matnr.
      endmethod.                    "constructor
      method Handle_no_data_found.
        write : / 'No Data Found for the given selection Criteria'.
      endmethod.
      method disp_vbap_details.
        data : wx_vbap like line of it_vbap.
        loop at it_vbap into wx_vbap.
          write :/ wx_vbap-vbeln,
                   wx_vbap-matnr,
                   wx_vbap-arktx.
        endloop.
        clear : it_vbap.
      endmethod.                    "disp_vbap_details
    endclass.                    "sales_order IMPLEMENTATION
    data : obj type ref to sales_order.
    start-of-selection.
      if not p_matnr is initial.
        create object obj exporting vbeln = p_vbeln
                                    matnr = p_matnr.
      else.
        create object obj exporting vbeln = p_vbeln.
      endif.
      set handler obj->Handle_no_data_found for obj.
      call method obj->get_vbap_details.
      call method obj->disp_vbap_details.
    Thanks & regards
    Sreenivasulu P

  • HOW TO MOVE DATA FROM INT-TABLE TO DATABASE STRUCTURE?

    DEAR ALL!
    CAN ANY ONE GIVE ME SAMPLE CODE TO MOVE DATA FROM INT -TABLE TO DB-STRUCTURE PLEASE.
    I HAVE THE VALUES IN TABLE AND I NEED TO UPDATE STRUCTURE.
    REGARDS,
    VJ

    Hi,
       If you want to update a db STRUCTURE it is not possible because Structure doesnot hold any data.
    If you are trying to update a db table  then the update command should do the work.
    Eg : UPDATE VBPA3 FROM TABLE DA_XVBPA3U.
    Note :  The Internal table should be of same structure and should not have duplicate entries.
    Regards,
    Srini.

  • Break a Int .Table

    Hi
    All
    i have a BDC program in which i have to pass  record from a int table having a lot of entries..
      Now i want to pass it by breaking it into 990 record for each pass to BDC ..
    How i can braek int table of large size into smaller ones of size 990 ..
    **BEST ANS HAS BEST POINTS ***
    Thanks
    Saurabh

    Hi saurabh,
    data:
      lv_lines type sytfill,
      lv_from type sytfill value 1,
      lv_to type sytfill,
      lt_itab_proc like table of itab. "if itab has header line
    *  lt_itab_proc like itab. "if itab has no header line
    describe table itab[] lines lv_lines.
    while  lv_from <=  lv_lines.
      lv_to = lv_from + 989. " -> 990 in first loop
      append lines of itab[] to lt_itab_proc from lv_from to lv_to.
      perform process_BDC using lt_itab_proc. "Process partial itab
      lv_from = lv_to + 1.
      clear lt_itab_proc.
    endwhile.
    I don't know if this is best but I'm convinced it is fastest solution.
    Regards,
    Clemens

  • Re: Table declaration

    hi,
    i saw some table declaration like
         GT_AGENTS TYPE STANDARD TABLE OF TT_AGENTS WITH DEFAULT KEY ,
    Here what is meaning of Default key.
    Please give me explanation

    Hi Santosh,
    Please check this link
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb366d358411d1829f0000e829fbfe/content.htm
    Key
    You can specify the key <key> of an internal table as follows:
    [UNIQUE|NON-UNIQUE] KEY <col1> ... <col n>
    In tables with a structured line type, all of the components <coli> belong to the key as long as they are not internal tables or references, and do not contain internal tables or references. Key fields can be nested structures. The substructures are expanded component by component when you access the table using the key. The system follows the sequence of the key fields.
    [UNIQUE|NON-UNIQUE] KEY TABLE LINE
    If a table has an elementary line type (C, D, F, I, N, P, T, X), you can define the entire line as the key. If you try this for a table whose line type is itself a table, a syntax error occurs. If a table has a structured line type, it is possible to specify the entire line as the key. However, you should remember that this is often not suitable.
    [UNIQUE|NON-UNIQUE] DEFAULT KEY
    This declares the fields of the default key as the key fields. If the table has a structured line type, the default key contains all non-numeric columns of the internal table that are not and do not contain references or internal tables. If the table has an elementary line type, the default key is the entire line. The default key of an internal table whose line type is an internal table, the default key is empty.
    Specifying a key is optional. If you do not specify a key, the system defines a table type with an arbitrary key. You can only use this to define the types of field symbols and the interface parameters of procedures . For exceptions, refer to Special Features of Standard Tables.
    The optional additions UNIQUE or NON-UNIQUE determine whether the key is to be unique or non-unique, that is, whether the table can accept duplicate entries. If you do not specify UNIQUE or NON-UNIQUE for the key, the table type is generic in this respect. As such, it can only be used for specifying types. When you specify the table type simultaneously, you must note the following restrictions:
    You cannot use the UNIQUE addition for standard tables. The system always generates the NON-UNIQUE addition automatically.
    You must always specify the UNIQUE option when you create a hashed table.
    Besty regards,
    raam

Maybe you are looking for

  • Report for Comparison of Material Qty

    Hi All, I need to Develop an Interactive report for Comparison of Material Qty. ordered through Purchase requisition, ordered material through PO and corresponding Material Receipt report. Can Someone Give a brief description about this & fields tcod

  • Current iTunes Sofware update: error 7 windows error 1114

    Software update caused Error 7, Windows error 1114. Fixed .net Framework 4.5.1 (7x64) Windows operating system., as per suggestion in previous discussions.The problem still persists. This has NEVER  happened & I have had iTunes since it was first int

  • Move Library from old drive to new drive on the same computer

    I have installed a new drive on my current computer system and I somehow can't seem to locate my music library on my old drive. Is there a way to locate the itunes library without having to delete or erase any music? Please help!

  • Using PGP on a BlackBerry 9790, how-to?

    I want to install the PGP Package on my 9790 to encrypt and decrypt emails from my emailbox to another using the public and private keys; is this possible? Does this only work with the applications provided by PGP Corporation, or with the free GPGToo

  • Preflight Droplet/Acrobat Startup Automation Problems

    Hello, We're experiencing some problems regarding preflight droplets not being executed for some instances when the Acrobat XI application (Acrobat Pro XI and Windows XP) is not yet opened before the preflight droplet is executed (Acrobat is started/