<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:clearspace="http://www.jivesoftware.com/xmlns/clearspace/rss" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>naimesh.patel</title>
    <link>http://scn.sap.com/people/naimesh.patel/blog</link>
    <description>Blog posts in ABAP objects and Tricks</description>
    <pubDate>Thu, 22 Dec 2011 17:59:56 GMT</pubDate>
    <generator>Jive SBS 5.0.1.1  (http://jivesoftware.com/products/clearspace/)</generator>
    <dc:date>2011-12-22T17:59:56Z</dc:date>
    <item>
      <title>Object Oriented Design Principles (OODP): Single Responsibility Principle (SRP)</title>
      <link>http://scn.sap.com/people/naimesh.patel/blog/2009/07/03/object-oriented-design-principles-oodp-single-responsibility-principle-srp</link>
      <description>&lt;!-- [DocumentBodyStart:89db3545-7054-49b8-8fd6-04b75b0a7eb9] --&gt;&lt;div class="jive-rendered-content"&gt;&lt;div&gt;In the previous post of the series Object Oriented Design Principles, we have seen:&lt;br/&gt;1) &lt;a class="jive-link-blog-small" data-containerId="9185" data-containerType="37" data-objectId="49767" data-objectType="38" href="http://scn.sap.com/people/naimesh.patel/blog/2009/05/20/object-oriented-design-principles-oodp-open-closed-principleocp"&gt;Object Oriented Design Principles (OODP): Open-Closed Principle(OCP)&lt;/a&gt;2) &lt;a class="jive-link-blog-small" data-containerId="9185" data-containerType="37" data-objectId="49814" data-objectType="38" href="http://scn.sap.com/people/naimesh.patel/blog/2009/05/26/object-oriented-design-principles-oodp-ocp-with-business-scenario"&gt;Object Oriented Design Principles (OODP): OCP with Business Scenario&lt;/a&gt;&lt;br/&gt;3) &lt;a class="jive-link-blog-small" data-containerId="9185" data-containerType="37" data-objectId="49943" data-objectType="38" href="http://scn.sap.com/people/naimesh.patel/blog/2009/06/10/object-oriented-design-principles-oodp-dependency-inversion-principle-dip"&gt;Object Oriented Design Principles (OODP): Dependency Inversion Principle (DIP)&lt;/a&gt;&amp;#160;&lt;/div&gt;&lt;div&gt;Today, we will&amp;#160;explore&amp;#160;about the Single Responsibility Principle.&amp;#160;&lt;/div&gt;&lt;br/&gt;&lt;br/&gt;&lt;div&gt;&lt;strong&gt;Definition:&lt;/strong&gt;&amp;#160;&lt;/div&gt;&lt;div&gt;According to Robert C. Martin, Single Responsibility Principle (SRP) by definition is: &lt;em&gt;There would not be more than one reason to change the class.&lt;/em&gt; Class would always represent only one responsibility. Here responsibility is the reason tot change the class.&lt;/div&gt;&lt;div&gt;&lt;br/&gt;&lt;/div&gt;&lt;div&gt;We must not create a single class which has more than one responsibility. If the class has more than one responsibility, than that would be more than one reason to change that class. Classes with more than one responsibility would have a tendency to break more easily than the classes with less responsibility. Whenever, we do the changes in multi responsibility classes, we have to make sure we don&amp;rsquo;t break the other responsibility of that class -&amp;#160;more responsibilities&amp;#160;leads to more testing.&lt;/div&gt;&lt;br/&gt;&lt;br/&gt;&lt;div&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/div&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-50169-59991/SRP_Vio1.png"&gt;&lt;img align="right" alt="image" border="0" height="123" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-50169-59991/269-123/SRP_Vio1.png" width="269"/&gt;&lt;/a&gt;&lt;span&gt; &lt;/span&gt;&lt;div&gt;We have to develop a simple report to select the data and than display this data as an ALV. If we design only one single class ZCL_REPORT to achieve this requirement, than we are giving more than one responsibility to this class: 1) Data Selection, 2) Output of DATA (ALV). Clearly, there are two reasons which lead to change this class: Change in Data selection (e.g. changing the formula to calculate the net price) and change in ALV processing (e.g. adding a provision to display default variant). There is no clear distinction between the attributes which belong to which responsibility and we might change them accidentally. So, we need to test the entire class and make sure we haven&amp;rsquo;t broken this functionality.&lt;/div&gt;&lt;div&gt;&lt;br/&gt;&lt;/div&gt;&lt;div&gt;We can avoid this risk by segregating both responsibilities in separate classes: class for data selection ZCL_DATA_SELECT &amp;amp; class for ALV ZCL_OUTPUT_ALV. Since we have different classes, we don&amp;rsquo;t have to worry about making accidental update in the other classes&amp;rsquo; attributes. We can still create a class ZCL_REPORT which uses both data selection ZCL_DATA_SELECT and ALV ZCL_OUTPUT_ALV classes.&lt;/div&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-50169-59992/SRP_1st.png"&gt;&lt;img alt="image" border="0" height="255" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-50169-59992/378-255/SRP_1st.png" width="378"/&gt;&lt;/a&gt;&lt;span&gt; &lt;/span&gt;&lt;div&gt;&lt;strong&gt;&lt;br/&gt;&lt;br/&gt;Dilemma:&amp;#160;&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;SRP seems to be the simplest principle but it is one of the hardest to get right. Segregating the responsibilities would depend always on the developer. One could still find more than one responsibility in the data selection class ZCL_DATA_SELECT: data selection from DB ZCL_DATA_DB &amp;amp; Data manipulation ZCL_DATA_PROCESS. Class Data selection from DB ZCL_DATA_DB would be still segregated in to more than one responsibility: data selection for each individual sub objects like Class to select material data ZCL_MATERIAL, class to select Customer data ZCL_CUSTOMER etc. We need to find the optimal segregation of the responsibilities between our classes.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Credits:&lt;br/&gt;&lt;/strong&gt;&lt;a class="jive-link-external-small" href="http://www.objectmentor.com/omTeam/martin_r.html"&gt;Robert C. Martin&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br/&gt;&lt;br/&gt;&amp;#160;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;!-- [DocumentBodyEnd:89db3545-7054-49b8-8fd6-04b75b0a7eb9] --&gt;</description>
      <pubDate>Fri, 03 Jul 2009 04:45:26 GMT</pubDate>
      <guid>http://scn.sap.com/people/naimesh.patel/blog/2009/07/03/object-oriented-design-principles-oodp-single-responsibility-principle-srp</guid>
      <dc:creator>Naimesh Patel</dc:creator>
      <dc:date>2009-07-03T04:45:26Z</dc:date>
      <clearspace:dateToText>1 year, 6 months ago</clearspace:dateToText>
      <clearspace:replyCount>1</clearspace:replyCount>
      <clearspace:objectType>0</clearspace:objectType>
      <wfw:comment>http://scn.sap.com/people/naimesh.patel/blog/comment/object-oriented-design-principles-oodp-single-responsibility-principle-srp</wfw:comment>
      <wfw:commentRss>http://scn.sap.com/people/naimesh.patel/blog/feeds/comments?blogPost=50169</wfw:commentRss>
    </item>
    <item>
      <title>Object Oriented Design Principles (OODP): Dependency Inversion Principle (DIP)</title>
      <link>http://scn.sap.com/people/naimesh.patel/blog/2009/06/10/object-oriented-design-principles-oodp-dependency-inversion-principle-dip</link>
      <description>&lt;!-- [DocumentBodyStart:69509c34-4c11-4540-9a1c-8b4cf957a550] --&gt;&lt;div class="jive-rendered-content"&gt;&lt;p&gt;In the previous post of the series Object Oriented Design Principles, we have seen:&lt;br/&gt;1) &lt;a class="jive-link-blog-small" data-containerId="9185" data-containerType="37" data-objectId="49767" data-objectType="38" href="http://scn.sap.com/people/naimesh.patel/blog/2009/05/20/object-oriented-design-principles-oodp-open-closed-principleocp"&gt;Object Oriented Design Principles (OODP): Open-Closed Principle(OCP)&lt;/a&gt;&lt;br/&gt;2) &lt;a class="jive-link-blog-small" data-containerId="9185" data-containerType="37" data-objectId="49814" data-objectType="38" href="http://scn.sap.com/people/naimesh.patel/blog/2009/05/26/object-oriented-design-principles-oodp-ocp-with-business-scenario"&gt;Object Oriented Design Principles (OODP): OCP with Business Scenario&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt;&lt;br/&gt;By Definition, Dependency Inversion Principle (DIP) is: &lt;em&gt;Depend upon Abstractions. Do not depend upon concretions. &lt;br/&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Problem with the Procedural design:&lt;/strong&gt;&lt;br/&gt;Procedural designs exhibit always particular type of dependency. In the procedural programming, there would be always some code blocks which are repetitive. Like in the example, we have a program which has different set of the interfaces like interface to create Sales Order (as shown in the blog post: &lt;a class="jive-link-blog-small" data-containerId="9185" data-containerType="37" data-objectId="49814" data-objectType="38" href="http://scn.sap.com/people/naimesh.patel/blog/2009/05/26/object-oriented-design-principles-oodp-ocp-with-business-scenario"&gt;Object Oriented Design Principles (OODP): OCP with Business Scenario&lt;/a&gt;), Purchase Order etc. Program structure have some CONCRETE code blocks which makes it very RIGID. As shown in this diagram, we can&amp;rsquo;t use the Validation of the sub objects in more than one interface because it is wrapped in the concrete code block or FM.&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-49943-59666/DIP_P.png"&gt;&lt;img alt="image" border="1" height="273" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-49943-59666/498-273/DIP_P.png" width="498"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;Concrete classes are rigid, where as using interfaces make the design flexible. So, if we follow the object oriented design using proper abstraction we can remove the rigidity of the code and make our code blocks more reusable. Moreover, we can extend the abstract classes or interfaces to have new functionality and we can achieve the Open Closed Principle (OCP). &lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Achieving DIP:&lt;br/&gt;&lt;/strong&gt;Every dependency should depend on the Interface or Abstraction class. There should be no dependency targeted on the concrete classes. For example, we would try to work on the object reference created with reference to abstract class or interface. We should try to define the method parameters, attributes with reference to abstract class or interface. There should not be direct reference of the concrete class.&lt;/p&gt;&lt;p&gt;We will&amp;#160;try to explore the same example, as we have seen in the previous post &lt;a class="jive-link-blog-small" data-containerId="9185" data-containerType="37" data-objectId="49814" data-objectType="38" href="http://scn.sap.com/people/naimesh.patel/blog/2009/05/26/object-oriented-design-principles-oodp-ocp-with-business-scenario"&gt;Object Oriented Design Principles (OODP): OCP with Business Scenario&lt;/a&gt;. Method VALIDATE_KEYS of the class LCL_SO is not reusable. We can&amp;rsquo;t use that method in another object to achieve the same functionality, unless we instantiate the SO object and call the method. This makes the design little bit rigid. Let&amp;rsquo;s see how we can overcome this problem by following DIP.&lt;/p&gt;&lt;p&gt;Let's check the UML diagram for this design:&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-49943-59667/DIP.png"&gt;&lt;img alt="image" border="1" height="329" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-49943-59667/640-329/DIP.png" width="640"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;To achieve the DIP in the same example, we can create an abstract class ZCL_AB_ORDER which contains all the common functionality e.g. VALIDATE method &amp;amp; common attributes e.g. table for sub-objects T_SUBOBJ. Based on this abstract class, we can inherit all main classes e.g. class for sales order ZCL_SALES_ORDER, class for purchase order ZCL_PURCHASE_ORDER etc. The attribute T_SUBOBJ will hold the object reference of the sub-objects like Material, Customer, Vendor etc.&lt;/p&gt;&lt;p&gt;Subclasses of the abstract class ZCL_AB_ORDER&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-49943-59668/zcl_ab_order_subclass.png"&gt;&lt;img alt="image" border="0" height="211" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-49943-59668/410-211/zcl_ab_order_subclass.png" width="410"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;For the sub-objects, we can create an interface ZIF_SUBOBJ which contains method definitions for common methods for the sub-objects like method VALIDATE_KEY. Use this interface in all the sub-objects like Material ZCL_MATERIAL, customer ZCL_CUSTOMER, Vendor ZCL_VENDOR etc. We can implement object specific validation in the inherited method from the ZIF_SUBOBJ e.g. material number validation against material master (table MARA) etc.&lt;/p&gt;&lt;p&gt;Subclasses&amp;#160;of subobject interface&amp;#160;ZIF_SUBOBJ:&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-49943-59669/zif_subobj_sub.png"&gt;&lt;img alt="image" border="0" height="211" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-49943-59669/358-211/zif_subobj_sub.png" width="358"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;We can create a utility class ZCL_UTILITIES which has some generic methods e.g. VALIDATION. This method can accept any object inherited from the abstract class ZCL_AB_ORDER. We can check all the sub-objects&amp;rsquo; method VALIDATE_KEY to call the object specific validation. &lt;/p&gt;&lt;p&gt;Implementation of Method VALIDATION:&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-49943-59670/zcl_utilities_valid1.png"&gt;&lt;img alt="image" border="0" height="272" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-49943-59670/466-272/zcl_utilities_valid1.png" width="466"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;We call this method VALIDATION from the method VALIDATE of the abstract class ZCL_AB_ORDER. Since the parameter of the VALIDATION method depend on the abstract class ZCL_AB_ORDER, we can use this method with any object reference which is inherited from the abstract class ZCL_AB_ORDER.&amp;#160;As a input of the method ZCL_UTILITES=&amp;gt;VALIDATION we are passing the current object (ME).&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-49943-59671/zcl_ab_order_valid2.png"&gt;&lt;img alt="image" border="0" height="218" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-49943-59671/386-218/zcl_ab_order_valid2.png" width="386"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;You can find the&amp;#160;class design, implementation and test report&amp;#160;in WIKI &lt;a class="jive-link-external-small" href="https://wiki.sdn.sap.com/wiki/x/PIChBg"&gt;Object-Oriented Design Principle - Dependency Inversion Principle Example&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br/&gt;* Abstraction would help us to create more reusable methods like VALIDATE in class ZCL_AB_ORDER and VALIDATION in class ZCL_UTILITIES. &lt;br/&gt;* Code would lose the rigidity and become more flexible, which would lead to easy maintenance.&lt;br/&gt;* We achieved DIP - Removed the dependency on the actual concrete class.&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Credits:&lt;br/&gt;&lt;/strong&gt;&lt;a class="jive-link-external-small" href="http://www.objectmentor.com/omTeam/martin_r.html"&gt;Robert C. Martin&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;!-- [DocumentBodyEnd:69509c34-4c11-4540-9a1c-8b4cf957a550] --&gt;</description>
      <pubDate>Wed, 10 Jun 2009 10:39:13 GMT</pubDate>
      <guid>http://scn.sap.com/people/naimesh.patel/blog/2009/06/10/object-oriented-design-principles-oodp-dependency-inversion-principle-dip</guid>
      <dc:creator>Naimesh Patel</dc:creator>
      <dc:date>2009-06-10T10:39:13Z</dc:date>
      <clearspace:dateToText>1 year, 6 months ago</clearspace:dateToText>
      <clearspace:replyCount>2</clearspace:replyCount>
      <clearspace:objectType>0</clearspace:objectType>
      <wfw:comment>http://scn.sap.com/people/naimesh.patel/blog/comment/object-oriented-design-principles-oodp-dependency-inversion-principle-dip</wfw:comment>
      <wfw:commentRss>http://scn.sap.com/people/naimesh.patel/blog/feeds/comments?blogPost=49943</wfw:commentRss>
    </item>
    <item>
      <title>Object Oriented Design Principles (OODP): OCP with Business Scenario</title>
      <link>http://scn.sap.com/people/naimesh.patel/blog/2009/05/26/object-oriented-design-principles-oodp-ocp-with-business-scenario</link>
      <description>&lt;!-- [DocumentBodyStart:0c8ec86e-997e-4b23-91f4-e25457f0a040] --&gt;&lt;div class="jive-rendered-content"&gt;&lt;p&gt;In the previous post &lt;a class="jive-link-blog-small" data-containerId="9185" data-containerType="37" data-objectId="49767" data-objectType="38" href="http://scn.sap.com/people/naimesh.patel/blog/2009/05/20/object-oriented-design-principles-oodp-open-closed-principleocp"&gt;Object Oriented Design Principles (OODP): Open-Closed Principle(OCP)&lt;/a&gt; of the series OODP, we have seen how we can achieve the OCP using Shape object like Square, Circle. In this blog post, we will see how we can use the Open-Closed Principle in business scenario. &lt;/p&gt;&lt;p&gt;As noted in the previous post thumb rule for OCP is: We can add new features in the module without changing the existing code (CLOSED) but by adding new code (OPEN).&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Requirement:&lt;/strong&gt; &lt;br/&gt;There is a need for a data upload program to create a sales order. Flat file would be the source of the data for this program. We are getting some fields in the flat file like Customer number, Material number, Plant etc. Obviously, it is required to validate the input before calling the BAPI to create the sales order. For this example, we would concentrate on the validation part. We will use the polymorphism to achieve the OCP for this requirement.&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;UML diagram&lt;/strong&gt; would look like this:&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-49814-59561/OCP_R1.png"&gt;&lt;img alt="image" border="1" height="206" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-49814-59561/473-206/OCP_R1.png" width="473"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;To realize this requirement, we would create an interface LIF_SUBOBJ for common methods which we can use in different classes like Customer LCL_KUNNR, Material LCL_MATNR, etc. Definition of the interface and interface impelementing classes:&lt;br/&gt;&lt;textarea cols="60" rows="10"&gt;*--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INTERFACE lif_subobj *--------------------------------------------------------* INTERFACE lif_subobj.&amp;#160;&amp;#160;&amp;#160; DATA: f_key&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TYPE string.&amp;#160;&amp;#160;&amp;#160; METHODS:&amp;#160;&amp;#160;&amp;#160;&amp;#160; is_valid&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; RETURNING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; value(rf_valid) TYPE boolean.&amp;#160; ENDINTERFACE.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lif_subobj&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_matnr DEFINITION *--------------------------------------------------------* CLASS lcl_matnr DEFINITION.&amp;#160;&amp;#160; PUBLIC SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INTERFACES: lif_subobj.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; METHODS:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; constructor&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IMPORTING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if_matnr TYPE mara-matnr.&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_matnr DEFINITION&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_kunnr DEFINITION *--------------------------------------------------------* * *--------------------------------------------------------* CLASS lcl_kunnr DEFINITION.&amp;#160;&amp;#160;&amp;#160; PUBLIC SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INTERFACES: lif_subobj.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; METHODS:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; constructor&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IMPORTING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if_kunnr TYPE kna1-kunnr.&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_kunnr DEFINITION&lt;/textarea&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;Method IS_VALID in the customer class LCL_KUNNR validates the customer number against the customer master KNA1. Method IS_VALID in the material class LCL_MATNR validates the material number against the material master MARA.&lt;br/&gt;Implementation for these classes LCL_KUNNR, LCL_MATNR:&lt;br/&gt;&lt;textarea cols="60" rows="10"&gt;*--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_matnr IMPLEMENTATION *--------------------------------------------------------* CLASS lcl_matnr IMPLEMENTATION.&amp;#160;&amp;#160;&amp;#160; METHOD constructor.&amp;#160; *&amp;#160;&amp;#160; set the key&amp;#160;&amp;#160;&amp;#160;&amp;#160; me-&amp;gt;lif_subobj~f_key = if_matnr.&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "constructor&amp;#160;&amp;#160;&amp;#160;&amp;#160; METHOD lif_subobj~is_valid.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: lf_matnr TYPE matnr.&amp;#160; *&amp;#160;&amp;#160; check if it is valid&amp;#160;&amp;#160;&amp;#160;&amp;#160; SELECT SINGLE matnr&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INTO lf_matnr&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FROM mara&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WHERE matnr = me-&amp;gt;lif_subobj~f_key.&amp;#160;&amp;#160;&amp;#160;&amp;#160; IF sy-subrc = 0.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; rf_valid = 'X'.&amp;#160;&amp;#160;&amp;#160;&amp;#160; ENDIF.&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lif_subobj~is_valid&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_matnr IMPLEMENTATION&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_kunnr IMPLEMENTATION *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Customer object *--------------------------------------------------------* CLASS lcl_kunnr IMPLEMENTATION.&amp;#160;&amp;#160;&amp;#160; METHOD constructor.&amp;#160; *&amp;#160;&amp;#160; set the key&amp;#160;&amp;#160;&amp;#160;&amp;#160; me-&amp;gt;lif_subobj~f_key = if_kunnr.&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "constructor&amp;#160;&amp;#160;&amp;#160; METHOD lif_subobj~is_valid.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: lf_kunnr TYPE kna1-kunnr.&amp;#160; *&amp;#160;&amp;#160; check if it is valid&amp;#160;&amp;#160;&amp;#160;&amp;#160; SELECT SINGLE kunnr&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INTO lf_kunnr&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FROM kna1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WHERE kunnr = me-&amp;gt;lif_subobj~f_key.&amp;#160;&amp;#160;&amp;#160;&amp;#160; IF sy-subrc = 0.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; rf_valid = 'X'.&amp;#160;&amp;#160;&amp;#160;&amp;#160; ENDIF.&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lif_subobj~is_valid&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_kunnr IMPLEMENTATION&lt;/textarea&gt; &lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;Public attribute LT_OBJ of class LCL_SO is an internal table which holds the reference of different objects like Customer LCL_KUNNR, Material Number LCL_MATNR etc. Method VALIDATE_KEYS of the class LCL_SO calls the method IS_VALID of each object reference of the table LT_OBJ attribute. We will use down cast from the object reference in LT_OBJ to object reference of LIF_SUBOBJ. Definition and Implementation of the sales order class LCL_SO is:&lt;br/&gt;&lt;textarea cols="60" rows="10"&gt;*--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_so DEFINITION *--------------------------------------------------------* CLASS lcl_so DEFINITION.&amp;#160;&amp;#160;&amp;#160; PUBLIC SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TYPES: BEGIN OF lty_obj,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; object TYPE REF TO object,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; END&amp;#160;&amp;#160; OF lty_obj.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: la_header TYPE vbak,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lt_item&amp;#160;&amp;#160; TYPE STANDARD TABLE OF vbap,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lt_obj&amp;#160;&amp;#160;&amp;#160; TYPE STANDARD TABLE OF lty_obj.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; METHODS:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; validate_keys&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; RAISING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lcx_exc.&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_so DEFINITION&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_so IMPLEMENTATION *--------------------------------------------------------* CLASS lcl_so IMPLEMENTATION.&amp;#160;&amp;#160;&amp;#160; METHOD validate_keys. * This method is closed for the changes but open for *&amp;#160;&amp;#160; adding a new code * We can add any new method call or do something with *&amp;#160;&amp;#160; the objects from the table, but we don't need to *&amp;#160;&amp;#160; change the code which calls IS_VALID method as long *&amp;#160;&amp;#160; as the object reference is avaliable object table&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: la_obj&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; LIKE LINE OF me-&amp;gt;lt_obj,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_subobj&amp;#160;&amp;#160; TYPE REF TO lif_subobj,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lf_valid&amp;#160;&amp;#160;&amp;#160; TYPE boolean.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; LOOP AT me-&amp;gt;lt_obj INTO la_obj.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_subobj ?= la_obj-object.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lf_valid = lo_subobj-&amp;gt;is_valid( ).&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IF lf_valid IS INITIAL.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; RAISE EXCEPTION TYPE lcx_exc&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; EXPORTING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if_text = 'Not Valid'.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ENDIF.&amp;#160;&amp;#160;&amp;#160;&amp;#160; ENDLOOP.&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "validate_keys&amp;#160;&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_so IMPLEMENTATION&lt;/textarea&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;Full&amp;#160;code sinppet&amp;#160;of the program could be found &lt;a class="jive-link-external-small" href="https://wiki.sdn.sap.com/wiki/x/boJCBg"&gt;here&lt;/a&gt;. For completion purpose, I have&amp;#160;included&amp;#160;local class based exception in this coding.&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Change in Requirement:&lt;/strong&gt;&lt;br/&gt;After successful validation of the object, it required to set some attributes of the each object. E.g. set the customer name attribute of the object customer. We will achieve this added requirement without any modification of the method VALIDATE_KEYS. &lt;/p&gt;&lt;p&gt;By adding a new method SET_ATTRIBUTES in the interface LIF_SUBOBJ, it will be available in all implementing classes like LCL_KUNNR, LCL_MATNR. Call this method inside the LOOP of objects after key validation in the method VALIDATE_KEYS. Updated UML will look like this:&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-49814-59562/OCR_R2.png"&gt;&lt;img alt="image" border="1" height="232" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-49814-59562/479-232/OCR_R2.png" width="479"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;And updated code snippet can be found &lt;a class="jive-link-external-small" href="https://wiki.sdn.sap.com/wiki/x/cYJCBg"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br/&gt;Method VALIDATE_KEYS is closed for any modification:&lt;br/&gt;* Achieve the same functionality (e.g. validating the object key) by creating a new class implementing LIF_SUBOBJ (e.g. LCL_WERKS for Plant validation)&lt;br/&gt;* Add a new common functionality (e.g. saving data into Ztable) by creating a new method in the interface (e.g. method SAVE_DATA_TO_ZTAB in class LIF_SUBOBJ)&lt;/p&gt;&lt;/div&gt;&lt;!-- [DocumentBodyEnd:0c8ec86e-997e-4b23-91f4-e25457f0a040] --&gt;</description>
      <pubDate>Tue, 26 May 2009 17:17:30 GMT</pubDate>
      <guid>http://scn.sap.com/people/naimesh.patel/blog/2009/05/26/object-oriented-design-principles-oodp-ocp-with-business-scenario</guid>
      <dc:creator>Naimesh Patel</dc:creator>
      <dc:date>2009-05-26T17:17:30Z</dc:date>
      <clearspace:dateToText>1 year, 6 months ago</clearspace:dateToText>
      <clearspace:replyCount>5</clearspace:replyCount>
      <clearspace:objectType>0</clearspace:objectType>
      <wfw:comment>http://scn.sap.com/people/naimesh.patel/blog/comment/object-oriented-design-principles-oodp-ocp-with-business-scenario</wfw:comment>
      <wfw:commentRss>http://scn.sap.com/people/naimesh.patel/blog/feeds/comments?blogPost=49814</wfw:commentRss>
    </item>
    <item>
      <title>Object Oriented Design Principles (OODP): Open-Closed Principle(OCP)</title>
      <link>http://scn.sap.com/people/naimesh.patel/blog/2009/05/20/object-oriented-design-principles-oodp-open-closed-principleocp</link>
      <description>&lt;!-- [DocumentBodyStart:b45a81ee-2af2-4370-9697-8bd9ba5bdaf3] --&gt;&lt;div class="jive-rendered-content"&gt;&lt;p&gt;We need to follow the Design principle while developing the software to reduce the TCO (Total Cost of Ownership), Reduce the Cost of maintenance and for robust design.&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt;&lt;br/&gt;The name itself sounds like contradicting &amp;ndash; OPEN &amp;amp; CLOSE, but by definition, &lt;em&gt;A module should be OPEN for extension but CLOSED for modification&lt;/em&gt;. The Open-Closed Principle (OCP) is one of the most important Design Principle. OCP originated from the work of by the Bertrand Meyer. &lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;In simple words: We can add new features in the module without changing the existing code (CLOSED) but by adding new code (OPEN).&amp;#160; By following this principle, we can make sure that by changing the code in the method we are not going to break existing functionality. Let us try to see it using the example.&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Example:&lt;br/&gt;&lt;/strong&gt;First of all we would see the code which doesn&amp;rsquo;t follow this principle. Consider we have a class which prints the shape information of different shapes based on the input.&lt;br/&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-49767-59514/OCP_NO.png"&gt;&lt;img alt="image" border="1" height="184" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-49767-59514/463-184/OCP_NO.png" width="463"/&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;Code snippet which violates this principle.&lt;/p&gt;&lt;p&gt;&lt;textarea cols="60" rows="20"&gt;*--------------------------------------------------------* *&amp;amp;&amp;#160; Author : Naimesh Patel *&amp;amp;&amp;#160; Purpose: Open-Closed Principle (violation) *--------------------------------------------------------*&amp;#160; REPORT&amp;#160; ztest_np_ocp.&amp;#160;&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_circle DEFINITION *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Circle *--------------------------------------------------------* CLASS lcl_circle DEFINITION.&amp;#160;&amp;#160;&amp;#160; PUBLIC SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160; METHODS:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; write_circle.&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_circle DEFINITION&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_square DEFINITION *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Square *--------------------------------------------------------* CLASS lcl_square DEFINITION.&amp;#160;&amp;#160;&amp;#160; PUBLIC SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160; METHODS:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; write_square.&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_square DEFINITION&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_report DEFINITION *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Report *--------------------------------------------------------* CLASS lcl_report DEFINITION.&amp;#160;&amp;#160;&amp;#160; PUBLIC SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160; METHODS:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; create_shape&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IMPORTING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if_type TYPE char30,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; write_shape&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IMPORTING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if_type TYPE char30.&amp;#160;&amp;#160;&amp;#160; PRIVATE SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: o_circle TYPE REF TO lcl_circle.&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: o_square TYPE REF TO lcl_square.&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_report DEFINITION&amp;#160; PARAMETERS: p_shape TYPE char30.&amp;#160; START-OF-SELECTION.&amp;#160;&amp;#160; DATA: o_report TYPE REF TO lcl_report.&amp;#160;&amp;#160;&amp;#160; CREATE OBJECT o_report.&amp;#160;&amp;#160;&amp;#160; o_report-&amp;gt;create_shape( p_shape ).&amp;#160;&amp;#160; o_report-&amp;gt;write_shape( p_shape ).&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_circle IMPLEMENTATION *--------------------------------------------------------* * *--------------------------------------------------------* CLASS lcl_circle IMPLEMENTATION.&amp;#160;&amp;#160;&amp;#160; METHOD write_circle.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WRITE: / 'I am a Circle'.&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "write_circle&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_circle IMPLEMENTATION&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_square IMPLEMENTATION *--------------------------------------------------------* * *--------------------------------------------------------* CLASS lcl_square IMPLEMENTATION.&amp;#160;&amp;#160;&amp;#160; METHOD write_square.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WRITE: / 'I am a Square'.&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "write_square&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_square IMPLEMENTATION&amp;#160;&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_report IMPLEMENTATION *--------------------------------------------------------* * *--------------------------------------------------------* CLASS lcl_report IMPLEMENTATION.&amp;#160;&amp;#160;&amp;#160; METHOD create_shape.&amp;#160;&amp;#160;&amp;#160;&amp;#160; CASE if_type.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WHEN 'CIRCLE'.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CREATE OBJECT: me-&amp;gt;o_circle.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WHEN 'SQUARE'.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CREATE OBJECT: me-&amp;gt;o_square.&amp;#160;&amp;#160;&amp;#160;&amp;#160; ENDCASE.&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "create_shapes&amp;#160;&amp;#160;&amp;#160; METHOD write_shape.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CASE if_type.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WHEN 'CIRCLE'.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; me-&amp;gt;o_circle-&amp;gt;write_circle( ).&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WHEN 'SQUARE'.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; me-&amp;gt;o_square-&amp;gt;write_square( ).&amp;#160;&amp;#160;&amp;#160;&amp;#160; ENDCASE.&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "write_shapes&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_report IMPLEMENTATION&lt;/textarea&gt; &lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;Now the problem with this code is, when ever we need to add a new type of Shape, we need to change the code in the CREATE_SHAPE, WRITE_SHAPE method, which is clear violation of the OCP. According to OCP, we should only change the method to add new functionality. Here we are not adding a new functionality. Creation of the Shape Object and writing the information of the different Shape is not a new functionality. So, we must re-design our class and methods to be able to follow the Open Closed Principle.&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;We can use the dynamic polymorphism to achieve Open-Closed design. Check the UML for the new design.&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-49767-59515/OCP_YES.png"&gt;&lt;img alt="image" border="1" height="244" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-49767-59515/514-244/OCP_YES.png" width="514"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Now we would create an interface LIF_SHAPE which we will use to create different shapes like circle using LCL_CIRCLE, square using LCL_SQUARE and so on.&lt;/p&gt;&lt;p&gt;&lt;textarea cols="60" rows="10"&gt;*--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INTERFACE lif_shape *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Shpae Interface *--------------------------------------------------------* INTERFACE lif_shape.&amp;#160;&amp;#160; METHODS:&amp;#160;&amp;#160;&amp;#160;&amp;#160; write_shape. ENDINTERFACE.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lif_shape&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_circle DEFINITION *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Circle uses interface *--------------------------------------------------------* CLASS lcl_circle DEFINITION.&amp;#160;&amp;#160; PUBLIC SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160; INTERFACES lif_shape. ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_circle DEFINITION&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_square DEFINITION *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Square uses interface *--------------------------------------------------------* CLASS lcl_square DEFINITION.&amp;#160;&amp;#160; PUBLIC SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160; INTERFACES lif_shape. ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_square DEFINITION&lt;/textarea&gt; &lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;Implementation of the class LCL_CIRCLE and LCL_SQUARE implements the method &lt;/p&gt;&lt;p&gt;&lt;textarea cols="60" rows="10"&gt;*--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_circle IMPLEMENTATION *--------------------------------------------------------* * *--------------------------------------------------------* CLASS lcl_circle IMPLEMENTATION.&amp;#160;&amp;#160;&amp;#160; METHOD lif_shape~write_shape.&amp;#160;&amp;#160;&amp;#160;&amp;#160; WRITE: 'I am a Circle'.&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lif_shape~write_shape&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_circle IMPLEMENTATION&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_square IMPLEMENTATION *--------------------------------------------------------* * *--------------------------------------------------------* CLASS lcl_square IMPLEMENTATION.&amp;#160;&amp;#160;&amp;#160; METHOD lif_shape~write_shape.&amp;#160;&amp;#160;&amp;#160;&amp;#160; WRITE: 'I am a Square'.&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lif_shape~write_shape&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_square IMPLEMENTATION &lt;/textarea&gt; &lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;Design of the report class is also changed. LCL_REPORT would now accept the class name instead of the simple type to instantiate required object as the parameter of the method CREATE_SHAPE.&lt;/p&gt;&lt;p&gt;&lt;textarea cols="60" rows="10"&gt;*--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_report DEFINITION *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Report *--------------------------------------------------------* CLASS lcl_report DEFINITION.&amp;#160;&amp;#160;&amp;#160; PUBLIC SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160; METHODS:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; create_shape&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IMPORTING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if_type TYPE char30,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; write_shape&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IMPORTING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if_type TYPE char30.&amp;#160;&amp;#160;&amp;#160; PRIVATE SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: o_shape TYPE REF TO lif_shape.&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_report DEFINITION &lt;/textarea&gt; &lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;Implementation of the class LCL_REPORT needs to be changed. CREATE_SHPAE would create the object and WRITE_SHAPE would call the method WRITE_SHAPE from the object O_SHAPE. &lt;/p&gt;&lt;p&gt;&lt;textarea cols="60" rows="10"&gt;*--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_report IMPLEMENTATION *--------------------------------------------------------* * *--------------------------------------------------------* CLASS lcl_report IMPLEMENTATION.&amp;#160;&amp;#160;&amp;#160; METHOD create_shape.&amp;#160; *&amp;#160;&amp;#160; Instantiate the object based on the type&amp;#160;&amp;#160;&amp;#160;&amp;#160; CREATE OBJECT me-&amp;gt;o_shape TYPE (if_type).&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "create_shapes&amp;#160;&amp;#160;&amp;#160; METHOD write_shape.&amp;#160; *&amp;#160;&amp;#160; write shape&amp;#160;&amp;#160;&amp;#160;&amp;#160; me-&amp;gt;o_shape-&amp;gt;write_shape( ).&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "write_shapes&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_report IMPLEMENTATION&lt;/textarea&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;Full code Snippet which shows how to achieve OCP design.&lt;/p&gt;&lt;p&gt;&lt;textarea cols="60" rows="20"&gt;*--------------------------------------------------------* *&amp;amp;&amp;#160; Author&amp;#160; : Naimesh Patel *&amp;amp;&amp;#160; Purpose : Open-Closed Principle (Achieved) *--------------------------------------------------------*&amp;#160; REPORT&amp;#160; ztest_np_ocp.&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INTERFACE lif_shape *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Shpae Interface *--------------------------------------------------------* INTERFACE lif_shape.&amp;#160;&amp;#160; METHODS:&amp;#160;&amp;#160;&amp;#160;&amp;#160; write_shape. ENDINTERFACE.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lif_shape&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_circle DEFINITION *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Circle uses interface *--------------------------------------------------------* CLASS lcl_circle DEFINITION.&amp;#160;&amp;#160; PUBLIC SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160; INTERFACES lif_shape. ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_circle DEFINITION&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_square DEFINITION *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Square uses interface *--------------------------------------------------------* CLASS lcl_square DEFINITION.&amp;#160;&amp;#160; PUBLIC SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160; INTERFACES lif_shape. ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_square DEFINITION&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_report DEFINITION *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Report *--------------------------------------------------------* CLASS lcl_report DEFINITION.&amp;#160;&amp;#160;&amp;#160; PUBLIC SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160; METHODS:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; create_shape&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IMPORTING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if_type TYPE char30,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; write_shape&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IMPORTING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if_type TYPE char30.&amp;#160;&amp;#160;&amp;#160; PRIVATE SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: o_shape TYPE REF TO lif_shape.&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_report DEFINITION&amp;#160; *......selection screen...................................* PARAMETERS: p_shape TYPE char30.&amp;#160; *..... START-OF_SELECTION.................................* START-OF-SELECTION.&amp;#160;&amp;#160; DATA: o_report TYPE REF TO lcl_report,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; w_type&amp;#160;&amp;#160; TYPE char30.&amp;#160; * Name of the Class&amp;#160;&amp;#160; CONCATENATE 'LCL_' p_shape INTO w_type.&amp;#160; * Instantiate the object&amp;#160;&amp;#160; CREATE OBJECT o_report.&amp;#160; * Shape&amp;#160;&amp;#160; o_report-&amp;gt;create_shape( w_type ).&amp;#160;&amp;#160; o_report-&amp;gt;write_shape( w_type ).&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_report IMPLEMENTATION *--------------------------------------------------------* * *--------------------------------------------------------* CLASS lcl_report IMPLEMENTATION.&amp;#160;&amp;#160;&amp;#160; METHOD create_shape.&amp;#160; *&amp;#160;&amp;#160; Instantiate the object based on the type&amp;#160;&amp;#160;&amp;#160;&amp;#160; CREATE OBJECT me-&amp;gt;o_shape TYPE (if_type).&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "create_shapes&amp;#160;&amp;#160;&amp;#160; METHOD write_shape.&amp;#160; *&amp;#160;&amp;#160; write shape&amp;#160;&amp;#160;&amp;#160;&amp;#160; me-&amp;gt;o_shape-&amp;gt;write_shape( ).&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "write_shapes&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_report IMPLEMENTATION&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_circle IMPLEMENTATION *--------------------------------------------------------* * *--------------------------------------------------------* CLASS lcl_circle IMPLEMENTATION.&amp;#160;&amp;#160;&amp;#160; METHOD lif_shape~write_shape.&amp;#160;&amp;#160;&amp;#160;&amp;#160; WRITE: 'I am a Circle'.&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lif_shape~write_shape&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_circle IMPLEMENTATION&amp;#160; *--------------------------------------------------------* *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CLASS lcl_square IMPLEMENTATION *--------------------------------------------------------* * *--------------------------------------------------------* CLASS lcl_square IMPLEMENTATION.&amp;#160;&amp;#160;&amp;#160; METHOD lif_shape~write_shape.&amp;#160;&amp;#160;&amp;#160;&amp;#160; WRITE: 'I am a Square'.&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lif_shape~write_shape&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_square IMPLEMENTATION &lt;/textarea&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;Now, if we want to add a new shape, say TRIANGLE. We can easily add a new shape without changing any existing code. &lt;br/&gt;1. Create a new class LCL_TRIANGLE which implements the interface LIF_SHAPE&lt;br/&gt;2. Implement the method LIF_SHAPE~WRITE_SHAPE in this class.&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br/&gt;By using the polymorphism, now both methods CREATE_SHAPE &amp;amp; WRITE_SHAPE of the class LCL_REPORT are CLOSED for any modification and we have successfully achieved OCP design.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;strong&gt;Credits:&lt;/strong&gt;&lt;br/&gt;&lt;a class="jive-link-external-small" href="http://en.wikipedia.org/wiki/Bertrand_Meyer"&gt;Bertrand Meyer&lt;/a&gt; &lt;br/&gt;&lt;a class="jive-link-external-small" href="http://www.objectmentor.com/omTeam/martin_r.html"&gt;Robert C. Martin&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;!-- [DocumentBodyEnd:b45a81ee-2af2-4370-9697-8bd9ba5bdaf3] --&gt;</description>
      <pubDate>Wed, 20 May 2009 09:47:43 GMT</pubDate>
      <guid>http://scn.sap.com/people/naimesh.patel/blog/2009/05/20/object-oriented-design-principles-oodp-open-closed-principleocp</guid>
      <dc:creator>Naimesh Patel</dc:creator>
      <dc:date>2009-05-20T09:47:43Z</dc:date>
      <clearspace:dateToText>1 year, 6 months ago</clearspace:dateToText>
      <clearspace:replyCount>7</clearspace:replyCount>
      <clearspace:objectType>0</clearspace:objectType>
      <wfw:comment>http://scn.sap.com/people/naimesh.patel/blog/comment/object-oriented-design-principles-oodp-open-closed-principleocp</wfw:comment>
      <wfw:commentRss>http://scn.sap.com/people/naimesh.patel/blog/feeds/comments?blogPost=49767</wfw:commentRss>
    </item>
    <item>
      <title>ABAP and Excel - Create Formatted Excel using XML</title>
      <link>http://scn.sap.com/people/naimesh.patel/blog/2009/02/10/abap-and-excel--create-formatted-excel-using-xml</link>
      <description>&lt;!-- [DocumentBodyStart:e05a9a20-69b7-4cea-97a1-516836083cd9] --&gt;&lt;div class="jive-rendered-content"&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Preface:&lt;/strong&gt;&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;Today&amp;rsquo;s blog &lt;/p&gt;&lt;!--[CodeBlockStart:5326b951-e57e-4d33-80f8-4864bf992fee]--&gt;&lt;span&gt;&lt;span&gt;The specified item was not found.&lt;/span&gt;&lt;/span&gt;&lt;!--[CodeBlockEnd:5326b951-e57e-4d33-80f8-4864bf992fee]--&gt;&lt;p&gt;&lt;span&gt; from Alvaro Tejada&amp;#160; (&lt;/span&gt;&lt;a class="jive-link-external-small" href="https://wiki.sdn.sap.com/wiki/x/nDk"&gt;https://wiki.sdn.sap.com/wiki/x/nDk&lt;/a&gt;&lt;span&gt;) has reminded me that we can also use the XML to create formatted, fancy Excel files using ABAP and XML.&lt;/span&gt;&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;The advantages of the XML technique over the OLE:&lt;/p&gt;&lt;ul&gt;&lt;ul&gt;&lt;li level="2" type="ul"&gt;&lt;p&gt;Using XML we can send the fancy generated file as an Email Attachment.&lt;/p&gt;&lt;/li&gt;&lt;li level="2" type="ul"&gt;&lt;p&gt;We can create formatted excel file using the XML technique from the Web applications generated using Web Dynpro or BSP.&lt;/p&gt;&lt;/li&gt;&lt;li level="2" type="ul"&gt;&lt;p&gt;It&amp;rsquo;s faster compared OLE technique&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;span&gt;We can use the CALL TRANSFORMATION&amp;#160; (&lt;/span&gt;&lt;a class="jive-link-external-small" href="http://help.sap.com/saphelp_nw04s/helpdata/en/e3/7d4719ca581441b6841f1054ff1326/frameset.htm"&gt;http://help.sap.com/saphelp_nw04s/helpdata/en/e3/7d4719ca581441b6841f1054ff1326/frameset.htm&lt;/a&gt;&lt;span&gt;) to convert our internal table data to the formatted Excel. As release 6.10, ABAP run time environment contains the XSLT processor for executing the transformation. Alternativly, we can use CONCATENATE syntax to XML string using the XML tags and the data, but it would be as clean as CALL TRANSFORMATION.&lt;/span&gt;&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Code to Generate sample Excel&lt;/strong&gt;&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;*&amp;amp;----&lt;/p&gt;&lt;hr originalText="---------------------------------------------------------------"/&gt;&lt;p&gt;*&lt;/p&gt;&lt;p&gt;*&amp;amp; Report&amp;#160; ZTEST_NP_EXCEL_XML&lt;/p&gt;&lt;p&gt;*&amp;amp;&lt;/p&gt;&lt;p&gt;*&amp;amp; Download the formatted excel file using XML&lt;/p&gt;&lt;p&gt;*&amp;amp;----&lt;/p&gt;&lt;hr originalText="---------------------------------------------------------------"/&gt;&lt;p&gt;*&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;REPORT&amp;#160; ztest_np_excel_xml.&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;TYPES: BEGIN OF ty_mara,&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; matnr TYPE matnr,&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; maktx TYPE char30,&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; END&amp;#160;&amp;#160; OF ty_mara.&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;DATA: itab TYPE STANDARD TABLE OF ty_mara,&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; la_tab LIKE LINE OF itab,&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; xmlstr TYPE string.&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;START-OF-SELECTION.&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;*----&lt;/p&gt;&lt;hr originalText="---"/&gt;&lt;ul&gt;&lt;li level="1" type="ul"&gt;&lt;p&gt;Test table&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;*----&lt;/p&gt;&lt;hr originalText="---"/&gt;&lt;p&gt;&amp;#160; la_tab-matnr = 'TEST1'.&lt;/p&gt;&lt;p&gt;&amp;#160; la_tab-maktx = 'Test description'.&lt;/p&gt;&lt;p&gt;&amp;#160; APPEND la_tab TO itab.&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&amp;#160; la_tab-matnr = 'TEST2'.&lt;/p&gt;&lt;p&gt;&amp;#160; la_tab-maktx = 'Test description 2'.&lt;/p&gt;&lt;p&gt;&amp;#160; APPEND la_tab TO itab.&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;*----&lt;/p&gt;&lt;hr originalText="---"/&gt;&lt;ul&gt;&lt;li level="1" type="ul"&gt;&lt;p&gt;Get the XML data excel&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;*----&lt;/p&gt;&lt;hr originalText="---"/&gt;&lt;p&gt;&amp;#160; CALL TRANSFORMATION ztest_np_xls&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; SOURCE table = itab&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; RESULT XML xmlstr.&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;*----&lt;/p&gt;&lt;hr originalText="---"/&gt;&lt;ul&gt;&lt;li level="1" type="ul"&gt;&lt;p&gt;Download the file&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;*----&lt;/p&gt;&lt;hr originalText="---"/&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;ul&gt;&lt;li level="1" type="ul"&gt;&lt;p&gt;Fill the table&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&amp;#160; DATA: xml_table TYPE STANDARD TABLE OF string.&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&amp;#160; APPEND xmlstr TO xml_table.&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&amp;#160; DATA: window_title TYPE string,&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; fullpath TYPE string,&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; path TYPE string,&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; user_action TYPE i,&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; default_extension TYPE string,&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; default_file_name TYPE string,&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; file_filter TYPE&amp;#160; string,&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; filename TYPE string,&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; initialpath TYPE string.&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;ul&gt;&lt;li level="1" type="ul"&gt;&lt;p&gt;File selection&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&amp;#160; MOVE '.XLS' TO default_extension.&lt;/p&gt;&lt;p&gt;&amp;#160; MOVE 'XLS files (&lt;strong&gt;.XLS)|&lt;/strong&gt;.XLS' TO file_filter.&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&amp;#160; CALL METHOD cl_gui_frontend_services=&amp;gt;file_save_dialog&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; EXPORTING&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; default_extension = default_extension&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; default_file_name = default_file_name&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; file_filter&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = file_filter&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; initial_directory = initialpath&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; CHANGING&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; filename&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = filename&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; path&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = path&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; fullpath&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = fullpath&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; user_action&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = user_action&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; EXCEPTIONS&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cntl_error&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = 1&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; error_no_gui&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = 2&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OTHERS&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = 3.&lt;/p&gt;&lt;p&gt;&amp;#160; IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/p&gt;&lt;p&gt;&amp;#160; ENDIF.&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;ul&gt;&lt;li level="1" type="ul"&gt;&lt;p&gt;download file&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&amp;#160; CALL FUNCTION 'GUI_DOWNLOAD'&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; EXPORTING&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; filename&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = fullpath&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; filetype&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = 'ASC'&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; TABLES&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; data_tab&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = xml_table&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; EXCEPTIONS&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; file_write_error&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = 1&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; no_batch&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = 2&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; gui_refuse_filetransfer = 3&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; invalid_type&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = 4&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OTHERS&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = 5.&lt;/p&gt;&lt;p&gt;&amp;#160; IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/p&gt;&lt;p&gt; MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno&lt;/p&gt;&lt;p&gt; WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/p&gt;&lt;p&gt; ENDIF.&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt; &amp;#160;&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;XML transformation&lt;/strong&gt;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&amp;lt;textarea cols="60" rows="20"&amp;gt;&amp;lt;?sap.transform simple?&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;?mso-application progid="Excel.Sheet"?&amp;gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&amp;lt;tt:transform xmlns:tt="&lt;/span&gt;&lt;a class="jive-link-external-small" href="http://www.sap.com/transformation-templates"&gt;http://www.sap.com/transformation-templates&lt;/a&gt;&lt;span&gt;"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&amp;#160; &amp;lt;tt:root name="table"/&amp;gt;&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&amp;#160; &amp;lt;tt:template&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html=&lt;/p&gt;&lt;p&gt;&lt;span&gt;"&lt;/span&gt;&lt;a class="jive-link-external-small" href="http://www.w3.org/TR/REC-html40"&gt;http://www.w3.org/TR/REC-html40&lt;/a&gt;&lt;span&gt;"&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Author&amp;gt;npatel&amp;lt;/Author&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;LastAuthor&amp;gt;npatel&amp;lt;/LastAuthor&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Created&amp;gt;2009-01-01T22:27:09Z&amp;lt;/Created&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Company&amp;gt;&amp;lt;/Company&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Version&amp;gt;11.8132&amp;lt;/Version&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/DocumentProperties&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;WindowHeight&amp;gt;12660&amp;lt;/WindowHeight&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;WindowWidth&amp;gt;19980&amp;lt;/WindowWidth&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;WindowTopX&amp;gt;480&amp;lt;/WindowTopX&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;WindowTopY&amp;gt;120&amp;lt;/WindowTopY&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;ProtectStructure&amp;gt;False&amp;lt;/ProtectStructure&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;ProtectWindows&amp;gt;False&amp;lt;/ProtectWindows&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/ExcelWorkbook&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Styles&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Style ss:ID="Default" ss:Name="Normal"&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Alignment ss:Vertical="Bottom"&amp;gt;&amp;lt;/Alignment&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Borders&amp;gt;&amp;lt;/Borders&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Font&amp;gt;&amp;lt;/Font&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Interior&amp;gt;&amp;lt;/Interior&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;NumberFormat/&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Protection&amp;gt;&amp;lt;/Protection&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Style&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Style ss:ID="s23"&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Font ss:Bold="1" ss:Size="26" x:Family="Swiss"&amp;gt;&amp;lt;/Font&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Interior ss:Color="#FFFF99" ss:Pattern="Solid"&amp;gt;&amp;lt;/Interior&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Style&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Styles&amp;gt;&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Worksheet ss:Name="Sheet1"&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Table ss:ExpandedColumnCount="3" ss:ExpandedRowCount="25" x:FullColumns="1" x:FullRows="1"&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Column ss:Width="152.25"/&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Column ss:Width="180"/&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Column ss:Width="117"/&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Row&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Cell ss:StyleID="s23"&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Data ss:Type="String"&amp;gt;Material No&amp;lt;/Data&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Cell&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Cell ss:StyleID="s23"&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Data ss:Type="String"&amp;gt;Material Desc&amp;lt;/Data&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Cell&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Row&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;tt:loop ref=".table"&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Row&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Cell&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Data ss:Type="String"&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;tt:value ref="MATNR"/&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Data&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Cell&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Cell&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Data ss:Type="String"&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;tt:value ref="MAKTX"/&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Data&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Cell&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Row&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/tt:loop&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Table&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Selected/&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Panes&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Pane&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Number&amp;gt;3&amp;lt;/Number&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;ActiveRow&amp;gt;4&amp;lt;/ActiveRow&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;ActiveCol&amp;gt;1&amp;lt;/ActiveCol&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Pane&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Panes&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;ProtectObjects&amp;gt;False&amp;lt;/ProtectObjects&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;ProtectScenarios&amp;gt;False&amp;lt;/ProtectScenarios&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/WorksheetOptions&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Worksheet&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Worksheet ss:Name="Sheet2"&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;ProtectObjects&amp;gt;False&amp;lt;/ProtectObjects&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;ProtectScenarios&amp;gt;False&amp;lt;/ProtectScenarios&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/WorksheetOptions&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Worksheet&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;Worksheet ss:Name="Sheet3"&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;ProtectObjects&amp;gt;False&amp;lt;/ProtectObjects&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;ProtectScenarios&amp;gt;False&amp;lt;/ProtectScenarios&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/WorksheetOptions&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Worksheet&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/Workbook&amp;gt;&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&amp;#160; &amp;lt;/tt:template&amp;gt;&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&amp;lt;/tt:transform&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;/textarea&amp;gt; &amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&lt;strong&gt;Output:&amp;lt;br /&amp;gt;&lt;/strong&gt;This test program will generate the formatted excel like this: &lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-48838-57716/3_excel_output.png"&gt;&lt;img alt="image" border="1" height="260" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-48838-57716/496-260/3_excel_output.png" width="496"/&gt;&lt;/a&gt; &lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;How to get the proper STYLE tag definition for particular formatting&lt;/strong&gt;:&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;1.&amp;#160;Create an test excel file in the MS Excel with the required formatting&lt;/p&gt;&lt;p&gt;2.&amp;#160;Save the file as the XML file.&lt;/p&gt;&lt;p&gt;3.&amp;#160;Open the file using the Notepad to know the Style&lt;/p&gt;&lt;p&gt;For example: Font-size 26, Background Color yellow will get us this Style&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-48838-57717/1style.png"&gt;&lt;img alt="image" border="1" height="183" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-48838-57717/560-183/1style.png" width="560"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;4.&amp;#160;Change the XML transformation accordingly&lt;/p&gt;&lt;p&gt;Like:&lt;/p&gt;&lt;p&gt;&lt;span&gt;!&lt;/span&gt;&lt;a class="jive-link-external-small" href="https://weblogs.sdn.sap.com/weblogs/images/47199/2_xml_style.png|height=284|alt=image|width=477|src=https://weblogs.sdn.sap.com/weblogs/images/47199/2_xml_style.png|border=1"&gt;https://weblogs.sdn.sap.com/weblogs/images/47199/2_xml_style.png|height=284|alt=image|width=477|src=https://weblogs.sdn.sap.com/weblogs/images/47199/2_xml_style.png|border=1&lt;/a&gt;&lt;span&gt;!&amp;lt;/body&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;!-- [DocumentBodyEnd:e05a9a20-69b7-4cea-97a1-516836083cd9] --&gt;</description>
      <pubDate>Tue, 10 Feb 2009 15:44:16 GMT</pubDate>
      <guid>http://scn.sap.com/people/naimesh.patel/blog/2009/02/10/abap-and-excel--create-formatted-excel-using-xml</guid>
      <dc:creator>Naimesh Patel</dc:creator>
      <dc:date>2009-02-10T15:44:16Z</dc:date>
      <clearspace:dateToText>1 year, 6 months ago</clearspace:dateToText>
      <clearspace:replyCount>12</clearspace:replyCount>
      <clearspace:objectType>0</clearspace:objectType>
      <wfw:comment>http://scn.sap.com/people/naimesh.patel/blog/comment/abap-and-excel--create-formatted-excel-using-xml</wfw:comment>
      <wfw:commentRss>http://scn.sap.com/people/naimesh.patel/blog/feeds/comments?blogPost=48838</wfw:commentRss>
    </item>
    <item>
      <title>Power of ABAP Objects: Overcome the Restrictions of SALV Model</title>
      <link>http://scn.sap.com/people/naimesh.patel/blog/2008/11/24/power-of-abap-objects-overcome-the-restrictions-of-salv-model</link>
      <description>&lt;!-- [DocumentBodyStart:fbcdc5a8-0ea1-41f3-8368-df29522e31dd] --&gt;&lt;div class="jive-rendered-content"&gt;&lt;p&gt;We&amp;#160;all know that ABAP Object is very powerful over the classical ABAP.&amp;#160;Here I want to share one&amp;#160;of my best experiments&amp;#160;with the ABAP objects to overcome the restrictions of SALV mdoel.&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Background&lt;/strong&gt;&lt;br/&gt;I was reading the help on the CL_SALV_TABLE to get more insight of how to use this new SALV model effectively. When I came across the section Recommendation and Restriction, I was amazed by reading "Tables displayed with ALV are not ready for input".&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-48210-56846/1doc_4.png"&gt;&lt;img alt="image" border="1" height="258" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-48210-56846/640-258/1doc_4.png" width="640"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;It was very hard for me to understand this restriction because: The new SALV model is unified object oriented model which has kind of wrapper classes which are ultimately calling the FM REUSE_ALV_GRID_DISPLAY or REUSE_ALV_LIST_DISPLAY; class GL_GUI_ALV_GRID and so on. So, if the ALV created with the CL_GUI_ALV_GRID can be ready for input, why can&amp;rsquo;t the ALV created with the SALV model be the "Ready for input"? This propelled me to analyze how we can make the ALV Full-screen as "Set ready for Input".&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Journey to&amp;#160;find&amp;#160;the solution&lt;/strong&gt;&lt;br/&gt;By putting breakpoints and debugging, I came to know that when I tried to generate the fullscreen ALV, it calls the FM REUSE_ALV_GRID_DISPLAY and this FM in turn uses the class CL_GUI_ALV_GRID to generate the ALV. &lt;/p&gt;&lt;p&gt;Before couple of months, I came across a very powerful function module GET_GLOBALS_FROM_SLVC_FULLSCR which gives us the object of type GL_GUI_ALV_GRID which was created to generate the fullscreen ALV. I have used this FM in couple of programs to achieve some functionality which is not possible using the FM REUSE_ALV_GRID_DISPLAY. Some of them:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a class="jive-link-external-small" href="http://help-abap.blogspot.com/2008/09/moving-cursor-to-next-row-by-pressing.html"&gt;Move Cursor to next row by pressing enter in Full-screen ALV&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="jive-link-external-small" href="http://help-abap.blogspot.com/2008/10/alv-disable-delete-key-on-keyboard-in.html"&gt;Full-screen ALV: Disable DELTE key of Keyboard&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="jive-link-external-small" href="http://help-abap.blogspot.com/2008/09/classical-alv-change-subtotal.html"&gt;Full-screen ALV: Change Subtotal&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="jive-link-message-small" data-containerId="2015" data-containerType="14" data-objectId="6330863" data-objectType="2" href="http://scn.sap.com/message/6330863#6330863"&gt;Re: Can we scroll to the last page of an alv grid?&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Basically, to achieve this type of not achievable functionality of the Fullscreen ALV, I get the object using the FM GET_GLOBALS_FROM_SLVC_FULLSCR and use the methods available in the CL_GUI_GRID_DISPLAY followed by the refresh method to refresh the ALV.&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;Based on the assumption - if I get the ALV object from the SALV model than I can make the SALV model ALV to "Set Ready for input" -&amp;#160; I have started searching the ALV object in the SALV model. At the very top node of the SALV model CL_SALV_MODEL, I got the methods (GET_GRID) which can provide me the ALV grid object.&lt;/p&gt;&lt;p&gt;UML diagram contains the SALV hierarchy and visibility of the R_CONTROLLER:&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-48210-56847/2SALV_GRID.png"&gt;&lt;img alt="image" border="1" height="360" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-48210-56847/630-360/2SALV_GRID.png" width="630"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Class CL_SALV_MODEL has a protected attribute R_CONTROLLER which has everything I need to get to GRID object. So, I tried to access that attribute directly, but obviously I didn&amp;rsquo;t work as I didn&amp;rsquo;t have the object reference for the CL_SALV_MODEL. By this point of time,&amp;#160;I have tried all the&amp;#160;normal ways to get the access the R_CONTROLLER&amp;#160;- like&amp;#160;Feild-symbol to access the&amp;#160;object from&amp;#160;memory but that didn't work either.&amp;#160;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Solution&lt;br/&gt;&lt;/strong&gt;I knew that I have to think in a different way,&amp;#160;and&amp;#160;I tried to inherite the class from the&amp;#160;class CL_SALV_MODEL_LIST, passed the ALV model to the class and tried to access the R_CONTROLLER and&amp;#160;BINGO - I am able to access the R_CONTROLLER in my inherited class.&lt;/p&gt;&lt;p&gt;UML Diagram shows the iherited class along with the existing SALV model:&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-48210-56848/3SALV_GRID_LOCAL.png"&gt;&lt;img alt="image" border="1" height="320" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-48210-56848/640-320/3SALV_GRID_LOCAL.png" width="640"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Steps to follow:&lt;br/&gt;&lt;/strong&gt;1. Inherited a local class LCL_SALV_MODEL from the CL_SALV_MODEL_LIST&lt;br/&gt;2. Generate SALV model to generate the ALV object&lt;br/&gt;3. Used narrow casting to get the CL_SALV_MODEL object from the ALV object&lt;br/&gt;4. Passed this CL_SALV_MODEL object to the inherited class LCL_SALV_MODEL. Since LCL_SALV_MODEL is inherited from the CL_SALV_MODEL_LIST, it allows me to access the R_CONTROLLER of the CL_SALV_MODEL.&lt;br/&gt;5. Get the GRID object from the object MODEL -&amp;gt; Controller -&amp;gt; Adapter -&amp;gt; Grid.&lt;br/&gt;6. Set the Layout for EDIT and Refresh the ALV.&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;When we run the report, ALV will not come directly&amp;#160;in the input&amp;#160;mode:&lt;br/&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-48210-56849/4ALV_op.png"&gt;&lt;img alt="image" border="0" height="173" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-48210-56849/580-173/4ALV_op.png" width="580"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;As soon as we press the "My Function" button, ALV will change into editable ALV. This ALV will have its separate GUI Status which contains all the required buttons for the Editable ALV.&lt;br/&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-48210-56850/5ALV_op_input1.png"&gt;&lt;img alt="image" border="0" height="247" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-48210-56850/640-247/5ALV_op_input1.png" width="640"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Code Snippet&lt;br/&gt;&lt;/strong&gt;UML diagram for code snippet:&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-48210-56851/SALV_GRID_APPS.png"&gt;&lt;img alt="image" border="1" height="380" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-48210-56851/640-380/SALV_GRID_APPS.png" width="640"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;Here is the code, which I used to get the access of the GRID object from the SALV model and to make ALV editable. Here I have used the PF-STATUS avaliable in the report program SALV_DEMO_TABLE_EVENTS&amp;#160;for easy installation of this demo report.&lt;/p&gt;&lt;textarea cols="75" rows="20"&gt;*&amp;amp;---------------------------------------------------------------------* *&amp;amp; Report&amp;#160; ZTEST_NP_EDIT_SALV *&amp;amp; Overcome the restriction of the SALV model using the power of the *&amp;amp;&amp;#160;&amp;#160; Object Oriented ABAP *&amp;amp;---------------------------------------------------------------------*&amp;#160; REPORT&amp;#160; ztest_np_edit_salv.&amp;#160; *----------------------------------------------------------------------* *&amp;#160; Define the Local class inheriting from the CL_SALV_MODEL_LIST *&amp;#160; to get an access of the model, controller and adapter which inturn *&amp;#160; provides the Grid Object *----------------------------------------------------------------------* CLASS lcl_salv_model DEFINITION INHERITING FROM cl_salv_model_list.&amp;#160;&amp;#160;&amp;#160; PUBLIC SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: o_control TYPE REF TO cl_salv_controller_model,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; o_adapter TYPE REF TO cl_salv_adapter.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; METHODS:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; grabe_model&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IMPORTING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; io_model TYPE REF TO cl_salv_model,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; grabe_controller,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; grabe_adapter.&amp;#160;&amp;#160;&amp;#160;&amp;#160; PRIVATE SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: lo_model TYPE REF TO cl_salv_model.&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "LCL_SALV_MODEL DEFINITION&amp;#160; *----------------------------------------------------------------------* * Event handler for the added buttons *----------------------------------------------------------------------* CLASS lcl_event_handler DEFINITION.&amp;#160;&amp;#160;&amp;#160; PUBLIC SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160; METHODS:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; on_user_command FOR EVENT added_function OF cl_salv_events&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IMPORTING e_salv_function.&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_event_handler DEFINITION&amp;#160;&amp;#160; *----------------------------------------------------------------------* * Local Report class - Definition *----------------------------------------------------------------------* CLASS lcl_report DEFINITION.&amp;#160;&amp;#160;&amp;#160; PUBLIC SECTION.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TYPES: ty_t_sflights TYPE STANDARD TABLE OF sflights.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: t_data TYPE ty_t_sflights.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: o_salv&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TYPE REF TO cl_salv_table.&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: o_salv_model TYPE REF TO lcl_salv_model.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; METHODS:&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get_data,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; generate_output.&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_report DEFINITION&amp;#160; *----------------------------------------------------------------------* * Global data *----------------------------------------------------------------------* DATA: lo_report TYPE REF TO lcl_report.&amp;#160; *----------------------------------------------------------------------* * Start of selection *----------------------------------------------------------------------* START-OF-SELECTION.&amp;#160;&amp;#160;&amp;#160; CREATE OBJECT lo_report.&amp;#160;&amp;#160;&amp;#160; lo_report-&amp;gt;get_data( ).&amp;#160;&amp;#160;&amp;#160; lo_report-&amp;gt;generate_output( ).&amp;#160;&amp;#160; *----------------------------------------------------------------------* * Local Report class - Implementation *----------------------------------------------------------------------* CLASS lcl_report IMPLEMENTATION.&amp;#160;&amp;#160;&amp;#160; METHOD get_data.&amp;#160; *&amp;#160;&amp;#160; test data&amp;#160;&amp;#160;&amp;#160;&amp;#160; SELECT * FROM sflights&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; INTO TABLE me-&amp;gt;t_data&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; UP TO 30 ROWS.&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "get_data&amp;#160;&amp;#160;&amp;#160; METHOD generate_output.&amp;#160; *...New ALV Instance ...............................................&amp;#160;&amp;#160;&amp;#160;&amp;#160; TRY.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; cl_salv_table=&amp;gt;factory(&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; EXPORTING *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; r_container&amp;#160;&amp;#160;&amp;#160; = w_alv1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; list_display = abap_false&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IMPORTING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; r_salv_table = o_salv&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CHANGING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; t_table&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = t_data ).&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CATCH cx_salv_msg.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "#EC NO_HANDLER&amp;#160;&amp;#160;&amp;#160;&amp;#160; ENDTRY.&amp;#160; *...PF Status....................................................... *&amp;#160;&amp;#160; Add MYFUNCTION from the report SALV_DEMO_TABLE_EVENTS&amp;#160;&amp;#160;&amp;#160;&amp;#160; o_salv-&amp;gt;set_screen_status(&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; pfstatus&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; =&amp;#160; 'SALV_STANDARD'&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; report&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; =&amp;#160; 'SALV_DEMO_TABLE_EVENTS'&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set_functions = o_salv-&amp;gt;c_functions_all ).&amp;#160; *...Event handler for the button.....................................&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: lo_events TYPE REF TO cl_salv_events_table,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_event_h TYPE REF TO lcl_event_handler.&amp;#160; * event object&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_events = o_salv-&amp;gt;get_event( ).&amp;#160; * event handler&amp;#160;&amp;#160;&amp;#160;&amp;#160; CREATE OBJECT lo_event_h.&amp;#160; * setting up the event handler&amp;#160;&amp;#160;&amp;#160;&amp;#160; SET HANDLER lo_event_h-&amp;gt;on_user_command FOR lo_events.&amp;#160;&amp;#160; *...Get Model Object ...............................................&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: lo_alv_mod TYPE REF TO cl_salv_model.&amp;#160; *&amp;#160;&amp;#160; Narrow casting&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_alv_mod ?= o_salv.&amp;#160; *&amp;#160;&amp;#160; object for the local inherited class from the CL_SALV_MODEL_LIST&amp;#160;&amp;#160;&amp;#160;&amp;#160; CREATE OBJECT o_salv_model.&amp;#160; *&amp;#160;&amp;#160; grabe model to use it later&amp;#160;&amp;#160;&amp;#160;&amp;#160; CALL METHOD o_salv_model-&amp;gt;grabe_model&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; EXPORTING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; io_model = lo_alv_mod.&amp;#160; *...Generate ALV output ...............................................&amp;#160;&amp;#160;&amp;#160;&amp;#160; o_salv-&amp;gt;display( ).&amp;#160;&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "generate_output&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_report IMPLEMENTATION&amp;#160; *----------------------------------------------------------------------* * LCL_SALV_MODEL implementation *----------------------------------------------------------------------* CLASS lcl_salv_model IMPLEMENTATION.&amp;#160;&amp;#160;&amp;#160; METHOD grabe_model.&amp;#160; *&amp;#160;&amp;#160; save the model&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_model = io_model.&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "grabe_model&amp;#160;&amp;#160;&amp;#160; METHOD grabe_controller.&amp;#160; *&amp;#160;&amp;#160; save the controller&amp;#160;&amp;#160;&amp;#160;&amp;#160; o_control = lo_model-&amp;gt;r_controller.&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "grabe_controller&amp;#160;&amp;#160;&amp;#160; METHOD grabe_adapter.&amp;#160; *&amp;#160;&amp;#160; save the adapter from controller&amp;#160;&amp;#160;&amp;#160;&amp;#160; o_adapter ?= lo_model-&amp;gt;r_controller-&amp;gt;r_adapter.&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "grabe_adapter&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "LCL_SALV_MODEL IMPLEMENTATION&amp;#160; *----------------------------------------------------------------------* * Event Handler for the SALV *----------------------------------------------------------------------* CLASS lcl_event_handler IMPLEMENTATION.&amp;#160;&amp;#160;&amp;#160; METHOD on_user_command.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: lo_grid TYPE REF TO cl_gui_alv_grid,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_full_adap TYPE REF TO cl_salv_fullscreen_adapter.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: ls_layout TYPE lvc_s_layo.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CASE e_salv_function.&amp;#160; *&amp;#160;&amp;#160;&amp;#160;&amp;#160; Make ALV as Editable ALV&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WHEN 'MYFUNCTION'.&amp;#160; *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Contorller&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CALL METHOD lo_report-&amp;gt;o_salv_model-&amp;gt;grabe_controller.&amp;#160; *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Adapter&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CALL METHOD lo_report-&amp;gt;o_salv_model-&amp;gt;grabe_adapter.&amp;#160; *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Fullscreen Adapter (Down Casting)&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_full_adap ?= lo_report-&amp;gt;o_salv_model-&amp;gt;o_adapter.&amp;#160; *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Get the Grid&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_grid = lo_full_adap-&amp;gt;get_grid( ).&amp;#160; *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Got the Grid .. ?&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IF lo_grid IS BOUND.&amp;#160; *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Editable ALV&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ls_layout-edit = 'X'.&amp;#160; *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Set the front layout of ALV&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CALL METHOD lo_grid-&amp;gt;set_frontend_layout&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; EXPORTING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; is_layout = ls_layout.&amp;#160; *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; refresh the table&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CALL METHOD lo_grid-&amp;gt;refresh_table_display.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ENDIF.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ENDCASE.&amp;#160;&amp;#160;&amp;#160; ENDMETHOD.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "on_user_command&amp;#160; ENDCLASS.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; "lcl_event_handler IMPLEMENTATION&lt;/textarea&gt;&lt;span&gt; &lt;/span&gt;&lt;br/&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong style="text-decoration: underline;"&gt;Example 2: Background Wallpaper in ALV created using SALV model&lt;br/&gt;&lt;/strong&gt;When we pass the parameter I_BACKGROUND_ID in the function module REUSE_ALV_GRID_DISPLAY, we will get the background wallpaper in the top of page section of the ALV.&lt;/p&gt;&lt;p&gt;SALV model uses the class CL_SALV_FORM_DYDOS to generate the TOP-OF-PAGE header from the SALV Form object (CL_SALV_FORM). CL_SALV_FORM is used to generate the Header in the SALV model.&lt;/p&gt;&lt;p&gt;When SALV model creates an object for the CL_SALV_FORM_DYDOS, it doesn&amp;rsquo;t pass the Wallpaper picture. Thus, we are not able to get the header background wallpaper in the SALV model. &lt;/p&gt;&lt;p&gt;To get the wallpaper in the header, we can use the same solution which we have used to make Editable ALV.&lt;/p&gt;&lt;p&gt;ALV header without wallpaper using the SALV model:&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-48210-56852/6ALV_wp.png"&gt;&lt;img alt="image" border="0" height="202" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-48210-56852/605-202/6ALV_wp.png" width="605"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;ALV header with the wallpaper using the SALV model:&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-48210-56853/7ALV_wp_with.png"&gt;&lt;img alt="image" border="0" height="199" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-48210-56853/622-199/7ALV_wp_with.png" width="622"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Code snippet&lt;/strong&gt; to get the header with the wallpaper:&lt;/p&gt;&lt;p&gt;Get the Header in the SALV:&lt;/p&gt;&lt;p&gt;&lt;textarea cols="75" rows="10"&gt;* Code comes before the calling the Display method of SALV * O_SALV-&amp;gt;DISPLAY( ) *...Header.......... ...............................................&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: lo_header&amp;#160; TYPE REF TO cl_salv_form_layout_grid,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_h_label TYPE REF TO cl_salv_form_label,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_h_flow&amp;#160; TYPE REF TO cl_salv_form_layout_flow.&amp;#160; *&amp;#160;&amp;#160; header object&amp;#160;&amp;#160;&amp;#160;&amp;#160; CREATE OBJECT lo_header.&amp;#160; *&amp;#160;&amp;#160; information in Bold&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_h_label = lo_header-&amp;gt;create_label( row = 1 column = 1 ).&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_h_label-&amp;gt;set_text( 'Header in Bold' ).&amp;#160; *&amp;#160;&amp;#160; information in tabular format&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_h_flow = lo_header-&amp;gt;create_flow( row = 2&amp;#160; column = 1 ).&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_h_flow-&amp;gt;create_text( text = 'This is text of flow' ).&amp;#160; *&amp;#160;&amp;#160; set the top of list using the header for Online.&amp;#160;&amp;#160;&amp;#160;&amp;#160; o_salv-&amp;gt;set_top_of_list( lo_header ). &lt;/textarea&gt; &lt;/p&gt;&lt;p&gt;Set the background wallpaper by accessing the GRID and TOP-of-LIST object&lt;/p&gt;&lt;p&gt;&lt;textarea cols="75" rows="10"&gt;* Code comes in the event handler of the added button.&amp;#160; *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Get the Grid&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_grid = lo_full_adap-&amp;gt;get_grid( ).&amp;#160; *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Got the Grid.. ?&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IF lo_grid IS BOUND.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DATA: lo_form_tol TYPE REF TO cl_salv_form,&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_dydos&amp;#160;&amp;#160;&amp;#160; TYPE REF TO cl_salv_form_dydos.&amp;#160; *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Get the Top of list object using the adapter&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; EXPORTING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ir_salv_fullscreen_adapter = lo_full_adap&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IMPORTING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; er_form_tol&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = lo_form_tol.&amp;#160; *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Got the Top Of List object.. ?&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IF lo_form_tol IS BOUND.&amp;#160; *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get the object using the Wide Casting&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_dydos ?= lo_form_tol.&amp;#160; *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set the wallpaper&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lo_dydos-&amp;gt;set_wallpaper( 'ALV_BACKGROUND' ).&amp;#160; *&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; refresh the table&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CALL METHOD lo_grid-&amp;gt;refresh_table_display.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ENDIF.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ENDIF.&lt;/textarea&gt;&lt;/p&gt;&lt;/div&gt;&lt;!-- [DocumentBodyEnd:fbcdc5a8-0ea1-41f3-8368-df29522e31dd] --&gt;</description>
      <pubDate>Mon, 24 Nov 2008 13:37:23 GMT</pubDate>
      <guid>http://scn.sap.com/people/naimesh.patel/blog/2008/11/24/power-of-abap-objects-overcome-the-restrictions-of-salv-model</guid>
      <dc:creator>Naimesh Patel</dc:creator>
      <dc:date>2008-11-24T13:37:23Z</dc:date>
      <clearspace:dateToText>1 year, 6 months ago</clearspace:dateToText>
      <clearspace:replyCount>22</clearspace:replyCount>
      <clearspace:objectType>0</clearspace:objectType>
      <wfw:comment>http://scn.sap.com/people/naimesh.patel/blog/comment/power-of-abap-objects-overcome-the-restrictions-of-salv-model</wfw:comment>
      <wfw:commentRss>http://scn.sap.com/people/naimesh.patel/blog/feeds/comments?blogPost=48210</wfw:commentRss>
    </item>
    <item>
      <title>LSMW with RFBIBL00</title>
      <link>http://scn.sap.com/people/naimesh.patel/blog/2008/08/14/lsmw-with-rfbibl00</link>
      <description>&lt;!-- [DocumentBodyStart:ceaf1124-01c0-4373-af15-7e108d3aede6] --&gt;&lt;div class="jive-rendered-content"&gt;&lt;p&gt;In the ABAP Forum, there are couple of questions unanswered related to LSMW using standard program RFBIBL00 to post the FI documents. That inspried me to write this Blog.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Step 1: Maintain Object Attributes&lt;/strong&gt;&lt;br/&gt;For creating the FI document with the RFBIBL00 using LSMW, we have to select the object 0100, method 0000 and program RFBIBL00.&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-47031-55043/1Assignprogram.png"&gt;&lt;img alt="image" border="0" height="135" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-47031-55043/561-135/1Assignprogram.png" width="561"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Step 2: Maintain Source Structures&lt;/strong&gt;&lt;br/&gt;We will create total two structures: One for header and another for item. We could have at least two line items in the FI document. So, we need to upload at least 2 records per document. To upload 2 records, we should able to pass those two records in the mapping as well as in the conversion.&lt;/p&gt;&lt;p&gt;Create a structure with name ZFI_HEAD for the Header (BKPF).&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-47031-55044/21ZFI_HEAD.png"&gt;&lt;img alt="image" border="0" height="163" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-47031-55044/445-163/21ZFI_HEAD.png" width="445"/&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;Under the ZFI_HEAD, create another structure ZFI_ITEM for items (BSEG). Put cursor on the ZFI_HEAD and press the create button to create lower level structure ZFI_ITEM. &lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-47031-55045/22BothStructure.png"&gt;&lt;img alt="image" border="0" height="199" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-47031-55045/462-199/22BothStructure.png" width="462"/&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Step 3: Maintain Source Fields&lt;br/&gt;&lt;/strong&gt;We need to have one link field which will link the Header record with the Item record which system will use later to link the records from both different files.&lt;/p&gt;&lt;p&gt;These are the fields for the ZFI_HEAD structure:&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-47031-55046/31ZFI_HEADFields.png"&gt;&lt;img alt="image" border="0" height="236" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-47031-55046/444-236/31ZFI_HEADFields.png" width="444"/&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;These are the fields for the ZFI_ITEM structure:&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-47031-55047/32ZFI_ITEMfields.png"&gt;&lt;img alt="image" border="0" height="196" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-47031-55047/438-196/32ZFI_ITEMfields.png" width="438"/&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Step 4: Maintain Structure Relations&lt;br/&gt;&lt;/strong&gt;Here we will define the structure relationship between source structure (BGR00, BBKPF, BBSEG, etc) and target structure (ZFI_HEAD, ZFI_ITEM, etc). &lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-47031-55048/4StructureRelation1.png"&gt;&lt;img alt="image" border="0" height="218" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-47031-55048/640-218/4StructureRelation1.png" width="640"/&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Step 5: Maintain Field Mapping and Conversion Rules&lt;br/&gt;&lt;/strong&gt;Assign all the fields from the ZFI_HEAD to respective fields from BBKPF and ZFI_ITEM to respective fields from BBSEG. Don't assign the CNT field to any of the field.&lt;br/&gt;Make sure we pass correct formatted date (YYYMMDD) to the BBKPF. &lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-47031-55049/5Fieldmapping.png"&gt;&lt;img alt="image" border="0" height="137" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-47031-55049/553-137/5Fieldmapping.png" width="553"/&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Step 6: Maintain Fixed Values, Translations, User-Defined Routines&lt;br/&gt;&lt;/strong&gt;We don't to maintain anything in field.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Step 7: Specify Files&lt;br/&gt;&lt;/strong&gt;Create 2 files: 1 for header, 1 for Item. Sequence of the fields in the Structure must be same as the fields in the file. You can download my test files: &lt;a class="jive-link-external-small" href="http://smartform.googlecode.com/files/FI_Header.txt"&gt;Header&lt;/a&gt; and &lt;a class="jive-link-external-small" href="http://smartform.googlecode.com/files/FI_Item.txt"&gt;Item&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Create a header file.&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-47031-55050/71files.png"&gt;&lt;img alt="image" border="0" height="361" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-47031-55050/507-361/71files.png" width="507"/&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;Create another file for the Items in the same fashion.&lt;/p&gt;&lt;p&gt;You can change the names of the Read and Conversion files.&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-47031-55051/7Files1.png"&gt;&lt;img alt="image" border="0" height="400" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-47031-55051/601-400/7Files1.png" width="601"/&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Step 8: Assign Files&lt;br/&gt;&lt;/strong&gt;Assign the files to the structures.&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-47031-55052/8Assignfiles.png"&gt;&lt;img alt="image" border="0" height="217" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-47031-55052/431-217/8Assignfiles.png" width="431"/&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Step 9: Read data&lt;/strong&gt;&lt;br/&gt;Read the files specified in the Step 7&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Step 10: Display read data&lt;/strong&gt;&lt;br/&gt;Displaying read data&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Step 11: Convert Data&lt;/strong&gt;&lt;br/&gt;Run the convert data report to convert the input data to .conv file&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Step 12: Display Converted Data&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Step 13: Run program&lt;/strong&gt;&lt;br/&gt;Run program RFBIBL00 to create a session.&lt;/p&gt;&lt;p&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-47031-55053/13Runprogram.png"&gt;&lt;img alt="image" border="0" height="211" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-47031-55053/270-211/13Runprogram.png" width="270"/&gt;&lt;/a&gt;&lt;span&gt; &lt;/span&gt;&lt;/p&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Use BBTAX:&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;To use the BBTAX structure also in the RFBIBL00, we need to create another structure (e.g. FI_TAX) under the ZFI_HEADER and same level of ZFI_ITEM. &lt;/li&gt;&lt;li&gt;As ZFI_ITEM (BBSEG) and FI_TAX (BBTAX) are at the same level so, we can use the same CNT field to link them. &lt;/li&gt;&lt;li&gt;Create a Separate file as we have created for the header and item. &lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Use BWITH:&lt;/strong&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;BWITH is the subitem level data for the FI document. With-holding tax data is attached to the line item. So, we need to create a child structure under the ZFI_ITEM. &lt;/li&gt;&lt;li&gt;Since we have created the structure at child level, we need another field to link the item data to the withholding tax data. &lt;/li&gt;&lt;li&gt;Create a separate field as we have created for the header and item.&lt;/li&gt;&lt;/ul&gt;&lt;p style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;I'm on Google+. Follow me on &lt;a href="https://plus.google.com/107384147679621746279?rel=author"&gt;Google+ &lt;img src="https://ssl.gstatic.com/images/icons/gplus-29.png"/&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;&lt;!-- [DocumentBodyEnd:ceaf1124-01c0-4373-af15-7e108d3aede6] --&gt;</description>
      <pubDate>Thu, 14 Aug 2008 17:06:08 GMT</pubDate>
      <guid>http://scn.sap.com/people/naimesh.patel/blog/2008/08/14/lsmw-with-rfbibl00</guid>
      <dc:creator>Naimesh Patel</dc:creator>
      <dc:date>2008-08-14T17:06:08Z</dc:date>
      <clearspace:dateToText>2 months, 3 weeks ago</clearspace:dateToText>
      <clearspace:replyCount>22</clearspace:replyCount>
      <clearspace:objectType>0</clearspace:objectType>
      <wfw:comment>http://scn.sap.com/people/naimesh.patel/blog/comment/lsmw-with-rfbibl00</wfw:comment>
      <wfw:commentRss>http://scn.sap.com/people/naimesh.patel/blog/feeds/comments?blogPost=47031</wfw:commentRss>
    </item>
    <item>
      <title>Watermark in SAPScript</title>
      <link>http://scn.sap.com/people/naimesh.patel/blog/2008/05/22/watermark-in-sapscript</link>
      <description>&lt;!-- [DocumentBodyStart:1bc75155-aaa9-4145-9a01-399935680fc2] --&gt;&lt;div class="jive-rendered-content"&gt;&lt;p&gt;&lt;br/&gt;On the other day, I was reading through SCN and this question came up. There wasn&amp;rsquo;t any suitable answer, which can get the watermark in SAPScript. So, I decided to give a try. I have tried couple of times with different techniques like calling the subroutine which SmartForm uses for background processing from SAPScript, putting the graphics in various windows and call them from driver program, etc. But today, I got a good solution, which I thought would be useful to everybody.&lt;/p&gt;&lt;p&gt;How it looks with Watermark?&lt;br/&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-46475-54137/Fig1_Watermark_preview.jpg"&gt;&lt;img alt="image" border="0" height="230" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-46475-54137/640-230/Fig1_Watermark_preview.jpg" width="640"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;There are couples of hurdles in the way to get it working:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;First&lt;/strong&gt; is the Graphics:&lt;br/&gt;Watermark Graphics should have some specific property. This kind of graphics should not have the &amp;ldquo;Reserve Height Automatically&amp;#8221; as ON in their attributes.&lt;br/&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-46475-54138/Fig2_Attributes.jpg"&gt;&lt;img alt="image" border="0" height="211" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-46475-54138/476-211/Fig2_Attributes.jpg" width="476"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Whenever we import any .bmp file as the graphics in the SE78, system by default sets the indicator &amp;ldquo;Reserve Height Automatically&amp;#8221; as ON. So, when we include this graphics in our SAPScript, system will reserve predefined space on the page which will prevent the next line to print in that space.&lt;/p&gt;&lt;p&gt;The Graphics with the &amp;ldquo;Reserve Height Automatically&amp;#8221; as ON generates output like this:&lt;br/&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-46475-54139/Fig3_Attribute_on.jpg"&gt;&lt;img alt="image" border="0" height="285" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-46475-54139/470-285/Fig3_Attribute_on.jpg" width="470"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;strong&gt;Second&lt;/strong&gt; is how to get the watermark on each page:&lt;br/&gt;To get the graphics on every page we have couple of options:&lt;br/&gt;&lt;em&gt;Option 1&lt;/em&gt;: Create a GRAPHICS window on the center of the page and include the watermark.&lt;br/&gt;This option is not working because: System starts the processing of the windows in the sequence maintained on the page window of SAPScript. So, Main window will be executed before Graphics window. This will overlap the content of the main window by the Graphics (which is not our purpose).&lt;br/&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-46475-54140/Fig4_Overlapping.jpg"&gt;&lt;img alt="image" border="0" height="325" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-46475-54140/470-325/Fig4_Overlapping.jpg" width="470"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;em&gt;Option 2&lt;/em&gt;: Call a Graphics inside the MAIN window.&lt;br/&gt;This option seems to work with little logic to print the watermark on each page.&lt;/p&gt;&lt;p&gt;I have attached my SAPScript, Little driver program&amp;#160;code and the test watermark image for your reference.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;SAPScript&lt;/strong&gt;:&lt;br/&gt;You can save this block as&amp;#160;.txt file and use report RSTXSCRP to import into your system. You need to save this SAPScript with name ZTEST_WATERMARK. &lt;textarea cols="100" rows="20"&gt;SFORMZTEST_WATERMARKHFORMZTEST_WATERMARK OLANE HEADFORM&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ZTEST_WATERMARK SAP&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DEF ETesting&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ZTEST_WATERMARK&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 00005NPATEL&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 640 20070716103554NPATEL&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 640 2008052016390213200010 E0&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 150 LINE/:FORM CPI 10; LPI 6; TAB-STOP 1 CM; START-PAGE FIRST; PARAGRAPH A1; RDI; LINE/:FORM RDIDEV; LINE/:PARAGRAPH A1 LINE-SPACE 1 LN; LINE/:PARAGRAPH A1 TAB 1 2 CM LEFT; LINE/:WINDOW GRAPHICS TYPE VAR; LINE/:WINDOW LAST TYPE VAR; LINE/:WINDOW MAIN LINE/:PAGE FIRST NEXT FIRST; LINE/:PAGE FIRST MAIN 0 1 CM 2 CM 10 CM 8 CM; LINE/:PAGE FIRST WINDOW LAST 5 CM 15 CM 5 CM 2 CM; END HEADFORM&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ZTEST_WATERMARK SAP&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TXT ETesting&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ZTEST_WATERMARK&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 00005NPATEL&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 640 20070716103554NPATEL&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 640 2008052016390213200019 E0&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 150 LINE/:FORM TEXT 'Testing'; LINE/:PARAGRAPH A1 TEXT 'default'; LINE/:WINDOW GRAPHICS TEXT 'graphics'; LINE/:WINDOW LAST TEXT 'last windoe'; LINE/:WINDOW MAIN TEXT 'Main Window'; LINE/:PAGE FIRST TEXT 'First'; LINE/WLAST LINE/ELAST LINE* last window LINE/WGRAPHICS LINE/:BITMAP 'ZTEST_NP' OBJECT GRAPHICS ID BMAP TYPE BCOL DPI 75 LINE/WMAIN LINE/:DEFINE &amp;amp;W_PAGE&amp;amp; := 0 LINE/EMAIN LINEA1&amp;amp;W_COUNT&amp;amp;,,TESTING OF THE WATERMARK LINE/:IF &amp;amp;PAGE&amp;amp; &amp;lt;&amp;gt; &amp;amp;W_PAGE&amp;amp; LINE/:BITMAP 'ZTEST_NP' OBJECT GRAPHICS ID BMAP TYPE BCOL DPI 75 LINE/:DEFINE &amp;amp;W_PAGE&amp;amp; := &amp;amp;PAGE&amp;amp; LINE/:ENDIF END ACTVSAPE&lt;/textarea&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Code&lt;/strong&gt;:&lt;br/&gt;Here is the simple driver program.&lt;/p&gt;&lt;p&gt;&lt;textarea cols="80" rows="20"&gt;*&amp;amp;---------------------------------------------------------------------**&amp;amp; Report&amp;#160; ZTEST_NP_SCRIPT*&amp;amp;*&amp;amp;---------------------------------------------------------------------**&amp;amp; Test Program to test Watermark in SAPScript*&amp;amp;---------------------------------------------------------------------*REPORT&amp;#160; ZTEST_NP_SCRIPT.DATA: W_COUNT TYPE I.PARAMETERS: P_NUM TYPE I DEFAULT 20.START-OF-SELECTION.&amp;#160; IF P_NUM IS INITIAL.&amp;#160;&amp;#160;&amp;#160; P_NUM = 20.&amp;#160; ENDIF.*&amp;#160; CALL FUNCTION 'OPEN_FORM'&amp;#160;&amp;#160;&amp;#160; EXPORTING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; APPLICATION = 'TX'&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DEVICE&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = 'PRINTER'&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DIALOG&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = 'X'&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FORM&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = 'ZTEST_WATERMARK'&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; LANGUAGE&amp;#160;&amp;#160;&amp;#160; = SY-LANGU.*&amp;#160; DO P_NUM TIMES.&amp;#160;&amp;#160;&amp;#160; W_COUNT = SY-INDEX.&amp;#160;&amp;#160;&amp;#160; CALL FUNCTION 'WRITE_FORM'&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; EXPORTING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ELEMENT = 'MAIN'&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WINDOW&amp;#160; = 'MAIN'.&amp;#160; ENDDO.*&amp;#160; CALL FUNCTION 'WRITE_FORM'&amp;#160;&amp;#160;&amp;#160; EXPORTING&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ELEMENT = 'LAST'&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WINDOW&amp;#160; = 'LAST'.&amp;#160; IF SY-SUBRC &amp;lt;&amp;gt; 0.&amp;#160; ENDIF.*&amp;#160; CALL FUNCTION 'CLOSE_FORM'&amp;#160;&amp;#160;&amp;#160; .&lt;/textarea&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Watermark Image&lt;/strong&gt;:&lt;br/&gt;I have used this image for my testing:&lt;br/&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-46475-54141/Fig5_TestWatermark.JPG"&gt;&lt;img alt="image" border="0" height="101" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-46475-54141/501-101/Fig5_TestWatermark.JPG" width="501"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Note: I have tried this on ECC 5.0. I am not sure about other systems.&lt;/p&gt;&lt;/div&gt;&lt;!-- [DocumentBodyEnd:1bc75155-aaa9-4145-9a01-399935680fc2] --&gt;</description>
      <pubDate>Thu, 22 May 2008 11:02:43 GMT</pubDate>
      <guid>http://scn.sap.com/people/naimesh.patel/blog/2008/05/22/watermark-in-sapscript</guid>
      <dc:creator>Naimesh Patel</dc:creator>
      <dc:date>2008-05-22T11:02:43Z</dc:date>
      <clearspace:dateToText>1 year, 6 months ago</clearspace:dateToText>
      <clearspace:replyCount>14</clearspace:replyCount>
      <clearspace:objectType>0</clearspace:objectType>
      <wfw:comment>http://scn.sap.com/people/naimesh.patel/blog/comment/watermark-in-sapscript</wfw:comment>
      <wfw:commentRss>http://scn.sap.com/people/naimesh.patel/blog/feeds/comments?blogPost=46475</wfw:commentRss>
    </item>
    <item>
      <title>Marbles Game in ABAP</title>
      <link>http://scn.sap.com/people/naimesh.patel/blog/2008/05/07/marbles-game-in-abap</link>
      <description>&lt;!-- [DocumentBodyStart:1ba43694-ee54-4251-8d6d-80fd6f379ef2] --&gt;&lt;div class="jive-rendered-content"&gt;&lt;span&gt;Marbles Game, a fun and simple variation of the famous Chinese Checkers Game! &lt;/span&gt;&lt;p&gt;Try to remove all but one marble from the board. You can remove a marble by skipping over it to an empty spot. Select a marble by clicking on it and move it by selecting the spot that you want to move to. (Caution: highly addictive...)&lt;/p&gt;&lt;p&gt;How it looks?&amp;#160;&lt;/p&gt;&lt;pre&gt;&lt;a href="http://scn.sap.com/servlet/JiveServlet/showImage/38-46289-53924/Marbles_ABAP.jpg"&gt;&lt;img alt="image" border="0" height="400" src="http://scn.sap.com/servlet/JiveServlet/downloadImage/38-46289-53924/303-400/Marbles_ABAP.jpg" width="303"/&gt;&lt;/a&gt;&lt;/pre&gt;&lt;p&gt;And the ABAP code is &lt;a class="jive-link-external-small" href="https://wiki.sdn.sap.com/wiki/x/Z4BgAQ"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Hope you will enjoy it..!!&lt;/p&gt;&lt;/div&gt;&lt;!-- [DocumentBodyEnd:1ba43694-ee54-4251-8d6d-80fd6f379ef2] --&gt;</description>
      <pubDate>Tue, 06 May 2008 23:51:40 GMT</pubDate>
      <guid>http://scn.sap.com/people/naimesh.patel/blog/2008/05/07/marbles-game-in-abap</guid>
      <dc:creator>Naimesh Patel</dc:creator>
      <dc:date>2008-05-06T23:51:40Z</dc:date>
      <clearspace:dateToText>1 year, 6 months ago</clearspace:dateToText>
      <clearspace:replyCount>9</clearspace:replyCount>
      <clearspace:objectType>0</clearspace:objectType>
      <wfw:comment>http://scn.sap.com/people/naimesh.patel/blog/comment/marbles-game-in-abap</wfw:comment>
      <wfw:commentRss>http://scn.sap.com/people/naimesh.patel/blog/feeds/comments?blogPost=46289</wfw:commentRss>
    </item>
  </channel>
</rss>

