Re-Using Objects

Could someone explain if re-using the same object to create multiple instances of the object (say a JTextField) is better than defining a whole new object for each instance.JTextField tf;
public void createFields() {
  tf = new JTextField(20);
  tf.setBackground(Color.green);
  JPanel p = new JPanel();
   p.add(tf);
  tf = new JTextField(20);
  tf.setBackground(Color.red);
  p.add(tf);
  contentPane.add(p, BorderLayout.CENTER ); // Just for explanation purposes.
} Is this a better way to do things. as against JTextField tf, tf2;
public void createFields() {
  tf = new JTextField(20);
  tf.setBackground(Color.green);
  JPanel p = new JPanel();
   p.add(tf);
  tf2 = new JTextField(20);
  tf2.setBackground(Color.red);
  p.add(tf2);
  contentPane.add(p, BorderLayout.CENTER ); // Just for explanation purposes.
} I ask because,
1. how will you be able to identify a particular field when you need to get some piece of information?
2. Is this is a better way to utilize system resources?
ICE

By the way I have another question.
Imports
It is advisable to be importing whole packages instead
of specific classes. I ask because I tend to do
this.import javax.swing.border.*;when in the whole class I might just use the
LineBorder or EmptyBorder. Does this also have some
effect on performance in terms of initial start up of
my application.?
ICENo, java only includes those classes which are necessary, doesn't make any difference in application. May be importing whole packages might slow down the compile time, nothing more than that.

