How to do something before exit?
hi all
i'm writing a simple db application
i want it to execute the last update on a db table before exit
the code is:
private void exitForm(java.awt.event.WindowEvent evt) {
try
Statement st=tmc.createStatement();
st.executeUpdate("UPDATE OPERATORI SET LOGGATO=FALSE WHERE OPERATORE='"+user+"'");
System.out.println("i'm exiting");
System.exit(0);
catch(SQLException s)
s.printStackTrace();
}when i got the output message "i'm exiting" i thinked that the db was modified, but checking it i saw that nothing changed
i tried the same code without the "System.exit(0);" line in a actionPerformed method of a temporary button that i putted on my form and it worked
so i think that the System.exit(0) call in a certain way arrives before or interrupts the db transition
i want to hide to my users this action, that's the reason for which i wrote my code in such a way!
any hint?
thanx in advance
sandro
Hi Sandro,
I am using databases and i have never had this problem.
But before closing the application, I always close the connections with database.
Why dont you try
private void exitForm(java.awt.event.WindowEvent evt) {
try
Statement st=tmc.createStatement();
st.executeUpdate("UPDATE OPERATORI SET LOGGATO=FALSE WHERE OPERATORE='"+user+"'");
System.out.println("i'm exiting");
tmc.close(); //close the connection
System.exit(0);
catch(SQLException s)
s.printStackTrace();
I hope it works well for you
sergio
Similar Messages
-
How to do something before the interface is seen?
I want to use Lingo to do something before everything is seen (before the first frame, and before the exe interface appears). But I don't know how to realize.
For example, I want to run the code:
alert("test begin!")
before everything is seen. I have tried to write the statement in startMovie(), prepareMovie(), prepareFrame(), and beginSprite(), and all failed. In all case, the alert message is popped after the interface appears.
How to do? Thanks!It depends on exactly what you want to do. In some cases you might have to set your movie to open with a stage size of 1 x 1, or completely off screen, before you do what you want and resize/move it. In other situations the lingo.ini file can be used to execute the #startup handler. However, you should only rely on this handler to set global variables - some objects, like cast members, sprites, etc. aren't available. Refer to the existing lingo.ini file in your Director\Configuration\ folder
-
How to do something before the user session expires
Hi,
I need to do some extra cleanup (delete some rows from database, etc) before the session of a user expires.
I tried to do it with Phase Listeners, but haven't figured out how to put it on the session, I guess I need a kind of Listener.Can implement ServletContextListener to fire off events on context destroy.
example.
public class LifeCycleServletContextListener
implements ServletContextListener {
public LifeCycleServletContextListener() {
public void contextInitialized(
ServletContextEvent sce) {
System.out.println(
"LifeCycleServletContextListener:
contextInitialized");
public void contextDestroyed(
ServletContextEvent sce) {
System.out.println(
"LifeCycleServletContextListener:
contextDestroyed");
} -
Every time I open iPhoto the dialogue box requiring me to do something before I can use iPhoto, how do I get rid of it?
Click on the More Info button and ignore the web page, go to iPhoto's Accounts preference pane and delete the MobileMe account. Next to go the System/MobileMe preference pane and log out of MMe. That will stop those messages.
OT -
How can I find out how many gb something will be before I download it?
On the new software update I'm not able to see how many gb something is before downloading it
Tom,
I appreciate your help. Does the Apple I-Book App have the ability to install e-books from other sources such as Kindle, Nook, Kobo, Googlebooks, and Sony? If I can read the other sources products on the apple i-book platform that would be just as good.
Thanks in Advance. -
How to detect window close event and do some task before exiting
Hi
Anyone knows how to detect window close event and do some task before exiting ?
Sridhar
Solved!
Go to Solution.
Attachments:
window close event.JPG 34 KBYes .You can discard the panel close event by passing "TRUE" boolean value to the "discard ?" terminal which is lied in the right side of that panel close(filter) event.& It will work in executables. See attached picture.
Attachments:
Panel Close.JPG 12 KB -
How to find the user exits and BADIS from SPRO
Hi all,
please let us know how to find the User exits or BADIS for an application from SPRO.
Regards,
MadhaviHi Varisetty,
Finding user exits and BAdis from SPRO can be cumbsersome. In most instances you know the standard SAP program and want to check (find) an exit called in the flow of the transaction. You can do this as follows:
For User Exit:
Put "/h" in the command box (to start debugging)
Execute your transaction
When you enter debugging - put a breakpoint at statement
CALL CUSTOMER-FUNCTION
the control will stop at all calls to User Exits
For BAdi (it's simpler)
Go to class CL_EXITHANDLER in SE24
Enter method GET_INSTANCE
Put a breakpoint in this method
Run your standard transaction - control will stop at all BAdis called within the flow since this method is used to check BAdi implementations before invoking them
Also, if you want to find enhancements by package - go to SE80, enter the package and check function groups starting with X - those contain function exits (conventional user exits). For BAdis in a package, there is normally a separate tree node (under the package) for Enhancements hence clearly identifiable.
Cheers,
Adi -
How to use a customer exit in WebI
Hi expert,
I read from official SAP document that customer exit variable are supported within WebI query.
I created an universe based on a query bex. In this query I use a variable exit for 0calmonth2.
Within the WebI universe I don't see any variable.
How can I use/build a customer exit variable in my WebI query?
System feature: BO 3.1
Many Thanks.
ClaudiaHi,
I havethe same issue, even though I place the user exit variable in Filter section, its not working as expected in WEBI/crystal.
the variable that i have created will assign default value as sysdate.its working fine BW.
Are there any extra settings at BEX/BW level which have to be set before using user/sap exit variables in webi/crystal?
How should the user/customer exit variables be defined in order to get them carried properly to webi or crystal, I mean what should be the properties set for these variables? -
I just bought a new iMac and I am new to the Desktop Mac. I read you can get a free upgrade to Mountain Lion if you bought your computer after June 11, 2012. Do I have to do something before Mountain Lion is released? If so What? Thanks
Just check in with this link when ML is released for instructions on how to claim your upgrade.
http://www.apple.com/osx/uptodate/ -
Do something before the PDF be openned
I wanna do something before the PDF be openned.
Can I complete it? How?Are you using the standard PDF methods for encryption? If so, then you want
to write a custom security handler and that handles encryption, decryption
and rights management.
If you are using your own encryption format - so that the PDF is no longer a
real PDF - then you want the AVConversion APIs. However, that won't help
you with the rights management. You will need to do a lot of overriding and
hooking in order to catch those. -
HOW TO CREATE A USER-EXIT FOR MB31 GOODS RECEIPT
Hy,
<b>HOW TO CREATE A USER-EXIT FOR MB31</b>
TO COMPARE ORDER QTY CONFIRMED AND GOODS RECEIPT QTY
( IF GR QTY GREATER THAN CONFIRMED QTY ERROR MESSAGE SHOULD COME AND NOT ALLOW TRANSCATION TO PROCEED).
POINTS CONFIRMED.
REGARDS,
KARTIKEY.Hi Rawat,
You Don't need to create User Exits,but you need to find user Exits.Below are list of user Exits for MB31.
Use proper exit as per your requirement.
Exit Name Description
MBCF0002 Customer function exit: Segment text in material doc. item
MBCF0005 Material document item for goods receipt/issue slip
MBCF0006 Customer function for WBS element
MBCF0007 Customer function exit: Updating a reservation
MBCF0009 Filling the storage location field
MBCF0010 Customer exit: Create reservation BAPI_RESERVATION_CREATE1
MBCF0011 Read from RESB and RKPF for print list in MB26
MB_CF001 Customer Function Exit in the Case of Updating a Mat. Doc.
award points if ans is useful.
Regards,
Albert -
Hi All,
How to find out User Exit in particular program.
I mean if you have one profile, how to find is there any user exits in that program.
Appreciate if any body tel answer.
Thanks & Regards,
SubbuYou could try searching the main program for "userexit_"
This would give you a list of all the available user exits within the application.
For Customer exits, you could search SMOD with a short description ex: order in the F4 help. Another way is to search for CUSTOMER-FUNCTION in the main program. You can then navigate to the enhancement in the customer function and use the Z Program in the enhancement.
http://www.easymarketplace.de/userexit.php - has a complete list.
More specifically, in case you're looking for SD exits - http://help.sap.com/saphelp_46c/helpdata/en/1c/f62c7dd435d1118b3f0060b03ca329/content.htm. -
How to find out user exits of t-code va03
hi all
how to find out user exits of any t-code .
regards
deepakHi Deepak,
<b>Try this code.</b>
*& Report Z_USEREXIT *
REPORT Z_USEREXIT
NO STANDARD PAGE HEADING.
*& Enter the transaction code that you want to search through in order
*& to find which Standard SAP User Exits exists.
*& Tables
TABLES : tstc, "SAP Transaction Codes
tadir, "Directory of Repository Objects
modsapt, "SAP Enhancements - Short Texts
modact, "Modifications
trdir, "System table TRDIR
tfdir, "Function Module
enlfdir, "Additional Attributes for Function Modules
tstct. "Transaction Code Texts
*& Variables
DATA : jtab LIKE tadir OCCURS 0 WITH HEADER LINE.
DATA : field1(30).
DATA : v_devclass LIKE tadir-devclass.
*& Selection Screen Parameters
SELECTION-SCREEN BEGIN OF BLOCK a01 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
PARAMETERS : p_tcode LIKE tstc-tcode OBLIGATORY.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK a01.
*& Start of main program
START-OF-SELECTION.
Validate Transaction Code
SELECT SINGLE * FROM tstc
WHERE tcode EQ p_tcode.
Find Repository Objects for transaction code
IF sy-subrc EQ 0.
SELECT SINGLE * FROM tadir
WHERE pgmid = 'R3TR'
AND object = 'PROG'
AND obj_name = tstc-pgmna.
MOVE : tadir-devclass TO v_devclass.
IF sy-subrc NE 0.
SELECT SINGLE * FROM trdir
WHERE name = tstc-pgmna.
IF trdir-subc EQ 'F'.
SELECT SINGLE * FROM tfdir
WHERE pname = tstc-pgmna.
SELECT SINGLE * FROM enlfdir
WHERE funcname = tfdir-funcname.
SELECT SINGLE * FROM tadir
WHERE pgmid = 'R3TR'
AND object = 'FUGR'
AND obj_name = enlfdir-area.
MOVE : tadir-devclass TO v_devclass.
ENDIF.
ENDIF.
Find SAP Modifactions
SELECT * FROM tadir
INTO TABLE jtab
WHERE pgmid = 'R3TR'
AND object = 'SMOD'
AND devclass = v_devclass.
SELECT SINGLE * FROM tstct
WHERE sprsl EQ sy-langu
AND tcode EQ p_tcode.
FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
WRITE:/(19) 'Transaction Code - ',
20(20) p_tcode,
45(50) tstct-ttext.
SKIP.
IF NOT jtab[] IS INITIAL.
WRITE:/(95) sy-uline.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
WRITE:/1 sy-vline,
2 'Exit Name',
21 sy-vline ,
22 'Description',
95 sy-vline.
WRITE:/(95) sy-uline.
LOOP AT jtab.
SELECT SINGLE * FROM modsapt
WHERE sprsl = sy-langu AND
name = jtab-obj_name.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
WRITE:/1 sy-vline,
2 jtab-obj_name HOTSPOT ON,
21 sy-vline ,
22 modsapt-modtext,
95 sy-vline.
ENDLOOP.
WRITE:/(95) sy-uline.
DESCRIBE TABLE jtab.
SKIP.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
WRITE:/ 'No of Exits:' , sy-tfill.
ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(95) 'No User Exit exists'.
ENDIF.
ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(95) 'Transaction Code Does Not Exist'.
ENDIF.
Take the user to SMOD for the Exit that was selected.
AT LINE-SELECTION.
GET CURSOR FIELD field1.
CHECK field1(4) EQ 'JTAB'.
SET PARAMETER ID 'MON' FIELD sy-lisel+1(10).
CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.
<b>plz reward points if helpful or if it solves ur query.</b>
Thanks
Chinmay -
How to find the user exit for a screen..
Hi,
plz help me how to find the user exit for a screen..?
Regards
AnbuHi,
check this program this will give you the list of user-exit and BADI for the perticular Tcode.
REPORT zuserexit_badi.
TABLES : tstc,
tadir,
modsapt,
modact,
trdir,
tfdir,
enlfdir,
sxs_attrt ,
tstct.
DATA : jtab LIKE tadir OCCURS 0 WITH HEADER LINE.
DATA : field1(30).
DATA : v_devclass LIKE tadir-devclass.
PARAMETERS : p_tcode LIKE tstc-tcode,
p_pgmna LIKE tstc-pgmna .
DATA wa_tadir TYPE tadir.
START-OF-SELECTION.
IF NOT p_tcode IS INITIAL.
SELECT SINGLE * FROM tstc WHERE tcode EQ p_tcode.
ELSEIF NOT p_pgmna IS INITIAL.
tstc-pgmna = p_pgmna.
ENDIF.
IF sy-subrc EQ 0.
SELECT SINGLE * FROM tadir
WHERE pgmid = 'R3TR'
AND object = 'PROG'
AND obj_name = tstc-pgmna.
MOVE : tadir-devclass TO v_devclass.
IF sy-subrc NE 0.
SELECT SINGLE * FROM trdir
WHERE name = tstc-pgmna.
IF trdir-subc EQ 'F'.
SELECT SINGLE * FROM tfdir
WHERE pname = tstc-pgmna.
SELECT SINGLE * FROM enlfdir
WHERE funcname = tfdir-funcname.
SELECT SINGLE * FROM tadir
WHERE pgmid = 'R3TR'
AND object = 'FUGR'
AND obj_name EQ enlfdir-area.
MOVE : tadir-devclass TO v_devclass.
ENDIF.
ENDIF.
SELECT * FROM tadir INTO TABLE jtab
WHERE pgmid = 'R3TR'
AND object IN ('SMOD', 'SXSD')
AND devclass = v_devclass.
SELECT SINGLE * FROM tstct
WHERE sprsl EQ sy-langu
AND tcode EQ p_tcode.
FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
WRITE:/(19) 'Transaction Code - ',
20(20) p_tcode,
45(50) tstct-ttext.
SKIP.
IF NOT jtab[] IS INITIAL.
WRITE:/(105) sy-uline.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
Sorting the internal Table
SORT jtab BY object.
DATA : wf_txt(60) TYPE c,
wf_smod TYPE i ,
wf_badi TYPE i ,
wf_object2(30) TYPE c.
CLEAR : wf_smod, wf_badi , wf_object2.
Get the total SMOD.
LOOP AT jtab INTO wa_tadir.
AT FIRST.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
WRITE:/1 sy-vline,
2 'Enhancement/ Business Add-in',
41 sy-vline ,
42 'Description',
105 sy-vline.
WRITE:/(105) sy-uline.
ENDAT.
CLEAR wf_txt.
AT NEW object.
IF wa_tadir-object = 'SMOD'.
wf_object2 = 'Enhancement' .
ELSEIF wa_tadir-object = 'SXSD'.
wf_object2 = ' Business Add-in'.
ENDIF.
FORMAT COLOR COL_GROUP INTENSIFIED ON.
WRITE:/1 sy-vline,
2 wf_object2,
105 sy-vline.
ENDAT.
CASE wa_tadir-object.
WHEN 'SMOD'.
wf_smod = wf_smod + 1.
SELECT SINGLE modtext INTO wf_txt
FROM modsapt
WHERE sprsl = sy-langu
AND name = wa_tadir-obj_name.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
WHEN 'SXSD'.
For BADis
wf_badi = wf_badi + 1 .
SELECT SINGLE text INTO wf_txt
FROM sxs_attrt
WHERE sprsl = sy-langu
AND exit_name = wa_tadir-obj_name.
FORMAT COLOR COL_NORMAL INTENSIFIED ON.
ENDCASE.
WRITE:/1 sy-vline,
2 wa_tadir-obj_name HOTSPOT ON,
41 sy-vline ,
42 wf_txt,
105 sy-vline.
AT END OF object.
WRITE : /(105) sy-uline.
ENDAT.
ENDLOOP.
WRITE:/(105) sy-uline.
SKIP.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
WRITE:/ 'No.of Exits:' , wf_smod.
WRITE:/ 'No.of BADis:' , wf_badi.
ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(105) 'No userexits or BADis exist'.
ENDIF.
ELSE.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE:/(105) 'Transaction does not exist'.
ENDIF.
AT LINE-SELECTION.
DATA : wf_object TYPE tadir-object.
CLEAR wf_object.
GET CURSOR FIELD field1.
CHECK field1(8) EQ 'WA_TADIR'.
READ TABLE jtab WITH KEY obj_name = sy-lisel+1(20).
MOVE jtab-object TO wf_object.
CASE wf_object.
WHEN 'SMOD'.
SET PARAMETER ID 'MON' FIELD sy-lisel+1(10).
CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.
WHEN 'SXSD'.
SET PARAMETER ID 'EXN' FIELD sy-lisel+1(20).
CALL TRANSACTION 'SE18' AND SKIP FIRST SCREEN.
ENDCASE.
Reagards,
Bharat. -
How to find the user exit for infotype 2013 ?
Hi All,
How to find the user exit in infotype 2013? i want to change the drop down list default value in infotype 2013.
Thanks,
Srikanth Preward points if useful
User exit name is PBAS0001.
code should be written in ZXPADU01 for PBO
ZXPADU02 for PAI.
Maybe you are looking for
-
Dynamic filename for stdout from cron
OL 5.6 x86-64 I'm looking for a way to dynamicly specify a filename for stdout from a cron job. From a command line, this works fine: /home/estevens/bin/x1 > /tmp/estevens_x1_log.`date +%F_%H%M%S`Producing the desired output: estevens:dwdev$ ls -ltr
-
Report Layout Problems - point over a letter - subscript words
Hi, is there a possibility to get a point over a letter in the report mode? i need that as a description for a heat flow Q. but it didn't found a way to get that point over the Q. is there an easy way to get that? another problem is that i need to su
-
Winforms app keeps asking for config
I have multiple apps that keep asking me for an XML config file. These are existing apps that I loaded from TFS. There is an app.config file in the solution. Thoughts? *** Please allow me to mark threads as answered and I will, Thank you ***
-
I was given a GB project which I'd like to do further work on in Pro Tools. The GB project contains both custom-recorded audio, factory Apple Loops, and software instruments. Is there an easy way to transfer it over? Basically, I'd like an audio boun
-
Custom error handler examples and/or instruction
I'm finishing up an application and would like to customize some of the error reporting. I've started playing around with the custom error handler VI's with some success. I would, however, like to see some examples from people who know what they are