Select out of loop

my previous code is
data : begin of itab occurs 0,
               matnr like zcst-zmatnr,
              checked type i,
          def11 type i,
               def14 type i,
end of itab.
DATA : ind TYPE i.
LOOP AT itab.
  ind = sy-tabix.
  SELECT COUNT( DISTINCT zcst~zcastn )
    FROM zcst INNER JOIN zvtrans
    ON ( zcstzcastn = zvtranszcastn AND
         zcstzmatnr = zvtranszmatnr AND
         zcstzwerks = zvtranszwerks AND
         zcstgjahr  = zvtransgjahr )
    INTO itab-checked
    WHERE
        zcst~zmatnr = itab-matnr AND
        zcst~zwerks IN s_plant AND
        zcastpd IN s_castpd AND
        zcatg IN s_categ.
  PERFORM defect_count USING itab-def11 '11'.
  PERFORM defect_count USING itab-def14 '14'.
  MODIFY itab INDEX ind.
ENDLOOP.
*&      Form  defect_count
      text
     -->P_DEFECT       text
     -->VALUE(P_CODE)  text
FORM defect_count  USING    p_defect
                            value(p_code).
  IF r1 = 'X'.
    SELECT COUNT( DISTINCT  zcst~zcastn )
    FROM zcst INNER JOIN zvtrans
    ON ( zcstzcastn = zvtranszcastn AND
         zcstzmatnr = zvtranszmatnr AND
         zcstzwerks = zvtranszwerks AND
         zcstgjahr  = zvtransgjahr )
    INTO p_defect
    WHERE
        zcst~zmatnr = itab-matnr AND
        zcst~zwerks IN s_plant AND
        zcastpd IN s_castpd AND
        zcatg IN s_categ AND
        zvtrans~zvcode = 'S' AND
        zdcode = p_code.
  ENDFORM.                    "defect_count
  what i have written is as new code is this. is this correct instead of above code.
  DATA : BEGIN OF w_final,
                zmatnr LIKE zcst-zmatnr,
               checked TYPE i,
            def11 TYPE i,
                 def14 TYPE i, END OF w_final.
  DATA : BEGIN OF w_chkd,
           zmatnr TYPE zcst-zmatnr,
           checked TYPE i,
         END OF w_chkd.
  DATA : BEGIN OF w_tab,
          zmatnr LIKE zcst-zmatnr,
         END OF w_tab.
  itab like standard table of w_tab,
     i_final like standard table of w_final.
  i_chkd like standard table of w_chkd,
  i_chkd1 like standard table of w_chkd.
  SELECT zcstzmatnr COUNT( DISTINCT zcstzcastn )
         FROM zcst INNER JOIN zvtrans
         ON ( zcstzcastn = zvtranszcastn AND
              zcstzmatnr = zvtranszmatnr AND
              zcstzwerks = zvtranszwerks AND
              zcstgjahr  = zvtransgjahr )
         INTO TABLE i_chkd
         WHERE
            zcst~zmatnr = w_tab-matnr AND
             zcst~zwerks EQ p_plant AND
             zcastpd IN s_castpd AND
             zcatg IN s_categ GROUP BY zcst~zmatnr.
  LOOP AT itab INTO w_tab.
    LOOP AT i_chkd INTO w_chkd WHERE zmatnr = w_tab-zmatnr.
      IF sy-subrc EQ 0.
        w_chkd-zmatnr = w_chkd-zmatnr.
        w_chkd-checked = w_chkd-checked.
        APPEND w_chkd TO i_chkd1.
      ENDIF.
    ENDLOOP.
  ENDLOOP.
  SELECT zcst~zmatnr
           zcst~zcastn
           zvtrans~zdcode
     FROM zcst INNER JOIN zvtrans
     ON ( zcstzcastn = zvtranszcastn AND
          zcstzmatnr = zvtranszmatnr AND
          zcstzwerks = zvtranszwerks AND
          zcstgjahr  = zvtransgjahr )
     INTO TABLE i_defect
     WHERE
       zcst~zmatnr = itab-matnr AND
         zcst~zwerks EQ p_plant AND
         zcastpd IN s_castpd AND
         zcatg IN s_categ AND
         zvtrans~zvcode = 'S' AND
         zdcode IN ('11','14','16','83','19','20','22','24','26','34',
                    '35','36','37','39','40','41','45','48','53','55',
                    '56','67','68','72','73','92','84','85','78','75').
  SORT i_defect BY zcastn.
  DELETE ADJACENT DUPLICATES FROM i_defect COMPARING zcastn.
  LOOP AT itab INTO w_tab.
    LOOP AT i_defect INTO w_defect WHERE zmatnr = w_tab-zmatnr.
      IF sy-subrc EQ 0.
        w1_defect-zmatnr = w_defect-zmatnr.
        w1_defect-zcastn = w_defect-zcastn.
        w1_defect-zdcode = w_defect-zdcode.
        APPEND w1_defect TO it_defect.
        CLEAR w1_defect.
      ENDIF.
    ENDLOOP.
  ENDLOOP.
  LOOP AT i_final INTO w_final.
    ind = sy-tabix.
