Internal table permutations: for experts

Hi all,
i have an internal table with 10 values.
I want to have all permutations. There are 10! possibilities.
How can i calculate this?
regards

I'm not sure about what you need...It could something like this???
TYPES: BEGIN OF ty_table,
       value TYPE string,
       END OF ty_table.
DATA: t_table TYPE STANDARD TABLE OF ty_table
      WITH HEADER LINE.
DATA: counter TYPE sy-tabix,
      count TYPE sy-tabix,
      value TYPE string,
      perm TYPE string.
FIELD-SYMBOLS: <fs_table> LIKE LINE OF t_table.
DO 10 TIMES.
  counter = counter + 1.
  t_table-value = counter.
  APPEND t_table.
ENDDO.
LOOP AT t_table ASSIGNING <fs_table>.
  CLEAR count.
  value = <fs_table>-value.
  CONCATENATE perm value
  INTO perm SEPARATED BY '-'.
  DO 10 TIMES.
    count = count + 1.
    READ TABLE t_table INDEX count.
    IF value NE t_table-value.
      CONCATENATE perm t_table-value
      INTO perm SEPARATED BY '-'.
      CONDENSE perm NO-GAPS.
    ENDIF.
  ENDDO.
  SHIFT perm LEFT DELETING LEADING '-'.
  WRITE:/ perm.
  CLEAR perm.
ENDLOOP.
Result...
1-2-3-4-5-6-7-8-9-10
2-1-3-4-5-6-7-8-9-10
3-1-2-4-5-6-7-8-9-10
4-1-2-3-5-6-7-8-9-10
5-1-2-3-4-6-7-8-9-10
6-1-2-3-4-5-7-8-9-10
7-1-2-3-4-5-6-8-9-10
8-1-2-3-4-5-6-7-9-10
9-1-2-3-4-5-6-7-8-10
10-1-2-3-4-5-6-7-8-9
Greetings,
Blag.

