BAPI to upload customer class characteristics(XD02)
Hi,
My requirement is to upload Class Characteristics and its values for a customer in XD02.
XD02- > Extras -> Classification
I have founded a few bapi's but its not working. I tried the below options.
BAPI_CLASS_CREATE
BAPI_OBJCL_CREATE
If someone who worked on similar requirement ... Pls reply.
Thanks
Hari
BAPI_OBJCL_CREATE must work fou you
look at:
[BAPI BAPI_OBJCL_CREATE|BAPI BAPI_OBJCL_CREATE]
[Characteristics value not assigned by BAPI_OBJCL_CHANGE;
don't forget BAPI_TRANSACTION_COMMIT after this FM
Similar Messages
-
Standard program / bdc / bapi to upload customer data.
hi experts,
i need standard program/bdc/lsmw/bapi to upload customer amster data .Hi,
Please check this links on how to use direct input program RFBIDE00.
http://www.sapbrain.com/TOOLS/LSMW/SAP_LSMW_steps_introduction.html
http://www.scmexpertonline.com/downloads/SCM_LSMW_StepsOnWeb.doc
Regards,
Ferry Lianto -
BAPI to upload customer advance
Hi,
We have to upload customer advance and holdback amounts against particular RV Document.
The T-code being used is F-04.
I want to know if there is any BAPI to do the same because I have tried doing BDC for that, but the line items are not visible during runtime against which I have to take the advance.
Please help.
Thanks,
Salman ZahirHi,
Check out this link, this issue is resolved before.
Is there any BAPI FM that can be used for F-04 ?
Thanks,
Krishna.. -
Which Bapi is available for uploading Customer Invoice and Payments in SAP
Dear Friends.
I want to upload Customer Invoices and Incoming Payments in the System.
Currently i have written a BDC-Session Program to Upload this data.
I have took the recording of tcode f-22 for Invoices, f-27 for credit memo and f-28 for payments and developed the required BDC program.
Its working fine.
Since the Volume of the data is huge .. ie around 50,000 daily, it takes too much time.
Also i am not able to have a proper error log.
I would like to know from you, whether there is any bapi available to upload this data (invoices,credit memo and payments).
OR is there any other faster and proper error log maintaining scenario available.
I appreciate for all your helps and informations.
Thanks
Kuna.Hi,
could u please send me the f-28 upload program.
Thanks in advance.
Regards
suni -
BAPI for fill class characteristics
Hi,
Wich BAPI schould I use to fill class characteristics,
where class is associated with batch.
Please it's very important
Regards,
Greg.BAPI_CLASS_ALLOC_GLOB_DEP BAPI: Assign Global Dependencies to Class
BAPI_CLASS_CHANGE BAPI: Change Class
BAPI_CLASS_CHARVALUE_DEL_DEP Class BAPI: Delete Local / Global Dependencies for Characteristic Valu
BAPI_CLASS_CHARVALUE_GLOB_DEP Class BAPI: Assign Global Dependencies to Characteristic Value
BAPI_CLASS_CHARVALUE_LOCAL_DEP Class BAPI: Maintain Local Dependency for Characteristic Value
BAPI_CLASS_CHARVALUE_READ_ALLO Class BAPI: Read Dependencies for Characteristic Value
BAPI_CLASS_CHAR_ALLOC_GLOB_DEP Class BAPI: Global Dependencies for Characteristic
BAPI_CLASS_CHAR_DELETE_DEP Class BAPI: Delete Global / Local Dependency for Characteristic
BAPI_CLASS_CHAR_LOCAL_DEP Class BAPI: Assign / Delete Local Dependency for Characteristic
BAPI_CLASS_CHAR_READ_ALLOC Class BAPI: Read Dependencies for Characteristic
BAPI_CLASS_CHAR_VALUE_TEXT_DEL Class BAPI: Delete Overwriting of Long Text for Characteristic or Value
BAPI_CLASS_CHAR_VALUE_TEXT_OVR Class BAPI: Overwriting of Long Text for Characteristic or Value
Just check these FM
Regards,
Pavan P. -
Currency problem in BAPI_MATERIAL_SAVEDATA while uploading valuation class
Hello Experts,
I am uploading valuation class using BAPI_MATERIAL_SAVEDATA.
While uploading it is showing runtime error "Unable to interpret KG as a number".
I have used the FM CONVERSION_EXIT_CUNIT_INPUT to convert the UOM from the file to Field symbol.
still the same. please guide me.
I have pasted my code below.
Kindly go through and help would be highly appreciated.
*& Report ZPRI_MAT_PRICE_UPLOAD
REPORT ZPRI_MAT_PRICE_UPLOAD no standard page heading line-size 150.
tables : mbew, " Material valuation
makt, " Material description
mara. " General material master
data : begin of t_matvclass occurs 0,
material type matnr, " Material
ind_sec type mbrsh, " Industry sector
mat_typ type mtart, " Material type
val_class type BKLAS, " Valuation class
MOV_PR TYPE VERPR, " MOVING PRISE
STD_PR TYPE STPRS, " STANDARD PRISE
base_uom like mara-meins, " Material unit
mat_desc type maktx, " Material description - MAKTX
plant type werks, " Plant
langu(2),
end of t_matvclass.
data : wa like line of t_matvclass.
data: begin of it_makt occurs 0.
include structure bapi_makt.
data end of it_makt.
data :bapi_head like bapimathead, " Header Segment with Control Info
bapi_clientdata like bapi_mara, " Material Data at Client Level
bapi_clientdatax like bapi_marax, "Checkbox Structure
bapi_valclass like BAPI_MBEW, " Valuation class
bapi_valclassx like BAPI_MBEWX, " Checkbox Structure
* BAPI_MOVING_PR LIKE BAPI_MBEW, "MOVING PRISE
* BAPI_MOVING_PRX LIKE BAPI_MBEWX, "MOVING PRISE
* BAPI_STD_PRISE LIKE BAPI_MBEW, "STANDARD PRISE
* BAPI_STD_PRISEX LIKE BAPI_MBEWX, "STANDARD PRISE
bapi_return like bapiret2, " Bapi return structrue
returnm type table of bapi_matreturn2 with header line.
data : it_excel type alsmex_tabline occurs 0 with header line.
data: begin of it_ret occurs 0.
include structure bapiret2.
data end of it_ret.
* Data objects for exception handling.
data : lv_converr type ref to CX_SY_CONVERSION_ERROR,
lv_dynerr type ref to CX_SY_DYN_CALL_ERROR.
data : txt_converr type string,
txt_converr_l type string,
txt_dynerr type string,
txt_dynerr_l type string.
data : char_uom(4) type c. " Global UOM after conversion
* Declaring selection screen for selecting a data file
* for uploading valuation class
selection-screen begin of block b1 with frame title text-001.
parameter : file_nam type rlgrap-filename obligatory default
'C:\master data UPDATED_test.xls'.
parameter : p_begcol type i default 1, " no-display,
p_begrow type i default 2, " no-display,
p_endcol type i default 9, " no-display,
p_endrow type i default 267. " no-display.
*parameters: p_valare type mbew-bwkey obligatory. " Valuation area
selection-screen end of block b1.
at selection-screen on value-request for file_nam.
perform F_get_file using file_nam.
start-of-selection.
perform F_xls_itab using file_nam changing it_excel.
perform F_move_data.
*perform F_get_data.
perform F_Display_data.
*& Form F_xls_itab
* text
* -->P_FILE_NAM text
* <--P_IT_EXCEL text
form F_xls_itab using p_file_nam changing p_it_excel.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = file_nam
i_begin_col = p_begcol
i_begin_row = p_begrow
i_end_col = p_endcol
i_end_row = p_endrow
tables
intern = it_excel
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
endform. " F_xls_itab
*& Form F_get_file
* Subroutine to get the file on F4
* -->P_FILE_NAM text
form F_get_file using p_file_nam.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
* STATIC = ' '
* MASK = ' '
CHANGING
file_name = file_nam
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2.
endform. " F_get_file
*& Form F_Display_data
* text
* --> p1 text
* <-- p2 text
form F_Display_data .
skip 2.
*write:/2 'Valuation area :', p_valare.
*write:/2 'Standard price :', p_stdprc.
skip 2.
write:/29 sy-uline(120).
write:/29 sy-vline,
30 'Material' color 1, " Material - MATNR
50 sy-vline, 'Ind_sector' color 1, " Industry sector - MBRSH
62 sy-vline, 'Mat_typ' color 1, " Material type - MTART
75 sy-vline, 'Valuation class' color 1, " Valuation class
85 sy-vline, 'Base UOM' color 1, " Base UOM
95 sy-vline, 'Material Decp' color 1, " Material descp
120 sy-vline, 'Mov Price', " Moving price
130 sy-vline, 'Std Price', " Standard price
140 sy-vline, 'Plant', " Plant
150 sy-vline.
write:/29 sy-uline(120).
loop at t_matvclass into wa.
write:/29 sy-vline,
30 wa-material color 2, " Material - MATNR
50 sy-vline,
55 wa-ind_sec color 2 right-justified, " Industry sector
62 sy-vline,
66 wa-mat_typ color 2, " Material type - MTART
75 sy-vline,
78 wa-val_class color 2 right-justified, " Valuation class
85 sy-vline,
88 wa-base_uom color 2 right-justified, " Base UOM
95 sy-vline,
98 wa-mat_desc color 2 left-justified, " Material Desc
120 sy-vline, wa-MOV_PR, " Standard price
130 sy-vline, wa-STD_PR, " Moving price
140 sy-vline, wa-plant, " Plant
150 sy-vline.
endloop.
write:/29 sy-uline(64).
endform. " F_Display_data
*& Form F_move_data
* Subroutine to move data from excel to internal table
* --> p1 text
* <-- p2 text
form F_move_data .
data : lv_index type i.
field-symbols <fs>.
* Sorting the internal table
sort it_excel by row col.
clear it_excel.
loop at it_excel.
move it_excel-col to lv_index.
* Assigning each record to the internal table row.
assign component lv_index of structure wa to <fs>.
* Assigning the field value to a field symbol
if lv_index eq 5.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
EXPORTING
INPUT = it_excel-value
LANGUAGE = SY-LANGU
IMPORTING
OUTPUT = char_uom.
** Moving the converted UOM to field symbol
move char_uom to <fs>.
else.
move it_excel-value to <fs>.
endif.
at end of row.
append wa to t_matvclass.
clear wa.
endat.
endloop.
endform. " F_move_data
*& Form F_get_data
* text
* --> p1 text
* <-- p2 text
form F_get_data .
loop at t_matvclass into wa.
try.
* BAPIHEAD --- > Header Segment with Control Information
bapi_head-material = wa-material.
bapi_head-ind_sector = wa-ind_sec.
bapi_head-matl_type = wa-mat_typ.
bapi_head-account_view = 'X'.
* For Clien Data
bapi_clientdata-BASE_UOM = wa-base_uom.
bapi_clientdatax-base_uom = 'X'.
bapi_clientdatax-base_uom_iso = 'X'.
* For Valuation Class.
bapi_valclass-val_area = wa-plant.
bapi_valclass-val_class = wa-val_class.
bapi_valclass-std_price = wa-STD_PR.
bapi_valclass-MOVING_PR = wa-MOV_PR.
* For Valuation Class control checkbox.
bapi_valclassx-val_area = wa-plant.
bapi_valclassx-val_class = 'X'.
bapi_valclassx-std_price = 'X'.
bapi_valclass-MOVING_PR = 'X'.
refresh it_makt.
wa-langu = SY-LANGU.
it_makt-langu = wa-langu.
it_makt-matl_desc = wa-mat_desc.
append it_makt.
clear it_ret.
refresh it_ret.
if t_matvclass[] is initial.
write:/ 'Cannot be updated'.
else.
perform F_call_bapi.
endif.
catch CX_SY_CONVERSION_ERROR into lv_converr.
txt_converr = lv_converr->get_text( ).
txt_converr_l = lv_converr->get_longtext( ).
write:/ 'Error:', txt_converr color 5.
write:/ 'Error:', txt_converr_l color 3.
endtry.
endloop.
endform. " F_get_data
*& Form F_bapi_commit
* text
* --> p1 text
* <-- p2 text
form F_bapi_commit.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
if sy-subrc eq 0.
write:/2 ' Transaction commited' color 4.
else.
write:/2 'Unable to commit the transaction' color 4.
endif.
endform. " F_bapi_commit
*& Form F_call_bapi
* text
* --> p1 text
* <-- p2 text
form F_call_bapi .
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = bapi_head
CLIENTDATA = bapi_clientdata
CLIENTDATAX = bapi_clientdatax
VALUATIONDATA = bapi_valclass
VALUATIONDATAX = bapi_valclassx
IMPORTING
RETURN = it_ret
TABLES
MATERIALDESCRIPTION = it_makt
RETURNMESSAGES = returnm.
IF it_ret-type eq 'E' or it_ret-TYPE eq 'S'.
Write:/1 it_ret-type,
8 it_ret-id,
30 it_ret-number,
38 it_ret-message,
190 it_ret-parameter,
210 it_ret-row,
220 it_ret-field.
endif.
endform. " F_call_bapi
Regards,
Ranjith Nresloved.
issue with the internal table structrue. -
Problem Using Custom Classes in UCCX8.5.1 SU3
Dear All,
My team is facing problem in using Java custom classes for UCCX 8.5.1 SU3
The problem is that we have created some conditional prompts for currency in different languages, our custom java class contains two mathods GetEnglishString(parameter set) and GetUrduString(parameter set). We are able to use/call both methods one by one and both at same time in CCX Editor and validate the script successfully but when we set the script as application it failed.
We tried to use both methods one by one and found that script with GetEnglishString is working ok but when we place GetUrduString (alone as well) MIVR logs say that method is unknown altough CCX Editor does not give us any error. We triend to restard Administration and Engine Services several time but to no avail. If somebody know the reason and solution kindly share it ASAP.
Regards
Kashif SurhioHi
In that case I would double check you have uploaded the file, and restart the server completely. In testing we found that restarting the engine didn't always reload the classes.
Aaron -
Accessing custom classes from JSP
Hi Guys,
I am having some problems accessing my custom classes from my JSP.
1) I've created a very simple class, SimpleCountingBean that just has accessors for an int. The class is in the package "SimpleCountingBean". I compiled this class locally on my laptop and uploaded the *.class file to my ISP.
2) I've checked my classpath and yes, the file "SimpleCountingBean/SimpleCountingBean.class" is located off of one of the directories listed in the classpath.
3) When I attempt to use this class in my JSP, via the following import statement:
import "SimpleCountingBean.*"
I get the following compile error
java.lang.NoClassDefFoundError: SimpleCountingBean/SimpleCountingBean
I'm pretty sure that my classpath is properly setup because when I purposely garble the import statement, I get the "package not found" compile error.
Do I need to upload some other files in addition to the class file? Any suggestions would of course be appreciated.
Sonny.Trying to get some clearer view.. so don't mind..
So you uploaded all your .jsp files into your account which is:
home/sonny
and it compiles and work. But custom classes doesn't seems to be working, where did you place your classes?
From my knowledge of tomcat, classes are normally placed in, in this case:
home/sonny/web-inf/classes
Maybe it differs from windows enviroment to *nix enviroment.. well, I'm just saying out so if its not the case.. don't mind me. -
Reg BAPI: "'BAPI_BASICPAY_CREATE" uploading to infotype P0008
The following BAPI to upload the salary data to info type PA0008( BASIC PAY).
This bapi is expects the table type amount with 4 decimals.
Please let us know any other bapi to upload the data to infotype 0008 or how to work with existing bapi. Sothat amount would be with 2 decimals raterthan 4 decimals.
CALL FUNCTION 'BAPI_BASICPAY_CREATE'
EXPORTING
EMPLOYEENUMBER = IT_PA0008-PERNR
SUBTYPE = IT_PA0008-SUBTY
VALIDITYBEGIN = IT_PA0008-BEGDA
VALIDITYEND = IT_PA0008-ENDDA
PAYSCALETYPE = IT_PA0008-TRFAR
PAYSCALEAREA = IT_PA0008-TRFGB
PAYSCALEGROUP = IT_PA0008-TRFGR
PAYSCALELEVEL = IT_PA0008-TRFST
NEXTINCREASE =
LOCALALLOWLEVEL =
PARTNERSHIP =
CURRENCY =
COMPARISONPAYSCLTYPE =
COMPARISONPAYSCLAREA =
COMPARISONPAYSCLGRP =
COMPARISONPAYSCLLVL =
COMPNEXTINCREASE =
CAPACITYUTILLEVEL = IT_PA0008-BSGRD
HOURSWORKEDPERPERIOD = IT_PA0008-DIVGV
ANNUALSALARY =
CASEGROUPCATALOG =
CASEGROUP =
CURRENCYANNUALSALARY = IT_PA0008-ANCUR
REASON =
NOCOMMIT =
IMPORTING
RETURN = IT_BAPIRETURN1
EMPLOYEENUMBER = V_PERNR
SUBTYPE =
OBJECTID =
LOCKINDICATOR =
VALIDITYBEGIN =
VALIDITYEND =
RECORDNUMBER =
TABLES
<b> WAGETYPES = IT_WAGE</b>
tHANKS
Badari
Help would be highly appreciable!PL note that HR_INFOTYPE_OPERATION is not RFC enabled.. you will have to wrap it around with a custom RFC in order to use it in palce of the above BAPI..
~Suresh -
BAPI function create Customer master(T-code XD01)??
Hi All,
i want to create BDC program using BAPI function create Customer master(upload customer master),but i do not know which BAPI function for create Customer master.
Does anyone know,please tell me which BAPI function i can use?
Thanks.
Van DungHi Amit Gujargoud,
I can use LSMW upload the data from legacy system to sap system., but my manager he did not want to use LSMW.He wants to use BAPI function for upload customer master.
I saw this BAPI function create customer master : BAPI_CUSTOMER_CREATEFROMDATA1,
BAPI_CUSTOMER_CREATEFROMDATA,
it is not enough field for input data.
example : if i want input : customer code,company code, Sales organiration,Distribution channel,Division.
So This BAPI function have not paramaters input this field.
Thanks for your answer
Van Dung. -
LSMW - Upload customer data (KNA1)
Hi,
I'm trying to upload customer data from a legacy system using buisness object KNA1 and method CREATEFROMDATA1 (BAPI). At first I discovered that to be able to use business object KNA1 I had to generate an ALE interface in transaction BDBG.
My problem is that when I try to "Maintain Structure Relations" I get following error message:
No target structures could be found
Message no. /SAPDMC/LSMW_OBJ_030001
Shouldn't it be possible to do it this way?
I prefer to use the BAPI method compare to Batch input for following reasons:
- Better performance
- I don't have to think of screen sequences. For example can different account groups mean different screens.
Thanks for help,
HansHans, did you ever come back to this problem and see if you could come up with a solution?
I am facing a similar problem while trying to upload Business Partners into our CRM system. Unfortunately for me, the batch input recording option is not viable, as that takes too long (~95 days to load our data, and can't be run in background). I have been told that I should look to use a BAPI, but am getting errors when trying to specify the field mapping.
Cheers,
Andrew -
Manipulate movieclip from custom class
Hello.
I have a movieclip (instance name preload), inside of it, I have another movieclip (bar) ... what i'm trying to do is a preloader for external files... i have a custom class and i what to manipulate my movieclip preload from it... you know verify the progress of the load:
Inside my class a have this function
public function loadProgress(e:ProgressEvent):void {
percent=e.bytesLoaded/e.bytesTotal*100;
rutaDos.preload.bar.scaleX=percent;
rutaDos is a reference to the stage... it works, I'm sure of it... the problem is:rutaDos.preload.bar.scaleX; I upload the files but it doesn't verify the progress of the load.
thanks for the helpthe complete class is:
package com.ludwing{
import flash.net.*;
import flash.events.*;
import flash.display.*;
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.display.Stage;
import gs.TweenMax;
import gs.easing.*;
import gs.events.*;
public class Transiciones extends MovieClip {
public var url:URLRequest;
public var loader:URLLoader;
public var rutaDos:MovieClip;
public var imgLoader:Loader;
public var movie:MovieClip;
public var container:Sprite;
public var bg:Boolean;
public var porcentaje:Number;
public function Transiciones(mRuta:MovieClip, miRuta:String,isBG:Boolean,contain:MovieClip) {
rutaDos=mRuta;
bg=isBG;
movie=contain;
container=new Sprite();
url=new URLRequest(miRuta);
imgLoader=new Loader();
imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete);
imgLoader.load(url);
public function onLoaderComplete(e:Event) {
imgLoader=new Loader();
imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imgComplete);
imgLoader.contentLoaderInfo.addEventListener(Event.INIT, imgInit);
imgLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
imgLoader.load(url);
public function loadProgress(e:ProgressEvent):void {
porcentaje=e.bytesLoaded/e.bytesTotal*100;
rutaDos.preload.bar.rotation=90;
public function imgInit(e:Event) {
movie.alpha=0;
rutaDos.preload.alpha=1;
public function imgComplete(event:Event) {
rutaDos.preload.alpha=0;
movie.addChild(imgLoader);
var myTween:TweenMax = TweenMax.to(movie, 1, {alpha:1, ease:Circ.easeOut});
myTween.addEventListener(Event.COMPLETE, onTransitionFinish);
public function onTransitionFinish(e:Event):void {
//MovieClip(root).gotoAndPlay(2);
//rutaDos.ext.gotoAndStop(2)
/*var my_parent:MovieClip=parent.parent as MovieClip;
my_parent.nextSection=2;
my_parent.gotoAndStop(my_parent.nextSection);*/
//rutaDos.stage.addEventListener(Event.RESIZE, resizeHandler);
if (bg==true) {
rutaDos.gotoAndStop(14);
I try to use an empty movieclip to load a external swf (instance name: ext) this way:
var transicion:Transiciones=new Transiciones(this, "welcome.swf",true,ext);
The external swf loads correctly, but when it is loading (i mean de progress load), the preload doesn't work.... -
Read Document Class Characteristics Values (Class Type 017)
Hi Gurus,
I want to read values of Document Class Characteristics (Class Type 017).
Is there any Functional Module available for this?
Best regards,
Abir.Hi ,
Use this BAPI BAPI_DOCUMENT_GETDETAIL2 to get the details of class and char values for particular documents.
kindly enter the data about the DIR and mark the ent
DOCUMENTTYPE DRW
DOCUMENTNUMBER 2000
DOCUMENTPART 000
DOCUMENTVERSION 00
GETOBJECTLINKS X
GETCOMPONENTS
GETSTATUSLOG
GETLONGTEXTS X
GETACTIVEFILES
GETDOCDESCRIPTIONS X
GETDOCFILES X
GETCLASSIFICATION X
GETSTRUCTURE
GETWHEREUSED
HOSTNAME
INHERITED
Here whatever marked as a 'X' BAPI will return the values for particular DIR.
Use TCODE SE37 for executing this BAPI or get the help of your technical person.
Regards
Abhiji A. Pachgade -
Unit testing: Mocking custom classes with null
Hi,
I was trying to save time on testing the usual hashCode() and equals() methods so I got this class: http://www.cornetdesign.com/files/BeanTestCase.java.txt
I altered it a bit as it wasn't handling standard classes only primitives.
Anyway, I got to the point to include my own custom classes.
I have to create a 'mock' object for my class properties, e.g. field.getType().newInstance()
Fine, but there are some tricky instances. E.g. when I'd like to create an instance of java.net.URL which takes a URL as String in the constructor.
This is almost impossible to automate as it has to be a valid URL format not just a random String.
So, I thought I set them to null, e.g.
assertTrue(o1.equals(o2))
as both properties are null.
Is this the right approach you think?
I welcome any suggestions.
My initial idea was to save enormous amount of time automating the hashCode() and equals() method tests as they took so long to write.
ThanksTrouble would be that you are only testing the null branch of the equals or hashCode, which typically have to check for null, then if not null do an actual comparison.
It's worth the effort of learning to use a package such as EasyMock to create and program mock objects. It's tidiier if you are progamming to interfaces, however, but it will mock ordinary objects, though probably not if they are final.
What you could do is to define a factory interface, and have a table of anonymous classes wich generate various types. In effect create a library of dumy object factories.
Something like:
private interface DummyGenerator {
Object generate(int idx);
Class<?> getType();
private final static DummyGenerator[] generatorsTable {
new DummyGenerator() {
public Object generate(int idx) {
return new URL("http://nowhere.com/" + idx);
public Class<?> getType() { return URL.class; }
.. generators for other classes
private final static Map<Class<?>, DummyGenerator> genMap = new HashMap<Class<?>, DummyGenerator>(generatiorsTable.length);
static {
for(DummyGenerator gen : generatorsTable)
genMap.put(gen.getType(), gen);
} -
Need help calling and looping custom classes
Hi, I am writing a code with custom classes in it and another program that calls upon all of the classes in the first program. I can get the second one (L6) to call upon and execute all of the classes of the first (Foreign). However, I need the second one to loop until quit is selected from the menu on Foreign and I can't seem to figure out how to do it. Here are the codes:
L6:
public class lab6
public static void main(String[] args)
Foreign camount = new Foreign();
camount = new Foreign();
camount.get();
camount.print();
camount.intake();
camount.convert();
camount.vertprint();
System.out.println(camount);
Foreign:
import java.util.Scanner;
public class Foreign
private String country;
private int choice;
private float dollars;
private float conversionValue;
private float conversionAmount;
public Foreign()
country = "null";
choice = 0;
dollars = 0;
conversionValue = 0;
conversionAmount = 0;
public void get()
Scanner Keyboard = new Scanner(System.in);
System.out.println("Foreign Exchange\n\n");
System.out.println("1 = U.S. to Canada");
System.out.println("2 = U.S. to Mexico");
System.out.println("3 = U.S. to Japan");
System.out.println("4 = U.S. to Euro");
System.out.println("0 = Quit");
System.out.print("\nEnter your choice: ");
choice = Keyboard.nextInt();
public void print()
System.out.print("\nYou chose " + choice);
public void intake()
Scanner Keyboard = new Scanner(System.in);
if (choice >= 1 && choice <= 4)
switch (choice)
case 1: System.out.println("\nU.S. to Canada");
conversionValue = 1.1225f;
country = ("Canadian Dollars");
break;
case 2: System.out.println("\nU.S. to Mexico");
conversionValue = 10.9685f;
country = ("Mexican Pesos");
break;
case 3: System.out.println("\nU.S. to Japan");
conversionValue = 118.47f;
country = ("Japanese Yen");
break;
case 4: System.out.println("\nU.S. to Euro");
conversionValue = 0.736377f;
country = ("European Union Euros");
break;
System.out.print("\nEnter U.S. dollar amount: ");
dollars = Keyboard.nextFloat();
public void convert()
conversionAmount = conversionValue * dollars;
public void vertprint()
System.out.println("\nCountry = " + country);
System.out.println("Rate = " + conversionValue);
System.out.println("Dollars = " + dollars);
System.out.println("Value = " + conversionAmount);
public String toString()
String line;
line = "\n" + country + " " + conversionValue + " " + dollars + " " + conversionAmount;
return line;
I appreciate any help anyone can give me. This is driving me crazy. Thanks.1. first you need to write method to get choice value from Foreign class.
simply add this method.
public class Foreign {
// ... Add this
public int getChoice() {
return choice;
}2. Then in your main, you can obtain with previos method.
public static void main(String[] args) {
Foreign camount = new Foreign();
// remove this. you alredy create an instance in last statement.
//camount = new Foreign();
int choice = 0;
do {
camount.get();
choice = camount.getChoice();
// your process...
} while (choice != 0);
}
Maybe you are looking for
-
How do I print a scanned-in photo from iPhoto
I scanned a photo into the iPhoto ap and was able to edit it but now desire to print it and cannot find a print option.
-
Does BAPI_PO_CHANGE work for ME22?
Hello, There is background program which is run at regular intervals, which changes the PO unit even when there is a GR created. So if I go to ME22n and change the order and save , PO unit is getting converted automatically. This is due to backgroun
-
What happened to the files from MobileMe when it went to ICloud
Am I crazy or does ICLOUD not store anything which isn't a MAC application. Did all the files which I had stored on Mobile Me just disappear?
-
Xmltype() does validation?
Hi, I'm trying to read xml content from a clob field. I try to extract "headers" and only after this I want the xml content to be validated. Here's my statement: SELECT xml.message_sgw_id, xml.message_source_system_id, xml.message_type_id, xml.action
-
While I generally use Firefox, one of the features I find useful in Internet Explorer 8 is that "alt text" appears as a small popup on mouse-over. I've searched Firefox and Firefox Help to see if there was a feature that could be enabled for this, bu