Code register??? (Sry for double topic post)
Ok, here is my "problem"
I have read 2 huge manuals + half a book for teaching java.
I do understand variables, oo programing etc... , and I know how the coding works.
The only problem I have is to find a code register, where you got all the basic and most important codes, where the function is explained in side of each code.
I have find allot manuals, but no code register. Does it exist any code register I can look at, or is the only way to search for all the codes and functions in the manuals?
Edited by: Boffel on Feb 25, 2008 2:55 PM
Thanks so much for helping with this, Nubz!
Joerg's instructions are excellent. I refer to them often and I've had them bookmarked since I found Apple Discussions last year. The new Code section is great!! Very clear!
Now we just need to find a way to get users to that page. Our problem has never been with users who are interested enough in Apple Discussions to visit the Tips Library. The unformatted code is coming from first-time users--not necessarily novice coders, but programmers of all skill levels who aren't coming here to learn about the forums or relate to the community. These folks are focused on their current project, may have found no answers anywhere else, and arrive here with tunnel vision. Often there's a language problem as well.
The newly arrived OP will often start the thread with a page of unformatted code. Those of us with eyes used to filling in the missing brackets, indentation etc. can sometimes decypher the mess, but usually we need to give formatting instructions and ask the OP to repost. The frequency of this scenario has been increasing. Lately I've been posting those instructions almost once every day.
Of course that's a good sign! We've been giving good service down there and the number of newcomers seems to be reflecting that. A big percentage have turned into regulars, so I think we have a very healthy forum. It's just the formatting cycle gets old, and the time and bytes add up too.
My suggestion is this:
One yellow moderator announcement that stays in the first position on the topic page for both dev forums. The subject line is:
To format code: Paste your code here
The user doesn't even need to open the message. Only developers will see this. No change to the page header is needed. If the user does open the message, a link will be provided to Joerg's tips.
- Ray
Similar Messages
-
Configuring double invoice check for vendor invoices posted through FB60
Dear all
Can anyone tell me how to configure double invoice check for vendor invoices posted through FB60.
for miro documents..we can use Tcode OMRDC
Is there any such tcode which can be used for configuring fi invoices for double checking..
regards
ExpertiaDear Expertia,
In FI,when checking for duplicated invoices, the system compares the
following :Vendor, currency, company code, gross amount of the invoice,
reference document number and Invoice document date.
SAP Note 305201 clarifies this in a more details; please read it.
The following fields must be identical for Duplicate invoice check
Company code (BUKRS)
Vendor number (LIFNR)
Currency (WAERS)
Reference number (XBLNR)
Amount in document currency (WRBTR)
Document date (BLDAT)
If the document is having any one of the above filed different then the
system does not consider it as a duplicate invoice.
Also It will check duplicate invoice check in vendor master data and
in posting key is there check box selected for sales related
The setting you making in OMRDC i.e Materials management->Logistics
Invoice Verification->Incoming Invoice ->Set Check for Duplicate
Invoices is only valid for MM and not FI invoices posted via FB60/FB65
You should check the F1 help on field "Chk double inv." (LFB1-REPRF)
in the relevant vendor master record (transaction FK03).
Please also check, that message F5 117 has been set correctly in the
IMG using this path:
Financial Accounting -> Financial Accounting Global Settings ->
Document -> Default Values for Document Processing -> Change Message
Control for Document Control For Document Processing
Finally & mainly, go to the relevant posting key is defined as sales
related in transaction OB41. You have to flag this field if the
duplicate invoice check should work.
I hope this helps You.
mauri -
SORRY FOR DOUBLE POST GUYS, it bugged and I don't know how to delete it ! I don't want to get an infraction :/ ..
Hey Guys ! First of all, I'm new to the community and looking forward to be as active as possible to help people and get help from professionals ! (And sorry for my bad english tho :/..)
So here's the problem ...... I bought a blackbery Curve 9300 today, and what happens, is when I try to update it, it gave me at first, error 507 (Which means there's no OS in the device I suppose) ... when I tried to update it again, it gets stuck on ''Reconnecting to JVN'' or ''JVM'' can't remember ..... ive been trying to find a solution for hours and stil no luck .... i tried pulling the battery out and putting it back in, but doesnt work ..... a pop up message told me to go to control panel, check for USB Root hub and put a check mark on a certain option, but they were already checked ..... this situation is extremely frustrating because the guy from whom i bought the phone doesn't answer anymore, and I don't really want to take it to a store to repair it for like 60-80 $ or whatever ..... if possible, I'd like to get some help please !!!
Thank-You in advance guys !Hi 12khaled21,
Welcome to the community.
Error code 507 comes when there is no OS installed in your device.
Try downloading appropriate OS and install it.
Check this link KB10144 and reply back.
Raj
Click " Like " if you want to Thank someone.
If Problem Resolves mark the post(s) as " Solution ", so that other can make use of it. -
Error 'No tax code found for difference' in Posting Vendor Invoice IDOC
Hi All,
I am getting error message 'No tax code found for difference' while posting Vendor Invoice IDOC into SAP. IDOC type is INVOIC02. There is no difference in PO price, Invoice price and even Standard price. then why this error message? Other Vendor EDI settings are done ( OBCA, OBCD, OBCE etc). Is there any thing specific to be done in the config for this error?
IDOC has PO as reference document.
I looked into several threads in SDN forum but could not find proper solution
Can any ine help me with this issue?
Thanks in advance
HariHi
You might be missing the tax code for uploding through IDOC
so you can use the t.code we02 and give the doc and find the error
go to the WE19 to edit the tax code
and USE the t.code BD87 to select the doc and process it
thanks
Madhu -
Hi ,
Could anyone let me know the BDC OK Code for Double click.
I need to select a row by double clicking it in my recording but not able to capture the code for it.
Please do the needful.
Thanks in Advance,
Sowmmya BHi sowmmya,
1. If the row you are talking about is
ALV Grid OO concepts,
then i think there is a problem.
It won't work with BDC as u are trying.
2. Well, for getting the code,
before double clicking go in debug mode /H
and then double click.
3. Now in deubbing mode,
see the value of sy-ucomm.
regards,
amit m. -
Code for double clicking rows in alvgrido/p and moving it to internal tabl
hi,
code for double clicking rows in alvgrido/p and moving it to internal tablehi,
see the following code which uses layout , double_click event in ALVGRID.
TABLES: mara,marc.
DATA:obj_custom TYPE REF TO cl_gui_custom_container,
obj_alv TYPE REF TO cl_gui_alv_grid.
DATA: it_mara TYPE TABLE OF mara,
wa_mara TYPE mara,
wa_layout TYPE lvc_s_layo,
wa_variant TYPE disvariant,
x_save.
DATA:it_marc TYPE TABLE OF marc,
wa_marc TYPE marc.
SELECT-OPTIONS: s_matnr FOR mara-matnr DEFAULT 1 TO 500.
START-OF-SELECTION.
SELECT * FROM mara INTO TABLE it_mara
WHERE matnr IN s_matnr.
CALL SCREEN '100'.
CLASS cl_dbclick DEFINITION
CLASS cl_dbclick DEFINITION.
PUBLIC SECTION.
METHODS dbl FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
ENDCLASS.
DATA: obj1 TYPE REF TO cl_dbclick.
CLASS cl_dbclick IMPLEMENTATION
CLASS cl_dbclick IMPLEMENTATION.
METHOD dbl.
IF e_row-rowtype = space AND NOT e_row-index IS INITIAL.
READ TABLE it_mara INDEX e_row-index INTO wa_mara.
SELECT * FROM marc INTO TABLE it_marc
WHERE matnr = wa_mara-matnr.
CALL METHOD obj_custom->free
EXCEPTIONS
cntl_error = 1
cntl_system_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.
CALL SCREEN '200'.
ENDIF.
ENDMETHOD. "dbl
ENDCLASS. "cl_dbclick IMPLEMENTATION
*& Module USER_COMMAND_0100 INPUT
text
MODULE user_command_0100 INPUT.
CALL METHOD obj_custom->free
EXCEPTIONS
cntl_error = 1
cntl_system_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.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Module filldata OUTPUT
text
MODULE filldata OUTPUT.
CREATE OBJECT obj_custom
EXPORTING
container_name = 'CONTROL'.
CREATE OBJECT obj_alv
EXPORTING
i_parent = obj_custom.
CREATE OBJECT obj1.
SET HANDLER obj1->dbl FOR obj_alv.
CALL METHOD obj_alv->set_table_for_first_display
EXPORTING
i_buffer_active =
i_bypassing_buffer =
i_consistency_check =
i_structure_name = 'MARA'
is_variant = wa_variant
i_save = x_save
i_default = 'X'
is_layout = wa_layout
is_print =
it_special_groups =
it_toolbar_excluding =
it_hyperlink =
it_alv_graphics =
it_except_qinfo =
ir_salv_adapter =
CHANGING
it_outtab = it_mara
it_fieldcatalog =
it_sort =
it_filter =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " filldata OUTPUT
*& Module STATUS_0100 OUTPUT
text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module STATUS_0200 OUTPUT
text
MODULE status_0200 OUTPUT.
SET PF-STATUS 'STATUS'.
* SET TITLEBAR 'xxx'.
SUPPRESS DIALOG.
SET PARAMETER ID 'MAT' FIELD wa_mara-matnr.
LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.
*WRITE:/ wa_mara-matnr,
wa_mara-mbrsh,
wa_mara-meins.
CREATE OBJECT obj_custom
EXPORTING
container_name = 'CONTROL'.
CREATE OBJECT obj_alv
EXPORTING
i_parent = obj_custom.
CALL METHOD obj_alv->set_table_for_first_display
EXPORTING
i_buffer_active =
i_bypassing_buffer =
i_consistency_check =
i_structure_name = 'MARC'
is_variant = wa_variant
i_save = x_save
i_default = 'X'
is_layout = wa_layout
is_print =
it_special_groups =
it_toolbar_excluding =
it_hyperlink =
it_alv_graphics =
it_except_qinfo =
ir_salv_adapter =
CHANGING
it_outtab = it_marc
it_fieldcatalog =
it_sort =
it_filter =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " STATUS_0200 OUTPUT
*& Module layout OUTPUT
text
MODULE layout OUTPUT.
wa_layout-grid_title = 'MATERIAL DATA'.
wa_layout-zebra = 'X'.
wa_layout-edit = 'X'.
ENDMODULE. " layout OUTPUT
*& Module variant OUTPUT
text
MODULE variant OUTPUT.
wa_variant-report = 'ZALV_GRID1'.
x_save = 'A'.
ENDMODULE. " variant OUTPUT
*& Module USER_COMMAND_0200 INPUT
text
MODULE user_command_0200 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
CALL METHOD obj_custom->free
EXCEPTIONS
cntl_error = 1
cntl_system_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.
LEAVE TO SCREEN '100'.
ENDCASE.
ENDMODULE. " USER_COMMAND_0200 INPUT
thanks,
raji
reward if helpful -
(edited)pls delete this. sorry for double post.
pls delete. sorry for double post.
the many options in 'Export with Quicktime...' offer you .aiff as format.. which is the audio-only of your project.. drag that into iTunes/Toast/Jam/whatever CD-authoring you're using and you get an audioCD of the iM-project..
but that is a single-track, whole-gig-in-once CD ... little convenient (I would prefer seperate tracks).. so, I guess, you have to edit that .aiff export first in some app, ... I'm just an average iLife User, my preferred tool is Garageband... but, for sure, any other audio-processor, as Logic, is able to handle that with a snap..
just to feed my curiosity: what spurred you to give yourself such a nic?? -
Authorization for opening & Closing posting periods - OB52
Hi,
Is there any way to set authorization for opening & closing of posting periods in OB52?
My scenario:
I have 2 company codes - A & B assigned to 2 different posting period variant - say PPA & PPB.
The user belonging to CoCd A should not be able to open/close posting period of CoCd B and vice versa.
Is this possible through any authorization settings?
Request your help on this.
Regards,
SrideviHi Sridevi
Please go through the following:
You can assign authorization groups for permitted posting periods. This means that, for example, some posting periods can only be opened for particular users within monthly or annual closing. You can only assign the authorization group at document header level and it only affects period 1. The authorization object is called F_BKPF_BUP (Accounting document: Authorizations for posting periods). Read the corresponding chapter on "User maintenance" in the "Assigning authorizations" topic.
"User maintenance"
Due to the modular authorization concept of the system, you can define authorization profiles which are tailored to the workplace of your employees. You can, for example, assign authorization to a workplace in the Accounts Receivable, Accounts Payable or General Ledger Accounting areas.
By assigning authorizations you define which business-related objects your employees are allowed to process and which editing functions are allowed.
In the following activities for authorization management, you must carry out the following for employees who are to work with the system:
Assign authorizations
The authorizations are assigned by specifying permitted values for the pre-defined objects.
Define profiles
In the SAP system, authorizations are grouped together in workplace profiles. Therefore one or more profiles must be allocated to the individual employee in the master record.
I hope this helps.
Regards
Kavitha -
Double Factory pattern purposal as replacement for Double Check #2
Hi All,
Here is the code for the pattern proposal, its intended as a replacement for double checked locking, which was proved to be broken in 2001. Here is the code...
public class DoubleFactory {
private static Object second_reference = null;
public static Object getInstance() {
Object toRet = second_reference;
if (toRet == null) {
second_reference = CreationFactory.createInstance();
toRet = second_reference;
return toRet;
private DoubleFactory() {}
public class CreationFactory {
private static Object instance = null;
public static synchronized Object createInstance() {
if (instance == null) {
instance = new Object();
return instance;
}Also I have spent several months discussing this with Peter Haggar, who believes that this code is not guaranteed to work. However I have been unable to discern from his message why he believes this will not be guaranteed to work, and I am posting this here to attempt to find a clearer explanation or confirmation that the pattern I am purposing (Double Factory) is guaranteed to work.
Thanks,
Scott
---------------------------- Original Message ----------------------------
Subject: Re: [Fwd: Double Factory replacement for Double Check #2] From:
"Scott Morgan" <[email protected]>
Date: Fri, January 25, 2008 10:36 pm
To: "Peter Haggar" <[email protected]>
Hi Peter,
I appologize if my last response came accross as rude or something. If
my code is not guaranteed to work ok, can you help me understand why. I
am after all looking for a solution for all of us.
If my solution is wrong as you say because the member variables of the
singleton are not up to date. I understand this to mean that the
second_reference pointer is assigned to the memory where the instance
object will get created before the instance object even starts the
creation process (when the jvm allocates memory and then enters the
constructor method of the Singleton). This doesn't seem possible to me.
Can you refrase your statments, to help me understand your points?
If not I am happy to turn to the original wiki for discussion.
Thanks for your effort,
Scott
Thanks for asking my opinion, many times, then telling me I'm
wrong...wonderful. You are a piece of work my friend. For what it'sworth, your email below shows you still don't understand these issues
or what I was saying in my emails. I've been more than patient.
>
All the best. And by the way, your code is not guaranteed to work. It's not just me that's "wrong", it's also the engineers at Sun who
designed Java, the JVM, and the memory model, and countless people who
have studied it. I'm glad you have it all figured out.
>
Peter
"Scott Morgan" <[email protected]>
01/18/2008 12:47 PM
Please respond to
[email protected]
To
Peter Haggar/Raleigh/IBM@IBMUS
cc
Subject
Re: [Fwd: Double Factory replacement for Double Check #2]
Hi Peter,
Thanks I understand your position now. However am I still believe that
it will work and be safe;
1) the Singleton you show would be fully constructed (having exited theSingleton() method) before the createInstance() method would have
returned.
2) The second_reference could not be assigned until the createInstance()
method returns.
3) So by the time second_reference points to Singleton all of the valueswill be set.
>
>
I do understand that if the createInstance method was not synchronized(at the CreationFactory class level) that my logic would be flawed, but
since there is synchronization on that method these points are true, and
your comments about up-to-date values are not accurate.
>
Cheers,
Scott
>In your listing from your latest email T2 does encounter a sync block
on createInstance.
>>>>
No. T2 will call getInstance and see second_reference as non-null.second_reference was made non-null by T1.
>>
>>>>
What are you exactly are you refering to with the phrase 'up-to-datevalues'?
>>>>
Assume my singleton ctor is thus:
public class Singleton
private int i;
private long l;
private String str;
public Singleton()
i = 5;
l = 10;
str = "Hello";
T2 will get a reference to the Singleton object. However, because youaccess second_reference without synchronization it may not see i as 5,
l as 10 and str as "Hello". It may see any of them as 0 or null. This
is not the out of order write problem, but is a general visibility
problem because you are accessing a variable without proper
synchronization.
>>
Peter
"Scott Morgan" <[email protected]>
01/16/2008 11:38 PM
Please respond to
[email protected]
To
Peter Haggar/Raleigh/IBM@IBMUS
cc
Subject
Re: [Fwd: Double Factory replacement for Double Check #2]
Hi Peter,
In your listing from your latest email T2 does encounter a sync blockon createInstance.
>>
What are you exactly are you refering to with the phrase 'up-to-datevalues'?
In this code the Singleton should also be
A) non mutable (as in the instance of class Object in the example).
If the singleton was more complex then the code to populate it'svalues
would go inside the sync of createInstance().
B) mutable with synchronization on it's mutator methods.
In your article you mention out of order writes, which doesn't occurin
this code.
Cheers,
Scott
You read it wrong.
- T1 calls getInstance which in turn calls createInstance.
- T1 constructs the singleton in createInstance and returns to
getInstance.
- T1 sets second_reference to the singleton returned in getInstance. -T1 goes about its business.
- T2 calls createInstance.
- T2 sees second_reference as non-null and returns it
- Since T2 accessed second_reference without sync, there is noguarantee
that T2 will see the up-to-date values for what this object refers to.
- Therefore the code is not guaranteed to work.
>>>
If this is not clear:
- Re-read my email below
- Re-read my article
- If still not clear, google on Double Checked Locking and readanything
from Brian Goetz or Bill Pugh.
Peter
"Scott Morgan" <[email protected]>
01/13/2008 05:26 AM
Please respond to
[email protected]
To
Peter Haggar/Raleigh/IBM@IBMUS
cc
Subject
Re: [Fwd: Double Factory replacement for Double Check #2]
Hi Peter,
Thanks for the reply, I don't see how T2 would see the a referenceto
a
partialy initialized object before the createInstance() method had
returned. If T1 was in createInstance() when T2 entered
getInstance(), T2 would wait on the CreationFactory's class monitor to
wait to enter createInstance().
Or in other words in the line of code ....
second_reference = CreationFactory.createInstance();
The pointer second_reference couldn't be assigned to the singleton
instance when the synchronized createInstance() had fully constructed,initialized and returned the singleton instance. Before that the the
second_reference pointer would always be assigned to null. So any
thread entering getInstance() before createInstance() had returned
(for the first time) would wait on the CreationFactory's class monitor
and enter the createInstance() method.
>>>
So T2 will wait for T1.
Cheers,
Scott
PS I think I am writing requirements for my next project :)
Sorry for the delay...been in all day meetings this week.
You are correct...I had been reading your code wrong, my apologies.
My explanations, although correct, did not exactly correspond to your
code.
However, the code is still not guaranteed to work. Here's why:
Assume T1 calls getInstance() which calls createInstance() and returnsthe
singelton. It then sets second_reference to refer to that singleton.
So
far, so good. Now, T2 executes and calls getInstance(). It can see
second_reference as non-null, so it simply returns it. But, there
was
no
synchronization in T2's code path. So there's no guarantee that even
if
T2 sees an up-to-date value for the reference, that it will seeup-to-date
values for anything else, ie what the object refers to...it's
instance data. If T2 used synchronization, it would ensure that it
read
up-to-date
values when it obtained the lock. Because it didn't, it could see
stale
values for the object's fields, which means it could see a partially
constructed object.
>>>>
In the typical double-checked locking, the mistake is to assume theworst
case is that two threads could race to initialize the object. But
the worst case is actually far worse -- that a thread uses an object
which
it
believes to be "fully baked" but which is in fact not.
Peter
"Scott Morgan" <[email protected]>
01/03/2008 06:33 PM
Please respond to
[email protected]
To
Peter Haggar/Raleigh/IBM@IBMUS
cc
Subject
Re: [Fwd: Double Factory replacement for Double Check #2]
Hi Peter,
Thanks for responding, I am still thinking that your mis
interpreting
the code so I have rewritten it here (Replacing
DoubleFactory.instance with DoubleFactory.second_reference for
clarity). If the T1 burps (gets interrupted) in the createInstance
method it wouldn't have returned so the second_reference pointer
would have never been
assigned
so T2 would just try again upon entering the getInstance method. Orif
it had already entered getInstance it would be waiting to enter
(until T1 releases the lock on CreationFactory.class ) on the
createInstance method.
>>>>
public class DoubleFactory {
private static Object second_reference = null;
public static Object getInstance() {
Object toRet = second_reference;
if (toRet == null) {
second_reference =
CreationFactory.createInstance();
toRet = second_reference;
return toRet;
private DoubleFactory() {}
public class CreationFactory {
private static Object instance = null;
public static synchronized Object createInstance() {
if (instance == null) {
instance = new Object();
return instance;
Does this clear up my idea at all?
second_reference should be always pointing to
null
or
a fully initialized Object
(also referenced by the pointer named 'instance' ), I don't see howit would end up partially initialized.
>>>>
Thanks Again,
Scott
"It" refers to T2.
Your createInstance method is identical to my Listing 2 and is fine
and
will work.
Yes, the problem with your code is in getInstance.
>I don't see how the DoubleFactory getInstance method could bereturning
a partially initialized object at this point. If CreationFactoryalways
returns a fully initialized object and DoubleFactory only assigns a
new
reference/pointer to it how could DoubleFactory getInstance return a
reference/pointer to partially initialized object?
>>>>>>>
>>>>>
The reason it is not guaranteed to work is explained in my previousemails
and in detail in the article. However, I'll try again. Anytime you
access shared variables from multiple threads without proper
synchronization, your code is not guaranteed to work. Threads are
allowed
to keep private working memory separate from main memory. There are
2
distinct points where private working memory is reconciled with main
memory:
- When using a synchronized method or block - on acquisition of thelock
and when it is released.
- If the variable is declared volatile - on each read or write of
that
volatile variable. (Note, this was broken in pre 1.5 JVMs which isthe
reason for the caveat I previously mentioned)
Your createInstance method uses synchronization, therefore, the
reconciliation happens on lock acquisition and lock release. T1 can
acquire the lock in createInstance, make some updates (ie create an
object, run it's ctor etc), but then get interrupted before exiting
createInstance and therefore before releasing the lock. Therefore,
T1
has
not released the lock and reconciled its private working memory withmain
memory. Therefore, you have ZERO guarantee about the state of mainmemory
from another threads perspective. Now, T2 comes along and accesses
"instance" from main memory in your getInstance method. What will
T2
see?
Since it is not properly synchronized, you cannot guarantee that T2sees
the values that T1 is working with since T1 may not have completely
flushed its private working memory back to main memory. Maybe it
did completely flush it, maybe it didn't. Since T1 still hold the
lock,
you
cannot guarantee what has transpired. Maybe your JVM is not usingprivate
working memory. However, maybe the JVM your code runs on does or
will
some day.
Bottom line: Your code is not properly synchronized and is notguaranteed
to work. I hope this helps.
Peter
"Scott Morgan" <[email protected]>
01/03/2008 12:49 PM
Please respond to
[email protected]
To
Peter Haggar/Raleigh/IBM@IBMUS
cc
Subject
Re: [Fwd: Double Factory replacement for Double Check #2]
Hi Peter,
Thanks for your response, I don't follow what 'it' refers to in
the
phrase 'It can see'. So for the same reason that you state that
example 2 from your article I believe this class CreationFactory to
work flawlessly when a client object calls the createInstance
method.
>>>>>
I see this CreationFactory code as identical to your example 2 doyou agree with this?
>>>>>
public class CreationFactory {
private static Object instance = null;
public static synchronized Object createInstance() {
if (instance == null) {
instance = new Object();
return instance;
}Then my rational in the DoubleFactory class is that it can obtain a
reference/pointer to the fully initialized object returned bycalling the above code. I believe you think that the problem with
my code is
in
the DoubleFactorys getInstance method, is this correct?
I don't see how the DoubleFactory getInstance method could bereturning
a partially initialized object at this point. If CreationFactory
always
returns a fully initialized object and DoubleFactory only assigns a
new
reference/pointer to it how could DoubleFactory getInstance return a
reference/pointer to partially initialized object?
>>>>>
Thanks again,
Scott
public static synchronized Singleton getInstance() //0
if (instance == null) //1
instance = new Singleton(); //2
return instance; //3
This above code is fine and will work flawlessly.
Annotating my paragraph:
T1 calls getInstance() and obtains the class lock at //0. T1 "sees"
instance as null at //1 and therefore executes: instance = new
Singleton() at //2. Now, instance = new Singleton() is made up of
several lines of non-atomic code. Therefore, T1 could be
interrupted
after Singleton is created but before Singleton's ctor isrun...somewhere
before all of //2 completes. T1 could also be interrupted after
//2 completes, but before exiting the method at //3. Since T1 has
not
exited
its synchronized block it has not flushed its cache. Now assume T2
then
calls getInstance().
All still true to this point. However, with your code the nextparagraph
is possible, with the code above, it's not. The reason is that T2
would
never enter getInstance() above at //0 because T1 holds the lock. T2will
block until T1 exits and flushes it's cache. Therefore, the code
above
is
properly thread safe.
It can "see" instance to be non-null and thus
return it. It will return a valid object, but one in which its ctor
has
not yet run or an object whose
values have not all been fully flushed since T1 has not exited itssync
block.
"Scott Morgan" <[email protected]>
01/02/2008 06:10 PM
Please respond to
[email protected]
To
Peter Haggar/Raleigh/IBM@IBMUS
cc
Subject
Re: [Fwd: Double Factory replacement for Double Check #2]
Hi Peter,
Thanks for the response I understand the rational for inventing
the
double check anti pattern, I am sorry I still don't understand the
difference between your solution #2 and my CreationFactory class.
>>>>>>
From your article figure 2.public static synchronized Singleton getInstance() //0
if (instance == null) //1
instance = new Singleton(); //2
return instance; //3
If I understand your email correctly this figure 2 is also flawed,since...
>>>>>>
T1 calls getInstance() and obtains the class lock at //0. T1 "sees"
instance as null at //1 and therefore executes: instance = new
Singleton() at //2. Now, instance = new Singleton() is made up ofseveral lines of non-atomic code. Therefore, T1 could be
interrupted
after Singleton is created but before Singleton's ctor isrun...somewhere
before all of //2 completes. T1 could also be interrupted after
//2 completes, but before exiting the method at //3. Since T1 has
not
exited
its synchronized block it has not flushed its cache. Now assume T2
then
calls getInstance(). It can "see" instance to be non-null and thus
return it. It will return a valid object, but one in which its
ctor
has
not yet run or an object whose
values have not all been fully flushed since T1 has not exited itssync
block.
So is #2 is also flawed for this reason?
If so please revise your article, since I interpreted #2 as a
plausible
solution recommended by you (which lead me to the DoubleFactory
idea).
If not please help me understand the difference between #2 and my
CreationFactory class.
>>>>>>
Thanks,
Scott
#2 is in Listing 2 in the article. What I meant was to forget the
DCL
idiom, and just synchronize the method...that's what listing 2
shows.
DCL
was invented to attempt to get rid of the synchronization for 99.9%
of
the
accesses.
The solution I outlined in my email is using the DCL idiom, but on
a
1.5
or later JVM and using volatile.
You solution is not guaranteed to work. Here's why:
public class DoubleFactory {
private static Object instance = null;
public static Object getInstance() {
Object toRet = instance;
if (toRet == null) {
instance =
CreationFactory.createInstance();
toRet = instance;
return toRet;
private DoubleFactory() {}
public class CreationFactory {
private static Object instance = null;
public static synchronized ObjectcreateInstance()
//1
if (instance == null) {
instance = new Object(); //2
return instance;
} //3
}T1 calls createInstance() and obtains the class lock at //1. T1"sees"
instance as null and therefore executes: instance = new Object() at//2.
Now, instance = new Object() is made up of several lines of
non-atomic
code. Therefore, T1 could be interrupted after Object is created
but
before Object's ctor is run...somewhere before all of //2
completes.
T1
could also be interrupted after //2 completes, but before exiting
the
method at //3. Since T1 has not exited its synchronized block ithas
not
flushed its cache. Now assume T2 then calls getInstance(). It can"see"
instance to be non-null and thus return it. It will return a
valid object, but one in which its ctor has not yet run or an
object
whose
values have not all been fully flushed since T1 has not exited itssync
block.
The bottom line is that if you are accessing shared variables
between
multiple threads without proper protection, you are open for aproblem.
Proper protection is defined as: proper synchronization pre 1.5,
and
proper synchronization or proper use of volatile 1.5 or after.
Therefore, if you must use the DCL idiom you have one option: -
Use DCL with volatile on a 1.5 or later JVM.
>>>>>>>
You can also forget about DCL and just use synchronization (listing2
in
my article) or use a static field (listing 10 in my article).
I hope this clears it up.
Peter
"Scott Morgan" <[email protected]>
01/02/2008 04:00 PM
Please respond to
[email protected]
To
Peter Haggar/Raleigh/IBM@IBMUS
cc
Subject
Re: [Fwd: Double Factory replacement for Double Check #2]
Hi Peter,
I apologies for not understanding but I don't see what is
different
between the solution you purposed...
2) Don't use DCL but use synchronization
and the code that I am putting forward. Perhaps I do just notunderstand
but you seem to be contradicting yourself in this email?
I understand that you are saying in #2 that this will always 'work'
with
out any issues...
public static Object instance = null;
public static synchronized Object getInstance() {
if (instance == null) {
instance = new Object();
return instance;
But first you seem to say in the email that if T1 gets
interrupted
it
may leave the instance pointing to a partially initialized object?
So as far as I understand it the createInstance method in my
CreationFactory class should be successful (always retuning a
fully initialized object) for the same reason #2 is successful.
Please keep in mind that there are two different instancepointers
in
the code I sent you, one is part of the DoubleFactory class and
the other is part of the CreationFactory class.
>>>>>>>
Thanks for your time, just looking for better solutions!
Scott
Scott,
Your solution is not guaranteed to work for various reasons
outlined
in
the article. For example, you can still return from your code apartially
initialized object. This can occur if T1 gets interrupted beforeleaving
the synchronized method createInstance() and T2 calls
getInstance().
T2
can "see" toRet/instance as non-null but partially initialized
since
T1
has not fully flushed its values.
As of 1.5, Sun fixed various issues with the memory model that
were
broken. Double Checked Locking will still break unless you usevolatile
(which was fixed in 1.5). Therefore, the following code works:
volatile Helper helper;
Helper getHelper() {
if (helper == null)
synchronized(this) {
if (helper == null)
helper = new Helper();
return helper;
but the original DCL idiom will not work. So, your options are:
1) Use DCL with volatile (above)
2) Don't use DCL but use synchronization
3) Don't use DCL, but use a static field.
#2 and #3 are outlined in my article from 2002.
Hope this helps,
Peter
"Scott Morgan" <[email protected]>
12/26/2007 04:12 PM
Please respond to
[email protected]
To
Peter Haggar/Raleigh/IBM@IBMUS
cc
Subject
[Fwd: Double Factory replacement for Double Check #2]
Hi Peter,
Thanks for the article on the out of order write problem. Whatdo
you
think of this as a solution?
TIA,
Scott
---------------------------- Original Message----------------------------
Subject: Double Factory replacement for Double Check #2
From: "Scott Morgan" <[email protected]>
Date: Wed, December 26, 2007 2:55 pm
To: [email protected]
Hi Ward,
Here is a pattern submission
Double Factory
Lazy initialization of singletons in accepted for a while usingthe
double check pattern. However it has been discovered that the
double
check pattern isn't thread safe because of the out of order write
problem. This problem occurs when Threads entering the Singleton
Factory method return with a fully constructed, but partially
initialized, Singleton object.
>>>>>>>>
Therefore: It makes sense to look for a way to initializeSingletons
in
a Lazy and Thread Safe manor. The following illustrates a fairly
simple
solution...
package foo;
public class DoubleFactory {
private static Object instance = null;
public static Object getInstance() {
Object toRet = instance;
if (toRet == null) {
instance =
CreationFactory.createInstance();
toRet = instance;
return toRet;
private DoubleFactory() {}
public class CreationFactory {
private static Object instance = null;
public static synchronized ObjectcreateInstance()
if (instance == null) {
instance = new Object();
return instance;
This gets around the out of order write problem because all
Threads
waiting on the CreationFactory's Class monitor will have a fully
constructed and initialized instance when they actually exit the
createInstance method.
>>>>>>>>
>>>>>>>>
During runtime while the Singleton instance is getting created(constructed and initialized) there may be a few Threads waiting
on
the
CreationFactory Class's objects monitor. After that period all
the
Treads
accessing
the Singleton will have unsynchronized reads to the instance,
which
will
optimize execution.
References:
http://www.ibm.com/developerworks/java/library/j-dcl.html
Copyright 2007 Adligo Inc.Scott-Morgan wrote:
Hi All,
Thanks for your comments, here are some more....
jtahlborn you state that
the only way to guarantee that a (non-final) reference assignment is visible across threads is through the use of volatile and synchronized,
From the jvm spec
http://java.sun.com/docs/books/jls/third_edition/html/memory.html
17.4.1 Shared Variables
Memory that can be shared between threads is called shared memory or heap memory.
All instance fields, static fields and array elements are stored in heap memory.
Since both the second_reference and instance fields are both static, they are shared and visible across all threads.Yes, all these things are shared across threads, however, if you keep reading, there is a notion of "correct" sharing. obviously these values may be visible, that's why double-checked locking was used for so long before people realized it was broken. it worked most of the time, except when it didn't, and that's what i'm trying to show. that the only way to correctly share state between threads is via synchronization points, the most common being volatile and synchronized (there are a couple of other less used ones which don't apply here). The articles you linked to below from ibm cover the "visibility" in great depth, this is exactly what i am referring to.
You also state that volatile is a solution, but you seem to rebut your self in stating that the overhead for volatile is almost as great as synchronization.
This article illustrates the solution, and also comments on the overhead of volatile.
http://www.ibm.com/developerworks/library/j-jtp03304/
linked from
http://www.ibm.com/developerworks/java/library/j-dcl.html
volatile is a solution, in that it is correct, and you avoid the appearance of synchronization each time. however, since the semantics of volatile were strengthened in the new memory model, using volatile will perform practically (if not exactly) the same as simply synchronizing each time. the article you link to says exactly this under the heading "Does this fix the double-checked locking problem?".
Also could you be more specific about the example at the end of the jvm memory spec page, like a section number?It's the very last thing on the page, the "discussion" under 17.9, where it mentions that changes to "this.done" made by other threads may never be visible to the current thread. -
How to get client side validation for double range and double field in stru
Hi,
I have achieved client side validation by using <html:javascript formName=""/>
All fields shows client side validation but double field and double range field is not shows client side validation but shows server side validation.
I am using Liferay jboss server.
Please tell me a way to achieve client side validation for double field and double range.
Thanks & Regards,
Brijesh BaserI see in the query component there is a QueryListener and a QueryOperationListener. Have you tried letting Jdeveloper create methods for these in some backing bean, and putting in some debug code to see when these methods run? I would think one of them could very well be used to validate the input, somehow; if the input were bad you could just raise an exception and pass your error message, I bet.
If not...
I am pretty sure that there is an appendix in the Fusion Developer's Guide for Forms developers turned to Java...you might look at what it says for post query. I know in the 10.1.3.0 equivalent documentation, they gave reference to a method in the ViewObject which fired for each record after a query was run. You could definitely intercept this query return from there. In fact doing something like this may be something like what Frank N. was intending when he mentioned ViewObjects "validation". Not sure though. I am still learning what new features there are in 11g adf/bc.
Good luck. -
Where can I find detailed, systematic HELP for advanced topics relating to Thunderbird?
In moving from XP to Windows 7, I opted for Thunderbird as email client in order to bypass Microsoft's hyper-intrusive Windows Live Mail (I used Outlook Express for years).
I have a very complicated email structure, and it's taken me weeks (seriously) to learn how to replicate it in TBird. Now I'm trying to customize TBird further, but none of the TBird articles/forum Q&A's/Google searches address my questions.
There is no live tech support for TBird, and I'm just about ready to leave it for good. However -- one last effort: where can I find detailed, systematic HELP for advanced topics relating to Thunderbird?
Thanks.I am no expert, but I don't know of any authoritative reference as to what elements of HTML and CSS are supported in Thunderbird. However, as I believe you appreciate, it's more than just what Thunderbird supports, but one must also think about what is likely to work in other email clients. Keep it simple. Avoid ancient deprecated tags that other email clients may not support, and for similar reasons, avoid cutting edge technology. Remember that recipients using tablets or smartphones won't appreciate large fancy email documents.
The only thing ''guaranteed'' to work in email is plain text. ;-)
If you haven't already discovered it, the Stationery add-on is designed specifically to support OE stationery in Thunderbird. Your existing stationery may "just work" in this add-on. It makes switching between various stationery templates much easier, but I'm not confident that it will affect interpretation of your CSS or HTML coding.
Your code is at least clean and minimal. Most times my involvement with troublesome templates and signatures centres on the horrible bloat and mso custom code generated by Word or Outlook.
Having said that, you and I are mortal enemies, as I don't have much patience with what you aspire to achieve. I specifically don't like background images, nor being obliged to suffer other folks' bizarre choice of typefaces and colours (but your simple 12pt black Tahoma is quite inoffensive. ;-) ) I'm of an age where my tolerance and eyesight are easily offended.
Nonetheless, I'm intrigued by how to parse the tag for the background image, as it doesn't look like a legitimate pathname to a graphics file. Does the background image actually appear as required? -
Using a Single Registered UDO for multiple Transactions
Dear Experts,
We are developing a Expense Booking System by using SAP B1 SDK. in .NET
The scenario is like this.
Need to book the expenses independently by using an Expense Booking Screen, and also from a Transaction screen (Sales) where the user enters the expenses details incurred during the sales activity.
Data from both the screens should be saved in a single User defined table.
ie, The Expense Booking Screen uses the table for direct saving and the Sales screen uses the same table as the child table of the transaction where the parent (header) table holds the details of Sales activity.
The table object is registered for the Direct Expense Booking screen.
Can I use the same object for the Sales Expense booking screen?
Is it possible?
If so, how can I implement it?
Please advice..
Thanks in advance
Regards,
TomsSure
Generic services are using to maintain UDO table using SDK. You no need to assign values to datasource items. You can simple collect the values from the form items / user data sources and update the UDO table accordingly.
First you go to this link
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d04b34b5-68cf-2b10-bc98-806feb4299ba
and download the DI GENERAL SERVICE SAMPLES
Applications with full source code is available for
1. Master Data UDO maintenance
2. Master Data UDO + Child Tables Maintenance
3. Document Data UDO maintenance
4. Document Data UDO + Child Tables Maintenance
Thank you
Anoop -
Custom process code and FM for custom IDoc...
Hello Experts,
I created a custom IDoc based from ARTMAS05 IDoc. This is because we only need 3 segments and
the standard idoc(Artmas05) contains so many segments that we need.
Now, will I create a custom process code and FM for this? how do I go about this?
Thank you guys and take care!Hello,
Here are the Steps that we need to be following while creating a Custom Process Code with Custom Function Module. ( Since the Segments to be handled are very Less, I am recommending that you go for a Custom Function Module).
1. Go to SE37 Create a Function Module. Please ensure to Create it with the IMPORT / EXPORT /TABLES parameters exactly in the way that they exist in any Standard SAP Inbound FM (Refer to IDOC_INPUT_ORDERS for example).
2. Once our FM is Ready (Need not be Complete with the Code to go ahead with the Process Code Creation) and Active, the next Step is to Create an Entry in the Transaction Code BD51 where we will register the Function Module.
3. Next, we'll have to go to T-Code WE57 where we'll have to make an entry for the Function Module with the IDoc Type & Message Type.
4. Finally, go to WE42 and Create a New Process Code and assign the Function Module and the Message Type.
NOTE 1 : The Process Code is, as we know, Client Dependent. So, once you create a Process Code, we need to have it migrated to the Testing Environment to Start & Carry Out Testing.
NOTE 2: If Step 2 & 3 are missing, then we'll not be able to assign the Function Module in WE42 while Creating Process Code.
Hope it was helpful.
Thanks and Regards,
Venkata Phani Prasad K -
Tax Jurisdiction Code not defined for procedure TAXSE
Hello,
We are facing any issue with the error "Tax Jurisdiction Code not defined for procedure TAXSE"
We are in mid of production bill run and this is getting very critical. Any pointers would be highly appreciated.
The company code country is SE (Sweden)
We have 2 BPs with address in California, US.
The Billing is successful for both the BPs.
While invoicing, one BP is successful.
The other is going in error "Tax Jurisdiction Code not defined for procedure TAXSE".
Error Details
Jurisdiction code not defined for procedure TAXSE
Message no. FF748
Diagnosis
You have entered a jurisdiction code in a country whose calculation procedure
does not allow the entry of jurisdiction codes.
System Response
Procedure
Check and, if necessary, correct the entry.
Procedure for System Administration
If it is not an input error, check and possibly change the system
settings.
To do this, choose Maintain entries (F5).
Change your calculation procedure so that tax calculation is carried out
using the jurisdiction code.
The BP and the CA setup is exact for both the cases.
ThanksHi
Go to the following SPRO config-
SAP Customizing Implementation Guide-->Financial Accounting-->Contract Accounts Receivable and Payable--->Basic Functions--->Contract Accounts--->Field Modifications--->Configure Field Attributes per Activity
Select Change and double-click on field grouping Jurisdiction code.
You will get the following screen.
You have to tick the option Changes plannable and then you will be able to remove jurisdiction code from CAA2
Hope it helps..
Thanks,
Amlan -
BAPI_ACC_INVOICE_RECEIPT_POST for vendor invoice posting
Hi ,
I am using BAPI_ACC_INVOICE_RECEIPT_POST for vendor invoice posting, I have made the header , and account paybale table
, can any body give link for the sample code or give me sample code.continue....
FORM build_bapi_parameters2.
*Build account GL data for BAPI
wa_accountgl-itemno_acc = 2. " Line Item Number
wa_accountgl-gl_account = '0000720300'. " GL Account Number
wa_accountgl-comp_code = '0050'. " Company Code
wa_accountgl-pstng_date = '12012006'. " Posting Date
wa_accountgl-doc_type = 'KQ'. " Document Type
wa_accountgl-fisc_year = '2006'. " Fiscal Year
wa_accountgl-fis_period = '12'. " Fiscal Period
wa_accountgl-item_text = ''. " Item Text
APPEND wa_accountgl TO accountgl.
CLEAR wa_accountgl.
*Build currency data for BAPI
wa_curramount-itemno_acc = 2. " Line Item Number
wa_curramount-curr_type = '00'. " Currency Type
wa_curramount-currency = 'USD'. " Currency Key
wa_curramount-currency_iso = 'USD'. " ISO Code
wa_curramount-amt_doccur = '5000.00'. " Amount
wa_curramount-amt_base = ''. " Base Amount
APPEND wa_curramount TO curramount.
CLEAR wa_curramount.
ENDFORM. " build_bapi_parameters
FORM build_bapi_parameters3.
*Build account GL data for BAPI
wa_accountgl-itemno_acc = 3. " Line Item Number
wa_accountgl-gl_account = '0000256166'. " GL Account Number
wa_accountgl-comp_code = '0050'. " Company Code
wa_accountgl-pstng_date = '12012006'. " Posting Date
wa_accountgl-doc_type = 'KQ'. " Document Type
wa_accountgl-fisc_year = '2006'. " Fiscal Year
wa_accountgl-fis_period = '12'. " Fiscal Period
wa_accountgl-item_text = ''. " Item Text
APPEND wa_accountgl TO accountgl.
CLEAR wa_accountgl.
*Build currency data for BAPI
wa_curramount-itemno_acc = 3. " Line Item Number
wa_curramount-curr_type = '00'. " Currency Type
wa_curramount-currency = 'USD'. " Currency Key
wa_curramount-currency_iso = 'USD'. " ISO Code
wa_curramount-amt_doccur = '-1000.00'. " Amount
wa_curramount-amt_base = ''. " Base Amount
APPEND wa_curramount TO curramount.
CLEAR wa_curramount.
ENDFORM. " build_bapi_parameters
Edited by: krupa jani on Aug 12, 2009 1:45 PM
Maybe you are looking for
-
Error while entering a wage type through TCODE CAT2
Hi Gurus, I was trying to enter a wage type through TCODE CAT2 received and error " Invalid Wage type for this work date" Could you please let me know what would be the reason
-
Help getting Outlook 2007 to sync with proper calendar on Blackberry Curve
Hi I'm new to this forum and have looked for specific answers but not luck as of yet. I'll try to explain what I need to happen fully so it may seem like I'm rambling. I've recently been issued a new computer with Vista and Outlook 2007 for work. Pre
-
Using Bootcamp for Windows XP Installation
Forgive the irony of asking this question on an Apple forum. I'm planning to use Bootcamp to install Windows XP on my MBP. I have a legitimate WinXP SP2 license currently installed on a desktop PC that I plan to decommission. How do I deauthorize the
-
Looking for a good APEX Instructor
My organization is considering an on-site APEX training seminar for our developers. If anyone has had a good experience with a specific trainer or company, I am interested in hearing about it. Thanks, Jack
-
Why can't I buy books with iBooks on my iPad?
I attempt to purchase books with iBooks on my iPad. I can neither purchase the book by clicking on the price nor download a sample. I have no problem purchasing items on iTunes Store and internet connection is fine. This problem has persisted for sev