*checked
    READ TABLE i_chkd1 INTO w_chkd WITH KEY zmatnr = w_final-zmatnr.
    w_final-checked = w_chkd-checked.
    PERFORM defect_count USING w_final-def11 '11'.
    PERFORM defect_count USING w_final-def14 '14'.
    MODIFY i_final FROM w_final INDEX ind.
  ENDLOOP.
*&      Form  defect_count
      text
     -->P_DEFECT       text
     -->VALUE(P_CODE)  text
FORM defect_count  USING    p_defect
                            value(p_code).
  LOOP AT it_defect INTO w_defect WHERE zdcode = p_code.
    IF sy-subrc EQ 0.
      p_defect = p_defect + 1.
    ENDIF.
  ENDLOOP.
ENDFORM.                    "defect_count

Hi,
DATA :  i_bkpf LIKE BKPF OCCURS 0 WITH
            HEADER LINE.
SELECT * FROM BKPF
INTO TABLE i_BKPF
FOR ALL ENTRIES IN WK
WHERE BUKRS = '4187' AND
             BELNR = WK-BELNR AND
             GJAHR = PROCYR.
LOOP AT WK.
READ TABLE i_BKPF WITH KEY
BUKRS = '4187'
BELNR = WK-BELNR
GJAHR = PROCYR.
IF SY-SUBRC EQ 0.
ENDIF.
ENDLOOP.
Don't forget to reward if useful...

