Auto-generated Swing Code: jbInit()

Hi,
I noticed that the auto-generated code for Swing apps directly uses class member variables, which is far from ideal. For example:
public class Screen {
    private JLabel boardingPassLabel = new JLabel();
    public void jbInit() {
        boardingPassLabel.setText("Boarding Pass");
        boardingPassLabel.setBounds(new Rectangle(170, 25, 115, 20));
        boardingPassLabel.setFont(new Font("Tahoma", 1, 12));
}The issue is that instantiating Screen will cause a JLabel to also be instantiated. While this is fine for a single screen and a single label, if there are hundreds of screens, each with twenty labels and buttons, it quickly gets out of hand.
It would be nice to see the following code auto-generated:
public class Screen {
    private JLabel boardingPassLabel;
    public void jbInit() {
        JLabel boardingPassLabel = getBoardingPassLabel();
        boardingPassLabel.setText("Boarding Pass");
        boardingPassLabel.setBounds(new Rectangle(170, 25, 115, 20));
        boardingPassLabel.setFont(new Font("Tahoma", 1, 12));
    public JLabel getBoardingPassLabel() {
      if( boardingPassLabel == null ) {
        boardingPassLabel = createBoardingPassLabel();
      return boardingPassLabel;
    protected JLabel createBoardingPassLabel() {
      return new JLabel();
}This allows subclasses to provide a different subclass of JLabel (if needed). It also means that there is little overhead to instantiating the Screen class. Thus if we had to instantiate 100 screens, each with 20+ widgets, there would be no performance hit.
As a work-around, we can simply not instantiate the Screen classes until just before they are used. This may not work in our situation, though.
Thoughts?
D

I should probably add a detail here.
We are running the Swing app on the CrEme JVM under Windows CE on a 520 MHz hand-held device with at most 256 MB of memory. (The specs say 520 MHz; but runs slower in practice.) Thus we need a lot more control over object instantiation, as has been described.
It would be nice to see a "use lazy initialization" checkbox for the auto-generated code. Or perhaps a "generate and use accessors" checkbox.
Note that the following code contains a redundancy:
    private JLabel boardingPassLabel = null;The assignemnt to null is superfluous; it adds about 50 more bytes to the final class size (using Sun's javac). It can be omitted for class member variables.
D

Similar Messages

  • Auto generate BP code

    I know this subject has been discussed in here several times and I have searched and tried several of theexamples. Can someone please tell me what is wrong with the following code as I receive error message internal error when I execute the FMS
    SELECT CASE WHEN OCRD.CardType = 'S' THEN 'V' ELSE 'C' END + CAST((MAX(CAST(RIGHT(T0.CardCode, (LEN(T0.CardCode)-1)) AS INT))+1) AS VARCHAR) FROM OCRD T0
    Thanks in advance for any help

    Keith,
    this is probably the solution for your problem from SAP notes :
    In order to create consecutive alphanumeric business partner codes, such as C1000, C1001 etc, please follow the procedure outlined below:
       1. Manually create the first customer, supplier and lead type business partners, e.g. C1000, S5000, L8000.
       2. Go to Reports -> Query Generator -> Click on 'Execute' without making any selection.
       3. In the 'Queries' window click on the pencil icon in the upper left area to activate the query structure area. The area appears grey when blocked, white when ready and yellow when active.
       4. Copy and paste the query from below or the attached text file (BPcode_autocreate.txt) into the window, replacing the 'SELECT *' that is present by default:
    select max(cardtype)
    + cast(substring( max(cardcode), 2, len(max(cardcode)))
    + 1 as nvarchar(10)) from ocrd
    where cardtype = $[OCRD.CARDTYPE]
       1. Click on the button 'Save',then, in the 'Save Query' window, enter an appropriate name for the query and select the appropriate category. Then click on 'Save'.
       2. Click on 'Cancel' in the window 'Queries' and 'Close' in the window 'Query Generator'.
       3. Go to Business Partners -> Business Partner Master Data, change to 'Add' mode.
       4. Map a formatted search to this field by either of the following means:
             1. Clicking in the field 'Code' to activate it, then select 'Tools' in the strip menu, select 'Search Function', then 'Define'.
             2. Pressing CtrlAltF2 in the active field.
       5. In the 'Define Formatted Search' window, click on the button for 'Search by Saved Query'
       6. Bring the cursor to the bar that will pop up just below 'Search by Saved Query' until it changes from an arrow to a pointing hand, then double-click.
       7. The 'Query Manager' window will pop up, select the category where the query above was saved under, then click on the query name to select it, click on 'OK'.
       8. Place a tick in the box for 'Auto Refresh When Field Changes' and select 'BP Name' from the drop down menu.
       9. Click on 'Cancel' in the Business Partner Master Data window and open it up again.
      10. Click on 'Refresh Regularly' and click on 'Save'.
      11. Change to 'Add' mode, select the 'Type' (Customer, Supplier, Lead) and enter a name for the new business partner. Press the 'Tab' key and the next available BP code will automatically be inserted into the BP code field.
    Rgds,

  • Auto generated code in makefile

    For our product we have a TCL script that reads a series of text files and generates C++ classes for easy access to database records. Our code has been in use for make years and works very well. We have always used a solaris command prompt dmake to compile, which first generates the C++ files then complies them. It uses a series of enviroment variables which a user must set before compilation.
    I recently tried to create a Sun Studio Express based on NetBeans 6.5.rc1 project from a make file. This has worked for every other makefile except for this one. The others do not have any auto generated code.
    To run sun studio I in a command prompt source in the environments then run netbeans. Then I choose to build the product but I get an error. I then try to copy the command it is running into telnet window and it works fine. Does anyone have an idea on why in the sun studio I get and error while the telnet window works fine.

    I think the problem is that the SunStudio IDE runs the build command in a wrong directory.
    Can you verify that the working directory is correct?
    (it is in project properties: Build > Make)
    Also you can find this directory in the message in the output, when you try to build the project.
    That's the message, that you copied to the terminal window.
    Thanks,
    Nik

  • How to change Auto-generated web service's URL

    Hi,
    is it possible to change/edit the auto-generated url of a web services created with the wizard in SE80 transaction?
    Example:
    Now the wizard generates a URL as following:
    http://<host name>:8080/sap/bc/srt/wsdl/bndg_4BC67655E5155680E10000000A7B0410/wsdl11/allinone/standard/document?sap-client=001
    where the alfa-numeric code 4BC67655E5155680E10000000A7B0410 changes every time I create the service. at the same time and for the reason above, I have to change the LOGICAL DESTINATION with "visual administrator" application to consume the service in SAP Netweaver environment.
    Thanks in advance.
    Luca

    Hi Luca,
    Please refer the below link . it is described that URLs and its Namespaces  . Please check whether its useful.
    [http://help.sap.com/saphelp_nw70/helpdata/EN/8c/780741375cf16fe10000000a1550b0/frameset.htm] .

  • HOW TO GET AUTO GENERATED PRIMARY ID KEY BACK FROM AN INSERT STATEMENT IN .

    Just recently I ran into a problem with what seems to be a deficiency in the Oracle Database. When trying to return an auto-generated key as is done in Microsoft's SQL database, it seems Oracle for whatever reason didn't add this capability, the key couldn't be passed back to the .Net call. After tinkering with the .Net software and talking with the Oracle techs, a decent work around to the problem (presented here) comes fairly close. Two things have to be done first before this will work. A sequence has to be created on the Oracle DB. Also a trigger has to be created against the table the keys are going to be returned from.
    The class works by passing to the function 'update_datasets_return' a DataSet with as many tables as you want. The function spins through the tables and put the keys in each row inserted. It's assumed the first row will either be the primary key or some numeric value. This can be changed by modifying the: dt.Columns(0).ColumnName
    Notice the word Inserted. On Updates and Deletes the key value is ignored because it's already present. The routine just updates the database as usual.
    So in other words you could send a table to the function with rows inserted, deleted, or updated and it will take care of them all. One routine for all.
    ' ======================================================================
    ' Created by SEF and Oracle SR: 5607364.993 This is a complete Redo
    ' of the initial concept. SEF...
    ' Sample of sequence and trigger at bottom.
    ' Uses the ODP.NET data provider.
    ' update_datasets_return: Goes thru each table in the dataset and
    ' updates, deletes, or inserts as needed.
    ' If inserting, a 'sequence counter' and a 'trigger'
    ' using the 'before insert' must be present. The sequence
    ' counter is set to auto increment by 1 starting at 1.
    ' The trigger is specific to the table.
    ' Create the trigger and sequence in the database or run the samples
    ' below in PL/SQL. Be sure the logon with a user that has enough rights.
    ' Routine assumes the first column is going to hold the sequence
    ' number. Actually any column could be used. Just change the
    ' dt.Columns(0).ColumnName to whatever you want or leave as default.
    ' The da_RowUpdated sub is where the 'sequence number' gets returned
    ' on each row that is inserted into a table. Routine is ignored on
    ' deletes and updates. SEF...
    ' =======================================================================
    Imports System
    Imports System.Data
    Imports Oracle.DataAccess.Client
    Imports Oracle.DataAccess.Types
    Public Class OracleUpdate
    Private Shared m_conn As OracleConnection
    Private Shared da As New OracleDataAdapter
    Private Shared dt As DataTable
    Private Shared conn As New OracleConnection
    Private Shared dr As DataRow
    Private Shared astep As Long
    Private Shared rwIndex As Integer = 0
    Private Shared tblIndex As Integer = 0
    Public Shared Function update_datasets_return(ByVal constr As String, ByVal ds As DataSet) As DataSet ''ByRef ds As DataSet)
    Dim selectstmt As String
    m_conn = New OracleConnection(constr)
    Try
    m_conn.Open()
    Catch ex As Exception
    Throw New ArgumentException(" Error: connection lost." & ex.Message)
    End Try
    For Each dt In ds.Tables
    ''Uncomment the code only if auto numbering
    ''is NOT turned on for the table being updated. SEF...
    ''rwIndex = 0
    ''For Each dr In dt.Rows
    '' Try
    '' Select Case dr.RowState
    '' Case DataRowState.Added
    '' astep += 1
    '' ' =======================================================
    '' ' This "Try Catch" section created only if auto numbering
    '' ' is NOT turned on for the table being updated. SEF...
    '' ' It's a crude attempt at creating a unique number.
    '' ' A more serious approach would be to use a GUID.
    '' ' Use only if you decide not to have a sequence and a
    '' ' trigger for the table.
    '' ' =======================================================
    '' Try
    '' 'ds.Tables(tblIndex).Rows(rwIndex).Item(0) = astep
    '' Catch
    '' ' ignore the error corrected integer identity so don't randomize it
    '' End Try
    '' dr.Item("createdDate") = Now
    '' dr.Item("changedDate") = Now
    '' Case DataRowState.Modified
    '' dr.Item("changedDate") = Now
    '' End Select
    '' Catch ex As Exception
    '' conn.Close()
    '' conn.Dispose()
    '' Throw New ArgumentException(" Error: update_datasets " & ex.Message)
    '' End Try
    '' rwIndex += 1
    ''Next
    selectstmt = "SELECT * From " & dt.TableName & " Where " & dt.Columns(0).ColumnName & " = " & 0
    da = New OracleDataAdapter(selectstmt, m_conn)
    Dim bldr As OracleCommandBuilder = New OracleCommandBuilder(da)
    AddHandler da.RowUpdated, New Oracle.DataAccess.Client.OracleRowUpdatedEventHandler(AddressOf da_RowUpdated)
    Dim insCmd As OracleCommand = Nothing
    Try
    insCmd = CType(bldr.GetInsertCommand(), OracleCommand)
    Catch ex As Exception
    Throw New Exception("")
    End Try
    insCmd.CommandText += " returning " + dt.Columns(0).ColumnName + " into :seqno"
    insCmd.Parameters.Add(New OracleParameter("seqno", OracleDbType.Int16, _
    4, ParameterDirection.Output, False, CType(0, System.Byte), CType(0, _
    System.Byte), dt.Columns(0).ColumnName, DataRowVersion.Current, Nothing))
    da.InsertCommand = insCmd
    Try
    ' ===========================
    da.Update(ds, dt.TableName)
    ' ===========================
    Catch ex As Exception
    Throw New ArgumentException(" Error: update_datasets_return " & ex.Message)
    End Try
    Next
    m_conn.Close()
    m_conn.Dispose()
    Return ds
    End Function
    Friend Shared Sub da_RowUpdated(ByVal sender As Object, ByVal e As OracleRowUpdatedEventArgs)
    If e.StatementType = StatementType.Insert Then
    e.Row(0) = Int64.Parse(e.Command.Parameters("seqno").Value.ToString())
    End If
    End Sub
    ' ================================================================================
    ' Notes:
    ' =================== How To -- Sample section for PL/SQL ==================================
    ' myTrigger, myTable, mySequence, and myColumn are values you need to supply.
    ' Note: A trigger needs to be created for each table.
    ' A sequence needs to be created only once and referenced each time
    ' in the trigger(s). Or you could create a new sequence each time you
    ' create a trigger. Sort of a waste of effort.
    ' Explanation:
    ' myTrigger = The name you are giving this trigger.
    ' If a trigger with same name already
    ' exist, it will be overwritten.
    ' myTable = Table you want to add the sequence numbers to.
    ' mySequence = Sequence counter you created. Whatever name you called it.
    ' myColumn = The column to update with the sequence number.
    ' =================================================================================
    ' -- Run in PL/SQL or create at DB. --
    ' create or replace trigger myTrigger
    ' before insert on myTable for each row
    ' begin
    ' select mySequence.nextval into :new.myColumn from dual ;
    ' end;
    ' -- Run in PL/SQL or create at DB. --
    ' create sequence mySequence
    ' MINVALUE 1
    ' START WITH 1
    ' INCREMENT BY 1
    ' NOCACHE; can be set to CACHE but sequence may contain gaps.
    ' Explanation of CACHE from: http://www.techonthenet.com/oracle/sequences.php
    ' With respect to a sequence, the CACHE option specifies how many sequence
    ' values will be stored in memory for faster access. The downside of creating
    ' a sequence with a CACHE is that if a system failure occurs, all cached
    ' sequence values that have not be used, will be "lost". This results in
    ' a "gap" in the assigned sequence values. When the system comes back up,
    ' Oracle will CACHE new numbers from where it left off in the sequence,
    ' ignoring the so called "lost" sequence values.
    ' Note: To recover the lost sequence values, you can always execute an
    ' ALTER SEQUENCE command to reset the counter to the correct value.
    ' NOCACHE means that none of the sequence values are stored in memory.
    ' This option may sacrifice some performance, however, you should not encounter
    ' a gap in the assigned sequence values.
    End Class
    C#:
    using System;
    using System.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    public class OracleUpdater2
    private static OracleConnection m_conn;
    private static OracleDataAdapter da = new OracleDataAdapter();
    private static OracleConnection conn = new OracleConnection();
    public static DataTable load_it(string constr, string strqry, string tblName)
    // =====================================================================
    // constr = User Id=myUser;Password=myPass";Data Source=myDataSource
    // strqry = Select * from something?
    // tblName = The table name to fill.
    // =====================================================================
    conn = new OracleConnection(constr);
    conn.Open();
    da = new OracleDataAdapter(strqry, conn);
    OracleCommandBuilder bldr = new OracleCommandBuilder(da);
    DataTable dt = new DataTable(tblName);
    da.Fill(dt);
    conn.Dispose();
    return dt;
    public static DataSet update_datasets_return(string constr, DataSet ds)
    //'ByRef ds As DataSet)
    string selectstmt = null;
    m_conn = new OracleConnection(constr);
    try
    m_conn.Open();
    catch (Exception ex)
    throw new ArgumentException(" Error: connection lost." + ex.Message);
    foreach (DataTable dt in ds.Tables)
    selectstmt = "SELECT * From " + dt.TableName + " Where " +
    dt.Columns[0].ColumnName + " = " + 0;
    da = new OracleDataAdapter(selectstmt, m_conn);
    OracleCommandBuilder bldr = new OracleCommandBuilder(da);
    da.RowUpdated += new
    Oracle.DataAccess.Client.OracleRowUpdatedEventHandler(da_RowUpdated);
    OracleCommand insCmd = null;
    try
    insCmd = (OracleCommand)(bldr.GetInsertCommand());
    catch (Exception ex)
    throw new Exception("" + ex.Message);
    insCmd.CommandText += " returning " + dt.Columns[0].ColumnName + " into
    :seqno";
    insCmd.Parameters.Add(new OracleParameter("seqno", OracleDbType.Int16, 4,
    ParameterDirection.Output, false, System.Convert.ToByte(0),
    System.Convert.ToByte(0), dt.Columns[0].ColumnName, DataRowVersion.Current,
    null));
    da.InsertCommand = insCmd;
    try
    // ===========================
    da.Update(ds, dt.TableName);
    // ===========================
    catch (Exception ex)
    throw new ArgumentException(" Error: update_datasets_return " +
    ex.Message);
    m_conn.Close();
    m_conn.Dispose();
    return ds;
    If you need a working program of how this works, let me know.

    Oh my god, it is too long! You definitely check out types, casting and especially ODP.Net (it does everything for you)... etc. They can help you to simplify your code. I do not have enough time to copy paste it to Studio and understand and solve your issue, so I got title of your message as your main question.
    In Oracle, you can create an autonumber field by using sequences object. This is really useful when you need to create a unique number to act as a primary key.
    Basically you can create a sequence simply typing;
    CREATE SEQUENCE MY_SEQUENCE;
    now you have a sequence called "MY_SEQUENCE"... Then, I advice you select a number from sequence;
    select MY_SEQUENCE.nextval from dual;
    I said I advice actually kinda must, although it called sequence, I cannot be sequential. Do not even try to predict the value. You can be sure that it is unique number so you can use it.
    Then insert you record and use that number part of your primary key. I think that's it. Have fun.

  • Update Fund & Fund center data in auto generated PR during MRP RUN

    Problem in the MRP auto generated PRs.
    The normal PRs created manually have all relevant fields of fund center viz CO area ,commitment item,Funds center, fund.
    But the problem is with respect to the Purchase Requisitions generated automatically during the MRP RUN.
    How to include the fund centers in MRP generated PRs automatically in the creation stage itself instead of going into change mode using ME52n Transaction code and change it to include fund centers one by one for each line item.
    We require this as we have hundreds of PRs generated every day.

    Hi,
    In order to fulfill this requirement, transaction FM_MRP_PR should be used.
    Please also take a look to FM_MRP_PR on-line documentation :
    The PRs generated from the MRP run are considered as planning documents
    and do not have any impact on the budget. To encumber these PRs in the
    corresponding settlement receivers, you have to execute this program for
    the relevant PRs.
    Best Regards,
    Arminda Jack

  • Hand made or generated GUI code, what do proffesional use?

    Hello!
    I am currious about what programs people that work as a programmer use? Is it common that they use programs that generats code like Netbeens for instance? I tryed that program in design mode to make a gui, but when I looked at the code it had generated I could not understand it. When I have seen simple example of gui code that has been hand written I have no trouble to understand the code.
    My opinion is that code is something that others than yourself can read and understand. Wich ofcource is not as simple as it sounds :) The reason I could not understand Netbeens generated code can ofcource be that I am a java beginner.
    So, what I am asking is that:
    1. Is it common that proffesional programmers use programs like Netbeens to generate GUI code ?
    2. The problem that others cant read or understand the code, is it more common that the programmer have used generated code or does the problem as easly occur when the code is hand written?
    Regards
    Martin
    Edited by: onslow77 on Nov 4, 2009 8:02 AM

    gimbal2 wrote:
    but I prefer hand made code; that generated crap is unreadable (all imho of course) and I don't understand it eitherSeconded. Code generation not only creates messy, undocumented code, but it also leads to hidden mistakes which are the worst kind. I'd rather spend a little more time writing the stuff by hand and not only having full control over the outcome, but also have full knowledge of its inner workings.Thirded. For my money, if you're building rich GUIs that are anything other than trivial, it's probably worth investing some effort in writing a layer of code to simplify building those GUIs. Working with vast amounts of raw Swing, for example, is a painful experience. For our Swing products, we've got a whole library of controls we built specific to our apps. We also wrote a layer of abstraction over the whole of Swing itself, but that's another story. Another alternative is to use a Rich Client Platform like Eclipse RCP, which provides a lot of common, rich components, and a framework for deploying them in, out of the box. Both the Eclipse and NetBeans IDEs are built upon their own respective RCP packages, which are available for you to use for your own apps. All those nice editors, drag-n-drop views, trees, menus, shortcuts and what-not, all just there for you to use without having to write any tiresome window-resizing code. Lovely. I don't know about IntelliJ, but I wouldn't be surprised if it, too, did so. Spring RCP is another such package.

  • How to strip out leading numbers in auto-generated bookmarks?

    For years now my team has used an Acrobat plug-in called Compose, which lets us strip out the leading numbers from bookmarks in PDFs generated from FrameMaker 7.2. (The tool works after the fact, so that all bookmark creation occurs after the PDF is created.)
    For example, these document headings:
    1.1 Intro to Happy Fun Ball
    1.1.1. System Requirements
    1.1.2. Cautionary Information (WARNING)
    are translated to the bookmarks:
    Intro to Happy Fun Ball
    System Requirements
    Cautionary Information (WARNING)
    After evaluating the new Adobe Tech Comm Suite, it seems that Acrobat 9 Extended Pro isn't compatible with the Compose plug-in (or at least, the version we've been using for years).
    Does anyone know if there's a method -- built into either FrameMaker 8 or Acrobat 9 Pro Extended, or in an SDK -- that allows you to auto-generate bookmarks but strip out leading numbers? It seems this is a no-brainer of a feature, yet I can't find it listed anywhere in the Acrobat documentation.
    Other names for this feature might be "wild card" or "text masking," not to mention "strip leading numbers."
    Thanks very much for your help.
    Regards,
    Buster

    The following code can be run from the JavaScript console, but since you're new to this, it might be easier to create a button, paste the code shown below into the Mouse Up event of the button, select the Hand tool and click the button to execute the code, and then delete the button if everything is OK.
    If you need to do this a lot, you should consider setting up a custom menu item or toolbar button that executes this code:
    function removeBookmarkPrefix(bookmark) {
        // Resursive function to remove bookmark prefix
        // Rename bookmark without prefix
        bookmark.name = bookmark.name.replace(/^\S+\s+/, "");
        if (bookmark.children != null) {
            for (var i = 0; i < bookmark.children.length; i++) {
                removeBookmarkPrefix(bookmark.children[i]);
    // Remove all bookmark prefixes, recursively
    removeBookmarkPrefix(bookmarkRoot);
    The code uses what's called a regular expression, which in this case is fairly simple: /^\S+\s+/
    This regular expression means to search the bookmark name for the beginning of the string (^), followed by one or more non-whitespace characters (\S+), followed by one or more white space characters (\s+), and replace all that with an empty string (""), thus removing it. This should work with the bookmark name prefixes you describe.
    The function is called recursively, which is an efficient way to handle the hierarchical structure that the bookmark tree can have.
    If you get stuck, post again.
    George

  • How to get auto generated column in spring jdbc

    Hi guys ,
    I am using springJDBC and sybase db.
    I think what i am facing is a standard problem but whatever support i am getting from google is not working.
    My problem is :
    "While inserting values in database one colum is autogenerated .....how do i get the value of that column??"
    FYI,
    I have tried using the following code :
    "final String INSERT_SQL = "insert into my_test (name) values(?)";
    final String name = "Rob";
    KeyHolder keyHolder = new GeneratedKeyHolder();
    jdbcTemplate.update(
    new PreparedStatementCreator() {
    public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
    PreparedStatement ps =
    connection.prepareStatement(INSERT_SQL, new String[] {"id"});
    ps.setString(1, name);
    return ps;
    keyHolder);
    // keyHolder.getKey() now contains the generated key"
    but i am getting this error : "java.lang.AbstractMethodError: com.sybase.jdbc2.jdbc.SybConnection.prepareStatement(Ljava/lang/String;I)Ljava/sql/PreparedStatement"
    I think this code works well with Oracle but not with sybase .........does anyone know the solution of this problem .......and by "this problem" i mean how to retrieve auto generate value in spring jdbc ...........without using SimpleJdbcInsert class

    Looking at the previous post it doesn't look like a Spring issue.
    You are using a JDBC driver which does not support getting generated keys so you have 2 choices:
    - Use a different driver that supports generated keys
    - Get the generated key by issuing some vendor specific SQL e.g. 'select @@identity' for SQL server

  • Auto generated selection screen in Modulepool program

    Hi Experts!!
    How to develop/Desing auto-generated screen for accepting values from the user as criteria for database selections while running a report.
    pls. guide me.
    Thanks in advance

    Use this - two FMS-
    here is the code -
    FORM extended_selection.
      DATA : t_dyn    LIKE rsdsfields OCCURS 0 WITH HEADER LINE.
    *Work Areas.
      DATA : wa_range  TYPE LINE OF rsds_trange,
             wa_ranget TYPE rsds_frange_t,
             wa_line   TYPE LINE OF rsds_frange_t,
             t_selopt  TYPE rsds_selopt_t.
    *Fields to be Put on the dynamic selection screen
      t_dyn-tablename = 'KNA1'.
      t_dyn-fieldname = 'KUNNR'.
      APPEND t_dyn.
      CLEAR  t_dyn.
      t_dyn-tablename = 'CEPC'.
      t_dyn-fieldname = 'PRCTR'.
      APPEND t_dyn.
      CLEAR  t_dyn.
      IF ( ( g_sel IS INITIAL ) OR ( t_ranges[] IS INITIAL ) ).
    *Initialize Free Selection Mode.
        CALL FUNCTION 'FREE_SELECTIONS_INIT'
             EXPORTING
                  kind                     = 'F'
             IMPORTING
                  selection_id             = g_sel
             TABLES
                  fields_tab               = t_dyn
             EXCEPTIONS
                  fields_incomplete        = 1
                  fields_no_join           = 2
                  field_not_found          = 3
                  no_tables                = 4
                  table_not_found          = 5
                  expression_not_supported = 6
                  incorrect_expression     = 7
                  illegal_kind             = 8
                  area_not_found           = 9
                  inconsistent_area        = 10
                  kind_f_no_fields_left    = 11
                  kind_f_no_fields         = 12
                  too_many_fields          = 13
                  dup_field                = 14
                  field_no_type            = 15
                  field_ill_type           = 16
                  dup_event_field          = 17
                  node_not_in_ldb          = 18
                  area_no_field            = 19
                  OTHERS                   = 20.
        IF sy-subrc NE 0.
          MESSAGE e717(db).
        ENDIF.
      ENDIF.
    *Dialog for Selection.
      REFRESH t_ranges.
      CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
           EXPORTING
                selection_id    = g_sel
                title           = 'Extended Selection'(s12)
                as_window       = true
                start_row       = 5
                start_col       = 20
                tree_visible    = space
           IMPORTING
                field_ranges    = t_ranges
           TABLES
                fields_tab      = t_dyn
           EXCEPTIONS
                internal_error  = 1
                no_action       = 2
                selid_not_found = 3
                illegal_status  = 4
                OTHERS          = 5.
      IF sy-subrc NE 0.
        CHECK sy-subrc NE 2.
        MESSAGE e717(db).
      ENDIF.
    This will create a dynamic selection screen for you. For more information u can refer to the documentations of those function mdoules.
    Hope it solves ur prob.

  • Can any Java program be able to auto generate objects?

    Like to check if
    Java program is be able to auto generate objects?

    Take example: Point = constructor
    Point p =new Point ();
    so p is tne name of the object. Er... rite??"p" is the name of a variable. This is a refrence to an object (a instances of a class).
    If you are asking what I think you are asking, look at Map. (Collections tutorial)
    Please don't take offence, but I recomend taking a read of
    Resources for Beginners
    Sun's basic Java tutorial
    Sun's New To Java Center. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    http://javaalmanac.com. A couple dozen code examples that supplement The Java Developers Almanac.
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's Thinking in Java (Available online.)
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java. This one has been getting a lot of very positive comments lately.

  • How to Auto generate "order_id"

    I want to Auto generate "order_id" No with sysdate and sequence through pre-insert trigger.
    for example:
    when user commit transaction 1st time today that auto generate this No
    020220101
    when 2nd time commit transcation generate this
    020220102
    3rd time commit transcation generate this
    020220103
    4th time commit transcation generate this
    020220104
    when user will commit transaction tomorrow 1st time generat this
    030220101
    when 2nd time commit transcation generate this
    030220102
    3rd time commit transcation generate this
    030220103
    4th time commit transcation generate this
    030220104
    anyone can help me.

    Hi,
    Try the following code.
    SELECT TO_CHAR(SYSDAYE, 'DDMMRRRR') || NVL(MAX(TO_NUMBER(SUBSTR(ORDER_ID, 9))), 0) + 1 INTO :<block_name>.<field_name> FROM <table_name> WHERE SUBSTR(ORDER_ID, 1, 8) = TO_CHAR(SYSDAYE, 'DDMMRRRR');Regards,
    Manu.
    If my response or the response of another was helpful, please mark it accordingly

  • How to auto generate a sequence.

    Dear all
    The entity Object "OrderEntryEO" has an attribute called"OrdNumber" that indicates the reference number of the order number. the order number is compose be a sequence on the year. For example 1/2011 , 2/2011 , 3/2011 and so on..
    this sequence must be auto generated when pressing save button.
    I have generated the entityImpl java class "OrderEntryEOImpl.java . with accessors , DO_DML method and create method.
    these are the methods
    {code}
    protected void create(AttributeList attributeList) {
    super.create(attributeList);
    {code}
    {code}
    protected void doDML(int operation, TransactionEvent e) {
    super.doDML(operation, e);
    {code}
    Can any one please help me how to Implement this in java code
    Regards

    I wanted to clear up what I consider to be some misinformation on this thread.
    Database sequences, regardless of what magic you try (including setting the cache size to 1) can and will, by their very design have gaps. I don't care if you are doing a web app, a client server app, an SOA app, or any other newfangled or old-fashioned, red screens, green screens, blue screens - DATABASE SEQUENCES IN ORACLE CAN AND WILL HAVE GAPS.
    There is only one way to ensure gap-free sequence numbers upon insert:
    * You must lock the table or use some other device to serialise inserts.
    Any other technique you want to use will not work in a multi-user environment. I'm not going to go through the proof of it here because it's been discussed ad-infinitum (search on asktom.oracle.com if you want to see all of the crazy failed attempts to do it without serialisation). You can also read on asktom about some other techniques (such as assigning the numbers after the fact) that you could consider.
    Bottom line to remember however, Oracle Database Sequences are not and cannot be gap free (at least as of today, the 4th of April, 2011 AD at 08:48 GMT +1)
    John

  • Auto-Generate mail for database performace reporting.

    Hello,
    i have many server to keep an eye on for maintenance but, now the number for it is growing day by day. Its difficult for me to keep a watch on each in detail. So I have an idea to implement.
    I want to make a script which will auto generate a mail from the server & send it to my email id with all the details of database. Basically performance related details.+
    Is it possible to do so ???? I know how to send a mail with attachment, the code i will use is given below.+
    please suggest me how can i attach my performance tuning queries  output & get those things in my mail on a daily basis......
    thanks in advance .....
    DECLARE
    v_From VARCHAR2(80) := '[email protected]';
    v_Recipient VARCHAR2(80) := '[email protected]';
    v_Subject VARCHAR2(80) := 'test subject';
    v_Mail_Host VARCHAR2(30) := 'mail.mycompany.com';
    v_Mail_Conn utl_smtp.Connection;
    crlf VARCHAR2(2) := chr(13)||chr(10);
    BEGIN
    v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host, 25);
    utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
    utl_smtp.Mail(v_Mail_Conn, v_From);
    utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);
    utl_smtp.Data(v_Mail_Conn,
    'Date: ' || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
    'From: ' || v_From || crlf ||
    'Subject: '|| v_Subject || crlf ||
    'To: ' || v_Recipient || crlf ||
    'MIME-Version: 1.0'|| crlf ||     -- Use MIME mail standard
    'Content-Type: multipart/mixed;'|| crlf ||
    ' boundary="-----SECBOUND"'|| crlf ||
    crlf ||
    '-------SECBOUND'|| crlf ||
    'Content-Type: text/plain;'|| crlf ||
    'Content-Transfer_Encoding: 7bit'|| crlf ||
    crlf ||
    'some message text'|| crlf ||     -- Message body
    'more message text'|| crlf ||
    crlf ||
    '-------SECBOUND'|| crlf ||
    'Content-Type: text/plain;'|| crlf ||
    ' name="excel.csv"'|| crlf ||
    'Content-Transfer_Encoding: 8bit'|| crlf ||
    'Content-Disposition: attachment;'|| crlf ||
    ' filename="excel.csv"'|| crlf ||
    crlf ||
    'CSV,file,attachement'|| crlf ||     -- Content of attachment
    crlf ||
    '-------SECBOUND--'               -- End MIME mail
    utl_smtp.Quit(v_mail_conn);
    EXCEPTION
    WHEN utl_smtp.Transient_Error OR utl_smtp.Permanent_Error then
    raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
    END;
    /

    I like your script idea.
    You can spool output to a file and mail the file to yourself.
    What OS are you running?
    On linux a simple starter script would look like this:
    #!/bin/bash
    echo `date`
    # Set the Environmental variable for TESTDB instance
    . /u01/app/oracle/dba_tool/env/TESTDB.env
    $ORACLE_HOME/bin/sqlplus -s system/<PASSWORD> <<EOF
    @/u01/app/oracle/dba_tool/TESTDB/quickaudit
    EOF
    echo `date`
    mailx -s "Check database on TESTDB" [email protected] < /tmp/quickaudit.lst
    ----------------------sample ENV file--------------------------------------
    ORACLE_BASE=/u01/app/oracle
    ULIMIT=unlimited
    ORACLE_SID=TESTDB
    export ORACLE_TERM=xterm
    ORACLE_HOME=$ORACLE_BASE/product/11.2.0
    ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
    LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
    LIBPATH=$LD_LIBRARY_PATH:/usr/lib
    TNS_ADMIN=$ORACLE_HOME/network/admin
    PATH=$ORACLE_HOME/bin:$ORACLE_BASE/dba_tool/bin:/bin:/usr/bin:/usr/ccs/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:/usr/lbin:/GNU/bin/make:/u01/app/oracle/dba_tool/bin:/home/oracle/utils/SCRIPTS:/usr/local/bin:
    export ORACLE_BASE ORACLE_SID ORACLE_TERM ULIMIT
    export ORACLE_HOME
    export LIBPATH LD_LIBRARY_PATH ORA_NLS33
    export TNS_ADMIN
    export PATH
    --------------------Starter reporting script--------------------------------------------------
    SET ECHO OFF
    SET TERMOUT OFF
    REM Revisions:
    REM Date ID Version Description
    REM -------- -- ------- ----------------------------------------------------|
    REM 10/07/05 1.0 Script to check for database issues
    SPOOL /tmp/quickaudit.lst
    SELECT SYSDATE FROM DUAL;
    SHOW USER
    SET TERMOUT ON
    SET VERIFY OFF
    SET FEEDBACK ON
    PROMPT
    PROMPT Checking database name and archive mode
    PROMPT
    column NAME format A9
    column LOG_MODE format A12
    SELECT NAME,CREATED, LOG_MODE FROM V$DATABASE;
    PROMPT
    PROMPT ------------------------------------------------------------------------|
    PROMPT
    PROMPT
    PROMPT Checking database versions
    PROMPT
    column BANNER format A64
    select * from v$version;
    PROMPT
    PROMPT ------------------------------------------------------------------------|
    PROMPT
    PROMPT
    PROMPT Checking control file(s)
    PROMPT
    column STATUS format a7
    column NAME format a68
    column IS_RECOVERY_DEST_FILE format a3
    set linesize 110
    SELECT * FROM V$CONTROLFILE;
    PROMPT
    PROMPT ------------------------------------------------------------------------|
    PROMPT
    PROMPT
    PROMPT Checking redo logs and group(s)
    PROMPT
    column member format a70
    set linesize 110
    set pagesize 30
    SELECT group#, member FROM v$logfile;
    PROMPT
    PROMPT -----------------------------------------------------------------------|
    PROMPT
    PROMPT
    PROMPT ------------------------------------------------------------------------|
    PROMPT
    PROMPT
    PROMPT Checking freespace by tablespace
    PROMPT
    column dummy noprint
    column pct_used format 999.9 heading "%|Used"
    column name format a16 heading "Tablespace Name"
    column bytes format 9,999,999,999,999 heading "Total Bytes"
    column used format 99,999,999,999 heading "Used"
    column free format 999,999,999,999 heading "Free"
    break on report
    compute sum of bytes on report
    compute sum of free on report
    compute sum of used on report
    set termout off
    set pagesize 40
    select a.tablespace_name name,
    b.tablespace_name dummy,
    sum(b.bytes)/count( distinct a.file_id||'.'||a.block_id ) bytes,
    sum(b.bytes)/count( distinct a.file_id||'.'||a.block_id ) -
    sum(a.bytes)/count( distinct b.file_id ) used,
    sum(a.bytes)/count( distinct b.file_id ) free,
    100 * ( (sum(b.bytes)/count( distinct a.file_id||'.'||a.block_id )) -
    (sum(a.bytes)/count( distinct b.file_id ) )) /
    (sum(b.bytes)/count( distinct a.file_id||'.'||a.block_id )) pct_used
    from sys.dba_free_space a, sys.dba_data_files b
    where a.tablespace_name = b.tablespace_name
    group by a.tablespace_name, b.tablespace_name;
    PROMPT
    PROMPT ------------------------------------------------------------------------|
    PROMPT
    PROMPT
    PROMPT Checking for invalid objects
    PROMPT

  • CF 9.0.2 and Oracle - On update returns error "Auto-generated keys were not requested..."

    We have a simple update statement to Oracle 11g Database. When running the statement the data is not getting updated and we are getting an error "Auto-generated keys were not requested, or the SQL was not a simple INSERT statement. ErrorCode=0 SQLState=HY000". We found this error by dumping the SQL to a file.
    But most other Update statements are working fine.
    Also, the same statment works for Oracle 10g and Coldfusion 9.0.0.
    Any idea if this is a problem with Coldfusion or Oracle? Is there any resolution.
    I found the CF 8 had a similar issue and was fixed in a hotfix (http://helpx.adobe.com/coldfusion/kb/error-auto-generated-keys-requested.html).

    Hi,
    Thanks. I compiled my code using JDeveloper 10.1.2, didn't dare to use the latest. It works in 10g apps server. When I deployed to 9ias apps server, those weird errors showed up. Unfornately, our dev environment is at a newer version than the production one.
    So, you think the error is generated because I referenced some newer technologies that was not provided by 9ias?
    Jia

Maybe you are looking for