Sorting a internal table

hai all
what is the effect of sorting the sorted internal table.
thanks in advance

Hello Sathish,
If u declare an itab as sorted u cannot use the syntax for that itab.
If useful reward.
Vasanth

Similar Messages

  • Sort the internal table based on the vendor field

    hello experts,
    I am stuck with a small problem...
    I am uploading the data for partner association for vendors through lsmw BI program.
    I am collecting all the records in the end of trasaction and downloading all those records on to the apps server.
    I declared one internal table as
    TYPES: BEGIN OF type_erecord,
            mesg(1000) TYPE c,
            END OF type_erecord.
    DATA: t_precord type standard table of type_erecord initial size 0,
                w_precord type type_erecord.
    I am concatenating all the fields and moving to the internal table..
    concatenate zvendor_master-source  zvendor_master-lifnr  blf00-lifnr                   
                      zvendor_master-lname    zvendor_master-parvw
                      zvendor_master-psource  zvendor_master-pname
                      zvendor_master-lifn2        bwyt3-lifn2
                      zvendor_master-ekorg      zvendor_master-werks   
                      w_PLANT-muplant           zvendor_master-defpa
                      v_message
          into w_precord-mesg separated by c_pipe.
          append w_precord to t_precord.
    now at the end I have to sort this internal table t_precord based on blf00-lifnr
    can any one guide me how to do it
    Thanks for your anticipation
    Nitesha

    OK...
    Than you can create one more table and do the process of sorting and than put data into the final table.
    TYPES: BEGIN OF type_erecord,
    mesg(1000) TYPE c,
    END OF type_erecord.
    DATA: t_precord type standard table of type_erecord initial size 0,
    w_precord type type_erecord.
    TYPES: BEGIN OF type_erecord_1,
    mesg(1000) TYPE c,
    lifnr type blf00-lifnr ,  "<<<
    END OF type_erecord_1.
    DATA: t_precord_1 type standard table of type_erecord initial size 0,
    w_precord_1 type type_erecord.
    I am concatenating all the fields and moving to the internal table..
    concatenate zvendor_master-source zvendor_master-lifnr blf00-lifnr
    zvendor_master-lname zvendor_master-parvw
    zvendor_master-psource zvendor_master-pname
    zvendor_master-lifn2 bwyt3-lifn2
    zvendor_master-ekorg zvendor_master-werks
    w_PLANT-muplant zvendor_master-defpa
    v_message
    into w_precord_1-mesg separated by c_pipe.
    w_precord_1-lifnr = blf00-lifnr .  " <<<
    append w_precord_1 to t_precord_1.   " <<<
    SORT T_PRECORD_1 by LIFNR.  " <<
    LOOP AT T_PRECORD_1 into w_precord_1.
      move-corresponing w_precord_1 to w_precord.
      append w_precord to T_PRECORD.
      clear  w_precord .
    endloop.
    Regards,
    Naimesh Patel

  • How to sort an internal table with a header line?

    hi all,
    i have declared table i_bseg type standard table of bseg with header line.
    now i have populated data in i_bseg.
    now i am sorting it by bukrs
    ie i am writing sort i_bseg by bukrs.
    before sorting all i_bseg-belnrs were populated...
    but after sorting the contents of  the i_bseg is changing.
    some of the belnrs are getting deleted..
    is there any special way to sort an internal table with header line...?

    hi,
    <b>SORT <itab> [ASCENDING|DESCENDING] [AS TEXT] [STABLE].</b>
    The statement sorts the internal table <itab> in ascending order by its key.<b> The statement always applies to the table itself, not to the header line</b>.
    If you have an internal table with a structured line type that you want sort by a different key, you can specify the key in the SORT statement:
    SORT <itab> [ASCENDING|DESCENDING] [AS TEXT] [STABLE]
                 BY <f1> [ASCENDING|DESCENDING] [AS TEXT]
                    <fn> [ASCENDING|DESCENDING] [AS TEXT].
    <b>this is your sort statement:  sort i_bseg by bukrs.
    you try with this statement:  sort i_bseg by bukrs STABLE.</b>
    regards,
    Ashokreddy

  • Sorting the internal table I'm getting ......

    While sorting the internal table I'm getting one of the columns not sorted .... why is that? for example
    A   B   C
    9   2    11
    4   9    10
    8   3    7
    using ---> sort itab by A B C. gives me this
    A   B   C
    4   2    7
    8   9    10
    9   3    11
    please help?

    Hi,
    check this code,
    REPORT ZEX31 .
    data : begin of itab occurs 0,
           f1 type i,
           f2 type i,
           f3 type i,
           end of itab.
    itab-f1 = 9 .
    itab-f2 = 2.
    itab-f3 = 11 .
    append itab.
    clear itab.
    itab-f1 = 4 .
    itab-f2 = 9.
    itab-f3 = 10 .
    append itab.
    clear itab.
    itab-f1 = 8 .
    itab-f2 = 3.
    itab-f3 = 7 .
    append itab.
    clear itab.
    loop at itab.
      write : / itab-f1 , itab-f2 , itab-f3.
    endloop.
    sort itab by f1 f2 f3.
    skip 2.
    loop at itab.
      write : / itab-f1 , itab-f2 , itab-f3.
    endloop.
    sorting will be based on the order u give,
    if u give order f1 f2 f3 then first f1 will be checked and sorted in the order of it.
    o/p will be
    4  9  10
    8  3   7
    9  2  11

  • Date sorting in internal table

    Dear Friends
       I wish to know how i perform the date operations in internal table... I am looking for the most recent record from the internal table for that i am supposed to look at chdate and chtime fields gives me the information on most corrently changed record... if  in the case of the record which is there but not changed to determin the its most currentness i must look at the crdate and crtime..so i have the code for that which works perfectly nice without the crdate and crtime... if i insert the crdate and crtime it gives me the only those records which are most currently chnaged according to chdate and chtime...would you like to help me in  this regards, I am giving you the code here.. any suggestion or changes will be great help of mine... thanking you,,,,
    regards naim... the code:
    TYPES: BEGIN OF itab_type,
            id       TYPE i,
            idnumber TYPE i,
            chdate   LIKE sy-datum,
            chtime   LIKE sy-uzeit,
            crdate   LIKE sy-datum,
            crtime   LIKE sy-uzeit.
    TYPES: END OF itab_type.
    DATA: itab     TYPE TABLE OF itab_type WITH HEADER LINE,
          itab_new TYPE TABLE OF itab_type WITH HEADER LINE,
          prev_rec TYPE itab_type.
    DATA: v_id TYPE i.
    START-OF-SELECTION.
      itab-id       = 1.
      itab-idnumber = 123456.
      itab-chdate   = '20060606'.
      itab-chtime   = '135312'.
      itab-crdate   = '00000000'.
      itab-crtime   = '000000'.
      APPEND itab. CLEAR itab.
      itab-id       = 2.
      itab-idnumber = 123456.
      itab-chdate   = '20060606'.
      itab-chtime   = '135900'.
      itab-crdate    = '00000000'.
      itab-crtime    = '000000'.
      APPEND itab. CLEAR itab.
      itab-id       = 3.
      itab-idnumber = 123456.
      itab-chdate   = '00000000'.
      itab-chtime   = '000000'.
      itab-crtime    = '20060622'.
      itab-crdate    = '125412'.
      APPEND itab. CLEAR itab.
      itab-id       = 4.
      itab-idnumber = 123457.
      itab-chdate   = '20060606'.
      itab-chtime   = '140000'.
      itab-crdate    = '00000000'.
      itab-crtime    = '000000'.
      APPEND itab. CLEAR itab.
      itab-id       = 5.
      itab-idnumber = 123457.
      itab-chdate   = '20060606'.
      itab-chtime   = '142500'.
      itab-crdate    = '00000000'.
      itab-crtime    = '000000'.
      APPEND itab. CLEAR itab.
      itab-id       = 6.
      itab-idnumber = 123457.
      itab-chdate   = '20060606'.
      itab-chtime   = '135312'.
      itab-crdate    = '00000000'.
      itab-crtime    = '000000'.
      APPEND itab. CLEAR itab.
      itab-id       = 7.
      itab-idnumber = 123457.
      itab-chdate   = '00000000'.
      itab-chtime   = '000000'.
      itab-crdate    = '20060601'.
      itab-crtime    = '150000'.
      APPEND itab. CLEAR itab.
      itab_new[] = itab[].
      SORT itab_new BY idnumber ASCENDING
                       chdate DESCENDING
                       chtime DESCENDING
                       crdate Descending
                       crtime Descending.
      DELETE ADJACENT DUPLICATES FROM itab_new COMPARING idnumber.
    LOOP AT itab.
         WRITE:/ itab-id,
                 itab-idnumber,
                 itab-chdate,
                 itab-chtime,
                 itab-crdate,
                 itab-crtime.
      ENDLOOP.
    skip 5.
    write: '_______________________________________________________________________________________'.
      LOOP AT itab_new.
        WRITE:/ itab_new-id,
                itab_new-idnumber,
                itab_new-chdate,
                itab_new-chtime,
                itab_new-crdate,
                itab_new-crtime.
      ENDLOOP.

    Hi,
    i modifed your code now see...,Copy paste and see...
    REPORT  ZTESTT                                  .
    TYPES: BEGIN OF itab_type,
    id TYPE i,
    idnumber TYPE i,
    chdate LIKE sy-datum,
    chtime LIKE sy-uzeit,
    crdate LIKE sy-datum,
    crtime LIKE sy-uzeit.
    TYPES: END OF itab_type.
    DATA: itab TYPE TABLE OF itab_type WITH HEADER LINE,
    itab_new TYPE TABLE OF itab_type WITH HEADER LINE,
    prev_rec TYPE itab_type.
    DATA: v_id TYPE i.
    START-OF-SELECTION.
    itab-id = 1.
    itab-idnumber = 123456.
    itab-chdate = '20060606'.
    itab-chtime = '135312'.
    itab-crdate = '00000000'.
    itab-crtime = '000000'.
    APPEND itab. CLEAR itab.
    itab-id = 2.
    itab-idnumber = 123456.
    itab-chdate = '20060606'.
    itab-chtime = '135900'.
    itab-crdate = '00000000'.
    itab-crtime = '000000'.
    APPEND itab. CLEAR itab.
    itab-id = 3.
    itab-idnumber = 123456.
    itab-chdate = '00000000'.
    itab-chtime = '000000'.
    <b>itab-crdate = '20060622'. "here you intechanged the data
    itab-crtime = '125412'.</b>
    APPEND itab. CLEAR itab.
    itab-id = 4.
    itab-idnumber = 123457.
    itab-chdate = '20060606'.
    itab-chtime = '140000'.
    itab-crdate = '00000000'.
    itab-crtime = '000000'.
    APPEND itab. CLEAR itab.
    itab-id = 5.
    itab-idnumber = 123457.
    itab-chdate = '20060606'.
    itab-chtime = '142500'.
    itab-crdate = '00000000'.
    itab-crtime = '000000'.
    APPEND itab. CLEAR itab.
    itab-id = 6.
    itab-idnumber = 123457.
    itab-chdate = '20060606'.
    itab-chtime = '135312'.
    itab-crdate = '00000000'.
    itab-crtime = '000000'.
    APPEND itab. CLEAR itab.
    itab-id = 7.
    itab-idnumber = 123457.
    itab-chdate = '00000000'.
    itab-chtime = '000000'.
    itab-crdate = '20060601'.
    itab-crtime = '150000'.
    APPEND itab. CLEAR itab.
    itab_new[] = itab[].
    SORT itab_new BY
    idnumber
    *chdate DESCENDING
    *chtime DESCENDING
    crdate Descending
    crtime Descending.
    DELETE ADJACENT DUPLICATES FROM itab_new COMPARING idnumber crdate
    crtime.
    *DELETE ADJACENT DUPLICATES FROM itab_new COMPARING idnumber.
    LOOP AT itab.
    WRITE:/ itab-id,
    itab-idnumber,
    itab-chdate,
    itab-chtime,
    itab-crdate,
    itab-crtime.
    ENDLOOP.
    skip 5.
    LOOP AT itab_new.
    WRITE:/ itab_new-id,
    itab_new-idnumber,
    itab_new-chdate,
    itab_new-chtime,
    itab_new-crdate,
    itab_new-crtime.
    ENDLOOP.
    Regards
    vijay

  • Sorting of internal tables

    Dear All,
    i have two internal tables itab1 & itab2.
    ITAB1 is of strecture EBANX, and ITAB2 is declared as fallows:
    TYPES: BEGIN OF gty_temp_stru,
             BANFN TYPE eban-BANFN,
             matnr TYPE eban-matnr,
             werks TYPE eban-werks,
             land1 TYPE t001w-land1,
             taxim TYPE mlan-taxim,
           END OF gty_temp_stru.
    DATA: ITAB2 TYPE TABLE OF GTY_TEMP_STRU,
              GWA_ITAB2 TYPE GTY_TEMP_STRU.
    now once i fetch the data into ITAB2 i have to sort it based on ITAB2-TAXIM.
    based on the result of ITAB2 i have to sort the data in ITAB1.
    How to do this, plz help me in solving the issue.
    Thanks,
    Rama

    Hi Prashant ,
    please go through the below explination
    sort itab2 by taxim.
    sort itab1 by taxim.
    this can not be done, because we don't have the field TAXIM in ITAB1.
    itab1 can have records as fallows
    BANFN          BNFPO   NEW_PO  NEW_ITEM
    9000000011  |  00010 |     X     | space
    9000000012  |  00010 |     space |     X
    9000000013  |  00010 |     space |     X
    9000000015  |  00010 |     space |     X
    9000000014  |  00010 |     X     | space
    9000000016  |  00010 |     space |     X
    and based on the values that we fetch from EBAN, T001W and MLAN into itab2
    we have to sort thouse itab2 results based on the values for TAXIM.
    once the table itab2 is sorted, based on the result we have to sort the table itab1.
    Regards,
    Rama

  • Differences between standard structured sorted hashed internal tables.

    can any one elobrate the differences among them with simple examples.
    why hashed table serch is faster...what happens if list is not sorted...explain the scenarios best suitable ..when we go for what kinda tables...

    <a href="http://www.sap-img.com/abap/what-are-different-types-of-internal-tables-and-their-usage.htm">refer this link for details</a>
    <a href="http://www.geekinterview.com/question_details/1498">also refer this</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb366d358411d1829f0000e829fbfe/content.htm">also this- SAP Help</a>
    regards,
    srinivas

  • Examples of sorted hashed  internal tables

    Hello friends
    Can someone give me an example code in which sorted tables and hashed tables have been used.
    Regards

    hi Surya,
    Sorted tables
    This is the most appropriate type if you need a table which is sorted as you fill it. You fill sorted tables using the INSERT statement. Entries are inserted according to the sort sequence defined through the table key. Any illegal entries are recognized as soon as you try to add them to the table. The response time for key access is logarithmically proportional to the number of table entries, since the system always uses a binary search. Sorted tables are particularly useful for partially sequential processing in a LOOP if you specify the beginning of the table key in the WHERE condition.
    REPORT ZREPORT_SORTED1.
    DATA: BEGIN OF LINE,
    COL1 TYPE I,
    COL2 TYPE I,
    END OF LINE.
    DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.
    DO 4 TIMES.
      LINE-COL1 = SY-INDEX.
      LINE-COL2 = SY-INDEX ** 2.
    INSERT LINE INTO TABLE ITAB.
    ENDDO.
    CLEAR LINE.
    READ TABLE ITAB WITH TABLE KEY COL1 = 3
                    INTO LINE TRANSPORTING COL2.
    WRITE:   'SY-SUBRC =', SY-SUBRC,
           / 'SY-TABIX =', SY-TABIX.
    SKIP.
    WRITE: / LINE-COL1, LINE-COL2.
    The output is:
    SY-SUBRC =    0
    SY-TABIX =       3
             0        9
    REPORT ZREPORT_SORTED2.
    DATA: BEGIN OF LINE,
            COL1 TYPE I,
            COL2 TYPE I,
          END OF LINE.
    DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.
    DO 4 TIMES.
      LINE-COL1 = SY-INDEX.
      LINE-COL2 = SY-INDEX ** 2.
      INSERT LINE INTO TABLE ITAB.
    ENDDO.
    READ TABLE ITAB WITH KEY COL2 = 16  TRANSPORTING NO FIELDS.
    WRITE:   'SY-SUBRC =', SY-SUBRC,
           / 'SY-TABIX =', SY-TABIX.
    The output is:
    SY-SUBRC =    0
    SY-TABIX =       4
    Hashed tables
    This is the most appropriate type for any table where the main operation is key access. You cannot access a hashed table using its index. The response time for key access remains constant, regardless of the number of table entries. Like database tables, hashed tables always have a unique key. Hashed tables are useful if you want to construct and use an internal table which resembles a database table or for processing large amounts of data.
    REPORT ZREPORT_HASHED1.
    DATA: BEGIN OF LINE,
    COL1 TYPE I,
    COL2 TYPE I,
    END OF LINE.
    DATA ITAB LIKE HASHED TABLE OF LINE WITH UNIQUE KEY COL1.
    DO 4 TIMES.
      LINE-COL1 = SY-INDEX.
      LINE-COL2 = SY-INDEX ** 2.
    INSERT LINE INTO TABLE ITAB.
    ENDDO.
    LINE-COL1 = 2. LINE-COL2 = 3.
    READ TABLE ITAB FROM LINE INTO LINE COMPARING COL2.
    WRITE: 'SY-SUBRC =', SY-SUBRC.
    SKIP.
    WRITE: / LINE-COL1, LINE-COL2.
    The output is:
    SY-SUBRC =    2
             2        4
    REPORT ZREPORT_HASHED2.
    DATA: BEGIN OF LINE,
    COL1 TYPE I,
    COL2 TYPE I,
    END OF LINE.
    DATA ITAB LIKE HASHED TABLE OF LINE WITH UNIQUE KEY COL1.
    FIELD-SYMBOLS <FS> LIKE LINE OF ITAB.
    DO 4 TIMES.
      LINE-COL1 = SY-INDEX.
      LINE-COL2 = SY-INDEX ** 2.
    INSERT LINE INTO TABLE ITAB.
    ENDDO.
    READ TABLE ITAB WITH TABLE KEY COL1 = 2 ASSIGNING <FS>.
    <FS>-COL2 = 100.
    LOOP AT ITAB INTO LINE.
      WRITE: / LINE-COL1, LINE-COL2.
    ENDLOOP.
    The output is:
             1        1
             2      100
             3        9
             4       16
    Regards
    vijay

  • SORT DYNAMIC INTERNAL TABLE

    Hello everybody.
    How can I sort a dynamic internal table ???
    The sentence sort <gt_table> by matnr werks doesn' t work... How can I do it ??
    Thanks a lot.
    Regards

    Here is an example:
    PARAMETERS dbtab TYPE c LENGTH 30.
    SELECT-OPTIONS columns FOR dbtab NO INTERVALS.
    DATA: otab TYPE abap_sortorder_tab,
    oline TYPE abap_sortorder,
    dref TYPE REF TO data.
    FIELD-SYMBOLS: <column> LIKE LINE OF columns,
    <itab> TYPE STANDARD TABLE.
    TRY.
    CREATE DATA dref TYPE STANDARD TABLE OF (dbtab).
    ***I have assigned the value dref to internal table as follows***
    ASSIGN dref->* TO <itab>.
    CATCH cx_sy_create_data_error.
    MESSAGE 'Wrong data type!' TYPE 'I' DISPLAY LIKE 'E'.
    LEAVE PROGRAM.
    ENDTRY.
    TRY.
    SELECT *
    FROM (dbtab)
    INTO TABLE <itab>.
    CATCH cx_sy_dynamic_osql_semantics.
    MESSAGE 'Wrong database table!' TYPE 'I' DISPLAY LIKE 'E'.
    LEAVE PROGRAM.
    ENDTRY.
    LOOP AT columns ASSIGNING <column>.
    oline-name = <column>-low.
    APPEND oline TO otab.
    ENDLOOP.
    TRY.
    SORT <itab> BY (otab).
    CATCH cx_sy_dyn_table_ill_comp_val.
    MESSAGE 'Wrong column name!' TYPE 'I' DISPLAY LIKE 'E'.
    LEAVE PROGRAM.
    ENDTRY.

  • Sorting an internal table by date.

    SORT it_stpo BY andat stpoz DESCENDING.
          before sort
        DATUV    ANDAT    STLKN    STPOZ   
    1. 20020118|20020118|00000002|00000004|
    2. 20060711|20060811|00000004|00000008|
    3. 20060801|20060811|00000005|00000011
    4. 20020515|20020515|00000003|00000006
    AFTER SORT..
       DATUV    ANDAT    STLKN    STPOZ   
    1.  20020118|20020118|00000002|00000004
    2.  20020515|20020515|00000003|00000006|
    3. 20060801|20060811|00000005|00000011
    4. 20060711|20060811|00000004|00000008|
    what I expected was to see Record # 3 as my first record after the sort ?
    Any ideas?

    Hello J.J
    The explicit version of your SORT statement is:
    SORT it_stpo BY andat ASCENDING
                    stpoz DESCENDING.
    Because ASCENDING is the default sorting direction.
    If you want to sort all fields of your itab in descending order your statement must look like:
    SORT it_stpo DESCENDING BY andat
                               stpoz.
    Regards
        Uwe

  • How to sort an Internal table Based on a One Char Trans type in the rec?

    Meaning, ascending descending will not work, lets say itab_A has the order O-H-W-G-I-A, and I want it to write it to itab_B to the correct order, G-H-O-I-A-W.
    I know I can do loop at itab_A where for each one and write it, but is their a better way?
       Thank-You

    if you know the correct order play with index in the itab_A and append to itab_B
    loop at itab_A index X.
    blah.. blah..
    endloop.
    or
    itab_temp [] =  itab_A[].
    delete itab_temp where index <> 'X'.
    append itab_temp to itab_B.
    refresh itab_temp[].
    itab_temp [] =  itab_A[].
    delete itab_temp where index <> 'Y'.
    append lines of  itab_temp to itab_B.
    refresh itab_temp[].

  • SORT INTERNAL TABLE USING NON KEY OF THE INTERNAL TABLE

    HI,
    i have one query for the cdpos table of abap.
    What i am looking is i want the latest CHANENR of the cdpos for that
    objectid  and tabname and fname in my internal table.
    what i thought of doing was to sort my internal table with objectid changnr tabname fname in descending order
    and than use delete adjacent duplicates command
    BUt that is not sorting based on all field , its sorting on changnr only
    please let me know what can i do

    no, that is not what i am looking at,
    I am saying say i have internal table cdpos
    OBJECTCLAS      OBJECTID    CHANGENR   TABNAME                        FNAME
    RECN_RECN      |0100TEST1   0000384409|    VICN01                        |RECNEND
    RECN_RECN       0100TEST1   0000383462    VICN01                          RECNLIFNR 
    RECN_RECN       0100TEST1    0000360190   VICN01                         RECNEND
    RECN_RECN        0100TEST1   0000340630    VICN01                         RECNEND
    this is my debug output after sorting on objectid changenr tabname fname in descending
    i wanted line 2nd to be at last so when i use delete adjacent command i can get 2 line item i.e 1st and 2nd line ...

  • Regarding the sorting of the internal table

    hi,
       this is my requirement
    iam having an internal table itab and it consists of the date field s_date.
    i have to sort the internal table in the descending order of the s_date.
    please provide me the code for this.
    thanks in advance

    Hi Surya,
    U can use this code
    SORT ITAB BY S_DATE DESCENDING.
    itab----internal table
    S_date--Field name
    By default the sorting is done ascending you dont have to specify.
    Thanks
    Mohinder Singh Chauhan

  • Hashed & sorted internal tables

    hi all,
        can any body help me to understand the concept of <b>hashed & sorted</b> internal table  & how they can be used for improve the performance of report.
    regards
    Deepak

    Hi Deepak,
    If you have an internal table in your program which is used solely for lookup, it is good programming practice to use a hash table. The example below shows this, in combination with a method for buffering SELECT SINGLE results.
    Code
    *&      Form  select_dispo
          Get MRP controller and in-house production time from material
          and plant
         --> MATNR  Material
         --> RESWK  Plant
         <-- DISPO  MRP controller
         <-- DZEIT  In-house production time
    form select_from_marc using matnr werks dispo dzeit.
      types: begin of mrp_lookup_type,
               matnr like marc-matnr,
               werks like marc-werks,
               dispo like marc-dispo,
               dzeit like marc-dzeit,
             end of mrp_lookup_type.
    Define static hashed table to hold results
      statics: st_mrp type hashed table of mrp_lookup_type
                      with unique key matnr werks.
      data: l_wa_mrp type mrp_lookup_type.
      clear dzeit.
    See if data is in the table
      read table st_mrp into l_wa_mrp with table key matnr = matnr
                                                     werks = werks.
    If not in table, get it from the database
      if not sy-subrc is initial.
        select single dispo dzeit from marc
            into corresponding fields of l_wa_mrp-dispo
            where matnr eq matnr
              and werks eq werks.
    Insert into table
        l_wa_mrp-matnr = matnr.
        l_wa_mrp-werks = werks.
        insert l_wa_mrp into table st_mrp.
      endif.
      dispo = l_wa_mrp-dispo.                      " MRP Controller
      dzeit = l_wa_mrp-dzeit.                      " Inhouse production time
    endform.                    " select_from_marc

  • Sorting internal table

    Hi all,
    I have a scenario wherein i have to sort the internal table without using the sort function( i.e sort syntax).Is there any logic.
    Can nebody pls help me out.
    Regards
    Jak

    Hai,
    To understand bubble sort, think of an air bubble rising in water
    To sort N items, N passes are made through the data.
    The result of the first pass is that the smallest item is in the last location of the array.
    The result of the second pass is that the second smallest item is in the second last location of the array.
    etc.
    After N passes, the entire array is sorted.
    The operation in each pass is as follows:
    First, the values in the first two locations are compared. If necessary the values are exchanged, so that the smaller one is last.
    Then, the values in the second and third locations are compared. If necessary the values are exchanged, so that again the smaller one is last.
    This process repeats to the end of the array.
    In effect, the smaller item bubbles its way towards the top. It keeps on going until either it reaches the top (and the pass ends), or it strikes a smaller item. In that case it stops itself, and gives that smaller item a nudge to start it on its way.
    If a complete pass is made without any exchanges being made, the data must already be sorted. This is easily checked. Thus it might be possible to halt the algorithm without going through all N passes.

