Very very simple method return question
Using a UML tool, the following code has been generated for a method called getScores.
//getScores
public String[] getScores(int nCount)
//your code goes here
return null;
}Can I just clarify what this method is returning here using the parameter nCount - a complete String array or just a position in the array?
And once i've put some code in the method body, i presume the return statement will no longer be null, but either the array or position in the array?
Can I just clarify what this method is returning here
using the parameter nCount - a complete String array
or just a position in the array?It is return an array of Strings.
>
And once i've put some code in the method body, i
presume the return statement will no longer be null,
but either the array or position in the array?Not automagically. You will need to return an array of Strings
Similar Messages
-
Design question: methods returning objects
I have a general design question. When, in general (and why), should you have a method alter an object via it's methods but not return the object as opposed to doing the same operation in a method and then return it.
Consider the two below methods which do basically the same thing. When is one desireable over the other, and why?
Cheers--
public void setMyIntField(SomeObject pObj){
pObj.setSomeInt(5);
public SomeObject setMyIntField(SomeObject pObj){
pObj.setSomeInt(5);
return pObj;
}Let me give a better example:
class FruitWorker{
private void someMethod(){
HashMap myCitrus = new HashMap();
HashMap myTropicals = new Hashmap();
// use my no return obj method
addFruitProps1(myCitrus,
"tartnes",
new FruitProperty("very!" ));
// use my return object method
myTropicals = addFruitProps2(myCitrus,
"sweetness",
new FruitProperty("little bit" ));
}// end method
private void addFruitProperties1(HashMap pFruitProps,
String pProp
FruitProperty pVal){
pFruitProps.add( pProp,pVal);
}// end method
private HashMap addFruitProperties2(HashMap pFruitProps,
String pProp
FruitProperty pVal){
pFruitProps.add( pProp,pVal);
return pFruitProps;
}// end method
}// end class -
Hi...
I am working on customizing existing JSP Page. The idea is to retrieve the customer name as show in 1 and send is as run time parameter to SQL query and use the result of select statement to pass it to 2.
<INPUT TYPE="HIDDEN" NAME="soldtoCustPartyName" VALUE="<%= soldtoCustPartyName %>">.............1
The above line of code gives the customer name. We need to find the site id for the above customer and pass it to the following line of code. site id will replace the hardcoded number '7945'.
pageContext.setAttribute("party_site_id", new BigDecimal(7945), PageContext.REQUEST_SCOPE);...............2
Hence we create database connection to find out site id. The query will return the site id depending upon the customer name as in 1. SQL statement will be something like:
select site_id from ..... where fixed conditions and sitename = (from 1).
How can we create SQL statement to take run time values.
For eg. we do the following to execute Query after connecting to the databse..
Statement statement = connection.createStatement();
ResultSet rs = null;
rs = statement.executeQuery("SELECT party_id from apps.hz_party_sites where cust_name='IBM'");
<% rs.next(); %>
<% out.print(rs.getInt("party_id")); %>
How can the above query be modified to take run time value for cust_name.
THIS IS VERY VERY URGENT.....PLEASE HELP.......Where are these run time values coming from? The user is entering the values into a form with that input?
If so, then the user will need to submit the form, you need a servlet to process the form, take the value from the parameter with the same name as the input, insert it into the SQL statement, and run the database query, get the results and store them in the context you want. -
Why no simple method for reading text files
I'd like to know, after all this time why there is no simple method of reading ext files into a string.
Yes, yes, I know all about buffered readers, (it took me long enough to figure them out) but they are cumbersome and seem to change every release (how many file methods have been deprecated...)
Here's what I'm looking for:
file.open();
file.read(String);
file.close();
No single character at a time, no loop - the whole file into a single string in one shot. If buffers are used, i want it hidden.
Perl, PHP, VB, C# all have this. Even Java has it when you write to a file.
So why not on read?
Yes, buffered streams are very elegant, but for what most programmers want to do, they are overkill and annoying.Just Dennis Ritchie's little joke.
Do you have a better reason for wanting the feature
other than that some other languages have it?Yes. It would save me time and help dozens of new programmers who continually ask this question in this and other forums. It is in other languages because people use it and want it - clearly Jarkata saw the need. If you don't like the idea, then I won't argue the point. We agree to disagree.
Also did you have an answer for my question?in java.io.file you can do the following: (i've used it, it works) Granted, you still have to use the buffered output streams, which in my opinion should be abstracted for a simple text read and write.
BufferedWriter outputStream = new BufferedWriter(new FileWriter(fileNewPath));
outputStream.write(fileContent);
outputStream.close(); -
Java.nio select() method return 0 in my client application
Hello,
I'm developing a simple chat application who echo messages
But my client application loop because the select() method return 0
This is my code
// SERVER
package test;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.Iterator;
import java.util.Set;
public class Server {
private int port = 5001;
public void work() {
try {
ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
serverSocketChannel.configureBlocking(false);
InetSocketAddress isa = new InetSocketAddress(port);
serverSocketChannel.socket().bind(isa);
Selector selector = Selector.open();
serverSocketChannel.register(selector, SelectionKey.OP_ACCEPT);
System.out.println("Listing on "+port);
while(selector.select()>0) {
Set keys = selector.selectedKeys();
for(Iterator i = keys.iterator(); i.hasNext();) {
SelectionKey key = (SelectionKey) i.next();
i.remove();
if (key.isAcceptable()) {
ServerSocketChannel keyChannel = (ServerSocketChannel)key.channel();
SocketChannel channel = keyChannel.accept();
channel.configureBlocking(false);
channel.register(selector, SelectionKey.OP_READ );
} else if (key.isReadable()) {
SocketChannel keyChannel = (SocketChannel) key.channel();
String m = Help.read(keyChannel );
Help.write(m.toUpperCase(), keyChannel );
} catch (IOException e) {
e.printStackTrace();
public static void main(String[] args) {
Server s = new Server();
s.work();
// CLIENT
package test;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.util.Iterator;
import java.util.Set;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
public class Client extends JFrame {
private String host = "localhost";
private int port = 5001;
private SocketChannel socketChannel;
private Selector selector;
public void work() {
try {
socketChannel = SocketChannel.open();
socketChannel.configureBlocking(false);
InetSocketAddress isa = new InetSocketAddress(host, port);
socketChannel.connect(isa);
selector = Selector.open();
socketChannel.register(selector, SelectionKey.OP_CONNECT | SelectionKey.OP_READ );
while(true) {
selector.select();
Set keys = selector.selectedKeys();
for(Iterator i = keys.iterator(); i.hasNext();) {
SelectionKey key = (SelectionKey) i.next();
i.remove();
if (key.isConnectable()) {
SocketChannel keyChannel = (SocketChannel) key.channel();
if (keyChannel.isConnectionPending()) {
System.out.println("Connected "+keyChannel.finishConnect());
} else if (key.isReadable()) {
SocketChannel keyChannel = (SocketChannel) key.channel();
String m = Help.read(keyChannel);
display(m);
} catch (IOException e) {
e.printStackTrace();
private void display(final String m) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
area.append(m+"\n");
textFieed.setText("");
private void sendMessage(final String m) {
Thread t = new Thread(new Runnable() {
public void run() {
try {
Help.write(m, socketChannel);
} catch (IOException e) {
e.printStackTrace();
t.start();
public Client() {
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(1);
textFieed.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode()== KeyEvent.VK_ENTER) {
String m = textFieed.getText();
sendMessage(m);
area.setEditable(false);
getContentPane().add(textFieed, "North");
getContentPane().add(new JScrollPane(area));
setBounds(200, 200, 400, 300);
show();
private String messageToSend;
private JTextArea area = new JTextArea();
JTextField textFieed = new JTextField();
public static void main(String[] args) {
Client s = new Client();
s.work();
// HELPER CLASS
package test;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
public class Help {
private static Charset charset = Charset.forName("us-ascii");
private static CharsetEncoder enc = charset.newEncoder();
private static CharsetDecoder dec = charset.newDecoder();
private static void log(String m) {
System.out.println(m);
public static String read(SocketChannel channel) throws IOException {
log("*** start READ");
int n;
ByteBuffer buffer = ByteBuffer.allocate(1024);
while((n = channel.read(buffer)) > 0) {
System.out.println(" adding "+n+" bytes");
log(" BUFFER REMPLI : "+buffer);
buffer.flip();
CharBuffer cb = dec.decode(buffer);
log(" CHARBUFFER : "+cb);
String m = cb.toString();
log(" MESSAGE : "+m);
log("*** end READ");
//buffer.clear();
return m;
public static void write(String m, SocketChannel channel) throws IOException {
log("xxx start WRITE");
CharBuffer cb = CharBuffer.wrap(m);
log(" CHARBUFFER : "+cb);
ByteBuffer buffer = enc.encode(cb);
log(" BUFFER ALLOUE REMPLI : "+buffer);
int n;
while(buffer.hasRemaining()) {
n = channel.write(buffer);
System.out.println(" REMAINING : "+buffer.hasRemaining());
log("xxx end WRITE");Here's the fix for that old problem. Change the work method to do the following
- don't register interest in things that can't happen
- when you connect register based on whether the connection is complete or pending.
- add the OP_READ interest once the connection is complete.
This doesn't fix all the other problems this code will have,
eg.
- what happens if a write is incomplete?
- why does my code loop if I add OP_WRITE interest?
- why does my interestOps or register method block?
For code that answers all those questions see my obese post Taming the NIO Circus
Here's the fixed up Client code
// CLIENT
package test
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.util.Iterator;
import java.util.Set;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
public class Client extends JFrame {
private String host = "localhost";
private int port = 5001;
private SocketChannel socketChannel;
private Selector selector;
public void work() {
try {
socketChannel = SocketChannel.open();
socketChannel.configureBlocking(false);
InetSocketAddress isa = new InetSocketAddress(host, port);
socketChannel.connect(isa);
selector = Selector.open();
int interest = 0;
if(socketChannel.isConnected())interest = SelectionKey.OP_READ;
else if(socketChannel.isConnectionPending())interest = SelectionKey.OP_CONNECT;
socketChannel.register(selector, interest);
while(true)
int nn = selector.select();
System.out.println("nn="+nn);
Set keys = selector.selectedKeys();
for(Iterator i = keys.iterator(); i.hasNext();)
SelectionKey key = (SelectionKey) i.next();
i.remove();
if (key.isConnectable())
SocketChannel keyChannel = (SocketChannel) key.channel();
System.out.println("Connected "+keyChannel.finishConnect());
key.interestOps(SelectionKey.OP_READ);
if (key.isReadable())
SocketChannel keyChannel = (SocketChannel) key.channel();
String m = Help.read(keyChannel);
display(m);
} catch (IOException e) {
e.printStackTrace();
private void display(final String m) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
area.append(m+"\n");
textFieed.setText("");
private void sendMessage(final String m) {
Thread t = new Thread(new Runnable() {
public void run() {
try {
Help.write(m, socketChannel);
} catch (IOException e) {
e.printStackTrace();
t.start();
public Client() {
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(1);
textFieed.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode()== KeyEvent.VK_ENTER) {
String m = textFieed.getText();
sendMessage(m);
area.setEditable(false);
getContentPane().add(textFieed, "North");
getContentPane().add(new JScrollPane(area));
setBounds(200, 200, 400, 300);
show();
private String messageToSend;
private JTextArea area = new JTextArea();
JTextField textFieed = new JTextField();
public static void main(String[] args) {
Client s = new Client();
s.work(); -
Can a method return a class ?
hi,
i have a simple question.
can a method return class value ?
in the below script i did'nt understand the commented line.
package com.google.gwt.sample.stockwatcher.client;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("login")
public interface LoginService extends RemoteService {
public LoginInfo login(String requestUri); //What is this ? is this a sample of what i asked ?
}The answer to your question is yes.
The idea is that an object calls a function of another object (passing in objects to the function as arguments) in which that object returns an object (note the arguments or returned value of the function may alternately be primitive types). Each object typically encapsulates data and provides a rich set of functions to the calling object so that calling object doesn't have to deal with the raw data directly. Therefore, not only does the calling object get the data it wants, but also a rich set of functions that can manipulate that data.
Example:
Book book = new Book();
int characterCount = book.getChapter(3).getParagraph(4).getSentence(12).getWord(8).getCharacterCount();
In the above, each object (Book, Chapter,Paragraph,Sentence,Word) has a rich set of functions it provides to its caller.
Example: the Sentence Object has a collection of word objects (raw data). Functions it provides to Paragraph object are:
Word getWord(int index), Words getWords(), int getWordCount().
If you haven't already done so, I suggest reading a book on Java from cover to cover to pick up such Object Oriented concepts. -
Need help in changing this simple method
This method searches an inventory vector for an object that wants to delete. It works successfully for the first occurence of the object....ignores the other occurences...
If I have three titles "Mash" it deletes the first one only ...I need to delete all of teh occurences....please help in improving this method... this method returns true if deleted succesfully, otherwise it returns false... your help is very much appreciated.
public boolean deleteMovie(MovieItem movie)
{ MovieData aMovie = new MovieData( queryTitle(movie.getTitle()) );
if ( isEmpty() || aMovie.getMovieSpecs() == null )
return false;
MovieData actualMovie = null;
int i = 0;
boolean found = false;
while( i < inventory.size() && !found )
{ actualMovie = (MovieData)inventory.elementAt(i);
if ( actualMovie.getMovieTitle().equals( aMovie.getMovieTitle() ) )
found = true;
else
i++;
if (found && notRented( actualMovie.getMovieSpecs() ) )
{ inventory.removeElementAt(i);
return true;
else
{ return false;removeElementAt removes only one element from the vector. If you want to remove N items from a vector you need to call removeElementAt N times. But you currently call it only once.
Here's your code formatted a bit more nicely:public boolean deleteMovie(MovieItem movie) {
MovieData aMovie = new MovieData(queryTitle(movie.getTitle()));
if (isEmpty() || aMovie.getMovieSpecs() == null)
return false;
MovieData actualMovie = null;
int i = 0;
boolean found = false;
while (i < inventory.size() && !found) {
actualMovie = (MovieData) inventory.elementAt(i);
if (actualMovie.getMovieTitle().equals(aMovie.getMovieTitle()))
found = true;
else
i++;
if (found && notRented(actualMovie.getMovieSpecs())) {
inventory.removeElementAt(i);
return true;
} else {
return false;
}As you can see, "inventory.removeElementAt(i);" is not in the loop -
Qemu with kvm is very, very slow
Hi!
I first installed kvm by following http://wiki.archlinux.org/index.php/Kvm
And I also tried the "using qemu with kvm support" method from http://wiki.archlinux.org/index.php/QEMU
With both methods, a VM is very, very slow (when i start an iso, you literally see it render the things, and after that when you get the grub menu, it takes ages for the pointer to move if you press the arrow keys).
I'm on a Dell laptop with Intel C2D cpu with VT support (and enabled in bios, I checked)
[dieter@dieter-dellD620-arch ~]$ egrep '^flags.*(vmx|svm)|model name' /proc/cpuinfo
model name : Intel(R) Core(TM)2 CPU T7200 @ 2.00GHz
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm lahf_lm tpr_shadow
model name : Intel(R) Core(TM)2 CPU T7200 @ 2.00GHz
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm lahf_lm tpr_shadow
[dieter@dieter-dellD620-arch ~]$ lsmod | egrep 'qemu|vbox|kvm'
kvm_intel 43752 0
kvm 169896 1 kvm_intel
[dieter@dieter-dellD620-arch ~]$ cat /etc/udev/rules.d/65-kvm.rules
KERNEL=="kvm", NAME="%k", GROUP="kvm", MODE="0660"
[dieter@dieter-dellD620-arch ~]$ ls -alh /dev/kvm
crw-rw---- 1 root kvm 10, 232 2009-07-18 17:12 /dev/kvm
[dieter@dieter-dellD620-arch ~]$ grep kvm /etc/group
kvm:x:78:dieter
anyone an idea?damjan wrote:
try qemu-kvm-0.10.5, it's the stable qemu with additional kvm support:
http://sourceforge.net/projects/kvm/fil … z/download
also, in the qemu monitor you can check to see if kvm is used with "info kvm" .. should return "kvm support: enabled"
finally, the grub menu is using old BIOS APIs and cpu pooling since it's running in 16bit mode with no drivers. It uses up 100% of one of my cores when I leave a VM on the grub menu. Make sure you run a serious OS soon and check performance there.
Thanks
- i am using 0.10.5 (this is the version that Arch has packaged)
- it says kvm enabled, and you're right, once it goes out of grub, it goes much faster!
- apparently my keyboard arrows are just plainly being ignored -
Simple Crop tool question... how do I save the crop section?
Hi,
I have a very simple crop tool question. I'm a photoshop girl usually... so Illustrator is new to me. When I select the crop section I want... how do I save it?... if I select another tool in the tool panel, the crop section disappears and I can't get it back when I re-select Crop tool. If I select Save as... it saves the whole document...and not just my crop section.
Like I said, simple question...but I just don't know the secret to the Illustrator crop tool.
Thanks!
YzzaEither press the Tab key or F key.
-
Exchange 2013 CU5 , Exchange Power Shell very very very slow reasponse when using get command.
First my organize has Exchange on 2 site like
site A (internet facing) : 2CAS 2 MB all are Services pack1
site B (DR Site , no user active on this site) : 2CAS 2MB all are Services pack 1
so today I upgrade Exchange 2013 from SP1 to CU5 start on "site B" and I found this issue and the details is....
When I open EMS on any CU5 for query something (like get-mailboxdatabasecopystatus) the response return very slow and some query will not return at all (like get-owavirtualdirectory).
But If I using EMS on SP1. Everything is ok then I try to use EMS on SP1 connect to CU5 and try to query something. the result is
some query command cannot return for any result that are server on siteB (just some query command)
Problem
EMS on CU5 return very slow result.
EMS on SP1 still ok.
Does anyone face this problem before for CU5??? Please help me figure this out. Thank you
reply from Social.technetHi,
Have you used the above cmdlets to check your Exchange server health?
"all other command that I ran on EMS didn't logged on event viewer.", my environment is the same with you. I use Exchange 2013, only errors will be displayed in MSExchange Management. Actually, it is not related to slow EMS response.
Hope it helps.
Best regards,
Amy Wang
TechNet Community Support -
UPDATE ROUTINE --- CUBE --- ODS Very Very URGENT
Hi Collegues/Friends ,
First I need to thank for the intiators of this site , as I came to know that for many
problems we will get different best solutions ... Hoping the same I am posting a question
which is very very very urgent as the client is running after me for this .
My Requirement is as Follows. ..
I Moving the data from Cube to ODS . While i need to write a routine for an extra field in
ODS based on Billing Quantity in Base Unit of Measure . The Key Field in the ODS Is UNIQKEY
Transaction and It is a Characterstic in the Cube and we have MAterial as another
Characteristic and core element as navigational attribute .
In the Cube for every UNIQKEY transaction- there are more than One line items.
My data fields in the ODS are Billing Quantity in Base Unit of MEasure and and EXTRA FIELD
: No of Items in Transaction . But the thing is that I have only Billing Quantity in Base
Unit of Measure in cube as a key figure
BAsing on the UNIQKEY transcation and Billing Quantity In Base Unit Of Measure I need to
populate the No of Items in Transaction... For this i need to write a routine .
Let suppose say that for the Materials the core elements are as follows
Material Core element
10 1 -- fuel -- In liters
20 2 -- Cigar - in PAck
30 3 -- Coke - in Cans
Now Lets see how the records are there in InfoCUbe
Uniqkey / Material / Core element /Billin Quantiy
A / 10 / 1 / 22
B / 30 / 3 / 2
C / 10 / 1 / 15
C / 30 / 3 / 2
D / 20 / 2 / 10
D / 30 / 3 / 2
And IN the ODS -- I need to Populate the No OF items in Transaction.
the Logic behind this as follows .
1.if Materail is of type 1(Mean if the core element - 1)
I need to Populate the No of items in tnx = 1
2.If Material id of type 2 or 3 I need to populate the billing quantity to the no of
transcations.
3. If the Uniqkey tanscation contains two line items as suppose that you have 20 litres of
fuel and 2 cans of coke, then No of Items in the transaction should be 3 and Billing
Quantity in BUoM 22
billing quantity in BUoM = 20 litres for the first line item and 2 for the second line
item...
then as the first line item is fuel, field No OF Items in the Transcation should be 1
(replacing the 20) + 2 = 3
so the final result in the ODS should be billing quantity in BUoM = 22 and The Items in the
Transcation = 3
For this I have Written a Rouinte like this for that field
PROGRAM UPDATE_ROUTINE.
$$ begin of global - insert your declaration only below this line -
TABLES: /BI0/PMATERIAL.
DATA: TITEMS LIKE /BIC/AZPOCODS00-/BIC/ZTITEMS,
CORE_ELEMENT like /BI0/PMATERIAL-RPA_WGH1.
$$ end of global - insert your declaration only before this line -
FORM compute_data_field
TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring
USING COMM_STRUCTURE LIKE /BIC/CS8ZPOCTUS04
RECORD_NO LIKE SY-TABIX
RECORD_ALL LIKE SY-TABIX
SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
CHANGING RESULT LIKE /BIC/AZPOCODS00-/BIC/ZTITEMS
RETURNCODE LIKE SY-SUBRC "Do not use!
ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
$$ begin of routine - insert your code only below this line -
fill the internal table "MONITOR", to make monitor entries
check not COMM_STRUCTURE-material is initial.
select SINGLE RPA_WGH1
INTO CORE_ELEMENT
from /BI0/PMATERIAL
where
material = COMM_STRUCTURE-material
and OBJVERS <>'D'.
IF CORE_ELEMENT EQ '1'.
TITEMS = '1'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = titems
IMPORTING
OUTPUT = titems
ELSE.
TITEMS = COMM_STRUCTURE-BILL_QTY.
ENDIF.
result value of the routine
RESULT = TITEMS..
if abort is not equal zero, the update process will be canceled
ABORT = 0.
$$ end of routine - insert your code only before this line -
Does it satisfy all the conditions ?? mentioned above if . As far As i know as the only key
field in the transcation it will satisfy the first two conditions .
I want to know or If possioble anybody pls take some pain for me to send the code or any
Ideas for satisfying all the conditions.
Hope I will get immediate replies....
Mail me to [email protected]Reddy,
Please do not post in all sections ... makes it hard to follow up on posts..
Arun -
Error during GR(very very urgent)
Hi all,
i am using a developed program for GR.i used this program before.there was no error.but now i am facing error like
<b>PO ordered quqntity exceeded by 18,000 EA.</b>.i am using <b>BAPI_GOODSMVT_CREATE</b> for goods transfer.
In the selection screen, i am putting
PO number- PO1
material number- MAT
GR quantity- 18,000
delivery order-111
i want to receive the material MAT of quantity 18,000 from that PO.initially i have ordered PO quntity as 1 lakh. Till now i have received 42,000 materials,now i try to receive 18,000 materials.but it is showing this type of error.
This error is fired from the return parameter of that BAPI only.error having message class-M7 & error no-022
is comming.
i am giving my coding below.plz suggest where is the problem.it is very very urgent.recently my company has added some patches to update the SAP.is this the cause for that error.plz suggest.
any idea will be highly appreaciated.
Regards
REPORT zmui001
LINE-SIZE 140
LINE-COUNT 65
NO STANDARD PAGE HEADING.
*-- DATA DECLARATION--
*-- tables
TABLES : ekpo,
ekbe,
marv.
*--Includes
INCLUDE : <icon>. " Include for Icons
*-- Types
TYPES : BEGIN OF t_mseg,
ebeln LIKE ekko-ebeln,
name1 LIKE lfa1-name1,
lifnr LIKE lfa1-lifnr,
eknam LIKE t024-eknam,
mblnr LIKE mkpf-mblnr,
matnr LIKE ekpo-matnr,
maktx LIKE makt-maktx,
lgort LIKE mseg-lgort,
charg LIKE mseg-charg, "chg: 10/17/2005
menge LIKE mseg-menge,
budat LIKE mkpf-budat,
bldat LIKE mkpf-bldat, " chg : 08/18/2003
xblnr LIKE mkpf-xblnr,
END OF t_mseg.
DATA: BEGIN OF t_ekbe,
ebeln LIKE ekbe-ebeln,
ebelp LIKE ekbe-ebelp,
bwart LIKE ekbe-bwart,
matnr LIKE ekbe-matnr,
menge LIKE ekbe-menge,
END OF t_ekbe,
BEGIN OF t_ekpo,
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
menge LIKE ekpo-menge,
END OF t_ekpo.
TYPES : BEGIN OF t_options.
INCLUDE STRUCTURE itcpo.
TYPES : END OF t_options.
*--Internal tables
DATA: BEGIN OF i_item OCCURS 50. "Create Material Document Item
INCLUDE STRUCTURE bapi2017_gm_item_create.
DATA: END OF i_item .
DATA: BEGIN OF i_return OCCURS 20. "Return parameter
INCLUDE STRUCTURE bapiret2.
DATA: END OF i_return.
DATA: BEGIN OF i_part OCCURS 0, " Internal table for split data
part(20),
END OF i_part.
DATA: BEGIN OF i_return1 OCCURS 20. "Return parameter
INCLUDE STRUCTURE bapiret1.
DATA: END OF i_return1.
*-- Work areas
DATA: BEGIN OF wa_header . "Material Document Header Data
INCLUDE STRUCTURE bapi2017_gm_head_01.
DATA: END OF wa_header .
DATA: BEGIN OF wa_return . "Output Structure
INCLUDE STRUCTURE bapi2017_gm_head_ret.
DATA: END OF wa_return .
*-- Work areas
DATA: wa_mseg TYPE t_mseg,
wa_ekbe LIKE t_ekbe,
wa_ekpo LIKE t_ekpo,
wa_options TYPE t_options,
i_ekbe LIKE STANDARD TABLE OF t_ekbe,
i_ekbe2 LIKE STANDARD TABLE OF t_ekbe,
i_ekpo LIKE STANDARD TABLE OF t_ekpo.
*---Variables
DATA: v_first, " variable to get first digit
v_set TYPE c,
v_found TYPE p,
v_menge TYPE p,
v_ebeln LIKE ekko-ebeln,
v_lifnr LIKE ekko-lifnr,
v_belnr LIKE ekbe-belnr,
v_postdate LIKE mkpf-budat,
v_bukrs LIKE marv-bukrs,
v_datum LIKE sy-datum,
v_lgort LIKE mard-lgort, " Stge. location
v_bwart LIKE mseg-bwart, " Movement type
v_infnr LIKE eina-infnr, " Info record no.
v_ltsnr LIKE eina-ltsnr.
*---Constants
CONSTANTS: c_comma TYPE c VALUE ',', " For splitting data at commas
c_01(2) TYPE c VALUE '01', " For movement code in Bapi
c_b TYPE c VALUE 'B', " For mvt. Indicator in Bapi
c_save(4) TYPE c VALUE 'SAVE', " For button text
c_clear(5) TYPE c VALUE 'CLEAR', " For clear button
c_mvmt(4) TYPE c VALUE 'MVMT',
c_ok(2) TYPE c VALUE 'OK',
c_error(5) TYPE c VALUE 'Error'.
*--SELECTION SCREEN DESIGN--
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME.
PARAMETERS: p_bar(75) , " Scanned data from barcode
p_ebeln LIKE ekko-ebeln, " PO number
p_matnr LIKE ekpo-matnr, " Material number
p_menge LIKE ekpo-menge, " Quantity
p_lifnr LIKE ekko-lifnr, " Vendor code
p_frbnr LIKE mkpf-frbnr, " Reference doc for goods mvt
p_status(5) TYPE c.
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN PUSHBUTTON 15(10) v_save USER-COMMAND mvmt.
SELECTION-SCREEN PUSHBUTTON 40(10) v_clear USER-COMMAND clear.
INITIALIZATION -
INITIALIZATION.
v_save = c_save .
v_clear = c_clear.
*--AT SELECTION_SCREEN--
AT SELECTION-SCREEN .
IF sy-ucomm = c_clear.
PERFORM f_clear.
ELSE.
IF sy-ucomm <> c_mvmt.
if not sy-tabix is initial and sy-ucomm <> c_mvmt.
*--- Extracting the data by splitting the scanned values.
PERFORM f_get_split_data.
*--- Validating the input data.
PERFORM f_check_inputs.
ELSE .
*--- Validating the input data.
PERFORM f_check_inputs.
*-- Determining the posting date and period check.
PERFORM f_get_posting_date.
*---Post goods movement
PERFORM f_post_receipt.
ENDIF.
ENDIF.
SUBROUTINES *
*& Form f_check_inputs
Validating the input parameters
FORM f_check_inputs.
*-- Validating material no.
SELECT SINGLE matnr INTO p_matnr
FROM mara
WHERE matnr = p_matnr.
IF sy-subrc = 4.
p_status = c_error.
MESSAGE e003(zm) WITH 'Material no.'.
ENDIF.
*-- Validating JHT reference no.
SELECT SINGLE ebeln
lifnr
bukrs
INTO (p_ebeln, v_lifnr , v_bukrs)
FROM ekko
where unsez = p_unsez. chg:07072003
WHERE ebeln = p_ebeln.
IF sy-subrc = 4.
p_status = c_error.
MESSAGE e003(zm) WITH 'Purchase order no.'.
ENDIF.
*-- Validating material po combination
SELECT SINGLE *
FROM ekpo
WHERE ebeln = p_ebeln
AND matnr = p_matnr.
IF sy-subrc = 4.
p_status = c_error.
MESSAGE e003(zm) WITH 'Purchase order no.' ' and Material no.'.
ENDIF.
*--- Checking for DO entry . (chng : 30/06/2003)
IF p_frbnr IS INITIAL.
MESSAGE e018(m7) WITH 'Delivery no.'.
p_status = c_error.
PERFORM f_clear.
ENDIF.
*-- Validating material po do combination
SELECT SINGLE a~belnr
INTO v_belnr
FROM ekbe AS a
INNER JOIN mkpf AS b
ON abelnr = bmblnr
AND agjahr = bmjahr
WHERE a~ebeln = ekpo-ebeln
AND a~ebelp = ekpo-ebelp
AND b~xblnr = p_frbnr.
IF sy-subrc = 0.
MESSAGE e019(zm) WITH v_belnr.
p_status = c_error.
PERFORM f_clear.
ENDIF.
p_status = c_ok.
ENDFORM. " f_check_inputs
*& Form f_get_split_data
Extracting the data by splitting the Scanned data
FORM f_get_split_data.
*-- Splitting the data at commas
SPLIT p_bar AT c_comma INTO TABLE i_part.
*-- Assigning the parts to variables.
LOOP AT i_part.
v_first = i_part-part+0(1).
TRANSLATE v_first TO UPPER CASE.
CASE v_first .
WHEN 'V'.
p_lifnr = i_part-part+1(10).
WHEN 'P'.
p_matnr = i_part-part+1(18).
WHEN 'Q'.
p_menge = i_part-part+1(13).
WHEN 'K'.
p_ebeln = i_part-part+1(10).
WHEN 'D'.
p_frbnr = i_part-part+2(16).
WHEN OTHERS.
CONTINUE.
ENDCASE.
ENDLOOP.
ENDFORM. " f_get_split_data
*& Form f_get_posting_date
Determing the posting date for document
FORM f_get_posting_date.
*-- get the current period for todays date.
DATA: l_period LIKE t009b-poper.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = sy-datum
i_periv = 'K4'
IMPORTING
e_buper = l_period
E_GJAHR =
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*-- Determining whether the open period
SELECT SINGLE *
FROM marv
WHERE bukrs = v_bukrs.
IF sy-subrc = 0.
IF l_period = marv-lfmon .
v_postdate = sy-datum.
ELSE.
CALL FUNCTION 'BAPI_CCODE_GET_FIRSTDAY_PERIOD'
EXPORTING
companycodeid = v_bukrs
fiscal_period = marv-lfmon
fiscal_year = marv-lfgja
IMPORTING
first_day_of_period = v_postdate
return = i_return1.
IF NOT i_return[] IS INITIAL.
LOOP AT i_return1.
MESSAGE i016(zm) WITH i_return-message.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " f_get_posting_date
*& Form f_post_receipt
Post the goods receipt for entered data.
FORM f_post_receipt.
PERFORM f_fill_item.
PERFORM f_fill_header.
PERFORM f_execute_transfer.
PERFORM f_clear.
ENDFORM. " f_post_receipt
*& Form f_fill_item
Updating the item data for the GR
FORM f_fill_item.
Checking for IQC cycle is done here.(chng : 23/07/2003)
PERFORM f_check_iqc.
*---- Assigning movement type as per IQC cycle.(chng : 23/07/2003)
IF v_lgort IS INITIAL.
MOVE '101' TO i_item-move_type.
SELECT SINGLE lgort INTO i_item-stge_loc
FROM ekpo
where ebeln = v_ebeln and " chg :07/07/2003
WHERE ebeln = p_ebeln AND
matnr = p_matnr .
ELSE.
MOVE v_lgort TO i_item-stge_loc.
MOVE v_bwart TO i_item-move_type.
ENDIF.
MOVE p_matnr TO i_item-material.
MOVE p_menge TO i_item-entry_qnt.
move v_ebeln to i_item-po_number. " 07/07/2003
MOVE p_ebeln TO i_item-po_number.
MOVE v_lifnr TO i_item-vendor.
MOVE c_b TO i_item-mvt_ind.
select single ebelp into i_item-po_item " chg :29/07/2003
from ekpo
where ebeln = p_ebeln
and matnr = p_matnr
and elikz = ''.
SELECT ebeln
ebelp
matnr
menge
INTO CORRESPONDING FIELDS OF TABLE i_ekpo
FROM ekpo
WHERE ebeln = p_ebeln
AND matnr = p_matnr
AND loekz = '' .
SORT i_ekpo BY ebeln ebelp matnr.
LOOP AT i_ekpo INTO wa_ekpo.
IF v_found = 0.
SELECT ebeln ebelp
bwart menge
INTO CORRESPONDING FIELDS OF TABLE i_ekbe
FROM ekbe
WHERE ebeln = p_ebeln
AND ebelp = wa_ekpo-ebelp
AND matnr = p_matnr.
and elikz = '' . CHG -- 03/19/2004
IF sy-subrc = 0.
LOOP AT i_ekbe INTO wa_ekbe .
IF wa_ekbe-bwart = '101'.
v_menge = v_menge + wa_ekbe-menge.
ENDIF.
IF wa_ekbe-bwart = '102'.
v_menge = v_menge - wa_ekbe-menge.
ENDIF.
IF wa_ekbe-bwart = '122'.
v_menge = v_menge - wa_ekbe-menge.
ENDIF.
ENDLOOP.
chng: 03/19/2004 compare po qty against receipt
v_menge = v_menge + p_menge .
IF wa_ekpo-menge >= v_menge .
v_found = 1.
MOVE wa_ekpo-ebelp TO i_item-po_item.
ENDIF.
ELSE .
v_found = 1.
MOVE wa_ekpo-ebelp TO i_item-po_item.
ENDIF.
ENDIF.
CLEAR : wa_ekbe, i_ekbe, v_menge.
ENDLOOP.
IF v_found = 0 .
MESSAGE e003(zm) WITH ' delivery items'.
ENDIF.
APPEND i_item.
CLEAR : i_item, v_found .
ENDFORM. " f_fill_item
*& Form f_check_iqc
Checking the storage location for the (chng : 23/07/2003)
FORM f_check_iqc.
CALL FUNCTION 'Z_M_GET_IQC_STATUS'
EXPORTING
matnr = p_matnr
lifnr = v_lifnr
IMPORTING
lgort = v_lgort
bwart = v_bwart
ltsnr = v_ltsnr
infnr = v_infnr
EXCEPTIONS
non_iqc_vendor = 1
OTHERS = 2.
IF sy-subrc <> 0.
CLEAR : v_lgort , v_bwart , v_ltsnr.
ENDIF.
ENDFORM. " f_check_iqc
*& Form f_fill_header
Updating data in the header
FORM f_fill_header.
MOVE v_postdate TO wa_header-pstng_date.
MOVE sy-datum TO wa_header-doc_date.
MOVE p_frbnr TO wa_header-ref_doc_no.
ENDFORM. " f_fill_header
*& Form f_execute_transfer
Executing the goods movement.
FORM f_execute_transfer.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = wa_header
goodsmvt_code = c_01
IMPORTING
goodsmvt_headret = wa_return
TABLES
goodsmvt_item = i_item
return = i_return.
IF i_return[] IS INITIAL .
COMMIT WORK.
*--- UPdating Info record for IQC cycle ind.(chng : 23/07/2003)
IF NOT v_ltsnr IS INITIAL.
UPDATE eina SET ltsnr = v_ltsnr
WHERE infnr = v_infnr.
ENDIF.
REFRESH : i_item.
CLEAR : wa_header,v_ltsnr , v_infnr,v_bwart,v_lifnr.
MESSAGE i012(migo) WITH wa_return-mat_doc.
PERFORM f_do_print.
ELSE.
REFRESH : i_item.
CLEAR : wa_header,v_ltsnr , v_infnr,v_bwart,v_lifnr.
PERFORM write_errors.
ENDIF.
ENDFORM. " f_execute_transfer
FORM write_errors.
WRITE: 0(90) sy-uline ,
/0'|',
3 'System messages for GR posting',
90 '|',
/0(90) sy-uline .
LOOP AT i_return.
CASE i_return-type.
WHEN 'E'.
MESSAGE i016(zm) WITH i_return-message.
WHEN 'W'.
MESSAGE i017(zm) WITH i_return-message.
WHEN 'I'.
WRITE: /0'|',
icon_yellow_light AS ICON ,
'|',
10 i_return-message,
90 '|'.
MESSAGE i018(zm) WITH i_return-message.
WHEN 'S'.
WRITE: /0'|',
icon_green_light AS ICON ,
'|',
10 i_return-message,
90 '|'.
MESSAGE i018(zm) WITH i_return-message.
WHEN OTHERS.
WRITE: /0'|',
icon_red_light AS ICON ,
'|',
10 i_return-message,
90 '|'.
MESSAGE e016(zm) WITH i_return-message.
ENDCASE.
AT LAST .
WRITE:/0(90) sy-uline .
ENDAT.
ENDLOOP.
ENDFORM. " write_errors
*& Form f_clear
Clearing the input parameters
FORM f_clear.
CLEAR : p_ebeln ,
p_bar,
p_matnr,
p_frbnr,
v_lifnr,
p_menge,
p_status.Hi all,
can anyone suggest any idea?
Regrds
pabitra -
What's wrong with this simple method
i'm having compile troubles with this simple method, and i think it's got to be something in my syntax.
public String setTime()
String timeString = new String("The time is " + getHours() + ":" + getMinutes() + ":" + getSeconds() + " " + getIsAM());
return timeString;
this simple method calls the get methods for hours, minutes, seconds, and isAM. the compiler tells me i need another ) right before getSeconds(), but i don't believe it. i know this is a simple one, but i could use the advice.
thanks.Hi,
I was able to compile this method , it gave no error -
A very very strange issue on BlazeDS Deserializing
Hi all,
I run into a very very strange issue on BlazeDS Deserializing. Is there any hint or idea? Thanks a lot!
Scenario 1:
Both the browser(firefox or IE) and the midtier (BlazeDS ,java) are on the same machine.
Actual result:
Everything works fine. All the properties in the Flex Object could be mapped to the Java Class
Scenario 2:
The browser(firefox or IE) and the midtier (BlazeDS ,java) are on the different machine.
Actual result:
Sometimes it works fine.
And most of the time it does not work fine. Only the data in List is mapped correctly. All the values of simple data type such as int are mapped to 0 .
Let me simplify the problem.
The objects of Class B is always stored in the ArrayCollection assocItems of Class A
Flex side:
public class A {
public var id: int;
public var name: String;
public var assocItems: ArrayCollection=new ArrayCollection();
public class B {
public var id: int;
public var assocItems : ArrayCollection=new ArrayCollection();
The id , name in Flex Class A and assocItems in Class B could be deserialize to correct value . But the id of Class B is always mapped to 0. This is not correct.
The log level of BlazeDS is configured to Debug. From the log I can see that each value is passed from Flex side to Java server side correctly.
[BlazeDS][INFO] Channel endpoint my-amf received request.
[BlazeDS][DEBUG] Deserializing AMF/HTTP request
Version: 3
(Message #0 targetURI=null, responseURI=/18)
(Array #0)
[0] = (Typed Object #0 'flex.messaging.messages.RemotingMessage')
However, the Java object does not get the correct value of B.id.
In conclusion,
1. It’s an issue with only default types
2. It does not occur every time
3. It does not occur when the browser(firefox or IE) and the midtier (BlazeDS ,java) are on the same machine
Have you ever run into the similar problems? And what’s your solution?I checked, when I hard-code the constant in linq, the generated sql is like this:
SELECT "Extent1"."AA" AS "AA"
FROM (SELECT "TBL"."AA" AS "AA"
FROM "USERNAME"."TBL" "TBL") "Extent1"
WHERE ('1062303212007000121' = "Extent1"."AA")
if I pass a variable to the query with same value, the sql is like this:
SELECT "Extent1"."AA" AS "AA"
FROM (SELECT "TBL"."AA" AS "AA"
FROM "USERNAME"."TBL" "TBL") "Extent1"
WHERE ("Extent1"."AA" = '1062303212007000121' /* @p__linq__0 */) (@p__linq__0 is passed as parameter)
The only difference is a paramter. I can't figure out why there is such a impact on performance. -
Custom Login Module - Commit Method return TRUE always?
Hi,
I am creating a custom login module for my portal authentication.
For the login module, should the commit() method always return TRUE?
The example code on help.sap.com indicates yes to this question.
However, the JAVA Sun standard indicates that commit should return FALSE if the preceding login method returned FALSE.
Does the SAP example stray from the SUN standard? How should I code the commit() method such that it works (Always TRUE, or follow lead of login() method)?
Regards,
KevinHi Kevin,
I'm actually working with this document: <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/events/webinars/jaas%20login%20module%20development%20on%20webas%20java%20640.pdf#search=%22classloader%20sda%20jar%20reference%22">JAAS Login Modules</a>.
There is also example code. If it should be ignored they return false, otherwise true (page 32).
Regards,
Marcus
Message was edited by: Marcus Freiheit
Maybe you are looking for
-
Are the ProRes codec and .MOV file no longer supported?
I posted the following over at Creative Cow with no luck... hopefully I can get answers here ... I am on a MAC - I joined the Adobe bandwagon during the great FCP migration of 2011 ... So far it's been great but... Both Premiere CC AND After Effects
-
Calculation of po qty based on material in Reuse_alv_grid_dispay report
Hi friends, This is the requirement I need to calculate the total Quantity(ekpo-menge) on open stores orders(doc type) with today's delivery date + (today's date + 1). help me out in giving the mandatory fields that need to be taken and the code to
-
SQL statement not working for an application
Hello, Here is a sql statement which i am using to populate Department ID using another row in the table. Using these I am getting the values called department alias from different table and schema. UPDATE tablename_4127 PT SET "Deptid" = (select dis
-
Bootstrapping Error: ALC-TTN-105-000 under linux
As I deploied with Adobe LiveCycle Configuration Manager I got an error : ALC-TTN-105-000: Could not connect to bootstrap Servlet: Port [Connection refused] may be invalid I have checked with this command: netstat -an | find "8080. There was no servi
-
Apple TV 2, DVD's, and external hard drives
Hello All...Here is what I am trying to accomplish: 1 Burn DVD's to external hard drive 2 Use Apple TV to play DVD's on brand new Panasonic Plasma via the external storage device. I've got a 3 month old macbook pro running mountain lion, a Buffalo Mi