Similar Messages

  • How to display horizontal line in top-of-page by using object oriented ALV?

    How to display horizontal line in top-of-page by using object oriented ALV.
    I am created top-of-page in object oriented alv.
    But not be successes in showing horizontal line in it.
    Can any one pls give solution for this..
    Thanks and regards..

    Hi
    Try like this
    data: gt_list_top_of_page type slis_t_listheader. " Top of page text. 
    Initialization. 
    perform comment_build using gt_list_top_of_page[]. 
    form top_of_page. 
    * Note to self: the gif must be loaded into transaction OAOR with 
    * classname 'PICTURES' AND TYPE 'OT' to work with ALV GRID Functions. 
    * I Loaded NOVALOGO2 into system. 
    call function 'REUSE_ALV_COMMENTARY_WRITE' 
         exporting 
    * I_LOGO = 'NOVALOGO2' 
    * i_logo = 'ENJOYSAP_LOGO' 
             it_list_commentary = gt_list_top_of_page. 
    endform. " TOP_OF_PAGE 
    form comment_build using e04_lt_top_of_page type slis_t_listheader. 
    data: ls_line type slis_listheader. 
          clear ls_line. 
          ls_line-typ = 'A'. 
          ls_line-info = 'Special'(001). 
          fgrant = xgrant. 
          concatenate ls_line-info fgrant 
          'Stock Option Report to the board'(002) 
                 into ls_line-info separated by space. 
                        condense ls_line-info. 
          append ls_line to e04_lt_top_of_page. 
    endform. " COMMENT_BUILD
    Use following syntex for footer print in alv:
    * For End of Page
    form END_OF_PAGE.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      write: sy-uline(50).
      skip.
      write:/40 'Page:', sy-pagno .
    endform.
    *  For End of Report
    form END_OF_LIST.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      skip.
      write:/40 'Page:', sy-pagno .
    endform.
    check this link
    http://abapprogramming.blogspot.com/
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5dc3e690-0201-0010-1ebf-b85b3bed962d
    Changing width of a custom container dynamically
    Display Page numbers in ALV
    Insert picture in selection screen.
    Logo in OO ALV Grid
    Reward all helpfull answers
    Regards
    Pavan

  • Creation of Disctribution Model view using Distribution using object classe

    Hi All ,
             Can anybody tell me how to create distribution model through  Distribution using object classes option in SALE transaction(Path : SALE - > Modelling and implementing Business processes - > master data Distribution - > Distribution using object classes).What is the difference between normal distribution model creation through BD64 and creating in the above way?
    Please help me its urgent.Thanks in advance.
    Regards,
    Rakesh.

    Hi All ,
             Can anybody tell me how to create distribution model through  Distribution using object classes option in SALE transaction(Path : SALE - > Modelling and implementing Business processes - > master data Distribution - > Distribution using object classes).What is the difference between normal distribution model creation through BD64 and creating in the above way?
    Please help me its urgent.Thanks in advance.
    Regards,
    Rakesh.

  • Sum in ALV grid display using objects

    Hi Experts,
    I have created a Report with ALV using objects and also am able to get SUM for some fields using do_sum = 'X'.
    My problem is i want to do some calculation using the total amount which i have got, how can i do that (or can it be done??).
    Thanks in Advance...
    Santosh

    Hi this may be of some help.
    ABAP List Viewer
    The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).
    This helps us to implement all the features mentioned very effectively.
    Using ALV, We can have three types of reports:
    1. Simple Report
    2. Block Report
    3. Hierarchical Sequential Report
    There are some function modules which will enable to produce the above reports without much effort.
    All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
    1. SIMPLE REPORT.
    The important function modules are
    a. Reuse_alv_list_display
    b. Reuse_alv_fieldcatalog_merge
    c. Reuse_alv_events_get
    d. Reuse_alv_commentary_write
    e. Reuse_alv_grid_display
    A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.
    The important parameters are :
    I. Export :
    i. I_callback_program : report id
    ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status
    iii. I_callback_user_command : routine where the function codes are handled
    iv. I_structure name : name of the dictionary table
    v. Is_layout : structure to set the layout of the report
    vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE
    vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.
    II. Tables :
    i. t_outtab : internal table with the data to be output
    B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.
    The Important Parameters are :
    I. Export :
    i. I_program_name : report id
    ii. I_internal_tabname : the internal output table
    iii. I_inclname : include or the report name where all the dynamic forms are handled.
    II Changing
    ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is
    declared in the type pool SLIS.
    C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type
    Parameters :
    I. Import :
    Et_Events : The event table is returned with all possible CALLBACK events
    for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.
    II. Export :
    I_List_type :
    0 = simple list REUSE_ALV_LIST_DISPLAY
    1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY
    2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND
    3 = hierarchical-sequential block list
    REUSE_ALV_BLOCK_LIST_HS_APPEND
    D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
    Parameters :
    I. it_list_commentary : internal table with the headings of the type slis_t_listheader.
    This internal table has three fields :
    Typ : ‘H’ – header, ‘S’ – selection , ‘A’ - action
    Key : only when typ is ‘S’.
    Info : the text to be printed
    E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.
    Parameters : same as reuse_alv_list_display
    This is an example for simple list.
    2. BLOCK REPORT
    This is used to have multiple lists continuously.
    The important functions used in this report are:
    A. REUSE_ALV_BLOCK_LIST_INIT
    B. REUSE_ALV_BLOCK_LIST_APPEND
    C. REUSE_ALV_BLOCK_LIST_HS_APPEND
    D. REUSE_ALV_BLOCK_LIST_DISPLAY
    A. REUSE_ALV_BLOCK_LIST_INIT
    Parameters:
    I. I_CALLBACK_PROGRAM
    II. I_CALLBACK_PF_STATUS_SET
    III. I_CALLBACK_USER_COMMAND
    This function module is used to set the default gui status etc.
    B. REUSE_ALV_BLOCK_LIST_APPEND
    Parameters :
    Export :
    I. is_layout : layout settings for block
    II. it_fieldcat : field catalog
    III. i_tabname : internal table name with output data
    IV. it_events : internal table with all possible events
    Tables :
    i. t_outtab : internal table with output data.
    This function module adds the data to the block.
    Repeat this function for all the different blocks to be displayed one after the other.
    C. REUSE_ALV_BLOCK_LIST_HS_APPEND
    This function module is used for hierarchical sequential blocks.
    D. REUSE_ALV_BLOCK_LIST_DISPLAY
    Parameters : All the parameters are optional.
    This function module display the list with data appended by the above function.
    Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.
    3. Hierarchical reports :
    Hierarchical sequential list output.
    The function module is
    A. REUSE_ALV_HIERSEQ_LIST_DISPLAY
    Parameters:
    I. Export:
    i. I_CALLBACK_PROGRAM
    ii. I_CALLBACK_PF_STATUS_SET
    iii. I_CALLBACK_USER_COMMAND
    iv. IS_LAYOUT
    v. IT_FIELDCAT
    vi. IT_EVENTS
    vii. i_tabname_header : Name of the internal table in the program containing the
    output data of the highest hierarchy level.
    viii. i_tabname_item : Name of the internal table in the program containing the
    output data of the lowest hierarchy level.
    ix. is_keyinfo : This structure contains the header and item table field
    names which link the two tables (shared key).
    II. Tables
    i. t_outtab_header : Header table with data to be output
    ii. t_outtab_item : Name of the internal table in the program containing the
    output data of the lowest hierarchy level.
    slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using ‘REUSE_ALV_FIELDCATALOG_MERGE’.
    Important Attributes :
    A. col_pos : position of the column
    B. fieldname : internal fieldname
    C. tabname : internal table name
    D. ref_fieldname : fieldname (dictionary)
    E. ref_tabname : table (dictionary)
    F. key(1) : column with key-color
    G. icon(1) : icon
    H. symbol(1) : symbol
    I. checkbox(1) : checkbox
    J. just(1) : (R)ight (L)eft (C)ent.
    K. do_sum(1) : sum up
    L. no_out(1) : (O)blig.(X)no out
    M. outputlen : output length
    N. seltext_l : long key word
    O. seltext_m : middle key word
    P. seltext_s : short key word
    Q. reptext_ddic : heading (ddic)
    R. ddictxt(1) : (S)hort (M)iddle (L)ong
    S. datatype : datatype
    T. hotspot(1) : hotspot
    with regards,
    Hema Sundara.
    pls reward if u find it helpful.

  • Set cursor alv grid (not using objects)

    I got a question on ALV GRID (not using objects), please let me know if you have pointers. Thanks.
    Output has 2 screens both has different contents. The output is generated using internal table1 and 2 and using FM  'REUSE_ALV_GRID_DISPLAY_LVC'  (both screen use same FM).
    First screen has multiple pages of output (say 10 pages). User scrolled page 5 and line 10 of first screen and then double clicked it takes to screen #2. After completion of screen #2, the back arrow should get back to page 5 and line 10 of screen #1. Currently the back arrow gets to screen#1 page 1 and line 1. How to remember the cursor position in alv grid and instruct the cursor to go there?
    Appreciate the input.
    Note: I tried "set cursor line n" with "Scroll" command but no luck. http://help.sap.com/saphelp_nw70/helpdata/EN/9f/dba47e35c111d1829f0000e829fbfe/content.htm

    Thanks for the inputs.
    FYI, I got it implemented using method  CALL METHOD <ref.var. to CL_GUI_ALV_GRID > ->set_current_cell_via_id
    The method is called by 'REUSE_ALV_GRID_DISPLAY_LVC' form 'PF_STATUS_SET' when the ALV grid output is presented each time.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
        EXPORTING
          i_bypassing_buffer       = 'X'
          i_callback_program       = gc_repid
          i_callback_pf_status_set = 'PF_STATUS_SET'
          i_callback_user_command  = 'USER_COMMAND'
          is_layout_lvc            = lwa_layout
          it_fieldcat_lvc          = git_fc_lvc
          i_default                = ' '
        TABLES
          t_outtab                 = git_data
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      FORM alv_event_pf_status_set USING rt_extab                
                                 TYPE slis_t_extab.
      DATA lo_ref1 TYPE REF TO cl_gui_alv_grid.
    *Get the reference to class "lo_ref1" for the ALV report
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          e_grid = lo_ref1.
    *set the focus of cursor in ALV
      CALL METHOD lo_ref1->set_current_cell_via_id
        EXPORTING
          is_row_no = gv_row. "row number where you want to focus the cursor
      ENDFORM.

  • Downloading ALV Grid (using objects) output to Excel

    Hi all,
    I'm using objects for ALV Grid. I have few other fields (few are above and few are below the custom control) on screen other than custom control. I want to download the entire screen to excel (including other fields). But using Export option I'm able to download only ALV Grid. I did tried with Excel in place option which is not pulling data from ALV Grid control.
    Please suggest me the solution.
    Regards
    Jaker.

    hi
    use this code in ALV format
    TABLES USR03.
    DATA: BEGIN OF ISAPDAT OCCURS 0,
              BNAME LIKE USR03-BNAME,
              NAME1 LIKE USR03-NAME1,
              NAME2 LIKE USR03-NAME2,
          END OF ISAPDAT.
    PARAMETERS P_FNAME LIKE RLGRAP-FILENAME
                        DEFAULT 'd:\sapdata.xls' OBLIGATORY.
    SELECT * FROM USR03 INTO CORRESPONDING FIELDS OF TABLE ISAPDAT.
    SORT ISAPDAT.
    CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
         EXPORTING
              I_FILENAME        = P_FNAME
         TABLES
              I_TAB_SAP_DATA    = ISAPDAT
         EXCEPTIONS
              CONVERSION_FAILED = 1
              OTHERS            = 2.
    IF SY-SUBRC EQ 0.
      WRITE:/ 'Download to Excel complete'.
    ELSE.
      WRITE:/ 'Error with download'.
    ENDIF.
    Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 2:34 PM

  • How to use objects as a message type in WSDL?

    How can I use object as a type for the message in WSDL?
    For example, I want to achieve something like this:
    <message name="DBConnection">
    <part name="conn" type="???"/>
    </message>
    In the above example, for any operation getConnection(), the return type would be an object of the type Connection.
    Any suggestions ?
    Thanks,
    Dhaval

    Hi,
    Listed below is the step by step intructions to configure the Nokia device as a modem to a mac.
    Steps:
    Connecting your Mac to the internet is convenient and easy with your a compatible Nokia S60 device. You'll need a Nokia S60 device that supports a 2G or 3G data connection (such as GPRS or HSDPA), a compatible Mac (with the latest OS X), a USB cable for your Nokia device or a Bluetooth-enabled Mac, and a network subscription with your mobile service provider.
    To set up your device you'll need to know your operator's Access Point Name (APN) and have the packet data service enabled. For help with this please contact your operator.
    In Settings select and open Connection >Select and open Packet data > Select and open Access point >Type in your operator's Access Point Name
    Exit Settings. Your device is now ready to be used as a modem for your Mac!
    Bluetooth Connection: Pairing between Mac and Device using bluetooth, follow the instruction from here: http://europe.nokia.com/get-support-and-software/download-software/device-as-a-modem/connect-to-your...
    Note: Preferred mode is USB as it much faster than Bluetooth.
    Connect the device and then go to System preferences- >Network- >Select Device (Nokia XXX)
    Click on Advanced Tab > Modem tab
    - Vendor : Nokia
    -Model:GPRS (GSM/3G)
    -Telephone Number: *99***1# (contact your operator to get this settings)
    -APN: airtelgprs.com (contact your operator to get this settings)
    CID: 1
    Once connected it will be highlighted in green.
    Hopefully this helps.
    Cheers
    Sandy
    Message Edited by sandy2410 on 30-Mar-2009 04:52 AM
    Helpful information, then dont forget to hit the kudos star :-) Or say it accepted solution and thanks

  • How to embed jnlp file into html page using object tag

    hi everyone,
    i have written one jnlp file like this.
    <?xml version="1.0" encoding="utf-8" ?>
    <!-- JNLP file for Demo applicaion -->
    <jnlp spec="1.0+" codebase="http://localhost:9080/base/" href="SampleExample.jnlp">
         <information>
              <title>Demo Application</title>
              <vendor> </vendor>
              <description>Sample Demo Application</description>
              <offline-allowed/>
         </information>
         <security/>
         <resources>
              <j2se version="1.3+" />
              <jar href="common.jar" main="true" download="eager" />
              <jar href="classes12.jar" download="eager" />
              <jar href="toplink.jar" download="eager"/>
              <package name="com.applet.*" part="applet" recursive="true"/>
         </resources>
         <applet-desc name="grid" main-class="com.applet.PriceGrid" width="1000" height="300"/>
    </jnlp>
    i am trying embed that jnlp file using object tag like
    <OBJECT
    classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH="1000" HEIGHT="300" NAME="grid">     
    <PARAM NAME="jnlp" VALUE="http://localhost:9080/base/SampleExample.jnlp">
    </OBJECT>
    but i am not able to load the applet using Web Start.
    Can anyone please help me. This is very Urgent for me.
    Thanks & Regards,
    Shiva.

    thanks.
    i am giving my problem clearly. i have one applet. Previously i am loading the applet in my html page using object tag like this...
    <OBJECT
    classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH="1000" HEIGHT="300" NAME="grid">
    <PARAM NAME="CODE" VALUE="com.adp.base.applet.PriceGrid.class" >
         <PARAM NAME="ARCHIVE" VALUE="common.jar,classes12.jar,toplink.jar" >
         <PARAM NAME="NAME" VALUE="grid" >
    <PARAM NAME="type" VALUE="application/x-java-applet">
    <PARAM NAME= "cache_option" VALUE ="no">
    </OBJECT>
    now what i need to do is
    i need load the applet only first time using web start and when ever the applet code changes in the server i need to reload the applet.
    for that i kept all the applet resources in .jnlp file.i want to cache all the resources which are in .jnlp file and applet must be displayed within a web page within a browser.
    Webstart always open a new application windows.
    I need to run an Applet embedded within a web page within a browser.
    Is there a way to still use Webstart?

  • File I/O Using Object Streams

    My program is supposed to be a Driving instructor program that allows someone to enter a Name and Lesson Number, and it will pull up the Date, and Comments that the lesson took place. The information is saved in a file with the person's name, and saved as an array. We are required to use Object Streams for the file i/o. The only part of the program that I don't have working is the actual file i/o. The large commented section that I have in the datamanager class is the notes from the professor on the board and I haven't removed them yet. There are 4 classes for this file.
    The main class that creates the program and calls the other classes.
    import java.awt.*;
    import javax.swing.*;
    public class main {
    /** Creates a new instance of main */
    public main() {
    * @param args the command line arguments
    public static void main(String[] args)
    guiLayout labelFrame = new guiLayout(); // creates LabelFrame
    labelFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE);
    labelFrame.setSize(600, 200);
    labelFrame.setVisible(true);
    } The second class is the GUI class and event handler class.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    public class guiLayout extends JFrame{
        private JPanel centertop;
        private JPanel centermiddle;
        private JPanel centerbottom;
        private JLabel dateLabel;
        private JLabel nameLabel;
        private JLabel lessonLabel;
        private JLabel commentsLabel;
        private JTextArea DateTextArea;
        private JTextArea NameTextArea;
        private JTextArea LessonTextArea;
        private JTextArea CommentsTextArea;
        private JButton Save;
        private JButton Retrieve;
        private String tempDay[];
        private DataManager DMO;
        /** Creates a new instance of guiLayout */
        public guiLayout()
            super("Drive Application");
            setLayout(new FlowLayout());
            dateLabel = new JLabel("Date (mm/dd/yy)");
            nameLabel = new JLabel("Name");
            lessonLabel = new JLabel("Lesson (1-10)");
            commentsLabel = new JLabel("Comments");
            DateTextArea = new JTextArea(1, 7);
            NameTextArea = new JTextArea(1, 15);
            LessonTextArea = new JTextArea(1, 2);
            CommentsTextArea = new JTextArea(6, 30);
            Save = new JButton( "Save");
            Retrieve = new JButton( "Retrieve");
            //insert into GUI
            //TOP
            centertop = new JPanel();
            centertop.add(nameLabel);
            centertop.add(NameTextArea);
            centertop.add(lessonLabel);
            centertop.add(LessonTextArea);
            centertop.add(dateLabel);
            centertop.add(DateTextArea);
            centertop.setLayout(new GridLayout(6,1));
            add(centertop, BorderLayout.NORTH);
            centermiddle = new JPanel();
            centermiddle.setLayout(new GridLayout(1,1));
            centermiddle.add(CommentsTextArea);
            add(centermiddle, BorderLayout.CENTER);
            centerbottom = new JPanel();
            centerbottom.setLayout(new GridLayout(1,3));
            centerbottom.add (Save);
            centerbottom.add(Retrieve);
            add(centerbottom, BorderLayout.SOUTH);
            ButtonHandler handler = new ButtonHandler();
            Save.addActionListener( handler);
            Retrieve.addActionListener(handler);
        private class ButtonHandler implements ActionListener
            public void actionPerformed(ActionEvent event)
                String Namein = NameTextArea.getText();
                String Datein = DateTextArea.getText();
                String Commentsin = CommentsTextArea.getText();
                int Lessonin = Integer.parseInt(LessonTextArea.getText());
                if(event.getSource()==Save)
                   DMO.Save(Namein, Datein, Commentsin, Lessonin);
                if(event.getSource()==Retrieve)
                    if(Lessonin >= 1 && Lessonin <= 10)
                       LessonRecord r = (DMO.Retrieve(Namein, Lessonin));
                    else
                        String errormess = "Lesson Number must be between 1 and 10!";
                        CommentsTextArea.setText(errormess);
    }The third class is the DataManager class which handles the actual file i/o.
    import java.io.*;
    import java.util.*;
    public class DataManager implements Serializable
        //private String Path = "P:\\D00766703\\CET431\\Assign5";
        private String Path = "C:\\Java";
        FileInputStream fin;
        FileOutputStream fout;
        ObjectInputStream oin;
        ObjectOutputStream oout;
        public String Retrieve(String name, int lesson)
            String itemFile = Path + name + ".ser";
            File f = new File(itemFile);
            if (f.exists() == true)
                try
                    if(fin == null)
                        fin = new FileInputStream(itemFile);
                        oin = new ObjectInputStream(fin);
                    LessonRecord r[] = oin.readObject();
                    if(fin.available() == 0)
                        oout.close();
                        fout.close();
                        return r[lesson - 1];
                catch(IOException ioe)
                    System.out.print(ioe);
            else
                LessonRecord LR = new LessonRecord();
                LR.date = " ";
                LR.comment = "File Not Found";
                return LR;
        /*create file object for Path\\Name
         *if file exists
         *  create fileinputstream
         *  create objectinputstream - oin
         *  read array of lesson records
         *  LessonRecord |r[] = oin.readObject();    need cast to array here
         *  close object input stream and file input stream
         *  return |r[lesson - 1];
         *else file does NOT EXIST
         *  LessonRecord LR = new LessonRecord();
         *  LR.date = " ";
         *  LR.comment = error message;
         *  return LR;
        public void Save(String name, String date, String comment, int lesson)
            String itemFile = Path + name + ".ser";
            File f = new File(itemFile);
            LessonRecord |r[];
            if (f.exists() == true)
                try
                    fin = new FileInputStream(itemFile);
                    oin = new ObjectInputStream(fin);
                    LessonRecord r[] = oin.readObject();
                catch(IOException ioe)
                    System.out.print(ioe);
            else
                r = new LessonRecord[10];
            r[lesson - 1] = new LessonRecord(date, comment);
            fout = new FileOutputStream(itemFile, true);
            oout = new ObjectOutputStream(fout);
            oout.write(r);
            oout.close();
            fout.close();
        /*create file object for Path\\Name
         *LessonRecord |r[];
         *if file exists
         *  create fileinputstream
         *  create objectinputstream - oin
         *  read array of lesson records
         *  LessonRecord |r[] = oin.readObject();    need cast to array here
         *  close object input stream and file input stream
         *else
         *  |r = new LessonRecord[10];
         *|r[lesson - 1] = new LessonRecord(date, comment);
         *createfileoutputstream(BaseDir\\Name);
         *createobjectoutputstream - oout
         *oout.write(|r);
         *closeobjectstream
         *closefilestream
    }And the fourth class is the LessonRecord class which is serializable and has the date and comments variables.
    import java.io.Serializable;
    public class LessonRecord implements Serializable
        public String Date;
        public String Comment;
        /** Creates a new instance of LessonRecord */
        public LessonRecord()
            Date = "";
            Comment = "";
        public LessonRecord(String Datein, String Commentin)
            Date = Datein;
            Comment = Commentin;
    }I could have sworn that the professor said to make it |r for the account records variable names, but I always get errors when I do that, and I need to know how to cast to an array too.

    hi Friend,
    I have made some modification to your code. and try this...I think it will help you...
    /*guiLayout.java*/
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    public class guiLayout extends JFrame{
        private JPanel centertop;
        private JPanel centermiddle;
        private JPanel centerbottom;
        private JLabel dateLabel;
        private JLabel nameLabel;
        private JLabel lessonLabel;
        private JLabel commentsLabel;
        private JTextArea DateTextArea;
        private JTextArea NameTextArea;
        private JTextArea LessonTextArea;
        private JTextArea CommentsTextArea;
        private JButton Save;
        private JButton Retrieve;
        private String tempDay[];
        private DataManager DMO;
        /** Creates a new instance of guiLayout */
        public guiLayout()
            super("Drive Application");
            DMO=new DataManager();
            setLayout(new FlowLayout());
            dateLabel = new JLabel("Date (mm/dd/yy)");
            nameLabel = new JLabel("Name");
            lessonLabel = new JLabel("Lesson (1-10)");
            commentsLabel = new JLabel("Comments");
            DateTextArea = new JTextArea(1, 7);
            NameTextArea = new JTextArea(1, 15);
            LessonTextArea = new JTextArea(1, 2);
            CommentsTextArea = new JTextArea(6, 30);
            Save = new JButton( "Save");
            Retrieve = new JButton( "Retrieve");
            //insert into GUI
            //TOP
            centertop = new JPanel();
            centertop.add(nameLabel);
            centertop.add(NameTextArea);
            centertop.add(lessonLabel);
            centertop.add(LessonTextArea);
            centertop.add(dateLabel);
            centertop.add(DateTextArea);
            centertop.setLayout(new GridLayout(6,1));
            add(centertop, BorderLayout.NORTH);
            centermiddle = new JPanel();
            centermiddle.setLayout(new GridLayout(1,1));
            centermiddle.add(CommentsTextArea);
            add(centermiddle, BorderLayout.CENTER);
            centerbottom = new JPanel();
            centerbottom.setLayout(new GridLayout(1,3));
            centerbottom.add (Save);
            centerbottom.add(Retrieve);
            add(centerbottom, BorderLayout.SOUTH);
            ButtonHandler handler = new ButtonHandler();
            Save.addActionListener( handler);
            Retrieve.addActionListener(handler);
        private class ButtonHandler implements ActionListener
            public void actionPerformed(ActionEvent event)
                String Namein = NameTextArea.getText();
                int Lessonin = Integer.parseInt(LessonTextArea.getText());
                if(event.getSource()==Save)
                    String Datein = DateTextArea.getText();
                     String Commentsin = CommentsTextArea.getText();
                   DMO.Save(Namein, Datein, Commentsin, Lessonin);
                if(event.getSource()==Retrieve)
                    if(Lessonin >= 1 && Lessonin <= 10)
                       LessonRecord r = (DMO.Retrieve(Namein, Lessonin));
                       System.out.println("Retrieve:"+ r.Comment+":"+r.Date);
                    else
                        String errormess = "Lesson Number must be between 1 and 10!";
                        CommentsTextArea.setText(errormess);
    /*DataManager.java*/
    import java.io.*;
    import java.util.*;
    public class DataManager implements Serializable
        //private String Path = "P:\\D00766703\\CET431\\Assign5";
        private String Path = "C:/Java";
        FileInputStream fin;
        FileOutputStream fout;
        ObjectInputStream oin;
        ObjectOutputStream oout;
        public LessonRecord Retrieve(String name, int lesson)
            String itemFile = Path + name + ".ser";
            File f = new File(itemFile);
            LessonRecord[] r=null;
            if (f.exists() == true)
                try
                    if(fin == null)
                        fin = new FileInputStream(itemFile);
                        oin = new ObjectInputStream(fin);
                    r= (LessonRecord[])oin.readObject();
                    System.out.println(r[lesson-1].Comment+":"+r[lesson-1].Date);
                catch(IOException ioe)
                    System.out.print(ioe);
                  catch(ClassNotFoundException c){
                    c.printStackTrace();
                finally
                    try {
                        if(fin!=null)fin.close();
                        if(oin!=null)oin.close();
                    } catch (IOException ex) {
                        ex.printStackTrace();
            else
                LessonRecord LR = new LessonRecord();
                LR.Date = " ";
                LR.Comment = "File Not Found";
                return LR;
        /*create file object for Path\\Name
         *if file exists
         *  create fileinputstream
         *  create objectinputstream - oin
         *  read array of lesson records
         *  LessonRecord |r[] = oin.readObject();    need cast to array here
         *  close object input stream and file input stream
         *  return |r[lesson - 1];
         *else file does NOT EXIST
         *  LessonRecord LR = new LessonRecord();
         *  LR.date = " ";
         *  LR.comment = error message;
         *  return LR;
      return r[lesson - 1];
        public void Save(String name, String date, String comment, int lesson)
            String itemFile = Path + name + ".ser";
            File f = new File(itemFile);
            LessonRecord r[]=new LessonRecord[10];
            if (f.exists() == true)
                try
                    fin = new FileInputStream(itemFile);
                    oin = new ObjectInputStream(fin);
                     r = (LessonRecord[])oin.readObject();
                catch(IOException ioe)
                    System.out.print(ioe);
                catch(ClassNotFoundException c){
                    c.printStackTrace();
                finally
                    try {
                        if(fin!=null)fin.close();
                        if(oin!=null)oin.close();
                    } catch (IOException ex) {
                        ex.printStackTrace();
            else
                r = new LessonRecord[10];
       try
            r[lesson - 1] = new LessonRecord(date, comment);
            fout = new FileOutputStream(itemFile);
            oout = new ObjectOutputStream(fout);
            oout.writeObject(r);
            oout.flush();
       catch(IOException ioe)
            finally
                try {
                    if(fout!=null)fout.close();
                    if(oout!=null)oout.close();
                } catch (IOException ex) {
                    ex.printStackTrace();
        /*create file object for Path\\Name
         *LessonRecord |r[];
         *if file exists
         *  create fileinputstream
         *  create objectinputstream - oin
         *  read array of lesson records
         *  LessonRecord |r[] = oin.readObject();    need cast to array here
         *  close object input stream and file input stream
         *else
         *  |r = new LessonRecord[10];
         *|r[lesson - 1] = new LessonRecord(date, comment);
         *createfileoutputstream(BaseDir\\Name);
         *createobjectoutputstream - oout
         *oout.write(|r);
         *closeobjectstream
         *closefilestream
    }main.java and LessonRecord.java does not have any changes so you use the old code....
    Thanks
    Edited by: rajaram on Sep 28, 2007 1:24 PM

  • Is there any procedure to get the memory warning levels using objective C

    I want know the different levels of memory warnings programmatically using objective C.Is there any procedure to get that.

    AmirTs wrote:
    my device connects to my server and need to authenticate with a unique number
    and i need access to the number to add it in the server.

  • How to capture index/row no of row in table using object oriented alv.

    i have a table with many fields. i have an alv grid table displayed using object oriented alv. when i double click on a record, i call another screen. there i want to display the record number. eg, if i doubleclick on the third row, i will go to next screen and display 3 there.
    please let me know how it is done as it is urgent.
    thanks in advance.

    Hi,
    Use the following code to get rowno.
    CLASS lcl_grid_events DEFINITION DEFERRED.
    DATA:
      grid1_events      TYPE REF TO lcl_grid_events.
    CLASS lcl_grid_events DEFINITION.
      PUBLIC SECTION.
        METHODS:
          dbclk
           FOR EVENT double_click  OF cl_gui_alv_grid
           IMPORTING e_row
                     e_column
                     es_row_no.
    ENDCLASS.                    "lcl_grid_events DEFINITION
    CLASS lcl_grid_events IMPLEMENTATION.
      METHOD dbclk.
    *access e_row variable, which contains the record no.
      ENDMETHOD.                    "dbclk
    ENDCLASS.                    "lcl_grid
    write the following code after method call of set_table_for_first_display
        CREATE OBJECT grid1_events.
        SET HANDLER grid1_events->dbclk
                    FOR grid1.
    reward point if useful.

  • Approval Status using Object ID

    Hi Experts,
    I am creating a Backend Report which gives the SC Status. I have Shopping Cart number, Based on the SC# how can I find the status like who approved or with whom the SC is waiting for approval. I dont have Work Item ID here.
    Pls let me know which table / FM I can use to get the above status using Object ID( SC# ).
    Thanks in Advance.
    Rupachandran G

    Hi,
       Please refer the link..
    How to Get WorkItem ID
    Saravanan

  • On Work Order using Object lists for equip u can manually create Notifi

    On a maintenance Work Order using Object lists for equipment you can manually create a notification for each line item.
    We want to automate this process to do this when we save the document.
    Any ideau2019s on how to do this?
    Does a user exit exist for this?

    Hi:
    Check with Tcode: IBIP - Plant maintenace batch input utility tool.
    Hope, it may help!
    Thanks,
    Murali.

  • Notes on using Object  oriented concept in ABAP

    Hi ,
    I want somes notes on how to use Object  oriented concept in ABAP.
    Thanks in advance.
    Chetan

    Hi, this may help you
    OOPs ABAP uses Classes and Interfaces which uses Methods and events.
    If you have Java skills it is advantage for you.
    There are Local classes as well as Global Classes.
    Local classes we can work in SE38 straight away.
    But mostly it is better to use the Global classes.
    Global Classes or Interfaces are to be created in SE24.
    SAP already given some predefined classes and Interfaces.
    This OOPS concepts very useful for writing BADI's also.
    So first create a class in SE 24.
    Define attributes, Methods for that class.
    Define parameters for that Method.
    You can define event handlers also to handle the messages.
    After creation in each method write the code.
    Methods are similar to ABAP PERFORM -FORM statements.
    After the creation of CLass and methods come to SE38 and create the program.
    In the program create a object type ref to that class and with the help of that Object call the methods of that Class and display the data.
    Example:
    REPORT sapmz_hf_alv_grid .
    Type pool for icons - used in the toolbar
    TYPE-POOLS: icon.
    TABLES: zsflight.
    To allow the declaration of o_event_receiver before the
    lcl_event_receiver class is defined, decale it as deferred in the
    start of the program
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    G L O B A L I N T E R N A L T A B L E S
    *DATA: gi_sflight TYPE STANDARD TABLE OF sflight.
    To include a traffic light and/or color a line the structure of the
    table must include fields for the traffic light and/or the color
    TYPES: BEGIN OF st_sflight.
    INCLUDE STRUCTURE zsflight.
    Field for traffic light
    TYPES: traffic_light TYPE c.
    Field for line color
    types: line_color(4) type c.
    TYPES: END OF st_sflight.
    TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight.
    DATA: gi_sflight TYPE tt_sflight.
    G L O B A L D A T A
    DATA: ok_code LIKE sy-ucomm,
    Work area for internal table
    g_wa_sflight TYPE st_sflight,
    ALV control: Layout structure
    gs_layout TYPE lvc_s_layo.
    Declare reference variables to the ALV grid and the container
    DATA:
    go_grid TYPE REF TO cl_gui_alv_grid,
    go_custom_container TYPE REF TO cl_gui_custom_container,
    o_event_receiver TYPE REF TO lcl_event_receiver.
    DATA:
    Work area for screen 200
    g_screen200 LIKE zsflight.
    Data for storing information about selected rows in the grid
    DATA:
    Internal table
    gi_index_rows TYPE lvc_t_row,
    Information about 1 row
    g_selected_row LIKE lvc_s_row.
    C L A S S E S
    CLASS lcl_event_receiver DEFINITION.
    PUBLIC SECTION.
    METHODS:
    handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
    IMPORTING
    e_object e_interactive,
    handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
    IMPORTING e_ucomm.
    ENDCLASS.
    CLASS lcl_event_receiver IMPLEMENTATION
    CLASS lcl_event_receiver IMPLEMENTATION.
    METHOD handle_toolbar.
    Event handler method for event toolbar.
    CONSTANTS:
    Constants for button type
    c_button_normal TYPE i VALUE 0,
    c_menu_and_default_button TYPE i VALUE 1,
    c_menu TYPE i VALUE 2,
    c_separator TYPE i VALUE 3,
    c_radio_button TYPE i VALUE 4,
    c_checkbox TYPE i VALUE 5,
    c_menu_entry TYPE i VALUE 6.
    DATA:
    ls_toolbar TYPE stb_button.
    Append seperator to the normal toolbar
    CLEAR ls_toolbar.
    MOVE c_separator TO ls_toolbar-butn_type..
    APPEND ls_toolbar TO e_object->mt_toolbar.
    Append a new button that to the toolbar. Use E_OBJECT of
    event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.
    This class has one attribute MT_TOOLBAR which is of table type
    TTB_BUTTON. The structure is STB_BUTTON
    CLEAR ls_toolbar.
    MOVE 'CHANGE' TO ls_toolbar-function.
    MOVE icon_change TO ls_toolbar-icon.
    MOVE 'Change flight' TO ls_toolbar-quickinfo.
    MOVE 'Change' TO ls_toolbar-text.
    MOVE ' ' TO ls_toolbar-disabled.
    APPEND ls_toolbar TO e_object->mt_toolbar.
    ENDMETHOD.
    METHOD handle_user_command.
    Handle own functions defined in the toolbar
    CASE e_ucomm.
    WHEN 'CHANGE'.
    PERFORM change_flight.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMETHOD.
    ENDCLASS.
    S T A R T - O F - S E L E C T I O N.
    START-OF-SELECTION.
    SET SCREEN '100'.
    *& Module USER_COMMAND_0100 INPUT
    MODULE user_command_0100 INPUT.
    CASE ok_code.
    WHEN 'EXIT'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    *& Module STATUS_0100 OUTPUT
    MODULE status_0100 OUTPUT.
    DATA:
    For parameter IS_VARIANT that is sued to set up options for storing
    the grid layout as a variant in method set_table_for_first_display
    l_layout TYPE disvariant,
    Utillity field
    l_lines TYPE i.
    After returning from screen 200 the line that was selected before
    going to screen 200, should be selected again. The table gi_index_rows
    was the output table from the GET_SELECTED_ROWS method in form
    CHANGE_FLIGHT
    DESCRIBE TABLE gi_index_rows LINES l_lines.
    IF l_lines > 0.
    CALL METHOD go_grid->set_selected_rows
    EXPORTING
    it_index_rows = gi_index_rows.
    CALL METHOD cl_gui_cfw=>flush.
    REFRESH gi_index_rows.
    ENDIF.
    Read data and create objects
    IF go_custom_container IS INITIAL.
    Read data from datbase table
    PERFORM get_data.
    Create objects for container and ALV grid
    CREATE OBJECT go_custom_container
    EXPORTING container_name = 'ALV_CONTAINER'.
    CREATE OBJECT go_grid
    EXPORTING
    i_parent = go_custom_container.
    Create object for event_receiver class
    and set handlers
    CREATE OBJECT o_event_receiver.
    SET HANDLER o_event_receiver->handle_user_command FOR go_grid.
    SET HANDLER o_event_receiver->handle_toolbar FOR go_grid.
    Layout (Variant) for ALV grid
    l_layout-report = sy-repid. "Layout fo report
    Setup the grid layout using a variable of structure lvc_s_layo
    Set grid title
    gs_layout-grid_title = 'Flights'.
    Selection mode - Single row without buttons
    (This is the default mode
    gs_layout-sel_mode = 'B'.
    Name of the exception field (Traffic light field) and the color
    field + set the exception and color field of the table
    gs_layout-excp_fname = 'TRAFFIC_LIGHT'.
    gs_layout-info_fname = 'LINE_COLOR'.
    LOOP AT gi_sflight INTO g_wa_sflight.
    IF g_wa_sflight-paymentsum < 100000.
    Value of traffic light field
    g_wa_sflight-traffic_light = '1'.
    Value of color field:
    C = Color, 6=Color 1=Intesified on, 0: Inverse display off
    g_wa_sflight-line_color = 'C610'.
    ELSEIF g_wa_sflight-paymentsum => 100000 AND
    g_wa_sflight-paymentsum < 1000000.
    g_wa_sflight-traffic_light = '2'.
    ELSE.
    g_wa_sflight-traffic_light = '3'.
    ENDIF.
    MODIFY gi_sflight FROM g_wa_sflight.
    ENDLOOP.
    Grid setup for first display
    CALL METHOD go_grid->set_table_for_first_display
    EXPORTING i_structure_name = 'SFLIGHT'
    is_variant = l_layout
    i_save = 'A'
    is_layout = gs_layout
    CHANGING it_outtab = gi_sflight.
    *-- End of grid setup -
    Raise event toolbar to show the modified toolbar
    CALL METHOD go_grid->set_toolbar_interactive.
    Set focus to the grid. This is not necessary in this
    example as there is only one control on the screen
    CALL METHOD cl_gui_control=>set_focus EXPORTING control = go_grid.
    ENDIF.
    ENDMODULE. " STATUS_0100 OUTPUT
    *& Module USER_COMMAND_0200 INPUT
    MODULE user_command_0200 INPUT.
    CASE ok_code.
    WHEN 'EXIT200'.
    LEAVE TO SCREEN 100.
    WHEN'SAVE'.
    PERFORM save_changes.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0200 INPUT
    *& Form get_data
    FORM get_data.
    Read data from table SFLIGHT
    SELECT *
    FROM zsflight
    INTO TABLE gi_sflight.
    ENDFORM. " load_data_into_grid
    *& Form change_flight
    Reads the contents of the selected row in the grid, ans transfers
    the data to screen 200, where it can be changed and saved.
    FORM change_flight.
    DATA:l_lines TYPE i.
    REFRESH gi_index_rows.
    CLEAR g_selected_row.
    Read index of selected rows
    CALL METHOD go_grid->get_selected_rows
    IMPORTING
    et_index_rows = gi_index_rows.
    Check if any row are selected at all. If not
    table gi_index_rows will be empty
    DESCRIBE TABLE gi_index_rows LINES l_lines.
    IF l_lines = 0.
    CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
    EXPORTING
    textline1 = 'You must choose a line'.
    EXIT.
    ENDIF.
    Read indexes of selected rows. In this example only one
    row can be selected as we are using gs_layout-sel_mode = 'B',
    so it is only ncessary to read the first entry in
    table gi_index_rows
    LOOP AT gi_index_rows INTO g_selected_row.
    IF sy-tabix = 1.
    READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight.
    ENDIF.
    ENDLOOP.
    Transfer data from the selected row to screenm 200 and show
    screen 200
    CLEAR g_screen200.
    MOVE-CORRESPONDING g_wa_sflight TO g_screen200.
    LEAVE TO SCREEN '200'.
    ENDFORM. " change_flight
    *& Form save_changes
    Changes made in screen 200 are written to the datbase table
    zsflight, and to the grid table gi_sflight, and the grid is
    updated with method refresh_table_display to display the changes
    FORM save_changes.
    DATA: l_traffic_light TYPE c.
    Update traffic light field
    Update database table
    MODIFY zsflight FROM g_screen200.
    Update grid table , traffic light field and color field.
    Note that it is necessary to use structure g_wa_sflight
    for the update, as the screen structure does not have a
    traffic light field
    MOVE-CORRESPONDING g_screen200 TO g_wa_sflight.
    IF g_wa_sflight-paymentsum < 100000.
    g_wa_sflight-traffic_light = '1'.
    C = Color, 6=Color 1=Intesified on, 0: Inverse display off
    g_wa_sflight-line_color = 'C610'.
    ELSEIF g_wa_sflight-paymentsum => 100000 AND
    g_wa_sflight-paymentsum < 1000000.
    g_wa_sflight-traffic_light = '2'.
    clear g_wa_sflight-line_color.
    ELSE.
    g_wa_sflight-traffic_light = '3'.
    clear g_wa_sflight-line_color.
    ENDIF.
    MODIFY gi_sflight INDEX g_selected_row-index FROM g_wa_sflight.
    Refresh grid
    CALL METHOD go_grid->refresh_table_display.
    CALL METHOD cl_gui_cfw=>flush.
    LEAVE TO SCREEN '100'.
    ENDFORM. " save_changes
    chk this blog
    /people/vijaybabu.dudla/blog/2006/07/21/topofpage-in-alv-using-clguialvgrid
    Reward if helpfull.
    Regards Madhu.

  • Grid using Object Oriented View

    Can anyone send me program for grid using object oriented view.

    hi Sandeep,
    please look at this code
    REPORT Z_PICK_LIST .
    TABLES: RESB.
    SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME TITLE TEXT-BL1.
    SELECT-OPTIONS: S_WERKS FOR RESB-WERKS," Plant
    S_AUFNR FOR RESB-AUFNR," Order number
    S_BDTER FOR RESB-BDTER." Req. date
    SELECTION-SCREEN END OF BLOCK BL1.
    PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT DEFAULT '/STANDARD'.
    DATA: BEGIN OF OUT OCCURS 10,
    AUFNR LIKE RESB-AUFNR, " Order number
    MATNR LIKE RESB-MATNR, " Material
    BDMNG LIKE RESB-BDMNG, " Requirements in UM
    MEINS LIKE RESB-MEINS, " Unit of Measure (UM)
    ERFMG LIKE RESB-ERFMG, " Requirements in UE
    ERFME LIKE RESB-ERFME, " Unit of Entry (UE)
    MAKTX LIKE MAKT-MAKTX, " Mat. description
    END OF OUT.
    INCLUDE Z_ALV_VARIABLES.
    INITIALIZATION.
    REPNAME = SY-REPID.
    PERFORM INITIALIZE_FIELDCAT USING FIELDTAB[].
    PERFORM BUILD_EVENTTAB USING EVENTS[].
    PERFORM BUILD_COMMENT USING HEADING[].
    PERFORM INITIALIZE_VARIANT.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
    PERFORM F4_FOR_VARIANT.
    AT SELECTION-SCREEN.
    PERFORM PAI_OF_SELECTION_SCREEN.
    START-OF-SELECTION.
    PERFORM GET_ORDERS.
    PERFORM GET_MATERIAL_DESCRIPTION.
    END-OF-SELECTION.
    PERFORM BUILD_LAYOUT USING LAYOUT.
    PERFORM BUILD_PRINT USING PRINTS.
    PERFORM WRITE_USING_ALV.
    FORM INITIALIZE_FIELDCAT *
    --> P_TAB *
    FORM INITIALIZE_FIELDCAT USING P_TAB TYPE SLIS_T_FIELDCAT_ALV.
    DATA: CAT TYPE SLIS_FIELDCAT_ALV.
    CLEAR CAT.
    ENDFORM. " INITIALIZE_FIELDCAT
    *& Form GET_ORDERS
    text
    FORM GET_ORDERS.
    SELECT AUFNR MATNR BDMNG MEINS ERFMG ERFME
    FROM RESB
    APPENDING TABLE OUT
    WHERE XLOEK EQ SPACE " deletion indicator
    AND XWAOK EQ 'X' " goods movement indicator
    AND WERKS IN S_WERKS " plant
    AND BDTER IN S_BDTER " req. date
    AND AUFNR IN S_AUFNR. " pr. order
    ENDFORM. " GET_ORDERS
    *& Form GET_MATERIAL_DESCRIPTION
    text
    FORM GET_MATERIAL_DESCRIPTION.
    SORT OUT BY MATNR.
    LOOP AT OUT.
    SELECT SINGLE MAKTX
    INTO OUT-MAKTX
    FROM MAKT
    WHERE MATNR EQ OUT-MATNR
    AND SPRAS EQ 'EN'.
    MODIFY OUT.
    ENDLOOP.
    SORT OUT BY AUFNR MATNR.
    ENDFORM. " GET_MATERIAL_DESCRIPTION
    FORM TOP_OF_PAGE *
    FORM TOP_OF_PAGE.
    DATA: L_POS TYPE P.
    first line
    WRITE:/ TEXT-001. " Plant:
    IF S_WERKS-HIGH NE SPACE.
    WRITE: S_WERKS-LOW, TEXT-TO1, S_WERKS-HIGH.
    ELSEIF S_WERKS-LOW NE SPACE.
    LOOP AT S_WERKS.
    WRITE: S_WERKS-LOW.
    ENDLOOP.
    ELSEIF S_WERKS-LOW EQ SPACE.
    WRITE: TEXT-ALL.
    ENDIF.
    L_POS = ( SY-LINSZ DIV 2 ) - ( STRLEN( TEXT-TIT ) DIV 2 ).
    POSITION L_POS. WRITE: TEXT-TIT.
    L_POS = SY-LINSZ - 20.
    POSITION L_POS. WRITE: TEXT-011, SY-UNAME RIGHT-JUSTIFIED. " User:
    second line
    WRITE:/ TEXT-002. " Order:
    IF S_AUFNR-HIGH NE SPACE.
    WRITE: S_AUFNR-LOW, TEXT-TO1, S_AUFNR-HIGH.
    ELSEIF S_AUFNR-LOW NE SPACE.
    LOOP AT S_AUFNR.
    WRITE: S_AUFNR-LOW.
    ENDLOOP.
    ELSEIF S_AUFNR-LOW EQ SPACE.
    WRITE: TEXT-ALL.
    ENDIF.
    L_POS = SY-LINSZ - 20.
    POSITION L_POS. WRITE: TEXT-012,SY-DATUM. " Date:
    third line
    WRITE:/ TEXT-003. " Req. Date:
    IF S_BDTER-HIGH(1) NE '0'.
    WRITE: S_BDTER-LOW, TEXT-TO1, S_BDTER-HIGH.
    ELSEIF S_BDTER-LOW(1) NE '0'.
    LOOP AT S_BDTER.
    WRITE: S_BDTER-LOW.
    ENDLOOP.
    ELSEIF S_BDTER-LOW(1) EQ '0'.
    WRITE: TEXT-ALL.
    ENDIF.
    L_POS = SY-LINSZ - 20.
    POSITION L_POS. WRITE: TEXT-013, SY-PAGNO. " Page:
    ENDFORM. " TOP_OF_PAGE
    FORM END_OF_LIST *
    FORM END_OF_LIST.
    DATA: L_POS TYPE P.
    ULINE.
    WRITE:/ '|', TEXT-021. " Delivered by:
    L_POS = SY-LINSZ DIV 2.
    POSITION L_POS. WRITE: '|', TEXT-031. " Received by:
    L_POS = SY-LINSZ.
    POSITION L_POS. WRITE: '|'.
    WRITE:/ '|'.
    L_POS = SY-LINSZ DIV 2.
    POSITION L_POS. WRITE: '|'.
    L_POS = SY-LINSZ.
    POSITION L_POS. WRITE: '|'.
    ULINE.
    WRITE:/ '|', TEXT-012. " Date:
    L_POS = SY-LINSZ DIV 2.
    POSITION L_POS. WRITE: '|', TEXT-012. " Date:
    L_POS = SY-LINSZ.
    POSITION L_POS. WRITE: '|'.
    WRITE:/ '|'.
    L_POS = SY-LINSZ DIV 2.
    POSITION L_POS. WRITE: '|'.
    L_POS = SY-LINSZ.
    POSITION L_POS. WRITE: '|'.
    ULINE.
    ENDFORM. " END_OF_LIST
    *& Form WRITE_USING_ALV
    text
    FORM WRITE_USING_ALV.
    Look this code*****
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    I_PROGRAM_NAME = REPNAME
    I_INTERNAL_TABNAME = 'OUT'
    I_INCLNAME = REPNAME
    CHANGING
    CT_FIELDCAT = FIELDTAB.
    IF SY-SUBRC 0.
    WRITE: 'SY-SUBRC: ', SY-SUBRC,
    'REUSE_ALV_FIELDCATALOG_MERGE'.
    ENDIF.
    LOOk this code also.*********
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = REPNAME
    i_callback_pf_status_set = 'PF_STATUS_SET'
    i_callback_user_command = 'USER_COMMAND'
    I_STRUCTURE_NAME = 'OUT'
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = FIELDTAB
    I_DEFAULT = 'A'
    I_SAVE = G_SAVE
    IS_VARIANT = G_VARIANT
    IT_EVENTS = EVENTS[]
    IS_PRINT = PRINTS
    TABLES
    T_OUTTAB = OUT.
    IF SY-SUBRC 0.
    WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_LIST_DISPLAY'.
    ENDIF.
    ENDFORM. " WRITE_USING_ALV
    ***************report over***************
    HOPE THIS CODE HELPS U
    Reward if its useful.............
    thanks and regards
    suma sailaja

  • Maintain the variants for the deletion progError while using object W_SOR

    Dear Experts ,
    While running the archival using object W_SOR , I am getting the error " Maintain the variants for the deletion program first"
    I have checked Customizing -> Archiving Object-Specific Customizing: Technical Settings) , In that std variants already exist .
    Please tell me what is the setting that could be missing .
    I am not getting the same error  in development client , but getting it in the production client .
    Is there anything else to be done ?
    regards
    Anis

    tcode OMBT..
    click on display groups (F5) & select the check box wich includes WA (the Number Range Object Material document Grouping)
    copy the entry for 2005, but do not assign any current number.

Maybe you are looking for