Class related object
How can I create a class related object??
In my code the class doens't find the log object(FileWriter)
example:
public class LogFile
public LogFile()
try
File outputFile = new File("/Java/Iss/log/BatchQuery.log");
FileWriter log = new FileWriter(outputFile);
catch (IOException exp)
System.out.println("Fatal error, can't write to log - "+exp.getMessage());
private static LogFile instance = new LogFile();
public static LogFile getInstance()
if(instance==null)
return instance = new LogFile();
else
return instance;
public static synchronized void write(String toLog)
log.write(toLog);
log.write("\n");
public static synchronized void close()
log.close();
}
Hi, shouldn t your code be like this ? :
public class LogFile
private static LogFile instance = new LogFile();
private FileWritter log = null;
public LogFile()
try
File outputFile = new File("/Java/Iss/log/BatchQuery.log");
log = new FileWriter(outputFile);
catch (IOException exp)
System.out.println("Fatal error, can't write to log - "+exp.getMessage());
public static LogFile getInstance()
if(instance==null)
return instance = new LogFile();
else
return instance;
public synchronized void write(String toLog)
log.write(toLog);
log.write("\n");
public synchronized void close()
log.close();
instance = null;
So now you have a static getInstance() method to recover the unique instance.
All others methods shouldn t be static so that they shall be called only if an instance has been generated.
Similar Messages
-
Hallo,
I want to start a
discussion, to find a best practice method to change several related master
data objects via BDT. At the moment we are faced with miscellaneous requirements,
where we have a master data object which uses BDT framework for maintenance (in
our case an insured objects). While changing or creating the insured objects a
several related objects e.g. Business Partner should also be changed or
created. So am searching for a best practices approach how to implement such a
solution.
One Idea was to so call a
report via SUBMIT AND RETURN in Event DSAVC or DSAVE. Unfortunately this implementation
method has only poor options to handle errors. Second it is also hard to keep LUW
together.
Another idea is to call an additional
BDT instance in the DCHCK-event via FM BDT_INSTANCE_SELECT and the parameters
iv_xpush_classic = ‘X’ and iv_xpop_classic = ‘X’. At this time we didn’t get
this solution working correctly, because there is always something missing
(e.g. global memory is not transferred correctly between the two BDT instances).
So hopefully you can report
about your implementations to find a best practice approach for facing such
requirements.
Hallo
ich möchte an der Stelle eine Diskussion starten um einen Best Practice
Ansatz zu finden, der eine BDT Implementierung/Erweiterung beschreibt, bei der
verschiedene abhängige BDT-Objekte geändert werden. Momentan treffen bei uns
mehrere Anforderungen an, bei deinen Änderungen eines BDT Objektes an ein
anderes BDT Objekte vererbt werden sollen. Sprich es sollen weitere Objekte geänderte
werden, wenn ein Objekt (in unserem Fall ein Versicherungsvertrag) angelegt
oder geändert wird (zum Beispiel ein Geschäftspartner)
Die erste unserer Ideen war es, im Zeitpunkt DSAVC oder DSAVE einen
Report per SUBMIT AND RETURN aufzurufen. Dieser sollte dann die abhängigen Änderungen
durchführen. Allerdings gibt es hier Probleme mit der Fehlerbehandlung, da
diese asynchrone stattfinden muss. Weiterhin ist es auch schwer die Konsistenz der
LUW zu garantieren.
Ein anderer Ansatz den wir verfolgt hatten, war im Zeitpunkt
DCHCK per FuBA BDT_INSTANCE_SELECT und den Parameter iv_xpush_classic = ‘X’ and
iv_xpop_classic = ‘X’ eine neue BDT Instanz zu erzeugen. Leider konnten wir diese
Lösung nicht endgültig zum Laufen bekommen, da es immer Probleme beim
Übertragen der globalen Speicher der einzelnen BDT Instanzen gab.
Ich hoffe Ihr könnt hier eure Implementierungen kurz beschreiben, dass wir
eine Best Practice Ansatz für das Thema finden können
BR/VG
Dominik -
New ID of related object in PO13
Hi all,
I explain u my prb.-
T code -<b> PO13</b>
Select Infotype name - Object
Then Create
Then Enter <b>Object Abbr</b> --> Save and then new screen is opened.
In New Screen, In <b>related Object</b> block
Type of related Object - <b>Organizational Unit</b> then at the
ID of related object field --> F4 --> <b>Organizational Structure window open</b>.
Then expand --> <b>directors office</b>
Click on <b>Sales and Marketting</b> --> now click on <b>central sales</b> --> Some branches name are displayed ( few fields are Branch name , ID , code ..).
<b>I want to add some new branches in that list.</b>
So pls tell me the procedure of add new branches in this list.
Thanks & regards,
Abhinay SachanHi,
PO13 is to create Positions, but a you want to create branches can use object type 'O' i.e t-code PO10.
Suppose u want to add 2 brances there.
then 1st create branches using
t-code PO10
select reqd. plan version
select object(1000) infotype -> create -> give Object abbr. and Object name -> save
the n in the next screen in the ID of related object give the object id of CENTRAL SALES. then SAVE.
repeat the procedure again for n number of brances u want to add.
~Thrilleswar -
I am working on a SCSM change control workflow driven by email.
A lot of my work is based on the information found in this post:
http://blogs.technet.com/b/servicemanager/archive/2012/04/03/using-data-properties-from-the-parent-work-items-in-activity-email-templates.aspx#pi158453=4
This is an excellent post to which my Internet searches continually return. The workflow is about 90% complete.
My question is can I insert the properties of a related object of the parent workitem in a workflow email notification?
For example, I want to include the name property of the RequestedByUser related object of the parent workitem object in a review activity notification.Thank you for your reply. I have confirmed my template is using a projection that includes the parent workitem and requested by user. Where I am having trouble is the notification template syntax used to call the properties of the related
object of the parent workitem. The picker in the GUI won't show that related object, so I have no example to follow. I hope this reply makes sense! -
Assigning object of one class to object of another class.
Hi,
How will i assign an object of one class to an object of another class?
Ex:
ClassX A=some_method();
Now how will I assign the object A of class ClassX to the object 'B' of another class 'ClassY'.In java you can only assign a object reference of one class into object reference of another class if the first class is the Second class (in other words the first class is a subclass of second class).
for example if this is a inheritance chart
Car ==========>Mercedes
"===========>Audi
then you can use
Audi a1 = new Audi();
Car c1 = a1;
or Mercedes m1 = new Mercedes();
Car c1 = m1;
but not
a1 = m1;
before assigning a variable into another variable of different class, use:
if(variable1 instanceOf ToBeAssignedIn Class){
variable2 = variable1;
example:
Audi a1;
Car c1;
if(a1 instanceOf Car){
c1 = a1;
Edited by: gaurav.suse on Apr 10, 2012 1:14 PM
Edited by: gaurav.suse on Apr 10, 2012 1:15 PM -
Class and Object name change in the universe designer
Hello Experts
I have a confusion , I am just wondering if I devlop a bobj universe, lets say, based on SQL database and change the name of the class and object during the creation of the universe, will that fetch the data from d/base properly while running a query / report. Although universe class and object has different names than database now but the records are the same. Do we need to point the object to d/base object in some kind of different or special way .
To make my question more simple, In d/base table name is "Employee" whereas on universe side I create a class name "Staff" and at the same time field name in the database is "Emploee ID" whereas in the universe I named it "Badge number".
Please advise if that will make any difference while I run the query or Is there any kind of complication on the universe side that I should expect which I am not familiar with.
I would apprecite your response.
Best RegardsHello experts,
Let me rephrase the issue with exact scenario.
I have a table names "REGION" with fields region id, region and country id.
I have another table name REGION_SLINE with fields SL_id, region id and Sales_revenue.
I created an equi join between these two tables based on region id field and checked the cardinality which is ok.
Now when I try to create a report based on sales revenue per customer ( "customer's first name" is an other field on CUSTOMER table), I dont get any result in the report and get a message that "No data to reterive"
Also please note that when I run a report which is sales revenue per region id, I get the result, seem slike these two tables REGION and REGION_SLINE can generate the report but sales revenue per customer report is not generated because customer first name is a field of another table.
I was just wondering if I need to write some kind of where clause in the object properties of region id which is used to create equi joon link.
I woulld appreciate your response.
Regards
Edited by: SAP_LCCHS on Jul 4, 2011 9:19 AM
Edited by: SAP_LCCHS on Jul 4, 2011 9:21 AM -
Object Class and Object Id for material Determination tables.
I want to know what is the Object Class and Object Id for material Determination records to verify tables CDHDR and CDPOS.
The purpose is to know the changes done by the different users for material determination records.
Can any one help.Hi ZZZSUNNY,
Similar question is answered recently.Please find the below link which will helps you
Material determination: how to see the creater of a record?
Thanks
Dasaradha -
Object class for object id 'ADRNR'
Hi all,
How can iget teh value of object class for object id 'ADRNR'. i tried to see teh contents in CDHDR but there are no entries in the dev and QA box either.
I need this value to pass to the CHANGEDOCUMENT_OPEN
and CHANGEDOCUMENT_CLOSe fm's.
ThanksHow can we find the correct object class id for a data element ?
Regards
Megha -
Find Universe, classes and objects used in each report
I want to find a list of universes, classes and objects used in each report
or the other way to find list of reports which use a particular universe. please let know, i could not get much information from activity universe in a proper way.Hello Venkataramat,
plese post in more detail what kind of report you are using Crystal report ? webi ? Deski.
Please post in the specific forums.
If you have a Crystal Report I recommend to post this query to the [Crystal Reports Design|SAP Crystal Reports; forum.
Best regards
Falk -
ALV using ABAP Classes and Objects
Hi All,
I am trying to print the values in my internal table using ALV, using ABAP classes and objects. Here the title for columns are picked based on the title specified in the data element. I want to set the title of my columns by my own. how to achieve this ?. Please provide me a sample code if possible.
thanks & regards,
Navneeth.KHello Navneeth
The following sample report shows how to build and modify a fieldcatalog (routine <b>BUILD_FIELDCATALOG_KNB1</b>).
*& Report ZUS_SDN_ALVGRID_EVENTS
REPORT zus_sdn_alvgrid_events.
DATA:
gd_okcode TYPE ui_func,
gt_fcat TYPE lvc_t_fcat,
go_docking TYPE REF TO cl_gui_docking_container,
go_grid1 TYPE REF TO cl_gui_alv_grid.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1.
PARAMETERS:
p_bukrs TYPE bukrs DEFAULT '2000' OBLIGATORY.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING
e_row_id
e_column_id
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_hotspot_click.
* define local data
DATA:
ls_knb1 TYPE knb1,
ls_col_id TYPE lvc_s_col.
READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row_id-index.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
CASE e_column_id-fieldname.
WHEN 'KUNNR'.
SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
WHEN 'ERNAM'.
* SET PARAMETER ID 'USR' FIELD ls_knb1-ernam.
* NOTE: no parameter id available, yet simply show the priciple
CALL TRANSACTION 'SU01' AND SKIP FIRST SCREEN.
WHEN OTHERS.
* do nothing
ENDCASE.
* Set active cell to field BUKRS otherwise the focus is still on
* field KUNNR which will always raise event HOTSPOT_CLICK
ls_col_id-fieldname = 'BUKRS'.
CALL METHOD go_grid1->set_current_cell_via_id
EXPORTING
is_row_id = e_row_id
is_column_id = ls_col_id.
ENDMETHOD. "handle_hotspot_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = p_bukrs.
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create ALV grid
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_docking
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Set event handler
SET HANDLER:
lcl_eventhandler=>handle_hotspot_click FOR go_grid1.
* Build fieldcatalog and set hotspot for field KUNNR
PERFORM build_fieldcatalog_knb1.
* Display data
CALL METHOD go_grid1->set_table_for_first_display
CHANGING
it_outtab = gt_knb1
it_fieldcatalog = gt_fcat
EXCEPTIONS
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.
* Link the docking container to the target dynpro
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
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.
* ok-code field = GD_OKCODE
CALL SCREEN '0100'.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form BUILD_FIELDCATALOG_KNB1
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog_knb1 .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'KNB1'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT gt_fcat INTO ls_fcat
WHERE ( fieldname = 'KUNNR' OR
fieldname = 'ERNAM' ).
ls_fcat-hotspot = abap_true.
ls_fcat-scrtext_s = '<short text>'. " short text of column
ls_fcat-scrtext_m = '<medium text>'. " medium text of column
ls_fcat-scrtext_l = '<long text>'. " longtext text of column
ls_fcat-tooltip = '...'. " ALV control: Tool tip for column header
ls_fcat-coltext = '...'. " ALV control: Column heading
MODIFY gt_fcat FROM ls_fcat.
ENDLOOP.
ENDFORM. " BUILD_FIELDCATALOG_KNB1
Regards
Uwe -
Why related objects with indirection are selected when deleting an object
myCompany object is related to one-to-many addresses through indirection.
Using uow.deleteObject(myCompany) shows that when commiting, before actually removing the object and its privately owned related objects, toplink select these related objects from database (SELECT FROM ...) . Why is it necessary to perform this latter operation ?
Thanks in advance for your reply,
ChrisThis could be possible, but TopLink would also need to update its cache. In addition, there are a number of other things TopLink must do on each of the individual objects - such as search them for privately owned relations, delete ordering, firing any events and including them in changesets for cache synchronization and auditing purposes. There could be more, but they all require that TopLink find the privately owned objects before it attempts to delete them.
I will enter a feature request though so that this option can be configured, as it might improve performance for users who do not use other options mentioned above.
Best Regards,
Chris -
Need help w/ created classes and objects
I am having a difficult time understanding what is wrong w/ my classes and objects. I've looked in two books and have messed around a bit. Here is what I am -attempting- to do.
I want to make a class called CLOTHING. In this class i want objects such as shirt and pants (for now).
these are the errors im getting:
.\Shirt.java:6: invalid method declaration; return type required
public Shirt(int size){
^
.\Shirt.java:3: class Clothing is public, should be declared in a file named Clothing.java
public class Clothing {
^
MyClassHW.java:10: cannot resolve symbol
symbol : constructor Shirt (int,int)
location: class Shirt
myShirt = new Shirt(1,1);
^
3 errors------------------------------------------------------------
This is the code for my Clothing class:
import java.awt.*;
public class Clothing {
private int shirtSize;
private void Shirt(Graphics s, int h, int v){
Polygon shirts;
shirts = new Polygon();
shirts.addPoint(5+h,8+v); // 1
shirts.addPoint(17+h,12+v); // 2
shirts.addPoint(19+h,13+v); // 3
shirts.addPoint(33+h,8+v); // 4
shirts.addPoint(37+h,13+v); // 5
shirts.addPoint(25+h,20+v); // 6
shirts.addPoint(25+h,28+v); // 7
shirts.addPoint(15+h,28+v); // 8
shirts.addPoint(15+h,20+v); // 9
shirts.addPoint(1+h,12+v); //10
s.fillPolygon(shirts);
}from what i understand each object is essentially a method...
Here is the code for the java applet I'm making:
import java.awt.event.*;
import java.awt.*;
import java.applet.*;
public class MyClassHW extends Applet { // implements ActionListener, AdjustmentListener {
Shirt myShirt;
int size;
public void init(){
myShirt = new Shirt(1,1);
// <applet code = "MyClassHW.class" height = 300 width=300> </applet>thank you for your time and help. as always, your efforts are appriciated..\Shirt.java:6: invalid method declaration; return type required public Shirt(int size){
I guess, public Shirt(int size) is constructor in class shirt. You have one int in this constructor. Shirt(int size)
Here you initialize your shirt with two int:
MyClassHW.java:10: cannot resolve symbolsymbol : constructor Shirt (int,int)location: class Shirt myShirt = new Shirt(1,1);
Shirt(int size, int what?)
It's why it show such message.
But even if you fix it seems like you have very vague ideas about what you are doing.
As far as I understood you need three classes.
First applet Clothing:
public class Clothing extends Applet{
Shirt myShirt;
Pants myPants;
public void init() {
myShirt = new Shirt(1); // small shirt
myPants = new Pants(32, 40); // medium waist and long legs
Second and third your classes Shirt and Pants:
public class Shirt extends Object {
int size;
public Shirt(int s) {
size = s;
public int getSize () {
return size;
same for Pants, only you need two parameters for it or whatever you want.
You could design it diffrently if you want derive your Shirts and Pants from Clothing and then to use them in your applet. But, indeeed, you desperately have to do some serious reading, where authors are accurate in they definitions and stuff, because it's kind of complicated. -
Setting a related object value from an update
Hi - Is there anyway without custom integration servic to set a field value of a related object based on the update to a
record (e.g. lead record)?
For example, I want to keep track of a user's total open leads for assignment purposes. So ideally I'd like to update the
user's custom lead count field, everytime my leads get closed or created.I believe this would require a custom web service program. I would recommend that you post this question in the CRM On Demand Integration Development forum.
-
Can I use classes and objects to create my own package in LabVIEW?
Hi....I am writing my thesis on develpoing a simulation package. I am trying to compare simulation packages and their feautures as a scope of my project. Does anyone know if LabVIEW allows users to create their own toolboxes like MATLAB?...i mean something that can be done in object-oriented programming by making classes and objects.
thanks guysThe short answer is yes. NI sells toolkits. There's also OpenG. How you code the guts is up to you - you can do it non-LVOOP or LVOOP.
-
What Class/Method/Object's would I use to send variable form data to BradySoft? I have a basic label setup in BradySoft and I want to send it variable form data (a serial number) from Labview ActiveX. I have attached Brady's ActiveX programmers guide but can't figure out what to use for this. P.S. I would call Brady or TekLynx tech support about this but they have a strict policy whereas BradySoft supports ActiveX but their tech support doesn't provide programming help with it. I figured I'd try the NI Forums.
Aaronb, I presume by publishing an ActiveX programmers manual the BradySoft software installs Active X objects. You may choose to interact with these objects within LabVIEW using Active X controls. The following link will provide a starting point for LabVIEW help topics on Active X communication: Select ActiveX Object Dialog Box
http://zone.ni.com/reference/en-XX/help/371361F-01/lvdialog/insert_active_x_object/
Building a Simple Web Browser Using ActiveX (Example of ActiveX arcitecture)
http://zone.ni.com/devzone/cda/epd/p/id/81 Hope this helps provide a bit of guidance. Cheers!
Maybe you are looking for
-
Why does Contacts crash each time I open it?
since the weekend, I cannot open the Contacts App - it crashes at open every single time with a report dump that states its an EXC_CRASH (SIGABRT)
-
same user with administrative rights on all the servers in single domain user as a part of administrator group in all the servers: same user is configured as administrator on all the servers in one domain at windows 2003 server. Should this user be m
-
How to create search index files for Java Pet Store
Hi All, As you may know, the java pet store application uses for the search function a search index object, which itself uses the following files '_36.cfs', 'deletable', 'segments'. Now as I want to change the data of the database (delete some pets,
-
Color Calibration Issues with iPhoto 7.0.2 and H-P Photosmart 7360
I'm having color calibration problems with print output to my H-P Photosmart 7360 since iPhoto 7 and above. Is anyone else encountering this? I'm consistently getting darker output on the printer compared to what's on the screen. Up until iPhoto 7, t
-
Hye, In Premiere CS6, when I use Speech Analysis and launch it, Media Encoder is giving me a .f4v file ! (instead of a xml file right ?). And so, Premiere is not able to use this file to give me a transcription. With CS5 i never had this problem. Any