0% found this document useful (0 votes)
567 views361 pages

ABAP

Golden Rules of Abap

Uploaded by

unnivelan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
567 views361 pages

ABAP

Golden Rules of Abap

Uploaded by

unnivelan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 361
About the Author Ganapati Adimulam is an SAP Technical Consultant. Having nearly Five years of Experience in the SAP Domain, several successful implementation, and a background in training and technical documentation has afforded him many opportunities to observe all aspects of SAP implementation. Mr. Ganapati did his M.C.A in 2002. He started his SAP career in 2003 March. He has worked for corporate giants like CGEY (CapGemini Emest & Young), Infosys and Satyam Computers and also for many other international clients as both onsite and off-shore Technical consultant. As his basic interest is in SAP training domain, he has turned into SAP training services after relieving from the corporate biggies. He is presently offering excellent training services in SAP through eMax Technologies. He is also a cynosure for imparting SAP training ‘to the corporate consultants. He is a big talk among the corporate as a very good SAP corporate trainer. From eMAX Technologies. ACKNOWLEDGEMENTS Doing a book of this magnitude requies a team effort. Every task is completely successful if and only if we acknowledge the effosts contributed by the individual personnel. We acknowledge our sincere thanks to our Honorable Director, eMax Technologies, Mr. Rama Rao for his continuous guidance, support and co-operation throught this project. I want to take this opportunity to thank the entire management, beloved students and My friend and Classmate Mr.Bhaskar and several other individuals of Max Technologies in reviewing and assuring the quality checks of the accomplishments at every stage of this project. Finally I would like to extend my sincere thanks to my family members from the bottom of my heart. Ganapati Adimulam. ACE Building the Career in SAP is not SO Difficult but it depends on two facts. i.e. the place where you get trained and also how seriously you put your efforts. Now a days, all the training centers improve the Quality in Training, but there is No quality in the People who attend for the training. Le. Only 10 to 20 Percentage Trainees are serious and the rest is just passing the Time. My Sincere advise is , Please think of SAP if you are really serious because now a days the Competition is also High but as long as you put your Efforts seriously, the Competition doesn’t matter. This is book is Prepared Only to keep the ABAP trainees from Hyderabad in mind,where the students don’t know much Exposure on the ADVANCED. TOPICs Such as ABAP OBJETCs,ALVs,BADIs,BAPIs .... Because Now a Days Learning ONLY the BASIC ABAP is not enough to work on ABAP . Think Of ADVANCED Topics them think of Interview Calls. It is brought into. Our notice, people are‘expetting the Material For Cross Application, Thé Material is ready: Except ALE/EDI 1DOCs and I suggest you to go for ALE/EDI Idoe by:Arvind Nagpaul , the best book for Cross ‘Apps and very soon I am going to add the Same If Possible. Please forward yout. comments and _—_— suggestion —_to [email protected] and also for further help in attending interviews . ALL THE BEST Ganapati Adimulam. INDEX 1. ABAP OBJECTS ( 00-ABAP) 2. ENHANCEMENTS a).Introudcution b).customer Exists c).BADI 3. BAPIs 4. ALV a) Using Funetion Modules b) Using ABAP Objects 1-134 01 1-47 1-60 1-112 1-44 1-70 ABAP Objects(OQO-ABAP) Duration -4Days(2Hrs) Introduction to Object Orientation OO-Concepts = DATA Abstraction = Encapsulation = Inheritance = Polymorphism Working With Local Classes = Define & Implement Classes = Define & Implement Methods = Inheritance = Interfaces = Events Working With Global Classes = Define & Implement Classes = Define & Implement Methods = Inheritance = Interfaces ABAP Objects We Never Compromise in Quality. Would You? What is Object Orientation? DAY-1 Object orientation (0), or to be more precise, object-oriented programming, is a problem-solving ‘method in which the software solution reflects objects in the real world. Definitions of Some Object Oriented Concepts (Terms). Encapsulation: Objects restrict the visibility of their resources (attributes and methods) to other users. Every object has an interface, which determines how other objects can interact with it, The implementation of the object is encapsulated, that is, invisible outside the object itself Classes : Class is a section af source code that contains data and provides services into a Single Unit. The data forms the attributes and the services are known as methods (also known a5 operations or functions). Typically, methods operate on private data (the atibtes, oF state of the object), which is only visible to the methods of the Class. Thus the attributestof a cannot be changed directly by the user, but only by the methods of the Class. This guaranteds the internal consistency of the Ohio re" <>, Note: ncapsulation is Supported through Classes. Objects : From a technical point of view, objects are runtime instances of a class. you can create any number of objects based on a single class. Each instance (object) of a class has a unique identity and its own set of values for its attribute: Polymorphism : Identical (identically-named) methods behave differently in different classes. Object ‘oriented programming contains constructions called interfaces. They enable you to address methods with the same name in different objects, Although the form of address is always the same, the implementation of the method is specific to a particular class. Inheritance : You can use an existing class to derive a new class. Derived classes inherit the data and methods of the superclass. However, they can overwrite existing methods, and also add new ones. Uses of Object Orientation as B Below are. some of the advantages of object-oriented programming: ee ee Jeottware systems become easier to understand, since object-oriented oud Fea fes a closer representation of reality than other programming techniques. . In a well-designed object-oriented system, it should be possible to implement changes at class level, without having to make alterations af other points in the system. This reduces the overall amount of maintenance required. . Through polymorphism and inheritance, object-oriented prograrvming allows you to reuse individual components, . In an object-oriented system, the amount of work involved in revising and maintaining the system is reduced, since many problems can be detected and corrected in the design phase. Page 1 of 134 Compiled By: Ganapati Adimulamn ‘Max Technologies, Ameerpet,Hyderabad Ph No: +91 40 68976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? What Is ABAP Objects? : asap onjects is a new concept in R/3 Release 4.0, The term has two meanings. On the one hand, it stands for the entire ABAP runtime environment. On the other hand, it represents the object-oriented extension ofthe ABAP language. The Object-Oriented Language Extension: ABAP Objects is a complete set of object-oriented statements that has been introduced into the ABAP ianguage. This object-oriented extension of ABAP builds on the existing language, and is fully compatible with it, You can use ABAP Objects in existing programs, and can also use "conventional" ABAP in new ABAP Objects programs. ABAP Objects supports object-oriented programming. Object orientation (OO), also know as the object-oriented paradigm, is a programming model that unites data and functions in objects. The rest, of the ABAP language is primarily intended for structured programming, where data is stored in a structured form in database tables and function-oriented programs access and work with it. ‘The object-oriented enhancement of ABAP is based on the models of Java and C++. Itis compatible with external object interfaces such as DCOM and CORBA, From Function Groups to Classes and Objects At the ceniter-of any object-oriented model are-objects, which contain attributes (data) and methods (functions): Objects .should enable programmers to map a feal problem and its proposed software solution On @ one-to-onébasis. Typical objects in a business environment are, for example, ‘customer’, ‘Orde’, or invoice’ From Reléase 3.1 onwards, the Business Object Repository (BOR) has contained examples of Such objects. The-object model of ABAP Obiects, the object-oriented extension of ABAP, is compaiible with the object model of the BOR, Before R/3 Release 4.0, the nearest equivalent of objects in ABAP were function modules and function groups. Suppose we havé'a function group for processing orders. The attributes of an order correspond to the global data of the function group, while the individual function modules represent actions that manipulate that data (methods). This means thet the actual order data is encapsulated in the function group, and is never directly addressed, but instead only through the function modules. In this way, the function modules can ensure that the data is consistent. ‘The program cannot access the data in the function group directly, but only through the function module, The function modules and their parameters are the interface between the function group and the user. The main difference between real object orientation and function groups is that although a program can work with the instances of several function groups at the same time, it cannot work with several instances of a single function group. Page 2 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,Ameerpet,fyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? Note : Let Us Assume Either Increase / Decrease Speed is Always 1. Function Group Data : v_speed type I. Funetion Modules : Increase_Speed, Decrease_Speed, Display Speed. Class Methods Increase_Speed, Decrease Speed, Display_Speed. i i eA iwavs Only One nsec Obiect! | [Obiec2 | [Lobiees | CALL FUNCTION : Increase_Speed, CALL METHOD : Object! Increase_ Speed, increase_Speed, Object2 Increase_Speed Note : Here in the Function Groups, All the Function Modules Updates the Same Variables Where Using Classes Each Object has it's Own Copy the Same Variable. Conclusion : In One Program, We Cannot Have More than One Instance for the Same Funetion Group, and We Can Have Any No Of Instances(Objects) for the Same Class in the | Same Program. fae Classe 1 Clasgés are templates for objects. Conversely, you can say that the type of an object. is the sam ad A class is an abstract description of an object. You could say that it is a set of instructions for building’ an object. The attributes of objects are defined by the components of the class, which describe the state and behavior of objects. Local and Global Classes lasses in ABAP Objects can be declared either globally or locally. You define global classes and interfaces in the Class Builder (Transaction SE24) in the ABAP Workbench. They are stored centrally in the class library in the 8/3 Repository. All of the ABAP programs in an R/3 System can access the Page 3 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies,Ameerpet,Ayderabad Ph No: #91 40 -65976727, Cell No: 99484 44808, 98490 34399, ww ABAP Objects We Never Compromise in Quality. Would You ? glotal classes. Local classes are defined within an ABAP program, Local classes and interfaces can only be used in the program in which they are defined. When you use a class in an ABAP program, the system first searches for 2 local class with the specified name. If it does not find one, it then looks for a global class. Apart from the visibility question, there is no difference between using a global class and using a local class. Defining and Working With Local Classes Local classes consist of ABAP source code, enclosed in the ABAP statements CLASS .. ENDCLASS. A complete class definition consists of a declaration part and, if required, an implementation part. The declaration part of a class is a statement block CLASS DEFINITION ENDCLASS. It contains the declaration for all components (attributes, methods, events) of the ciass. When you define local classes, the declaration part belongs to the global program data. You should therefore place itat the teeginning of the program If you declare methods in the declaration part of a class, you must also write an implementation part for it This consists of a further statement block CLASS IMPLEMENTATION, ENDCLASS. The plementation part of a class contains the implementation of all methods of the class. Structure of a Class The following statements define the structure of a class. . ‘class contains components . Each comiponent is assigned to a visibility section + “\2.classes implement methods The following sections describe the structure of classes in more detail Class Components : The components of a class make up its contents. All components are declared in the deciaration part of the class. The components define the attributes of the objects in a class. When you define the class, each component is assigned to one of the three visibility sections, which define the extemal interface of the class. All of the components of a class are visible within the class. All Page 4 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies,Ameerpet,llyderabad 91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com PhNi ABAP Objects We Never Compromise in Quality. Would You? components are in the same namespace. This means that all components of the class must have names that are unique within the class. ‘There are two kinds of components in a class - those that exist separately for each object in the class, and those that exist only once for the whole class, regardless of the number of instances. Instance- specific components are known as instance components. Components that are not instance-specific are called static components. 4 Components Of a Class : 4 ‘Attributes : Attributes are internal data fields within a class that can have any ABAP'Matatype=The state ‘of an object is determined by the contents of its attributes. One kind of attribute i isthe reference variable. Reference variables allow you to create and address objects. Reference variables can be defined in classes, allowing you to access objects from within a class. % Instance Attributes: The contents of ingfance attributes define the instance-spafilic state of an object. ‘You declare them using the DATA statement Static Attibutes: The contents of = routes dete the sate ofthe ass thal is vad fra instances ofthe cass. Static atibutel a for each class. You decare them using the CLASS- Barmy see eich cs All of the objects in a class can access its sta ibutes. If you change a static attribute in an object, the changaiis visible in all other objects in theClass. Methods: Methods are internal pro¢ cedures in a class that define the behavior of an object. They can acceso al ofthe ates of cag hiallowe thom fo change the data content of an object. They also have a parameter interface(IMPORTING,EXPOIRTING etc), with which users can supply them with values when calling them and receive values back from them The private attributes of a class can only be changed by metnotyp the same class. “The definition and parameter interfaee%f a method is similar to that of function modules. You define a method in the definition part a class and implement it in the implementation part using the following processing block,” “Method Implementation METHOD . ENDMETHOD. You can declare local data types and objects in methods in the same way as in other ABAP procedures (subroutines and function modules). You call methods using the CALL METHOD statement, Page 5 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies,Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality, Would You ? Instance Methods : You deciare instance methods using the METHODS statement, They can access all of the attributes of a class, and can trigger all of the events of the class Static Methods : You declare static methods using the CLASS-METHODS statement, They can only access static attributes and trigger static events. Special Methods : As well as normal methods, which you call using CALL METHOD, there are two special methods called CONSTRUCTOR and CLASS_CONSTRUCTOR, which are automatically called when you create an object (CONSTRUCTOR) or wien you first access the components of a class (CLASS_CONSTRUCTOR). Declaring Methods ‘You can deciare methods in the deciaration part of a class of in'an interface. To declare instance methods, use the following statement METHODS IMPORTING.. [VALUE(]()] TYPE type {OPTIONAL} EXPORTING. [VALUE(}) EXCEPTIONS. . ‘and ine appropriate additions To declare static methods, use the following statement CLASS-METHODS . Note : Unlike in function modules, the default way of passing a parameter in a method is by reference. To pass a parameter by value, you must do so explicitly using the VALUE addition. The return value (RETURNING parameter) must always be passed explicitly as a value. This is suitable for methods that return a single output value. If you use it, you cannot use EXPORTING or CHANGING parameters. Implementing Methods You must implement all of the methods in a class in the implementation part of the class in a METHOD . ENDMETHOD. Page 6 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies Amecrpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? block. When you implement the method, you do not have to specify any interface parameters, since these are defined in the method declaration. The interface parameters of a method behave like local variables within the method implementation. You can define additional local variables within a method using the DATA statement. ‘As in function modules, you can use the RAISE and MESSAGE RAISING statements to handle error situations NOTE : When you implementa stato method, remember that ican ony work wth the static abuts of Your cass Instance methods can work with both static and instance altaGutes, eA, Calling Methods To call a method, use the following statement: CALL METHOD EXPORTING i; é IMPORTING... <€> =.<9@ CHANGING ... =.-> is a reference variable whose value points to an instance of the class, When you call a method, you must pass all non-optional input parameters using the EXPORTING or CHANGING adaition in the CALL METHOD statement ‘You pass and receive values to and from methods in the same way 2s with function modules, that is, with the syntax = The interface parameters (formal parameters) are always on the left-hand side of the equals sign. ‘The actual parameters are always on the right. Page 7 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www. ABAP Objects We Never Compromise in Quality. Would You? Event Handler Methods Event handler methods are special methods that cannot all be called using the CALL METHOD statement, Instead, they are triggered using events, You define a method as an event handler method using the addition FOR EVENT OF in the METHODS or CLASS-METHODS statement ‘The following special rules apply to the interface of an event handler method: The interface may only consist of IMPORTING parameters. Each IMPORTING parameter must be an EXPORTING parameter of the event . The attributes of the parameters are defined in the dectaration of the event (EVENTS, statement) and are adopted by the event handler method, Constructors Constructors are special methods that cannot be called using CALL METHOD. Instead, they are called automatically by the system to set the starting state of a new object or class. There are two types of constructors - instance constructors and static canstructors. Constructors are methods with a predefined name. To use them, you must declare them explicitly in the class ‘The instance constructor of a class is the predefined instance method CONSTRUCTOR. You declare it in the public section as follows: METHODS CONSTRUCTOR IMPORTING... [VALUE(][)] TYPE type {OPTIONAL}. EXCEPTIONS. . and implement it in the implementation section like any other method. The system calls the instance constructor once for éach instance of the class, directly after the object has been created in the GREATE OBJECT statement. You can pass the input parameters of the instance constructor and handle its exceptions using the EXPORTING and EXCEPTIONS additions in the CREATE OBJECT statement. ‘The static constructor of a class is the predefined static method CLASS_CONSTRUCTOR. You declare it In the public section as follows: CLASS-METHODS CLASS_CONSTRUCTOR. Page 8 of 134 Compiled By: Ganapati Adimulam Max Technologies, AmeerpetsHyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? ana implement it in the implementation section ike any other method. The Static constructor has no parameters, The system calls the static constructor once for each class, before the class is accessed for the first time. The static constructor eannot therefore access the components of its own class. Events: Objects or classes can use events to trigger event handler methods in other objects or classes. In a normal method call, one method can be called by any number of users. When an event is triggered, any number of event handler methods can be called. The link between the trigger and the handler is not established until runtime. In a normal method call, the calling program determines the methods that it wants to call. These methods must exist. With events, the handler determines the events to which it wants to react, & ‘The events of a class can be triggered in the methods of the samev€lass Using the RAISE EVENT statement. You can declare a method ofthe same or a different classias ah Byentnandlee method for the event of class using the addition FOR EVENT OF DEFINITION. PUBLIC SECTION. PROTECTED SECTION. PRIVATE SECTION. ENDCLASS. Page 9 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? ‘ThEse Breas Calne the ExterAal VSHOIMly OF he Class components, tals, the interlace between We class and its users. Note : Each component of a class must be assigned to one of the visibility sections. Public Section: All of the components declared in the public section are accessible to all users of the class, and to the methods of the class and any classes that inherit from it. The public components of the class form the interface between the class and its users. Protected Section : All of the components declared in the protected section are accessible to all methods of the class and of classes that inherit from it. Protected components form a special interface between a class and its subclasses. Since inheritance is not active in Release 4.5B, the protected section currently has the same effect as the private section : Private Section : Components that you declare in the private section are only visible in the methods of the same class. The private components are not part ofthe externatinterface of the class. Object Handling Objects Objects are instances of classes, Each object has @ unique identity and its own attributes. A class can have any number of objects (instances). Object References : To access an object from an ABAP program, We use object references Object references are pointers to objets. In ABAP, they are always contained in reference variables Reference variables : Reference variables contain references. A reference variable is either intial Cr contains a reference to an existing object. The identity of an object depends on its reference. A reference variable thatpoints to an object knows the identity of that object. Users cannot access the identity of the object directly. Reference variables in ABAP are treated like other elementary data objects. This means that a reference variable ¢an occur as @ component of a structure or intemal table as well as on its own. You define class'reférences using the TYPE REF TO addition in the TYPES or DATA statement, where refers to a class. A reference variable with the type class reference is called a class reference variable, or class reference for shor Page 10 of 134 Compiled By: Ganapati Adimulam eMax Technologies, Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? ‘TRSS TOTRTENCE XCVET> STOWE BUSEY TO CreaIE MT TISTEMCE TOOIECTY OF Wie Corresponding CASS, aM address a visible component within it using the form. Creating Objects : Before you can create an object for a class, you need to declare a reference variable with reference to that class. Once you have declared a class reference variable for a class , you can create an object using the statement CREATE OBJECT . This statement creates an instance of the class , and the reference variable contains a reference to the object, Addressing the Components of Objects Programs can only access the instance components of an object using references in reference variables. The syntax is as follows (where is a reference variable) 2 + Toaccess an attribute :fef>-> + Tocall a method : CALL METHOD -> vax scons ate corponets oA Mg raw ol ne reference vai Ri bo possible to address the static componetits of 4 elass before an object has been created + Addressing a static attribute : CALL METHOD: -=> shce ME to access the individual components: in the Same class: ME-> * Tocall a method — Sal references allow an object ae ive,dtner objects a reference to it. You can also access attributes in methods fm win an object ever they are obscured by local tributes of the method Creating More Than One Instance of a Class : Ina program, you can create any number of objects from the same class. The objects are fully independent of each other. Each one has its own identity within the program and its own attributes. Each CREATE OBJECT statement generates a new object, whose identity is defined by its unique object reference. Object Lifetime : An object exists for as long as itis being used in the program, An object is in use by @ program for as long as at least one reference points to it, or at least one method of the object is registered as an event handler. Page 11 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies, Ameerpet,yderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? ‘As soon as there are no more references to an object, and so long as none of its methods are registered as event handlers, its deleted by the automatic memory management (garbage collection). The ID of the object then becomes free, and can be used by anew object Graphic Overview Of Classes Facts About Classes and Objects : Note : Here C_COUN ER is the Class. ean J Page 12 of 134 Compiled By: Ganapati Adimulam eMax Technologies, Ameerpet,Hyderabad Ph No: +91 40 ~65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? ‘The CLEAR statement resets the reference in CREF2 to its initial value. The reference variable CREF2 then contains the same value as it did immediately after its declaration, and does not point to an abject any more. ATR: CREF1 TYPE REF TO C_COUWTER, CREE? TYPE REF TO C“COUNTER, CREE3 LIKE CREF1. CREATE OBJECT: CREEL, CREF2. MOVE CREF2 TO CREF3. CLEAR CREF2. OUNTER> CREF3 = CREF 1. cs z (C_COUNTER<1> cREF3] =|" CREF2|~! i creri| | fey “The effect‘of the assignment statement is to copy the reference from CREF 1 to CREF2. As a result, the reference: ng CREFS also points to the object C_COUNTER<1>. No more references point to the object >, and itis automatically deleted by the garbage collection. The internal name x 'snow fee again 4 Page 13 of 134 Compiled By: Ganapati Adimulam eNiax Technologies, AmeerpetHyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtecl ABAP Objects We Never Compromise in Quality. Would You? Classes & Objects Introductory Example Requirement : Upload the Data From File INTO Internal Table TESS SISSIES ISOS OSHS SEI IIIS III IIIT IAAI * PROGRAM: ZDEMO_ABAP_OBJECTS_UPLOAD * + AUTHOR : GANAPATI . ADIMULAM * * PURPOSE : Upload the Data From File INTO Internal * * Table using CLASSes and OBJECTs * * DATE : 22-07-2007 * * COPIED FROM: * *COMPANY, eMAX Technologies * JESSIE ISITE III ISI IA III III IIa A II IIE *MODIFICATION LOG ; * + Pereettrtttireeeccceterecetttreetrrceccecteetcrtere?: -feeterery REPORT ZDEMO ABAP OBJECTS UPLOAD LINE-SIZE 150 : DATA : BEGIN OF WA_FILE, BUKRS(4) TYPE C, BUTXT(25) TYPE C, ORTO1(35) TYPE C, STREET (25) , LAND1(3), END OF WA_FILE. DATA IT FILE LIKE TABLE OF WA_FILE. ‘*DEFINITION CLASS LCL_FILE DEFINITION. PUBLIC SECTION. p METHODS : UPLOAD FILE IMPORTING IM FILE TYPE STRING IM_SEP TYPE C CHANGING IT_DATA TYPE STANDARD TABLE. ENDCLASS. * IMPLEMENTATION CLASS LCL_FILE IMPLEMENTATION. Page 14 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies, Ameerpet,flyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxt ABAP Objects ‘We Never Compromise in Quality. Would You ? METHOD UPLOAD_FILE. CALL FUNCTION 'GUI_UPLOAD' EXPORTING filename = IM FILE HAS _FIELD_SEPARATOR = IM_SEP tables data_tab = IT DATA IF sy-subre = 0. MESSAGE S002(ZGDEMO CLASSES) WITH IM FILE. ENDIF. ENDMETHOD . ENDCLASS . *Reference Variable DATA O_FILE TYPE REF TO LCL FILE. peereteeeetetteceeettitectstettetctttrertetererereerticerrenry * START-OF-SELECTION. * JHE SISSIES IIIS IIIS ISS IIS ASI IO IIIT TIA II I AAI START-OF-SELECTION . CREATE OBJECT 0 FILE. roan reg : ey” *C:\RELE JKT? Oe” IM_SEP = 'Xx! CHANGING IT_DATA = If FILE. Pal *DISPLAY DATA” LOOP AT IT FILE INTO WA_FILE. WRITE : / WA_FILE-BUKRS, WA_FILE-BUTXT,WA_FILE-ORTO1,WA_FILE- LAND1. ENDLOOP. Page 15 of 134 Compiled By: Ganapati Adimutam eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? ovreor—> ESE: 2 f =1SLx) Bie cot Format View Hee [001 EMAKI TECHNOLOGIES HYDERABAD AMEERPET. N= £002 EMA? TeECHMOLOGIES HYDERABAD See NAGAR In £003 EMASG TechmoLocies HYDERABAD, ABEERPET in Output Of the Program Demo On ABAP Objects Sai Em Teonamses—_wibaRaea “rEEHPET ue ee Si Reese th fon emis abesRre i Page 16 of 134 Compiled By: Ganapati Adimutam ‘Max Technologies,Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? Example 2 : BDC Program to Create Customer Master Data Using Classes and Methods. REPORT ZDEMO_BPC_USING CLASSES FEISS SIGHS O EIST SDSS AHS IIIS I IOS ATOR I * PROGRAM ©: | ZDEMO_BDC_USING CLASSES * * AUTHOR ©: GANAPATI | ADIMULAM * * PURPOSE : UPLOAD Customer Master Data Using Call + * Transaction through ABAP OBJECTs * * DATE + 22-07-2007 Fax : * COPIED FROM: L SS * *COMPANY : @MAX Technologies i. of “hy ! * ESS H ES HUSH O SIRI D IID IOD TO BOE EI AGI = q prreteetereteetetteeirecesttcertreeserc]: * Definition Of the CLASS LCL_BDC DEFINITION. * eetireetirtrairretirreetettc ets ter rece tieeetrect tere rrrrcrsss CODE I CLASS LCL_RDC DEFINITION. PUBLIC SECTION METHODS : UPLOAD_DATA IMPORTING FILE TYPE C SEP TYPE C SN CHANGING IT_DATA TYPE STANDARD TABLE, (6 BYLL_SCREEN_DETATLS IMPORTING TM_PROGRAM TYPE spc_phos » E IM_DYNPRO TYPE oo DETATLS IMPORTING IM_FNAM TYPE ram “do IM_FVAL TYPE C, CALL_TRANSACTION IMPORTING IM _TCODE TYPE C IMUBDATE TYPE C IM DISPLAY TYPE C. PRIVATE SECTION. DATA : WA_BDCDATA TYPE BDCDATA, Page 17 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies, Ameerpet Hyderabad Ph No: +91 4065976727, Cell No: 99484 44808, 98490 34399, www.emaxtech,com ABAP Objects We Never Compromise in Quality. Would You? TT T_BDCDATA_ LIKE TABLE OF WABDCDATA, SSS WA_BDCMSGCOLL TYPE BDCMSGCOLL, IT _BDCMSGCOLL LIKE TABLE OF WA_BDCMSGCOLL. ENDCLASS. JESSIE COSTE IAAT IA ISIE SISSIES IIIT IAI IAI I TAI IAI * Implementation Of the CLASS LCL_BDC DEFINITION. * FEI ISIS ISIS IE IG IGE TEI IOSI ICICI CITT OTTO II SII SATII CLASS LCL_BDC IMPLEMENTATION. METHOD UPLOAD_DATA. CALL FUNCTION 'GUI_UPLOAD!' EXPORTING FILENAME = FILE * FILETYPE HAS_FIELD_SEPARATOR TABLES DATA_TAB = IT_DATA ENDMETHOD . *FILL_SCREEN_DETAILS METHOD FILL_SCREEN DETAILS . CLEAR WA_BDCDATA. WA_BDCDATA-PROGRAM = IM PROGRAM. WA_BDCDATA-DYNPRO = IM DYNPRO. WA_BDCDATA-DYNBEGIN = 'X'. append WA_BDCDATA TO. IT _BDCDATA. ENDMETHOD. METHOD FILL_FIELD_DETAILS. CLEAR WA_BDCDATA. WA_BDCDATA-FNAM = IM_FNAM. WA_BDCDATA-FVAL = IM_FVAL. APPEND WA_BDCDATA TO IT_BDCDATA. ENDMETHOD . METHOD CALL_TRANSACTION. Page 18 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies,Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects ‘We Never Compromise in Quality. Would You? CALL TRANSACTION IM_TCODE USING IT_BDCDATA UPDATE IM_UPDATE MODE IM DISPLAY MESSAGES INTO IT_BDCMSGCOLL. REFRESH IT_BDCDATA. ENDMETHOD . 4 ENDCLASS. #Reference Variable DATA 0 BDC TYPE REF TO LCL_BDC. DATA : BEGIN OF WA_XDO1, KONNR(10) TYPE C, "CUS.NO KTOKD(4) TYPE C, "ACC.GRP NAME1 TYPE NAME1, "NAME SORTL TYPE SORTL, "SEARCH STRAS TYPE STRAS, "STREET LAND1 TYPE LAND1, "COUNTRY SPRAS TYPE SPRAS, "LANG END OF WA_XDO1. DATA IT_XD01 LIKE TABLE OF WA_XDO1. JESS SEIS ISIS SEI IOS IIIS ISS IIIT IASI IAA * START-OF-SELECTION. * JX ESSE SS IIIS SSIES ISIE SSSI IIT III ATI II stant-oRSSELECTTON.— cxennd, oager o pc. CALE MBtHOD 0 BD¢->UPLOAD_DATA EXPORTING FILE = "c:\xD01_DATAGEXT' “aa SEP = ‘x! CHANGING IT_DATA = IT_xDO1. *FOR EACH RECORD LOOP AT IT_XD01 INTO WA_XDOL. CALL METHOD 0_BDC->FILL_SCREEN DETAILS EXPORTING IM PROGRAM = 'SAPMFO2D' Page 19 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com_ ABAP Objects We Never Compromise in Quality. Would You? “IM_DYNPRO OL *EIELD DETAILS CALL METHOD 0_BDC->FILL_FIELD_DETAILS EXPORTING IM FNAM = 'BDC_OKCODE! IM_FVAL */00'. *KUNNR ~ CALL METHOD 0_BDC->FIZi_FIELD_DETAILS EXPORTING IM FNAM = 'RFO2D-KUNNR’ IM“FVAL = WA_XDO1- KUNNR. +RTOKD CALL METHOD 0_BDC->FILL_FISLD_DETAILS EXPORTING IM_FNAM mL FVAL 'RFO2D-KTOKD' WA_xDO1- KTOKD *2ND SCREEN DETAILS CALL METHOD 0_BDC->FILL_SCREEN_ DETAILS EXPORTING IM_PROGRAM = 'SAPMFO2D' IMDYNPRO = '0110' *SAVE CALL METHOD O_BDC->FILL_FIELD_DETAILS EXPORTING IM FNAM = 'BDC_OKCODE' IM_FVAL = '=UPDA'. *NAMEL CALL METHOD O_BDC->FILL_FIELD_DETAILS EXPORTING IM_FNAM = 'KNA1-NAME1' IM_FVAL = WA_XDO1- NAME1. *SORTL CALL METHOD ©_BDC~>FILL_FIELD_DETAILS EXPORTING IM FNAM = 'RNA1-SORTL' IM_FVAL = WA_XDO1- SORTL- *STRAS 3 CALL METHOD. 6-BDC->FILL_FIELD_DETAILS EXPORTING IM_FNAM = 'KNA1-STRAS' IM_FVAL = WA_xDO1- STRAS. *LANDI CALL METHOD 0_BDC->FILL_FIELD DETAILS EXPORTING IM FNAM = 'KNA1-LAND1' Page 20 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies, Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects in Quality. Would You? LANDL. *SPRAS CALL METHOD O_BDC->FILL_FIELD_DETAILS EXPORTING IM FNAM = 'KNA1-SPRAS' IM-FVAL = WA_xDO1- SPRAS. 7 scall Transaction & CALL METHOD O_BDC->CALL TRANSACTION EXPORTING»IM_TCODE = 'XDO1' ENDLOOP. Input File : , alolx Elle Edit Format View Help (2111 0004 EMAXL EMAXL STREETI IN EN = 32222 0004 EMAX2 EMA? STREET2 IN EN 7 = 0004 EMAX3 EMAXS STREET2 IN EN Sosa AH ow | eer an Page 21 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies,Ameerpet Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaytech.com ABAP Objects We Never Compromise in Quality. Would You? Create Customer: Address Street svPeert 26 Bow i I | ro amerces i | Telexnumaet | iris Exe oiecsion A ht ogo" ‘estomer | oie eeraton | olsun oanns! eset|oe [Bo (Bs. jSelsx) 2 CIO Ry. 12:58PM. Similarly, All the Records are Created. Page 22 of 134 Compiled By: Ganapati Adimulam Max Technologies,AmeerpetHyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? Inheritance Inheritance allows you to derive a new class from an existing class. You do this using the INHERITING. FROM addition CLASS DEFINITION INHERITING FROM ‘The new class inherits all of the components of the existing class‘, The new class is called the subclass of the class from which it is derived. The original class is called the superclass of the new class. If you do not add any new declarations to the subclass, it contains. tHe! Samiezcomponents as the superclass. However, only the public and protected components of the superciass ate visible in the subclass. Although the private components of the superclass exist in the subclass, they are not visibie, You can declare private components in a subclass that have the same names as private’components of the superclass. Each class works with its own private components. Methods that a subclass inherits from a Supeciavs use the privat atribuies of he superclass, and not any private components ofthe subclass with the same names. If the superclass does not have a priyateivisibility section, the subclass is an exact replica of the superclass. However, you can add'n st to the subclass. This allows you to turn the subclass into a specialized version of the: tipyeace Alass can have more than one direct sess, only have one direct superctass. This is called single inheritance. When subclasses inherit irom bupetcessts and tre supercans i feet te subdacs of another class a it he classes involved form aniinheritance tree, whose degree of specialization increases with i Yevel you add. Cbriversely, the classes become more generalized until you reagh ne veal naan tree: The root node of all inheritance trees in ABAP Objects is the predefined emp a T. This is the most generalized class possible, since it contains nein ttabutes gor metnods re ) you define a new class, you do nct have to specify it explicitly as the superciass ithe relationship is always impliciiy defined. Within an inheritance tree, two adjacent nodes are the direct eo oF direct subclass of one another Redefining Methods Al subclasses contain the components of all classes between themselves and the root node in an inheritance tree. The visibilly of a component cannot be changed. However, you can use the REDEFINITION addition inthe METHODS statement to redefine an inherited public or protected instance method in a subclass and make its function more specialized. When you redefine a method, you cannck change its interface, The method retains the same name and interface, but has a new implementation. The method deciaration and implementation in the superclass is not affected when you redefine the method in a subclass. The implementation of the redefinition in the subclass obscures the original implementation in the superclass. ‘Any reference that points to an object of the subclass uses the redefined method, even if the reference was defined with reference to the superclass. This particularly applies to the self-reference ME-> If, fot Page 23 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality, Would You? example, S Supercass Method MT -CONTaMS a CAI CALL METROW [ME-S|NZ, and MZ Is redened ina subclass, calling M1 trom an instance of the subclass will cause the original method M2 to be called, and caling M1 from an instance of the subclass will cause the redefined method M2 to be called Within a redefine method, you can use the pseudoreference SUPER-> to access the obscured method This enables you to use the existing function of the method in the superclass without having to recode it in the subclass. Abstract and Final Methods and Classes ‘The ABSTRACT and FINAL additions to the METHODS and CLASS statements allow you to define abstract and final methods or classes. ‘An abstract method is defined in an abstract class and cannot be implemented in that class. Instead, itis implemented in a subclass of the class, Abstract classes cannot be instantiated, A final method cannot be redefined in a subclass. Final classes cannot have subclasses. They conclude an inheritance tree. Namespace for Components ‘Subclasses contain all of the components of all of their superclasses within the inheritance tree. Of these componefits, only the public and protected ones are visible. All public and protected components within an inheritance tree belong to the same namespace, and consequently must have unique names. The names of private components, an the other hand, must only be unique within their class. When you redefine methods, the new implementation of the method obscures the method of the superclass with the same name. However, the new definition replaces the previous method implementation, so the name is stil unique. You can use the psewdoreference SUPER-> to access a method definition in a superclass that has been obscured by a redefinition in a subclass. Inheritance and Static Attributes Like all components, static'attributes only exist once in each inheritance tree, A subolass can access the public and protected static attributes of al of ts superciasses. Conversely, a superclass shares its public and protected static attributes with all ofits subclasses. In terms of inheritance, static attributes are not assigned to a;single class, but to a part of the inheritance tree. You can change them from outside the class using the Class component selector with any class name, or within any class in which they are shared. They are visible in ai classes in the inheritance tree When you address a static attribute that belongs to part of an inheritance tree, you always address the class in which the attribute is dectared, irrespective of the class you specify in the class selector. This is particularly important when you call the static constructors of classes in inheritance. Static constructors are executed the first time you address a class. If you address a static attribute declared in a superciass using the class name of a subclass, only the static constructor of the superclass is executed. Page 24 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies, AmeerpetHyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromis inheritance and Constructors There are special rules governing constructors in inheritance. Instance Constructors Every class has an instance constructor called CONSTRUCTOR. This is an exception to the rule that states that component names within an inheritance tree must be unique. However the instance ‘constructors of the various classes in an inheritance tree are fully| independent gfione another. You cannot redefine the instance constructor of a superclass in a subclass, neither can you call one specifically using the statement CALL METHOD CONSTRUCTOR. oe ‘no naming conflicts an occur. a oem “The instance constructor af a class is called by the system when you instantiate the class Using CREATE OBJECT. Since a subclass contains all ofthe visible attributes of its superciasses, which Can also be set by instance constructors, the instance constructor of a subclass has to ensure that the instance constructors of ail of its ‘superctasses are also called. To do this, the instaneayconstructor of each subclass must contain a CALL METHOD SUPER>CONSTRUCTOR statement“The only exception to this rule are direct subclasses ofthe sot gee OBJECT. In superciasses without an cacnlatng instance constructor, the implicit instance constructor is ‘called. This automatically ensures th rtanoe ‘constructor of the immediate superclass is called oS a When you call an instance constructor iyou ature values forall of Its non-optional interface Parameter, There are various ways of dln ths Ae = Using CREATE OBO... ithe lass tat you ann tonuang aneskeae tthe class that you are in ing hag an instance constructor without an interface, you do not pass any parameters ed ou If the class you are instantiating/Goes not have an explicit instance constructor, you must look in the inheritance tree for the next-highest supercass with an explicit instance constructor. If this has an interface, you must supply values using EXPORTING , Otherwise, you do not have to pass any values. Using CALL METHOD SUPER->CONSTRUCTOR If the direct superclass has an instance constructor with an interface, you must pass values to it using EXPORTING If the direct superciass has an instance constructor without an interface, you do not pass any parameters. Page 25 of 134 Compiled By: Ganapati Adimulam Max Technologies, Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? If the direct superclass does not have an explicit instance constructar, you must look in the inheritance tree for the next-highest superclass with an explicit instance constructor. If this fas an interface, you must supply values using EXPORTING . Otherwise, you do not have to pass any values In both CREATE OBJECT and CALL METHOD SUPER->CONSTRUCTOR, you must look at the next- available explict instance constructor and, if it has an interface, pass values to it. The same applies to exception handling for instance constructors. When you work with inheritance, you need an precise knowledge of the entire inheritance ‘ree. When you instantiate a class al the. bottom of the inheritance tree, you may need to pass parameters to the constructor ofa class that is much nearer the root node. The instance constructor of a subclass is divided into two parts by the CALL METHOD SUPER->CONSTRUCTOR statement. In the statements before the call, the constructor behaves like 2 static method, that is, it cannot access the instance attributes ofits class. You cannot address instance attributes until after the call. Use the statements before the call to determine the actual parameters for the interface of the instance constructor of the superclass. You can only use static attributes or local data to do this, When you instantiate a subclass, the instance constructors are called hierarchically. The first nesting level in which you can address instance attributes is the highest-level superclass. When you ceturn to the constructors of the lower-level classes, you can also successively address their instance attributes, ‘na constructor method, the methods of the subciasses of the class are not visible. If an instance constructor cails an instance method of the same class using the implicit self-reference ME-, the method is called as itis implemented in the class of the instance constructor, and not in any redefined form that may occur in the subclass you want to instantiate. This is an exception to the rule that states thet when ‘you call instance methods, the system always calls the method as itis implemented in the class to whose instance the reference is pointing Static Constructors Every ciass fas @ static constructor called CLASS_CONSTRUCTOR. As far as the namespace within an inheritance tree, the same-applies to static constructors as to instance constructors. ‘The firstitme’you address @ subclass in a program, its static constructor is executed. However, before it can be execiited, the static constructors of all ofits superciasses must already have been executed. A static constructor tray only’be called once per program. Therefore, when you first address a subclass, the system looks fer the néxt-highest superciass whose static constructor has not yet been executed. It executes the static constructor of that class, followed by those of all classes between that class and the subclass you addressed. Page 26 of 134 Compiled By: Ganapati Adimulam eMax Technologies, Ameerpet Hyderabad 91 40 ~65976727, Cell No: 99484 44808, 98490 34399, wwav.emaxtech.com Ph No: ABAP Objects We Never Compromise in Quality. Would You ? Inheritance: Overview Graphic Class OBECT —— | The left-hand part of the graphic shows Royibu can derive a subclass 2 from a superclass ¢1 using the INHERTING FROM addition in the GLASS statement. The right-hand part of the graphic shows the distribution of the subclass in the inhettance tree, which stretches back to the default empty class OBJECT. A subclass contains sll of tha/gomponénisideciared above it in the inheritance tree, and can address all of them that are declared publg or prot Single innefitane ca Page 27 of 134 Compiled By: Ganapati Adimulam Max Technologies,Ameerpet,iyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? THis graphic Mlustates SINgIs Thhentarnice. A class May only Nave One direct superclass, BU rca Rave ‘more than one direct subclass. The empty class OBJECT is tire root node of every inheritance tree in ABAP Objects, Inheritance and Reference Variables : SS { aéclaes3> | hal CRE This graphic shows now reference variables defined with reference to a superclass can point to objects of subclasses. The object on the right is an instance of the class class3. The class reference variables CREF1, CREF2, and CREFS are typed with reference to class’, class2, and class3. All three can point to the object. However, CREF can only address the public components of class1. CREF2 can address the public components of class! and class2. CREFS can address the public components of all of the classes. If you redefine @ method of @.superciass in a subclass, you can use a reference variable defined with reference to the superclass to address objects with different method implementations, When you address the superciass, the method has:the original implementation, but when you address the subclass, the method has the new implementation. Using a single reference variable to call identically-named methods that behave differently is called polymorphism. Page 28 of 134 Compiled By: Ganapati Adimulam eMax Technologies, AmeerpetsHyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, w: ABAP Objects We Never Compromise in Quality. Would You ? Inheritance: Introductory Example ‘The following simple example shows the principle of inheritance within ABAP Objects Example 1: Derive the Subclass for Call Transaction from the Class of Generic BDC Class . REPORT ZDEMO_BDC_INHERITANCE . JESSE SSSI ISSO ESSE ISSA TIBET ISI III III I TOI IIIA * PROGRAM ©: ZDEMO_BDC_INHERTTANCE * * AUTHOR GANAPATI . ADIMULAM * * PURPOSE UPLOAD Customer MasteneData Using Call * * Transaction through// ABAP\OBJECTs INHERITANCE * DATE 22-07-2007 a ‘ * * COPIED FROM: f ~~ * *COMPANY : eMAX Technologies —” * JERE IERIE SEBO D I EEIO TOTES COCO OEE SCE S OOO Ie *MODIFICATION LOG * * * JHB SII IO SS SSIS ISIE IIIT IIIS II TIS IASI II JESS SISSIES SSIS IIIS IIIS III IIIT I III I II * CLASS LCL_BDC_CLASS DEFINITION. * TEESE SS ISS I ISS IS IIIA III IIIT II TIS III I I IAI CLASS LCL_BDC_CLASS DEFINITION. PUBLIC SECTION . seruons > METHODS : READ FILE INTO ITAB IMPORTING IM FILE TYPE STRING & CHANGING IM IT DATA TYPE STANDARD TABLE} \) FILLSCREEN DETAILS IMPORTING IM_PROGRAM TYPE BDC, PROG IM_DYNPRO TYPE BDC_DYNR IM_DYNBEGIN TYPE BDC_START, FILL_FIELP_DETAILS IMPORTING IM FNAM ‘TYPE FMAM IM_FVAL TYPE c. Page 29 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies AmecrpetsHyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects ‘We Never Compromise in Quality. Would ‘You? PROTECTED SECTION. *DECLERATION DATA : IT _BDCDATA TYPE TABLE OF BDCDATA, WA_BDCDATA TYPE BDCDATA. DATA V_STRING TYPE STRING. ENDCLASS. JESSIE OIE SOS DE SSE E SEES ESI SIE IIIS Oa ae * LCL_BDC_CLASS IMPLEMENTATION * JESSE IES IUD ISIS EIS O SUSE II DI IT SOON IESE gt CLASS LCL_BDC_CLASS IMPLEMENTATION. METHOD READ_FILE_INTO_ITAB CALL FUNCTION 'GUI_UPLOAD* EXPORTING filename IM FILE * FILETYPE "ASC! HAS FIELD_SEPARATOR x tables data_tab = IM_IT_DATA ENDMETHOD METHOD FILL_SCREEN DETAILS. CLEAR WA_BDCDATA. WA_BDCDATA-PROGRAM =" IM_ PROGRAM. WA_BDCDATA-DYNPRO = IM_DYNPRO WA_BDCDATA-DYNBEGIN = IM DYNBEGIN. APPEND WA_BDCDATA TO IT_BDCDATA. ENDMETHOD . METHOD FILL_FIELD_DETAILS CLEAR WA_BDCDATA. WA_BDCDATA-FNAM = IM_FNAM. WA_BDCDATA-FVAL = IM FVAL. APPEND WA_BDCDATA TO IT _BDCDATA. Page 30 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,Ameerpet, Hyderabad 91 40 -65976727, Cell No: 99484 44808, 98490 34399, w Ph Ne ABAP Objects ‘We Never Compromise in Quality. Would You? ENDMETHOD . ENDCLASS. JESUS IDES IS IIIS ESSE IO IIIA TA III IAA IO * INHERITING FROM LCL_BDC_CLASS * EEE IEEE SIO IIIT TTT AIO TOT SA DIT SAS II III AIOE CLASS LCL_BDC_CALL_TRANS DEFINITION INHERITING FROM LCL_BDC_CLASS. PUBLIC SECTION. METHODS : CALI. TRANSACTION IMPORTING JMMTOCDE «TYPE C | IMUPDATE TYPE C IM 1 DE if TYPE C ENDCLASS . JESS IGS IIE IA IORI SISTA II TOI TEI I I ATI TI IATA * LCL_BDC_CALL_TRANS IMPLEMENTATION * THESIS ISIS IDES I ISI AO OTIS II IOI TIT TTI IAI III III CLASS LCL_BDC_CALL TRANS IMPLEMENTATION. METHOD CALI_TRANSACTION CAL TRANSACTION 1M TOCDE USING 17_BOCDATA oy UPDATE IM_UPDATE & MODE IM MODE. REFRESH rpepcoaia. ENDMETHOD- 5 Page 31 of 134 Compiled By: Ganapati Adimulam eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? ERE ¥ FRET REEE FREER FREE EERE EERE * DECLERATIONS * JESS ISS SESS SSIS SISSIES TOSI IIIS ITI DATA : BEGIN OF WA_DATA, KUNNR(10) TYPE C, "CUS.NO KTOKD(4) TYPE C, "ACC.GRP NAME1(25) TYPE C, "NAME SORTL(10) TYPE C, STRAS(35) TYPE C. LAND1(3) TYPE C, SPRAS(2) TYPE C, END OF WA _DATA. DATA IT_DATA LIKE TABLE OF WA_DATA. DATA OBJ_CALL TRANS TYPE REF TO LCL_BDC_CALL TRANS. JAE SIDS ISS RIG ISIS SII IIIS SITS * START-OF-SELECTION. * JECT IIIS ISI TTT I I TITAS III START-OF-SELECTION. CREATE OBJECT OBJ_CALL_TRANS ¥UPLOAD DATA CALL METHOD OBJ_CALL TRANS->READ_FILE_INTO_ITAB EXPORTING IM FILE = '¢:\xD01_DAER. TXT! CHANGING IM_IT DATA = IT_DATA. *FOR EACH DATA RECORD LOOP AT IT DATA INTO WA_DATA. *FILL 1ST SCREEN DETAILS CALL METHOD OBJ_CALL TRANS->FILL SCREEN DETAILS EXPORTING IM PROGRAM = 'SAPMFO2D' IM_DYNPRO = '0100' IM_DYNBEGIN = 'x'. Page 32 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects ‘We Never Compromise in Quality. Would You ? *FILL FIELD CURSOR DETAILS CALL METHOD OBJ_CALL_TRANS->FILL_FIELD_DETAILS EXPORTING IM FNAM = 'BDC_OKCODE' IM_FVAL = '/00 **KUNNR, CALL METHOD OBJ_CALL_TRANS->FILL_FIELD_DETAILS EXPORTING IM FNAM = ‘RFO2D-KUNNR! IM/FVAL = WA_DATA-KUNNR. **KTOKD CALL METHOD OBJ_CALL_TRANS->PIUL_FIELD_DEYAILS EXPORTING IM FNAM = 'RFO2D-KTOKD' IM_FVAL = WA_DATA-KTOKD. +#2ND SCREEN . CALL METHOD OBJ_CALL_TRANS->FILL_SCREEN DETAILS EXPORTING IM_PROGRAM = !!SAPMFO2D' IM DYNpRO (= ‘0 on IM_DYNBEGIN **SRVE CALL METHOD OBJ_CALL_TRANS->PILL_FIELD_Deratts —""EXBORTING IM FNAM = "BDC OKCODE' IMLEVAL = '=UBDA'. **NAMEL CALL METHOD OBJ_CALL_TRANS->FILL_FIELD_DETAILS EXPORTING IM_FNAM = 'KNA1-NAME1' IM_FVAL = WA_DATA-NAME1. +*soRTE CALL METHOD OBJ_CALL_TRANS->FILL FIELD DETAILS EXPORTING IM_FNAM = 'KNA1-SORTL' é sesrrad- ar IM_FVAL = WA_DATA-SORTL. aa Lingl as pote rine en (\y—7) RXPORTING IM_FNAM = TKNAI-STRAS' y ia IM_EFVAL = WA_DATA-STRAS. *LAND1 “C7 CALL ME" CALL_TRANS->FILL_FIELD_DETAILS EXPORTING IM_FNAM = ?KNA1-LAND1' IMLFVAL = WA_DATA-LAND1. +**SPRAS CALL METHOD OBJ_CALL_TRANS->FILL_FIELD_DETATLS EXPORTING JM FNAM = "KNA1-SPRAS' IM_FVAL = WA_DATA-SPRAS. Page 33 of 134 Compiled By: Ganapati Adimulam. ‘Max Technologies,Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? CALL METHOD OBJ_CALL,_TRANS->CALL. TRANSACTION EXPORTING IM TOCDE = 'XDO1' CUPDATE = ‘A “AYSNCH ROMODE = ‘A’ "ALL CLEAR WA_DATA. ENDLOOP. Execute the Program INPUT FILE : Be cman vse Page 34 of 134 Compiled By: Ganapati Adimulam eMax Technologies,Ameerpet,llyderabad Ph No: +91 40 65976727, Cell No; 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? Page 35 of 134 Compiled By; Ganapati Adimulam ‘Max Technologies Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? Greate Customer: initial Screen Gucoiner conparncote Aesontsoon soot a | comaaneooe | ost |Civee taal soness mananement 2 [iG ncoartcasoea22s3hes beer created Page 36 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies,Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.cmaxtech.com ABAP Objects ‘We Never Compromise in Quality. Would You? Inheritance Example 2 : Derive the Session Specific Class from Common BDC Class . REPORT ZDEMO_BDC_INHERITANCE2 . * PROGRAM © ZDEMO_BDC_INHERITANCE2 + xDTHOR GANAPATT > ADIMULAM é + PURPOSE UPLOAD Customer Master Data Using Session + . Mathoa through ABAP OBUECT= TNGERIENNGE | + * DATE : 22-07-2007 as + CopIED FROM: company etx Technologies 2 ¢ *MODIFICATION LOG , * CLASS LCL_BDC_CLASS oar * CLASS LCL_BDC_CLASS DEFINITION. : PUBLIC SECTION. ‘METHODS vericns = nepi@iigyanro_rzan IMPORTING IM FILE TYPE STRING CHANGING IM/IT DATA TYPE STANDARD TABLE, EeRpggerte Gi proomm neve anc_pso IM-DYNPRO TYPE BDC_DYNR NX [3 IMCDYNBEGIN TYPE BDC_START, PILL PIELEQRETAILS IMGORPING IMCENAM TYPE EWAN IMEVAL "TYPE C. PROTECTED SECTION. *DECLERATION DATA : IT BDCDATA TYPE TABLE OF BDCDATA, WALBDCDATA TYPE BDCDATA. DATA V_STRING TYPE STRING. ENDCIASS. * LCL_BDC_CLASS IMPLEMENTATION - CLASS LCL_BDC_CLASS IMPLEMENTATION. METHOD READ _FILE_INTO_TTAB. Page 37 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,AmeerpetsHyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.em: ABAP Objects We Never Compromise in Quality. Would You ? CALL FUNCTION 'GUI_UPLOAD' EXPORTING, filename = D4 FILE * FILETYPE "asc" HAS_PIELD_SEPARATOR ‘x tables data_tab = TrT DATA ENDMETHOD. METHOD FILL_SCREEN DETAILS CLEAR WA_BDCDATA, WA_BDCDATA~PROGRAM = IM_PROGRAM. WA_BDCDATA-DYNPRO = IM _DY¥NPRO. WA_BDCDATA-DYNEEGIN = IM DYNBEGIN. APPEND WA_BDCDATA TO IT_BDCDATA. ENDMETHOD METHOD EILL_FIELD DETAILS CLEAR WA_BDCDATA. WA_BDCDATA-FNAM = 14_FNAM. WA_BDCDATA-FVAL = IM EVAL, APPEND WA BDCDATA TO IT_BDCDRTA. ENDMETHOD | ENDCLASS * LCL BDC SESSION DEFINITION * CLASS LCL)BDC_SESSION DEFINITION INHERITING FROM LCL_BDC CLASS. PUBLIC. SECTION, METHODS: \CREATE_S#SSION IMPORTING IM GROUP TYPE APQ_GRPN ~ IM USER TYPE SYUNAME < ¢ IM KEEP TYPE c, BDC _TNSERT IMPORTING IM_TOCDE TYPE C, CLOSE_SESSTON ENDCLASS * ECL_BDC_SESSION IMPLEMENTATION * CLASS LCL_BDC_SESSION IMPLEMENTATION. Page 38 of 134 Compiled By: Ganapati Adimulam Max Technologies, Ameerpet Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? METHOD CREATE_SESSION. CALL FUNCTION” 'BDC_OPEN_GROUP' EXPORTING CLIENT = sy-manp? * Dest = FILLERS Group = IM_GROUP * —HOLDDATE = FILLERS KEEP = IM KEEP USER = IMUSER IF sy-subre = 0. WRITE / ‘THE SESSION TS CREATED SUCCESSFULLY! . ENDIF. ENDMETHOD. METHOD BDC_INSERT. CALL FUNCTION 'BDC_INSERT' EXPORTING TTCODE 7 TABLES eS READ FILE_INTO_ITAB ~ "EXPORTING IM_FILE =. '¢:\XD01_DATA. TXT" CHANGING IM_IT DATA = IT DATA. CALL METHOD OBJ_SESSTON->CREATE_SESSION EXPORTING IM GROUP = 'EMAX SESSION’ TUSER = sv-UNAME IMKEEP = 1x", FOR EACH DATA RECORD LooP AT IT DATA INTO WA_DATA. PSL 1st SCREEN DETAILS CALL METHOD OBJ. SESSTON->rrE4, SCREEN DETAILS EXPORTING IM PROGRAM = 'SAPMFO2D" iM_DENERO = '0100' TH_DYNBEGIN = 'X". ‘ILL FIELD CURSOR DETAILS CALL METHOD, OBJ_SESSION->FILL FIELD DETAILS EXPORTING IM_FNAM= 'BDC_OKCODE' IM-EVAL = '/00 ¥#KUNNR CALL METHOD OBJ_SESSION->FILL_¥TELD_DBTATLS EXPORTING IM FNAM = 'RFO2D-KUNNR! IM/FVAL = WA_DATA-KUNNR. **KTOKD CALL METHOD OBJ_SESSION->FILL_ FIELD DETAILS EXPORTING IM FNAM = 'RFO2D-KTOKD' IM_EVAL = WA_DATA-KTOKD Page 40 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies Amecrpet,Hiyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? +42ND SCREEN CALL METHOD OBJ_SESSION->PTLU_SCREEN_DETATLS EXPORTING IM PROGRAM = 'SAPMO2D' TMDYNPRO = '0110' IM _DYNBEGIN = "x" *4SAVE CALL METHOD OBJ_SESSION->FILL_FIELD_DETAILS EXPORTING IM_FNAM= 'EDC_OKCODE’ IMCFVAL = '=UPDA'. swmet CALL METHOD OBG_SESSTON->FILL_ FIELD DETATLS EXPORTING 1M $NAM = 'KNAL-NAMEL' IM_FVAL = WA DNTR-NAMEL **SORTL CALL METHOD OBJ_SESSION->FILL, FTELD_DEZATLS f EXPORTING TM_FNAM = '#NAL-SORL" 4 IM-EVAL = WA_DATA-SORTL. ¥ ‘**STRAS z CALL METHOD 0B9_SESSION->FTEaRTELD_perATLs EXPORTING. ¥ ‘KNAL-STRAS' WA DATA-STRAS. rus SRrORTING TH pra? ~tani* IAEVAL ~ WALDATA-LANDI +sSPRAS ‘a ee Catt METHOD Cag PRESeTON->FILL FIELD DETAILS — “HPN © 'KNAL-SPRAS* eS = WA_DATA-SPRAS. can METHOD OBZ § ggron 780d ain HACE = “2001. CLEAR WA_DATA. ~ ENDLOO?. bs *cLOsE ‘THE SESSION ’ CALL METHOD OBJ_SESSTON-SELOSE_szSSTON. Page 41 of 134 Compiled By: Ganapati Adimulam eMax Technologies, Ameerpet,ilyderabad Ph No: +91 4065976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? Batch input: Session Overview Bivens @ Poets GI buinies TO) Wks OST ATA OBA gsi ise ae rere ony I Haeeeacae peorse| ont |) clewor mote Fa peer frora| | ae [pspioer ruse fo or 0 1 Esevoor sarusch 0.07.20 process 38 |i7.97-a007 42.50 22) brouser barusen Page 42 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies,Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? ee eee Po pox Pcade epion sear SEE a cee! a re ester] O~@ ms,1Ds [Mal mo) ac} cc! sulle, Page 43 of 134 Compiled By: Ganapati Adimulam eMiax Technologies Ameerpet Hyderabad Ph No: 491 40-65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects ‘We Never Compromise in Quality. Would You ? e! - 2 C@@ | ‘Analysis of Session EMAX_SESSION & Optons 2 Lose litt Traneauiore (EB Sewene GP Lapcreatedon 2907 2007 3 900062222 has been casted 5 || [oa upeserenuee a Bef Lames pa eecpemenn ee eemnnrariens ek | RR {33:52:51 Processing sts i bi | locke ftase-st) atans | es | | Bp | frass2cu1|- aon | ot | Lk | Le eee ‘Analysis of Session EMAX_SESSION ‘El choose ortore 2 Loge FEW Tensceuons | Serene” | SE Ung ewatnaon 2072007 | aoaa Oe a joo: iseeapash 22.07.2007 ‘Asonaaon —— SAPUSER Locked unt uevetD ororz21ssissa0s20002 a Page 44 of 134 Compiled By: Ganapati Adimulam eMax Technologies,Ameerpet.Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? eee DAY-3 Interfaces : Interfaces extend the scope of a class by adding their own components to its public section. This allows users to address different classes via a universal point of contact. Interfaces, along with inheritance, provide one of the pillars of polymorphism, since they allow a single method within an interface to behave differently in different classes. Defining Interfaces INTERFACE in the deciaration part of the class, This statement may only appear inthe public section ofthe class. ee When yadfimplemént an interface in a class, the components of the interface are added to the other sin th pubic fection. A component of an interface can be addressed as though it weré a member of the class under the name . s The classi plement the metiiods of all interfaces implemented in it, The implementation part of the class must cantata method implementation for each interface method : ee ENDMETHOD. Page 45 of 134, Compiled By: Ganapati Adimulam eMax Technologies AmeerpetHyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? Interfaces can be implomented by different classes. Each of these classes is extended by the ‘same set of components. However, the methods of the interface can be implemented differently in each class. Interfaces allow you to use different classes in a uniform way using interface references (polymorphism). For example, interfaces that are implemented in different classes extend the public scope of each class by the same set of components. If a class does not have any class-specific public components, the interfaces define the entire public face of the class Interface References Reference variables allow you to access objects. Instead of creating reference variabies with, reference to a class, you can also define them with reference to an interface. This kind of referenceVariable can contain references to objects of classes that implement the corresponding interface, To define an interface reference, use the addition TYPE REF TO in the TYPES or DATA statement. must be an interface that has been decisred to the program before the actual reference declaration occurs. A reference variable with the type interface reference is called a interface reference variable, ot interface reference for short. ‘An interface reference allows a user to use the form -> to address all visible interface components of the object to which the object reference Is pointing, It allows the user to access all of the components ofthe object that were added to is definition by the implementation ofthe interface Addressing Objects Using Interface References To create an object of the’class with reference to the class, If the class implements an interface , you can use the following assignment between the class reference variable and an interface reference to make the interface reference in point to the same object as the class reference in : ‘ = If the interface contains an instance attribute and an instance method , you can address the interface components as follows: Using the class reference variable ‘+ Toaccess an attribute : -> ‘© Tocalla method : CALL METHOD -> Using the interface reference variable : © Toaccess an attribute : < iref>-> * Tocall a method : CALL METHOD ~> Page 46 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies. AmeerpetHyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.cmaxtech.com ABAP Objects We Never Compromise in Quality. Would You? Assignment Using Interface References - Casting Like class references, you can assign interface references to different reference variables. You can also make assignments between class reference variables and interface reference variables. When you use the MOVE statement or the assignment operator (=) to assign reference variables, the system must be able to recognize in the syntax check whether an assignment is possible. ‘Suppose we have a class reference and interface references , , and , The following assignments with interface references can be checked statically. © = Both interface references must refer tothe same intefage,o he interface of must contain the interface as a component. 5 © “The class ofthe class reference must implemefi the intetdbe of the interface reference . Banh © = ‘The class of must be the predefined emply class OBJECT. In all other cases, you would have to, work with the statement MOVE ...? TO or the casting operator (2=). The casting operator repiaces the assignment operator (=). In the MOVE... ? TO statement, or when you use the casting operator, there is.no static type check. Instead, the system checks at runtime Whether the object reference in the source variable points to an object to which the object reference in the target variable can also point Ifthe assignment is possible, the system makes it, otherwise, the catchable runtime eo IA CAST_ERROR oocurs You must always Se casting for assigning an interface reference to a class reference if does not refer tothe predefined emply class OBJECT oe Page 47 of 134 Compiled By: Ganapati Adimulam eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality, Would You? Overview Graphics for Interfaces eaoeeaie aal eee Ciare(c 1s memos: 1. ee Public Prnvate ‘EMDINTERFACE componente bompeneete bata: aa teen PRIVATE SECTION. of he method ENDCLASS. Protected ccmpenente ENDMETHOD Suites 61 All users — ‘The left-hand sidé Gf the diagram Shaws the definition of a local interface 11 and the declaration and implementation paris of @ jocal:class C1 that implements the interface 11 in its public section. The interface method I1~Mt"is implemented in the class. You cannot implement interfaces in the other visibility sections, The right-hand side ilustrateS-the structure of the class with the components in their respective visibility areas, and the implementation of the methods. The interface components extend the public scope of the class. All users can access the public components specific to the class and those of the interface. Page 48 of 134 Compiled By: Ganapati Adimulam eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxte ABAP Objects We Never Compromise in Quality. Would You? CLASS C1 DEFINITION. Class C1 PUBLIC SECTION. INTEREACES: T1, 12, Public Private PROTECTED SECTION. com ponents ae PRIVATE SECTION. Ie. ENDcLASS. is ‘noplementation of the metho: CLASS C1 MPLEAENTATION. Protected components METHOD Ti-... ENDMETHOD. METHOD 12... EMDMETHOD. ENDCLASS. All users Classes can implement any number of interfaces in their public section. The left-hand side of the diagram shows the declaration and implementation part of a local class C1, which implements several interfaces in its public section. The class must implement all of the interface methods in its implementation part. The right-hand-side,ilustrates the structure of the class with the components in their respective visibility areas, ar rahempter jentation of the methods. The interface components extend the public section of the class in which theyare dectared b v4 A Interfaces Introductory Example The following sifiple example shows how you can use an interface to implement two counters that are different, but can be addressed in the same way. See also the example in the Classes section. JESS SISSIES ISS ISO ESI II III * PROGRAM ©: © ZGDEMO_INTERFACES * * AUTHOR : GANAPATI . ADIMULAM * * PURPOSE =: Working With INTERFACES * Page 49 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,Ameerpet,flyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? * DATE 30=07=200 * COPIED FROM: * *COMPANY : @MAX Technologies * JESS SISOS SSIS IIIS I ISO II ISIE I IO II *MODIFICATION LOG * * + JASE SSIS SSIS EIS ISHII JOSS IIIS IE REPORT ZGDEMO_INTERFACES *SELECTION SCREEN *BLOCK BL SELECTION-SCREEN BEGIN OF BLOCK Bl WITH FRAME TITLE TEXT-000. PARAMETER : RB SALES RADIOBUTTON GROUP G1, RB_CUST RADIOBUTTON GROUP G1. SELECTION-SCREEN END OF BLOCK B1. *BLOCK B2 SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-001. PARAMETER : RB_cret RADIOBUTTON GROUP G2, RB_chng RADIOBUTTON GROUP G2, RB_DISP RADIOBUTTON GROUP G2. SELECTION-SCREEN END OF BLOCK B2. *INTERFACE DEFINITION INTERFACE I_DATA. METHODS : CREATE, CHANGE , DISPLAY. ENDINTERFACE *DEFINE LCL_CUSTOMER CLASS LCL CUSTOMER DEFINITION. PUBLIC SECTION. INTERFACES : I_DATA. ENDCLASS * IMPLEMENTATION CLASS LCL_CUSTOMER IMPLEMENTATION. Page 50 of 134 Compiled By: Ganapati Adimulam eMax Technologies,Ameerpet,lyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects ‘We Never Compromise in Quality. Would You? METHOD J_DATA~CREATE. CALL TRANSACTION 'XDO1'. ENDMETHOD . METHOD _DATA~CHANGE. CALL TRANSACTION 'xD02’. ENDMETHOD . METHOD J_DATA~DISPLAY. CALL TRANSACTION 'XD03'. ENDMETHOD . ENDCLASS. *CLASS LCL_SALES_ORDER CLASS LCL_SALES ORDER DEFINITION. PUBLIC SECTION. : INTERFACES T_DATA. ENDCLASS. * IMPLEMENTATION, CLASS LCL_SALES ORDER IMPLEMENTATION, METHOD 1_DATA~CREATE. CALL TRANSACTION 'VA01'. METHOD/T. _DATA~CUANGE . CALL TRANSACTION iyvacz’. ENDMETHOD . ENDCLASS . Page 51 of 134 Compiled By: Ganapati Adimulam €Miax Technologies, Ameerpet,HHyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality, Would You? ‘*REFERENCE VARIABLES DATA : 0 CUSTOMER TYPE REF TO LCL_CUSTOMER, © SORDER TYPE REF TO LCL_SALES ORDER, IREF_DATA TYPE REF TO I_DATA. JESS IIIT IIIS I IIIS III SE III ASIII I III II IIA * START-OF-SELECTION * JESS SGOT I ITSO S IIIS SSI IIS II IITA I I START-OF-SELECTION . CREATE OBJECT : 0_CUSTOMER, "CUSTOMER O_SORDER. "SALES ORDER *Assign the Corresponding Object to the Interface Object IF RB_CUST = 'x'. IREF_DATA = 0 CUSTOMER. ELSEIF RB_SALES = 'X'. IREF_DATA = 0_SORDER. ENDIF IF RB_CRET = 'X'. CALL METHOD IREF_DATA->CREATE. ELSEIF RB_CHNG = 'X CALL METHOD IREF_DATA->CHANGE. ELSEIF RB_DISP = 'X'. CALL METHOD IREF_DATA->DISPLAY. ENDIF. output + Page 52 of 134 Compiled By: Ganapati Adimulam ,Ameerpet,Hlyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98498 34399, ww ABAP Objects ‘We Never Compromise in Quality. Would You ? Execute : For Sales Order and Create Options , it should Call Sales Order creation ‘Transaction. henge Page 53 of 134 Compiled By: Ganapati Adimulam eMax Technologies,Ameerpet,Hyderabad Ph No: #91 40-65976727, Cell No: 99484 44808, 98490 34399, wwww.emaxtech,com ABAP Objects e Coe ‘Change Sales Order: Initial Soreen as &. Stee 8 tam oveniow | Crémnnp any | EB orere | GB “te 7 (Ppocreec crn a Sie : Page 54 of 134 Compiled By: Ganapati Adimulam eMax Technologies,Ameerpet,flyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? For Customer and Create Options, it should Call the Customer Creation ‘Transaction. Page 55 of 134 Compited By: Ganapati Adimulam ‘eMax Technologies, Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? Triggering and Handling Events In ABAP Objects, triggering and handling an event means that certain methods act as triggers and trigger events, to which other methods - the handlers - react. This means that the handler methods are executed when the event occurs, This section contains explains how to work with events in ABAP Objects. For precise details of the relevant ABAP staternents, refer lo the corresponding keyword documentation in the ABAP Editor. Triggering Events ‘To trigger an event, a class must ‘+ Declare the event in its declaration part ‘+ Trigger the event in one of its methods Declaring Events You deciare events in the declaration part of a class or in an interface. To declare instance events, use the following statement EVENTS EXPORTING... VALUE() TYPE type [OPTIONAL}.. To deciare static events, use the following statement: CLASS-EVENTS Both statements have the same syntax ‘When you declare'an event, you can use the EXPORTING addition to specify parameters that are passed to the event handler. The parameters are always passed by value. Instance events always contain the implcit parameter SENDER, which has the type of a reference to the type or the interface in which the event is declared Triggering Events ee ‘An instance event ina class can be triggered by any method in the class. Static events can be triggered by any static method. To trigger an event in a method, use the following statement RAISE EVENT EXPORTING... = . For each formal parameter that is not defined as optional, you must pass @ corresponding actual parameter in the EXPORTING addition. The self-reference ME is automatically passed to the implicit parameter SENDER Page 56 of 134 Compiled By: Ganapati Adimutam eMax Technologies,Ameerpet,lIyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? Handling Events Events are handled using special methods, To handle an event, a method must «be defined as an event handler method jor that event ‘© be registered at runtime for the event. Declaring Event Handler Methods a ‘Any class can contain event handler methods for events from other classes You can, of course, also define event handler methods in the same class as the event itself. To declare an event handler method, use the following statement: METHODS FOR EVENT OF IMPORTING. , foran instance method. For a state method, use CLASS- METHODS insteao OF META event declared in the class of interface . The attributes of thesparameter are also adopted by the event The event handler method does riot have to use all of the/parameters passed in the RAISE EVEN statement. If you want the implicit parameter SENDER to be‘tiséd as well, you must lst it in the interface. This parameter allows eh \tyou declare an event handler rey Bf isan Spit means that the instances of the class or the class itself are, in principle, able to handie a} yered in a method. ~ Registering Evant Handler Meth “GP a y Toallow an afte ee sto, secon event, you must determine at runtime the trigger to which iswi iis to react You canto inte olen SET HANDLER... ...FOR . or you can register the handler for all instances that can trigger the event: SET HANDLER... ...FOR ALL INSTANCES, ‘The registration then applies even to triggering instances that have not yet been created when you register the handler. You cannot use the FOR addition for static events: SET HANDLER... . The registration applies automatically to the whole class, o* to all of the classes that implement the interface containing the static event. n the case of interfaces, the registration also applies to classes that are not loaded until after the handler has been registered, 3 Timing of Event Handling After the RAISE EVENT statement, all registered handler methods are executed before the next statement is processed (synchronous event handling). if a handler method itself triggers events, its handler methods are executed before the original handler method continues. To avoid the possibilty of endless recursion, events may currently only be nested 64 deep Handler methods are executed in the order in which they were registered. Since event handlers are registered dynamically, you should not assume that they will be processed in a particular order. Instead, you should program as though all event handlers will be executed simultaneously, Overview Graphic : ‘Suppose we have two classes, C1 and C2 Eventtaser Page 58 of 134 Eventhenaer Compiled By: Ganapati Adimulam ‘Max Technologies,Ameerpet,llyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, ww: maxtech.com ABAP Objects We Never Compromise in Quality. Would You ? The class C1 contains an event E1, which is triggered by tne method M1. Class C2 contains a method M2, which can handle event E1 of class C1. The following diagram illustrates handler registration: Reoistering nencilers Seco ‘The program creates‘aiinstan@e"6f the:cless, C1 and two instances of the class C2. The values of the reference variables R1, Hand H2 point t0 these instances. The SET HANDLER statemehtigeates a handler table, invisible to the user, for each event for which @ handler method has been registered,” ‘F The handler table contains the,fiames of the handler methods and references to the registered instances. The entries in the table are administered dynamically by the SET HANDLER statement. A reference to an instance in @ handler table is like a reference in a reference variable. In other words, it counts as.a use of the instance, and therefore directly affecis is lifetime. In the above diagram, this means that the instances C2<1> and C2<2> are not deleted by the garbage collection, even if H1 and H2 are initialized, s0 long as their registration is not deleted from the handler table. For static events, the system creates an instance independent handler table for the relevant class. When an event is triggered, the system looks in the corresponding event table and executes the methods in the appropriate instances (or in the corresponding class for a static handler method). Page 59 of 134 Compiled By: Ganapati Adimulam €Max Technologies Ameerpet Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? Events: Introductory Example ‘The following simple example shows the principle of events within ABAP Objects. REPORT demo_clase_counter_event CLASS counter DEFINITION, PUBLIC SECTION. METHODS increment_counter EVENTS critical _value EXPORTING value(excess) TYPE i. PRIVATE SECTION. DATA: count | TYPE i, threshold TYPE i VALUE 10. ENDCLASS. CLASS counter IMPLEMENTATION, METHOD increment. counter. DATA diff TYPE i. ADD 1 TO count. IF count > threshold. aiff = count - threshold. RAISE EVENT critical value EXPORTING excess = diff ENDIF. ENDMETHOD. ENDCLASS: CLASS handler DEFINITION, PUBLIC SECTION. METHODS handle excess FOR EVENT critical_value OF counter IMPORTING excess ENDCLASS CLASS handler IMPLEMENTATION METHOD handle excess. WRITE: / ‘Excess is', excess. ENDMETHOD. ENDCLASS Dam rl TYPE REF TO counter, hl TYPE REF 70 handler: START-OF-SELECTION. CREATE OBJECT: rl, hl. )R ALL INSTANCES. SBT HANDLER hi->handle excess Page 60 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? Do 20 TIMES. CALL METHOD r1->increment_counter. ENDO. The class COUNTER implements a counter. It triggers the event CRITIGAL_VALUE when a threshold value is exceeded, and displays the difference. HANDLER can handle the exception in COUNTER. At runtime, the handler is registered for all reference variables that point fo the object. Events: Example2 JESS SESE SIIB ISI IIIS IIIS II III * PROGRAM AUTHOR PURPOSE =: DATE : COPIED FROM: *COMPANY : wee TEASE SSSI SIS III OIE REI *MODIFICATION LOG ZGDEMO_CUSTOM EVENTS * GANAPATI . ADIMULAM Working With Custoyf Ever 30-07-2007 eMAX Technologies JOSS OBES SESS U ESSE SISSIES ISEB ote REPORT ZGDEMO_CUSTOM EVENTS JOE C SSIES SII IISA ESSE ISI IE * LCL_COMPANY DATA DEFINITION * JEDI SSSI IOI TEI AIS IIIS II III IIIA CLASS LCL. pgreray DAA DEFINITION. "T_DATA, PEND_DATA, _DISPLAY_DATA, FRESH DATA. szvents Bocibvation EVENTS IS_INITIAL PRIVATE SECTION. Page 61 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies,Ameerpet,tiyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? DATA : BEGIN OF WA_TOO1, BUKRS TYPE BUKRS, BUTXT TYPE BUTT, ORTO1 TYPE ORTO1, LAND1 TYPE LAND1, END OF WA_TOO1. DATA IT_T001 LIKE TABLE OF WA_T001. ENDCLASS. JESSE IIIT III IAI ITO UII III IOI * LCL_COMPANY_DATA IMPLEMENTATION * JOE OO IOS DO IIIS II IIIT IIIT I I IAI CLASS LCL_COMPANY_DATA IMPLEMENTATION. JESSIE SSIES SISSIES IIIT IE * IMPLEMENT GET_DATA. * JX ESE JESU G III IU DUDE ITO II DIO II SII IIE METHOD GET_DATA. SELECT BUKRS BUTXT ORTOL LAND1 FROM T001 INTO. TABLE IT_T001 UP TO 10 ROWS. ENDMETHOD . JES EES SESE E IEEE I ISIS XIII OSI DO III * IMPLEMENT APPEND_DATA. * JES ESSE IDES IE ISIS ISIS AIDA I IAI METHOD APPEND_DATA. CLEAR WA_TOO1. WA_T001-BUKRS = 'E001'. WA_TO01-BUTXT = 'EMAX TECHNOLOGIES’. APPEND WA_TO01 TO IT_TOO1. CLEAR WA_TO01. WA_T001-BUKRS = 'T001'. WA_TOO1-BUTXT = 'iMAX TECHNOLOGIES’. APPEND WA_T001 TO IT_T001. ENDMETHOD . Page 62 of 134 Compiled By: Ganapati Adimulam es, Ameerpet,fyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? TEESE TOO SEIS IIIS IIIT I I IIIA * IMPLEMENT DISPLAY_DATA. * JESSE SIO TI IE EI IIIT IOI TUS TAI IRI III METHOD DISPLAY _DATA. IF NOT If TOO1 1g INITIAL. LOOP AT IT_T001 INTO WA_T001. WRITE :/ WA_T001~BUKRS,WA_T001-BUTXT. ENDLOOP . SKIP 2. ELSE. RAISE EVENT IS_INITIAL. ‘ENDIF. ENDMETHOD . * IMPLEMENT REFRESH_DATA. METHOD REFRESH _DATA. REFRESH IT_T001. ENDMETHOD. ENDCLASS. “CLASS FOR EVENT HANDLER METHODS CLASS LCL_handler DEFINITION, PUBLIC SECTION. *EVENT HANDLER METHOD METHODS HANDLE INITIAL FOR EVENT IS_INITIAL OF Ic. a DATA. *IMPLEMENTATION OF EVENT HANDLER METHODS CLASS LCL_handler IMPLEMENTATION. METHOD HANDLE_INITIAL. WRITE : / ‘EVENT ‘‘IS_INITIAL'' IS TRIGGERED’, WRITE: / 'NO DATA IN INTERNAL TABLE IT_T001'. Page 63 of 134 Compiled By: Ganapati Adimulam ‘handle INITIAL FOR 0_COMPANY_DATA. WRITE : / 'THE INITIAL DATA IS'. ULINE. CALL METHOD : O_COMPANY_DATA->DISPLAY_DATA, O_COMPANY_DATA->GET_DATA. WRITE : / ‘DATA AFTER SELECT'. ULINE. CALL METHOD : O_COMPANY_DATA->DISPLAY_DATA, O_COMPANY_DATA->APPEND_DATA. WRITE : / ‘DATA AFTER APPEND’. ULINE. CALL METHOD : O_COMPANY_DATA->DISPLAY_DATA, ©_COMPANY_DATA->REFRESH_DATA. WRITE : / ‘DATA AFTER REFRESH ULINE. CALL METHOD O_COMPANY_DATA->DISPLAY_DATA. Page 64 of 134 Compiled By: Ganapati Adimulam Max Technologies,AmeerpetHyderabad Ph No: 491 40 ~-65976727, Cell No: 99484 44808, 98490 34399, www.emaxtect ABAP Objects ‘We Never Compromise in Quality. Would You? OUTPUT : The Event IS_INITIAL is Triggerd , Every time the Internal Table is Empty. SSO:ONa 25a: 5h 08 Demo On Custom Events eno On custon Events 1 ict 5 ete Eure Subsidiary ~ gaipive q ‘| nay sar As site oes Oe 2 thes rine i a 2500, 3000 a0ie Eure Sobetstary - eotorue Enos Enwx TECuwOLOstes DATA AFTER REFRESH EVENT <6 (MITTAL” 15 TRIGGERED NO: OATA IA INTERNAL TABLE TC=TOOY Page 65 of 134 Compiled By: Ganapati Adimulam eMax Technologies, Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects ‘We Never Compromise in Quality. Would You? OO Transactions In transaction maintenance {SE93), you can specify a transaction code as an OO transaction. You either link the transaction code to the Transaction Service of the ABAP Object Services for persistent objects or to a public method of a global or local ciass of a program. When calling up transaction that is linked to an instance method, the system automatically generates an instance of the Glass in ts own internal session. ‘An example of a link between 2 transaction code and an instance method of a local class of an unspecified ABAP program: program DEMO_00_TRANSACTION class DEMO_CLASS definition. public section nothods INSTANCE METHOD. endelass clase DEMO_CLASS implementation method INSTANCE METHOD message ‘Instance method in local class' type ‘I! endaethod. endelass ‘The.DEMO_00_TRANSACTION program is a module pool of type M that does not Contain any screens or-dialog modules. Instead, the program contains the definition of @ local class OEMO_CLASS. ‘The DEMO_OO_METHOD transaction code is linked to this program as follows: Steps to Work With 00 Transaction : Execute SE93 and Continue with 00 transaction The Class Name is DEMO_CLASS ‘The Method is INSTANCE_METHOD. Local in program is selected and DEMO_OO_TRANSACTION specified. \Winen the transaction is called up, the program is loaded, an instance of the class is created, and the method is executed Page 66 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologics,Ameerpet,Hyderabad Ph No: +91 40 -65976727, Celt No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? Working With Global Ciasses : Class Builder : DAY-4 ‘The Ciass Builder is a tool within the ABAP Workbench that allows you to create, define, change and test GLOBAL ABAP classes and interfaces, Purpose: The Class Builder allows you to create and maintain global ABAP classes and interfaces. Both of these object types, like global data types, are defined in the R/S Repository. Together, they form a central class library and are visible throughout the system. eee Note: Transaction Code for Class Builder is SE24. Noto: Local classes are ony visible within the detning mod Features of Class Builder: a Display an overview (in the Class Browser) of global abject types ard their relationships Maintain existing global classes or interfaces. nal ‘Create new global classes and interfaces. Implement inheritance between global classes Greate compound interfaces Create and specify the attributes, methods, and events of global classes and interfaces. Define internal types in classes. Implement methods. Redefine methods Maintain local auxiliary classes. Test classes or interfaces in a simulated runtime environment big Naming Conventions in ABAP Objects Treagapienton hag , Piece: Goneral Remake een Kept as general as possible to avoid adversely influencing the naming When you choose names for development abjects, you should: + Use Englisty names + Use glossary terms when possible Page 67 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies,Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com { Local classes in programs ABAP Objects We Never Compromise in Quality. Would You? For example, CL_COMPANY_CODE instead of BUKRS + In-compound names, use the underscore character (_) as a separator. Since names are not case-sensitive, this is the only character that you can use to separate names, Example: CL_COMPANY_CODE, CL_GENERAL_LEDGER_ACCOUNT # Names should describe the action, not the implementation of the action. Example: PRINT_RECTANGLE, not RECTANGLE_TO_SPOOL lass in the class library CL_ ‘The class name should be made up of singular nouns. CL_COMPANY_CODE, CL_GENERAL_LEDGER_ACCOUNT Interfaces in the class library IF terface name> The same naming convention applies to interfaces as to classes. IF_STATUS_MANAGEMANT, IF_CHECKER Ceri (recommendation) The class name should be made up of singular nouns. LCL_TREE_MANAGEMENT Local interfaces in programs LIF_ (recommendation) The sane naming convention applies to interfaces as to classes. | LIF_PRINTER Conventions for Object Types Recommended naming conventions are not compulsory. However, if you use prefixes for these class and interface names, you should use those listed above. Page 68 of 134 _ Compiled By: Ganapati Adimulam ‘eMax Technologies, AmeerpetHyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com | Event handler methods L | I ABAP Objects We Never Compramise in Quality. Weald You? Conventions Tor Components Method names should begin with a verb GET_STATUS, CREATE_ORDER, DETERMINE_PRICE Events { Event names should have the form | snoun> spartcple>: , Local type definitions within a class (recommendation) | TYLINTERNAL TYPE, TY_TREE_LIST?” Data definitions (variables) class (CLASS-DATA or y DATA), avoid using verbs at sae of the name (to avoid conflicts with method names). LINE_COUNT, MARK_PRINTED, MARK_CHANGED, »StATUS 3 CO_MAX_LINE, 36. a es (CO_DEFAULT_WIDTH, nacommengsf nee are A. ee, However, if you use prefixes for these class and interface names, a Us nape a above Conerete Method Dereiigs a) Rs Data definitions (constants) (recommendation) SET_, GET_ Methods that access attributes of any kind should be prefaced with GET_or SET. Attribute access GET_STATUS, SET_USE_COUNT | “ON_ Methods that handle events shovld begin | with ON, followed by the name of the event that they handle. ON_BUTTON_PUSHED, ON_BUSINESS_PARTNER_PRINTED. Wethods that perform type $_ AS_STRING, AS_ISOCODE conversions Methods that return a Boolean | _IS_IS_OPEN, IS_EMPTY, IS_ACTIVE Page 69 of 134 Compiled By: Ganapati Adimulam eMax Technologies Ameerpet;Hyderabad Ph No: +91 40 -65976727, Cell No: 99434 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? value These methods may not return any exceptions. Recommendation: Use SPACE and 'X' to represent false and true respectively. [Check nathode CHECK CHECK_AUTHORIZATION, CHECK_PROCESS_DATE Local Conventions within Methods For parameters ‘The parameters are regarded from the point of view of the method that implements them: IM_ IMPORTING parameters a EXPORTING parameters, EX_ [ CHANGING parameters CH_s "RESULT RE_ - - Using prefixes is NOT compulsory. However, if you do use them, use those listed above, For exceptions The following table contains a series of possible exception names, that can also be used generically (for example, NOT_FOUND could also be used as DATE_NOT_FOUND) EXCEPTION Meaning | ACTION_NOT_SUPPORTED ‘The requested action or function code is not supported. “CANCELLED Ifa method uses @ dialog to find out what has to be dome (for | example, a list of choices), and the user chooses "Cancel you can set this exception EXISTING ‘Anew object that you want to create already exists in the database. FAILED The method could not be executed because ofthe current environment. This exception is intended for cases where the method cannot be executed because of variable system circumstances. Page 70 of 134 Compiled By: Ganapati Adimulam eMax Technologies, Ameerpet,{lyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Qualiyy. Would You ? Part of the method could not be completed because of the current environment. (OPEN_FAILED, CLOSE_FAILED, | ‘SELECTION, FAILED, AUTHORIZATION_FAILED) Data is locked by another user. ‘Object data in the database is inconsistent. “The component data for. of ap object in the database is inconsistent. Gi INVALID [The object data enereds infect (or oxample, company | | code does not exist), ampere NOT_QUALIFIED. a | “The component data Ehtered fora ee poren | Compare NOT-QUALIFIED. |. : INVALID Last resort. Only use this excepigpn i you cannat be more precise about the nature of the eg? The user does not have he required authorization | The object requested is not correctly customized | >The component ... of the requested object is not correctly “istomized ie 0 fing the requested object. | Unable fond Companent ... of he requested object. “The,combination of input parameters is insufficient to run the method. Compare INVALID, | One parameter ofthe method isnot qualified Error assigning a number. | This exception is set if the Basis system returns an \ unexpected error message Class Builder Initial screen: Creating Standard (Normal) Classes Procedure To create a new class from the initial screen of the ABAP Workbench: Page 71 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies, Ameerpei,Hyderabad Ph No: +91 40-65976727, Cell No: 99484 44808, 98490 34399, www.cmaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? Execute the Transaction SE24 (Class Builder] lew gee sigeno_ontonb rive & 2. Provide the Name of the Class and Choose Create. a amie POvENG_UPLOAD FILE #Stert) (B29 SAPM..J ABAP Continue with option CLASS. Page 72 of 134 Compiled By: Ganapati Adimulam eMax Technologies, Ameerpe Hyderabad Ph No: +91 40 ~65976727, Cell No: 99484 44808, 98490 34399, wwwy.emaxtech.com ABAP Objects ‘We Never Compromise in Quality. Would You ? ‘The TEMIOT UISpIY oF the Class Editor appears From Tere, We can denne WS components and mctude— interfaces in it Sheer arene eet _uruane cee (ele sey) a on rive, Defining Components of a Class : Creating Attributes Atrioutes contain data, They define the state of an object, that isthe instance ofa class. 1. Open the class in change Mode 2. Choose Attributes. 3. To create an attribute, Define a. unique name with which the attribute is identified. specify the Type as a constant, an instance attribute, or a static attribute (that is shared by all instances of the class) - Visibility. Define the visibility of attributes for the user of the class. Public assigns the attribute to the public area of the class and the attribute can be called by every user of the class. Remember that public attributes form part of the external point of contac! to the class, and as such stand in the way of full encapsulation Atributes that are protected are visible and can be used by the class itself and any of its subclasses Attributes that are private are only visible in and available to the class itself. Private attributes therefore are not visible in the subclasses. Page 74 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No: #91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? Fm ee meen 18 #stort| G6 Bsarm..| wiasap..| sap... |[fsap_ Bisaee..| PEND — 1%, : a Description \ ~ pt instances of the particular class (with CREATE The Protected opondefinbget nly nerd classes or the rlevant clas ise can crate instances, of this class. e ‘The Private option, only the rele! itself can create its instances (only using its own method). Class type - Normal Usual ABAP) Class = Final : A final class with the Final option completes the inheritance hierarchy since a final class may not create any further subclasses. + Modeled only : The class is not included in the class pool. We Cannot address it at runtime or test it. Choose Save. Enter the Package. Page 73 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality, Would You? = Modeled omnly Ifyou have selected this option, the system does not enter the interface in the class pool. You cannot access the components at runtime, = Typing methad ABAP keyword for defining the type reference. You can choose one of the following: Type, Like or Type Ref To (for class references) = Reference type You can use any elementary ABAP type (including generic types) or object type (classes and interfaces) = Read-only This option restricts the changeabiity of attributes as well as visibility. Users cannot change the attribute if a flag is set. = Description Short description of the components. «= nitial value i You must enter an initial valde for'constants, Note : Panton mie = aa a aos eee Properties | Interfaces | Friends Attributes | Methods | Events | intemal types’ | Aliases | Example: Name of Caner | f seats Ifyou need the definition of a structured data object here, click on and define the structure within the DATA statement in the displayed editor DATA: BEGIN OF structure, END OF structure. Then perform the syntax check. Save your entries, Page 75 of 134 Compiled By: Ganapati Adimulam eMax Technologies, Ameerpet,Hyderabad Ph No: +91 40-65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? Definition & Implementation Of Methods Methods describe how an object behaves. You implement them using functions defined within classes They are operations that change the attributes of a class or interface. There are instance- and static methods. Instance methods refer to a certain class instance, whereas static methods are common to all the class instances. Static methods can only address static attributes. ‘The special methods include constructors and class constructors, Constructors (class constructors) need not be created explicitly if they are not to be implemented. Procedure To-create methods for classes and interfaces 4. Open the Class in Change Mode through SE24, 18 SGe FH 200A OH Ow jass ZCL_DEMO_CLASS_FOR_BDC GFW) Tree) toleration ist oeas [a Parameters ot Ecepioneta)(0S/Cia FBIGR! iD). 8 ae fae eras ert vena buon FvGe_batay Trseaice Nethad”"Fublve {Gp puss 25 pews. GUASE_ Fon. fOG sues Choose Mathods tab Provide: Method Name, Type as an instance method or a static method (not instance-specific), Visibility Public assigns the method to the public area of the class and the method can be called by every user of the class, protected, itis visible to and can be used by the class itself and any of its subclasses, private, itis only visible in and available to the class itself, Private methods do not form part of the external point of contact between the class and its users, Page 76 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies,Ameerpettyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98190 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? S88... So If the flag is set, no entry will be made in the class pool. You cannot access the components at runtime: Description ‘Short description of the method. Note : Repeat the above steps for any further methods. If you create a constructor or class constructor method, itis assigned the predefined name CONSTRUCTOR or CLASS_CONSTRUCTOR respectively. The Class Builder also predefines certain other attributes. Save your entries. Creating Parameters for Methods. You define methods in a similar way to function modules. Soseate interface parameters and exceptions and then you code (implement) the method fe inpulgMegeters inlige re Importing ard ‘Changing parameters. The output parameters can be, ey EY ‘and Returning parameters: Procedure To create a parameter for a method 4. Open the class or interface in Change Mode. 2. Position the cursor on the name of the method or event." 3. Choose Parameters. 4. To define parameters of methods Click On Parameter to Provide the Input and Output Parameters pales Be [en Oe (EL RC BC IRS cenne eee Page 77 of 134 Compiled By: Ganapati Adimalam ‘eMax Technologies, AmeerpetHyderabad Ph No: +91 40 65976721, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? @ 2 8 60@ 800 H0oo DD Os (Class Builder: Change Class ZCL_DEMO_CLASS_FOR BDC BERS PB ot tee aii et a 0 Fa Creating Exceptions for Methods Use When you create an exception for a method, you can decide if you want to use the classical exceptions oF the new class-based exceptions in the method. When you use the class-based method, exceptions are represented with abjects of exception classes af runtime, Procedure To create an exception for a method 4. Place the cursor on the name of the corresponding method 2. Choose Exceptions. 3. If you want to define normal exceptions for the method, enter the following: = Exception Specify a suitable name for the exception. - Description ‘Short description of the exception. If you want to create a class-based exception, first activate the Exception classes checkbox and Page 78 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies, Amecrpet,Hyderabad Ph No: 491 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? RET ere THe appropriate EXCEPIION CIASSTES) UNGET EXCEPTION. ONCE YOU nave PreSSe ENTER, the Class Builder checks if the specified exception classes really exist. Ifa class does not exist, you can create it at this time. Otherwise the class description is copied. Clase [EL TESTOCASS implemented # Active Propeaies | interacee | Friends | Atputes. Methods | Events | Internal types | Alisee’ | ‘weihad exceptions TSPLAY, Methods | th Pavarnatore {ua i] ii] Augnehmenkioesen Exception lcx_}V_EXCEPTION Implementing Methods : MS Procedure f 4. Open the Class in Change Method, 6 2. Choose Methods. 3. Position the cursor on the name of the relevant mm 4. Double-click, or choose Source code. ‘The ABAP Editor appears, containing an empty statement block between the METHOD and ENDMETHOD statements, “Glass Buiter: Change Ciass 26L_DEMO_CLASS_FOR_GDC gia Sp ae ae i 2 eae, ceww-prue-onre Sige al ise 1B: Boece eee oe Page 79 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects ‘We Never Compromise in Quality. Would You ? cou fur display Ue Signature of the MelNod Neve. TO do So, click on Signature. To close the signature display, click again on Signature. 5. Write the ABAP source code for the method. You can also create text elements in the source code using forward navigation, e! B So@ SH0a TORT Grae placer enone eT ester ots. |wa Os. jus. la |Malie.. & iSree rea testa t a | | het) 7 ist ap - 1 Page 80 of 134 Compiled By: Ganapati Adimutam eMax Technologies, Amecrpet|Ayderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects ‘We Never Compromise in Quality. Would You ? 6. Check the syntax. 7, Save the source code. 8. Choose Back 10 return to the class editor. Save Check and Activate it. Seen] oo 3S] A, |S Bie RAL eee Note : Repeat the Same Procedure For All the Other Methods ‘Test Procedure: TESTING the Class and Method : Page 8t of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies, Ameerpet Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? Pane Sa Continue. Note : If the Class has Constructor Method, We need to Create the Instance of the Class first To Provide the Input for the Constructor . To do. so, Click On Create Instance. Which is Available on the Below Screen Only When the Class has Constructor Method. Coe BN SUS BH Ow {| oro FL 0874 ° u Page 82 of 134 Compiled By: Ganapati Adimulam eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 93490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? Select the Method Name and Click On Execute it and Provide the Parameters for the Method And Execute. © dtivanng | VE: ———— | To) CGe Sum a IL E_DATA: Display Res Si Test Method Testonject-sUPLDH8 FILE DAO) ‘oper omer oxee actove a eqn Lean 2 [ase ae Le cuneineserseter ay tape cucies st fa acs Page 83 of 134 Compiled By: Ganapati Adimulam eMax Technologies, Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? ae ea Soe Fhe Svas mn ® DATA from Entry 4 Sf ‘Structure Editor: Display UPLOAD_FRLE_DATAIT fed» MK conn GB erin stn Note : Repeat the Same Procedure to Create the rest of the Common Methods for BDC Program and Complete the Class Definition. Check the Below Screens for the Same. ‘Add the Method FILL_SCREEN_DETAILS and Implement it. Page 84 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? Add the Parameters. Class Builder: Change Class ZCL_DEMO_CLASS_FOR BDC Sse eelal ae Ae Page 85 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? Implement the Source Code. BB os Class Builder: Ci eS 1pedia Pretinter | Signature ora FILL SREEN_BETARLE oma nAreocoaTA To st precesue BACK -> Save ,Check and Activate it. Test it. ‘Next Method : FILL_FIELD_DETAILS and Provide the Parameters and Implement i Page 86 of 134 Compiled By: Ganapati Adimulam ies, Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www. Jaxtech.com ABAP Objects We Never Compromise in Qu Class Builder: Change Class ZGL_DEWO_CLASS_FOR_BDC 4 Ra ah | 8 | | pes) el imoiomeriaon | (ass mienice 20L_DENG_CLase FOR BOC is /Aetg Conse. A Hare | sae tio F saee” Warnes Cea | eames Memod patametere ___FILL_FIELD_DETAILS f fethoa Fike FIELD bevaTCS PATA (_WALDOCDATA TYPE BUCDATA Ea | c— Back, Save, Check and Activate it, Page 87 of 134 Compiled By: Ganapati Adimulam eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, wayw.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? And Testi. Result : A Class ZCL_DEMO_CLASS_FOR_BDC is Ready with Methods UPLOAD FILE DATA (to Upload the File) FILL_SCREEN_DETAILS ( Append Screen Details ) FILL_FIELD_DETAILS _ ( Append Screen Field Details ) NOW The Common Class is ready for AH the BDC Programs. Inheritance Creating Subclasses Use Inheritance allows you to derive classes from other classes. The new class contains a greater range of more specific functions than its superclass. You can do this by adding new components to the subclass or redefining methods inherited from the superclass. Procedure 1, Execute SE24 and Enter the Sub Class Name and Create. Page 88 of 134 Compiled By: Ganapati Adimulam Max Technologies AmeerpetlTyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, worw.emaxtech.com ABAP Objects We Never Compron SAP surach irra! Glick On Create Inheritance by Provide the Sub Class Name , Class Type a8 Usiial ABAP Class and DeSelect the Final (Further Classes Can be Derived From this Sub Class’). i lies Superciacs Desenption Indtantistion = For Seesion inhorting From Gene ube ear ‘Glass Type @ Usual ABAP Clase Exception Class | © Persiatent class Cicnly madeiad 7 v Sane x Page 89 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 ~65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? Extending Subclasses Changes to subclasses are additive, that is, you cannot delete @ component from a class if it was inherited from a superclass. However, you can extend a subclass as follows: By adding new components By redefining inherited methods You can only redefine instance methods. Attributes, class methods, and other inherited ‘components of a subclass cannot be redefined Furthermore, the methods that you want to redefine may not have been defined as final methods in the superclass, Constructor methads may not be redefined, since they are implicitly inal ‘A method redefinition may only extend to @ new implementation of the method. The signature (names and types of the parameters) may not be changed. The interface ofthe redefined method must remain the same as that of the original method in the superclass. Redefining Methods To redefine an inherited method in a subclass: 1. Display all the methods of the subclass The system displays the inherited methods of all subciasses. 2. Place the cursor on the relevant method and go to change mode 3. Click on Redefine. The ABAP source code of the original method implementation appears 4, Infiplement the method again. 5. Check the syntax 6. Save your source code 7. Document the newly implemented method Page 90 of 134 Compiled By: Ganapati Adimulam eMax Technologies Amecrpet Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise Would You? eae e 2H C60; 508 Sa8 moe Class Builder: Games Class ZCL_DEMO_CLASS_FOR_BDC_SE... | ea Rt | | Type i 26L_DemGCLASS_FOR_QOG_SESGION implemeniod 7 Actve Propenina | interfaces {Fringe { Aitubutes, " Method= Everts (intemaltysea 4 Aliesec_| #4” Inplementation| I Macros | [3 Paramotore 60 fea BS eee Sue HnaAa Ha Change Class ZCL_DEMO_CLASS_FOR_BDC_SE... | +e |) | yo nslomenaton ise interac "Zo DeNO_CLASS_FOR_BOC_SESSION limplomaited) Inactive (ovians)» 5) Propanies "| lbteragee [ Fuecde ( Attrvutes”” Mathoda | Events | internal typaa’ ont (aL Se (LL i S| (sa = fee ee esaari Sie Re 5 Sear a Page 91 of 134 Compiled By: Ganapati Adimulam €Max Technologies, Amecrpet Hyderabad Ph No: +91 40~65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? e S18 C6@ BM B28S OH a Class Builder: Change Class ZoL_DEMO_CLASS_FOR_BDC_SE... Se Se | Sk MM | Tynes Implementation fal Macs (Clase interface ZOL._DEMO_CLASS_FOR_60C_SESSION Implemanted / Active Properties | Interfaces | Friends ; Aftbutes © Metnods {Events | ls ethos paramete 9PEN_sesston fat [ee Be escola 7) (ERE SET - type P. __ Aseeciated Type import ‘RPO_MANOT = innpert [APO_GREN cae Impert ‘eo oe Import ‘APO_HAPW _CLASS_FOR_BDC_SESSION C. B® Patom Pretty Printor “lene [Smour nae i GALL FUNCTION *60c_0PEN_cRoUP | Sexporrznc eLieNr M_CLIENT: » “Gest FILLERS crouP MLGROUP + “Notooare FILLERG KEEP. i USER incuser RECORD FILLER: oP iin t= tn 71 of 33 ines [SER CE oniyice Th Page 92 of 134 Compiled By: Ganapati Adimulam eMax Technologies, AmeerpeisAyderabad Ph No: +91 40 ~65976727, Celt No: 99484 44808, 98490 34399, wow.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? SERT_SESSION, 212%, tase interface 'SSION, Inplamarand / aetwn Terpetion f. lnteraces [ Fiande |’ Aitdbutes”” mcinode {Event | intemaltypce | Alleses” | | a) near session ZCL_DEMO_| R_BDC_SE. [SS 2) SRA | et Types RST Implementation | KS Macros | interes > 9EL_DEMO_GLAGS_¢0R_SDC_SESSIGN implomented /Acive. Projeaus j iworeces f Priende {ilies Methods €'Events \ utamaliyeea. Abuses | INSERT_SeSsi oN Eceamona— fe S Page 93 of 134 Compiled By; Ganapati Adimulam ‘eMax Technologies. Ameerpet Hyderabad, Ph No: +91 40 65976727, Cell N 99484 44808, 98490 34399, www emastech.com %, ep ABAP Objects NS We Never Compromise in Quality. Would You ? M@O_CLASS_FOR_BDC_SESSION C. @ Porter Pretty Printer | Signature - ‘Deserption 1 Weobe IBE Tepe Ran “Tt 1 IED YNPROTAE TYPE STaNDARO TABLE ~/DYNPRO TaB 3 | TuSERT_StSStON act o oa ‘method INSERT CALL FuNeTION *BOC_1N5 EXPORTING TCODE = In_Tco0€ PosT_Locat. = NOvELOCAL, + PRINTING = HopRENT + Simentey . + crupa ens TABLES ‘synprotab = Im_OYHPROTAR, + exceptions + “INTERNAL ERROR (Obata oy aeen Oe onge Class 2CL_DEMO_CLASS_FOR_BOC_SE. OS a! e+ oe Se EF BW! tel Types ie implementation ite! Macros 0 SLASS_FOR_BUG_SESSTON Implemented / Active B00) 00, ce Larimer lGptaae pice pare insts Insta Page 94 of 134 Compiled By: Ganapati Adimulam eMax Technologies Amecrpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? Matos LOSE _sESSrON Act CTs) [1 (esis) (lca) ssthod CLOSE SESSION CALL FUNCTION pDC_CLOSE, “EXCEPTIONS. 2 NOT OPEN e ‘QUEUE ERROR SeneRs. SNExSaGE TD SySHSGIO TYPE SY-rSGTY NUMBER SY -NEaNO WITH S¥-MSGy! 'Sy-MSav2 S¥-MSGVa S¥-MSGva ENOTF IF sy-subre <> 0 | enemethod Result You have now extended the class, and your new components are visible, as well as the public and protected components of the superclass If you redefine a method in a subclass, the corresponding original method in the superclass remains a You can acéess i)8 components that are visible in the subclass in the same manner. You also access the inherit So one ients {fom the superclass with their local names. If, however, you need to address componénts a direct spores you can use the pseudoreference SUPER, Example | ram ‘With Session Method Using the Above Inherited Global Class : ncrorr 2 HRDESE”coaa_aNieRITANCE. DATA : BEGIN OF wa fi01, banks LIKE bnka“banks, bankl LIKE baka-bankl, banka LIKE bnka-banka, ort0l LIKE bnka-ort01, END OF wa_fi01. DATA : it_fiO1 LIKE TABLE OF wa_fi0l. Page 95 of 134 Compiled By: Ganapati Adimulam ‘Max ‘Yechnologies,Ameerpet, Hyderabad Ph No: #91 40 -68976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? DATA :WA_BOCDATA LIKE BDCDATA, TT-BDCDATA LIKE TABLE OF WA_BDCDATA, DATA 0_BDC_SESSION TYPE REF TO ZCL_DEMO_CLASS_FOR_BDC_SESSION ®_START-OF-SELECTION START-OF-SELECTION CREATE OBJECT 0_BDC_SESSION. CALL METHOD o_bdc_SESSTON->upload_filedata EXPORTING ‘im_file = ‘imsep changing it_data = IT_FIO1 'C:/FIOL. xT" Sh if. sy-subre = 0. write :/ ‘file is successfully uploaded’ . endif. *OPEN_GROUP CALL METHOD 0_BDC_SESSTON->OPEN_SESSION EXPORTING IM_CLIENT = SY-MANDT IM_GROUP = 'ZSATISH’ IMLKEEP = 'X" IMLUSER = SY-UNAME. * RECORD To BE CREATED LOOP AT IT_FIO1 INTO WA_FTOL. REFRESH IT BDCDATA. *FIRST SCREEN DETAILS CALL METHOD 0_bdc_SESSION->fi?7_screen_details EXPORTING ‘improgram = "sapme028" im_dynpro *9100" im_dynbegin = 'x' changing it_procedure = TT_socDATA BANKS CALL METHOD 0_bdc_SESSION->fi11_field_details EXPORTING ‘im_fnram "BNKA-BANKS* im_fval wa_fi01-banks changing ‘tprocedure = IT_sDCDATA *BANKL CALL METHOD o_bdc_SeSSION->fil1_tield_detai1s EXPORTING Page 96 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hlyderabad Ph No: +91 40 -65976727, Cell No: 99484 44908, 98490 34399, www emaxtec ABAP Objects We Never Compromise in Quality. Would You ? im_foam = 'BNKA-BANKL' ‘im_fval = wa_fi01-bank. changing t_procedure = 1T_BOCDATA *ENTER CALL METHOD 0_80C_SESSION->fi11_field_details EXPORTING jm_fnam BDC_OKCODE* im_fval +700" changing ‘it_procedure = IT_BDCDATA #SECOND SCREEN CALL METHOD 0_BDC_SESSION->fil1_screen_details EXPORTING ‘improgram = 'SAPMFO2B" = imcdynpro 10110" ‘im_dynbegin = 'x' changing ‘it_procedure = TT_BDCDATA *BANKA CALL METHOD 0_sDC_SESSION->fi11_field_details| “i EXPORTING ” ‘im_fnam = "BNKA~BANKA’ ‘im_fval = wa_fi0l-banka changing it_procedure = IT_BDCDATA FoRTOL CALL METHOD 0_BDC_SESSION->fi11_field_details EXPORTING ‘im_fnam "BNKA-ORTOL" im_tv; wa_fi01-ort01 cnanaing pale = TTsocoaTa *SAVE. y CALL MERHOD 0_ > >fi11_field_details ali }C_OKCODE* Slag =n" changing ‘it_procedure = IT_BOCDATA *B0C_INSERT CALL METHOD 0_BDC_SESSION->INSERT_SESSION EXPORTING IM_TCODE = 'FIOL" CHANGING IM_DYNPROTAB = TT_BDCDATA. Page 97 of 134 Compited By: Ganapati Adimulam eMax Technologies, Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? ENDLOOP . *BDC_CLOSE CALL METHOD 0_8DC_SESSION->CLOSE_SESSTON. execute the Program and Run the session I.e Created By the Program. Bin kay " rs Greate bank > Dc a | Page 98 of 154 Compiled By: Ganapati Adimulam €Max Technologies Amecrpetyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, wow.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? Overview Or the Session: Batch input: Session Overview Analysis ® Process (Hl Statistics | log El Recoring Ma ke S ee From To Created by, * “—“Kahotsa, EH E ores 5 nigel SAcusER Eee USER 2007|14:86 17lenECo PUSER E corns ISapUSER 2a07/14.39.s5|zRece \ PUSER Hoe arvsee zea7|t4:39.26,zReco | Garuser PUSER zeor|ia 20. o1lzneca { SAPUSER I Earusen 2007/14: 26: 48.zAEco | BAPUSER. os USER 2007}17:21 :05\ze0¢ eraser o2ize00 USER SESS @ earusen =a) ‘nlyice WS Analysis of Session ZSATISH its | Orticne 1 Lage | |G Sas BH Tronaacuons [EA Serene” | GF Loa created on OG 207 | i aria Faider ae aes Braet oo ise | ae | Page 99 of 134 Compiled By: Ganapati Adimulam eMax Technologies, Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? Example 2 On Inheritance : Define Another Sub Class for Call Transaction Method from the Same Super Class. REPORT ZCALL_TRAN_GLOBAL_INHERITANCE DATA : BEGIN OF wa_Fi01, banks LIKE bnka-banks, bank? CIKE bnka-bankl, banka LIKE bnka-banka, ort0 LIKE bnka-ort01, END OF wa_fi01. DATA : it_fi01 LIKE TABLE OF wa_fi0l. DATA :WA_BDCDATA LIKE BOCDATA, TTLBDCDATA LIKE TABLE OF WA_BDCDATAG DATA O_BDC TYPE REF To ZCL_DEMO_CLASS_FOR. <« * START-OF-SELECTION. START-OF-SELECTION. CREATE OBJECT 0_B0C. CALL METHOD o_bdc->upload_file data EXPORTING ‘im_file im_sep changing itcdata = TTFr01. FIOL.TxT" iS * RECORD TO BE CREATED LOOP AT TIEFEOpINTO WA.FIOL. REFRESH JPFEBDCDATA. *FIRST) SCREEN DETATES |_bdc-> fil 1_screen_details afisapnroze" Ime = 10100" ‘imdy x" changing ‘t_procedure = IT_BDCDATA. BANKS CALL METHOD o_bdc->fill_field_details EXPORTING im_fnam *BNKA-BANKS" ‘im_fval = wa_fi0l-banks Page 100 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies, Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? changing ‘it_procedure = IT_socDATA. SBANKL CALL METHOD o_bdc->fil1_field_details EXPORTING ‘im_fnam "BNKA~BANKL" im_fval wa_fi01-bankt changing ‘t_procedure = IT_BDCDATA. ENTER CALL METHOD o_bdc->fi11_field_details EXPORTING ‘im_fnam "BDC_OKCODE* ‘im_fval "700" changing ‘it_procedure = SECOND SCREEN z CALL METHOD o_bdc->fi11_sc jetails EXPORTING ‘im_program SAPMEO2 0110" rT_BDCDATA.. imdynpro. imdynbegin = 'x* changing it_procedure = TT_BDCDATA: 4 Rana Site i1]_field_c a 1 CALL METHOD 4 ie’ ails SxpoR Nee ‘im_fnam NGA BANA a im_fval changing it_procedure ° *oRTOL we CALL METHOD o_bde->FiT1_fjeld_details EXPORTING ‘im-fnan = "amma-onT01" im_fval wa_fi0l-orto1 changing ‘t-procedure = TT_BDCDATA. *SavE CALL METHOD o_bde->fi11_field details EXPORTING ‘im_fnam *BDC_OKCODE" ‘im_fval *=UPDA" changing ‘it_procedure = IT_BDCDATA. Page 101 of 134 Compiled By: Ganapati Adimulam, ‘eMax Technologies, Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? CALL. TRANSACTION CALL METHOD o_bdc->ca¥1_transaction EXPORTING teode imupdate = im_mode ‘At it_data IT_BDCDATA. ENDLOOP. Execute the pr ele Create bank: initial Screen Bark eatiy mn ‘Gene muminer ao | . = TREY ba renyass TINS Similarly All the records wi be Created. Page 102 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects ‘We Never Compromise in Quality. Would You? Interfaces Definition and implementation : Interface Definition (Creation ) : Execute SE24 and Enter the Name and Create. Page 103 of 134 Compiled By: Ganapati Adimulam eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www .emaxtech.com ABAP Objects Bie Class Builder: Change Interface ZIF_DATA | DS S| a Eh |e | “race docienianon ‘Povcerins tiene“ aie Save ,Check and Activate. Result : An Interface is Ready with the Services (Methods) CREATE,CHANGE and DISPLAY. WE Can Give Different implementatioins for the Same Methods in Different Classes. Enhancing Classes with Interfaces Interfaces are extensions to class definitions and provide a uniform point of contact for objects. In contrast to classes, instances cannot be created from interfaces. instead, classes implement interfaces by implemening ita sr methods. You can hen adres tem using either las references or interface referenc, Different classes can implement the same interface in difterent ways by implementing the methods aifferenty. Interfaces thus form the basis for polymorphism in ABAP Objects Implementation sgthrough Class : ZCL_CUSTOMER “s Procedure 4. Create the Class to Implement the above Interface .e Execute Class Builder SE24, Page 104 of 134 Compiled By: Ganapati Adimulam Max Technologies,AmeerpetHyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? | | have eh rah es Page 105 of 134 Compiled By: Ganapati Adimulam eMax Technologies,AmeerpetHyderabad Ph No: +91 40 ~65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality, Would You ? = Interface Definition of the interface name. When you press Enter, the system checks that the interface exists in the class library. You can use the possible entries help to display a list of all interfaces, ~ Abstract Only mark the checkbox if the defining class is an abstract class. This means that all the instance methods of the interface have property ABSTRACT . For this reason these interfacé methods may not be implemented in the defining class. Instead, the derived classes must implement il he interface methods, - Final : Marking the checkbox means that all instance methods of the interface(hay"atrbute. means that the interface methods may not be redefined in the subclasses wien the cia a face in the class pool. You cannot Repeat the above steps for any further inteHtaees. # Ite interface is nested, the system displays all ofthe cofmponentinertaces inthe hierarchy after it has checked your input a - Modeled only as Ifyou have selected this option, the system does not en ‘access the components at runtime. 4. Save your entries. You can assign attribute ABSTRACT of FINAL for selected instance methods of the interfaces. To do so, place the cursor on the required interface method in the method display of the enhanced class and go to the detail display of the selected method by choosing Result You enhanced domponents of the class with interfaces. The interfaces that were added are listed in the definition part of the class following the INTERFACES statement in the class pool. The mel tees in the. fetes definition can only be implemented within the class if they did not mark the taterface as Abstract. The components defined in the interface (attributes, methods, and events) appear inthe Class in the from ~ like the below Screen. This enstirés that no naming conflicts can occur with class components. Page 106 of 134 Compiled By: Ganapati Adimulam ,Ameerpet.Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality, Would You ? Class Builder: Change Class ZCL_CUSTOMER S| 8 SS | ABC WM | BI ose | impiemeninon | actos “DY conciucor) + aoLcusroreR inglonbbdiieive texseg: former | instead’ Fie” BINO” Wot see | manatee {Meow | Be WE 2 we ea paoriccica iF paiccuee ‘ange Ota aan OTSPLH ‘beirbat ——— 5 Select the Method and | Click On Code to (a Implement the Method. ‘Tema wo Ws |MAL |e ANS Gea MEA CR Now Implement the Methods by Providing the source code to meet the functionality . Page 107 of 134 Compited By: Ganapati Adinmalam Max Technologies,Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects ‘We Never Compromise in Quality. Would You ? Implementation For Method CREATE. el 1 SO@ Basa Class Builder: Class ZCL_ CUSTOMER Change © Fars Pre ener | Sie ere =r oe XDO1 is the Transaction — ALL HmkeAt0n “01 Code to Create the snot Customer. Class Builder: Class ZGL_CUSTOMER Change SDD hE | yeh | FA | Paten |rowspan || Sana Sea eee ah Page 108 of 134 Compiled By: Ganapati Adimulam eMax Technologies, Ameerpet,Ayderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? implementation For “Class Builder: Cisss ZCL_CUSTOMER Change |e Bieter BI | pater | Previa | sions Tle CT lan serio “3609 Save, Check and Activate it. Test the Class : F8 ae COO SH Chest Builders Change Class 201_cUSTOMER To | Ren ie Wis) anes CY Sta ON: ao See amt es CLAS... | WABAP. [WS ABAP.INFEClass... Page 109 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? Coe Sam Sean ae) ‘est intertace ZIF_DATA Bi It Hora, menereserrecs gave oats — estar GB wo Eee BpeaP.|IStest CIDER 616PM Page 110 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies,Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? Customer Creation Transaction for the Create Method in Customer Object. (Sessa [aieates swan custamer | Saree ongomation arcu sns.asean._cstonee- Page 111 of 134 Compiled By: Ganapati Adimulam Max Technologies, Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emax ABAP Objects We Never Compromise in Quality. Would You ? Usual ABAP Clace > Exception Class 2 Persistent class Page 112 of 134 Compiled By: Ganapati Adimulam eMax Technologies.Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98496 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? oe 5,78 COO, HS DOS NA Oe Class Guilder: Change Class 2CL_SALES_ORDER > | 8 2 GB | BF a hve imwearaton |G ace) contactor) OV» tne a Page 113 of 134 Compiled By: Ganapati Adimmulam «Max Technologies,Ameerpet.Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44308, $8490 34399, www.emaxtech.com ABAP Objects We Mover Compromise in Quality. Would You? Implementation For Create . 2/981 Cee Gate ‘Class Suilder: Class ZCL_SALES_ORDER Change | | LS | Eto Prony Pier Sra 3 el @ we Create Sales Order ‘Transaction is Called Class Builder: Class ZCL_SALES_ORDER Change Ba | eS | AH a | Patan | Hew P| “Sananre Tir parecmee es ‘Sah asic Page 114 of 134 Compiled By: Ganapati Adimulam «Max Technologies, Ameerpet,HTyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality, Woutd You? Implementation For Display . 2G, CGe SMM ONT 2 HE Ow Class Builder: Class ZCL_SALES_ORDER Change ese eaieieiaa | BE 2 ee setnoe TBAT DISPCRT sipasia: Wane eee Test > F8 Page 115 of 134 Compiled By: Ganapati Adimulam eMax Technologies, AmeerpetAlyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? ai U ok 606 Sha ano8 BA ow Test Class ZCL_SALES_ORDER emesis ener Tower cose active a @ ceed, 2 COSC SNS BUNGE! Se, Test interface ZF DATA Be Pana atte 5 irons rosea Comer a — C “Eine = sions wast stort] @ sac. | Baas | B)awar. | RABAP. |S Test.. Page 116 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies, Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? Create Method in the Instance Of Sales Order Class , Should Create Sales Order. ‘Teetovect->ZIF_pATA~ HB — Execute Change Method Page 117 of 134 Compiled By: Ganapati Adinmutarn eMax Technologies,Ameerpet Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality, Would You? TH CO@ SNS ONG | eoistosar Example Program to Work with Global Interfaces TnonHneinenernniborinnon Honuneiiibnunbriremins * PROGRAM Z_INTERFACE_USING_GLOBAL_CLASS* * AUTHOR GANAPATI. . ADIMULAM + * PURPOSE working With INTERFACES . * DATE 03-08-2007 * * COPIE * *COMPANY eMAX Technologies * eresoueses ite reer ses eerese * * A Ee RAR tee USING GLOBAL_CLASS . eS *SELECTION *BLOCK B1 SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000. PARAMETER : RB_SALES RADIOBUTTON GROUP G1, RB_CUST RADIOBUTTON GROUP G1. SELECTION-SCREEN END OF BLOCK B1. Page 118 of 134 Compiled By: Ganapati Adimulam Max Technologies, Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? *BLOCK B2 SELECTION-SCREEN BEGIN OF BLOCK B82 WITH FRAME TITLE TEXT-001. PARAMETER : RB_cret RADIOBUTTON GROUP G2, RB_chng RADIOBUTTON GROUP G2; RB_DISP RADIOBUTTON GROUP G2. SELECTION-SCREEN END OF BLOCK 62. *REFERENCE VARIABLES DATA : O_CUSTOMER TYPE REF TO ZCL_CUSTONER, A OLSORDER TYPE REF TO ZCL SALES ORDER, IREF_DATA TYPE REF TO Z1F_DATA. Pereresttistirertrcetteretrsrrcstecrsrerecesrsy * START-OF-SELECTION IESE SHS HENS IESE ION NTIS ISSUE SIS II START-OF-SELECTION. CREATE OBJECT : O_CUSTOMER, "CUSTOMER OLSORDER. |*SALES ORDER IF RB_CUST = 'X'. ELSEIF RB_SALES = *x'. IREF_DATA = O_SORDER. ENDIF. IF RB_CRET Page 119 of 134 Compiled By: Ganapati Adimulam eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? eros Nesting Interfaces ABAP Objects supports nested, or compound interfaces. A compound interface contains one or more interfaces as component interfaces. These may contain further interfaces as components, A number of levels of nesting are therefore possible. Interfaces that do not contain other interfaces are referred to as simple interfaces, Use Procedure 1. Goto the Class Editor of the Class Builder. 2. Choose interfaces for the relevant interface (making sure you are in change mode). Page 120 of 134 Compiled By: Ganapati Adimulam eMax Technologies, Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects ‘We Never Compromise in Quality. Would You ? 3. Under Includes, enter the names of the component interfaces Ifyou select the Only modeled option, the system does not c/eate a corresponding entry in the Class pool. 4, Press Enter. ‘The entry in the class library is checked, The description is then added. 5. Save your entries. Result All of the component interfaces that you entered belong to the same nest ‘compound interface, it must implement all methods of all component All tne interfaces mvolved are implemented at tne same level, whatever their nesting Mierarofy- They are now “next to each other’. You acoess their components using their original names that is, the form: ~ You can assign all the components offi interfaces alias names as an abbrevialion for the full name. To do so, click on Aliases and enter ai addition to the name, you can also define the visibility (PUBLIC, PROTECTED, PRIVATE! restrict the use of alias names. Sa, Creating Events NEE [ABAP Objects can indicat that their state has carey tidGering @ method. Events can be defined in classes oF in inteffabes,,. Corresponding ethods jgger these events with the RAISE EVENT statement. Eaghi : that going to fle the coresponding event must implement a relevant handler andiregis \the SET HANDLER statement. When an event acours, the system cals al of the Like method definitions, have EXPORTING param Prerequisites >. You must already have created yy” interface. Procedure ler methods registered for that event ts have a oa interface. The only difference is that events may only 4. Select the class or eet and change to the Class Editor. 2. Choose Events. 3. Tocreate an event, make the following entries: - Event Define a unique name with which the event is identified. Type Specify events with an instance event as instance event or with static event as static event. + Visibility Define the visibility of the event with Public, Protected or Private. Page 121 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies, Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, wow.emaxtech.com ABAP Objects ‘We Never Compromise in Quality. Would You ? - Modeled only If the flag is set, no entry will be made in the class pool. You cannot access the components at runtime, - Deseription Short description of the event. 4, Repeat the above steps for any further events. Example: Clase |CLTESTOLASS ~~~" implemented 7 Act Properios | Inturtaces | Friends | Attnbutes | Methods Evente | intomnal types | Parameters | Ea| Males] Glee] s¢|1| A) 20/68) F Ee 5. Save your entries. Result ‘You have now created events for your object type. The events are listed in the declaration part of the class or interface after the EVENTS statement. Creating Internal Types in Classes AED You mustfot create bub data types within global asses. Procedu re 1. Startti itor in change mode. 2. Choos 3. To create an internal type within a class, enter the following information: ~ Type A.unique name to identify the type. The recommended naming convention for internal types in classes is to use the prefix TY_, = Visibility Defines the visibility. If you make the type private, it can only be accessed from within the class Page 122 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,Ameerpet,llyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? 4 itself. If the type is protected, itis also visible to the subolasses of the class. = Modeled Ifyou select this option, the system does nat enter the type in the class pool. You will not be able to address the component at runtime. = Typing method ‘ABAP keyword indicating the reference type. This can be one of TYPE, LIKE, of TYPE REF TO (for class references). - Reference typo You can use any elementary ABAP type (including generic types) or object type (classes and interfaces) - Description Short description of the type. Save your entries, 4 if you need to qualify an interndldata type in a class further (far example, to specify the field length of a character field), [email protected] type entry. Note that this only makes sense if you have aot selected Only modeled. AES [CL_DEO_ATRPLANE Implemented inextive wind | AL Intetoves |G Alubutes | ® Methods | Everts Ineralypes | |_|" |e) es PEs "5 [ol marl Reem vs] [Dee TWORTENTATION — [Protecied) | | |Protected| T_ WSTRING Sting tit [Type direct type entry ‘The contents of the class pool appear for the corresponding visibily section. 7. Modify the data type Page 123 of 134 Compiled By: Ganapati Adimulam eMax Technologies, Ameerpet,yderabad Ph No: +41 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? 8 =" types 7 TYPE: 8 | TYLORIENTATION(5) TYPE © , 8 TV_STRING(1824) TYPE C . . 10 8. Check the syntax. dh 9. Save your entries. ot 40. Choose Back to return to the Internal types display. Result You have now created internal data type within your class. You can use these inyour class, and, if they are defined as protected, alsa in its sdbelasses. You can define private and protected attributes and interface parameters using the TYPE agi Use The Class ucla jolene story ches win a global lass. This enhancement can be useful when you wali fo encapsUlate implementation detals ofthe global class to hide them from outside. The local auxili ees can onl seen and used within the defining global class. Procedure 4. Sélect the class and changai the Class Ear. 2. Choose’ mpl. fr local ess implementations. ‘The ABAP Editor for the class implementation is displayed, 3, Go to change mode. 4. Edit the definitions and implementation parts of the local class: CLASS DEFINITION BNDCLASS Page 124 of 134 Compiled By: Ganapati Adimulam eMax Technologies Ameerpet,Hyderabad Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? Defining Macros that are Local to the Class Use As in the context of ABAP programs, you can create macro definitions within the classes in the Class Builder, These include a sequence of complete ABAP. “gta can be used more than once within the defining class. oy & Procedure 1. Select the class and go to the Class Eiter. 2. Choose Macros. ‘The system displays the Ecitor. 3. Goto change mode. 4, Edit the macros within the corresponding statement block DEFINE . Defining Global Exchpli.classes % Basis Release 6.10 introduces the conce fotos exceptions, Atruntime, an exception is represented with an.excention object, andis therefore jan stance of an exception class. The attributes of an exception agian Gopal adatona fermion apeuthe err ie In addition to using predefined exeeptie Classes for a inthe suntime environment, you can define your own global exceptign-classes for'spedal erors within your application using the Ciass Buller. The flowin documenatensescibes hese or dong so Creating ExceptionyClasses Procedure You can create a new exception class where you need it the first time, for example when assigning exceptions in the method definition. To create en exception class from the intial screen of the Class Builder SE24 1. Enter the name of the new class according to the naming conventions under Object type. The refix CX is added to the class name of all exception classes. 2. Choose Create. The Create Class dialog box is displayed. Page 126 of 134 Compiled By: Ganapati Adimutam ‘Max Technologies, Ameerpet,Hyderabad Ph No: 491 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects ‘We Never Compromise in Quality. Would You ? 3. Enter the rest of the basic data for the class’ Inherits from Enter the name of the direct superclass. Exception classes are derived from one of the predefined basic classes CK_STATIC_cHECK, CX_DYNAMIC_CHECK of Cx_NO_CHECK as subclasses. Depending on the position of the ‘exception class within the class hierarchy, enter the appropriate claes within this hierarchy of one of the predefined basic classes as superclass. In the latter case, expand a new hierarctiy tre. ~ Dascription Inst. Creation In general, classes are marked with the Public option. /This means instances of the particular class (with CREATE OBJECT). ‘The Protected option defines that only inherited clasteagolvant class itself can create instances of this class. nas? I you choose the Private option, only the relevant class itself can create Its instances (only using its own method). You can define an abstract class with the Abstract option. You cannot create an instance for this, lass, An abstract class can be uséd as template for your subclasses. You can only access this ‘class with your static attrbutes or with your subclasses, - Class type I you assigned the prefix cx for the name of the exception class, class type Exception class is sees ia fFinal, * ae A Yoidetine a finalfajoeption class with the Final option. This class completes the inheritance rieaty sinoaé Aa case may not cent any thor sublasces = Modeled only Ifyou mark this checkbox, no entry is made in the class poo! for this exception class. This class cannot be accessed at runtime. 4. Choose Save. _Page 127 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies, Ameerpet,Hydcrabad Ph Na: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? ‘The Create Object Catalog Entry dialog box is displayed 5. Enter the Package. 5. Choose Save again Result Z You create @ new exception class. A class pool was generated for he new See the Modeled only option was not activated. In contrast to normal classes, you cannot ereate a method for an aN The Clase Bulider simply creates the constructor. However, you can create attributes and maintain exception texts, Creating Exception Texts y There should be an explanatory text'Gssighied to each exception. This text describes the exception situation for the user. You can assign Fe texts to an exception class in the Class Builder. Different texts are addressed with the Corresponding IDs. Each class has a default text whose ID Corresponds fo the class name, If you Wart iSeréate further texts fr special casos ofthis exception, you have to assign a separate ID for each * Exception texts aggeneraly language- petite and ee 6 to)E translated. The OTR can be used here as a central sorage ia a = texts. You might want to a ein te atte rane n Bigs Example: An error occu in object &ATTRIBUTE®. sxtaiwith attributes of the exception class. To do so, enclose Procedure To create exception texts: Select the exception class, Switch the Class Builder to change mode and click on Texts. First edit the default text whose ID was created automatically by the Class Builder. Choose ENTER Bona ‘The system displays the Create OTR Concept dialog box. 5. Confirming your entries will copy the new text to the OTR. 6. Ifnecessary, create further IDs to assign special texts and repeat steps 4-6, Page 128 of 134 Compiled By: Ganapati Adimulam €Max Technologies, Ameerpet,Hyderabad Ph No: +91 4065976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? Result ‘The exception texts for an exception class are created in the OTR and can be output as message texts. Settings in the Class Builder Use the Class Builder settings to change the display of the classes and their components. To change the Ciass Builder settings: 1. Choose Utilities > Settings. 2. Select the appropriate settings on the Class Buildertitle element and confirm them with 3. The selected settings will take effect in the Class Builder when you select the Filler checkbox. rN Properties | Interfaces | Friends Attributes | Methods | Events | internal types | Aliases | | G\2>| Bie) Xe) Al ala, ee _ Ee Fite Options ‘You can select the folowing options: Option Meaning (if flag is set) Gs, Also display inherited Enhance the display of inherited “9 — components components (attributes, methods, yy interfaces, events). The superclasses of the heirs and not only the direct heirs are used here. The inherited components are highlighted in blue in the component display. ‘A\so display included interface Enhance the class display with the components interface components. Display public components only Restrict the display to include public ‘samponents only. Page 129 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies,AmeerpetHyderabad Ph No: +91 40 ~65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? Display constants Enhance the display or attributes to | inclade constants, The constants are marked in the attribute display with the type Constant. Scope Display instance components Restrict the class display to instance filter only ‘components. Display static components only Restrict the class display to static ‘components. Display all components ‘The entire class is displayed with this standard setting Display aliases If there are alias names (title element Aliases) for interface components, these are output in the method dispiay instead of the long name. ‘The components of the displayed class are sorted by superclass component and by interfaces included. You can show or hide the grouping by double-clicking on the name of the superclass or interface. Page 130 of 134 Compiled By: . S Requirements that could not Vabe foreseen when you were carrying out the design can result in significant changes to the existing)class hierarchy (enhancements to the design, creation of new ‘components in classes or interfaces)uifite Refactoring Assistant was integrated in the Class Builder to counteract such restructuring of thelgxisting class design, All the changes made with the Refactoring Assistant refer only to global classes and interfaces. Local object types are not supported. Note that the Refactoring Assistant does not make any adjustments to the user. Users of components might be invalidated by restructuring Ganapati Adimulam ‘eMax Technologies,Ameerpet,liyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You? Possible Movings: 1) Moving Components to the Superclass ‘You can move attributes, methods and events of a class to their direct superclass. Note that a confict occurs if non-private components that you want to move to,ttie superclass already exist in another class that is derived from this superclass. This results in a syntaxerrorin the corresponding derived class. Z Procedure 4. Open the Class in Change Mode. 2. Make sure you are in Change mode y 3. Choose Utilities > Refactoring Assistant. & ‘The Assistant is started in a separate window. e fF 4, Select the component to be moved anid move it to the tame atthe superclass using Drag & Drop. pg You can move several components at one time with multiple selection, 5. Save using the corresponding icon, 6. Close the Assistant, Result The moved components are deleted in their original cless and created in the superclass. Note : The Procedure to Move the things from One Place to Another is Always Same. 4) Open the Source (Class/interface/Method ...) In Change Mode. 2) Choose Utilities -» Refactoring Assistant. Then Assistant is started in a separate window. 3} Select the component to be moved from the Source and move it to the name of the Target using Drag & Drop. 4) Save using the corresponding icon, 5) Close the Assistant, Page 131 of 134 Compiled By: Ganapati Adimulam ‘eMax Technologies Amecrpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? Moving Components to Subclass(es) Use You can move attributes, methods and results of a class to one or more direct subclasses, Prerequisites The (private) components to be moved do not yet exist in the subclass \fyou did not move the components from the superclass to all direct subclasses, these components will be deleted from all the subclasses that were not affected Moving Components to the Interface Use If required, attributes, methods and events of all visibility sections of a class can be moved to an interface implemented by the class. However, the components might né: aa ‘8 visible after the move since interfaces only have PUBLIC components. Ue Note that 2 conflict could occur if a method that you move to an interface was already redefined in a subclass. In this case the subclass must redefine another method, namely the interface method, The ‘Assistant recognizes this situation and performs the necessary adjustments in the subclass for you. Create an alias name for each component that wes moved. This prevents the users of these components from being invalidated. Result The movéd class components are created in the interface. All PRIVATE and PROTECTED components are autffateal assigned f2°L.1C visibly. methods wih exstng implementation were moved, he implementation is retained), a to the Superclass Use Interfaces that are implemiented by a class can be moved to the direct superclass. The superclass becomes the implementing class. Page 132 of 134 Compiled By: Ganapati Adimulam eMax Technologies,Ameerpet,Hyderabad Ph No: +91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects We Never Compromise in Quality. Would You ? Note that a conflict can occur if another subclass of the superclass to which you are moving the interface also implements the interface. In this case this subclass would inherit the interface after the move and would implement it again. This situation is not allowed. Result ‘The superclass implements the interface that was moved, # Moving Interfaces to Subclass(es) Use Interfaces that are implemented by a clas can be moved 10 their subclasses. The! become the implementing classes. Nofé that a conflict could ocesr ifthe interface is not moved to all the subclasses. The interface componer ng from inheritance are deleted in the subclasses that do not implement the interface. Moving Interface Co Use PR... \ You can move atrbil, methods and Bens ‘of an interface to the implementing classes if required. eS e Note that moving interlace methods that are redefined in subclasses requires further adjustments to the subclasses The Asistaifproms these austen oyu Result oy” ‘The selected components of the interface are created in the implementing classes. Page 133 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies,Ameerpet, Hyderabad Ph No: +91 4065976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com ABAP Objects ‘We Never Compromise in Quality. Would You ? Splitting Classes Use By spliting classes you can move selected methods, attributes and events of a class to a new class. Splitting Interfaces Use 1. By splitting implemented interfaces you can move selected methods, attributes and events toa pew interface, Testing Event Handling when itis triggered, A simulation of the ABAP SET HANDLER silassigns handlers ta triggering events, ; Sat Procedure >. 1, {nthe Events branch of the object display, select an event, 2. Choose Handler, fo enable the handler The icon changes, to indicate that the handler is active. a: Events nx a fh SHpsta method inthe object display. Chobe Execute e Result’ If the method is called successfully, the chosen event is triggered and the result displayed, ‘9 switch off the handler for the chosen event, choose Utilities +> Event handling > Switch off handler. Page 134 of 134 Compiled By: Ganapati Adimulam ‘Max Technologies, Ameerpet,Hyderabad Ph No: +91 40 ~65976727, Cell No: 99484 44808, 98498 34399, www.emaxtech.com ENHANCEMENTS Duration-Sdays(2Hrs) _ e Introduction e Enhancement Types e Customer Exits > Locating Exits > Function Module Exit > Menu Exit > Screen Exit e BADIs > Introduction > BADI Views > Locating BADIs > Implementing BADIs = Function BADIs = Menu BADIs = Screen BADIs » Custom BADIs ¢ Definition e Calling Enhancements@eMAX We Never Compromise in Quality Would You? * The R/3 ENHANCEMENT concept allows us to add your own functionality to SAP's standard business applications without having to modify the original applications. ‘© SAP creates enhancements for specifie programs, screens, and menus within standard R/3 applications. These enhancements do not contain any functionality. Instead, the enhancements act as hooks where WE can HANG Our own add-on. functionality onto these hooks. Advantages with Ephancements: ——_ + They do not affect standard SAP source code DAY-1 ‘When you add new functionality to your SAP System using SAP's exits, you do not alter the source code of standard SAP programs in any way. The code and screens you create are encapsulated as separate objects. These customer objects are linked to standard applications, but exist separately from SAP's standard software package ‘+ They do not affect software updates When you add new functionality to your SAP System using SAP's enhancements, your objects (called customer objects) must adhere to strict naming conventions. When it comes time to upgrade a to a new software release, customer objects’ names ensure that they will not be affected by any changes or new additions to the standard software package. Note: Customer enhancements May not available for ah pragrams and screens found in the ‘SAP System. You can only use customer exits if they already exist in the SAP System Enhancement Approaches Procedural Object Oriented | | ’ Y Using Function Modules Using Classes & Methods Are Called Customer Exits Are Called BADIs Note : Infact In Procedural , We have Two Types . 1) Using Subroutines - User Exits (Out Dated) 2) Using Function Modules - Customer Exits Page I of 1 Compiled By Ganapati Adimulam ‘Max Technologies, AmeerpetHyderabad Ph No :+91 40 ~65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Customer Exits @eMAX We Never Compromise In Quality. Would You? Customer Exits DAY-1 Types of Exits Note : The Entire SAP Product Can be Divided Into 3 Parts. ee — Programs [——— | Tables Front End Programs Back End > Sereen and Menu Exits to enhance the Front End > Function Exits to Enhance the Programs > APPEND Structures/CI Includes to enhance BackEnd There are several different types of customer exits. Each of these exits acts as hooks where We can attach or “hang” Our own add-ons. © Menu Exits Menu exits add items to the pulldown menus in standard SAP applications. You can use these menu items to call up your own screens or to trigger entire add-on applications, SAP creates menu exits by defining special menu items in the Menu Painter. These special entries have function codes that begin with "+" (a plus sign). You specify the menu item's text when activating the item in an add-on project. © Screen Exits Screen exits add fields to screens in R/3 applications. SAP creates screen exits ay placing special subscreen areas on a standard RI3 screen and calling a customer subscreen from the standard screen's flow logic, ‘= Function Module Exits Function module exits add functionality to RIS applications, Function module exits play @ role in both menu and screen exits. When you add a new menu item to a standard pulldown menu, you use a function module exit to define the actions that should take place once your menu is activated, Function module exits also contro} the data flow between standard programs and screen exit fields. Page 1 of 47 Compiled By Ganapati Adimulam. ‘Max Technologies, Ameerpet,Hyderabad Ph No :+91 40 65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Customer Exit s@eMAX We Never Compromise In Quality. Would You? SAP application developers create function module exits by writing cals to customer functions into the source code of standard R/2 programs. These calls have the following syntax: CALL CUSTOMER-FUNCTION 001". Note : In the Older SAP Versions, We Have Field Exits but itis Outdated from 4.6 C Version From Release 4.5A, you can change field texts on screens and add data element documentation using the Modification Assistant, Locating Exits from Standard Applications: Note: We can take the Advantage Of the Exits Only When SAP Provides it in the Standard Transactions. SAP organizes its exits in packages/Development Classes are called SAP enhancements. Each SAP enhancement can contain many individual exits. Steps to Locate the Exits for Any Transaction : Note: We Have Different Ways for the Same But we go through the Commonly Used Procedure, 4) Find Out the Development Class / Package For Which the Enhancement Should be Located. Find Out the Program From the Transaction ie Open the Transaction in Display Mode through SE93. Maintain Transaction aS te | Page 2 of 47 Compiled By Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No :+91 40 65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Display Dialo. ‘Transaction cove Development class Transaction text Program Screen number Authortzation object @! _ ABAP Edito e Le \es|e& Ot SB a Customer Exits @eMAX We Never Compromise In Quality. Would You? transaction xpo1 FAD :| Double Click On the Create Custer sapmegzo| | Program to Open it. 160 = Z—— FkNAtape “THR Values Toxt elements , SAPMFO Variants | ale Dbject directory tr 1 Dbject directory entry aS Documentation Translation is Top-Include ausge Online manual 61.1998 M. Kienzle \ Back ial Zentraler Moduipoo) Debitoren Stammdaten ssibutes Type Nocue poot 2 Status Test pragrain anplestion Finacial accountea [Shserve the Development 2 utorztion groups ci Deveopmenntiass YS ala vere TERETE ata Page3 of 47 Compiled By Ganapati Adimalam eMax Technologies Ameerpet. Hyderabad Ph No :+91 4065976727, Cell No : 99484 44808,98490 34399, www.emaxteck.com Customer Exits @eMAX We Never Compromise In Quality. Would You? 2) Execute Transaction SMOD to Find out the Enhancement from the Already Identified Development Class /Package. “SAP Enhancemenis ob owe Enhancement i Object components ® Attributes F Components | © Documentation i Click On Info System (If Displayed). Enter the Name Of the Development ClassiPackage Of the Standard Program For Which the Enhancements should be Located. Page 4 of 47 Compiled By Ganapati Adimulam ‘@Max Technologies, AmeerpetsHyderabad Ph No :+91 40 -65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com @eMAX We Never Compromise 1n Quality, Would You? Exit name Development Class ‘Short text Of Customer Creation, Development class v sy Program(XD01), Press ENTER. en =e text : SEUEELNes : Enhancement Name [Emenee | Note : To Check the Individual Exits From the Enhancement, BACK to the Initial Screen, Enter the Enhancement Name, Select Component Options and Say Display. Page 5 of 47 Compiled By Ganapati Adimulam eMax Technologies, Ameerpet Hyderabad Ph No :+91 40 -65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Customer Exits @eMAX We Never Compromise In Quality: Would You? SAP Enhancements 8 | op Enhancement SAPMFO2D ‘Object components“ Attributes Componente eoe@ emerit Observe the Function Exit and it Triggers Before Saving the Data Into Database, No. Area Called screen No. ShortTt Note : If More than Exit is Available, We Need to Findout the right Exit by Checking the Interface Parameters(IMPORT,EXPORT..) and also the Place Of Triggering. Page 6 of 47 Compiled By Ganapati Adimulam eMax Technologies Ameerpet,Hyderabad Ph No #91 40 -65976727, Cell No : 99484 44808,98490 34399, www.cmaxtech.com Customer Exits @eMAX We Never Compromise In Quatity. Would You? 2nd Way to Locate the Customer Exits_is Writing a Custom Program : Note : No Need to Understand and Develop this Program , You Can Simpily Execute it for the Given Transaction Code - REPORT ZGDEMO_LOCATEENHANCEMENT . * Cinding the user-exits of a SAP transaction code ® Enter the transaction code in which you are looking for the user-* “exit and it will list you the list of user-exits in the transaction * codeston. * TABLES DECLARATION TABLES TSTC, "SAP Transaction Codes. TADIR, “Directory of Repository Objects. MODSAPT, "SAP Enhancements - Short’ Texts. MoDacT, "Modifications. TRDIR, "system table TROTR. TFDIR, "Function Module. ENLEDIR, "Additional Attributes for Function Modules TsTcT. “transaction Code Texts DECLARATIONS DATA : ITAG LIKE TABLE OF TADIR , WA LIKE TADIR. V_FIELD1(30) . VIDEVCLASS LIKE TADIR-DEVCLASS DATA : DATA INPUT SCREEN DECLARATIONS PARAMETERS : P_TCODE LIKE TSTC-TCODE OBLIGATORY. START-OF-SELECTION. #--Read SAP Transaction code from the given input. SELECT SINGLE * FROM TSTC WHERE TCODE EQ P_TCODE. IF SY-SUBRC_EQ 0. Get the Directory of Repository objects for the %---selected program name. SELECT SINGLE * FROM TADIR WHERE PGMID = 'R3TR' AND OBJECT = ‘PROG' AND O83_NAME = TSTC-PGMNA. MOVE : TADIR-DEVCLASS TO V_DEVCLASS. IF Sy-SUBRC NEO, #Read System table TROIR for the selected program name. SELECT SINGLE * FROM TRDIR WHERE NAME = TSTC-PGMNA. *Get the function module name for the selected program name Page 7 of 47 Compiled By Ganapati Adimulam. ‘eMax Technologies, Ameerpet,Hyderabad Ph No :+91 40 -65976727, Cell No : 99484 44808,98490 34399, www.cmaxtech.com Customer Exits @eMAX We Never Compromise in Quality. Woold You? IF TROIR-SUBC EQ 'F'. SELECT SINGLE * FROM TEDIR WHERE PNAME = TSTC-PGMNA. *Get the function group for the selected program name SELECT SINGLE * FROM_ENLFDIR WHERE FUNCNAME = TFOTR-FUNCNAME. *Read the development class for the corresponding function group. SELECT SINGLE * FROM TADIR WHERE PGMID = 'R3TR' AND OBJECT = *FuGR AND 0B3_NAME EQ ENLFDIR-AREA. MOVE _: TADIR-DEVCLASS TO V_DEVCLASS. ENDIF. ENDIF. *--Read all the entries into the internal table itab. eee FROM TADIR INTO TABLE XTAB WHERE PGMID = 'R3TR' AND OBJECT "smop" AND DEVCLASS = V_DEVCLASS. *--Read Transaction code information from the table tstct. SELECT SINGLE * FROM TSTCT WHERE SPRSL_EQ SY-LANGU AND TCODE EQ P_TCODE. *=- Colum Headings FORMAT COLOR COL_POSETIVE INTENSIFIED OFF. wriTe:/(19) ‘Transaction code ~*, 20(20) P_TCODE, 45(50) TSTCT-TTEXT. SKIP. IF NOT ITAB IS INITIAL. werre:/(95) SY-ULINE. FORMAT COLOR COL_HEADING INTENSIFIED ON. WRITE: /1 SY-VLINE, 2 ‘Exit Name", 21 SY-VLINE , 22 *vescription", 95 SY-VLINE. WRITE: /(95) “SY-ULINE. Loop AT ITAB INTO WA: <-Read SAP Enhancements short texts information, SELECT SINGLE * FROM MODSAPT WHERE SPRSL_= SY-LANGU AND NAME = WA-OB9_NAME. FORMAT COLOR COL_NORMAL INTENSIFIED OFF. WRITE: /1 SY-VLINE, 2 WA-OBJ_NAME HOTSPOT ON, 21 SY-VLINE , 22 MODSAPT-MODTEXT,, 95 SY-VLINE. ENDLOOP. WRITE:/(95)_SY-ULINE. DESCRIBE TABLE ITAB. SKIP. Page 8 of 47 Compiled By Ganapati Adimulam eMax Technologies, Ameerpet.Hyderabad Ph No +91 40 -65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Customer Exits @eMAX We Never Compromise In Quality. Would You? FORMAT COLOR COL_TOTAL INTENSIFIED ON. WRITE:/ 'No of Exits:' , SY-TFILL. ELSE. FORMAT COLOR COL_NEGATIVE INTENSTFIED ON. WRITE: /(95) ‘No User Exit exists’ ENDIF. ELSE. FORMAT COLOR COL_NEGATIVE INTENSIFIED ON. werTe:/(95) "Transaction Code Does Not Exist! ENDIF. "AT LINE-SELECTION EVENT AT LINE-SELECTION. GET CURSOR FIELD V_FIELDL. CHECK V_FIELD1(11) EQ, 'WA-OB)_NAME' SET PARAMETER TD "MON' FIELD SY-LISEL+1(10). *-- call transation MOD : Sap enhancement. CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN. Execute the Program and Enter the Transaction Code : Demo to eS Transaction Code koot 2 Demo to Locate the Enhancemer & Demo to Locate the Enhancement Transaction Code » X001 Create Customer (Centrally) Exits Neme _) Click On the Enhancement and it Opens SMOD. E isarMro20 No of Exits. 1 MOD Transaction is Opened and We Can Continue From Here. Page 9 of 47 Compiled By Ganapati Adimulam €Max Technologies Ameerpet,Hyderabad Ph No 1+91 4065976727, Cell No - 99484 44808.98490 34399, www.emaxtech.com Customer Exits @eMAX We Never Compromise In Quality. Would You? SAP Bohancenents fee ee fhe a —— — Ennancement SAPMrozD fe) e Attributes _ 3rd Way to Locate the Customer Exits 4) Open the Program in Display Mode | eas 3 Aue TopsEne lade susgeTagere Son ha98 Hi Kienzie = Zenitaior Moduipeoi Debstoren Stemmdatan “ £80." Heduie Zur Textverarbel tune IncLube maadeTe 2) Click On Find — Page 10 of 47 Compited By Ganapati Adimulam ‘Max Technologies,Amecrpet,Hyderabad Ph No :+91 40 -65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Customer Exits @eMAX Find CALL CUSTOMER As string BAS sword Case-sensilve [Replace wth In ensin program ‘In program 3 ‘© Only include my inactive versions Include all inactive versions 3) Press ENTER reazoeex 71 BEALL CUSTONER. FUNCTION “008 Esra ine Double Click On CALL CUSTOMER FUNCTION ‘001’. Page 11 of 47 Compiled By Ganapati Adimulam eMax Technologies Amecrpet Hyderabad Ph No :+91 40 -65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Customer Exits @eMAX We Never Compromise In Quality. Would You? Funetion Builder: Display EXIT_SAPMEO2D 004 = © 19 Sig: Ga Bg ~ g Thisisthe Function : - Module Exit. ——=} Soi Function module EXIT_SAPMFO20_031 _==—=——acve— Attibutes | Impat | Export | Changing , Tables , Exceptions ' Source code La FUNCTION EXIT_SAPHFO20_081 **"Lokale Sehnittstelle " IMPORTING = VALUE(I_KNA1) LIKE KNA1 STRUCTURE KNA1 B VALUE (I_KNE1) LIKE KNBi STRUCTURE KNB OPTIONAL el VALUE (TLKNU) LIKE KNYV. STRUCTURE KNVV OPTIONAL *s VALUE (I_ADDRHANDLE) LIKE ADDR1_SEL-ADDAHANDLE a OPTIONAL oa TABLES " T_KNAS STRUCTURE KMS CPTIONAL » TIKNAT STRUCTURE KNAT OPTIONAL ” TIKNBS STRUCTURE KNBS OPTIONAL * TLRNBK STRUCTURE KNBK OPTIONAL . KNBW STRUCTURE KNW OPTIONAL I TIKNEX ST KNEX OPTIONAL ™ TIKNVA STRUCTURE KNVA OPTIONAL . TIKNVD STRUCTURE KNYD OPTIONAL ” TIKNVE STRUCTURE. KIWI L TOKHWK STRUCTURE KN “ TCRNWL STRUCTURE KNVL OPTIONAL Implementing the Enhancements: To take advantage of the exits available in standard R/3 applications, We need to create an add-on project. This project organizes the enhancement packages and exits we want to use. The add-on project also allows you to hang add-on functionality onto the exit hooks contained with SAP enhancements. > We can include an SAP enhancement and the customer exits it contains in one project only. The same SAP enhancement Cannot be Included in more than One Project. v in order to make your add-ons, such as menu items or screen fields, appear in standard RI3 applications, you must activate your add-on project. When you activate a project, al of the add-ons created within this project are activated as well. For this reason, you should ensure that the exits you include in your project contain functions that can be activated simultaneously. It is not possible to activate exits individually. Page 2 of 47 Compiled By Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No +91 40 ~-65976727, Celi No : 99484 44808,98490 34399, www.emaxtech.com Customer Exits @eMAX We Never Function module exits allow you to implement our own functions and processing logic in standard SAP programs. To take advantage of a function module exit, We first need to create a project as described in the section Creating an Add-on Project. Then, We must include the SAP enhancement that contains the function module exit We want to use in your project, Requirement : While Creating/Changing the Customer, Display the Pop up Message, to save the Customer (AccountNo,Name,City,Country) Into a File and the File Name Should be Created with Combination Of the Customer No,Date,Time. Steps to Work with Function Exits A) Create the Project and Link the Enhancement. 1. Execute CMOD Transaction and Enter the Project Neme and Choose Create. Project kemax ” [3 (9 ‘Greate —"} Beate Subobjeci= Attributes | Enhancement sesignment Describe the nature of the project by providing a short descriptive text. Page 13 of 47 Compiled By Ganapati Adimulam ‘eMax Technologies, Ameerpet,Hyderabad Ph No :+9! 40 -65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Customer Exits @eMAX We Never Compromise In Quality. Would You? its_Components Project ZEWAX Snort tex Project For Al the eMAX Enhancements sp | Original ienguage EN | Created by SAPUSER 7.418.207 \ Last changed oniby Changed i Choose Save. 2. Specify which SAP enhancement packages you want to include in your project by choosing SAP enhancements. 3. Enter the names of these SAP enhancements in the spaces provided. Note : You should choose enhancement packages that logically belong together. For example, if you are planning to use several enhancements that deal with Materials Management modules, you can include all of these enhancements in the same praject. If you are working on enhancements that deal with different applications, or if the enhancements are not logically related, you should include these enhancements in separate projects, SAP Enhancements in Enhancement Project ZEMAX |B | BBB Enrancemon Components Enfancement Short pt SAPHEG20 User exfts: Customer master data (Once you have identified the SAP enhancements you want to include in your project, you can begin adding your own functions to the exits offered in the enhancements. Page 14 of 7 Compiled By Ganapati Adimulam ‘eMax Technologies AmeerpetsHyderabad Ph No :+91 40 ~65976727, Cell No : 99484 44808,98490 34399, www.emaxtect Customer Exits @eMAX We Never Compromise In Quality. Would You? roject ZEMAX Which Is Already Idemified From. the Customer Creation Transaction Enniancement shor pa | XDOD. a = SAP Enhancements in Enbanceme Enhancement [6a Samnro2n(@) User ewts: Customer master data To display the individual components of the SAP enhancements, Place the Cursor On the required Enhancement and Choose Components The system displays all of the exits included in the enhancement Dispiay ZEMAX @ | BB Ennancemon sasignments (EF Enhancoment Ml |= [zemax pr Project For All the eM Enhancement impr las [exp [SAeHea20 User exits: Cuetanir mi Function exit |v EXIT_SAPMFG2D_001 | Note : Once the Project and Enhancement is Linked , We Can Implement the Customer Functionality either through SMOD or CMOD Transactions By Double Click On the) Correct Exit and Continue.. B) Implementaion Steps For the Function Module Exit. Let Us Continue With CMOD Only i.e From the Previous Step. play ZEMAX Enhancement assignments EB Enhancemen = ZENAX Project For AN) the a Function exit |extT_saPtFo20_901 Double-click on the Function Module Exit. Page 15 of 47 Compiled By Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No :+91 40 -65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Customer Exits @eMAX We Never Compromise In Quality. Would You? a L_) (ea VALUE STSRRSSA REESE, EERE SE +) Is the Place Where We Can = ADD Our Own Functionality. a ee The system asks you if you want to create the include program. Confirm that you want to create the include program. Say YES. Note : We can fill this nodule with functions We want by calling the include program (called ZXnnnUO1) contained within the module and inserting Our own source code into it Enter your function’s source code in the editor. INCLUDE ZXFO4U01 *"Lokale schnittstel le: KNAL STRUCTURE KNAL KNB1 STRUCTURE KNB1 OPTIONAL KNVV STRUCTURE KNW OPTIONAL LIKE ADDR1_SEL-ADDRWANDLE en IMPORTING oa VALUECT_ANAL LIKE “ VALUECT-KNGL) LIKE * VALUE (I_KNW) LIKE VALUE (I_ADDRHANDLE) OPTIONAL TABLES. TLKNAS STRUCTURE KNAS TLKNAT STRUCTURE KNAT TOKNBS STRUCTURE KNBS TLKNBK STRUCTURE KNBK TANBW STRUCTURE KNBW STRUCTURE KNEX STRUCTURE KNVA STRUCTURE KNVD on STRUCTURE KNVI ww STRUCTURE KKVK a STRUCTURE KNVL am STRUCTURE KNVP a STRUCTURE DATA V_ANSWER(L) TYPE C. DATA V_FILE ‘TYPE STRING. DATA : BEGIN OF WA_KNAL, KUNNR TYPE KUNNR, Page 16 of 47 KNZA OPTIONAL OPTIONAL OPTIONAL OPTIONAL OPTIONAL, OPTIONAL, OPTIONAL OPTIONAL OPTIONAL OPTIONAL OPTIONAL OPTIONAL OPTIONAL Compiled By Ganapati Adimulam €Max Technologies, Amecrpet,Ayderabad Ph No :+91 40 -65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Customer Exits @eMAX We Never Compromise in Quality. Would You? NAME] TYPE NAME1, KTOKD TYPE KTOKD, ORTO1 TYPE ORTOL, LAND] TYPE LAND1, END OF WALKNAL. DATA IT_KNAL LIKE TABLE OF WA_KNAL * prepare the File Name with Customer ,Date and Time Combination CONCATENATE "C:\CUSTOMERS\" I_KNAI-KUNNR SY-DATUM SY-UZEIT ". TXT" INTO VFILE CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING ; TETLEBAR "save Data as File’ * DIAGNOSE_oB JECT TEXT_QUESTION TEXT_BUTTON_1 "po You want Save Data As File ?' ryes" TEXT_BUTTON_2 = "No" IMPORTING ANSWER = vanswer IF V_ANSWER = '1'. "YES MOVE : I_KNAL-KUNNR TO WA_KNAL-KUNNR, JOKNAL-NAMEL TO WALKNAL-NAME1, T_KNAL-KTOKD TO WA_KNAL-KTOKD, TLKNAL-ORTO1 TO WACKNA1-ORTOL, ICKNAI-LAND1 TO WA_KNA1~landi. APPEND WA_KNAL TO ET_KNAL. CALL FUNCTION 'GUT_DoWNLOAD’ EXPORTING * BIN_FILEST| = Frvenawe | PlacetheBreak =| = y rue * IMPORTING Point & Make Sure = FILELENGTH| a = TABLES that You Enter into DATA TAB | this INCLUDE = TTKNAL IF Sy-supre = 2 — Message SQ0L(ZGDEMO_CLASSES) WITH V_FILE. ENDIF. = a jc is Successfully Downloded ENDIF. Save, Gheck and Activate the include program. BACK and Activate the Function Module Exit(Enhancement). Page 17 of 47 Compiled By Ganapati Adimulam ‘eMax Technologies,AmeerpetHyderabad Ph No :+91 40 -65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Customer Exits @e¢MAX We Never Compromise In Quality. Would You? Change ZEMAX 2 | EE | SoD cohancement assignments “activate (Cr+ Enhancernent Project ZEWAX Project For A11 ‘the eMAX Enhancement Enhancement |tmpt Exp |SAPMFOZD User exits’ Customer master data BACK to the Initial Screen Of Project. Project i | (cuse3)] T Tartivate proj Prowect weniax [oC [Subadjecte k : ‘@ Attributes: k Enhancement agsignment EB Porn B ter © Sno very e Cony dota aaa Trancter to Cemang Managsinnt Notice that Menu ‘Mieroron Excel Options Are Added weet «| Bn St atest group Se Sno pany : reas Table versen Custorestneton 3 axial ot (Bees: ee Customer function 5 [feats ay Customer tinton © Customer function 7 Customer function 3 Customer function 9 k On Menu Option Create Program and Notice that ABAP Editor Screen is Called. ABAP Editor: tnitial Screen Gat © oH te P| BT BH | © debugging Execute with variant Variants |< Variants | Oanributes © Documentation Text eloments et f Compiled By Ganapati Adimulam, ‘Max Technologies. Ameerpet,Ayderabad Ph No :+91 40 65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Page 28 of 47 Customer Exits @eMAX We Never Compromise In Quality. Would You? larly Continue with Create Table Option. tn coveteie tren sersien Aa Active version Notice that Table Creation Screen is Opened. ABAP Dictionary: Initial Scr “ Congratulations ! Both the Menu Options Create Program and Create |-— ‘Table are Working. oe Note : In Real time , Instead Of SPMq ace Calling SE38 and SE11 , We Develop beak the Custom Programs/Transaction and “Santen te Link the Same. Page 29 of 47 Compiled By Ganapati Adimulam ‘eMax Technologies,Ameerpet,fyderabad Ph No :+91 40 -65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Customer Exits @eMAX We Never Compromise In Quality, Would You? Working With Screen Exits Introduction SAP provides standard transactions to enter data into database. But a client may want to maintain some additional information in SAP other than what is provided. To make provisions for this, additional screens have to be provided and additional fields must be added into appropriate database table. This Can be Done through SCREEN Exits | Screen exits allow you to add your own fields to specified screens in standard R’3 transactions. Note : SAP Provides the locations (Screen Exits) by Leaving SubScreen Areas in Standard Screens and Which Can Include the SubScreens with the required custom Fields into the SubScreen Areas. Note : The global data defined in the standard SAP program is not known to the program that controls your customer subscreen. In the same way, the fields you use in your subscreen are not known to the SAP program in which they appear. To compensate for this problem, SAP creates special flow logic modules when defining screen exits. Note : So that SAP creates a special Process Before Output module (PBO module) with a function module exit. You can use this function module exit to transfer specific field values from the SAP program to your customer subscreen. SAP also includes a Process After Input (PAI) module that has a function module exit for transferring values back from your subscreen to the SAP program, Note : The import and export parameters for the PBO and PAI function module exits are predefined by SAP. As a result, you can only transfer values to and from your subscreen if they correspond to the parameters determined in the existing function module exit interface. Note :So that Each Screen Exit Should have two more Function Module Exits i.e To transfer the Data Between Standard Program and Custom Module Pool Program with SubScreen Page 30 of 47 Compiled By Ganapati Adimutam eMax Technologies,Ameerpet,Hyderabad Ph No :+91 40 -65976727, Cell Ne 9484 44808,98490 34399, www.emaxtech.com Customer Exits @eMAX We Never Compromise In Qual Steps to Work With SCREEN EXITs : Requirement : Adding Customer Fields ie Priority and Duration of the Project Definition to transaction CJ01 through Enhancement CNEX0006. Note : Most the Implementation Tips are available from the Documentation Of the Enhancement. ‘So Execute SMOD and Provide Enhancement Name, Select Documentation Option and Click On Display. eon p> Eshancsinan — Eweiéads [@) (B.~ivme J) aes Bipiay 2 Siam Documentation : The data of the project definitions are saved in datsbase tables that have been defined by SAP. You can use this enhancement to make your om customer specitic enhancements to the project definition tabte (table PROJ) You can activate our onn function for processing WAS with which you Con call up a customer "apacific screen’ Here you ean display or edit the new fields thet you Nave included in the PROJS table The CNEXGNG6 enhancement has the following components Menu options: SAPLCUGR + Pao —_(v6a. oer 31 OO OnO 5 [mmunetms |e OO reo down 60 Ow ew Oa 0 5 jweneesion [SO 0 (Trav [ZrLePATH aR 4 O OO OAS |e ¢ Fea [erusMe ow) OM OK Oa OF [aah % Fea) | aPUETEXTE (dow 65 CL ror own [O_O O15 Oa) OF owen ROL (own 3 2 3 0 Gouna] 0 Ow Os Oa OF [Gaal 60 ows Oat eect owe NO O10 @I5 O20 2 [Seed sceme 2 2 Enter the Table Name as PROJ and Select the Customer Fields ZZPRIORITY and ZZDURATION. Page 38 of 47 Compiled By Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No :+91 40 -65976727, Cell No : 99484 44808,98490 34399, www Customer Exits @eMAX We Never Compromise In Quality. Would You? Activate the Screen. Click On BACK , Which takes to the exits List. Change ZGALL 2 Qa cm Preset fo | [reat reject for ANT the Gustan Dano Eoancenante [esancarent [inet] @ [Eun [eNex000e PS custanar specific fields project definition Function act fo lex sLone_ ore 7 [ETT saPLeae 003 Newent |e sapicace son ssp ten Sermon ent | spec 205 uSTSCR SAPLECIN 0 Iv ssp ‘216 eusrsom SePUxOM 2500 Note : Once the Sub Screen is Created , WE need to Transfer the Between Program > Sub Screen through the Function Module Exits JEXIT_SAPLCJWB_002 —_» [For PRO EXIT_SAPLCJWB_03 Function exit |¥ oe For PAT Double Click On EXIT_SAPLCJWB_002 to do anything Before Display the SubScreen. [Aidt natie |< cait san ca oa the oe (GF Abites: j Impot |’ Expat [Changing | Tables | Exceptions | Source code eA ea Cis! | FUNCTION ExET_SAPLCWE_002 1 *'Lokale Schnittetelle we IMPORTING WALUE(SAP_PROL_IMP) LIKE PROJ STRUCTURE PRO! VALUE (CNCT_PaOJ_INP) LIKE CHCT_PROJ STRUCTURE. CNCTPAD YVALUE(SAP_OTSPLAY ONLY) LIKE ROWBS.SELOt Double Click On the Custom INCLUDE to Create it, INCLUDE ZxcHtUIt ENDFUNCTTON Page 39 of 47 Compiled By Ganapati Adimulam ‘eMax Technologies,Ameerpet,fyderabad Ph No :+91 40 65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Customer Exits @eMAX We Never Compromise In Quality. Would You? Notice that the INCLUDE Program is Already Created i.e Implemented By SAP. se ABAP Ear: Display Incline ZRCNTUTS Se iv gia aeiag me canis) tale ‘Notice that INCLUDE Program is Already Created by SAP With This Source Code. Without Changing the SAPs Code , We Need Add Our Own Data ‘Transfer Processing Logie. - che Notice that the INCLUDE Program is in Display Mode to make sure that The SAP's Code is Cannot be Changed. Click On to Switch to Change Mode. eo [PSR BSA BB) © Petem |S of sen ch Replace cf Delete ah Canc Compiled By Ganapati Adimulam ies, Ameerpet,Hyderabad Ph No :+91 40 -65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Customer Exits @eMAX We Never Compromise In Quality. Would You? observe that, the INCLUDE is In Change Mode and SAP's Source Code is In Display Mode To ADD Our Own Processing Logic, Place the Cursor at Which we need to Add of Insert Code and Click On Which Includes * We Can ADD Our Own Source Code. *To Transfer any Default Values to the SubScreen F111 the Customer Fields into SAP_PROJ_IMP. MOVE-CORRESPONDING SAP_PROJ_IMP TO PROJ. Note : SAP_PROJ_IMP is Declared as Global Work Area PROJ Should be Declared as a Work Area through the SubScreen Fields Are Added. Note : PRO] Should be Declared as a Global Variable Using TABLES . So Double Click On PROJ, Global field PROJ does not ewst Ba you want to create tne object? Yer y Continue With YES. Field symbol U table STABLES Satemenl | i | | Name of data object PROJ | | | | Constant | Unspecified ivinclude / program ZXCNITOP ad Continue With TABLES Statement. — Page 41 of 47 Compiled By Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No 491 40 -65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Customer Exits @eMAX We Never Compromise In Qual "Would You? Notice that, TABLI —— 1 PROJ > |) Js ADDed in the Global INCLUDE seciuce | ZXCNITOP. TABLES PROJ == a SAVE i Back and SAVE it Click On BACK Twice to reach exits List DLA) | HB GS [Enhancement assignments Bl Enhancement [activate _(CrieShit 4 me) |= zeau. project for All the Gustam Damo Enhancemante "| Enhancement |mpi|@ [exe [CNEKGgGE PS customer enecifte Fields project datinitian Function exit |v exrT_GAPLOMB_602 ’ EXIT_SAPLEM8_008 Menu exit v SAPLCCR +cuo 4 We 0 Screen exit |v SAPLOWE 205 cusTscR: saPLxcH | 2 ISTSCRI SRPLXCHA SAPLOWE 1216 Activate it. Note : We Need to Repeat the Same for the PAI Function Exit EXIT_SAPLC.WE_093 to Transfer Data from Subscreen to Program where the Actual Database Updation takes Place. Double Click On EXIT_SAPLCJWB_003. Page 42 of 47 Compiled By Ganapati Adimulam Max Technologies Amecrpet,Hyderabad Ph No :+91 40 -65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Customer Exits @eMAX We Never Compromise In Quality. Would You? Function module EXTT_SAPLCJWB_G63 ‘Active Attributes |, Import , Export CeO Oo oe FUNCTION EXIT_SAPLCJWE_003 Changing | Tables | Exceptions Source code *"*"Lokale Schnittstel le. #* EXPORTING vs "VALUE (CNCI_PROJ_EXP) LIKE CNCI_PROJ STRUCTURE cNCT_PROJ ** VALUE (FL@_CLR_OK_CODE_EXP) TYPE C INCLUOE ZxCNAUt2 ENDFUNCTION, e: (9% @|% SBe|h8 zxcwiuta ‘Actve(revsed) zxcntta aa ® Pattem |B cf incest | ef Replace | Notice the INCLUDE is Already Created BY SAP and is in Display Mode. Le So Click On and to Add the Source Code Click On EF Insert Page 43 of 47 Compiled By Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No :+91 40 -65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Customer Exits @eMAX ‘We Never Compromise In Quality. Would You? ZxoNAUI2 Det Ce ‘Yeansfer the Data From Sub Screen Fields to Global Variables. MOVE-CORRESPONDING PROJ TO CNCI_PROU_EXP. MOVE-CORRESPONDING PROJ TO CNCI_PROJ_EXP.which Transfers the Data From ‘SubScreen Fields to Giobal Veraibles through Which the Database Tables Are Updated. SAVE. Click On BACK Twice and Activate it. | +0 | BW Enhancement assignments El Eaancerent Project a ZGALL. Project for AIL the Custom Deno’ Erhennetients' [Enhatcenent —|npt|@ Eo [ONexa008 ps custdner spaeitic Fidlds project definition Function exit |v \~ { EXIT_SAPLGJNB_003 Men exit lw sapucuse oun y SAPLCINE cu Screen exit |v ‘saPLowna 620s cusTscRt SAPLxCNt ? SAPLCME 1246 CUSTSCRA SAPLXCHT Page 44 of 47 Compiled By Ganapati Adimulam eMax Technologies, Ameerpet,Hyderabs Ph No :+91 40 65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com Customer Exits @e¢MAX ‘We Never Compromise In Quality, Would You? BACK to the Initial Screen of Project Management (CMOD) and Activate the Project. Project Managemer ‘Hob civate pect (CineFS) Project osu Subobjects @ Attro © Enhancement assignment Components i Documentation | Testing the Screen Exit: We Need to Execute the Corresponding Standard Transaction(CJ01) to make sure that the Sub Screen is Added to the Standard Transaction and Also Make Sure that the Data from the Sub Screen is Inserted into the Corresponding Table(PROJ). Execute the Transaction CJ01 and Provide Project Definition and Project Profile and Press ENTER. Create Project: Initial § creen B Proj definition fi) Open number Project vet P0020 tprojectiprotie — Cost projects a a Template” Project det | Std pro). det. i Page 45 of 47 Compiled By Ganapati Adimulam ‘eMax Technologies, Ameerpet,yderabad Ph No :491 40 -65976727, Celt No : 99484 44808,98490 34399, werw.cmaxtech.com Customer Exits @eMAX We Never Compromise In Quality. Would You? Details > Project Definition Customer Fields to Check the Custom SubScreen. Settlement rule Project defition customer flds B ia LZ Structure Settlement rule ralect det P-003 | @ sel bad Longest ro | @ Basic data {Control data. {~ Adnmstranor | —eumgrxr———————~* yster status CRTD User status [SBD stuctuw Sotoment ale : Priority ofthe Proj HIGH Duration in Months 47] SAVE. Page 46 of 47 Compiled By Ganapati Adimulam eMax Technologies, Ameerpet,Fiyderabad Ph No :+91 40 -65976727, Cell No : 99484 44808,98490 34399, woww.emaxtech.com Customer Exits @eMAX We Never Compromise In Quality. Would You? Create Project: Initial B_ Proj definition G2 Op Project der. p-ao20 eB Projectaronie Cast arojects B Terapiate Project det, | sta pro). cer | Clwitn wes documents Observe that P-0020 is Created Successfully. A woo Fa / Observe that the Values For Priority and Duration are Inserted for P-0020. T ZzpREORITY |Z20URATION Congratulations, the Screen Exit is Working. Page 47 of 47 Compiled By Ganapati Adimulam. ‘eMax Technologies, Ameerpet,Hyderabad Ph No :+91 40 65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com BADIs@eMAX ‘We Never Compromise in Quality. Would You ? Business Add-Ins DAY-3 SAP has introduced new enhancement technique Business Add-ins from release 4 6A Business Add-in is the new enhancement technique based on ABAP Objects. BADI is an exit point in a source that allows specific industry sectors, partners, and customers to attach additional sofware to standard SAP source code with out modifying the eriginal object. The users of Business Add-ins can customize the logic according to requirement or they can use the standard logic one available. SAP guarantees the upward compatiblity of all Business Add-in interfaces. Release upgrades do not affect enhancement calls fom within the standard software nor do they affect the validity of call interfaces. ‘Two different views Of BAD! are available: ‘+ In the definition view, an application programmer predefines exit points in a source that allow specific industry sectors, partners, and customers to attach additional Functionality to standard SAP source code without having to modify the original object. Note : Generally BADI are Defined by SAP in tho Standard Applications (Programs,Screens,Menus ...) and Implemented by the Customers. ‘+ In the implementation view, the users of Business Add-Ins can Enhance (customize) the logic they need or use a standard logic if one is available. Differences Between Customer Exits and BADI: | Customer Exit BADI Procedural Approach to work with | ‘Object Oriented Approach to Work with Enhancements, Enhancements. is a two-level infrasi~uclure (SAP and customer | Allow for a mul-level system landscape (SAP, solutions}. partner, and customer solutions, as well as country versions, industry solutions, and the tke), | Note : Business Add-Ins can be created at each level within such a system infrastructure. ‘tan only be implemented once and In addition, Business Add-Ins can be enhancements that can be used actively by | defined according to filter values. This ay aes allows you to control add-in | implementation and make it dependent on specific criteria (on a specific Country value, for example) Page 1 of 60 compiled By Ganapati Adimulam ‘eMax Technologies, AmeerpetHyderabad Ph No +91 40 65976727, Cell No : 99484 44808,98490 34399, www. BADIs@eMAX We Never Compromise in Quality: Would You ? Basic skills required to Work With BADIs © Work Experience/Knowledge on ABAP Objects (Object orientation of ABAP) is mandatory. ‘+ Although the implementation concept is based on classes, methods and inheritance you do not really have to understand this fully to implement a BADI. Simply think of methods as a function module with the same import and export parameters and follow the simple instructions below. + Experience on SAP enhancement technique. Business Add-Ins: Architecture In order to enhance a program, @ Business Add-In must first be defined. Application developers create an interface for the add-in, Enhancement management takes this interface and generates an adapter class for implementing it, thus opening a path for implementations created by partners or customers. Your developer then creates an instance of the adapter class in the application program and calls the corresponding method at the appropriate time. Note : Each Business Add-in will have one interface and an adapter class - ‘+ One Interface with list Of Methods and with NO Implementations. = One Adapter class will be predefined by SAP. The generated class (Adapter class) has the following tasks. i. Control, the adapter class calls the active implementations. li, Filtering, If the Add-in has to be executed under certain conditions, then the adapter class ensures that only certain implementations will be executed, Note : BAdIs are contained in the system and are fully operational as of Release 4.68. SAP creates Add-ins for specific programs, menus, and screen enhancements for standard R/3 applications. This Add-ins doesn’t contain any functionality. Instead you can add-on functionality onto these hooks by implementing the BADIs. Implementing Business Add-Ins Note: Implementation Of BADI requires to find out the right BADI if More than One BADI Exists for the Standard Application. Procedures to Find Out the BADIs Procedure 1: Most Of the times , the List of BADIs for a particular Application Component are available Through SAP Reference Implementation guide (IMG) or in component hierarchy I.e through Transaction SPRO. Ex : Find Out the BADI for Customer Creation (xD01) Execute SPRO. Page 2 of 60 compiled By Ganapati Adimulam ‘Max Technologies Ameerpet Hyderabad Ph No :+91 40 -65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com BADIs@eMAX We Never Compromise in Qu: 1) Execute Transaetien SPRO. eee eoute Project @| a an oe ‘Customizing: {3 Bh mottomaton | Proictaahate 2D Rentecte 2 2B eee Tome a PADEERERTT hence Customer astra ana ete Fn EE ce Stace Sree soit Page 3 of 60 compiled By Ganapati Adimulam Max Technologies,Ameerpet Hyderabad Ph No :+91 40 -65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com BADIs@eMAX We Never Compromise in Quality. Would You ? Logistics ~General > Business Partner > Customers > Control -> Adoption Of Customer's Own Master Data Fields.( We Can See the Steps for the Sereen Implementation) customers = Be Cone! a ‘anaae Custer Matar Fle and Cee iid Usage & Deine scout Groups anes Selena estos | S ctr Depardet cen Lipo | & bane ans Asin Cusomernaumber Ranges 3 @ change escape Conol fr Customer Mester Data i © Develop Emancarent for Cuter Mtr Dat © date ndusties 3 @ chore sesten is for Dabo betne custamernancoses & dete an Assign Fat Auhavzaton Geo © detne ites [3 © Deine Conon ups _Satings or Cantal dass Manager Bs G busirass Adein: Processing of Master Oata Enhancements B® Business Aden: Processing of Waster Data Enhancements with Batch nt ‘ PURURESEEEROR Note: 1,2 and 3 are the BADI Definitions For Customer Master . Page 4 of 60 compiled By Ganapati Adimulam ‘eMax Technologies,Ameerpet,Hyderabad Ph No :#91 40 ~65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com BADIs@cMAX We Never Compromise in Qu: Would You ? Procedure 2 Find Out the Package Of the Standard Transaction (Application) ie VS. Open that Package in SE80 (Object Navigator), we Can see the List of Enhancements. 2 ‘oce ane sy ‘| List Of BADI Definitions: . > Cj Business adtins (Def) | DUBTOVER ADDRSCR _( CUSTOMER 400_DATA CUSTOMER_ADD_DATA BI CUSTOMER _ADD_DATA, Page 5 of 60 compiled By Ganapati Adimulam ‘eMax Technotogies,Ameerpet,Hyderabad Ph No :+91 40 65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com BADIs@eMAX ‘We Never Compro: in Quatity. Would You? Note : We Can Also Open the BADI Definition through SE18. Note : To Understand More about the BADI Definition, Check Out the Documentation Of BADI. i.e Goto > Documentation ->Display eto he asta et car eB HAL SHIA eh) THO. AD DES to Fee rs teatime thlansation oF sa Mtoe gig ee (aS ‘sre Je hs ttt int tng ne nt topic g 2 . “ARM ORB once s : ‘ne exits pet oy I 15 ani ‘ ‘lew! ooo eae gain ae Sea Page 6 of 60 compiled By Ganapati Adimulam eMax Technologies, Ameerpet Hyderabad Ph No :+91 40 -65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com BADIs@eMAX We Never Compromise in Quality. Would You? Procedure 3: 1) Execute the Transaction SE93 and Enter the transaction XD01 and Click On Display Maintain Transaction Son WH) FO Transaction Code xd81] & [ge Display] (A _Change ‘Transaction code xpo1 Package Feo Double Click On the Program to Open It. — | Transaction text Create Custer SAPHFa2D Program | screen number 198 Authorization abject Fawat_aee fff] Values | 7] Maintenance of sta i dard transaction variant allowed I zl SGe@' 50008 ABAP Editor: Display Mod. pool SAPMFO2D Si | OE | 6B | | @ Poston | GLE 1) ae Page 7 of 60 compiled By Ganapa ‘Max Technotogies,Ameerpet,Hyderabad Ph No :+91 40 65976727, Cell No : 99484 44808,98490 34399, www.emaxt BADIs@eMAX We Never Compromise in Quality. Would You? click on Fina AS Sting GET_INSTANCE As aword Select the Gption Main Program and Search For CL_EXITHANDLER=>GET_INSTANCE ase-soneitive []Reptace witn @ In main progratn In program ® Onty include my inactive versions t | Cinetude al inactive versions \ vx and Press ENTER — The Value Of INSTANCE in the Glohat Search in Programs CALL METHOD 1s the Name OF ' ae the BADI Definition. © 2%) 8 |S SE BB ecandea Value ora Variable IF Variable , Double Click on it = Prosran to Find Out the Decleration, (CEmF02D_ADD_ON_FBB 14 CALL METHOD CL_EX1THANDLER: aN aN ING INSTANCE = 6 s001TH5GA_oxTA 67 CALL METHOO CL_ENITHANDLERSSeET-INGTANCE cians INSTANCE = 6 ADDITIONAL, o4T4 65 04 GALL meTAan bu ExiTWAWOLER=DGETOINST clause INGTANGE = 6 AODRESS_soRECK_ CHG Hore G_ADDITIONAL_DATA is the Variable and Double Click On ito Find Out it's Decleration. DATA: G_ADDITIONAL_DATA TYPE REF TO IF_EXCUSTOMER_ADD_DATA. Here the BADI Definition is CUSTOMER_ADD_DATA ie We Get the BADI Definition Name 8y Ignoring IF_EX__ From the Corresponding Referenced Interface i.e IF_EX_CUSTOMER_ADD_DATA and Which is the Generic Procedure. Page 8 of 60 compiled By Ganapati Adimulam Max Technologies, AmeerpetHyderabad Ph No :#91 40 65976727, Cell No : 99484 44808,98490 34399, www.emaxtech.com BADIs@eMAX We Never Compromise in Quality. Would You ? Steps to Implement the BADI: Requiremen' Transaction | Xoo J BADI Definition _ CUSTOMER ADD_DATA a Method to be Implemented ‘CHECK ALL DATA. | Funtionality to be Implemented Is to Download the Customer Data into File Before the Customer Is Created(Saved). Note : Here the File Name is Generated Dynamically. Le C:\CUSTOMERSI\

You might also like