Using Objects to Initialize Static Fields: Good or Bad

I have a Command interface and a bunch of Commands that implement it (i.e. CmdJoin,CmdQuit). These Commands' settings change at runtime (i.e. required access levels, String identifiers). I don't want to have to store an instance of each Command in a database to save their settings , so instead I'm using the obvious solution: making static fields in these commands for these settings. This way, I can use a Simple Factory to return a Command, change its settings, execute it, and forget it, and still have the settings for that Command apply to all Commands. Yet I want to be able to modify and access fields of different Commands polymorphically. How can I have these commands' settings-related fields be static while modifying and accessing these fields polymorphically?
Here's what I have though of. First of all, interfaces can't have static methods. Secondly, neither can abstract classes. I also can't extend a base class which implements these settings-related fields and their interface, because then the fields would belong to all child classes of this base class, whereas I just want it to belong to a certain child class of the base class (i.e. all instances of CmdJoin or CmdQuit).
I've thought of two solutions.
The first is implementing a concrete interface in an abstract base class (getting rid of the Command interface) and overriding it in child classes, so that I can use the interface of the base class and the fields of the child classes.
The second is having no base class, and just a bunch of Commands implementing the interface with their own static fields. I would initialize these fields by passing arguments to their constructors.
These solutions seem very sloppy though! Are there any better ways?

To clarify, I want all objects of type A to be able to respond to a static method declared in type A yet still remember their implementation of this static method. I provided two solutions that I have thought of, and I find them sloppy, so I'm asking if there's a better way.

