Re: loop condition using length
Hi friends,
in a loop condition i am using below coding.
LOOP AT I_FORM1 INTO W_FORM1.
A = STRLEN( W_FORM1-LOTNO ).
LOOP AT I_AUFM INTO W_AUFM WHERE CHARG+0(A) = W_FORM1-LOTNO.
ENDLOOP.
ENDLOOP.
But coming error is
The length specification "(A)" is not a numeric literal or a numeric constant.
how is it possible please help me any body.
Hello ,
Data type of variable A should be a integer .
Edited by: Annasaheb More on Jul 2, 2011 9:20 AM
Similar Messages
-
I pull fiftyfour bytes of data from MicroProcessor's EEPROM using serial port. It works fine. I then send a request for 512 bytes and my "read" goes into loop condition, no bytes are delivered and system is lost
Hello,
You mention that you send a string to the microprocessor that tells it how many bytes to send. Instead of requesting 512 bytes, try reading 10 times and only requesting about 50 bytes at a time.
If that doesn�t help, try directly communicating with your microprocessor through HyperTerminal. If you are not on a Windows system, please let me know. Also, if you are using an NI serial board instead of your computer�s serial port, let me know.
In Windows XP, go to Start, Programs, Accessories, Communications, and select HyperTerminal.
Enter a name for the connection and click OK.
In the next pop-up dialog, choose the COM port you are using to communicate with your device and click OK.
In the final pop
-up dialog, set the communication settings for communicating with your device.
Type the same commands you sent through LabVIEW and observe if you can receive the first 54 bytes you mention. Also observe if data is returned from your 512 byte request or if HyperTerminal just waits.
If you do not receive the 512 byte request through HyperTerminal, your microprocessor is unable to communicate with your computer at a low level. LabVIEW uses the same Windows DLLs as HyperTerminal for serial communication. Double check the instrument user manual for any additional information that may be necessary to communicate.
Please let me know the results from the above test in HyperTerminal. We can then proceed from there.
Grant M.
National Instruments -
Help with a while loop condition
I'm trying to write to a File. I ask the user for input, then I enter a while loop and test the condition. The loop works, but it won't stop. I've tried everything. Here is my code please help!!
thanks
inputline = keyboard.readLine();//read the keyboard
try{
while( inputline != null ){
DiskOut.println( inputline );
DiskOut.flush();
inputline = keyboard.readLine();//read the keyboard again
}//end while
}//end try
catch (IOException e) {
e.printStackTrace();
}//end catch
also i've tried these while loop conditions:
while(inputline != "\n" || inputline != "\r") and the sortwhile(inputline != "\n" || inputline != "\r")The condition
X!=Y OR X!=Z (given Y != Z)
is always true. X will always not be equal to at least one of the values. So you'll want to use:
while(!inputline.equals("\n") && !inputline.equals("\r"))In other words, "while inputline is not equal to either of them". Note the use of && instead of ||.
If "keyboard" is simply a BufferedReader on top of System.in (and not your own class), the trailing line feeds and carriage returns won't even be in the string returned by readLine(). Your best bet is this:
while(null != inputline && 0 != inputline.length())Make sure you type the two parts of that AND condition in the order above. If for whatever reason there are trailing \r and \n on the strings, you'll want to accomodate for platforms that may include both characters.
// trim the trailing newline characters
while(inputline.endsWith("\r") ||
inputline.endsWith("\n")) {
inputline = inputline.substring(0,inputline.length()-1);
// or maybe this will work if you don't mind losing
// the whitespace at the beginning of the string:
inputline = inputline.trim();Hope that helps somewhat. -
Hi there,
Working on a client/server chat application. On the client side app, everytime I want to send a message I create a new Thread called "SendingThread". See below.
import java.io.*;
import java.net.*;
public class SendingThread extends Thread
private Socket clientSocket;
private String messageToSend;
public SendingThread(Socket socket, String userName, String message)
super("SendingThread: " + socket);
clientSocket = socket;
messageToSend = userName + Constants.MESSAGE_SEPERATOR + message;
public void run()
try
PrintWriter writer = new PrintWriter(clientSocket.getOutputStream());
writer.println(messageToSend);
writer.flush();
writer.close();
catch(IOException ioe)
System.out.println("Server must have closed connection");
ioe.printStackTrace();
}As you can see the line writer.close() is important in regard to a Thread that is running on the server app called "ReceivingThread" (see below). In the ReceivingThread there is a line:
if((temp = input.readLine()) != null)
It blocks until I actually send a message to read in. This is expected. However, now I have a catch 22 situation. On the client side app, since I called writer.close(), this was necessary in order to get a null value during the readLine() call on the ReceivingThread on the server. The one line gets processed as expected. The stream is now closed and on the server side app, since this is true, the next iteration of the while loop attempts to read in another line but now it is alway null and thus I wind up with an endless loop condition. I introduced a "count" variable and a condition only so that the loop wouldn't get away too far. I was hoping it would block again, but it isn't. I believe the ReceivingThread is written correctly, but I need to somehow obtain a null value on the stream for message completion and also have the ReceivingThread block for the next message coming in.
Please advise,
Alan
public class ReceivingThread extends Thread
private BufferedReader input;
private MessageListener messageListener;
private boolean keepListening = true;
public ReceivingThread(MessageListener listener, Socket clientSocket)
super("ReceivingThread: " + clientSocket);
messageListener = listener;
try
clientSocket.setSoTimeout(50000);
input = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
catch(IOException ioe){ioe.printStackTrace();}
public void run()
StringBuffer messageBuffer = new StringBuffer();
String temp = "";
int messageCount = 0;
int count = 0;
//START:
while(keepListening)
while(true)
try
//In order to receive a null, the client app
//has to close the stream! Otherwise, this
//will block indefinitely.
System.out.println("blocking...");
if((temp = input.readLine()) != null)
if(messageCount == 0)
messageBuffer.append(temp);
messageCount++;
System.out.println("temp: " + temp);
else
//When we use the readLine method, it strips
//off the newline character, so we need to
//put it back.
messageBuffer.append("\n" + temp);
System.out.println("temp: " + temp);
else
break;
catch(IOException ioe)
System.out.println("IOException...");
ioe.printStackTrace();
//break;
}//end while
//System.out.println("out of inner while loop...message:\n" + messageBuffer.toString());
String message = messageBuffer.toString();
System.out.println("message: " + message);
StringTokenizer tokenizer = new StringTokenizer(message, Constants.MESSAGE_SEPERATOR);
if(tokenizer.countTokens() == 2)
System.out.println("message received");
messageListener.messageReceived(tokenizer.nextToken(), tokenizer.nextToken());
//reset string variables
messageCount = 0;
temp = "";
messageBuffer.delete(0, messageBuffer.length());
message = "";
else
//System.out.println("checking disconnect string: " + message);
if(message.equalsIgnoreCase(Constants.MESSAGE_SEPERATOR + Constants.DISCONNECT_STRING))
stopListening();
count++;
if(count > 3)break;
}//end while
try
//System.out.println("closing ReceivingThread");
input.close();
catch(IOException ioe){ioe.printStackTrace();}
public void stopListening()
keepListening = false;
}Edited by: ashiers on Nov 21, 2007 7:33 AM
Edited by: ashiers on Nov 21, 2007 7:34 AMI'm not quite sure what you want to happen here. Here is what I would expect from the code you posted:
*1.* The client connects and sends its message to the server.
*2.* The server iterates through the line-reading loop until it exhausts the input (input.readLine() == null) and breaks out of the while (true) loop. The "temp: foo" messages are written to standard output accordingly.
*3.* The server reaches the message portion of the loop and writes the "message: foo" to standard output.
*4.* The server hits the end of the "while (keepListening)" loop and (assuming that you didn't receive a disconnect message) keepListening is still true. So it loops back around.
*5.* The first time through the while (true) loop, the input is still empty (of course). So you get a null.
*6.* Next, you get a "message: foo" output.
*7.* Repeat *4* through *6* until your computer hardware fails or you abort the program. (Except that you added that count thing, so it'll loop three times and then break.)
What are you trying to make the "keepListening" loop do? It doesn't seem like it should be there at all. At no point does this reading thread get the opportunity to read from any other socket. It almost seems like you want to spawn one ReceivingThread for each Socket you receive from the ServerSocket; if that's the case, the main thread (or whichever thread you have running that code and spawning the ReceivingThreads should be inside of the while (keepListening) loop.
Any help? -
New object inside loop condition
I would like to create new object inside loop condition and use in its body
while(new File(localization).exists()){
//now would like use File object created above
}What's the notation for that?YoungWinston wrote:
TheGreatEmperor wrote:
I would like to create new object inside loop condition and use in its body
while(new File(localization).exists()){
//now would like use File object created above
}What's the notation for that?Encephalopathic gave it to you, but I'd worry about ending up with a never-ending loop. What about
if ((myFile = new File(fileString)).exists()) { ...instead?
Winston1) Same thing I put (except change the name "f" with "myFile")
2) you could get a never-ending loop with your answer (depending on the body)
3) The previous answer by Encephalopathic would NOT give a never-ending loop unless there was a never-ending listing of files with the name:
"Foo" + fileCounter + ".txt"; where "fileCounter" is incrementing (as done in his code) -
flash player has been installed multiple time without errors but bbc news website and even flash player help say it isn't. How do i get out of this loop? - using windows 7 ultimate and latest IE11
I have had the same problem for WEEKS and I cannot access any sites that use Flash. Flash has been installed on this computer since I bought it in 2012. I have allowed auto updates but for weeks the updates never get past Step 2 - is this because I do NOT want the Google Tool bar? I use NO tool bars as there is only 6 inches of vertical screen space. Is this because I uncheck wanting Chrome as a default browser? It is already installed, I just don't use it. I came to this site and ran the check is it installed and the system says it is either not installed or not enabled. Version 14 just downloaded about 30 minutes ago - but did not progress to Step 3 although a pop up screen came up with a finish button, which I clicked. WHAT is the problem and how do I fix it? If this were just a compatibility bug between IE11 and Adobe they have had plenty of time to fix it.
Stephanie HC -
BPM: Loop condition not coming outside of the loop
Hi Experts,
I am working on BPM. In the loop I am giving the condition as
(ForSyncResponse./p1:MT_Test_JDBC_Req_response/row_response/Row/indicator u2260 9)
If indication not equal to the 9(Integer) then it should come out of the loop otherwise loop needs to be repeat( Iam getting this data from the database through Send Synch step). When ever iam sending data other than 9 then it repeating if I send 9 also even though the loop condition is not satisfying and its keep on repeating the loop. Can you please let me know what might be ther problem.
Thanks & Regards,
PurushothamHi Prasadh,
I am able to give thie "Create the following expression in the expression editor:
/MT_Test_JDBC_Req_response/row_responseindicator != 9" expression
How can i give the second"(/MT_Test_JDBC_Req_response/row_responseindicator != 9 EX)" condition??
I tried with giving the AND but it is not allowing me to enter the 9.
Can you please let me know.
Thanks & Regards,
Purushotham -
We have a output xml in BPM as shown below :
<?xml version="1.0" encoding="utf-8" ?>
<Product>
<ProductRecord>
<ProductID schemeID="MaterialNumber" schemeAgencyID="MDM30_FILEADAPTER01" schemeAgencySchemeAgencyID="ZZZ">KRANTI_MAT1</ProductID>
<ProductID schemeID="ProductGUID" schemeAgencyID="QM3_002" schemeAgencySchemeAgencyID="ZZZ">416452CBD0746B23E10000000A1553FC</ProductID>
<ProductTypeCode>01</ProductTypeCode>
<Category>
<CategoryID schemeID="ProductCategoryGUID" schemeAgencyID="QM3_002" schemeAgencySchemeAgencyID="ZZZ">4162C19D0C250E78E10000000A1553FC</CategoryID>
<CategoryID schemeID="StandardCategoryID" schemeAgencyID="MDM30_FILEADAPTER01" schemeAgencySchemeAgencyID="ZZZ">MATCLASS2_ROOT</CategoryID>
</Category>
</ProductRecord>
</Product>
The product id tag is 1..undbounded.
We want a loop condition in BPM wherein as soon as we get a line of ProductID with schemeID="ProductGUID" then we want to exit the loop.
Can anybody help us with the loop condition.
Regards,
AnuragHi Prasadh,
I am able to give thie "Create the following expression in the expression editor:
/MT_Test_JDBC_Req_response/row_responseindicator != 9" expression
How can i give the second"(/MT_Test_JDBC_Req_response/row_responseindicator != 9 EX)" condition??
I tried with giving the AND but it is not allowing me to enter the 9.
Can you please let me know.
Thanks & Regards,
Purushotham -
Spliting files based on condition using multi mapping with BPM
Hi All,
Can any one please let me know How to <b>Splite the outbound records based on condition using multi mapping with Integration Process in BPM</b>?
Thanks
Govindu.Hi All,
Sorry for mistake this question for Exchange infrastructure guys.
Thanks,
Govindu -
JMM: legal to optimize non-volatile flag out of particular loop condition?
Does Java Memory Model allow JIT compiler to optimize non-volatile flag out of loop conditions in code like as follows...
class NonVolatileConditionInLoop {
private int number;
private boolean writingReady = true; // non-volatile, always handled inside synchronized block
public synchronized void setNumber(int n) {
while (!writingReady) { // non-volatile flag in loop condition
try { wait(); }
catch (InterruptedException e) { e.printStackTrace(); }
this.number = n;
this.writingReady = false;
notifyAll();
public synchronized int getNumber() {
while (writingReady) { // non-volatile flag in loop condition
try { wait(); }
catch (InterruptedException e) { e.printStackTrace(); }
this.writingReady = true;
notifyAll();
return number;
}...so that it will execute like this:
class NonVolatileConditionInLoopHacked {
private int number;
private boolean writingReady = true; // non-volatile, always handled inside synchronized block
public synchronized void setNumber(int n) {
if (!writingReady) { // moved out of loop condition
while (true) {
try { wait(); }
catch (InterruptedException e) { e.printStackTrace(); }
this.number = n;
this.writingReady = false;
notifyAll();
public synchronized int getNumber() {
if (writingReady) { // moved out of loop condition
while (true) {
try { wait(); }
catch (InterruptedException e) { e.printStackTrace(); }
this.writingReady = true;
notifyAll();
return number;
This question was recently discussed in [one of threads|http://forums.sun.com/thread.jspa?messageID=11001801#11001801|thread] at New To Java forum.
My take on it is that optimization like above is legal. From the perspective of single-threaded program, repeated checks for writingReady are redundant because it is not modified within the loop. As far as I understand, unless explicitly forced by volatile modifier (and in our case it is not), optimizing compiler "has a right" to optimize based on single-thread execution assumption.
Opposite opinion is that JMM prohibits such an optimization because methods containing the loop(s) are synchronized.gnat wrote:
...so that it will execute like this:
class NonVolatileConditionInLoopHacked {
private int number;
private boolean writingReady = true; // non-volatile, always handled inside synchronized block
public synchronized void setNumber(int n) {
if (!writingReady) { // moved out of loop condition
while (true) {
try { wait(); }
catch (InterruptedException e) { e.printStackTrace(); }
this.number = n;
this.writingReady = false;
notifyAll();
public synchronized int getNumber() {
if (writingReady) { // moved out of loop condition
while (true) {
try { wait(); }
catch (InterruptedException e) { e.printStackTrace(); }
this.writingReady = true;
notifyAll();
return number;
This question was recently discussed in [one of threads|http://forums.sun.com/thread.jspa?messageID=11001801#11001801|thread] at New To Java forum.
My take on it is that optimization like above is legal. From the perspective of single-threaded program, repeated checks for writingReady are redundant because it is not modified within the loop. As far as I understand, unless explicitly forced by volatile modifier (and in our case it is not), optimizing compiler "has a right" to optimize based on single-thread execution assumption.
Opposite opinion is that JMM prohibits such an optimization because methods containing the loop(s) are synchronized.One of the problems with wait() and your the proposed optimization is that "interrupts and spurious wakeups are possible" from wait() . See [http://java.sun.com/javase/6/docs/api/java/lang/Object.html#wait()] Therefore your wait() would loop without checking if this optimization would occur and a interrupt or spurious wake-up happened. Therefore for this reason I do not believe writingReady would be rolled out of the loop. Also the code isn't even equivalent. Once all the threads wake-up due to the notifyAll() they would spin in the while(true) and wait() again. I don't think the JMM prohibits such an optimization because methods containing the loop(s) are synchronized, but because it contains a wait(). The wait() is kind of a temporary flow control escape out of the loop.
Example:
writingReady is true
Thread A calls getNumber(). It waits().
Thread B calls setNumber(). It calls notifyAll() and writingReady is now false;
Thread A wakes up in getNumber() and while(true) loop and waits again(). //Big problem. -
Less or less than equal in the for loop condition
Hi,
What do you prefer, what is more common, which one is more easily readable, less or less than equal in the for loop condition?
for (int i = 0; i < arr.lenght; i++){..}
//or
for (int i = 0; i <= arr.lenght - 1 ; i++){..}I know this is basic programming and nothing to do with Java, so if this forum is not for this purpose, could you please suggest a general programming forum?
I would really appreciate it as I have many general questions :)
Thanks in advance,
lemonbostonlemonboston wrote:
Hi,
What do you preferPersonal preference, which is useless to you
, what is more common,Based on years of reading open source code, the first
which one is more easily readable, less or less than equal in the for loop condition?Personal opinion, which is useless to you
I would really appreciate it as I have many general questions :)If you don't want to think about it yourself (which you should be doing in stead of asking general questions), simply attack it lazily. Both examples achieve exactly the same, but the first one is less to type and to read. -
hello,
i am forwarding my codes here, and pls let me know how to write the loop conditions regarding this.
*& Report ZGOM1
REPORT ZGOM1.
CALL SCREEN 200.
*& Module USER_COMMAND_0200 INPUT
text
MODULE USER_COMMAND_0200 INPUT.
tables : ZPERSONAL.
data : begin of itab occurs 0,
NAME LIKE ZPERSONAL-NAME,
ADDRESS LIKE ZPERSONAL-ADDRESS,
TELNO LIKE ZPERSONAL-TELNO,
MOBILENO LIKE ZPERSONAL-MOBILENO,
COUNTRY LIKE ZPERSONAL-COUNTRY,
end of itab.
case sy-ucomm.
when 'DISP'.
select * FROM ZPERSONAL INTO corresponding fields of ITAB.
endselect.
when 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0200 INPUT
*& Module STATUS_0200 OUTPUT
text
MODULE STATUS_0200 OUTPUT.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
move-corresponding itab to ZPERSONAL.
ENDMODULE. " STATUS_0200 OUTPUT
please do the needful urgently,
thanks
sujahello,
i am forwarding my codes here, and pls let me know how to write the loop conditions regarding this.
please do the needful urgently,
thanks
suja -
New-CMGlobalCondition unable to create New script Condition using Power Shell
I am using config Manger 2012 and trying to use power shell cmdlet to create a new Global Condition using PowerShell but its not working for me using this
Do not understand how to use that command any idea.
New-CMGlobalCondition -DataType Boolean -DeviceType Windows -FilePath file.ps1 -Name test -ScriptLanguage PowerShell
Error comes as
New-CMGlobalCondition : No object corresponds to the specified parameters.
At line:1 char:1
+ New-CMGlobalCondition -DataType Boolean -DeviceType Windows -FilePath file.ps1 - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Confi...onditionCommand:NewGlobalConditionCommand) [New-CMGlobalCondition], I
temNotFoundException
+ FullyQualifiedErrorId : ItemNotFound,Microsoft.ConfigurationManagement.Cmdlets.AppModel.Commands.NewGlobalConditionCommandHi,
What's your version of SCCM? I ran this command line on SCCM 2012 R2 CU2.
It seems SCCM 2012 R2 CU2 fixed New-CMGlobalCondition cmdlet issue.
"The New-CMGlobalCondition cmdlet incorrectly requires use of the
-WhereClause parameter."
Description of Windows PowerShell changes in Cumulative Update 2 for System Center 2012 R2 Configuration Manager
Best Regards,
Joyce -
I can't accept iTunes store terms and conditions using my iPhone...
I can't accept iTunes store terms and conditions using my iPhone... It means there's no possibility to downoad any new app from the store...
Have you tried to restore it?If you have important data,back it up and restore it after entering DFU Mode.OR TRY TO RESTART YOUR PHONE.Google DFU MODE if you dont understand.Cheers!!!
-
Import Product Price and Condition using LSMW IDoc method
Hi Friends,
I am working on the Product Import to CRM from flat file using LSMW IDoc method using the "CRMXIF_PRODUCT_MATERIAL_SAVE" message type.
I am able to import the entire product with its required details except the Price and its conditions.
Can anyone please let me know which structure or with message type to be used to import the Product Price and condition using the IDoc method.
Please pass on your valuable comments.
Thanking you,
NaveenHi Naveen.
I am doing the same thing but only the product gets created and the details like short text, unit etc. do not get populated. The idoc gets processed successfuly. Can you share the fields that are required to be mapped or are mandatory.
Maybe you are looking for
-
How to collapse all folders in list view
If you search on this topic, there are many discussions about it without a real solution. The challenge is the following: you have a list view of many folders, some of which are expanded, and some are not ( to expand/collapse a folder you click on t
-
How to convert an excel "If" formula into a PCR?
I need to create a rule so that an overpayment recovery is only taken if the net pay is above an agreed amount with the employee. I can write the rule in excel but i'm struggling to convert this into a PCR. All help is welcome even if it's pointing m
-
Error while performing OSB Resource Provisioning in OEM12c
Hi , I tried the following, but faced the below errors mentioned. 1.Log on to Oracle Enterprise Manager Cloud Control 12c Workspace using "sysman" userid 2. Navigate to Enterprise-> Provisioning and Patching-> Middleware Provisioning. 3. From the Lis
-
Can anybody assist me with my T 43 OS choice menu during boot up. I had partitioned for two OS, windows XP and 2000 and now only reformatted one partition for storage and only use Win 2K. However during boot I still get the choice menu for both XP a
-
Creative cloud apps tab / error.
My creative cloud apps tab is empty even though the rest of the tabs work. In the apps tab it says download error, click to refresh. However this doesn't work. So i can't update the apps I have and can't download new ones since I can't even see them