Design Pattern and ABAP Objects

Hello Friends,
I would like to know, if ABAP Objects can be used to do pattern oriented programming ?
For example GANG of four has provided almost more then 30 design pattern ( MVC, singelton, Obserable, FACADE,,,etc) can we implement patterns using ABAP ??
Many thanks
Haider Syed

Hi,
Take a look at the following site:
http://patternshare.org/
It has all the basic patterns from the GOF and a lot more. I can recommend the ones from Martin Fowler but be sure you start with the ones from the GOF.
All patterns are described by using UML so it's very easy to translate them into ABAP OO code.
Regarding your other question. For the observer pattern I used an interface which the SAP had already created if_cm_observer and created my own abstract observable class. The observable class is nearly a 100% copy of the java.util. one
regards
Thomas

Similar Messages

  • Design Patterns in ABAP.

    Hi,
    I want to know about the Design Patterns in ABAP.
    Regards,
    Sourav

    hi sourdi
    Below are the list of Design pattern in abap .
    Singleton: ensuring single class instantiation
    Adapter: making class interfaces compatible
    Factory: encapsulating object creation
    MVC: decoupling business logic from the view
    Facade: providing a simplified interface
    Composite: treating individual objects and compositions uniformly
    Decorator: forming a dynamic chain of components to be used as one by the client
    regards
    chinnaiya P

  • Design patterns,about value object ,how?why?could you give me a soluttion

    design patterns,about value object ,how?why?could you give me a soluttion
    use value object in ejb,thanks
    i want not set/get the value in ejb,find the method to solve it ,use value
    object ?
    how? thanks.

    Hai
    Enter your telephone number here, at the top it will say your Exchange, Phone and cabient number. If it doesn't mention cabinet that means you are directly connected to the exchange and not via PCP.
    If you are connected to a cabinet and it doesn't say FTTC is available, ask your neighbor to-do the same test (they have 2 be infinity connected). If they are, then proceed to contact the moderators here. Though it could not be showing because all the ports have been used up in the FTTC Cabinet.
    If this helped you please click the Star beside my name.
    If this answered your question please click "Mark as Accepted Solution" below.

  • ABAP and ABAP Objects

    Hi ,
    What is the exact difference between ABAP and ABAP Objects?

    Hi,
    Look at:
    <a href="/people/dirk.feeken/blog/2007/07/06/abap-trial-version-for-newbies-part-17--your-first-abap-object Trial Version for Newbies: Part 17 - Your first ABAP Object</a>
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1591ec90-0201-0010-3ba8-cdcd500b17cf">ABAP Code Sample for Objects</a>
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/2503f09c-0801-0010-dc89-80bab376e4b8">Object Oriented ABAP - Local and Global classes</a>
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b6cae890-0201-0010-ef8b-f970a9c41d47">ABAP Code Sample to Learn Basic Concept of Object-Oriented Programming</a>
    <a href="https://sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/37c5db90-0201-0010-3a9b-d0a5288f3c15">Eight Reasons Why Every ABAP Developer Should Give ABAP Objects a Second Look</a>
    <a href="https://sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/3e59b790-0201-0010-88aa-bc8a7f95f6fb">Why use ABAP Objects</a>
    <a href="https://media.sdn.sap.com/public/eclasses/teched04/ABAP151_files/Default.htm#nopreload=1">ABAP Objects for Java Developers</a>
    Regards.
    Marcelo Ramos

  • Help regarding ABAP and ABAP Objects

    Dear all,
    I am very new in abap and abap objects. But i have some expr. in other language..specialy development. Right now i am working for srm module...So i want to move my self into abap object and specialy in workflow...Please provide me help regarding this...along with the starting point for this.
    Best Regards
    Vijay Patil

    hi
    Object Oriented prg
    A programming technique in which solutions reflect real world objects
    What are objects ?
    An object is an instantiation of a class. E.g. If “Animal” is a class, A cat
    can be an object of that class .
    With respect to code, Object refers to a set of services ( methods /
    attributes ) and can contain data
    What are classes ?
    A class defines the properties of an object. A class can be instantiated
    as many number of times
    Advantages of Object Orientated approach
    Easier to understand when the system is complex
    Easy to make changes
    Encapsulation - Can restrict the visibility of the data ( Restrict the access to the data )
    Polymorphism - Identically named methods behave differently in different classes
    Inheritance - You can use an existing class to define a new class
    Polymorphism and inheritance lead to code reuse
    Have a look at these good links for OO ABAP-
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://www.allsaplinks.com/
    http://www.sap-img.com/
    http://www.sapgenie.com/
    http://help.sap.com
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com.
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.sapgenie.com/abap/controls/index.htm
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    check the below links lot of info and examples r there
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.geocities.com/victorav15/sapr3/abap_ood.html
    http://www.brabandt.de/html/abap_oo.html
    Check this cool weblog:
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://www.allsaplinks.com/
    http://www.sap-img.com/
    http://www.sapgenie.com/
    http://help.sap.com
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.sapgenie.com/abap/controls/index.htm
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    these links
    http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm
    For funtion module to class
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm
    for classes
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
    for methods
    http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
    for inheritance
    http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
    for interfaces
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
    For Materials:
    1) http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291
    2) http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    3) http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
    6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
    7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
    8) http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
    1) http://www.erpgenie.com/sap/abap/OO/index.htm
    2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    Hope this helps
    if it helped, you can acknowledge the same by rewarding
    regards
    ankit

  • Business Objects And ABAP Objects ?

    hi all!
    May be this is a repitition but still :
    Can anyone give me a clarification on Business objects and abap objects in termas of difference-relations b/w them.
    regards
    sachin

    Hi Sachin,
    Please refer the below links,
    Business Object Repository and Class Library
    business objects
    Hope this helps.
    Regards,
    Hema.
    Reward points if it is useful.

  • How to implement Strategy pattern in ABAP Objects?

    Hello,
    I have a problem where I need to implement different algorithms, depending on the type of input. Example: I have to calculate a Present Value, sometimes with payments in advance, sometimes payment in arrear.
    From documentation and to enhance my ABAP Objects skills, I would like to implement the strategy pattern. It sounds the right solution for the problem.
    Hence I need some help in implementing this pattern in OO. I have some basic OO skills, but still learning.
    Has somebody already implemented this pattern in ABAP OO and can give me some input. Or is there any documentation how to implement it?
    Thanks and regards,
    Tapio

    Keshav has already outlined required logic, so let me fulfill his answer with a snippet
    An Interface
    INTERFACE lif_payment.
      METHODS pay CHANGING c_val TYPE p.
    ENDINTERFACE.
    Payment implementations
    CLASS lcl_payment_1 DEFINITION.
      PUBLIC SECTION.
      INTERFACES lif_payment.
      ALIASES pay for lif_payment~pay.
    ENDCLASS.                 
    CLASS lcl_payment_2 DEFINITION.
      PUBLIC SECTION.
      INTERFACES lif_payment.
      ALIASES pay for lif_payment~pay.
    ENDCLASS.                   
    CLASS lcl_payment_1 IMPLEMENTATION.
      METHOD pay.
        "do something with c_val i.e.
        c_val = c_val - 10.
      ENDMETHOD.                   
    ENDCLASS.                  
    CLASS lcl_payment_2 IMPLEMENTATION.
      METHOD pay.
        "do something else with c_val i.e.
        c_val = c_val + 10.
      ENDMETHOD.  
    Main class which uses strategy pattern
    CLASS lcl_main DEFINITION.
      PUBLIC SECTION.
        "during main object creation you pass which payment you want to use for this object
        METHODS constructor IMPORTING ir_payment TYPE REF TO lif_payment.
        "later on you can change this dynamicaly
        METHODS set_payment IMPORTING ir_payment TYPE REF TO lif_payment.
        METHODS show_payment_val.
        METHODS pay.
      PRIVATE SECTION.
        DATA payment_value TYPE p.
        "reference to your interface whcih you will be working with
        "polimorphically
        DATA mr_payment TYPE REF TO lif_payment.
    ENDCLASS.                  
    CLASS lcl_main IMPLEMENTATION.
      METHOD constructor.
        IF ir_payment IS BOUND.
          me->mr_payment = ir_payment.
        ENDIF.
      ENDMETHOD.                  
      METHOD set_payment.
        IF ir_payment IS BOUND.
          me->mr_payment = ir_payment.
        ENDIF.
      ENDMETHOD.                  
      METHOD show_payment_val.
        WRITE /: 'Payment value is now ', me->payment_value.
      ENDMETHOD.                  
      "hide fact that you are using composition to access pay method
      METHOD pay.
        mr_payment->pay( CHANGING c_val = payment_value ).
      ENDMETHOD.                   ENDCLASS.                  
    Client application
    PARAMETERS pa_pay TYPE c. "1 - first payment, 2 - second
    DATA gr_main TYPE REF TO lcl_main.
    DATA gr_payment TYPE REF TO lif_payment.
    START-OF-SELECTION.
      "client application (which uses stategy pattern)
      CASE pa_pay.
        WHEN 1.
          "create first type of payment
          CREATE OBJECT gr_payment TYPE lcl_payment_1.
        WHEN 2.
          "create second type of payment
          CREATE OBJECT gr_payment TYPE lcl_payment_2.
      ENDCASE.
      "pass payment type to main object
      CREATE OBJECT gr_main
        EXPORTING
          ir_payment = gr_payment.
      gr_main->show_payment_val( ).
      "now client doesn't know which object it is working with
      gr_main->pay( ).
      gr_main->show_payment_val( ).
      "you can also use set_payment method to set payment type dynamically
      "client would see no change
      if pa_pay = 1.
        "now create different payment to set it dynamically
        CREATE OBJECT gr_payment TYPE lcl_payment_2.
        gr_main->set_payment( gr_payment ).
        gr_main->pay( ).
        gr_main->show_payment_val( ).
      endif.
    Regads
    Marcin

  • Which Design Pattern and how to design using OOP this scenario

    I am having trouble designing a module, can anybody help me?
    Because it will be hard to maintain this kind of module, I also think that this can test my skill of design pattern usage.
    Requirement
    This is basically an agricultural project (web application). I need to design a module where some calculation takes place.
    There are different crops involved like maize, tomato, okra etc. Each of these crops has different traits.
    Each trait has a measurement scale which lies in integer like 200-1000. Now let's say I have planted the crop and done measurement noted down the traits. Now I want to do some sort of measurement. Some measurements are simple and some are complex.
    Example
    Lets take an example of crop maize. I have recorded observations for 15 traits. (We'll use trait1-trait15 as examples, the actual name can be like plt_ht, yld, etc.)
    I recorded 5 observations for each trait:
    trait1 trait2 trait3 trait5 trait6..... trait15
    01,02,03,04 01,02,03,04 01,02,03,04
    User logs into system and selects his crops and enters data for these observations. I have to calculate either average or sum of the data entered for each trait.
    Complexity / centre of the problem
    So far it's simple but complexity comes when I have some different formulas for some of the traits.
    Example: trait YLD has a formula based on which I have to calculate its value, which may also depend on some other traits. Each different crop can have different traits.
    All this I am able to do - whenever user selects crop I will check for those specific traits and do calculations (if it's not a special trait then I either average or sum it, based on db entry), but there is a lot of hard coding.
    I would like to have suggestions on a better way of handling this.
    My code needs to handle both simple and complex calculations.
    Simple calculations are easy, I have take average of value entered for trait.
    The problem comes when I have to do complex calculations, since each crop have different traits with their own formulas, so to calculate I have to check for crop and then for complex trait. So I have to hardcode the trait name of complex traits.
    Can any tell me how I can design this using Java oops [?!?] so that I can make it generic?
    I have about 10 different crops. Some calculations are specific to crops, so there will be lot of code like the if below:
    hasZeroValue = (HashMap<String, ArrayList<String>>) dataValues[1];
    } else if(cropId.equalsIgnoreCase("MZ") && traitName.equalsIgnoreCase("Shelling")) {
        avg=HybridTestDataUtility.calculateAvg(traitName, dataPoint, dataTraits, traitValues,dataPvalues, dataPoint, type);
        avg=avg*dataPoint;
        traitAvg=getMaizeYeild(traitName, traitAvg, population, avg, hybrid, area);
    } else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("YLDGM")) {
        avg=HybridTestDataUtility.calculateAvg(traitName, dataPoint, dataTraits, traitValues,dataPvalues, dataPoint, type);
        //avg=avg*dataPoint;
        Object[] dataValues=getOKRAYield(traitName, traitAvg, population, avg, dividend,hasZeroValue,hybrid,repl);
        traitAvg = (HashMap<String, Float>) dataValues[0];
        hasZeroValue = (HashMap<String, ArrayList<String>>) dataValues[1];
    } else if(cropId.equalsIgnoreCase("HP") && traitName.equalsIgnoreCase("w1-w10")) {
        avg=HybridTestDataUtility.calculateAvg(traitName, dataPts, dataTraits, traitValues,dataPvalues, dataPoint, type);
        avg=avg*dataPoint;
        Object[] dataValues=getHotPepperYield(traitName, traitAvg, population, avg,dividend,hasZeroValue,hybrid,repl);
        traitAvg = (HashMap<String, Float>) dataValues[0];
        hasZeroValue = (HashMap<String, ArrayList<String>>) dataValues[1];
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("TLSSG_70")) {
        traitAvg=calculateTLCV(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues,50);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("TLSSG_100")) {
        traitAvg=calculateTLCV(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues,50);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("YVMV_60")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("YVMV_90")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("YVMV_120")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("ELCV_60")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("ELCV_90")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("TO") && traitName.equalsIgnoreCase("ELCV_120")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("YVMV_60")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("YVMV_90")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg,dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("YVMV_120")) {
        traitAvg=tomatoYVMVCalculation(traitName, traitAvg, dataPoint, dataTraits, hybrid, repl, traitValues, dataPvalues);
    } else if(cropId.equalsIgnoreCase("OK") && traitName.equalsIgnoreCase("ELCV_60")) {Can anybody think of a way to make a generic approach to this?

    There are crops and each crop have traits , traits are actually a mesuremet
    scale to decide growth of a seed of a particular crop.
    This module is to for planters to observe growth of seeds sowed of certain
    crops and take down n no of observation for each trait and upload in csv format.Once they enter
    data i have to either avg out the values or sum the values or sometimes
    there are more complex function that i have to apply it may differe for each
    trait .This is the whole module about.Just to give an idea about how they
    will enter data
    Hyubrid(seed) trait1 trait2 trait3 trait5 trait6..... trait15
    Hybrid1 01 02 03 04 01
    HYbrid2 04 06 08 04 01
    HYbrid2 04 06 08 04 01
    HYbrid2 04 06 08 04 01
    HYbrid2 04 06 08 04 01
    Once they enter data in this format i have to give result something like
    this.
    Here avg colum does not necessaryly mean avg it can be sum or any formula
    based resutl.Hybrid is the seed for which they record the observation.
    I have shown avg column only for two tratis it is actually for all the
    traits.
    Hyubrid(seed) trait1 Avg trait2 avg trait3 trait5 trait6..... trait15
    Hybrid1 01 01 02 04 03 04 01
    HYbrid2 04 04 06 10 08 04 01
    HYbrid2 04 04 06 12 08 04 01
    HYbrid2 04 04 06 14 08 04 01
    HYbrid2 04 04 06 12 08 04 01
    Hope this clarifies atleat a but
    The data are not correctly indented but there is no way i can format it.

  • SmartForms and ABAP Objects

    Hi all,
    I'm trying to use ABAP Objects with smartforms. The thing is that whenever I need to display an object attribute, I have to call a getter method (say object->getSomeAttribute for example), assign the return to a global variable in the smartform, then assign that variable to the text node. I would like to know if there is a way to avoid this and do like we usually  would do for field in a structure, i.e. assign sommeStrucutre-someField directly to a text node without using a global variable. Thank you in advance.

    Hi,
    Look at:
    <a href="/people/dirk.feeken/blog/2007/07/06/abap-trial-version-for-newbies-part-17--your-first-abap-object Trial Version for Newbies: Part 17 - Your first ABAP Object</a>
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1591ec90-0201-0010-3ba8-cdcd500b17cf">ABAP Code Sample for Objects</a>
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/2503f09c-0801-0010-dc89-80bab376e4b8">Object Oriented ABAP - Local and Global classes</a>
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b6cae890-0201-0010-ef8b-f970a9c41d47">ABAP Code Sample to Learn Basic Concept of Object-Oriented Programming</a>
    <a href="https://sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/37c5db90-0201-0010-3a9b-d0a5288f3c15">Eight Reasons Why Every ABAP Developer Should Give ABAP Objects a Second Look</a>
    <a href="https://sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/3e59b790-0201-0010-88aa-bc8a7f95f6fb">Why use ABAP Objects</a>
    <a href="https://media.sdn.sap.com/public/eclasses/teched04/ABAP151_files/Default.htm#nopreload=1">ABAP Objects for Java Developers</a>
    Regards.
    Marcelo Ramos

  • Data Lista Handler Design Pattern and paging queries

    I'm using Toplink in an MVC (Regular Beans, JSP and Struts) application. I'm not using ADF. At least not until i make up my mind on the features-portability tradeoff.
    Anyway, my application will have to use queries to show the data to the user. This can easily be accomplished by putting the search parameters on my jsp and using ReadAllQuery to compose my query.
    My problem is that the result can return a large amount of records and show all this records at once on the jsp might take a time the user won't be willing to wait. That's when paging the results will come handy.
    In another application of mine i use paging manipulating the rownum of the query, but in that case, i had control of the whole sql statement. As this is the first time i'm working with Toplink, i'm feeling that can't be done.
    There's the Data List Handler design pattern too, but that one also manipulates the sql statement.
    I'm wondering now whether paging can be accomplished using Toplink..? Will i have to use ADF...? This kind of stuff.
    Thanks a lot to all.
    - Eduardo

    Eduardo,
    What you need to do is use Cursors in TopLink.Scrollable cursors enable you to scroll through a result set from the database without reading the whole result set in a single database read. The ScrollableCursor class implements the Java ListIterator interface to allow for direct and relative access within the stream. Scrollable cursors also enable you to scroll forward and backward through the stream.
    Here is an example:
    ReadAllQuery query = new ReadAllQuery();
    query.setReferenceClass(Employee.class);
    query.useScrollableCursor();
    ScrollableCursor cursor = (ScrollableCursor) session.executeQuery(query);
    while (cursor.hasNext()) {
    System.out.println(cursor.next().toString());
    cursor.close();
    I hope this answers your question.
    Deepak

  • Design Patterns and J2mE

    Hey,
    I do wanna know if is recommendable to use a Java Design Pattern (like Singleton, Fa�ade, etc)... in a J2ME application. I mean, a colleague of mine made a j2me application using these kind of technologies, but, when he installed in his cell phone, the application occuppied much memory. So, another guy told me that due to the limited memory space we find on these devices it's better for us to use only the MVC idea. So, is it recommendable for me to use this kind of resources???
    Thanks!

    Hi,
    it is a good programming practice to use Design patterns. But too much of design patterns results in more classes which will be a problem in j2me sometimes.
    Most of the MIDP classes uses Singleton and abstract design patterns

  • String.matches vs Pattern and Matcher object

    Hi,
    I was trying to match some regex using String.matches but for me it is not working (probably I am not using it the way it should be used).
    Here is a simple example:
    /* This does not work */
    String patternStr = "a";
    String inputStr = "abc";
    if(inputStr.matches( "a" ))
    System.out.println("String matched");
    /* This works */
    Pattern p = Pattern.compile( "a" );
    Matcher m = p.matcher( "abc" );
    boolean found = false;
    while(m.find())
    System.out.println("Matched using Pattern and Matcher");
    found = true;
    if(!found)
    System.out.println("Not matching with Pattern and Matcher");
    Am I not matches method of String class properly?
    Please throw some lights on this.
    Thank you.

    String.matches looks at the whole string.
    bsh % "abc".matches("a");
    <false>
    bsh % "abc".matches("a.*");
    <true>

  • First try with ALV Grid and Abap Objects

    Hi,
    this is my first try to write a simple report which just reads a textfile and display it in an ALV Grid. As a basis, I used some examples from SDN, but it did not work as expected
    I would like just to use a docking container. I do not need a separate area for the ALV Grid. The report gives no syntax errors, but it just display the report title, nothing else. SAP R/3 Release is 4.7. Below is the source code of the report. Any idea what is missing?
    *& Report  Z_PLAN_TEXT_UPLOAD                                          *
    REPORT z_plan_text_upload.
    INCLUDE <icon>.
    * Data Declaration
    DATA:
      gf_dynnr TYPE sy-dynnr,
      gf_repid TYPE sy-repid.
    DATA:
      go_docking_container TYPE REF TO cl_gui_docking_container,
      go_alv_grid TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_fieldcat TYPE lvc_t_fcat,
      gs_fieldcat LIKE LINE OF gt_fieldcat.
    TYPES:
      BEGIN OF gy_text_input,
        firma(20)           TYPE c,
        kostenstelle(20)    TYPE c,
        datenart1(10)       TYPE c,
        planjahr(10)        TYPE c,
    *    planperiode         TYPE co_perio,
        planperiode(5)      TYPE c,
        datenart2(10)       TYPE c,
        planungposition(10) TYPE c,
    *    kostenart           TYPE koart,
        kostenart(10)       TYPE c,
    *    planbetrag          TYPE bapicurr_d,
        planbetrag(20)      TYPE c,
      END OF gy_text_input.
    DATA:
      gt_text_input TYPE TABLE OF gy_text_input,
      gs_text_input LIKE LINE OF gt_text_input.
    * Local Class Definition
    * Local Class Implementation
    * Selection-Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1
      WITH FRAME TITLE text-001.
    SKIP.
    PARAMETERS:
      gp_file TYPE localfile,
      gp_head TYPE checkbox DEFAULT 'X'.
    SKIP.
    PARAMETERS:
      gp_gjahr LIKE coep-gjahr,
      gp_versn LIKE coep-versn.
    SELECTION-SCREEN END OF BLOCK b1.
    * Initialization
    INITIALIZATION.
      DATA:
        lf_sapworkdir TYPE string.
      CALL METHOD cl_gui_frontend_services=>get_sapgui_workdir
        CHANGING
          sapworkdir            = lf_sapworkdir
        EXCEPTIONS
          get_sapworkdir_failed = 1
          cntl_error            = 2
          error_no_gui          = 3
          not_supported_by_gui  = 4
          OTHERS                = 5.
      IF sy-subrc <> 0 OR lf_sapworkdir = ''.
        CALL METHOD cl_gui_frontend_services=>directory_get_current
          CHANGING
            current_directory            = lf_sapworkdir
          EXCEPTIONS
            directory_get_current_failed = 1
            cntl_error                   = 2
            error_no_gui                 = 3
            not_supported_by_gui         = 4
            OTHERS                       = 5.
        CALL METHOD cl_gui_cfw=>flush.
      ENDIF."sy-subrc <> 0 OR sapworkdir = ''
      gp_file = lf_sapworkdir.
      gf_dynnr = sy-dynnr.
      gf_repid = sy-repid.
    * At Selection-Screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR gp_file.
      DATA:
        lt_filetable TYPE filetable,
        ls_filetable LIKE LINE OF lt_filetable,
        lt_rc TYPE i.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
    *  EXPORTING
    *    WINDOW_TITLE            =
    *    DEFAULT_EXTENSION       =
    *    DEFAULT_FILENAME        =
    *    FILE_FILTER             =
    *    INITIAL_DIRECTORY       =
    *    MULTISELECTION          =
    *    WITH_ENCODING           =
        CHANGING
          file_table              = lt_filetable
          rc                      = lt_rc
    *    USER_ACTION             =
    *    FILE_ENCODING           =
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 4
          OTHERS                  = 5.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      READ TABLE lt_filetable INDEX 1
        INTO
          ls_filetable.
      gp_file = ls_filetable-filename.
      CALL METHOD cl_gui_cfw=>flush.
    * Start-Of-Selection
    START-OF-SELECTION.
      DATA:
        lf_filename LIKE filename-fileintern.
      lf_filename = gp_file.
      CALL FUNCTION 'FILE_READ_AND_CONVERT_SAP_DATA'
        EXPORTING
          i_filename                 = lf_filename
          i_servertyp                = 'PRS '
          i_fileformat               = 'TXT'
    *     I_FIELD_SEPERATOR          =
          i_line_header              = gp_head
    *   IMPORTING
    *     E_BIN_FILELENGTH           =
       TABLES
         i_tab_receiver             = gt_text_input
       EXCEPTIONS
         file_not_found             = 1
         close_failed               = 2
         authorization_failed       = 3
         open_failed                = 4
         conversion_failed          = 5
         OTHERS                     = 6.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *------ Build the Field Catalog ---------------------------------------*
      PERFORM build_fieldcatalog
        CHANGING gt_fieldcat.
    *------ Create the docking container ----------------------------------*
      IF go_docking_container IS INITIAL.
        CREATE OBJECT go_docking_container
          EXPORTING
    *      PARENT                      =
            repid                       = gf_repid
            dynnr                       = gf_dynnr
    *     SIDE                        = go_docking_container->DOCK_AT_bottom
    *      EXTENSION                   = 200
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      CAPTION                     =
    *      METRIC                      = 0
    *      RATIO                       =
    *      NO_AUTODEF_PROGID_DYNNR     =
    *      NAME                        =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF."go_docking_container IS INITIAL
    *------ Create the ALV Grid -------------------------------------------*
      IF go_alv_grid IS INITIAL.
        CREATE OBJECT go_alv_grid
          EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
            i_parent          = go_docking_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF."go_alv_grid is initial
    *------ Call ALV Grid -------------------------------------------------*
      CALL METHOD go_alv_grid->set_table_for_first_display
    *     EXPORTING
    *      I_BUFFER_ACTIVE               =
    *      I_BYPASSING_BUFFER            =
    *      I_CONSISTENCY_CHECK           =
    *      I_STRUCTURE_NAME              =
    *      IS_VARIANT                    =
    *      I_SAVE                        =
    *      I_DEFAULT                     = 'X'
    *      IS_LAYOUT                     =
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
    *      IT_TOOLBAR_EXCLUDING          =
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = gt_text_input
          it_fieldcatalog               = gt_fieldcat
    *      IT_SORT                       =
    *      IT_FILTER                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *&      Form  build_fieldcatalog
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcatalog
      CHANGING
        pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      ls_fcat-fieldname = 'FIRMA' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Firma' .
      ls_fcat-seltext = 'Firma' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENSTELLE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Kostenstelle' .
      ls_fcat-seltext = 'Kostenstelle' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART1' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart1' .
      ls_fcat-seltext = 'Datenart1' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANJAHR' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planjahr' .
      ls_fcat-seltext = 'Planjahr' .
      APPEND ls_fcat TO pt_fieldcat .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANPERIODE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '5' .
      ls_fcat-coltext = 'Planperiode' .
      ls_fcat-seltext = 'Planperiode' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART2' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart2' .
      ls_fcat-seltext = 'Datenart2' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANUNGSPOSITION' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planungsposition' .
      ls_fcat-seltext = 'Planungsposition' .
      APPEND ls_fcat TO pt_fieldcat .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENART' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Kostenart' .
      ls_fcat-seltext = 'Kostenart' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANBETRAG' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Planbetrag' .
      ls_fcat-seltext = 'Planbetrag' .
      APPEND ls_fcat TO pt_fieldcat .
    ENDFORM.                    "build_fieldcatalog

    I have added some more functionality to my report. The good thing is, the report works as it should.
    BUT, I'm not really sure, whether this is a good (correct) design. The report works the following way:
    1. Read planning data form text file into internal table
    2. Display the internal table
    3. Convert the data and display the converted result
    4. Post the converted data to the system
    5. Display log with messages
    The main thing is, I would like to know, do i really need two dynros, to display the two different internal tables or is it possible just to use one ALV-Grid? I was not able to find another solution. Any comment or help to the report is appreciated.
    *& Report  Z_PLAN_TEXT_UPLOAD_TEST                                     *
    REPORT z_plan_text_upload_test.
    INCLUDE <icon>.
    * Data Declaration
    DATA:
      gf_okcode TYPE ui_func,
      gf_balloghndl TYPE balloghndl.
    DATA:
      go_docking_container TYPE REF TO cl_gui_docking_container,
      go_alv_grid_0100 TYPE REF TO cl_gui_alv_grid,
      go_alv_grid_0200 TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_fieldcat TYPE lvc_t_fcat,
      gs_fieldcat LIKE LINE OF gt_fieldcat.
    TYPES:
      BEGIN OF gy_text_input,
        firma(20)            TYPE c,
        kostenstelle(20)     TYPE c,
        datenart1(10)        TYPE c,
        planjahr(10)         TYPE c,
    *    planperiode         TYPE co_perio,
        planperiode(5)       TYPE c,
        datenart2(10)        TYPE c,
        planungsposition(10) TYPE c,
    *    kostenart           TYPE koart,
        kostenart(10)        TYPE c,
    *    planbetrag          TYPE bapicurr_d,
        planbetrag(20)       TYPE c,
      END OF gy_text_input.
    DATA:
      gt_text_input TYPE TABLE OF gy_text_input,
      gs_text_input LIKE LINE OF gt_text_input.
    * Bapi Strukturen
    DATA:
      gs_headerinfo TYPE bapiplnhdr,
      gt_indexstructure TYPE TABLE OF bapiacpstru,
      gs_indexstructure LIKE LINE OF gt_indexstructure,
      gt_coobject TYPE TABLE OF bapipcpobj,
      gs_coobject LIKE LINE OF gt_coobject,
      gt_pervalue TYPE TABLE OF bapipcpval,
      gs_pervalue LIKE LINE OF gt_pervalue,
      gt_return TYPE TABLE OF bapiret2,
      gs_return LIKE LINE OF gt_return,
      gt_control TYPE TABLE OF bapipcpctrl,
      gt_totvalue TYPE TABLE OF bapipcptot.
    TYPES:
      BEGIN OF gy_bapi_input,
        version      TYPE versn,
    *    perio       TYPE co_perio,
        fisc_year    TYPE gjahr,
        coobject(10) TYPE c,
        cost_elem    TYPE kstar,
        wkgbtr01     TYPE wkgxxx,
        wkgbtr02     TYPE wkgxxx,
        wkgbtr03     TYPE wkgxxx,
        wkgbtr04     TYPE wkgxxx,
        wkgbtr05     TYPE wkgxxx,
        wkgbtr06     TYPE wkgxxx,
        wkgbtr07     TYPE wkgxxx,
        wkgbtr08     TYPE wkgxxx,
        wkgbtr09     TYPE wkgxxx,
        wkgbtr10     TYPE wkgxxx,
        wkgbtr11     TYPE wkgxxx,
        wkgbtr12     TYPE wkgxxx,
      END OF gy_bapi_input.
    DATA:
      gt_bapi_input TYPE TABLE OF gy_bapi_input,
      gs_bapi_input LIKE LINE OF gt_bapi_input.
    * Anwendungs-Log
    DATA: gs_balsmsg TYPE bal_s_msg.
    * Selection-Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1
      WITH FRAME TITLE text-001.
    PARAMETERS:
      gp_file TYPE localfile,
      gp_head TYPE checkbox DEFAULT 'X'.
    SELECTION-SCREEN SKIP.
    PARAMETERS:
      gp_kokrs  LIKE coep-kokrs,
      gp_gjahr LIKE coep-gjahr,
      gp_versn LIKE coep-versn,
      gp_test AS CHECKBOX DEFAULT 'X'.
    SELECTION-SCREEN END OF BLOCK b1.
    * Local Class Definition
    CLASS lcl_event_handler DEFINITION.
      PUBLIC SECTION.
        METHODS:
        handle_toolbar_0100 FOR EVENT toolbar OF cl_gui_alv_grid
          IMPORTING
            e_object
            e_interactive,
        handle_user_command_0100 FOR EVENT user_command OF cl_gui_alv_grid
          IMPORTING
            e_ucomm,
        handle_toolbar_0200 FOR EVENT toolbar OF cl_gui_alv_grid
          IMPORTING
            e_object
            e_interactive,
        handle_user_command_0200 FOR EVENT user_command OF cl_gui_alv_grid
          IMPORTING
            e_ucomm.
      PRIVATE SECTION.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    * Local Class Implementation
    CLASS lcl_event_handler IMPLEMENTATION.
      METHOD handle_toolbar_0100.
        PERFORM handle_toolbar_0100
          USING
            e_object.
    *        e_interactive.
      ENDMETHOD.                    "handle_toolbar_0100
      METHOD handle_user_command_0100.
        PERFORM handle_user_command_0100
          USING
            e_ucomm.
      ENDMETHOD.                    "handle_user_command_0100
      METHOD handle_toolbar_0200.
        PERFORM handle_toolbar_0200
          USING
            e_object.
    *        e_interactive.
      ENDMETHOD.                    "handle_toolbar_0100
      METHOD handle_user_command_0200.
        PERFORM handle_user_command_0200
          USING
            e_ucomm.
      ENDMETHOD.                    "handle_user_command_0100
    ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
    * Initialization
    INITIALIZATION.
      DATA:
        lf_sapworkdir TYPE string.
      CALL METHOD cl_gui_frontend_services=>get_sapgui_workdir
        CHANGING
          sapworkdir            = lf_sapworkdir
        EXCEPTIONS
          get_sapworkdir_failed = 1
          cntl_error            = 2
          error_no_gui          = 3
          not_supported_by_gui  = 4
          OTHERS                = 5.
      IF sy-subrc <> 0 OR lf_sapworkdir = ''.
        CALL METHOD cl_gui_frontend_services=>directory_get_current
          CHANGING
            current_directory            = lf_sapworkdir
          EXCEPTIONS
            directory_get_current_failed = 1
            cntl_error                   = 2
            error_no_gui                 = 3
            not_supported_by_gui         = 4
            OTHERS                       = 5.
        CALL METHOD cl_gui_cfw=>flush.
      ENDIF."sy-subrc <> 0 OR sapworkdir = ''
      gp_file = lf_sapworkdir.
    * At Selection-Screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR gp_file.
      DATA:
        lt_filetable TYPE filetable,
        ls_filetable LIKE LINE OF lt_filetable,
        lt_rc TYPE i.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
    *  EXPORTING
    *    WINDOW_TITLE            =
    *    DEFAULT_EXTENSION       =
    *    DEFAULT_FILENAME        =
    *    FILE_FILTER             =
    *    INITIAL_DIRECTORY       =
    *    MULTISELECTION          =
    *    WITH_ENCODING           =
        CHANGING
          file_table              = lt_filetable
          rc                      = lt_rc
    *    USER_ACTION             =
    *    FILE_ENCODING           =
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 4
          OTHERS                  = 5.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      READ TABLE lt_filetable INDEX 1
        INTO
          ls_filetable.
      gp_file = ls_filetable-filename.
      CALL METHOD cl_gui_cfw=>flush.
    * Start-Of-Selection
    START-OF-SELECTION.
      DATA:
        lf_filename LIKE filename-fileintern.
      PERFORM create_log.
      gs_return-type = 'I'.
      IF gp_test = 'X'.
        gs_return-message = text-010.
      ELSE.
        gs_return-message = text-020.
      ENDIF.
      PERFORM add_log_message_free_text
        USING
           gs_return-type
           gs_return-message.
      lf_filename = gp_file.
      CALL FUNCTION 'FILE_READ_AND_CONVERT_SAP_DATA'
        EXPORTING
          i_filename                 = lf_filename
          i_servertyp                = 'PRS '
          i_fileformat               = 'TXT'
    *     I_FIELD_SEPERATOR          =
          i_line_header              = gp_head
    *   IMPORTING
    *     E_BIN_FILELENGTH           =
       TABLES
         i_tab_receiver             = gt_text_input
       EXCEPTIONS
         file_not_found             = 1
         close_failed               = 2
         authorization_failed       = 3
         open_failed                = 4
         conversion_failed          = 5
         OTHERS                     = 6.
      IF sy-subrc <> 0.
        gs_balsmsg-msgty = sy-msgty.
        gs_balsmsg-msgid = sy-msgid.
        gs_balsmsg-msgno = sy-msgno.
        gs_balsmsg-msgv1 = sy-msgv1.
        gs_balsmsg-msgv2 = sy-msgv2.
        gs_balsmsg-msgv3 = sy-msgv3.
        gs_balsmsg-msgv4 = sy-msgv4.
        PERFORM add_log_message
          USING
            gs_balsmsg.
      ENDIF.
      CALL SCREEN '0100'.
    *&      Module  status_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *------ Create the docking container ----------------------------------*
      IF go_docking_container IS INITIAL.
        CREATE OBJECT go_docking_container
          EXPORTING
            parent                      = cl_gui_container=>screen0
    *        repid                       = gf_repid
    *        dynnr                       = gf_dynnr
    *     SIDE                        = go_docking_container->DOCK_AT_bottom
    *       EXTENSION                   = 200
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      CAPTION                     =
    *      METRIC                      = 0
            ratio                       = 95
    *      NO_AUTODEF_PROGID_DYNNR     =
    *      NAME                        =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    *------ Expand  docking container to full screen    -------------------*
        CALL METHOD go_docking_container->set_extension
          EXPORTING
            extension  = 99999  "full-screen size !!!
          EXCEPTIONS
            cntl_error = 1
            OTHERS     = 2.
        IF sy-subrc = 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF."go_docking_container IS INITIAL
    *------ Link docking container to screen ------------------------------*
      CALL METHOD go_docking_container->link
        EXPORTING
          repid                       = sy-repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          lifetime_dynpro_dynpro_link = 3
          OTHERS                      = 4
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *------ Build the Field Catalog ---------------------------------------*
      PERFORM build_fieldcatalog_input
        CHANGING gt_fieldcat.
    *------ Create the ALV Grid -------------------------------------------*
      IF go_alv_grid_0100 IS INITIAL.
        CREATE OBJECT go_alv_grid_0100
          EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
            i_parent          = go_docking_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF."go_alv_grid_0100 is initial
    *------ Create instance for event handler -----------------------------*
      DATA: go_event_handler_0100 TYPE REF TO lcl_event_handler.
      CREATE OBJECT go_event_handler_0100.
    *------ Register event handler ----------------------------------------*
      SET HANDLER go_event_handler_0100->handle_toolbar_0100
        FOR go_alv_grid_0100.
      SET HANDLER go_event_handler_0100->handle_user_command_0100
        FOR go_alv_grid_0100.
    *------ Call ALV Grid -------------------------------------------------*
      CALL METHOD go_alv_grid_0100->set_table_for_first_display
    *     EXPORTING
    *      I_BUFFER_ACTIVE               =
    *      I_BYPASSING_BUFFER            =
    *      I_CONSISTENCY_CHECK           =
    *      I_STRUCTURE_NAME              =
    *      IS_VARIANT                    =
    *      I_SAVE                        =
    *      I_DEFAULT                     = 'X'
    *      IS_LAYOUT                     =
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
    *      IT_TOOLBAR_EXCLUDING          =
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = gt_text_input
          it_fieldcatalog               = gt_fieldcat
    *      IT_SORT                       =
    *      IT_FILTER                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *---- Call method 'set_toolbar_interactive' to raise event TOOLBAR.
      CALL METHOD go_alv_grid_0100->set_toolbar_interactive.
    ENDMODULE.                 " status_0100  OUTPUT
    *&      Module  status_0200  OUTPUT
    *       text
    MODULE status_0200 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *------ Create the docking container ----------------------------------*
      IF go_docking_container IS INITIAL.
        CREATE OBJECT go_docking_container
          EXPORTING
            parent                      = cl_gui_container=>screen0
    *        repid                       = gf_repid
    *        dynnr                       = gf_dynnr
    *     SIDE                        = go_docking_container->DOCK_AT_bottom
    *       EXTENSION                   = 200
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      CAPTION                     =
    *      METRIC                      = 0
            ratio                       = 95
    *      NO_AUTODEF_PROGID_DYNNR     =
    *      NAME                        =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    *------ Expand  docking container to full screen    -------------------*
        CALL METHOD go_docking_container->set_extension
          EXPORTING
            extension  = 99999
          EXCEPTIONS
            cntl_error = 1
            OTHERS     = 2.
        IF sy-subrc = 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF."go_docking_container IS INITIAL
    *------ Link docking container to screen ------------------------------*
      CALL METHOD go_docking_container->link
        EXPORTING
          repid                       = sy-repid
          dynnr                       = '0200'
    *      CONTAINER                   =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          lifetime_dynpro_dynpro_link = 3
          OTHERS                      = 4
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *------ Build the Field Catalog---------------------------------------*
      PERFORM build_fieldcatalog_bapi_input
        CHANGING
          gt_fieldcat.
    *------ Create the ALV Grid -------------------------------------------*
      IF go_alv_grid_0200 IS INITIAL.
        CREATE OBJECT go_alv_grid_0200
          EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
           i_parent          = go_docking_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF."go_alv_grid_0200 is initial
    *------ Create instance for event handler -----------------------------*
      DATA: go_event_handler_0200 TYPE REF TO lcl_event_handler.
      CREATE OBJECT go_event_handler_0200.
    *------ Register event handler ----------------------------------------*
      SET HANDLER go_event_handler_0200->handle_toolbar_0200
        FOR go_alv_grid_0200.
      SET HANDLER go_event_handler_0200->handle_user_command_0200
        FOR go_alv_grid_0200.
    *------ Call ALV Grid -------------------------------------------------*
      CALL METHOD go_alv_grid_0200->set_table_for_first_display
    *     EXPORTING
    *      I_BUFFER_ACTIVE               =
    *      I_BYPASSING_BUFFER            =
    *      I_CONSISTENCY_CHECK           =
    *      I_STRUCTURE_NAME              =
    *      IS_VARIANT                    =
    *      I_SAVE                        =
    *      I_DEFAULT                     = 'X'
    *      IS_LAYOUT                     =
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
    *      IT_TOOLBAR_EXCLUDING          =
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = gt_bapi_input
          it_fieldcatalog               = gt_fieldcat
    *      IT_SORT                       =
    *      IT_FILTER                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *---- Call method 'set_toolbar_interactive' to raise event TOOLBAR.
      CALL METHOD go_alv_grid_0200->set_toolbar_interactive.
      CALL METHOD go_alv_grid_0200->refresh_table_display
    *  EXPORTING
    *    IS_STABLE      =
    *    I_SOFT_REFRESH =
        EXCEPTIONS
          finished       = 1
          OTHERS         = 2.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL METHOD cl_gui_control=>set_focus
        EXPORTING
          control = go_alv_grid_0200.
    ENDMODULE.                 " status_0200  OUTPUT
    *&      Module  user_command_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gf_okcode.
        WHEN 'BACK' OR 'END' OR 'CANC'.
          PERFORM exit_program.
        WHEN OTHERS.
      ENDCASE.
      CLEAR gf_okcode.
    ENDMODULE.                 " user_command_0100  INPUT
    *&      Module  user_command_0200  INPUT
    *       text
    MODULE user_command_0200 INPUT.
      CASE gf_okcode.
        WHEN 'BACK' OR 'END' OR 'CANC'.
          PERFORM exit_program.
        WHEN OTHERS.
      ENDCASE.
      CLEAR gf_okcode.
    ENDMODULE.                 " user_command_0200  INPUT
    *&      Form  build_fieldcatalog
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcatalog_input
      CHANGING
        pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CLEAR pt_fieldcat.
      ls_fcat-fieldname = 'FIRMA' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Firma' .
      ls_fcat-seltext = 'Firma' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENSTELLE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'CO-Objekt' .
      ls_fcat-seltext = 'CO-Objekt' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART1' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart1' .
      ls_fcat-seltext = 'Datenart1' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANJAHR' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planjahr' .
      ls_fcat-seltext = 'Planjahr' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANPERIODE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '5' .
      ls_fcat-coltext = 'Planperiode' .
      ls_fcat-seltext = 'Planperiode' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART2' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart2' .
      ls_fcat-seltext = 'Datenart2' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANUNGSPOSITION' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planungsposition' .
      ls_fcat-seltext = 'Planungsposition' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENART' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Kostenart' .
      ls_fcat-seltext = 'Kostenart' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANBETRAG' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Planbetrag' .
      ls_fcat-seltext = 'Planbetrag' .
      APPEND ls_fcat TO pt_fieldcat .
    ENDFORM.                    "build_fieldcatalog
    *&      Form  handle_toolbar_0100
    *       text
    *      -->P_E_OBJECT  text
    *      -->P_E_INTERACTIVE  text
    FORM handle_toolbar_0100
      USING
        po_object TYPE REF TO cl_alv_event_toolbar_set.
      DATA: ls_toolbar TYPE stb_button.
      CLEAR ls_toolbar.
      ls_toolbar-butn_type  = 0.
      ls_toolbar-function   = 'KONV'.
      ls_toolbar-quickinfo  = 'Konvertieren'.
      ls_toolbar-text       = 'Konvertieren'.
      ls_toolbar-disabled   = ' '.
      APPEND ls_toolbar TO po_object->mt_toolbar.
    ENDFORM.                    " handle_toolbar_0100
    *&      Form  handle_user_command_0100
    *       text
    *      -->P_E_UCOMM  text
    FORM handle_user_command_0100
      USING
        pf_ucomm TYPE syucomm.
      CASE pf_ucomm.
        WHEN 'KONV'.
          PERFORM convert_data.
      ENDCASE.
    ENDFORM.                    " handle_user_command_0100
    *&      Form  exit_program
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM exit_program.
      CALL METHOD go_alv_grid_0100->free.
      IF NOT go_alv_grid_0200 IS INITIAL.
        CALL METHOD go_alv_grid_0200->free.
      ENDIF.
      CALL METHOD go_docking_container->free.
      CALL METHOD cl_gui_cfw=>flush.
      IF sy-subrc NE 0.
    * add your handling, for example
        CALL FUNCTION 'POPUP_TO_INFORM'
          EXPORTING
            titel = sy-repid
            txt2  = sy-subrc
            txt1  = 'Error in Flush'(500).
      ENDIF.
      LEAVE PROGRAM.
    ENDFORM.                    " exit_program
    *&      Form  handle_toolbar_0200
    *       text
    *      -->P_E_OBJECT  text
    *      -->P_E_INTERACTIVE  text
    FORM handle_toolbar_0200
      USING
        po_object TYPE REF TO cl_alv_event_toolbar_set.
      DATA: ls_toolbar TYPE stb_button.
      CLEAR ls_toolbar.
      ls_toolbar-butn_type  = 0.
      ls_toolbar-function   = 'POST'.
      ls_toolbar-quickinfo  = 'Buchen'.
      ls_toolbar-text       = 'Buchen'.
      ls_toolbar-disabled   = ' '.
      APPEND ls_toolbar TO po_object->mt_toolbar.
    ENDFORM.                    " handle_toolbar_0200
    *&      Form  handle_user_command_0200
    *       text
    *      -->P_E_UCOMM  text
    FORM handle_user_command_0200
      USING
        pf_ucomm TYPE syucomm.
      CASE pf_ucomm.
        WHEN 'POST'.
          PERFORM post.
      ENDCASE.
    ENDFORM.                    " handle_user_command_0200
    *&      Form  convert_data
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM convert_data.
      DATA: lf_perio(3) TYPE n.
      LOOP AT gt_text_input INTO gs_text_input.
        TRANSLATE gs_text_input-planbetrag USING '. '.
        TRANSLATE gs_text_input-planbetrag USING ',.'.
        CONDENSE gs_text_input-planbetrag.
        gs_bapi_input-version   = gp_versn.
        gs_bapi_input-fisc_year = gp_gjahr.
        gs_bapi_input-coobject  = gs_text_input-kostenstelle.
        gs_bapi_input-cost_elem = gs_text_input-kostenart.
        lf_perio = gs_text_input-planperiode.
        CASE lf_perio.
          WHEN '001'.
            gs_bapi_input-wkgbtr01 = gs_text_input-planbetrag.
          WHEN '002'.
            gs_bapi_input-wkgbtr02 = gs_text_input-planbetrag.
          WHEN '003'.
            gs_bapi_input-wkgbtr03 = gs_text_input-planbetrag.
          WHEN '004'.
            gs_bapi_input-wkgbtr04 = gs_text_input-planbetrag.
          WHEN '005'.
            gs_bapi_input-wkgbtr05 = gs_text_input-planbetrag.
          WHEN '006'.
            gs_bapi_input-wkgbtr06 = gs_text_input-planbetrag.
          WHEN '007'.
            gs_bapi_input-wkgbtr07 = gs_text_input-planbetrag.
          WHEN '008'.
            gs_bapi_input-wkgbtr08 = gs_text_input-planbetrag.
          WHEN '009'.
            gs_bapi_input-wkgbtr09 = gs_text_input-planbetrag.
          WHEN '010'.
            gs_bapi_input-wkgbtr10 = gs_text_input-planbetrag.
          WHEN '011'.
            gs_bapi_input-wkgbtr11 = gs_text_input-planbetrag.
          WHEN '012'.
            gs_bapi_input-wkgbtr12 = gs_text_input-planbetrag.
        ENDCASE.
        COLLECT gs_bapi_input INTO gt_bapi_input.
        CLEAR gs_bapi_input.
      ENDLOOP. "at gt_text_input
      CALL SCREEN 0200.
    ENDFORM.                    " convert_data
    *&      Form  build_fieldcatalog_bapi_input
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcatalog_bapi_input
      CHANGING
        pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CLEAR pt_fieldcat.
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'VERSION' .
      ls_fcat-ref_table = 'BAPIPLNHDR' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'FISC_YEAR' .
      ls_fcat-ref_table = 'BAPIPLNHDR' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'COOBJECT' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'CO-Objekt' .
      ls_fcat-seltext = 'CO-Objekt' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'COST_ELEM' .
      ls_fcat-ref_table = 'BAPIPCPVAL' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR01'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR02'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR03'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR04'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR05'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR06'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR07'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR08'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR09'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR10'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR11'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR12'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
    ENDFORM.                    " build_fieldcatalog_bapi_input
    *&      Form  post
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM post.
      DATA:
        lf_index(6) TYPE n,
        lf_kostl    LIKE csks-kostl,
        lf_aufnr    LIKE aufk-aufnr,
        lf_kstar    LIKE cska-kstar.
      DATA:
        lt_csks TYPE TABLE OF csks.
      break c5085345.
    * Header
      gs_headerinfo-co_area       = gp_kokrs.
      gs_headerinfo-fisc_year     = gp_gjahr.
      gs_headerinfo-period_from   = '001'.
      gs_headerinfo-period_to     = '012'.
      gs_headerinfo-version       = gp_versn.
      gs_headerinfo-plan_currtype = 'C'.
      LOOP AT gt_bapi_input INTO gs_bapi_input.
    *   Fill index structure
        CLEAR gs_indexstructure.
        lf_index = sy-tabix.
        gs_indexstructure-object_index = lf_index.
        gs_indexstructure-value_index  = lf_index.
        gs_indexstructure-attrib_index = '000000'.
        INSERT gs_indexstructure INTO TABLE gt_indexstructure.
    *   Fill coobject
        CLEAR gs_coobject.
        gs_coobject-object_index = lf_index.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = gs_bapi_input-coobject
          IMPORTING
            output = lf_kostl.
        SELECT * FROM csks INTO TABLE lt_csks
          WHERE
            kokrs = gp_kokrs AND
            kostl = lf_kostl.
        IF sy-subrc = 0.
          gs_coobject-costcenter = lf_kostl.
        ELSE.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              input  = gs_bapi_input-coobject
            IMPORTING
              output = lf_aufnr.
          CALL FUNCTION 'K_ORDER_READ'
            EXPORTING
              aufnr     = lf_aufnr
            EXCEPTIONS
              not_found = 1.
          IF NOT sy-subrc = 0.
            gs_return-type = 'E'.
            gs_return-message+0(10)  = 'CO-Objekt '.
            gs_return-message+10(10) = gs_bapi_input-coobject.
            gs_return-message+20(20)  = ' existiert nicht.'.
            CONDENSE gs_return-message.
            PERFORM add_log_message_free_text
              USING
                gs_return-type
                gs_return-message.
            EXIT.
          ENDIF. "IF NOT sy-subrc = 0
          gs_coobject-orderid = lf_aufnr.
        ENDIF. "sy-subrc = 0
        INSERT gs_coobject INTO TABLE gt_coobject.
    *   Period value
        gs_pervalue-value_index = lf_index.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = gs_bapi_input-cost_elem
          IMPORTING
            output = lf_kstar.
        gs_pervalue-cost_elem = lf_kstar.
        gs_pervalue-fix_val_per01 = gs_bapi_input-wkgbtr01.
        gs_pervalue-fix_val_per02 = gs_bapi_input-wkgbtr02.
        gs_pervalue-fix_val_per03 = gs_bapi_input-wkgbtr03.
        gs_pervalue-fix_val_per04 = gs_bapi_input-wkgbtr04.
        gs_pervalue-fix_val_per05 = gs_bapi_input-wkgbtr05.
        gs_pervalue-fix_val_per06 = gs_bapi_input-wkgbtr06.
        gs_pervalue-fix_val_per07 = gs_bapi_input-wkgbtr07.
        gs_pervalue-fix_val_per08 = gs_bapi_input-wkgbtr08.
        gs_pervalue-fix_val_per09 = gs_bapi_input-wkgbtr09.
        gs_pervalue-fix_val_per10 = gs_bapi_input-wkgbtr10.
        gs_pervalue-fix_val_per11 = gs_bapi_input-wkgbtr11.
        gs_pervalue-fix_val_per12 = gs_bapi_input-wkgbtr12.
        INSERT gs_pervalue INTO TABLE gt_pervalue.
      ENDLOOP. "at gt_bapi_input
    * Buchungsbaustein
      CALL FUNCTION 'BAPI_PRIM_COST_CHECK_AND_POST'
        EXPORTING
          header_info         = gs_headerinfo
          testrun             = gp_test
    *   DELTA               = ' '
        TABLES
          idx_structure       = gt_indexstructure
          object              = gt_coobject
          per_value           = gt_pervalue
          tot_value           = gt_totvalue
          contrl              = gt_control
          return              = gt_return.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    *   EXPORTING
    *     WAIT          =
    *   IMPORTING
    *     RETURN        =
      LOOP AT gt_return INTO gs_return.
        gs_balsmsg-msgty = gs_return-type.
        gs_balsmsg-msgid = gs_return-id.
        gs_balsmsg-msgno = gs_return-number.
        gs_balsmsg-msgv1 = gs_return-message_v1.
        gs_balsmsg-msgv2 = gs_return-message_v2.
        gs_balsmsg-msgv3 = gs_return-message_v3.
        gs_balsmsg-msgv4 = gs_return-message_v4.
        PERFORM add_log_message
          USING
            gs_balsmsg.
      ENDLOOP. "AT gt_return
      PERFORM show_log.
    ENDFORM.                    " post
    *&      Form  create_log
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM create_log .
      DATA: ls_balslog TYPE bal_s_log.
    * Einige Verwaltungsdaten
      ls_balslog-extnumber = 'ZPLAN010'.
      ls_balslog-aluser    = sy-uname.
      ls_balslog-alprog    = sy-repid.
    * Create
      CALL FUNCTION 'BAL_LOG_CREATE'
        EXPORTING
          i_s_log                 = ls_balslog
    *    IMPORTING
    *      e_log_handle            = gf_balloghndl
        EXCEPTIONS
          log_header_inconsistent = 1
          OTHERS                  = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " create_log
    *&      Form  add_log_message
    *       text
    *      -->P_GS_BALSMSG  text
    FORM add_log_message
      USING
        ps_balsmsg TYPE bal_s_msg.
      break c5085345.
      CALL FUNCTION 'BAL_LOG_MSG_ADD'
        EXPORTING
    *       I_LOG_HANDLE              =
          i_s_msg                   = ps_balsmsg
    *     IMPORTING
    *       E_S_MSG_HANDLE            =
    *       E_MSG_WAS_LOGGED          =
    *       E_MSG_WAS_DISPLAYED       =
       EXCEPTIONS
         log_not_found             = 1
         msg_inconsistent          = 2
         log_is_full               = 3
         OTHERS                    = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " add_log_messa
    *&      Form  add_log_message_free_text
    *       text
    *      -->P_GS_RETURN_TYPE  text
    *      -->P_GS_RETURN_MESSAGE  text
    FORM add_log_message_free_text
      USING
        ps_type
        ps_message.
      CALL FUNCTION 'BAL_LOG_MSG_ADD_FREE_TEXT'
        EXPORTING
    *       I_LOG_HANDLE              =
          i_msgty                   = ps_type
    *       I_PROBCLASS               = '4'
          i_text                    = ps_message
    *       I_S_CONTEXT               =
    *       I_S_PARAMS                =
    *     IMPORTING
    *       E_S_MSG_HANDLE            =
    *       E_MSG_WAS_LOGGED          =
    *       E_MSG_WAS_DISPLAYED       =
       EXCEPTIONS
         log_not_found             = 1
         msg_inconsistent          = 2
         log_is_full               = 3
         OTHERS                    = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " add_log_message_free_text
    *&      Form  show_log
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM show_log .
      DATA:
        l_s_display_profile TYPE bal_s_prof.
    * get display profile
      CALL FUNCTION 'BAL_DSP_PROFILE_NO_TREE_GET'
        IMPORTING
          e_s_display_profile = l_s_display_profile
        EXCEPTIONS
          OTHERS              = 1.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    * use grid for display if wanted
      l_s_display_profile-use_grid = 'X'.
    * set report to allow saving of variants
      l_s_display_profile-disvariant-report = sy-repid.
    * when you use also other ALV lists in your report,
    * please specify a handle to distinguish between the display
    * variants of these different lists, e.g:
      l_s_display_profile-disvariant-handle = 'LOG'.
    * call display function module
    * We do not specify any filter (like I_S_LOG_FILTER, ...,
    * I_T_MSG_HANDLE) since we want to display all logs available
      CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
        EXPORTING
          i_s_display_profile = l_s_display_profile
        EXCEPTIONS
          OTHERS              = 1.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.

  • Screens and ABAP Objects - R/3 4.6c

    Greetings fellow SAP developers.
    Looking for some input here. What's the best way to manage dialog screens with ABAP OO?
    Do you encapsulate the screen in an object? So that there is just one method or two methods? As in:
    Screen->Init
    Or do you break it down into chunks? As in:
    Screen->Set_Fields
    Screen->Validate
    Screen->Handle_Action
    Or do you avoid using objects to encapsulate screens? That is, just use objects to encapsulate business processes? As  in:
    SCREEN_FIELD_1 = BusinessObject->Get_Value_1()
    SCREEN_FIELD_2 = BusinessObject->Get_Value_2()
    Thanks in advance for your input.
    Brett

    Sure you can handle PBO and PAI of screen using objects,  take a look at transaction MIGO,  its full of it.  The only thing is is that you can not use the "CALL SCREEN" statement inside your objects.
    Regards,
    Rich Heilman

  • Get instance method and design pattern

    Hi All,
    1. I New to abap objects and i read the help and some stuff from the forum,
    l like to now more about design pattern in abap objects,
    2. I saw in some abap class the use of method of GET_INSTANCE i think it's from factory pattern , what is the pros. and cons to use this method ,when i should consider to use it ?
    Thanks in Advance
    Nina

    Hello Nina
    A very good introduction into design patterns is the book "Head First: Design Patterns". Here you will find many good reasons why and when to use the factory pattern.
    You should use the factory pattern when
    - you want to prevent "direct" instantiation (i.e. using a public CONSTRUCTOR method) by the developer
    - you want to hide the complexity of instantiation from the user of the class
    - the instantiation creates an implementation of an interface and you want to keep control of which implementing class is returned
    Regards
      Uwe

Maybe you are looking for