Maybe you are looking for

  • Adobe Photoshop Elements 10 Language Problem

    Hi all! I've a problem with Adobe Photoshop Elements 10 Editor. I bought Elements 10 Editor from the app store (I've a Mac) some months ago and I chose the english language during the installation. Today it happened that, when I opened it, I found it

  • File Adapetr: File is not picking from File directory

    Hello, Issue: we are facing issue with file sender adapter like file is not picking from source file directory. Scenario: FTP1>PI>FTP2 1. SAP PI sender communication channel will pick the file from FTP1 and process to PI file server (NFS) 2. from PI

  • Mapping keyboard and mouse keys onto my gamepad

    I'm using arch linux x86_64 and I want to map some keyboard and mouse keys onto my gamepad to play games which don't support the gamepad directly. How can I do this?

  • What is the Lumia 520 Music Subscription period..

    Hi, I recently bought a new lumia 520 and the music account activated saying "Nokia music unlimited subscription activated." 1)What is the correct period of such subscription? 2) when i logged in again , it said  "Subscription ends on Jan 01". That i

  • Built-in restore session hangs/freezes with too many tabs in Fx 29

    Hi, I've used the Session Manager add on for awhile, ever since a previous 'upgrade' to Firefox tended to not save sessions after a crash. The upgrade to version 29 has rendered Session Manager unusable, as documented here: https://support.mozilla.or