Exit while in loop
hie guys
i am looping at two internal tables and want to exit through an if statement when a condition specified is not met however the code exits both loops.
loop at itab1.
loop at itab2.
if itab2-value eq 0.
exit.
else.
process.
endif.
endloop.
endloop.
however its not behaving as such..i have tryed to use return statement but it still wont work. i have verified my entries and the conditions exist to be true for some entries ie itab2-value ne 0 but the program exists. please assist.
regards.
Isaac Prince
YOU CAN USE IT
BUT THE SECOND TABLA MUS BE SORTED
LOOP AT T_DOCTOS_WORK.
T_DOCTOS_FINAL-BELNR_PAGO = T_DOCTOS_WORK-BELNR.
T_DOCTOS_FINAL-BUDAT_CONCILIA = T_DOCTOS_WORK-AUGDT.
T_DOCTOS_FINAL-BUDAT_PAGO = T_DOCTOS_WORK-BUDAT.
Se tratan las partidad del proveedor
READ TABLE T_DOC_BSIK_BSAK WITH KEY
AUGGJ = T_DOCTOS_WORK-GJAHR
AUGBL = T_DOCTOS_WORK-BELNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
INDEXK = SY-TABIX.
DO .
READ TABLE T_DOC_BSIK_BSAK INDEX INDEXK.
IF T_DOC_BSIK_BSAK-AUGGJ NE T_DOCTOS_WORK-GJAHR OR
T_DOC_BSIK_BSAK-AUGBL NE T_DOCTOS_WORK-BELNR OR
SY-SUBRC NE 0.
EXIT.
ELSE.
INDEXK = INDEXK + 1.
*MAKE YOUR CODE
ENDIF.
ENDDO.
ENDIF.
ENDLOOP
Similar Messages
-
To exit from the while(1) loop
Hi all ,
I have a simple question that if in a callback function of a command button, i use a While(bLoop)
loop , where bLoop is a boolean variable initially set to TRUE, then how can i break or exit from this while Loop by using a control on the front panel , which exits the while loop by setting bLoop = FALSE .
I have tried it but it is not exiting
Solved!
Go to Solution.The problem here is that CVI normally only executes one callback at a time. While you are in one control callback, no GUI processing and subsequent calls to other callbacks normally occurs.
You can try the following approach - but it is not really the best method:
while (b_loop) { // Inside a callback
... // Perform your tight program loop
ProcessSystemEvents (); // Force CVI to see if any GUI controls need servicing
If you have a different control callback to clear the global b_loop, this quick-and-dirty approach might work for you.
You should only use this technique for very simple programs - it can rapidly spiral out of control and end up in a mess if you're not careful. NI recommends that you do not use ProcessSystemEvents() inside a control callback.
JR -
How to terminate or exit a for loop when the user clicks on stop button
Actually my problem is to stop a loop when i click on stop button.
example:i have two buttons 'start' and 'stop'
in start buttom i wrote a for loop as
dim i as integer
For i=1 To 100000
print i
Next
when i click on start buuton it prints 'i' value up tp 100000.
my question is when i click on 'Stop' button the for loop has to terminate or Exit from the loop and should stops the execution.
Is it possible to termianate or Exit the 'for loop'
PS.Shakeer Hussain
HyderabadI am unable to stop the loop and application not at all allowing to Press the Stop button.
It seems like Hung, any advise ?
Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles btnStart.Click
btnStop.Enabled = True
btnSelectFile.Enabled = False
btnStart.Enabled = False
btnStop.Focus()
Dim strFileName As String = txtFileName.Text.ToString
Dim strLineText As String
If System.IO.File.Exists(strFileName) = True Then
Dim objReader As New System.IO.StreamReader(strFileName)
While objReader.Peek() <> -1 And stopclick = False
strLineText = objReader.ReadLine()
MsgBox(strLineText, MsgBoxStyle.Information)
Application.DoEvents()
Thread.Sleep(My.Settings("strDelay") * 1000)
'System.Diagnostics.Process.Start(My.Settings("strFireFoxLocation"), strLineText)
End While
End If
End Sub
Private Sub btnStop_Click(sender As Object, e As EventArgs) Handles btnStop.Click
stopclick = True
btnSelectFile.Enabled = True
btnStart.Enabled = True
btnStop.Enabled = False
End Sub
Raman Katwal
Please remember to mark the replies as answers if they help and unmark them if they provide no help -
hi guys,
does anyone know the correct way to exit a server loop, at the moment i have ....
while(!SrvInput.getEndProgStatus()){
sk = skt.accept();
System.out.println("Accepting new client connection");
serverThread st = new serverThread(sk, conn);
st.start();
this just loops around creating a new thread for every client that connects, i have a class SrvInput which reads input from the console so if the user types "quit" the end prog status flag is set to true and the server exits.
the problem is that for it to exit i need one more person to connect since it blocks on the accept call.
Does anyone know how i can sort this out
thanks for any helpHi.
I'm trying to solve the same problem. I solve it, sending myself a Socket conection and then existing the while code like this:
public void run()
while (!isFinish())
try
System.out.println("Waiting for connections.");
Socket client = serverSocket.accept();
if (!isFinish())
System.out.println("Accepted a connection from: "+client.getInetAddress());
LocationThread connect = new LocationThread(client);
}catch(Exception e)
System.out.println(e.getMessage());
e.printStackTrace();
try
System.out.println("Server exiting");
join(); // remove join(), this a test.....
serverSocket.close();
System.out.println("Server has exit");
}catch(Exception e)
System.out.println("Error al cerrar el Socket");
}This code belongs to the server side.
I do this, in a Button in a GUI interface.
try{
location.setFinish(true);
Socket s = new Socket(InetAddress.getLocalHost(),Integer.parseInt(result));
}catch(Exception e)
System.out.println("Error al tratar de terminar el servidor");
}But I have a problem, I want my server to wait for their childs to finish, How can I do it?.
a Join() , do the server to hang.
Any suggestion ?. -
Is usng while(true) loop in run mthd of thread good idea 2 make it wait ind
hi freinds.
sorry for writing short forms in my subject, but what i want to know is that is is using while(true) loop in run method of thread good idea to make it wait indefinately.
if not then what might be a good idea.
I Just need to Start a thread and make it wait indefinitely,
thanksNo. "while (true) {}" is a horribly bad way to do
nothing, as that thread will use 100% of the CPU.
What does "wait indefinitely" mean? Surely it can't
mean "wait forever", but if it doesn't mean that then
I can't guess what it does mean. Do you want to wait
until some condition is true? Or do you want to wait
a random amount of time? More information would help.Hello Dr.Clap, read your comments then checked my task manager and found that indeed it occupies 100% of CPU usage. thats really horrible , even i dont want that . ok i will explain u what i am trying to do along with my program on how i have accomplished it . please correct me where i went wrong.
My Requirement
my Application is deployed on JBOSS which has its JMS. now lets say i have defined a Queue named "MyAppQueue" and i know that all the senders whereever they may be will post there messages on this queue.
Now my responsibility is to write a MessageReceiver which is continously running and checking this queue for messages. whenever it receives a message it immidiately calls the messagesListener which processes the message.
So sow my requirement of Writing such MessageReceiver is that , it should always be in running mode(that means once i start it, it starts forever since this is going to be a REal time application) and continously checking the queue, as soon as some message comes it calls messageListener. and also that this messageReceiver should be fast , i mean coz many messages may come at once say 40-50 messages in a minute.
so please tell me how do i now write this MessageReceiver.
the way i have written
My Code
package test.jms;
import java.util.Properties;
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueReceiver;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class MyThreadReceiver implements Runnable{
String queueName = null;
Context jndiContext = null;
QueueConnectionFactory queueConnectionFactory = null;
QueueConnection queueConnection = null;
QueueSession queueSession = null;
Queue queue = null;
QueueReceiver queueReceiver = null;
TextMessage message = null;
MyQueueListener myQueueListener = new MyQueueListener();
/* (non-Javadoc)
* @see java.lang.Runnable#run()
String j;
public void run() {
// TODO Auto-generated method stub
while(true){
try {
// Thread.sleep(10000);
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
public static void main(String[] args) {
MyThreadReceiver myReceiver = new MyThreadReceiver();
myReceiver.establishConnection();
/* after connection is established to the queue, i am not closing the connection.i am making a thread and passing my class object to it and in run method i have written while(true ) loop to somehow make my MessageReceiver program run indefinately.. */
Thread thread = new Thread(myReceiver);
thread.start();
System.out.println("finished");
this method opens connection to the queue. and i am not closing this connection .
private void establishConnection(){
queueName = "queue/testQueue";
try {
Properties env = new Properties();
env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.NamingContextFactory");
jndiContext = new InitialContext();
}catch (NamingException e) {
System.out.println("Could not create JNDI API " + "context: " + e.toString());
System.exit(1);
try {
queueConnectionFactory = (QueueConnectionFactory)jndiContext.lookup("QueueConnectionFactory");
queue = (Queue) jndiContext.lookup(queueName);
}catch (NamingException e) {
System.out.println("JNDI API lookup failed: " + e.toString());
System.exit(1);
try {
queueConnection = queueConnectionFactory.createQueueConnection();
queueSession = queueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
queueReceiver = queueSession.createReceiver(queue);
queueReceiver.setMessageListener(myQueueListener);
queueConnection.start();
} catch (JMSException e) {
System.out.println("Exception occurred: " +
e.toString());
} finally {
//if (queueConnection != null) {
//try {
//queueConnection.close();
//}catch (JMSException e) {}
please correct my code. thanks in advance -
Which system variable is reset at the exit of a loop of an internal table
which system variable is reset at the exit of a loop of an internal table
a)sy-loop b)sy-index c)sy-dbcnt d)sy-tabixYou might want to revist your threads from Friday, and award points and mark as "Answered" or "Solved".
Regards,
Rich Heilman -
Path does not exit - While trying to save file on SharPoint Server 2013 from client machine
Hi,
I have installed Microsoft SharePoint Server 2013 Enterprise Edition on my testing Lab environment (On VM Workstation 10) on Windows Server 2012 with SQL server 2012, I can access all files stored at SharePoint Server from any physical machine, I can share
a single file among different people to work simultaneously, but here i stuck on saving any file from client machine to directly on SharePoint Server, Attached is the snap shot, whenever I try to save any file directly It says Path Does Not Exist, If I drag
and drop any file directly to SharePoint I do not see any error message.
I read from different posts that I need to Enable Desktop Experience Feature on Server 2012, which I installed but no positive result gained :(
I will appreciate for any possible help?
AliHi Ali,
Please try disabling the protected view per the link below and test the issue again:
http://social.technet.microsoft.com/Forums/en-US/b8381a19-3394-406f-8adb-1976f45460ef/path-does-not-exit-while-trying-to-save-file-on-sharpoint-server-2013-from-client-machine?forum=sharepointgeneral
You could simply type the url as http://sp/sites/sitename in the Filename place.
Regards,
Rebecca Tu
TechNet Community Support -
How to handle user exits while using BAPI
HI experts can any one help me on how to handle user exits while using BAPI. Do we need to handle it explicitly or standard BAPI will take care of it??.
Regards,
Hari KrishnaIf you have added some fields using append structures for screen enhancements, then you have to use appropriate user exits to fill these data while calling BAPI. Some BAPIs have EXTENSION structures to fill the custom data which can be processed using user exists or enhancements.
Regards
Vinod -
How to exit from a loop on 2 different conditions
Hello Experts
I’m trying to write a procedure in which I’m taking PROVINCE as an input parameter. All the provinces are stores in a table. I’m using a cursor and rowtype variable to check the province. After I finds province I displays province and its code. Everything works fine expect when I don’t find the province. I’m not sure how to exit from loop if I don’t find the province. I already uses exit when condition. I was expecting else condition should work and should exit from the loop but it doesn’t. Can please somebody show me how to exit if I don’t find province in the table through cursor.
Here is my code
set serveroutput on
variable G_TAX varchar2(10)
CREATE OR REPLACE PROCEDURE p_create(i_state VARCHAR2)is
CURSOR cur_bb_tax is
select * from bb_tax;
bb_tax_details bb_tax%rowtype;
begin
if not cur_bb_tax%isopen then
open cur_bb_tax;
end if;
loop
fetch cur_bb_tax into bb_tax_details;
if (bb_tax_details.state = i_state) then
dbms_output.put_line(bb_tax_details.state || bb_tax_details.idstate);
end if;
exit when bb_tax_details.state = i_state;
end loop;
close cur_bb_tax;
exception
when others then
dbms_output.put_line(SQLERRM);
end;
Thanks in advanceHello,
Why don't you use dbms_output.Put_line and print output to find why logic is not able to execute? Maybe upper case/lower case/whitespace. *Also put your code between \ to preserve formatting*.
Regards -
Stopping output tasks properly before exiting a For-loop
Hi,
I've been having some trouble exiting a For-loop conditionally. The problem is that when the loop is stopped conditionally (a button is pressed) the DAQ (NI USB 6353) outputs get stuck to whatever value they were in. I tried stopping the DAQ Assistant output task (1 sample on demand) before exiting the loop but that didn't solve the problem. Should this perhaps be done one iteration before exiting the loop or can it be done in the same iteration round?
What would be the "right" way to exit a for loop with output tasks so that the output signals would be 0V after exiting? I know that I could "force" feed the DAQ Assistant with 0V control before exiting but in this case that would be quite difficult...
Any ideas? Help is appriciated.Yes, I get it... However at this point I don't think that's an option.
Would this kind of solution work? ( I am not able to test all possible solutions in the real system which is why I would like to get a confirmation first)
The idea is to connect the output of the "Or" port to the "Stop" -ports of the DAQ Assistants in the loop.
Edit. Will the output automatically go to 0V if I just stop the task? I am not really sure about this.
Thank you.
Attachments:
exit-loop.jpg 8 KB -
User exit while creating delivery (VL01N)
Hi Experts,
Is there any User Exit, While creating Outbound Delivery with reference to Sales order using VL01N,subitem cannot be created without the related H.Level item.
So my requirement is:
Check Higher Level Item (VBAP-UEPOS), If Higher Level Item value is set for an item, ensure that the related item that the Higher Level Item value refers to is also on the same delivery. If not, then issue an error that sub item cannot be created without the related HLI item.
How to achieve this, Any user exit ? Help will be appreciated.
Thanks,
Ranjith.Hi,
You may use Report ZNEGI16 given in below link to find out the user exits and BADIs associated with the above T code.
How to find BADIs
Kindly let me know if this was of any help to you.
Regards,
Shayeree -
Badi / Exits while Saving a PO
Hi Experts ,
Is there any BADI / User Exits exits while Saving a PO from External System.
Thanx in Advance
pradiptaPradipta,
Check BADIs:
ME_PROCESS_PO, ME_PROCESS_PO_CUST
Thanks -
loop at itab.
if <CONDITION>
<EXIT LOOP>
endif
endloop.
this ths condition , pz tel how to exit from loopHi
Loop
statements
EXIT
Endloop.
Will comes out of the loop.
Regards,
Sreeram Kumar.Madisetty -
Should i let Main() exit while worker threads are still running?
what is the Java Best Programming Practices for the issue of having the
public static void main(String[] args) { ... }exit before the worker Threads that is starts exit?
letting main() exit first, or making it wait, has no practical difference.
yet, when others look at my code, what should it look like?
should i thread.join() on all worker threads, before main() exits?
imo: it appears to be bad style to let the main() exit while my session with the jvm is, essentially, still running.
yet, it is extra code that is not necessary.Strike that. Reverse it.
i.e.
>
1) Have main join the threads, and comment that you're doing so simply to preserve the notion of main as the umbrella for the program.
2) Make the threads daemons, and comment at the end of main that the daemon threads, and hence the program, may still run after main has completed.
>
should instead say:
1) Make the threads daemons, and have main join the threads, and comment that you're doing so simply to preserve the notion of main as the umbrella for the program.
2) Make the threads non-daemons (the default), and comment at the end of main that the non-daemon threads, and hence the program, may still run after main has completed.
Edited by: jverd on Oct 21, 2008 9:27 AM -
Search help exit while user double click
Hi,
As it was done earlier but while test facing some issue,Double clicked value from the output is not returned to input screen whatever thevalues only last value is returning to the screen
please ooverview some of my code,
IF callcontrol-step = 'DISP' or
callcontrol-step = 'SELECT' or "or "AND
callcontrol-step = 'RETURN'.
* EXIT.
SELECT *
from /ain/dm_loct
into table lt_loct.
IF sy-subrc eq 0.
READ TABLE shlp-INTERFACE into ls_interface INDEX 1.
if ls_interface-shlpfield = lc_gln. "'GLN'.
lv_cp_gln = ls_interface-value.
ENDIF.
loop at lt_loct INTO ls_loct.
CALL FUNCTION '/AIN/UI_MAPPED_LOC_ID_GET'
EXPORTING
IV_LOC_GUID = ls_loct-loc_guid
IV_ID_TYPE = lc_fmcg "'FMCG'
IMPORTING
ET_VALUE = lt_value.
* ET_RETURN =
READ TABLE lt_value into ls_value with key element = lc_gln.
* 'GLN'.
if sy-subrc = 0.
ls_loc_gln-GLN = ls_value-element_value.
ls_loc_gln-locdesc = ls_loct-locdesc.
APPEND ls_loc_gln to lt_valuex.
endif.
REFRESH lt_value.
ENDLOOP.
endif.
*-- Mape output data
if callcontrol-step = 'DISP' OR
callcontrol-step = 'SELECT'.
IF lv_cp_gln = '' AND lt_valuex IS NOT INITIAL.
CALL FUNCTION 'F4UT_RESULTS_MAP'
EXPORTING
* SOURCE_STRUCTURE =
apply_restrictions = gc_true "'X'
TABLES
shlp_tab = shlp_tab
record_tab = record_tab
source_tab = lt_valuex
CHANGING
shlp = shlp
callcontrol = callcontrol
EXCEPTIONS
illegal_structure = 1
OTHERS = 2.
* endif.
* exit.
Else.
refresh: record_tab[],lt_final.
LOOP at lt_valuex into ls_loc_gln where gln cp lv_cp_gln.
ls_loc_glnx-GLN = ls_loc_gln-gln.
ls_loc_glnx-locdesc = ls_loc_gln-locdesc.
APPEND ls_loc_glnx to lt_final.
ENDLOOP.
IF sy-subrc eq 0 and lt_final is NOT INITIAL.
CALL FUNCTION 'F4UT_RESULTS_MAP'
EXPORTING
* SOURCE_STRUCTURE =
apply_restrictions = gc_true "'X'
TABLES
shlp_tab = shlp_tab
record_tab = record_tab
source_tab = lt_final
CHANGING
shlp = shlp
callcontrol = callcontrol
EXCEPTIONS
illegal_structure = 1
OTHERS = 2.
else.
ENDIF.
IF record_tab[] is INITIAL.
message 'No values Exist' type 'S'.
ENDIF.
endif.sorry only first value is going to input screen
Maybe you are looking for
-
"Missing parameter values." -- Export and Print only...
I have a web application and I am using CrystalReportViewer. I am passing several parameters to Crystal using: report.SetParameterValue(field.Name, Session[field.Name]); I have session variables which will hold parameters needed to pass into the re
-
Apple gives an error signal saying that I need to be an adminstrator to make changes to all the users...there is only one adminstrator account and one guest account.
-
I have a letter size document (designed in Indesign CS 6 and saved as PDF) with 2p0 margins and with a rectangle shape witch is 0 from the document's top . When I print the document (with checked or unchecked Auto-Rotate and Center and paper source b
-
Hi, Password sync is not happening from AD to LDAP .user unable to login to the Directory server when a user changes their password by using ctrl+alt+del in AD with new password.But changing the password from LDAP then user can able to login to the A
-
Cool new video for Flex and CF but wheres the source files?
Here's the video: http://labs.adobe.com/technologies/flashbuilder4/tutorials/flexcf/ Very cool and very nice presentation. Thank you, Tim Buntel. But my CFCs dont look anything like that when I connect to them. What are the source files used in th