Similar Messages

  • Internal table problem for BDC

    Hai i am having flatfile like this format
    H   text1   1000   plant_name   10 short_text   X     X
                                                     20 short_text   X     X
                                                     30 short_text   X     X
    H   text1   1000   plant_name   10 short_text   X     X
                                                     20 short_text   X     X
                                                     30 short_text   X     X
    now this H indicates new record. In each new record number of line items are there.
    How to proceed using internal tables. please help me.

    hi,
    arrange your flat file like this...
    H    text1 1000  plant_name  10  short_text X X
    H    text1 1000  plant_name  20 short_text  X X
    H    text1 1000  plant_name  30 short_text  X X
    H1  text1 1000  plant_name  10 short_text  X X
    H1  text1 1000  plant_name  20 short_text  X X
    H1  text1 1000  plant_name  30 short_text  X X
    now make an internal table having all the fields present in your flat file
    and loop at that internal table and on change of field H call your function module and pass the value for record H......
    similarly it will work for H1.....H2.....
    for eg...
    LOOP AT "Your internal table" INTO "Work area of your internal table".
        AT END OF "field name for H".
          CALL FUNCTION ''Your function module"

  • Internal Table - logic for Chunk

    Hi,
    I have an internal table with n records.
    I want to use at a time say max of 20 records .
    This is calling a BDC.
    i.e.
    loop at n record.
    take 20 records.
    call BDC.
    then next set of recrds.
    repeat process till all records processed.
    Thanks in Advance.
    Amit

    Hi,
    try this way.
    data: count type i.
    loop at table
      if count LE 20.
        add 1 to count.
      else.
        clear count.
        call bdc.
        "refresh all the concerned tables and variables for the next 20 records.
      endif.
    endloop.
    Or.
    loop ...
    WHILE count le 20.  
       ADD 1 TO count.
    ENDWHILE.                   
        clear count.
        call bdc.
        "refresh all the concerned tables and variables for the next 20 records.
    endloop
    Regards.
    Marcelo Ramos

  • Populating Empty Fields for Existing Internal Table Using For All Entries

    I have an internal table called itab_extract that populates without any issues in SELECT A and SELECT B below. Trying to avoid looping, I am using select DB table 'for all entries' in itab_extract. I want the empty fields in itab_extract to populate from the values in the database. However, about 200,000 entries are being appended to the table, and, the values that existed for the already populated fields in itab_extract are gone, and the new fields are populated.
    I've played with the syntax and cannot seem to get it to work. My next option is a time consuming loop.
    How should the for all entries syntax look to accomplish filling the empty fields in the itab?   Thank-You
    *read ekko
        select ebeln lifnr aedat bsart from ekko                                                     *SELECT A*
               into  CORRESPONDING FIELDS OF TABLE me->itab_extract
               where aedat in r_aedat.
        select ebeln lifnr aedat BSART from ekko                                                  *SELECT B*
               appending CORRESPONDING FIELDS OF TABLE me->itab_extract
               where aedat in S_DATE2 AND
                     BSART IN S_BSART.
          select ebelp werks matnr                                                                           *SELECT C*
            into CORRESPONDING FIELDS OF TABLE itab_extract
            from ekpo
            FOR ALL ENTRIES IN itab_extract
            where ebeln = itab_extract-ebeln.

    Hi Tom,
               This SQL statement will be time consuming, Do not use a loop.
    There are two options.
    1. Select EKKO and EKPO details based on standard SAP view. (You can type EKKO in se11 view to find the correct view).
        also use one range table populate r_aedat and s_date2 in the same. So you where condition will have r_newrange and   
        s_bsart. Also do not use into corresponding fields, it is not a good idea. It will increase your performance. Maintain the proper 
        sequence (Based on database structure of EKKO and EKPO)
    2. If you are keen to use for all entries, then first select ekko then after your sy-subrc check get the data from EKPO.
    Should be like this.
    select ebeln bsart aedat lifnr from ekko into table gt_ekko where aedat in r_newrange and bsart in s_bsart.
    if sy-subrc eq 0.
    sort gt_ekko by ebeln ascending.
    select ebeln ebelp werks matnr  into table gt_ekpo for all entries in gt_ekko where ebeln eq gt_ekko-ebeln.
    endif.
    Hope it helps,
    Best Regards,
    Tapodipta Khan.

  • How to use dynamic internal table with FOR ALL ENTRIES

    Hello SDNers,
    I am having a dynamic internal table & want to use FOR ALL ENTRIES(FAE) using this dyn. table.
    This works fine for me:
    IF <lt_tmp> IS NOT INITIAL. "<lt_tmp> is my dyn. internal table
            SELECT field1 field2
              FROM TABLE ztable
              INTO TABLE itab "Itab is a static table
              FOR ALL ENTRIES IN <lt_tmp>
              WHERE (lv_dynwhere). "lv_dynwhere -> dynamic where clause
          ENDIF.
    SAP documentation says:
    "The logical expression sql_cond of the WHERE condition can be comprised of several logical expressions using AND and OR. However, if FOR ALL ENTRIES is specified, there must be at least one comparison with a column of the internal table itab that can be specified statically or dynamically. "
    How do we specify the column of the internal table dynamically ? Can we do something like this:
    IF <lt_tmp> IS NOT INITIAL. "<lt_tmp> is my dyn. internal table
            SELECT field1 field2
              FROM TABLE
              INTO TABLE itab "Itab is a static table
              FOR ALL ENTRIES IN <lt_tmp>
              WHERE key_field1 = (dynamic token for column1 of <lt_tmp>)
                           key_field2 = (dynamic token for column2 of <lt_tmp>)
          ENDIF.
          ENDIF.
    Let me know if i am not clear about my requirement.
    BR,
    Suhas

    Hello Thomas,
    What i meant was something like this:
    WHERE key_field1 = ('<LT_TMP-COL1>') AND
          key_field2 = ('<LT_TMP-COL2>')
    I am confused by what SAP means with "dynamic representation of internal table columns" in FAE ?
    @Rob: I was referring to SAPNW 7.0 documentation & the phrase (release 6.40 & higher) is missing. Anyways fyi i am on ECC5.0 ABAP release 6.40.
    @Subhankar: This is what Marcin had proposed in For all entries and dynamic table.
    Thanks,
    Suhas
    Edited by: Suhas Saha on Apr 6, 2010 11:53 AM

  • Internal table handling for table controls

    hi,
    can any one say me how we manage to store one header data and more than one line item data in one internal table. pls provide me one example with code.
    thanks,

    You need to make sure that table t_open_summ contains only the data for PO =xxxx matnr=xxx to begin with. I.e. when that table is filled in, just don't put any other data there. Then all the corresponding scrolling code (Page Up/Down) will work as usual.
    As an alternative, you could create a "clone" of t_open_summ and work with it instead.

  • Create internal table dynamically for IDoc fields

    Hi,
    I need to create an internal table dynamically based on the segment field names that are returned in the table pt_fields when calling function 'IDOCTYPE_READ_COMPLETE'.  I see many posts suggesting classes such as 'cl_wrf_dynamic_table=>create_dynamic_table', but it does not work for me.  The problem I have with the classes is that it doesn't allow you to have the same column name more than once.  But in the scenario I am testing, I have some column names that are duplicated, and I cannot remove the duplicates.  Are there any functions or classes that I can use to create a dynamic internal table that will not check if a column name is used twice?
    Thanks,
    Carrie

    Hello Carrie
    My first thought was that RTTI might be able to do this but it does not (see the dump below). And it is obvious that RTTI behave likes this.
    Error analysis
        An exception occurred which is explained in detail below.
        The exception, which is assigned to class 'CX_SY_STRUCT_COMP_NAME', was not
         caught and
        therefore caused a runtime error.
        The reason for the exception is:
        Multiple Specification of the Name 'CUSTOMER' as a Component Name (Component 7)
    Just think about any way  to define statically an itab or structure containing duplicated field names. You will always get a syntax error irrespective of whether you use a DDIC structure, a TYPE or a DATA variable.
    If there is no way to define such a structure statically why should it be different when defining dynamically?
    Regards
      Uwe

  • How to delete entries in an internal table except for one entry

    Hi all,
    I have 4 records in my internal table and I need to delete all the  records in the internal table except the last one.How do i do this?Any sample code?
    Thanks.
    Moderator message - Please do not ask or answer basic questions - thread locked
    Edited by: Rob Burbank on Dec 16, 2009 3:23 PM

    Hi,
      use following logic:
    DATA: lt_itab type standard table.
    DATA: l_lines type i.
    DESCRIBE TABLE lt_itab lines l_lines.
    l_lines = l_lines - 1.
    delete lt_itab from 1 to l_lines.
    Regards,
      Karol

  • Query statement for internal table

    is it possible to use a select statement to select data from an internal table? if yes, can anyone show me the codes to it? thx

    Hi Daphne,
    You use SELECT statement to read data from database table but not from Internal table.
    For reading data from Internal table, you have to use READ statement.
    Syntax:
    READ TABLE itab { table_key
                    | free_key
                    | index } result.
    Effect of using read statement:
    This statement reads a row from internal table itab. You have to specify the row by either naming values table_key for the table key, a free condition free_key or an index index. The latter choice is possible only for index tables. The output result result determines when and where the row contents are read.
    If the row to be read is not uniquely specified, the first suitable row is read. In the case of index tables, this row has the lowest table index of all matching rows.
    Reward if usefull
    thanks
    swaroop

  • Doubt for internal table

    hi abap gurus,
      Consider u have 2 internal tables (one for Header Data, other one
          for Line Item)
       How to transfer the Header & its corresponding Item data
            to third Internal table
    thanks and regards,
    bala

    Hi Bala,
    DATA : BEGIN OF IT_LIKP OCCURS 0,  "1st internal table
           FIELD1,
           FIELD2,
           FIELD3, ETC....
           END OF IT_LIKP.
    DATA : BEGIN OF IT_VBPA OCCURS 0,  "2nd internal table
           FIELD1,
           FIELD2,
           FIELD3, ETC....
        END OF IT_VBPA.
    DATA : BEGIN OF IT_FINAL OCCURS 0, "3rd internal table
           FIELD1,
           FIELD2,
           FIELD3, ETC....
    END OF IT_FINAL.
    SELECT STATEMENTS ON FIRST 2 INTERANL TABLES AND THEN PASS THE DATA IN THE FINAL INTERNAL TABLE IE IT_FINAL.
    THEN WITH IT_FINAL TABLE DISPLAY THE DATA.
      LOOP AT IT_LIKP.
        IT_FINAL-VBELN = IT_LIKP-VBELN.
        IT_FINAL-WADAT_IST = IT_LIKP-WADAT_IST.
        IT_FINAL-KUNNR = IT_LIKP-KUNNR.
        IT_FINAL-NAME1 = IT_LIKP-NAME1.
        IT_FINAL-VBELN_S = IT_LIKP-VBELV.
        IT_FINAL-ERDAT = IT_LIKP-ERDAT.
        READ TABLE IT_VBPA WITH KEY VBELN = IT_LIKP-VBELV BINARY
        SEARCH.
        IF SY-SUBRC = 0.
          IT_FINAL-KUNN2 = IT_VBPA-KUNNR.
          IT_FINAL-NAME2  = IT_VBPA-NAME1.
        ENDIF.
        APPEND IT_FINAL.
        CLEAR IT_FINAL.
      ENDLOOP.
    Thanks
    Vikranth Khimavath

  • Read Internal Table based on Multiple Values for Key Field

    Hi Gurus,
    i have one query can you tell me how read an internal table it_kna1 for multiple values of land1 DE US IND etc.
    i had tried as below but i could not can you try and let me knwo at the earliest.
    here i want read the values with DE or US and want further prosess them.
    REPORT  YC001.
    tables kna1.
    select-options: cust for kna1-kunnr.
    data: begin of it_kna1 occurs 0,
            kunnr like kna1-kunnr,
            name1 like kna1-name1,
            land1 like kna1-land1,
            end of it_kna1.
    select kunnr name1 land1 into table it_kna1 from kna1 where kunnr in cust.
    read table it_kna1 with key land1 = ( 'DE' OR 'US' ) .
    can anybody suggest me some solution.
    Thanks,
    Jeevi.

    This should be what you need:
    REPORT ztest NO STANDARD PAGE HEADING LINE-SIZE 80 MESSAGE-ID 00.
    TABLES kna1.
    SELECT-OPTIONS: cust FOR kna1-kunnr.
    DATA: BEGIN OF it_kna1 OCCURS 0,
            kunnr LIKE kna1-kunnr,
            name1 LIKE kna1-name1,
            land1 LIKE kna1-land1,
          END OF it_kna1.
    DATA: itab_index LIKE sy-tabix.
    SELECT kunnr name1 land1
      INTO TABLE it_kna1
      FROM kna1
      WHERE kunnr IN cust.
    SORT it_kna1 BY land1.
    READ TABLE it_kna1 WITH KEY
      land1 = 'DE'
      BINARY SEARCH.
    itab_index = sy-tabix.
    WHILE sy-subrc = 0.
      itab_index = itab_index + 1.
      WRITE: /001 it_kna1-kunnr, it_kna1-land1, it_kna1-name1.
      READ TABLE it_kna1 INDEX itab_index.
      IF it_kna1-land1 <> 'DE'.
        sy-subrc = 99.
      ENDIF.
    ENDWHILE.
    SKIP 1.
    READ TABLE it_kna1 WITH KEY
      land1 = 'US'
      BINARY SEARCH.
    itab_index = sy-tabix.
    WHILE sy-subrc = 0.
      itab_index = itab_index + 1.
      WRITE: /001 it_kna1-kunnr, it_kna1-land1, it_kna1-name1.
      READ TABLE it_kna1 INDEX itab_index.
      IF it_kna1-land1 <> 'US'.
        sy-subrc = 99.
      ENDIF.
    ENDWHILE.
    Rob

  • Extract Cube data for all entries of an internal table

    Hi
    I want to fetch the data from the cube for all entries of another internal table.
    Scenario : Fetching the COMPANY_CODE and DATE into an internal table and for those company codes and Dates, I have to fetch the records of the Cube.,
    I am using the Function Module : RSDRI_INFOPROV_READ
    But not sure how to accommodate the multiple selections condition for this.
    Selection Required:
                                    *For all entries of it_cc
                                      where comp_code = it_cc-comp_code and
                                                  date = it_cc-date.*
    Please help me how to such multiple conditions and "for all entries" functionality for fetching the data from the cube.
    Thanks.
    Veera Karthik G

    HI
    You can try like this
    LOOP AT lt_donotcall_old .
    <ls_donotcall>-examination_date = sy-date.
    <ls_donotcall>-examination_time = sy-time.
    ENDLOOP.
    append it_donotcall_old.
    Reward all helpfull answers
    Regards
    Pavan

  • Divide the internal table for months

    How to divide the internal table itab for the months?
    I have a field data in internal table itab and now i have need to divide itab in n table for months.
    The data interval is max 4 months.
    Sorry for my english.
    ex. itab.
    data: begin of itab occurs 0,
                 data LIKE vbak-erdat,
                 num_ord LIKE vbap-vbeln,
                 gruppo LIKE mara-labor,
            end of itab.

    I have solved in this method:
    SORT tab_gia DESCENDING BY data.
      tmp_mese = tab_gia-data+4(2).
      LOOP AT tab_gia.
        IF tmp_mese EQ tab_gia-data+4(2).
          IF flag1 = 'TRUE'.
            MOVE tab_gia-data     TO mese1-data.
            MOVE tab_gia-gruppo   TO mese1-gruppo.
            MOVE tab_gia-tipo     TO mese1-tipo.
            MOVE tab_gia-matnr    TO mese1-matnr.
            MOVE tab_gia-giacenza TO mese1-giacenza.
            APPEND mese1.
          ENDIF.
          IF flag2 EQ 'TRUE'.
            MOVE tab_gia-data     TO mese2-data.
            MOVE tab_gia-gruppo   TO mese2-gruppo.
            MOVE tab_gia-tipo     TO mese2-tipo.
            MOVE tab_gia-matnr    TO mese2-matnr.
            MOVE tab_gia-giacenza TO mese2-giacenza.
            APPEND mese2.
          ENDIF.
          IF flag3 EQ 'TRUE'.
            MOVE tab_gia-data     TO mese3-data.
            MOVE tab_gia-gruppo   TO mese3-gruppo.
            MOVE tab_gia-tipo     TO mese3-tipo.
            MOVE tab_gia-matnr    TO mese3-matnr.
            MOVE tab_gia-giacenza TO mese3-giacenza.
            APPEND mese3.
          ENDIF.
          IF flag4 EQ 'TRUE'.
            MOVE tab_gia-data     TO mese4-data.
            MOVE tab_gia-gruppo   TO mese4-gruppo.
            MOVE tab_gia-tipo     TO mese4-tipo.
            MOVE tab_gia-matnr    TO mese4-matnr.
            MOVE tab_gia-giacenza TO mese4-giacenza.
            APPEND mese4.
          ENDIF.
        ELSE.
    * trovato un altro mese.
          cnt = cnt + 1.
          tmp_mese = tab_gia-data+4(2).
          CASE cnt.
            WHEN 2.
              flag1 = 'FALSE'.
              flag2 = 'TRUE'.
            WHEN 3.
              flag2 = 'FALSE'.
              flag3 = 'TRUE'.
            WHEN 4.
              flag3 = 'FALSE'.
              flag4 = 'TRUE'.
          ENDCASE.
        ENDIF.
      ENDLOOP.
    thanks!!!
    Edited by: Alfonso Manzo on May 28, 2008 1:51 PM
    Edited by: Alfonso Manzo on May 28, 2008 1:52 PM

  • Statistics setup for 2LIS_11 and no storage space available internal table

    Hi, I am running statistical setup for 2LIS_11_VAITM. It ran for 10 hours and failed with an ABAP run time error. The error is "no storage space available for extending an internal table". For 11 application, the selection options is sales org, company code and sales document. We have tried twice, and already drilled down to the level of sales org and company code, but still with error.
    The only option is sales documents.
    The volume of the data is 16 million records around in VBAP table which needs to be in the setup table.
    What is the criteria to categorize the sales document.
    Can we use order types? We have 200 values in the order types. And I am not sure the document ranges in each order type is clearly defined and not overlapping each other, so that we could load those in the setup table.
    Please advise!! Or if you have other suggestions!
    Thanks!

    Hi
    It could be because of main memory problem... so Restrict your selections and do the statistical setup
    by the way how many comp codes you have? restrict with comp codes or doc ranges
    Thanks,

  • With in the internal table can I READ the same internal table for a record?

    With in the internal table can I READ the same internal table?
    For Suppose
    LOOP AT itab.
    can I do as below
    READ TABLE itab with key bukrs = itab-bukrs
                       belnr = itab-belnr.
    *and I have to compare
    IF itab-shkzg = itab-shkzg_ia.
    ENDIF.
    ENDLOOP.

    Hi,
    Yes..But use work area to differentiate..
    EX.
    DATA: WA LIKE ITAB.
    DATA: WA_READ LIKE ITAB.
    LOOP AT itab <b>INTO WA</b>.
    can I do as below
    READ TABLE itab <b>INTO WA_READ</b>
               with key bukrs = itab-bukrs
    belnr = itab-belnr.
    *and I have to compare
    IF <b>WA</b>-shkzg = <b>WA_READ</b>-shkzg_ia.
    ENDIF.
    ENDLOOP.
    Please reward for helpful answers.
    Thanks,
    Naren

Maybe you are looking for