Problem with array calculations
The only problem I have now is, instead of calculating the payments at 7 years/5.35%, 15 years/5.5%, and 30 years/5.75%, it's calculating them for 7 years at 5.35%, 5.5%, and 5.75%, 15 years at 5.35%, 5.5%, and 5.75%, and so on. I don't need it to do all of that, I need the years to correspond to the correct interest rate. How can I change that? Thank you so much. Here is my new code:
class PaymentArray {
public static void main(String[] arguments) {
double amount = 100000;
int[] term = {7, 15, 30};
double[] rate = {.0535, .055, .0575};
for (int i = 0; i < term.length; i++) {
for (int j = 0; j < rate.length; j++) {
System.out.println("If the initial loan amount is " + amount);
System.out.println("and the length of the term is " + term[i] + " years");
System.out.println("and the monthly interest rate is " + rate[j]);
double payment = (amount*(rate[j]/12))/(1-(Math.pow(1/(1+(rate[j]/12)),(term*12))));
System.out.println("The monthly payment will be " + payment);
Bollocks! The code tags got me!
You don't need two loops.
class PaymentArray {
public static void main(String[] arguments) {
double amount = 100000;
int[] term = {7, 15, 30};
double[] rate = {.0535, .055, .0575};
for (int i = 0; i < term.length; i++) {
System.out.println("If the initial loan amount is " + amount);
System.out.println("and the length of the term is " + term[i] + " years");
System.out.println("and the monthly interest rate is " + rate);
double payment = (amount*(rate[i]/12))/(1-(Math.pow(1/(1+(rate[i]/12)),(term[i]*12))));
System.out.println("The monthly payment will be " + payment);
Similar Messages
-
Problem with the calculator and modifications needed
i have got a problem with the calculator on my iphone i.e i cannot find any DEL key or Backspace....the problem is when typing a long value if one number is entered wrong we should start again.
EXAMPLE...if i need to type 114678047 * 345612
if acidentally if i type 114678047 * 3455 ( then i should start over typing "C" key)
i should start over to type the whole data..if we have a delete key we can just correct it right away and continue.....rather than starting over
we can find this feature in all the other smart phones , i dont know why apple coudnt find that
even every scientific calculator have a DEL key...
Thanks
vickyk7FEEDBACK
If you want to give Apple feed back then do it here http://www.apple.com/feedback/iphone.html -
Problem with a calculated member browsing cube with a specific user role
Good evening to all of you .
I am not a newbie about SSAS nor an expert developer.
I use SSAS 2008 R2 Standard Edition.
I try to simplify my problem with a calculated measure.
I have a CUBE with :
[Measures].[Sales Amount]
Dimension STORES - Dimension CUSTOMERS - Dimension DATE
I have also 2 user roles :
Direction Role can see all members of all dimensions.
Customize Role has a restriction about Dimension STORES ..it can see only a STORE of all (Suppose to have 100 stores).
User that has a Customize Role, when browse cube in Excel , want to see for a specific CUSTOMER , Sales Amount of his own STORE but also the total Sales Amount of ALL STORES for that Customer...
Is it possibile to do that ???
Can you give any suggestion also using Adventure Works Cube ???
I was able to create a calculated measure like that below.
It does not work...It give the same result of Sales Amount
It seems that Customize Role win Always about every kind of calculate measure i need to create..
i.e SUM([STORES].[STORES].[ALL STORES],[Measures].[Sales Amount])
Thanks in advance.Hi maretix,
According to your description, you have a customize role which limit the user can only see data about his own STORE. Now this user wants to see the total Sales Amount for his own STORES only. Right?
In Analysis Services, when granting custom access to dimension data, it has a option "Enable Visual Total" in Advanced dimension security. By default, the
VisualTotals property is disabled (set to False). This default setting maximizes performance because Analysis Services can quickly calculate the total of all cell values, instead of having to spend time selecting which
cells values to calculate. So you always get same result which is the total for all STORES.
In this scenario, please select this option. When you enable the VisualTotals property, your custom role can only view aggregated totals for dimension members to which the role has permission.
Reference:
Grant custom access to dimension data (Analysis Services)
If you have any question, please feel free to ask.
Best Regards,
Simon Hou
TechNet Community Support -
I think I found a problem with the calculator application.
I'm a south korean highschool student and I think I found a problem with calculator application. I use iPod touch 4th generation with iOS 5.0.1. I was playing with calculator app and I found out that 0.1!(factorial) is 0.951350769866873. This can't be right bacause factorial calculation can only be definrd whan n is natural number or 0(in n!). I want apple to correct this error.
And if you are someone working with apple, please let me know the algorithm of factorial calculation(if possible). I would be grateful if I can have a chance to study the algorithm and find out what made 0.1! possible.
so question.
do anybody know how to send an email to apple? I tried but I couldn't find the address.Apple doesn't dialogue with users via email the way you want, but you can report such problems to them via
http://www.apple.com/feedback/
But in this particular case you should be aware that factorial can in fact be done for non-integers:
http://en.wikipedia.org/wiki/Factorial#Extension_of_factorial_to_non-integer_val ues_of_argument -
I have a problem with my calculator :(
hi all,
i need some help with my calculator..after i wrote the code i discovered my mistake so i made some changes on the code..the problem is that it's still applying the old code !!
( i didn't forgot to compile it, & i closed all the browsers b4 trying it )
i will appreciate ANY suggestion
P.S : my mistake was with the operations buttons ( add, sub, multip, division ) & the equal button
if it may help, this is the code ( the new one, then the old one )
the new code:
import java.awt.* ; // Container, FlowLayout
import java.awt.event.* ; // ActionEvent, ActionListener
import javax.swing.* ; // JApplet , JButton , JLabal, JTextField
public class Calculator2 extends JApplet implements ActionListener {
// graphical user interface components
JTextField field ;
JButton zero, one, two, three, four, five, six, seven, eight, nine, fraction, clear,
add, sub, multip , division, equal ,sin , cos, tan ,log ,sqrt ,exp ;
// variables
String string = " " ; // to store what is in the text field
String operation ; // to store the operation selected
double operate ; // to store the result of the operation selected
double operand1 , operand2 ; // the operands of the operation
// set up GUI components
public void init ()
Container container = getContentPane ();
container.setLayout ( new FlowLayout () );
// create a text field
field = new JTextField ( 17 );
container.add ( field ) ;
// create buttons
clear = new JButton ( "C" ) ;
clear.addActionListener ( this ) ;
container.add ( clear );
zero = new JButton ( "0" ) ;
zero.addActionListener ( this ) ;
container.add ( zero );
one = new JButton ( "1" ) ;
one.addActionListener ( this ) ;
container.add ( one );
two = new JButton ( "2" ) ;
two.addActionListener ( this ) ;
container.add ( two );
three = new JButton ( "3" ) ;
three.addActionListener ( this ) ;
container.add ( three );
four = new JButton ( "4" ) ;
four.addActionListener ( this ) ;
container.add ( four );
five = new JButton ( "5" ) ;
five.addActionListener ( this ) ;
container.add ( five );
six = new JButton ( "6" ) ;
six.addActionListener ( this ) ;
container.add ( six );
seven = new JButton ( "7" ) ;
seven.addActionListener ( this ) ;
container.add ( seven );
eight = new JButton ( "8" ) ;
eight.addActionListener ( this ) ;
container.add ( eight );
nine = new JButton ( "9" ) ;
nine.addActionListener ( this ) ;
container.add ( nine );
fraction = new JButton ( "." ) ;
fraction.addActionListener ( this ) ;
container.add ( fraction );
add = new JButton ( "+" ) ;
add.addActionListener ( this ) ;
container.add ( add );
sub = new JButton ( "-" ) ;
sub.addActionListener ( this ) ;
container.add ( sub );
multip = new JButton ( "*" ) ;
multip.addActionListener ( this ) ;
container.add ( multip );
division = new JButton ( "�" ) ;
division.addActionListener ( this ) ;
container.add ( division );
sin = new JButton ( "sin" ) ;
sin.addActionListener ( this ) ;
container.add ( sin );
cos = new JButton ( "cos" ) ;
cos.addActionListener ( this ) ;
container.add ( cos );
tan = new JButton ( "tan" ) ;
tan.addActionListener ( this ) ;
container.add ( tan );
log = new JButton ( "log" ) ;
log.addActionListener ( this ) ;
container.add ( log );
sqrt = new JButton ( "sqrt" ) ;
sqrt.addActionListener ( this ) ;
container.add ( sqrt );
exp = new JButton ( "exp" ) ;
exp.addActionListener ( this ) ;
container.add ( exp );
equal = new JButton ( "=" ) ;
equal.addActionListener ( this ) ;
container.add ( equal );
} // end of method init
public void actionPerformed ( ActionEvent event )
// button zero
if ( event.getSource()== zero )
string = string + "0" ;
field.setText ( string ) ;
// button one
else if ( event.getSource()== one )
string = string + "1" ;
field.setText ( string ) ;
// button two
else if ( event.getSource()== two )
string = string + "2" ;
field.setText ( string ) ;
// button three
else if ( event.getSource()== three )
string = string + "3" ;
field.setText ( string ) ;
// button four
else if ( event.getSource()== four )
string = string + "4" ;
field.setText ( string ) ;
// button five
else if ( event.getSource()== five )
string = string + "5" ;
field.setText ( string ) ;
// button six
else if ( event.getSource()== six )
string = string + "6" ;
field.setText ( string ) ;
// button seven
else if ( event.getSource()== seven )
string = string + "7" ;
field.setText ( string ) ;
// button eight
else if ( event.getSource()== eight )
string = string + "8" ;
field.setText ( string ) ;
// button nine
else if ( event.getSource()== nine )
string = string + "9" ;
field.setText ( string ) ;
// button fraction
else if ( event.getSource()== fraction )
string = string + "." ;
field.setText ( string ) ;
// button clear
else if ( event.getSource()== clear )
clear ();
// button add
else if ( event.getSource()== add )
operand1 = Double.parseDouble ( string );
operation = "+" ;
clear ();
// button sub
else if ( event.getSource()== sub )
operand1 = Double.parseDouble ( string );
operation = "-" ;
clear ();
// button multip
else if ( event.getSource()== multip )
operand1 = Double.parseDouble ( string );
operation = "*" ;
clear ();
// button division
else if ( event.getSource()== division )
operand1 = Double.parseDouble ( string );
operation = "/" ;
clear ();
// button sin
else if ( event.getSource()== sin )
operate = Double.parseDouble ( string ) ;
operate = Math.sin( operate );
field.setText ( Double.toString ( operate ) ) ;
// button cos
else if ( event.getSource()== cos )
operate = Double.parseDouble ( string ) ;
operate = Math.cos( operate );
field.setText ( Double.toString ( operate ) ) ;
// button tan
else if ( event.getSource()== tan )
operate = Double.parseDouble ( string ) ;
operate = Math.tan( operate );
field.setText ( Double.toString ( operate ) ) ;
// button log
else if ( event.getSource()== log )
operate = Double.parseDouble ( string ) ;
operate = Math.log( operate );
field.setText ( Double.toString ( operate ) ) ;
// button sqrt
else if ( event.getSource()== sqrt )
operate = Double.parseDouble ( string ) ;
operate = Math.sqrt( operate );
field.setText ( Double.toString ( operate ) ) ;
// button exp
else if ( event.getSource()== exp )
operate = Double.parseDouble ( string ) ;
operate = Math.exp( operate );
field.setText ( Double.toString ( operate ) ) ;
// button equal
else // if ( event.getSource()== equal )
operand2 = Double.parseDouble ( string );
if ( operation == "+" )
operate = operand1 + operand2 ;
else if ( operation == "-" )
operate = operand1 - operand2 ;
else if ( operation == "*" )
operate = operand1 * operand2 ;
else if ( operation == "/" )
operate = operand1 / operand2 ;
field.setText ( Double.toString ( operate ) ) ;
} // end of method actionPerformed
public void clear ()
string = " ";
field.setText ( string ) ;
} // end of method clear
} // end of class
the old code which have the problem ( which i make the changes on ) :
// button clear
else if ( event.getSource()== clear )
string = "";
field.setText ( string ) ;
// button add
else if ( event.getSource()== add )
string = string + "+" ;
field.setText ( string ) ;
// button sub
else if ( event.getSource()== sub )
string = string + "-" ;
field.setText ( string ) ;
// button multip
else if ( event.getSource()== multip )
string = string + "*" ;
field.setText ( string ) ;
// button division
else if ( event.getSource()== division )
string = string + "/" ;
field.setText ( string ) ;
// button equal
else // if ( event.getSource()== equal )
operate = Double.parseDouble ( string ) ;
field.setText ( Double.toString ( operate ) ) ;
thanks a lot :)Open Java console and press "x" (Clear cache)
Disable caching in java paremeters. -
Problems with shipping calculations
We have been working with BC eCommerce since the beginning of 2013.
We have been working with UPS and the checkout shopping cart get the shipping costs from UPS.
However we are experiencing a problem with big orders due to the fact that big orders require a second or even a third box and then UPS charges are higher than the calculation
here is what is happening righ now:
we can house 4 products in a box. Each product weights 10.5 pound.
In orders of 4 or less products we dont have a problem. UPS calculates 1 box of 42 pounds.
Let's say we have to ship 7 products, then we have a 42 pounds box and a 31.5 pounds box but the system has calculated a box of 73.5 pound which is lower than shipping the two individual orders.
even using ground transportaion this problem represent 5 to 10 when shipping two boxes and it will grow even bigger when we have to ship 3 boxes (almost $40).
I appreciate your ideas on how to solve this problem.
ThanksI too, am having issues with inaccurate FEDEX shipping costs.
Our FEDEX rep has provided evidence that somewhere along the way, the measurements sent to the FEDEX server, is being provided to FEDEX in metric measurments.
Which is very strange, as our store is setup in English System of Measurments (U.S. Customary System and the Britich Imperial System) meaning that our dimensions and weight within the BC system are in inches and pounds. (BC support has confirmed that the setup is correctly for inches and pound measurement)
The result is that the shipping costs generated using integrated FEDEX on BC can be significantly lower than when using the same account info on the client's FEDEX web portal. This signicantly cuts into profits - and in some cases the client can loose money after making an online sale!
Is anyone else finding this to be the case? Does anyone have any suggestions? My client is very, very frustrated - and naturally does not want to lose money on shipping. Any help appreciated. Thanks.
TheBCMan - I know you specialize in shipping calculators, have you come across this?
GeckoTales - did you ever develop or come across a work-around?
Thanks everyone. Hope someone has come across this. Am getting desparate. -
Problem with Context - calculated Value
I have a problem with my WebDynPro-Project.
The Errors which is shown by the NWDS:
"Web Dynpro Generation: Metadata constraint of Component KeyMappingComponent is violated: CalculatedAttributeProvider "//WebDynpro/Controller:de.vwfsag.keymapping.ui.KeyMappingComponent/CalculatedAttributeProvider:BusinessAttributeDataSprache", Role "Attribute": A minimum of 1 object(s) is required"
What I've done:
- changed valueproperties calculated from "true" to "false" and back.
The problem is that the set und get methods remained after resetting the calculateproperty to "false".
I've tried several time to switch the property but now I got more remained set and get methods (..._1, ..._2, ...), which I can't delete in the NWDS.
What I also tried was to change the .wdcontroller"-file of my controller-component, but this file is generated so after a rebuild the ".wdcontroller"-file is still corrupted.
I think the conclusion should be something to delete these methods or change the calculatedproperty in some files you can't access directly from the NWDS.
I hope anyone could help me out with this?
Greetz Christian
Edited by: christian.zuehlsdorf on Dec 14, 2009 6:24 PMTushar Sinha wrote:Tushar Sinha wrote:Hey Sinha,
thank you fr your answer!
>
> Just try deleting the attribute for which you tried setting the calculated property as true and then false, try repairing your project, reload and build again. Hopefully this should get you rid of the getters and setters.
That was the first thing I already tried. I deleted the whole context und then rebuild and repair and rebuild... But none of that help.
>
> Do, not manually try deleting the getters/setters manually for any attribute as it is autogenerated for an attribute.
These getters/setters only have part of the configuration with no context-attribute-bind, which in fact seems to be the problem for the build-process. -
I am a rookie in SAP i have a small problem with date.Do we have any function module to find out the first day in a month if we give out the system current date ?? Pls help me out.
Hi,
As Ganesan told,you can do.
Here is the sample code.
data v type sy-datum.
data d type DTRESR-WEEKDAY.
v+6(2) = '01'.
v4(2) = sy-datum4(2).
v0(4) = sy-datum0(4).
CALL FUNCTION 'DATE_TO_DAY'
EXPORTING
date = v
IMPORTING
WEEKDAY = d.
write d. -
A basic question/problem with array element as undefined
Hello everybody,
thank you for looking at my problem. I'm very new to scripting and javaScript and I've encountered a strange problem. I'm always trying to solve all my problem myself, with documentation (it help to learn) or in the last instance with help of google. But in this case I am stuck. I'm sure its something very simple and elementary.
Here I have a code which simply loads a text file (txt), loads the content of the file in to a "var content". This text file contents a font family name, each name on a separate line, like:
Albertus
Antenna
Antique
Arial
Arimo
Avant
Barber1
Barber2
Barber3
Barber4
Birch
Blackoak ...etc
Now, I loop trough the content variable, extract each letter and add it to the "fontList[i]" array. If the character is a line break the fontList[i] array adds another element (i = i + 1); That's how I separate every single name into its own array element;
The problem which I am having is, when I loop trough the fontList array and $.writeln(fontList[i]) the result in the console is:
undefinedAlbertus
undefinedAntenna
undefinedAntique
undefinedArial ...etc.
I seriously don't get it, where the undefined is coming from? As far as I have tested each digit being added into the array element, I can't see anything out of ordinary.
Here is my code:
#target illustrator
var doc = app.documents.add();
//open file
var myFile = new File ("c:/ScriptFiles/installedFonts-Families.txt");
var openFile = myFile.open("r");
//check if open
if(openFile == true){
$.writeln("The file has loaded")}
else {$.writeln("The file did not load, check the name or the path");}
//load the file content into a variable
var content = myFile.read();
myFile.close();
var ch;
var x = 0;
var fontList = [];
for (var i = 0; i < content.length; i++) {
ch = content.charAt (i);
if((ch) !== (String.fromCharCode(10))) {
fontList[x] += ch;
else {
x ++;
for ( i = 0; i < fontList.length; i++) {
$.writeln(fontList[i]);
doc.close (SaveOptions.DONOTSAVECHANGES);
Thank you for any help or explanation. If you have any advice on how to improve my practices or any hint, please feel free to say. Thank youCarlosCantos wrote an amazing script a while back (2013) that may help you in your endeavor. Below is his code, I had nothing to do with this other then give him praise and I hope it doesn't offend him since it was pasted on the forums here.
This has helped me do something similar to what your doing.
Thanks again CarlosCanto
// script.name = fontList.jsx;
// script.description = creates a document and makes a list of all fonts seen by Illustrator;
// script.requirements = none; // runs on CS4 and newer;
// script.parent = CarlosCanto // 02/17/2013;
// script.elegant = false;
#target illustrator
var edgeSpacing = 10;
var columnSpacing = 195;
var docPreset = new DocumentPreset;
docPreset.width = 800;
docPreset.height = 600;
var idoc = documents.addDocument(DocumentColorSpace.CMYK, docPreset);
var x = edgeSpacing;
var yyy = (idoc.height - edgeSpacing);
var fontCount = textFonts.length;
var col = 1;
var ABcount = 1;
for(var i=0; i<fontCount; i++) {
sFontName = textFonts[i].name;
var itext = idoc.textFrames.add();
itext.textRange.characterAttributes.size = 12;
itext.contents = sFontName;
//$.writeln(yyy);
itext.top = yyy;
itext.left = x;
itext.textRange.characterAttributes.textFont = textFonts.getByName(textFonts[i].name);
// check wether the text frame will go off the bottom edge of the document
if( (yyy-=(itext.height)) <= 20 ) {
yyy = (idoc.height - edgeSpacing);
x += columnSpacing;
col++;
if (col>4) {
var ab = idoc.artboards[ABcount-1].artboardRect;
var abtop = ab[1];
var ableft = ab[0];
var abright = ab[2];
var abbottom = ab[3];
var ntop = abtop;
var nleft = abright+edgeSpacing;
var nbottom = abbottom;
var nright = abright-ableft+nleft;
var abRect = [nleft, ntop, nright, nbottom];
var newAb = idoc.artboards.add(abRect);
x = nleft+edgeSpacing;
ABcount++;
col=1;
//else yyy-=(itext.height); -
Problem with arrays and comparing
Hi,
I am having problem accessing the array indexes.
The program supposed to ask the user to enter the car model.
If the car exists then it will display the message The modelname is available.
If it doesnt exist The modelname does not exist.
Thanks
Car.java.........
public class Car {
private String regno;
private String make;
private String model;
private int deposit;
private int rate;
public void setCar(String m, String mo, String reg, int dep, int r) {
make = m;
model = mo;
regno = reg;
deposit = dep;
rate = r;
public String getRegNo() {
return regno;
public String getmake() {
return make;
public String getModel() {
return model;
public int getdeposit() {
return deposit;
public int getrate() {
return rate;
Database.java.........
public class Database {
public void showDetails(){
Car carList[] = new Car[9];
carList[0] = new Car();
carList[0].setCar("Toyota","Altis", "SJC2456 X", 100, 60);
carList[1].setCar("Toyota","Vios", "SJG 9523 B", 100, 50);
carList[2].setCar("Nissan","Latio", "SJB 7412 B", 100, 50);
carList[3].setCar("Nissan","Murano", "SJC 8761 B", 300, 150);
carList[4].setCar("Honda","Jazz", "SJB 4875 N", 100, 60);
carList[5].setCar("Honda","Civic", "SJD 73269 C", 120, 70);
carList[6].setCar("Honda","Stream", "SJL 5169 J", 120, 70);
carList[7].setCar("Honda","Odyssey", "SJB 3468 E", 200, 150);
carList[8].setCar("Subaru","WRX", "SJB 8234 L", 300, 200);
carList[9].setCar("Subaru","Impressa", "SJE 8234 K", 150, 80);
public Car findCarByModel(String findModel){
Car car = new Car();
for(int i = 0; i <=9; i++){
if(car.getModel().equalsIgnoreCase(findModel)== true)
return car; }
} return null;
IssueCarUi.java
public class IssueCarUI {
public static void main(String args[]){}
private String requestModel;
private Customer myCustomer;
// Payment myPayment = new Payment();
Rental myRental = new Rental();
Database myDatabase = new Database();
private int noOfDays;
public IssueCarUI() {
myCustomer = new Customer("", "");
}//end Constructor
public void createCustomer(String n, String i) {
myCustomer.setName(n);
myCustomer.setIC(i);
System.out.println("Name: " + myCustomer.getName());
System.out.println("Name: " + myCustomer.getIC());
}// end Create customer method
public void calculateCost(int d){
myRental.setdays(d);
System.out.println("Duration: 5 days");
}// End Calculate cost
public void showCarDetails(String requestModel) {
requestModel=null;
if(myDatabase.findCarByModel().equalsIgnoreCase(requestModel)==true){
System.out.println("Model " requestModel " is available");
}else{ System.out.println("Model " +requestModel + " not is available");}
}// End Class
mainmethod.java
import java.util.Scanner;
public class mainmethod {
public static void main(String args[]) {
IssueCarUI myIssue = new IssueCarUI();
Scanner input = new Scanner(System.in);
String name, ic,requestModel;
System.out.print("Please enter the model to rent");
requestModel = input.nextLine();
myIssue.showCarDetails(requestModel);
// System.out.print("Please Enter your name: ");
// name = input.nextLine();
// System.out.print("Please Enter your IC: ");
// ic = input.nextLine();
// myIssue.createCustomer(name, ic);
}Assumption:
* Removed setCar method and implemented the same method as a constructor for Car.
public class Car {
private String regno;
private String make;
private String model;
private int deposit;
private int rate;
public Car(String m, String mo, String reg, int dep, int r) {
make = m;
model = mo;
regno = reg;
deposit = dep;
rate = r;
public String getRegNo() {
return regno;
public String getmake() {
return make;
public String getModel() {
return model;
public int getdeposit() {
return deposit;
public int getrate() {
return rate;
* When the values in the Car array are assigned in the new init() default method, they are created using the Car constructor.
public class Database {
//Car array is now an instance variable, rather then a local variable.
private Car carList[]];
//Default constructor initializes Car array and populates.
public Database() {
init();
//Assign Car array with a custom Car array.
public Database(Car carList[]) {
this.carList = carList;
* I highly suggest passing in as a parameter to the constructor, the car list rather then depending on this restrictive internal initialization.
* I simply altered it in an init() method to keep it relative to your original code.
private void init(){
carList[] = new Car[9];
carList[0] = new Car();
carList[0] = new Car("Toyota","Altis", "SJC2456 X", 100, 60);
carList[1] = new Carr("Toyota","Vios", "SJG 9523 B", 100, 50);
carList[2] = new Car("Nissan","Latio", "SJB 7412 B", 100, 50);
carList[3] = new Car("Nissan","Murano", "SJC 8761 B", 300, 150);
carList[4] = new Car("Honda","Jazz", "SJB 4875 N", 100, 60);
carList[5] = new Car("Honda","Civic", "SJD 73269 C", 120, 70);
carList[6] = new Car("Honda","Stream", "SJL 5169 J", 120, 70);
carList[7] = new Car("Honda","Odyssey", "SJB 3468 E", 200, 150);
carList[8] = new Car("Subaru","WRX", "SJB 8234 L", 300, 200);
carList[9] = new Car("Subaru","Impressa", "SJE 8234 K", 150, 80);
public Car findCarByModel(String findModel){
for(Car car : carList) {
if(car.getModel().equalsIngoreCase(findModel)) {
return car;
return null;
}Mel -
Problems with Array-Parameters when using Document-Binding
Hi,
I use the following environment:
JDeveloper 11.1.1.3.0
WLS 10.3.3.0
I created a small EJB (2.1), containing a simple method, which is using arrays as parameters:
public String doTestArray(String[] aStringArray, int[] aIntArray)
throws RemoteException;
I exposed this EJB as a Webservice using JDev's Webservice wizard. I choosed Document/Wrapped-Binding. WSDL and mapping file are being generated. Made an EAR-Deployment-Profile and deployed the application to Integrated-WLS.
I tried to test the Webservice with the WLS integrated test client, which is generating the following request:
<doTestArrayElement xmlns="http://model/types/">
<!--Zero or more repetitions:-->
<arrayOfString_1>string</arrayOfString_1>
<!--Zero or more repetitions:-->
<arrayOfint_2>3</arrayOfint_2>
</doTestArrayElement>
Unfortunately, the invokation fails. WLS returns
weblogic.wsee.codec.CodecException: Failed to decode message
at weblogic.wsee.codec.soap11.SoapCodec.decode(SoapCodec.java:188)
at weblogic.wsee.ws.dispatch.server.CodecHandler.decode(CodecHandler.java:139)
That only happens in methods, which use array-parameters. Simple parameters are no problem.
However, when I use RPC/Encoded as Webservice-Binding, everything seems to be fine.
Does WLS have problems in general using array-parameters and Document-Binding?
Any help would be appreciated.
Thanks,
StefanHi Josko,
Where do you have this problem 3.5 or 7.0 BexAnalyzer.
When ever heirarchy icons are created in BEx, respective hyperlink is assigned to each of them, Make sure that you dont manipulate with them,,
If you still have problem then create OSS message.
Regards,
Vinay -
Problem with array type in SOAP response for sync interface
Hi,
We have a Synchronous Interface from SAP -->PI-->Unifier .The WSDL response has array type and when WSDL is imported it is showing red (I was able to activate and use it in mapping) .We are able to send the request successfully and when retrieving the response we are getting mapping error .Please find the attachment for reference and response message from unifier .I feel that the error is because of array type .Could someone throw some light how we can solve this soon as it was a bit urgent .
http://scn.sap.com/thread/326591
I tried to create the Data Type and use the same instead of using the WSDL from External Definition but did not helped.Request your help in this.I have attached the WSDL for reference .
The response is received as shown below which is giving mapping error :
<ns1:getUDRDataResponse xmlns:ns1='http://diran:12020/ws/services/mainservice' soapenv:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><getUDRDataReturn href='#id0'/></ns1:getUDRDataResponse>
The complete response looks like below where PI is not able to receive (this is retrieved from SOAP UI)
<?xml version="1.0" encoding="utf-8" ?>
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
- <ns1:getUDRDataResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://general.service.webservices.skire.com">
<getUDRDataReturn href="#id0" />
</ns1:getUDRDataResponse>
- <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:XMLObject" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="mainservice">
<errorStatus soapenc:arrayType="xsd:string[0]" xsi:type="soapenc:Array" />
<statusCode xsi:type="xsd:int">200</statusCode>
<xmlcontents xsi:type="xsd:string"><?xml version="1.0" encoding="UTF-8"?> <report> <report_header> <c1>Name</c1> <c2>Number</c2> <c3>Status</c3> <c4>Location</c4> <c5>Phase</c5> </report_header> <report_row> <c1>Test - Sprint 1 - v10</c1> <c2>GB424</c2> <c3>Active</c3> <c4>/North Sea</c4> <c5></c5> </report_row> <report_row> <c1>Test Training 3</c1> <c2>GB424-TRN3</c2> <c3>Active</c3> <c4>/North Sea</c4> <c5></c5> </report_row> </report></xmlcontents>
</multiRef>
</soapenv:Body>
</soapenv:Envelope>Hi Praveen and Mark,
Thanks for the help.I tried to use XSLT mapping for request and try to read Response as a single string but i was getting an error in SXMB_MONI with Cannot display document format,Do you want too save it to harddisk and i could not get rid of this even after pressing Yes in popup .
Can some one help to extract only the xmlcontents from the above response and map it to target where the target structure looks like
<report>
<report_header>
<report_row>
Please help . -
HP Proliant ML350G4 server - problem with array
Hi, I have HP Proliant ML350 G4 server. The problem is that I can not configure the array for SCSI hard drives. When I run the Array Configuration Utility from the SmartStart CD, I get the message: "ACU did not detect any supported controllers in your system." How do I solve this problem?
Hi:
You may also want to post your question on the HP Business Support Forum -- ML Servers section.
http://h30499.www3.hp.com/t5/ProLiant-Servers-ML-DL-SL/bd-p/itrc-264#.U48mculOW9I -
Problem with subtotal calculation in ALV reports
Hi All,
I am doing one program for calculating subtoals in ALV . For this i want to display subtotal text at each envey subtotal 's row.
For that i have created one form 'SUB_SUBTOT_TEXT' and it has given to IT_EVENTS-FORM. But SUB_SUBTOT_TEXT Form is not called by IT_EVENTS event.
what are all the mandatories for displaying subtotal text.
Can any one please help me.
Thanks in Advance.Hi Sree,
*& Table declaration
&----TABLES: ekko.&----
*& Type pool declaration
TYPE-POOLS: slis. " Type pool for ALV&----
*& Selection screen
SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.&----
*& Type declaration
&----* Type declaration for internal table to store EKPO data
TYPES: BEGIN OF x_data,
ebeln TYPE char30, " Document no.
ebelp TYPE ebelp, " Item no
matnr TYPE matnr, " Material no
matnr1 TYPE matnr, " Material no
werks TYPE werks_d, " Plant
werks1 TYPE werks_d, " Plant
ntgew TYPE entge, " Net weight
gewe TYPE egewe, " Unit of weight
END OF x_data.&----
*& Internal table declaration
DATA:* Internal table to store EKPO data
i_ekpo TYPE STANDARD TABLE OF x_data INITIAL SIZE 0,
Internal table for storing field catalog information
i_fieldcat TYPE slis_t_fieldcat_alv,
Internal table for Top of Page info. in ALV Display
i_alv_top_of_page TYPE slis_t_listheader,
Internal table for ALV Display events
i_events TYPE slis_t_event,
Internal table for storing ALV sort information
i_sort TYPE slis_t_sortinfo_alv,
i_event TYPE slis_t_event.&----
*& Work area declaration
&----DATA:
wa_ekko TYPE x_data,
wa_layout TYPE slis_layout_alv,
wa_events TYPE slis_alv_event,
wa_sort TYPE slis_sortinfo_alv.&----
*& Constant declaration
&----CONSTANTS:
c_header TYPE char1
VALUE 'H', "Header in ALV
c_item TYPE char1
VALUE 'S'.&----
*& Start-of-selection event
&----START-OF-SELECTION.* Select data from ekpo
SELECT ebeln " Doc no
ebelp " Item
matnr " Material
matnr " Material
werks " Plant
werks " Plant
ntgew " Quantity
gewei " Unit
FROM ekpo
INTO TABLE i_ekpo
WHERE ebeln IN s_ebeln
AND ntgew NE '0.00'. IF sy-subrc = 0.
SORT i_ekpo BY ebeln ebelp matnr .
ENDIF.* To build the Page header
PERFORM sub_build_header.* To prepare field catalog
PERFORM sub_field_catalog.* Perform to populate the layout structure
PERFORM sub_populate_layout.* Perform to populate the sort table.
PERFORM sub_populate_sort.* Perform to populate ALV event
PERFORM sub_get_event.END-OF-SELECTION.* Perform to display ALV report
PERFORM sub_alv_report_display.
*& Form sub_build_header
To build the header
No Parameter
FORM sub_build_header .* Local data declaration
DATA: l_system TYPE char10 , "System id
l_r_line TYPE slis_listheader, "Hold list header
l_date TYPE char10, "Date
l_time TYPE char10, "Time
l_success_records TYPE i, "No of success records
l_title(300) TYPE c. " Title
Title Display
l_r_line-typ = c_header. " header
l_title = 'Test report'(001).
l_r_line-info = l_title.
APPEND l_r_line TO i_alv_top_of_page.
CLEAR l_r_line.* Run date Display
CLEAR l_date.
l_r_line-typ = c_item. " Item
WRITE: sy-datum TO l_date MM/DD/YYYY.
l_r_line-key = 'Run Date :'(002).
l_r_line-info = l_date.
APPEND l_r_line TO i_alv_top_of_page.
CLEAR: l_r_line,
l_date.ENDFORM. " sub_build_header
*& Form sub_field_catalog
Build Field Catalog
No Parameter
FORM sub_field_catalog .* Build Field Catalog
PERFORM sub_fill_alv_field_catalog USING: '01' '01' 'EBELN' 'I_EKPO' 'L'
'Doc No'(003) ' ' ' ' ' ' ' ', '01' '02' 'EBELP' 'I_EKPO' 'L'
'Item No'(004) 'X' 'X' ' ' ' ', '01' '03' 'MATNR' 'I_EKPO' 'L'
'Material No'(005) 'X' 'X' ' ' ' ', '01' '03' 'MATNR1' 'I_EKPO' 'L'
'Material No'(005) ' ' ' ' ' ' ' ',
'01' '04' 'WERKS' 'I_EKPO' 'L'
'Plant'(006) 'X' 'X' ' ' ' ', '01' '04' 'WERKS1' 'I_EKPO' 'L'
'Plant'(006) ' ' ' ' ' ' ' ', '01' '05' 'NTGEW' 'I_EKPO' 'R'
'Net Weight'(007) ' ' ' ' 'GEWE' 'I_EKPO'.ENDFORM. " sub_field_catalog&----
*& Form sub_fill_alv_field_catalog
*& For building Field Catalog
*& p_rowpos Row position
*& p_colpos Col position
*& p_fldnam Fldname
*& p_tabnam Tabname
*& p_justif Justification
*& p_seltext Seltext
*& p_out no out
*& p_tech Technical field
*& p_qfield Quantity field
*& p_qtab Quantity table
FORM sub_fill_alv_field_catalog USING p_rowpos TYPE sycurow
p_colpos TYPE sycucol
p_fldnam TYPE fieldname
p_tabnam TYPE tabname
p_justif TYPE char1
p_seltext TYPE dd03p-scrtext_l
p_out TYPE char1
p_tech TYPE char1
p_qfield TYPE slis_fieldname
p_qtab TYPE slis_tabname.* Local declaration for field catalog
DATA: wa_lfl_fcat TYPE slis_fieldcat_alv. wa_lfl_fcat-row_pos = p_rowpos. "Row
wa_lfl_fcat-col_pos = p_colpos. "Column
wa_lfl_fcat-fieldname = p_fldnam. "Field Name
wa_lfl_fcat-tabname = p_tabnam. "Internal Table Name
wa_lfl_fcat-just = p_justif. "Screen Justified
wa_lfl_fcat-seltext_l = p_seltext. "Field Text
wa_lfl_fcat-no_out = p_out. "No output
wa_lfl_fcat-tech = p_tech. "Technical field
wa_lfl_fcat-qfieldname = p_qfield. "Quantity unit
wa_lfl_fcat-qtabname = p_qtab . "Quantity table IF p_fldnam = 'NTGEW'.
wa_lfl_fcat-do_sum = 'X'.
ENDIF.
APPEND wa_lfl_fcat TO i_fieldcat.
CLEAR wa_lfl_fcat.
ENDFORM. " sub_fill_alv_field_catalog&----
*& Form sub_populate_layout
Populate ALV layout
No Parameter
FORM sub_populate_layout . CLEAR wa_layout.
wa_layout-colwidth_optimize = 'X'." Optimization of Col widthENDFORM. " sub_populate_layout&----
*& Form sub_populate_sort
Populate ALV sort table
No Parameter
FORM sub_populate_sort .* Sort on material
wa_sort-spos = '01' .
wa_sort-fieldname = 'MATNR'.
wa_sort-tabname = 'I_EKPO'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort .
CLEAR wa_sort.* Sort on plant
wa_sort-spos = '02'.
wa_sort-fieldname = 'WERKS'.
wa_sort-tabname = 'I_EKPO'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort .
CLEAR wa_sort.
ENDFORM. " sub_populate_sort&----
*& Form sub_get_event
Get ALV grid event and pass the form name to subtotal_text
event
No Parameter
FORM sub_get_event .
CONSTANTS : c_formname_subtotal_text TYPE slis_formname VALUE
'SUBTOTAL_TEXT'. DATA: l_s_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 4
IMPORTING
et_events = i_event
EXCEPTIONS
list_type_wrong = 0
OTHERS = 0.* Subtotal
READ TABLE i_event INTO l_s_event
WITH KEY name = slis_ev_subtotal_text.
IF sy-subrc = 0.
MOVE c_formname_subtotal_text TO l_s_event-form.
MODIFY i_event FROM l_s_event INDEX sy-tabix.
ENDIF.ENDFORM. " sub_get_event&----
*& Form sub_alv_report_display
For ALV Report Display
No Parameter
FORM sub_alv_report_display .
DATA: l_repid TYPE syrepid .
l_repid = sy-repid .* This function module for displaying the ALV report
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_repid
i_callback_top_of_page = 'SUB_ALV_TOP_OF_PAGE'
is_layout = wa_layout
it_fieldcat = i_fieldcat
it_sort = i_sort
it_events = i_event
i_default = 'X'
i_save = 'A'
TABLES
t_outtab = i_ekpo
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE i000 WITH 'Error in ALV report display'(055).
ENDIF.ENDFORM. " sub_alv_report_display&----
FORM sub_alv_top_of_page
Call ALV top of page
No parameter
----FORM sub_alv_top_of_page. "#EC CALLED* To write header for the ALV
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = i_alv_top_of_page.
ENDFORM. "alv_top_of_page&----
*& Form subtotal_text
Build subtotal text
P_total Total
p_subtot_text Subtotal text info
FORM subtotal_text CHANGING
p_total TYPE any
p_subtot_text TYPE slis_subtot_text.
Material level sub total
IF p_subtot_text-criteria = 'MATNR'.
p_subtot_text-display_text_for_subtotal
= 'Material level total'(009).
ENDIF.* Plant level sub total
IF p_subtot_text-criteria = 'WERKS'.
p_subtot_text-display_text_for_subtotal = 'Plant level total'(010).
ENDIF.
ENDFORM. "subtotal_text
Hopes its helpful.
Regards,
Raj. -
XML to model, problem with arrays
I've imported XML data from the server using the HTTPService
and using the service to convert the XML to a model. So below is my
XML:
<details>
<field label="" value=""/>
<field label="" value=""/>
</details>
I have to deal with the situation where if there is only one
field, details.field is not Array otherwise it is but the following
condition doesn't seem to work:
if (details.field is Array)
but I can still iterate through the elements as if it was an
array. So if details.field is not an Array, what is it? Or more
generally how do I find out the class of a variable?The default resultFormat of HTTPService is object. This
causes your xml to be converted to a nested object structure. This
is rarely desirable. And it causes the issue you are seeing,
because the convertor can't differentiate between an array with a
single element and an object..
Instead, set resultFormat="e4x". then, in the result handler,
do:
var xmlResult:XML = XML(event.result);
trace(xmlResult.toXMLString);
The expression, xmlResult.field, will return an XMLList. You
can iterate over that using a normal for loop with bracketed index
style references.
There are also solutions to your issue if you want to stay
with resultFormat="object". They involve, as you expect, examining
the the result object for its contained datatype. You can probably
find an example in the archives.
But switch to XML, and drop Model. Look up e4x xml if you
want more erasons.
Tracy
Maybe you are looking for
-
I have installed a trial of Adobe illustrator on my macbook pro. It is the 2014 release of adobe illustrator. I want to trace an image using the custom trace button. I start a new document. Then I place my scanned pencil/colored pencil drawing, in to
-
I burned iPhoto to a folder and now my folders/albums are gone in iPhoto
I decided to burn a folder of all my photos in iPhoto as I was having a problem with iPhoto creating new,untitled subfolders everytime I put photo's in a folder. I thought that I should back everything up and then take the next step to reloading iPho
-
Apps not showing in apps list in iTunes
Since the new iTunes when I plug in any iOS device none of my apps show in the left hand column - where you can specify by size, name etc. The right hand side that shows a mock uo of the iOS screen where you can move apps around etc is fine an all ap
-
How can I preserve word internal document hyperlinks when importing into indd cs6
I have a document that is hundreds of pages long. The document was created in word by another user and has many internal document hyperlinks. Is it possible to preserve the hyperlinks, so that they show up and work in indd CS6? The document will then
-
JSF + Facelets + Tomahawk: ExtensionsFilter not correctly configured.
Hello, I want to use JSF with facelets and tomahawk... I have a standard facelets configuration like the demo on their website... But at the moment, there is a tomahawk component in one of the pages I get the following error: java.lang.IllegalStateEx