Loop at itab in a Smarform problem

Hi Guys,
Right now i'm developing my first OO program that calls a Smartform, but I'm having the following issue.
I call a method exporting the internal table that i want to pass to the SF, but when i want to make a loop statement in the SF I get a dump. I asked some friends and they told me that right now is obsolete the table statement, so i declare in the SF in the importing tab and then declare it in the exporting part of the FM that calls the SF.
Now when i try to activate the SF i guet the following error: "You may only read from table "IT_GRID1". - reading.".
so my question is, how can i declare my itab in order to be able to add a loop statement?.
Regards,
Eric

Hi Subramanian,
At first I did what you suggest, but for a reason that I can`t explain, when the loop begins I always get a dump. The only way that i could make the dump disappear was by replacing the name of the parameter that I receive from the method for the original table.
Example:
" I call the method in the main method.
       lcl_reporte_auditoria=>llamar_sf( EXPORTING
                                                           table = it_sf ).
  METHOD llamar_sf.
*   Llamar al Formulario
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        formname           = 'ZQM_RPT_AUDITORIA_LLANTA_VERDE'
      IMPORTING
        fm_name            = fm_name
      EXCEPTIONS
        no_form            = 1
        no_function_module = 2
        OTHERS             = 3.
*¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯*
* CONFIGURO LOS OPARAMETROS DE SALIDA PARA Q NO APAREZACA       *
* LA CAJA DE DIALOGO DE LA IMPRESION                            *
    wa_ssfctrlop-device     = 'PRINTER'.
    wa_ssfctrlop-langu      = sy-langu.
    wa_ssfctrlop-replangu1  = sy-langu.
    wa_ssfctrlop-replangu2  = sy-langu.
    wa_ssfctrlop-replangu3  = sy-langu.
    wa_ssfctrlop-no_dialog  = 'X'.      "SIN DIALOGO
    wa_ssfctrlop-preview    = 'X'.      "VISTA PREVIA
    wa_ssfcompop-tddest     = 'LOCL'.   "LOCAL AL PC
    wa_ssfcompop-tdimmed    = 'X'.      "IMPRESION IMEDIATA
    CALL FUNCTION fm_name
      EXPORTING
        control_parameters = wa_ssfctrlop
        output_options     = wa_ssfcompop
        user_settings      = ''
      TABLES
        it_grid1               = table
      EXCEPTIONS
        formatting_error   = 1
        internal_error     = 2
        send_error         = 3
        user_canceled      = 4
        OTHERS             = 5.
  ENDMETHOD.                    "llamar_sf
In this case I get a dump as soon as the SF reach the loop statement. If I change the
TABLES
it_grid1 = table
for
TABLES
it_grid1 = it_sf
The dump doesn't appear anymore.
The dump says: MOVE_TO_LIT_NOTALLOWED_NODATA
Assignment error: Overwriting a protected field.
At that moment a friend told me that the table statement was obsolete in OO programing, and encourage me to change it for a exporting parameter. This is the reason why i'm doing it, please anyone tell me is that affirmation is correct. Otherwise, could someone explain me why i'm getting that error when i export the table that i'm receiving in the method call.
Regards,
Eric
Message was edited by:
        Eric Hernandez Pardo

Similar Messages

  • Problem in select  statment & loop of itab.

    Hi all,
          I am having on ITAB1  for, ex which is having five line items or more  .
    iam also using select statment SINGLE statment for 7 times ,to select values for
    different data base  table.
    for ex,
    loop at itab.
       1---> SELECT SINGLE Z_CTRY_ORIG INTO LS_PSHDESN-Z_CTRY_ORIG FROM ZLE_PART_MST
      WHERE                           WERKS        = ITAB1-LGNUM
      AND                                 MATNR        = ITAB1-MATNR .
    2---
    3---
    4---
    endloop
    i want to remove from the loop statment  and i have to select  the datas ..
    can any one sugesset some possible ways....
    regards
    veera

    hi,
    Solution:
    Never use select single in loop at itab!! for that :
    Solution 1:
    say ur main table is ITAB and rferring  this u want to select data from other tables.
    SELECT SINGLE Z_CTRY_ORIG INTO LS_PSHDESN-Z_CTRY_ORIG FROM ZLE_PART_MST
    into table itab2
    FOR ALL ENTRIES IN ITAB
    WHERE WERKS = ITAB-LGNUM
    AND MATNR = ITAB-MATNR.
    With this what will hapeen , u will get all records in itab2 which u can update itab1(master) using loop.
    solution 2:
    Instead of all this use JOINs in select statement properly and u can fetch data in one shot this will reduce database load as well as abap load ( More than 3 joins in SELECT stmt  are not recommeded but can be used)
    I believe this is perfect solution if and only if u are giving joins on KEY fields only.  Same is applied for wherer clause.
    Hope this will help u, if not revert.
    Jogdand M B

  • Delete Itab within Loop at ITAB ?

    Hi,
    Help needed to remove this delete from within the loop.
    {code
    Loop at itab where <condition>.
    <statements>
    delete itab index sy-tabix.
    Exit.
    Endloop.
    {code}
    The functionality of the code should not be affected.
    Useful help would be awarded

    Hi,
    Instead of deleting data from itab use another internal table of same type (itab1) and append it. Use itab1 data for further processing.
    check below logic...
    {code
    Loop at itab1 into wa_itab1 where <condition>.
    <statements>
    if <condition>
    append wa_itab1 to itab2.
    exit.
    endif.
    Endloop.
    refresh itab1.
    itab1[] = itab2[].
    {code}
    regards,
    N M Poojari.

  • Error in loop at itab in ECC 6.0

    hi,
    in ECC 6.0, in an abap proxy class i have a loop statement as follows:
    LOOP AT tablename.
        sdfsdf
        sfsfsf
        s
        fsf
    ENDLOOP.
    and i get the error, At "Loop At itab" one of the additions into/assigning or transporting no fields is required in OO context !! what does that mean ? in my abap proxy class can't i use the loop at statement's simplest form ?
    whats the solution ?

    Sure you can, you just have to use an explicit workarea and use the INTO.
    Types: begin of ttab,
                fld1 type c,
               fld2 type c,
              end of ttab.
    data: itab type table of ttab.
    data: wa like line of itab.
    Loop at itab INTO wa.
    * Now the row is stord in WA, do what you need to here.
    endloop.
    YOu can NOT use internal tables with header lines in the OO context.
    Regards,
    Rich Heilman

  • I have a for loop inside of while loop.when i press stop for while loop, i also would like to stop for loop.how can i solve this problem?thanks

    i have a for loop inside of while loop.when i press stop for while loop, i also would like to stop for loop.how can i solve this problem?thanks

    Hi fais,
    Following through with what JB suggested. The steps involved in replacing the inner for loop with a while loop are outlined below.
    You can replace the inner for loop with a while by doing the following.
    1) Right-click of the for loop and select "Repalce" then navigate to the "while loop".
    2) Make sure the tunnels you where indexing on with the for loop are still indexing.
    3) Drop an "array size" node on your diagram. Wire the array that determines the number of iterations your for loop executes into this "array size".
    4) Wire the output of the array size into the new while loop.
    5) Set the condition terminal to "stop if true".
    6)Drop an "OR" gate inside the while loop and wire its output to the while loops condition terminal.
    7) C
    reate a local of the boolean "stop" button, and wire it into one of the inputs of your OR gate. This will allow you to stop the inner loop.
    8) Drop a "less than" node inside the inner while loop.
    9) Wire your iteration count into the bottom input of the "less than".
    10) Wire the count (see step 4 above) into the top input of the less than. This will stop the inner loop when ever the inner loop has processed the last element of your array.
    Provided I have not mixed up my tops and bottoms this should accomplish the replacement.
    I will let others explain how to takle this task using the "case solution".
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Insert ITAB INDEX SY-TABIX Problem

    Hi Experts,
    I have a problem in my report.
    Please look into the code.
    loop at li_basez980.
       read table i_z980 with key spmon = l_spmon
                                  matnr = li_basez980-matnr
                                  kunnr = li_basez980-kunnr
                                  werks = li_basez980-werks
                                  vkorg = li_basez980-vkorg binary search.
       if sy-subrc ne 0.
         i_z980-spmon = l_spmon.
         i_z980-matnr = li_basez980-matnr.
         i_z980-kunnr = li_basez980-kunnr.
         i_z980-werks = li_basez980-werks.
         i_z980-vkorg = li_basez980-vkorg.
         i_z980-basme = li_basez980-basme.          " 8/6/07
         i_z980-waers = c_waers.
         i_z980-cpudt = v_datum.
         i_z980-cputm = v_uzeit.
         i_z980-znetsalekg = 0.
         i_z980-znetsalevl = 0.
         insert i_z980 index sy-tabix.
         clear  i_z980.
       endif.
    endloop.
    When run my report in Foreground it runs fine. But when i run the same report in Background job gets cancelled when the index reaches to 228984 once 230070 once and 230104 once at insert statement i.e " insert i_z980 index sy-tabix." . I found this  by debugging the Job.
    Please help me if you know the solution.
    Regards,
    Ravikumar P
    Edited by: Ravikumar P on Mar 30, 2010 4:40 PM

    Hi,
    This is happening because after read you inserting the records when sy-surbc <> 0. At that time did you check the sy-tabix value. This value is comming correctly. You directly append the same.
    loop at li_basez980.
    read table i_z980 with key spmon = l_spmon
    matnr = li_basez980-matnr
    kunnr = li_basez980-kunnr
    werks = li_basez980-werks
    vkorg = li_basez980-vkorg binary search.
    if sy-subrc ne 0.
    i_z980-spmon = l_spmon.
    i_z980-matnr = li_basez980-matnr.
    i_z980-kunnr = li_basez980-kunnr.
    i_z980-werks = li_basez980-werks.
    i_z980-vkorg = li_basez980-vkorg.
    i_z980-basme = li_basez980-basme. " 8/6/07
    i_z980-waers = c_waers.
    i_z980-cpudt = v_datum.
    i_z980-cputm = v_uzeit.
    i_z980-znetsalekg = 0.
    i_z980-znetsalevl = 0.
    insert i_z980 index sy-tabix.
    clear i_z980.
    endif.
    endloop.

  • Is thier  a reason haveing a for loop in paint would cause a problem

    when i have a gui

    Yes i whittled this down to make it more readable.
    I am at a loss as to what the problem is,
    running it illustrates the problem.
    import java.applet.*;
    import java.awt.*;
    import javax.swing.*;
    public class thebug extends Applet {
    Image osImg;                     // offscreen image
    Graphics osG ;                    // off screen graphics
    boolean startOut = true;      // first time painting
    Dimension curD ;                 // current size of offscreen stuff
    int c = 0;int v = 0; int vv = 0;
    int degreesZ = 1;int degreesX = 1;int degreesY = 1;
    int off_set = 150 ;
    int Xa = 1; int Ya = 1; int Za = 1;
    int Xb = 1;int Yb = 1;int Zb = 1;
    int Xp =50;int Yp = -50;int Zp =1;
                          public void init() { }       
                          public void update (Graphics g) { paint(g);  }
         public void paint(Graphics g) { //---------------------------------------------------------------------   
         for(degreesZ = 1;degreesZ <=360;degreesZ++){  //test loop  this is z rotation instep 
                     if (startOut == true){  // is this the first time painting
                     curD = getSize();
                     osImg = createImage (curD.width ,curD.height);
                     osG = osImg.getGraphics();
                     startOut = false ;
                     // has the component been resized
                     if ((curD.width !=getSize().width) || (curD.height !=getSize().height)){
                     curD =getSize();
                     osImg = createImage (curD.width,curD.height);
                     osG = osImg.getGraphics();
                              osG.setColor(Color.red);
                              osG.fillRect(0,0,300,300);      
                               c++;  // this is just for the color can be removed
                               switch(c){
                               case 1: osG.setColor(Color.black);break;
                               case 2: osG.setColor(Color.blue);c=0;break;   
                               default :{c=0;}  
                               }     // end switch/case
        //setup to rotate the point    
        Xa=Xp;Ya=Yp;Za=Zp;                              
        double radiansZ =  ( Math.PI * degreesZ )/180;
        double radiansX = ( Math.PI * degreesX )/180;
        double radiansY = ( Math.PI * degreesY )/180;                  
        //   rotate on the  axises z,x,y
        Xb = (int)(Xa * Math.cos(radiansZ) - Ya * Math.sin(radiansZ) );
        Yb = (int)(Ya * Math.cos(radiansZ) + Xa * Math.sin(radiansZ) );          
        Yb = (int)(Yb * Math.cos(radiansX) - Za * Math.sin(radiansX) );
        Zb = (int)(Yb * Math.sin(radiansX) + Za * Math.cos(radiansX) );   
        Zb = (int)(Zb * Math.cos(radiansY) - Xb * Math.sin(radiansY) );
        Xb = (int)(Zb * Math.sin(radiansY) + Xb * Math.cos(radiansY) );
        // add a screen offset
        Xb = Xb+off_set;
        Yb = Yb+off_set;
        Zb = Zb;
                      osG.drawLine(off_set,off_set,Xb,Yb);   //draw it
                      g.drawImage(osImg,0,0,this );  
        System.out.println( "end degree loop" );
        } // end degree loop      
                 osG.dispose(); 
        System.out.println( "####end paint####" );
        } // end paint ------------------------------------------------------------------------------------------  

  • Performance tuning in loop at itab statements

    Hi ,
    I have one internal table lets ITAB1[] ,
    Its having 15,0000 Records.
    now I want to search only 5 records from ITAB1[] compairing ITAB2[] , ITAB2 having  15,0000 records.
    what is best method to search this records in minimum time.
    loop it ITAB1.
    Read table ITAB2 with = ... binary search.
    Endloop.
    Prblem is that , above statemnt will take 15,0000 intration at each statment while reading.

    Hi,
    loop it ITAB1.
    Read table ITAB2 with = ... binary search.
    Endloop.
    I think whatever code you are using now is appropriate only.
    As you want to read record from ITAB1 based on data in ITAB2, you will have to loop at ITAB2 and then do binary search on ITAB1. Just make sure that your table ITAB1 is sorted correctly as per the binary search criteria.
    Thanks,
    Archana

  • TS4147 This article creates a loop and doesn't solve the problem!!!

    I have unexpected duplicates in my contacts that happens when I sync with Outlook 2010 and icloud.  This article refers me to another article which says that if that doesn't resolve the problem, which is doesn't click here...which brings me back to this article.  Setting up icloud has made a complete mess of my OUtlook contacts right when I'm trying to do my Christmas Card mailing...
    I'm a fairly competent user and have checked and double checked all my settings but the duplications keep happening and proliferating!!!

    Restore the backup you made prior to Changing Outlooks accounts from local to iCloud.

  • Loop at Screen problem

    Hi,
    I am facing a few hicups in my code, I needed to make certain FIelds as updateable and some as non updateable but the problem is that this is not happening. Can you tell me where i am going wrong. I have written this code in my PBO at the end. The Code should enable FIELD KAWRT for the 1st Line and disable the rest, while for the others it should enable Field KWERT. what is the problem in my code.
      LOOP AT itab.
        IF sy-tabix = 1.
          LOOP AT SCREEN.
            IF screen-name = 'ITAB-KSCHL' OR
               screen-name = 'ITAB-KBETR' OR
               screen-name = 'ITAB-KWERT'.
              screen-input = '0'.
              screen-output = '0'.
              MODIFY SCREEN.
            ELSEIF screen-name = 'ITAB-KAWRT'.
              screen-input = '1'.
              screen-output = '1'.
              MODIFY SCREEN.
            ENDIF.
          ENDLOOP.
        ENDIF.
        READ TABLE i_kschl WITH KEY kschl = itab-kschl.
        IF sy-subrc = 0.
          LOOP AT SCREEN.
            IF screen-name = 'ITAB-KSCHL' OR
               screen-name = 'ITAB-KAWRT' OR
               screen-name = 'ITAB-KBETR'.
              screen-input = '0'.
              screen-output = '0'.
              MODIFY SCREEN.
            ELSEIF screen-name = 'ITAB-KWERT'.
              screen-input = '1'.
              screen-output = '1'.
              MODIFY SCREEN.
            ENDIF.
          ENDLOOP.
        ENDIF.
      ENDLOOP.

    Hi,
    Its happening so because as in your code:
    LOOP AT itab.
    IF sy-tabix = 1.
    LOOP AT SCREEN.                             "This is executed for the First Time That's *FINE*
    IF screen-name = 'ITAB-KSCHL' OR
    screen-name = 'ITAB-KBETR' OR
    screen-name = 'ITAB-KWERT'.
    screen-input = '0'.
    screen-output = '0'.
    MODIFY SCREEN.
    ELSEIF screen-name = 'ITAB-KAWRT'.
    screen-input = '1'.
    screen-output = '1'.
    MODIFY SCREEN.
    ENDIF.
    ENDLOOP.
    ENDIF.
    READ TABLE i_kschl WITH KEY kschl = itab-kschl.   
    *THIS PART OF CODE IS EXECUTED ALWAYS WHICH YOU DON'T  WANT SO THIS  SHUD BE IN ELSE PART OF _*IF SY-TABIX = 1**_                                             
    IF sy-subrc = 0.
    LOOP AT SCREEN.
    IF screen-name = 'ITAB-KSCHL' OR
    screen-name = 'ITAB-KAWRT' OR
    screen-name = 'ITAB-KBETR'.
    screen-input = '0'.
    screen-output = '0'.
    MODIFY SCREEN.
    ELSEIF screen-name = 'ITAB-KWERT'.
    screen-input = '1'.
    screen-output = '1'.
    MODIFY SCREEN.
    ENDIF.
    ENDLOOP.
    ENDIF.
    ENDLOOP.
    DO LIKE:
    LOOP AT itab.
    IF sy-tabix = 1.
    LOOP AT SCREEN.                     
    ENDLOOP.
    ELSE.
    READ TABLE i_kschl WITH KEY kschl = itab-kschl.   
    ENDIF.

  • Problem with  AT command in LOOP

    Hi Experts,
    here i ve a problem like, in my table there are 3 PSPHI(projects) values,
    if i loop n calculate the sum it is getting total amt for 3 PSPHI values,
    but i want every end of PSPHI i need sum.
    the below code is working fine if there is no AT coomand, if i put AT END OF PSPHI it is giving 00.00 values.
      LOOP AT it_final into it_output.
       AT END OF PSPHI.
        if it_final-wrttp = '04'
           AND it_final-vorga = 'COIN' 
           AND it_final-beltp  = '02'
           AND it_final-versn = '000'.
       t_pla_rev = t_pla_rev + it_output-wlp01.
        MOVE it_output-wlp01 TO pla_rev.
        sum = sum + pla_rev.
          if sy-subrc EQ 0.
            else.
            write:/10 ' u r not ok'.
        endif.
    e  ndif.
    append it_output.
    *ENDAT.
    ENDLOOP.
    write:/10 'total amt is', sum.
    could anybady check where i gone wrong pls...
    Thanks in advance,
    sudharsan.

    Hi,
    What is your table structure.
    The command  AT ........ENDAT  work in sequential order.
    Let me explain with example.
    if your table itab has two column  column1 and column2
    loop at itab into wa.
    at new column2.
    // This will execute when the Value of column 1 change or column2
    // change.
    endat.
    endlloop.
    The solution of your problem is.
    Change your internal table column order ,
    Put the column first for which you want to calculate the sum.
    Thanks & Regards
    Kulvendra Kumar

  • Problem in Select stmt in loop

    Hi all,
    Pls provide your suggestions for the following code.
    LOOP at ITAB.
    select * from zxyz into corresponding fields of table ITAB_FINAL
    where fromdate eq date1
              todate eq date2
              MATNR eq ITAB-matnr.
    ENDLOOP.
    My question is that for a particular entry in itab , select stmt is executed and some 5 to 6 line item is selected into itab_final. Now in second loop , again select stmt is executed and again some line item will be selected , BUT will this selection will replace the earlier entry in ITAB_FINAL OR the entry in SUCCESSIVE loop will be APPENDED ?
    Please suggest your valuable suggestion on this problem
    Thanks in advance,
    Regards,
    Vivek

    Hi,
    There is no need to loop if you are using FOR ALL ENTRIES
    select * from zxyz into corresponding fields of table ITAB_FINAL
    for all entries in itab
    where matnr eq itab-matnr
    and fromdate eq date1
    and todate eq date2.

  • How to overcome looping problem in Table control?

    If the table control displays,say for eg 5 rows in the screen,it is looping the same in flow logic.
    What if the table control has 10 rows but only 5 rows are displayed? and i want to loop through all the records in the flow logic.
    how to overcome this problem?
    Points will be awarded for answers.
    Regards
    Raja

    Hi
    U need to insert a new LOOP for you internal table and store the data in a different headerline:
    PROCESS PAI (or PBO).
      LOOP AT ITAB.
         MODULE LOOP_ITAB.
      ENDLOOP.
      MODULE LOOP_ITAB.
         LOOP AT ITAB INTO WA.
             IF SY-TABIX = <TABLE CONTROL>-CURRENT_LINE
    *--->It's the same record of LOOP of PAI (or PBO).
             ENDIF.
         ENLOOP.
      ENDMODULE.
    Max

  • Help needed regarding SUM keyword in an ITAB loop

    Hello,
    I am maintaining a code as given below.
    LOOP AT itab INTO totwa.
    SUM.
    ENDLOOP.
    totwa is defined as a workarea which is needed to hold the sum totals of the fields in the itab. According to the documentation of SUM, it should calculate the sum totals and should put the totals in the workarea mentioned. But somehow its not calculating the value. Could anyone please help me in resolving this issue. Please guide me with your thoughts as to what might have gone wrong.
    Note: the itab fields are of type P.
    Thanks in advance
    Sudha Naik

    Hello Suha
    According to the ABAP documentation the SUM statement is used in a specific situation:
    <b>Syntax
    SUM. </b>
    <b>Effect </b>
    <i>The statement SUM can only be specified within a loop starting with LOOP, and is only considered within a AT-ENDAT control structure. Prerequisites for using the statement SUM include using the addition INTO in the LOOP statement, and that the specified work area wa is compatible with the row type of the internal table. In addition, SUM cannot be used when the row type of the internal table itab contains components that are tables. </i>
    <i>The statement SUM calculates the component total with the numeric data type ( i, p, f) of all rows in the current control level and assigns these to the components of the work area wa. In the control levels FIRST, LAST , and outside of an AT-ENDAT control structure, the system calculates the sum of numeric components of all rows in the internal table.</i>
    I hope the following sample report will clarify the use of <b>SUM </b>and <b>COLLECT</b>.
    *& Report  ZUS_SDN_COLLECT
    REPORT  zus_sdn_collect.
    TYPES: BEGIN OF ty_s_line.
    TYPES:   key(1)    TYPE n.
    TYPES:   value     TYPE p DECIMALS 2.
    TYPES: END OF ty_s_line.
    TYPES: ty_t_itab    TYPE STANDARD TABLE OF ty_s_line
                        WITH DEFAULT KEY.
    DATA:
      gs_line       TYPE ty_s_line,
      gt_itab       TYPE ty_t_itab,
      gt_itab_coll  TYPE ty_t_itab.
    START-OF-SELECTION.
      DO 3 TIMES.
        gs_line-key = syst-index.
        gs_line-value = syst-index * '2.3'.
        APPEND gs_line TO gt_itab.
        APPEND gs_line TO gt_itab.
      ENDDO.
      gs_line-key = 4.
      gs_line-value = '5.5'.
      APPEND gs_line TO gt_itab.
      WRITE: / 'Initial list'.
      LOOP AT gt_itab INTO gs_line.
        WRITE: / gs_line-key,
                 gs_line-value.
      ENDLOOP.
      WRITE: / syst-uline.
      SKIP 2.
      WRITE: / 'Using SUM statement with AT END OF'.
      SORT gt_itab BY key.
      LOOP AT gt_itab INTO gs_line.
        AT END OF key.
          SUM.
          WRITE: / gs_line-key,
                   gs_line-value.
        ENDAT.
      ENDLOOP.
      WRITE: / syst-uline.
      SKIP 2.
      WRITE: / 'Using SUM statement without control structure (1)'.
      SORT gt_itab BY key.
      LOOP AT gt_itab INTO gs_line.
        SUM.
        WRITE: / gs_line-key,
                 gs_line-value.
      ENDLOOP.
      WRITE: / syst-uline.
      SKIP 2.
      WRITE: / 'Using SUM statement without control structure (2)'.
      SORT gt_itab BY key.
      LOOP AT gt_itab INTO gs_line.
        SUM.
        WRITE: / gs_line-key,
                 gs_line-value.
        EXIT.
      ENDLOOP.
      WRITE: / syst-uline.
      SKIP 2.
      WRITE: / 'Using COLLECT statement'.
      REFRESH: gt_itab_coll.
      LOOP AT gt_itab INTO gs_line.
        COLLECT gs_line INTO gt_itab_coll.
      ENDLOOP.
      LOOP AT gt_itab_coll INTO gs_line.
        WRITE: / gs_line-key,
                 gs_line-value.
      ENDLOOP.
      WRITE: / syst-uline.
      SKIP 2.
      WRITE: / 'Using COLLECT statement for total sum'.
      REFRESH: gt_itab_coll.
      LOOP AT gt_itab INTO gs_line.
        gs_line-key = 0.
        COLLECT gs_line INTO gt_itab_coll.
      ENDLOOP.
      LOOP AT gt_itab_coll INTO gs_line.
        WRITE: / gs_line-key,
                 gs_line-value.
      ENDLOOP.
      WRITE: / syst-uline.
      SKIP 2.
    END-OF-SELECTION.
    Regards
      Uwe

  • Problem with while loops, please help!

    I am having quite a bit of trouble with a program im working on. What i am doing is reading files from a directory in a for loop, in this loop the files are being broken into words and entered into a while loop where they are counted, the problem is i need to count the words in each file seperately and store each count in an array list or something similar. I also want to store the words in each file onto a seperate list
    for(...)
    read in files...
         //Go through each line of the first file
              while(matchLine1.find()) {
                   CharSequence line1 = matchLine1.group();
                   //Get the words in the line
                   String words1[] = wordBreak.split(line1);
                   for (int i1 = 0, n = words1.length; i1 < n; i1++) {
                        if(words1[i1].length() > 0) {
                             int count= 0;
                                           count++;
                             list1.add(words1[i1]);
              }This is what i have been doing, but with this method count stores the number of words in all files combined, not each individual file, and similarly list1 stores the words in all the files not in each individual file. Does anybody know how i could change this or what datastructures i could use that would allow me to store each file seperately. I would appreciate any help on this topic, Thanks!

    Don't try to construct complicated nested loops, it makes things a
    tangled mess. You want a collection of words per file. You have at least
    zero files. Given a file (or its name), you want to add a word to a collection
    associated with that file, right?
    A Map is perfect for this, i.e. the file's name can be the key and the
    associated value can be the collection of words. A separate simple class
    can be a 'MapManager' (ahem) that controls the access to this master
    map. This MapManager doesn't know anything about what type of
    collection is supposed to store all those words. Maybe you want to
    store just the unique words, maybe you want to store them all, including
    the duplicates etc. etc. The MapManager depends on a CollectionBuilder,
    i.e. a simple thing that is able to deliver a new collection to be associated
    with a file name. Here's the CollectionBuilder:public interface CollectionBuilder {
       Collection getCollection();
    }Because I'm feeling lazy today, I won't design an interface for a MapManager,
    so I simply make it a class; here it is:public class MapManager {
       private Map map= new HashMap(); // file/words association
       CollectionBuilder cb; // delivers Collections per file
       // constructor
       public MapManager(CollectionBuilder cb) { this.cb= cb; }
       // add a word 'word' given a filename 'name'
       public boolean addWord(String name, String word) {
          Collection c= map.get(name);
          if (c == null) { // nothing found for this file
             c= cb.getCollection(); // get a new collection
             map.put(name, c); // and associate it with the filename
          return c.add(word); // return whatever the collection returns
       // get the collection associated with a filename
       public Collection getCollection(String name) { return map.get(name); }
    }... now simply keep adding words from a file to this MapManager and
    retrieve the collections afterwards.
    kind regards,
    Jos

Maybe you are looking for

  • % of project completed by month (during Planning)

    Hello, I want to know the percentage of tasks concluded by month during the planning using MS Project. For example: I'm planning this month (May-2104) a project that begins in Jun-2104 and will last 7 months (from Jun to Dec-2104). When I conclude th

  • Port list to use with WFO (Workforce Optimization/Quality management)

    Hello I'm working with a new implementation of WFO and UCCX and I'm trying to have all the rules in the firewalls available so theres no problem in comunications between the servers and agents. Is there a doc where I can search for specifics ports? I

  • Problem with DrawingPad Erasing

    Hi All, Im a little new to java so please forgive me if this seems blatently easy. Im working on constructing a drawing pad and I've got it so it will update and paint correctly when you drag, etc. with the mouse. I'm trying to add a colorchooser whi

  • WebHelp fine with external links, but AIR output isn't.

    Sorry for the repost, but I did not get any eyeballs by posting this in the Adobe AIR or Other Single Source layouts forums. Hoping to get some experts' opinions here. I have this problem with using the AIR packager for RH7 as well as RH8. Please adv

  • Copying install from one machine to another

    Hi all, I have a macbook pro and a mac pro, both of which I would like to reinstall from scratch (i've installed and removed LOADS of crap over the past year and want to start from fresh). I've reinstalled the OS on my macbook pro (discs provided was