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.

Similar Messages

  • How to come out if loop other using break.

    can u plz give an example where i want come out of if loop other than break , return keyword.
    example If
    {  System.out.println("   ");
    break;
    or return;
    }

    Can you please give an example how to terminate a
    loop other than using break or return.What is the purpose of the question?
    Do you have a bug where it appears a loop is being terminated some other way?
    You need to clarify.

  • ****How to come out of the  infinite loop by passing a perticular message

    Hi all,
    Can You Pl expalin me in detail "How to come out of the  infinite loop by passing a perticular message in BPM Scenarios"
    Thanks,
    Srinivasa

    Hi Potharaju,
    For this al you need to do is define an IP with two branches. One of the branch receives message of a particular type only. And the other branch is used for stopping the message processing. This is achieved using the correlation. Correlation makes sure that the message of the first type goes to the first branch only and that the message of second type should go to the second branch only. Now when the message of the second type is received, the control comes out of the infinite loop.
    Hope it makesit clear.
    Regards,
    Sanjeev.

  • My phone got into blind people(voice guidance) mode how to come out of it??

    my phone got into blind people(voice guidance) mode how to come out of it, i switched off my mobile even though it is in the same mode plz help me out as early as possible.

    Hi 9l and welcome to the community! Since you're new please be sure that you have checked out our Discussion guidelines.
    I have removed your IMEI for your privacy; however can you please advise what assistance you would like?
    What are your thoughts about this forum? Let us know by doing this short survey.

  • How to find out the n number of records inserted??

    In File to JDBC Scenarios, i am inserting n records in Oracle.
    How to find out the n number of records inserted??

    Hi,
    If you are using the statement "UPDATE_INSERT", get the response on element <insert_count>count</insert_count>. It will give you the inserted rows.
    This link can be very helpfull.
    [http://help.sap.com/saphelp_nw2004s/helpdata/en/2e/96fd3f2d14e869e10000000a155106/frameset.htm]
    regards.
    roberti

  • 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 standard transaction after giving error message

    Hi Experts,
        I have one requirement like i need to validate a field in standard transaction ME21N. If user enters wrong value then i have to give error message and leave the transaction ME21N immediately. If i do the code with error message then i struck in the same screen of ME21N(but i need to come out of ME21N).Can anybody help me for this particular scenario.
    Regards,
    Bujji

    Ahhh,  I see, this is a different story, now.
    How about issuing an Information message, and saying LEAVE TO TRANSACTION 'ME21N'.
    Message I001(00) with 'THere is some problem, transaction ending'.
    leave to transaction 'ME21N'.  " Or you may be able to use SY-TCODE here.
    Regards,
    Rich Heilman

  • How to come out of the output in sql 11g

    In sql 11g release 2 i am not able to come out of the query window..if i use ctrl c it throws me out of the window..
    Some times i fire control c it does through me out of the ouptut screen to sqlplus prompt but sometimes it just throws me out of the sql window..
    What is the best way to cancel a sql command in oracle 11g release 2.
    in sql . In 10 g things were easier.. dont know what do we need to do in 11g release 2
    Edited by: zycoz100 on Jan 27, 2013 10:57 PM

    Use the "exit" or cntrl +c command to terminate your SQL*Plus session.
    Read the doc too
    Stopping a Command while it is Running
    http://docs.oracle.com/cd/B19306_01/server.102/b14357/ch4.htm#i1040012
    How to use Sql*plus
    http://docs.oracle.com/html/A88829_01/ch3.htm
    Edited by: Rahul India on Jan 28, 2013 12:35 PM

  • How to find out which was the last Function Fired in a given schema ..?

    Hi All ,
    Suppose there is a function called track_account (Accnt_id, bank_name ...)
    I have a requirement wherein I need to find out when was the last date when this function was called , by which user and what was the parameter list that was passed .For example i this case - what accountid and bank_name combinations were passed .
    I know the information is stored in one of the V$ tables but am not able to locate the exact table and column that would give me this information .
    Please suggest .
    Edited by: user3481493 on Mar 8, 2010 10:58 PM

    amol_dev wrote:
    Thank you for your reply Brynjar.
    However, I was trying to figure out a way to do this without having to change the calling command line, because due to legacy reasons, it is not possible to change the command line calling the parent applications of this common code.You cannot change the command line, but you can change the applications?
    In main() do this:
    System.setProperty("whoami",(new Throwable().getStackTrace()[0].getClassName()));Elsewhere:
    String whoami = System.getProperty("whoami");

  • How to print out the text for Info record in ME23?

    Dear all,
    I need to print out a report of PO data. need to print out the text from Info record note (like the picture shown below) in ME23, how should I pull that field and display out?
    I need the solution urgently. Hope experts can help.
    Thank you very much.
    [http://img293.imageshack.us/img293/238/inforecordnd1.png]

    Please check below sample code:
    PARAMETERS: p_ebeln TYPE ebeln OBLIGATORY.
    TYPES: BEGIN OF ty_ekpo,
             ebeln TYPE ebeln,
             ebelp TYPE ebelp,
           END OF ty_ekpo.
    DATA: i_ekpo TYPE TABLE OF ty_ekpo,
          wa_ekpo TYPE ty_ekpo.
    DATA: l_name TYPE tdobname,
          i_tline TYPE TABLE OF tline,
          wa_tline TYPE tline.
    CONSTANTS: c_id   TYPE tdid VALUE 'F02',
               c_object TYPE tdobject VALUE 'EKPO'.
    AT SELECTION-SCREEN.
      SELECT SINGLE ebeln INTO p_ebeln
             FROM ekko
             WHERE ebeln = p_ebeln.
      IF sy-subrc NE 0.
        MESSAGE e001(00) WITH 'Enter valid PO Number'.
      ENDIF.
    START-OF-SELECTION.
      SELECT ebeln ebelp INTO TABLE i_ekpo
             FROM ekpo
             WHERE ebeln = p_ebeln.
      LOOP AT i_ekpo INTO wa_ekpo.
        CONCATENATE wa_ekpo-ebeln wa_ekpo-ebelp
           INTO l_name.
        CALL FUNCTION 'READ_TEXT'
          EXPORTING
            id                      = c_id
            language                = sy-langu
            name                    = l_name
            object                  = c_object
          TABLES
            lines                   = i_tline
          EXCEPTIONS
            id                      = 1
            language                = 2
            name                    = 3
            not_found               = 4
            object                  = 5
            reference_check         = 6
            wrong_access_to_archive = 7
            OTHERS                  = 8.
        IF sy-subrc EQ 0.
          LOOP AT i_tline INTO wa_tline.
            WRITE:/ wa_tline-tdline.
            " Format wa_tline-tdline in the way you need to print out
          ENDLOOP.
        ENDIF.
      ENDLOOP.
    Regards
    Eswar

  • How i know when a EXECUTE_QUERY retrieved last record

    Hi...
    How i know when the EXECUTE QUERY retrieved the last record in a block ....?
    Exist a trigger after trigger POST-QUERY?
    Regards
    Hector Gabriel Ulloa Ligarius
    Santiago of Chile
    http://es.groups.yahoo.com/group/desarrolloOracle/

    Kevin, sorry
    But the :system.last_record not change the value during the execution of EXECUTE_QUERY.
    Only useful when the data was retrieved into blocks...not during..
    Other mode?
    Regards
    Hector Gabriel Ulloa Ligarius
    Santiago of Chile
    http://es.groups.yahoo.com/group/desarrolloOracle/

  • How to know the internal table's last record

    Dear friends,
    Just I want to know my internal table last records, Ex:
    I am having the records in my internal table like this:
    Itab-col1
    1
    2
    3
    4
    5
    6
    7
    8
    9
    I want to know and print the last record, it maybe n number of records in my itab.
    If I used at last within a loop but it dosn't work its taking the all *** in header.
    How to know which is the last record in my internal table.
    Thanks,
    Sridhar.

    hi,
    sridher reddy
    1st describe ur table i.e read the number of entries in the table .....
    data : count type i.
    DESCRIBE TABLE <table name > LINES count.
    READ TABLE <table name > INDEX count.
    write : <table name>-<fieldname>.......... .
    by this way u can print the last record of your table

  • How to stop a query on a last record?

    I have a basic question. I have put a button on my form, which goes to the next_record (it goes on id-es). (on when button pressed action)
    But I have a problem, when it comes to the last_record, it goes to the nex record which is not there ( it does not exist). I would like to stop the query on my last record. How to do it?
    I had sometihng like it
    if :atletika.idRezultata is null
    last_record;
    else
    next_record;
    end if;
    but its not working.

    Hai,
    If the block's INSERT ALLOWED property is set to YES, then it will go to new record.
    Try setting this property to NO
    Regards,
    Manu.
    If this answer is helpful or correct, please mark it. Thanks.

  • How to get the first and the last record of every month within a time range in sql

    I am trying to get the first record and the last record of each and every month in a given date range using sql. I have a sample code
    where i have just selected everything within the date range now i have to extract the first and the last records of each and every month.
    SELECT PurOrderNum,
    OrderDate
    FROM Purchasing.PurOrder
    WHERE OrderDate >= '2013-02-28'
    AND OrderDate <= '2014-12-29'

    SELECT PurOrderNum,
    OrderDate
    FROM
    SELECT PurOrderNum,
    OrderDate,
    MAX(OrderDate) OVER (PARTITION BY DATEDIFF(mm,0,OrderDate)) AS MaxDate,
    MIN(OrderDate) OVER (PARTITION BY DATEDIFF(mm,0,OrderDate)) AS MinDate
    FROM Purchasing.PurOrder
    WHERE OrderDate >= '2013-02-28'
    AND OrderDate <= '2014-12-29'
    )t
    WHERE OrderDate = MaxDate
    OR OrderDate = MinDate
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • HT1430 my phone is recover mode how to come out from it and itune not showing my phone

    My iphone is in recovery mode and Itune is not showing the phone

    Hi 9l and welcome to the community! Since you're new please be sure that you have checked out our Discussion guidelines.
    I have removed your IMEI for your privacy; however can you please advise what assistance you would like?
    What are your thoughts about this forum? Let us know by doing this short survey.

Maybe you are looking for

  • RMAN Restoration failed from ASM to non asm

    While restoring the database, we are getting this error frequently, updated the media center they said media is intact, but there is some "NO POLICY" NO SCHEDULE" error. what does this mean. Could some one please help us why and how to resolve this i

  • Webdav Repositories

    I am trying to setup a webdav repository.  I used the help.sap.com and it states I can find the webdav url for current repositories in the details/properties/access links.  However, when I go there, this is the url available: http://<%hostname%>/irj/

  • I can't see the Copy dialog box - ideas?

    Yep, it's as simple as that. When I copy something, I can't see the dialog box showing the progress of the copy/move/etc. In the Window menu, it shows that there's a copy dialog open, but I just can't see it.  It's not on another desktop or in a corn

  • Need .avi fix for HP Media Smart?

    My system is Windows 7 Home Premium. HP Media Smart was able to play .avi files in the past but will not now. How can I fix this? Windows media does not work either. I checked my files with Gspot and they check out OK, i.e., correct codex.

  • Where  can i get the free server

    hi I want to accomplish the video conferencing ,where i can get the free server .can u help me? Thank you advance!!