Similar Messages

  • Urgent - I have written select query between loop and endloop, Ple help out

    Can any one help out me on this select query. I have written select query between loop and endloop. When I execute the program it will take too much time in this query. Please help me out. Its very urgent.
    LOOP AT l_i_invoices ASSIGNING <l_invoices>.
          CLEAR alv_wa.
          alv_wa-bukrs = <l_invoices>-bukrs.
          alv_wa-gsber = <l_invoices>-gsber.
          CLEAR l_instid.
          CONCATENATE <l_invoices>-belnr <l_invoices>-gjahr INTO l_instid.
          SELECT top_wi_id FROM sww_wi2obj INTO TABLE l_i_swwwihead
                  WHERE catid   = c_catid_business_object
                    AND instid  = l_instid
                    AND typeid  = c_typeid_invoice
                    AND removed = space
                    AND ( wi_rh_task = c_task_buyer_message
                       OR wi_rh_task = c_task_buyer_message2 ).
          IF sy-subrc = 0.
            <l_invoices>-flag = 'X'.
          ELSE.
            <l_invoices>-flag = ' '.
          ENDIF.
          MODIFY l_i_invoices FROM <l_invoices> TRANSPORTING flag
                                WHERE belnr = <l_invoices>-belnr
                                   AND gjahr = <l_invoices>-gjahr.
          APPEND alv_wa TO i_alv.
        ENDLOOP.
    Thanks in advance.

    Here is a way to solve this problem.
    Choose somewhere before this loop processing to use that select. Therefore, you'll need use FOR ALL ENTRIES <that_loop_table> clause, and in the WHERE condition you need to specify that same fields.
    This way, you will have an internal table with all data you'll need to check.
    Then, inside your loop statement, use the READ TABLE command with the clause WITH KEY field = value, to read that record and use the value found.
    Like this sample:
      SELECT bukrs lifnr umsks umskz augdt augbl zuonr gjahr belnr buzei
             waers xblnr blart gsber ebeln zfbdt zbd1t zlsch
      INTO TABLE tg_bsak
      FROM bsak
      FOR ALL ENTRIES IN tl_bkpf_sel
      WHERE bukrs EQ tl_bkpf_sel-bukrs AND
            lifnr IN s_lifnr AND
            augbl EQ tl_bkpf_sel-belnr.
    LOOP AT tg_bseg INTO wa_bseg.
        READ TABLE tg_bsak INTO wa_bsak WITH KEY bukrs = wa_bseg-bukrs
                                                 gjahr = wa_bseg-gjahr
                                                 belnr = wa_bseg-belnr
                                                 BINARY SEARCH.
    if sy-subrc = 0.
    * do something
    endif.
    ENDLOOP.

  • New User - Cannot select drum kit loops

    Hi,
    I am a trying out GarageBand for the first time and having a lot of fun.
    However I was following one of the Apple tutorials where I clicked on song writing and had a basic drum track. The tutorial said if you don't like the drum track you can delete it and then use the Loop browser to select different drum kits.
    However when I click on the Loop browser I can't click on the drum kit icons to then select a drum loop - they are all ghosted out - like as if they are not installed on my system.
    Yet the basic drum loop played fine - so it must be there somewhere.
    Do I have to install these loops somehow like I had to install the instruments? (The system told me I needed to install some things online - but I've not seen anything regarding loops)
    Help !!!
    Thanks

    In case anyone had the same problems as me - I had to use the Applications disc that came with my laptop to re-install Garageband from the DVD.
    Just take care using it - make sure you backup your system just in case (always a good idea) - insert the disc and follow the instructions. Make sure you take all the tick boxes out of the other applications so that you only install Garageband.
    Then let it install and when the computer restarts there are all the loops in their glory.
    Its a shame that Garageband lets you download the loops online because that is a complete waste of time as even after downloading 1.2 gigs worth of data Garageband ignores the loops even though they are there on your system. The only way to get the loops to work is by installing off the dvd that came with your computer.
    Hope this helps other users.
    Cheers
    Phil

  • Normal State Button Shows Selected State At Loop Point

    My menu shows the Normal State Button Shows as the selected state At Loop Point. I want it to show for instance black until it is selected then "rollover" to red. TIA for any help.
    Murman

    There are two ways that you can do this without resorting to using a layer based shape or a layer based menu.
    First, you need to decide if it is important for the logo to appear in full colour or if you can get away with a single colour instance of it appearing. If the answer to this is that a single colour is OK, then use a standard overlay menu. Otehrwise, try using a masked overlay menu (there are limitations...)
    With a standard overlay, the background image is as you want it to appear without anything selected - all shapes and text, etc, should be in place as if no button is chosen.
    You then create the overlay, which is a simple .pict file that is the size of the menu. On this you simply place as many instances of the logo as you need - create them in black or grayscale and don't add anything else. The overlay will be mostly white with the black or gray shapes on it.
    Add this to your menu in DVDSP and drag out the button rectangles to cover the background text and the overlay shape. When the button is selected, the logo shape will show up, but will not show in the normal state.
    You can get the logo to be whatever colour you need by using the colour mapping within the property inspector for the button.
    If you definitley need a full colour logo to appear, you can either use a layer based photoshop menu, or use overlay masks:
    http://www.editorsbin.com/authoring/mask_overlay.html
    be aware that there are some limitations when using the masking technique - but all is explained in that tutorial.

  • Program times out while looping at internal table with huge records - Needs fine tuning suggestions

    Hi,
    I am trying to execute a report. It times out while looping at vbap internal table. This internal table has 140000  records and does the validation within this loop and geenrates data for the output. Due to this huge volume, the program times out when executed foreground.
    There are no nested loops, so I cannot apply 'Parallel Cursor' here.
    Is there any way I can fine tune the program so that it doesn't timeout? Is it possible to apply 'Parallel Processing' . If yes, how?
    Thanks,
    Pavan

    Hi Pavan ,
                  ->sort your internal table by all primary key for vbap.
                  ->Read a Record from the table (use your condition here)
                  ->if record satisfys your where condition ,get that record index .
                  ->loop the table from the index (without condition) .
                  its like parallel cursor only but for single loop .;-)
                  ->use field symbols ,wherever possible .
               if still dump is coming ,contact your basis team .
    regards,
    Krishna.

  • How to avoid data selection inside the loop?

    Hello Experts,
    I am working on one performance item and I have already applied some changes to the original version.
    Now, If I compare my new program with old program, I have good improvement in performance. I am checking if I can do anything on statements that are top on the below list. I think 40% for Modify statement is acceptable after my research (Below run is updating around 20M records which is real time volume for this application).
    As we can see 34% of run time to going for one SELECT query on custom table. Take a look at below high level flow of my program to understand above select query.
    1. Select data from ZABC
    2. Select data from Variant Table (Var1, Var2, Var3 etc.., 12 in real time)
    3. Loop Variant Table
    4. Select data from X, Y, Z table for Var<n>.
    5. Populate final internal table from ZABC, X, Y and Z table
    6. Modify ZTABLE with Final Internal table data
    7. End Loop on Variant Table
    As described in the flow of the program, ZABC table data is common for all the variants and need not to fetch multiple times. Hence I am doing it only once in my program. Below is that select query:
    select rrcty ryear rbukrs racct rcntr sum( amt1) as amt1  "Like I have 32 amount fields in original query
               from zabc
                into table i_zabc
                where ryear in r_year    " Two records in ranges with I and EQ
                and rvers = '001'
                and rrcty in r_rrcty        "Three records in ranges with I and EQ
                and rldnr = 'DT'
                group by rrcty ryear rbukrs racct rcntr
                order by rrcty ryear rbukrs racct rcntr.
    ZABC table is again having huge volume of data and we are fetching millions of records with above query. That is primary reason to take long time. May be that is okay as I am already using Indexes of this table. But, I am not comfortable with it as it can reach max. memory point and through run time error. Fetch Cursor is one reliable option that I can see here, but with that, I should move ZABC selection inside the variant loop which can cause fetching ZABC data 12 times (Let me know If I am missing anything here).
    Now, third statement in my trace results, with 10% of overall time is this:
    loop at i_abc assigning <fs_abc>. 
    loop at i_table assigning <fs_table> where low <= <fs_abc>-racct and high >= <fs_abc>-racct. 
    endloop. 
    endloop. 
    6 million executions with this complex WHERE condition is causing this statement to get 3rd position in trace results. I tried below two options which are, I think, taking even more time - (I am still monitoring these options)
    1) Removed WHERE condition on LOW, HIGH and applied filter inside the loop.
    2) Removed WHERE condition on HIGH only and applied filter inside the loop.
    Any suggestions on how to proceed with ZABC selection and I_TABLE loop.
    Let me know if you have any questions on above compose.

    Since I looked at this case before, let me try some quick suggestions:
    Is table ZABC related to table X, Y and/or Z and can the selection be limited by applying those 12 selection variants?
    If yes, try a join select involving these tables that could make your step 1 obsolete and replace steps 4 and 5.
    This might also get rid of the "loop inside loop" problem. Generally, make sure that the inner table is declared as a sorted table with a key that consists of the fields as used in the WHERE-condition of the inner loop. Use secondary keys for internal tables if your ABAP release permits and the task at hand warrants it.
    Finally, look at PACKAGE SIZE option for the (join) select to reduce memory consumption.
    Thomas

  • How to cast vector to vector with out using loop. and how to override "operator =" of vector for this kind of condition.

    Hi All How to TypeCast in vector<>...  typedef  struct ...  to class... 
    //how to cast the vector to vector cast with out using loop
    // is there any way?
    //================ This is Type Definition for the class of ClsMytype=====================
    typedef struct tagClsMytype
    CString m_Name;
    int m_Index;
    double m_Value;
    } xClsMytype;
    //================ End of Type Definition for the class of ClsMytype=====================
    class ClsMytype : public CObject
    public:
    ClsMytype(); // Constructor
    virtual ~ClsMytype(); // Distructor
    ClsMytype(const ClsMytype &e);//Copy Constructor
    // =========================================
    DECLARE_SERIAL(ClsMytype)
    virtual void Serialize(CArchive& ar); /// Serialize
    ClsMytype& operator=( const ClsMytype &e); //= operator for class
    xClsMytype GetType(); // return the typedef struct of an object
    ClsMytype& operator=( const xClsMytype &e);// = operator to use typedef struct
    ClsMytype* operator->() { return this;};
    operator ClsMytype*() { return this; };
    //public veriable decleare
    public:
    CString m_Name;
    int m_Index;
    double m_Value;
    typedef struct tagClsMyTypeCollection
    vector <xClsMytype> m_t_Col;
    } xClsMyTypeCollection;
    class ClsMyTypeCollection : public CObject
    public:
    ClsMyTypeCollection(); // Constructor
    virtual ~ClsMyTypeCollection(); // Distructor
    ClsMyTypeCollection(const ClsMyTypeCollection &e);//Copy Constructor
    DECLARE_SERIAL(ClsMyTypeCollection)
    virtual void Serialize(CArchive& ar);
    xClsMyTypeCollection GetType();
    ClsMyTypeCollection& operator=( const xClsMyTypeCollection &e);
    ClsMyTypeCollection& operator=( const ClsMyTypeCollection &e); //= operator for class
    void Init(); // init all object
    CString ToString(); // to convert value to string for the display or message proposed
    ClsMyTypeCollection* operator->() { return this;}; // operator pointer to ->
    operator ClsMyTypeCollection*() {return this;};
    public:
    vector <ClsMytype> m_t_Col;
    //private veriable decleare
    private:
    //===================================================
    ClsMytype& ClsMytype::operator=( const xClsMytype &e )
    this->m_Name= e.m_Name;
    this->m_Index= e.m_Index;
    this->m_Value= e.m_Value;
    return (*this);
    //==========================Problem for the vector to vector cast
    ClsMyTypeCollection& ClsMyTypeCollection::operator=( const xClsMyTypeCollection &e )
    this->m_t_Col= (vector<ClsMytype>)e.m_t_Col; // how to cast
    return (*this);
    Thanks in Advance

    Hi Smirt
    You could do:
    ClsMyTypeCollection* operator->() {
    returnthis;};
    // operator pointer to ->
    operatorClsMyTypeCollection*()
    {returnthis;};
    public:
    vector<ClsMytype>
    m_t_Col;//??
    The last line with "vector<xClsMytype>
    m_t_Col;". It compiles but I doubt that is what you want.
    Regards
    Chong

  • Never get out of loop

    With the below example, Im never getting to the "Out of loop message".It iterates through loop alrite but never comes out of it.
    Any ideas anyone?
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line = null;
    while ((line = br.readLine()) != null) {
    System.out.println("In loop");
    System.out.println("Out of loop");

    I think it something to do with the fact that the readline method reads to a '/n' and the stream may not have this termination point.

  • Loops greyed out in loop browser

    Can any one tell me how to make some greyed out loops in the loop browser play?
    The loops in question are in the following location on the HD:
    H/D / LIB / AUDIO / APPLE LOOPS / APPLE / APPLE LOOPS FOR GARAGE BAND.
    About 15% of these loops are greyed out in the loop browser and will not play. They play fine in QT if you select them from the apple loops folder.
    If I drag them into the loop browser then they appear in black above the grey version and WILL play!

    http://www.bulletsandbones.com/GB/FAQPages/NoLoops.html

  • How to find out how many recourds in recourd set  with out while loop

    hi
    i want to findout how many recourds in recourd set
    with out useing any loops like
    while(rs.next())
    count+=1;
    like this
    any mathod like(RecoundCount like )
    pls help me
    regards
    kedar

    If you dont want to use a scrollable result set do
    sql="SELECT COUNT(*) AS COUNT FROM TABLE"
    rs=stmt.executeQuery(sql);
    rs.next()
    count=rs.getString("COUNT");

  • How do I move data from a DAQ into and out of loops and structures?

    I have a set of RTD probes set up to read data into LabView through a DAQ. This block of code is in a while loop
    that executes alongside of several other loops simultaneously. I need to use the data from the RTD probes in other
    loops and case structures specifically for logic tests.
    The problem is that I can't seem to bring the dynamic data out of the DAQ containing while loop or into the other structures.
    Any ideas?
    I have had some success with using multiple DAQs and stopping all others while I need the data inside of a case structure.
    Is there a way to reference data from a DAQ or to run multiple DAQs that read the same data from the same channels without getting a "Task in use error"?
    Thanks,
    -David

    Search the forums for Prodcuer/consumer architecture.
    This uses queues to pass data from the producer loop (such as your data acquisition loop) to other "consumer" loops.  These are the other loops where you want to use the data.
    You won't be able to use multiple DAQ Read functions at the same time.  As you've seen you get error -50103 about the resources already being in use.

  • Come out of loop in debugger

    Hi.,
    While debugging, if we are inside the loop... How to come outside first line of that loop by excuting that loop?
    Also how to come outside of that loop... without excuting that loop?
    ---Its in new debugger!
    --Naveen Inuganti.

    Hi,
    Hope you all know about first screen of module pool programs, where we can't put break points...!
    There we can have LOOPS....
    If I am inside of loop here.... How can I come out of this loop?
    See the following code..is from onwe standard program of SAP..
    PROCESS BEFORE OUTPUT.
            MODULE STATUS_SETZEN_S.
            MODULE DYNPRO_KOPF_MODIF.
            MODULE AUSGLEICHS_VORSCHLAG.
            MODULE D0710_MODIF.
            module dynpro_sel_modif.                       
          LOOP.
            FIELD RF05A-XPOS1.
            FIELD RF05A-AZEI3.
            MODULE SEL_ANZEIGEN_AUSWAHL.
          ENDLOOP.
    PROCESS AFTER INPUT.
            MODULE EXIT AT EXIT-COMMAND.
            MODULE PAI_ANFANG.
            MODULE GET_CURSOR.
    *------- Konto, Buchungskreis ... --------------------------------------
            FIELD RF05A-AGKOA MODULE MC_OBJEKT_SETZEN1.
            FIELD RF05A-AGBUK MODULE MC_AGBUK_PARM_SETZEN.
    *------- Vertrag ----------------------------------------------"contract
            chain.
              field rf05a-vertn.
              field rf05a-vertt.
              field rf05a-xulsd.
              field rf05a-agums.
              module clr_contract.
            endchain.
          CHAIN.
            FIELD RF05A-AGKON.
            FIELD RF05A-VERTN.
            FIELD RF05A-VERTT.
            FIELD RF05A-AGKOA.
            FIELD RF05A-AGUMS.
            FIELD RF05A-XNOPS.
            FIELD RF05A-AGBUK.
            FIELD RF05A-XMULK.
            FIELD RF05A-AVSID.
            FIELD RF05A-XINVS.                                       
            MODULE AUSGLEICHSDATEN.
          ENDCHAIN.
    *------- ... weitere Konten ? ------------------------------------------
            FIELD RF05A-XMULK MODULE RF05A-XMULK ON INPUT.
          CHAIN.
            FIELD RF05A-XAUTS.
            FIELD RF05A-XFIFO.
            MODULE RF05A-XAUTS-XFIFO ON CHAIN-INPUT.
          ENDCHAIN.
    *------- Weitere Suchkriterien -----------------------------------------
          LOOP.
            FIELD RF05A-XPOS1.
            FIELD RF05A-AZEI3.
            MODULE SEL_BEARBEITEN_AUSW.
          ENDLOOP.
          CHAIN.
            FIELD RF05A-AGKON.
            FIELD RF05A-VERTN.
            FIELD RF05A-VERTT.
            FIELD RF05A-AGKOA.
            FIELD RF05A-AGUMS.
            FIELD RF05A-XNOPS.
            FIELD RF05A-AGBUK.
            FIELD RF05A-XMULK.
            FIELD RF05A-XINVS.                                       
            MODULE SEL_PRUEFEN.
            MODULE FUSSZEILE_BEARBEITEN.
          ENDCHAIN.
    PROCESS ON VALUE-REQUEST.
            FIELD RF05A-AGUMS MODULE F4_AGUMS.
            FIELD RF05A-AGKON MODULE F4_AGKON.
            FIELD RF05A-AVSID MODULE F4_AVSID.
    --Naveen Inuganti.

  • How to come out of loop at last record?

    As I told in my previous posts,Iam transferring data from excel to zgkmaster tabel
    table structure:
    eid
    ename
    First I did SHDB(recording) and then made my BDC program.There are 10 records in table with names gopi,hari,rajesh.... with eid 1 to 10.My task is to updated all these names to 'XXX' for all 10 records (just for simple purpose).In my program I called 'Call transaction 'se11' using ptable mode 'A'.I moved from first screen to last screen (where you will update XXX and save for each record').Here:
    Loop at ptable into otable
    perform screens using <program name> <number> 'X'
    perform fields using zgkmaster-ename , otable-ename
    perform fields using 'BDC_OKCODE' , 'SAVE'
    perform screens using <program name> <number> 'X'
    perform fields using 'BDC_OKCODE' , 'NEXT'
    endloop.
    This code works fine in 'A' mode,but at last record a message comes 'Function code cannot be selected' (i think 'next' cannot be executed as it is last record) but all records are updated.
    When the mode is changed to 'N' and 'E',nothing is saved and the same error 'Function code cannot be selected'.Due the this error whatever data we give before that is not saving into table,may be due to this error.
    Now how shoud i make the loop exit when it reaches last record,i tried even with hardcording
    if sy-index = 10.
    leave prograam'
    endif.
    perform.....'NEXT' statement
    But the program is not exiting,I dont know why?Can anyone help me,I think if i made the loop to exit before next statement for last record that error will not occur.advise me if anything wrong.
    Thanks in advance
    The problem is that
    endloop

    Hi..
    1. To Terminate the LOOP in Last record.
        LOOP AT ITAB.
            << PROCESSING LOGIC>>
             AT LAST.
               EXIT.
             ENDAT.
        ENDLOOP.
    2. It is necessary to Declare the Internal table with same structure as the Excel file
    3. It is not necessary to call the Screen Explicitly before filling the BDCDATA record.
        If you want to process the Screen Twice the Fill the SAME SCREEN twice in BDCDATA Table and set the DYNBEGIN = 'X' in both the cases.
    REWARD IF HELPFUL.

  • Not breaking out of loop

    I've written this piece of code to search through a file until it finds:
              BufferedReader in = new BufferedReader (new FileReader(outputFile));
              String name = null;
              String data = in.readLine();
              while (name == null)
                   System.out.print("Please enter your name: ");
                   name = kybd.nextLine();
                   kybd.nextLine();
                   while (data != null)
                        if (name.equalsIgnoreCase(data))
                             name = data;
                        else
                             name = null;
                        data = in.readLine();
                   System.out.println("Sorry, name not found.");
                   System.out.println();
              }I have some problems with the logic of it and it doesn't break out of the loops, can someone give me some advice as to where it's going wrong and how to correct this, thanks.
    I've now discovered that the "kybd.nextLine();" was causing it not to enter the first loop, however now I get a NullPointerException and I know what that is, but I do not know why it is happening here.
    Edited by: jnaish on Jul 2, 2008 6:40 AM

    jnaish wrote:
    Changed it to look like this:
              while (name == null || name == "no match")
    Don't do this. You're comparing object identity instead of comparing their values. Compare strings with .equals().
                   System.out.print("Please enter your name: ");
                   name = kybd.nextLine();
                   //kybd.nextLine();
                   while (data != null)You never set data (you did in your first example), so data will be null and your loop will not execute.
                        if (name.equalsIgnoreCase(data))
                             name = data;
                             System.out.println("Found.");
                        else
                             name = "no match";
                        data = in.readLine();
                   System.out.println("Sorry, name not found.");
                   System.out.println();
              }No exception anymore but, name doesn't become equal data either.Restructure your loop. What you're doing is just awkward.
    Pseudocode:
    function {
      get line of user input
      loop over lines in file {
        if user input is equal to line from file {
          print "found"
    }Edited by: nclow on Jul 2, 2008 2:11 PM

  • Coming out of loop

    DEAR TECHIS,,
    plz tell me the way to come out from the loop of item table
    i have devloped a bdc prog for Customer invoice fb70. for that i have used  two tables for header and item. here my problem is after posting the data. the loop is not breaking of item table to undersanding pupuse i m giving smalle
    as
    loop at header .
    performe...
            loop at item where acnt = header-acnt.
    perform........
           endloop.
    endloop.
    Here i didnt get the way to come out from the item tables loop.
    pls reply....
    Rewards for useful ans..
    thanks in advance...

    Hi Devalla,
    It's of sure that, your are looping the item table only when you have the acnt = header-acnt, in the Where condition of the loop.
    Stilll you find that your loop is not breaking up means its really a ?
    Try to debug and find out where is the probs?
    okay .. if you want to come out conditionally, place EXIT command at the begining or at the end of the Loop by placing a CHECK. with whatever you want either using the count of number of entries in the item table with respect to the header acnt field.
    if thing it's sure it's going to be some simple thing which block you...
    If still cant post the code.. with where it hooks...
    Reward points if useful

Maybe you are looking for

  • Installing hp updates after upgrading to windows 7

    I recently did a clean install (reformatted) of windows 7 on my touchsmart laptop, installed the updates off the windows 7 hp update page. However, the shortcut keys on the side of the touchscreen (the settings, mediasmart, screen rotate) no longer w

  • Can you use the same external hard drive for Time Machine backups and as an additional storage drive?

    I have an external HD that I've been using exclusively for Time Machine backups. I need to clear space on my hard drive, so I was thinking to move music & photos to an external drive.  Wondering if I can use the same one I have (which I'll aslo keep

  • Calendar so slow & minimal that it is useless

    I have always loved Palm and I can prove it because I own virtually every generation of device they have produced (except for the minor interium device upgrades) since the very first Pilot. I'm a hard core Palm evangelist and fenatic. To say that I a

  • Create pdf forms from a xml file for follow up information

    Forgive my amateurishness, I have a simple .xml that was created with excel with name, address, date of service, age, dob, account #, unit, and business name.  I need a form to be pre-populated with the .xml data but have other fields (mainly Yes/No

  • Camera Raw won't open in Photoshop CS6

    Wanting to begin using the Camera Raw plug-in for PS CS6, I find that it isn't active. (1) In Bridge CS6, the ACR icon in the top menu is grayed out; (2) after clicking a JPEG image file in Bridge, then right-clicking it, there's no option to open it