Similar Messages

  • Date on Static Field (good for header page fragment)

    Steps to follow:
    - create a StaticTextField
    - create a SessionBean string property
    - place this code inside SessionBean, see sample below
        public SessionBean1() {
            Date today = new Date();
            DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.FULL);
            myDate = dateFormatter.format(today);
        }- write the following value inside the StaticText-Property-Text
    #{SessionBean1.myDate}

    How's your JavaScript?
    This can be done by, for example, adding a button to be used by your estimator that sets the designated fields to read only.
    See Field properties and look at readonly.

  • Suggestion for Iridium I/O third party tool use in production environment. Is Good or bad to use?

    Hello Everyone,
    we are planing to use Iridium I/O third party tool in one of our critical production environment to improve the performance.
     but i want to know is it recommended  for such type of critical servers?.
    if i use this tool find any performance improvement.

    Hi Baraiya,
    Iridium I/O is certified by Microsoft. It can help to fix SQL Server performance instead of just pointing out performance problems . Benefits of using Iridium include the following aspects. Refer to:
    Iridium I/O for SQL Server.
    •Faster transactions
    •Faster batch jobs
    •Reduced blocking and deadlocking
    •Faster sorting in tempdb
    •Speeds up queries from 3rd Party apps that can't be tuned
    •Speeds up queries that are already "fully tuned"
    •Speeds up the 95% of queries that the DBA never has time to tune
    In addition, there will be no impact on the SQL databases when Iridium is removed. Personally, I recommend you install the Iridium I/O in a test environment, and check if it meets your requirement, then use it in the production server.
    For more details , you can also review this blog:
    SQL SERVER – Iridium I/O – SQL Server Deduplication that Shrinks Databases and Improves Performance.
    Thanks,
    Lydia Zhang

  • Static fields in serialized Vector objects

    just a curious question:
    If I have a Vector filled with Objects of all the same type, and the Object contains a static field, and I then Serialize the Vector, will it still give better performance than if the field wasn't static? Thanks,
    Max

    nevermind - found out the hard way that static fields won't get Serialized

  • Static field changes for both instances

    Whenever I construct a new object with a static field or use a set method on any of the instances of that object, the static field will change to the last modification made. In the case of my program, whenever the static String color field is changed to the last modification made. This only happens with the static fields, the other fields work just fine.
    Why does this problem occur?

    Sorry, I can't understand the question. If you have lots of different objects, all of the same class, they all share one copy of the static field, so if you invoke a method that changes the static field on one instance, all the other instances will see that change.
    if you don't want this behaviour, don't make the field static; then each instance will have its own copy of the field.

  • Non-numeric primary is good or bad for design

    In general, the primary key created using the non-numeric key is good or bad ?  Any specific reason?

    Numeric datatype is good for primary key because :
    1.No need to implicit conversion
    2.NO overhead in using a NUMBER datatype in joins!!
    3.Auto primary key index will be used since there is no conversion require for numeric datatype.
    All I learn and came to know from Sybrand's reply at below link:
    optimum datatype for primary key column O9i - Oracle Database
    Regards
    Girish Sharma

  • Static field initialization

    Ok, I know this was a good practices issue in C++, where order of initializing static fields from different source files was unknown, but I'm not sure if Java is smart enough to figure it out.
    So, say you have in one file
    public class A{
       public static B b = new B();
    }And in the other:
    public class C{
       private static D  d = A.b.getD();
    }Will this always work? Or does it depend on the order in wich classes A and C are loaded.

    jschell wrote:
    In multiple threads on some systems (potentially) the construction of B() is not guaranted before access to 'b' is allowed.Class initialization is synchronized, so the construction of B() should be fully visible to other threads without explicit synchronization or making the field final.
    From JLS 12.4.3:
    Code generators need to preserve the points of possible initialization of a class or interface, inserting an invocation of the initialization procedure just described. If this initialization procedure completes normally and the Class object is fully initialized and ready for use, then the invocation of the initialization procedure is no longer necessary and it may be eliminated from the code-for example, by patching it out or otherwise regenerating the code.So class initialization is attempted whenever the code generator feels it might be the first use of a class.
    And from 12.4.2:
    The procedure for initializing a class or interface is then as follows:
    1. Synchronize (§14.19) on the Class object that represents the class or interface to be initialized. This involves waiting until the current thread can obtain the lock for that object (§17.1).
    2. If initialization is in progress for the class or interface by some other thread, then wait on this Class object (which temporarily releases the lock). When the current thread awakens from the wait, repeat this step.So the class is synchronized on until initialization (which includes all static initializers) finishes. This makes possible the class holder idiom for singletons.

  • Is it necessary to use this. on objects or is it just good practice?

    Is it necessary to use this. on objects or is it just good practice?

    warnerja wrote:
    yawmark wrote:
    Is it necessary to use this. on objects or is it just good practice?It's good practice to use it when it's necessary.
    ~No, it's only necessary to use it when it's necessary.
    It's good practice to use it when it's good practice.<****/>
    <****/>
    <****/>
    (the sound of one hand, clapping)

  • Avoid assigning to servlet static fields without using a shared lock??

    Hi
    i received the following warning on my code, does anyone give me a help on this? Thanks
    "Avoid assigning to servlet static fields from javax.servlet.Service.service () without using a shared lock."
    And my code are as follow:
    public class MyDataSource {
        private static DataSource ds = null;
        public static DataSource getDataSource() throws NamingException, Exception
            if (ds==null){
                   InitialContext ctx = new InitialContext();
                try{
                    synchronized(getDataSource()){
                    if(ds==null){
                        ds = (DataSource) ctx.lookup(SysProperties.ds);
                } catch (Exception ex) {
                    throw new Exception("DBConnection Exception: " +ex.toString());
                }finally{
                        if(ctx !=null){
                            ctx.close();
            return ds;       
    }

    The service method of a servlet is multi-threaded to handle multiple requests. Hence,any static or public fields accessed by the service method should be restricted to a single thread access (for example using synchronized keyword) to make it thread-safe. That is why you are getting the warning message.

  • Reliable Static Routing Backup Using Object Tracking

    Can someone confirm if Reliable Static Routing Using Object Tracking is supported on the Cisco 3850 switch running IOS-XE?  If so, does it require IP Services licensing or will IP Base suffice?
    If it is not supported on the 3850, what about the 3750X running IOS?  Again, would it require IP Services licensing?                  

    Hello
    CCO seems to suggest it does
    http://www.cisco.com/c/en/us/td/docs/ios-xml/ios/ipapp/configuration/xe-3se/3850/iap-xe-3se-3850-book.pdf#page21
    Res
    Paul
    Sent from Cisco Technical Support iPad App

  • How can I share a static field between 2 class loaders?

    Hi,
    I've been googling for 2 days and it now seems I'm not understanding something because nobody seems to have my problem. Please, somebody tell me if I'm crazy.
    The system's architecture:
    I've got a web application running in a SunOne server. The app uses Struts for the MVC part and Spring to deal with business services and DAOs.
    Beside the web app, beyond the application context, but in the same physical server, there are some processes, kind of batch processes that update tables and that kind of stuff, that run once a day. Theese processes are plain Java classes, with a main method, that are executed from ".sh" scripts with the "java" command.
    What do I need to do?
    "Simple". I need one of those Java processes to use one of the web app's service. This service has some DAOs injected by Spring. And the service itself is a bean defined in the Spring configuration file.
    The solution is made-up of 2 parts:
    1. I created a class, in the web app, with a static method that returns any bean defined in the Spring configuration file, or in other words, any bean in the application context. In my case, this method returns the service I need.
    public class SpringApplicationContext implements ApplicationContextAware {
         private static ApplicationContext appContext;
         public void setApplicationContext(ApplicationContext context) throws BeansException {
              appContext = context;
         public static Object getBean(String nombreBean) {
              return appContext.getBean(nombreBean);
    }The ApplicationContext is injected to the class by Spring through the setApplicationContext method. This is set in the Spring configuration file.
    Well, this works fine if I call the getBean method from any class in the web app. But that's not what I need. I need to get a bean from outside the web app. From the "Java batch process".
    2. Why doesn't it work from outside the web app? Because when I call getBean from the process outside the web app, a different class loader is executed to load the SpringApplicationContext class. Thus, the static field appContext is null. Am I right?
    So, the question I need you to please answer me, the question I didn't find in Google:
    How can I share the static field between the 2 class loaders?
    If I can't, how can I load the SpringApplicationContext class, from the "Java batch process", with the same class loader my web app was started?
    Or, do I need to load the SpringApplicationContext class again? Can't I use, from the process, the class already loaded by my web app?
    I' sorry about my so extensive post...
    Thank you very much!

    zibilico wrote:
    But maybe, if the web service stuff gets to complicated or it doesn't fulfill my needs, I'll set up a separate Spring context, that gets loaded everytime I run the "Java batch process". It'll have it's own Spring configuration files (these will be a fragment of the web app's config files), where I'll define only the beans I need to use, say the service and the 2 DAOs, and also the DB connection. Additionally, I'll set the classpath to use the beans classes of the web app. Thus, if the service and DAOs were modified in the app server, the process would load the modified classes in the following execution.You'll almost certainly have to do that even if you do use RMI, Web services etc. to connect.
    What I suggest is that you split your web project into two source trees, the stuff that relates strictly to the web front end and the code which will be shared with the batch. The latter can then be treated as a library used by both the batch and web projects. That can include splitting Spring configuration files into common and specific, the common beans file can be retrieved from the classpath with an include. I regularly split web projects this way anyway, it helps impose decoupling between View/Controller and Model layers.
    On the other hand, you might consider running these batch processes inside the web server on background threads.

  • Is read-only access to a static field correct without volatile/locking?

    Hello,
    I wonder wether the following code is safe:
    static UnicomServerCentral instance;
         public static void setInstance(UnicomServerCentral central)
              synchronized (UnicomServerCentral.class)
                   instance = central;
         public static UnicomServerCentral getInstance()
              UnicomServerCentral central = thisinstance;
              if (central == null)
                   synchronized (UnicomServerCentral.class)
                        central = this.instance;
              return central;
         }The static field instance is already guaranteed to be set. Is this safe?
    Thank you in advance, lg Clemens

    It might be safe in a particular context if there is
    additional synchronization involving the construction
    of the the "central" object and the execution of any
    threads that might call getInstance.Well if getInstance() returns null I simply spin as long as I get a non-null value back - so the only circumstance I could get here null is initialization.
    Since this example is a perfect does-not-work-dcl example I'll search the net for exmplanations.
    Thanks a lot, lg Clemens

  • How to use object collection with linked objects

    <p>Hi,</p><p>I&#39;m using VS2005 Crystal reports in a c# client app (server has database, but client does not have!). So the use of the objects transfered to the client seemed to me a good solution for showing reports on the client. The objects mostly link to several other objects (properties of type <type> or properties of type [] <type>) and the links are correctly configured in database assistant.</p><p>But: Whenever using one of the linked fields, all of the main fields will never show up in the report.</p><p>So, what is the correct way of showing a master / detail report using linked object collections???</p><p> (A small test sample app can be provided upon request)</p><p> TIA</p><p>BP</p>

    What database and connection type are you using? Are you connecting the report directly to the database, or trying to assign the datasource to object data?
    It sounds like you might be trying to use a linked list, collection or other C# construct to pass your data in. This currently isn't supported by the Crystal Reports SDK. You can use a DataSet or a DataTable, and possibly also an IDataReader depending on which version of Crystal Reports you're referencing in your project. Of course you can also connect directly to the database, even if the database isn't on the same machine as the application.
    The way to show master records with detail information is through the use of subreports and linked subreport parameters. Linked subreports take their parameter value from a record in the main report, so that only the data appropriate to that master record is displayed. The guys over in the [report design|SAP Crystal Reports; forum can help you out with this if you have questions on the specifics.

  • Using workspaces for "ALMOST" static data

              Hi,
              The application that we are developing has the following requirement:
              We have a whole bunch of data that is ALMOST static as far as the application is concerned.
              However this data can change infrequently.
              We have two solutions in mind
              1) We are planning to have a StaticDataManager component that will handle the reading/updation of this data.
              All the other components of the application will get the static data from the StaticDataManager
              and cache this data to avoid communication between the components.
              The application will be hosted on a clustered WLS configuration.
              Now suppose an updation takes place, how best can we update all the components that have the cached data?
              2) In case we use Workspaces to cahce this static data, does the cluster configuration take care of
              updating the workspaces in the machines in the cluster?
              TIA!
              Sreeja
              

    If you do like you say and specify servera and then specify serverb
              respectively, then yes the workspace doesn't show the same information
              across the cluster. However, if you always specify the cluster, serverc,
              then no matter which side you update or read from the data is the same. So
              yes, if you specifiy a specific server in the cluster, and not the cluster,
              the data will not replicate across the cluster, and you lose concurrency.
              Let me paste in the output to show you what I am seeing which proves the
              data is being replicated with a single write.
              Tester ver. 1.00.00 ----> Test started...
              Connected successfully using http to ethouic97/198.171.100.107:80
              ws.store(DOG, FIDO)
              Connected successfully using http to ethouic97/198.171.100.106:80
              ws2.fetch(DOG)
              DOG = FIDO
              These are some system outs from the test app below with a few extra system
              outs. Notice if the cluster is always your connection point and not an
              individual server, in this case ethouic97. Then the answer to the original
              first question is YES, you can store near static data in workspaces on a
              cluster to have the data replicated across the cluster. However, you must
              always address the cluster and not the individual servers, in this case
              address ethouic97 never server 106 or 107 directly.
              Jonathon Cano
              "Mike Reiche" <[email protected]> wrote in message
              news:[email protected]...
              >
              > Well, it does look like it works, doesn't it?
              >
              > Now try running the first half on one WLS instance and the other half of a
              different WL instance and
              > specify servera in the first half and serverb in the second half. If the
              workspace is replicated it should
              > work.
              >
              > It's broken now. Not really. Regardless of where the t3 connection is
              made, the workspace is
              > in the local WL instance.
              >
              > Mike
              >
              >
              > "Jonathon Cano" <[email protected]> wrote:
              > >Details:
              > >We are using a DNS cluster where serverc actually maps to servers a and
              b.
              > >If you set the workspace to SCOPE_SERVER, and use a t3client connection
              to
              > >the serverc, it can not be servera or serverb directly, then the
              workspace
              > >is updated or read from the data is persisted across both sides of the
              > >cluster. All reads and writes must be done using the cluster name for
              this
              > >to work. I use this to manage fail-over for some Vitria subscribers I
              have
              > >runnig at startup. I have a tester I wrote which works, here is the
              code:
              > >
              > > private void testWorkSpaces() {
              > >
              > > try {
              > >
              > > T3User userInfo = new T3User("system","password");
              > >
              > > T3Client t3 = new T3Client("http://cluster:80",userInfo);
              > > t3.connect();
              > >
              > > WorkspaceDef ws =
              >
              >t3.services.workspace().getWorkspace().getWorkspace("test",WorkspaceDef.OPE
              N
              > >,WorkspaceDef.SCOPE_SERVER);
              > > ws.store("DOG", "FIDO");
              > >
              > > t3.disconnect();
              > >
              > > T3Client t32 = new T3Client("http://cluster:80",userInfo);
              > > t32.connect();
              > >
              > > WorkspaceDef ws2 =
              >
              >t32.services.workspace().getWorkspace().getWorkspace("test",WorkspaceDef.OP
              E
              > >N,WorkspaceDef.SCOPE_SERVER);
              > > String dogName = (String) ws2.fetch("DOG");
              > >
              > >
              > > t32.disconnect();
              > >
              > > System.out.println(dogName);
              > >
              > > } catch (Exception e) {
              > > System.out.println("Test Work Spaces Failed.);
              > > e.printStackTrace();
              > > }
              > >
              > > }
              > >
              > >The first t3client connection echos out that it is connecting to servera.
              > >The second t3client connection echos out that it is connecting to
              serverb.
              > >However, the data being returned is the name FIDO which was written to
              the
              > >workspace when connected to servera. Thus, as long as you are connecting
              to
              > >the cluster, you get replication of data across cluster for workspaces.
              > >
              > >WLS 5.1
              > >
              > >Jonathon Cano
              > >
              > >
              > >"mreiche" <[email protected]> wrote in message
              > >news:[email protected]...
              > >>
              > >> >I am confused.
              > >>
              > >> Yes.
              > >>
              > >> >So why was the original answer to workspaces being used for clustering
              > >near static data NO?
              > >>
              > >> Because that's what the documentation says?
              > >>
              > >> Are you really, really sure it's being propagated? Or perhaps it's just
              > >being updated identically on both instances?
              > >>
              > >> Mike
              > >>
              > >> "Jonathon Cano" <[email protected]> wrote:
              > >> >I am confused. I am storing data in the workspaces right now, and I
              am
              > >> >using this data in a cluster. I can update the data in the cluster
              just
              > >> >fine, and both sides of the cluster are being updated. So why was the
              > >> >original answer to workspaces being used for clustering near static
              data
              > >NO?
              > >> >
              > >> >Jonathon Cano
              > >> >
              > >> >"Tao Zhang" <[email protected]> wrote in message
              > >> >news:[email protected]...
              > >> >>
              > >> >> But the problem is whether you want Exactly-once-per-cluster data or
              > >not.
              > >> >> If not, you can deploy the data object into each server in the
              cluster,
              > >> >but in the data object, it contains the logic of updating itself.
              > >> >> Otherwise, you have to make it a pinned service.
              > >> >>
              > >> >> It's hard to describe here.
              > >> >>
              > >> >> Hope the document can solve your problem.
              > >> >>
              > >> >> http://www.weblogic.com/docs51/classdocs/API_jndi.html#user
              > >> >>
              > >> >> Good Luck.
              > >> >>
              > >> >> Tao Zhang
              > >> >>
              > >> >> "Sreeja" <[email protected]> wrote:
              > >> >> >
              > >> >> >Thanks. Can you please elaborate on the solutions 1 and 2. We are
              > >trying
              > >> >to eliminate the
              > >> >> > usage of 3 - entity beans - since we do not want the components
              using
              > >> >the data to contact
              > >> >> >the entity bean every time they need the static data - as this
              would
              > >> >result in remote calls
              > >> >> >for every usage.
              > >> >> >Sreeja
              > >> >> >
              > >> >> >"Tao Zhang" <[email protected]> wrote:
              > >> >> >>No, the workspace can't be clustered, the data can't be propagated
              to
              > >> >other
              > >> >> >>servers in the cluster.
              > >> >> >>Of course , you can select one server as the data holder and other
              > >> >servers
              > >> >> >>will be t3 client. But it's time consuming to
              > >> >> >>connect to the data holder server.
              > >> >> >>Possible solutions:
              > >> >> >>1. RMI.
              > >> >> >>Deploy the rmi as pinned service which hold the data.
              > >> >> >>2. jndi
              > >> >> >>The data can be propagated by jndi's default behavior.
              > >> >> >>3. database or entity bean.
              > >> >> >>
              > >> >> >>Hope this can help.
              > >> >> >>
              > >> >> >>Tao Zhang
              > >> >> >>
              > >> >> >>Sreeja <[email protected]> wrote in message
              > >> >> >>news:[email protected]...
              > >> >> >>>
              > >> >> >>> Hi,
              > >> >> >>>
              > >> >> >>> The application that we are developing has the following
              > >requirement:
              > >> >> >>> We have a whole bunch of data that is ALMOST static as far as
              the
              > >> >> >>application is concerned.
              > >> >> >>> However this data can change infrequently.
              > >> >> >>> We have two solutions in mind
              > >> >> >>> 1) We are planning to have a StaticDataManager component that
              will
              > >> >handle
              > >> >> >>the reading/updation of this data.
              > >> >> >>> All the other components of the application will get the static
              > >data
              > >> >from
              > >> >> >>the StaticDataManager
              > >> >> >>> and cache this data to avoid communication between the
              components.
              > >> >> >>> The application will be hosted on a clustered WLS configuration.
              > >> >> >>> Now suppose an updation takes place, how best can we update all
              the
              > >> >> >>components that have the cached data?
              > >> >> >>>
              > >> >> >>> 2) In case we use Workspaces to cahce this static data, does the
              > >> >cluster
              > >> >> >>configuration take care of
              > >> >> >>> updating the workspaces in the machines in the cluster?
              > >> >> >>>
              > >> >> >>> TIA!
              > >> >> >>> Sreeja
              > >> >> >>>
              > >> >> >>
              > >> >> >>
              > >> >> >
              > >> >>
              > >> >
              > >> >
              > >>
              > >
              > >
              >
              

  • 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

Maybe you are looking for

  • How to make a supreport to show its that in a new page

    <p>Dear all,</p><p>     I am using Crystal Report XI Release 2 with a VB6 application. I have many reports and want do show then like only one to make a big report of all stuff. I try using subreports but I want that each subreport begins in a new pa

  • How to create an email account??

    Hi, How to create a new email account by using Java program. I'm able to send and receive the mails to and from an existing account by using JavaMail. But I dont know how to create an account. Please help me... thanks in advance

  • How to create magnification effect around the mouse.

    Hi everybody, I have a problem which really freaks me out at the moment. I am working on an image sorting software and I try to implement a magnification glass. The problem seems to be easy: Create the Region OF Interest, "zoom" in ,display result at

  • WD My Book Studio Edition, bootable?

    Can Tiger/Leopard boot off a WD My Book Studio Edition's FW400/800/eSATA? I'm planning to buy one due to it being cheaper than separate storage and enclosure.

  • Ichat av for PC users?

    Is there a free download out there that is a program comparable to that of ichat? I need a program for a wecam that will work with macs and pcs. Last year there was a program out called Sightseen (i think), does anyone know what happened to that?