Thursday, 13 March 2014

SAP ABAP Certification Questions - 1

ABAP Certification Questions - 1



1. Which statements are allowed if you are working with an internal table of the 
     type SORTED? (T/F) 
      F- SORT 
      F- APPEND 
      F- MODIFY 
      T- COLLECT 
      T- READ

2. Which of the following ABAP statements create a list for executable programs? 
    (T/F) 
      T- SKIP  
      T- WRITE 
      F- PERFORM 
      F- CLEAR  
      T- ULINE 
  
3. Which of the following statements are correct? (T/F) 
     T - You can select from several database tables using a database view or a join. 
     T - A secondary index for non-key fields generally works like a primary index for 
           key fields. 
     T - A key field in a database table uniquely identifies a data record.
     F - The client field is a selective field and should therefore always be specified in 
           the WHERE condition for SELECT.  
     T - The OPEN SQL statements are converted into database-specific statements by 
           the database interface.

4. What do you get when you refer to a client-specific transparent table in the 
     Dictionary if you have a data definition with TABLES? (Single selection)   
     T - A structured work area (line).  
     F - A field. 
     F - An internal table.

5. In program P, the SUBMIT statement is used to call report R. How can you pass 
    data from P to R? (T/F)  
     T - Using the SET/GET parameters.  
     T - By passing parameters using additions in the SUBMIT statement. 
     T - Using the ABAP memory. 
     F - By declaring the data objects with the same name in both programs, using the 
          DATA statement. 
  
6. Which of the following statements about the SELECT statement are correct? 
    (T/F) 
     T - With SELECT SINGLE access, the result is one data record maximum. 
     T - The SELECT statement supports the return code (SY-SUBRC). 
     F - With SELECT...ENDSELECT access. the result is one data record maximum. 
     F - The SELECT statement always reads the data into the SAP memory first. 
     F - With SELECT...INTO TABLE access, the result is one data record maximum. 
  
7. Which of the following statements about data types, data objects, and field 
     symbols are correct? (T/F) 
     T - If you change the value of a field symbol, the value of the data object to which 
           the field symbol is assigned also changed. 
     F - A field symbol always reference a data element. 
     F - You can no longer create data objects at runtime(dynamically) since the ABAP 
           runtime system combines all the declarative statements in on processing block 
           and executes these first.  
     T - A field symbols only references a data object after the latter has been assigned 
           to the field symbols using the ASSIGN statement. 
     T - You can change the type of the assigned data object using the CASTING-TYPE 
           addition for the ASSIGN statement. 
  
8. Which of the following statements about internal tables is correct? (T/F) 
      F - Key access to an internal table of the type STANDARD generally has even less 
            runtime consumption than index access. 
      F - Index access to an internal table of type SORTED will, in certain cases, violate 
            the sort sequence. 
      T - Access to nested internal tables using field symbols usually increase 
            performance. 
      F - Index access to an internal table of the type HASHED has less runtime 
            consumption. 
      F - You can perform a binary search on internal tables of the type SORTED using 
            the addition BINARY SEARCH only.

9. You want a subroutine U to have a formal parameter P that is used to return a 
     value. Which of the following definitions of U would you use to ensure that the 
     value is passed back to the calling program only if the processing of U ends 
     normally and is not terminated with a MESSAGE statement? (Single selection) 
    T - FORM U CHANGING VALUE(P).
    F - FORM U CHANGING P. 
    F  - FROM U USING P. 
           LOCAL P. 
    F - FROM U USING p. 
    F - FORM U USING VALUE(P).

10. Which statement at the time of AT SELECTION-SCREEN causes the selection 
       screen to be displayed again with fields ready for input and a message in the 
       status line? (Single selection) 
    T - A MESSAGE E...statement 
    F - An AUTHORITY-CHECK statement that return code SY-SUBRC NE 0. 
    F - A MESSAGE I...statement.

11. What do you get when you refer to a client-specific transparent table in the 
       Dictionary if you have a data definition with TABLES? (Single selection) 
    T - A structured work area (line). 
    F - A field. 
    F - An internal table.

12.  Which of the following events generate lists? (T/F)  
    F - PROCESS BEFORE OUTPUT 
    T - START-OF-SELECTION.  
    F - AT SELECTION-SCREEN. 
    F - INITIALIZATION. 
    T - AT LINE-SELECTION.

13. Which component of an application sever controls the data traffic between a 
       work process and a presentation server? (Single selection)
    T - Dispatcher. 
    F - SAPGUI. 
    F - Front-end processor. 
    F - Message Handler. 
    F - Screen processor.

14. For which tasks is the database interface responsible? (T/F) 
     F - Syntax check of "native" SQL commands. 
     T - Conversion of Open SQL statement from ABAP statements into the corresponding            database  a statements. 
     F - Data consistency check with respect to foreign key relationships. 
     T - Database independence of application programs. 
     T - Usage of the SAP buffers.

15. Which SAP GUI types are there? (T/F) 
     T - SAP GUI for Windows 
     T - SAP GUI for HTML. 
     F - SAP GUI for Web AS. 
     F - SAP GUI for ITS.  
     T - SAP GUI for Java.

16. Where can you have automatic input checks against the check table? (Single 
      selection) 
     T - For input fields on screens if the input fields have been copied from the 
           Dication into the Screen Painter. 
     F - For input fields on ABAP lists. 
     F - For input fields on selection screens.

17. Is it possible to increase the number of key fields in transparent tables that 
      are already active? (Single selection) 
    T - No, Key changes are not allowed. 
    F - Yes, irrespective of whether the table already contains data or not. 
    F - Yes, However, the table must not contain any data yet.

18. Which of the following statements about APPEND structures are true? (T/F) 
    F - After adding an APPEND structure to a table, you must convert the table. 
    F - You can use an APPEND structure like any other structure in ABAP programs. 
    F - An APPEND structure allow you to append field to an SAP table without having 
          to modify the table itself. 
    F - An APPEND structure is the same as substructure.

19. Which of the following statements apply to a database view? (T/F)  
    F - A database view supplies the results quantity of an outer join logic. 
    T - Using a database view, you can read data from several tables. 
    F - Using a database view, you can insert data into several tables. 
    F - A database view is a special view of transparent tables. 
    T - A database view can have one or several base tables.

20. The search help function know various link options in the ABAP dictionary. 
      Which of the following statements apply? (T/F) 
     F- A search help function that is linked to the table field can return values only for 
          the search field (field where the f4 help was triggered).
     F- A search help function that is linked to the data element can return values only 
          for the search field (field where the f4 help was triggered). 
     T- If the search help function is linked to the data element as well as to the field. 
          The search help for the field is displayed. 
     F- If the search help function is linked to a table A. this search help is displayed 
          whenever there are input field from A on the screen. 
     T- If the search help function is linked to a table A. this search help displayed 
          whenever there are input fields on that screen that have A as the check table.

21. Which statements about parameters for an elementary search help apply? (T/F) 
     T- Parameters can be displayed on the result list. 
     F- Parameters must be fields from the selection method only. 
     T- Import parameters control which data can be included in the data selection. 
     T- Export parameters control which data can be returned to the input template. 
     F- A parameter is either an import or an export parameter.

22. Which of the following statements about indexes are correct? (T/F) 
     T- The primary index consists of the key fields of the database table. 
     F- An Index can be assigned to several database tables. 
     T- A database table can have more than one index. 
     T- Using an index speeds up data selection from a table.

23.For what purpose are foreign key (FK) defined in the ABAP Dictionary? (Single 
     selection) 
     F- For the purpose of data consistency: when you active the table the FKs are 
          created in the database. You thus prevent invalid data from getting into the table. 
     T- For the propose data consistency: when you maintain data records using dialog 
          transaction (screens). 
     T- The input values are automatically check in accordance with the FKs. 
     F- FKs are used solely for documenting table relationships.

24. In which of the following table types is there a one-to-one relationship between 
      the table defined in the ABAP Dictionary and relevant physical table in the 
     database? 
     F- Cluster table  
     F- Pooled table 
     F- Structure 
     T- Transparent database table.

25. What is allowed within class definitions? (T/F) 
     F- Typing with LIKE to ABAP Dictionary types. 
     F- The definition of internal tables with header lines. 
     F- The TABLES statement. 
     T- The definition of internal tables without header lines. 
     T- Typing with TYPE to ABAP Dictionary types.

26. Which techniques are basic requirements for polymorphism? (T/F) 
     T- Narrowing Case. 
     T- Redefinition of methods (for polymorphsim through inheritance). 
     F- Widening Cast. 
     T- Implementation of methods of an interface in the respective classes 
         (for polymorphism through interfaces).

27. Which of the following statements about interfaces are correct? (T/F) 
      T- Interfaces actually stand for an interface (protocol) between a client (interface 
           user) and a server (implementing class). 
      F- Interfaces are used to call static components of a class. 
      F- Using interface references you can reference all the public components of an 
          object that have been defined in the corresponding interface-implementing class.  
     T- A client (caller) can use interface reference to access all methods of the interfaces          and thus archive polymorphism behavior. 
     T- Using interfaces you can simulate multiple inheritance.

28. Using the statement CREATE OBJECT you can instantiate objects of a class. 
      What situations can arise here? (T/F) 
    T- All objects of the same class contain the same number of attributes and 
         methods after being created. 
    T- You can preset different objects of a class with different values immediately 
         when they are being created. 
    F- The contents of the attributes of different objects in a class always contain the 
         same content or value immediately after being created. 
    T- You define the type and number of attributes of an object through the 
         corresponding class.

29. Ref_cl is a reference to the class cl_document. ref_if is a reference to the 
      interface if_display. The interface if_display is implemented by the class cl_document.
      What option do you have to create an object of the class cl_docment? (T/F) 
    T - CREATE OBJECT ref_cl. 
    T- CREATE OBJECT ref_if TYPE cl_document. 
    F- CREATE OBJECT ref_if. 
    T- DATA class_name TYPE string. 
         class_name = "CL_DOCUMENT"
         CREATE OBJECT ref_if TYPE (class_name). 
30. In the case of classes, we distinguish between two types of components 
      (attributes and methods): 
      Instance components and static components. Which of the following statements 
      apply in this context? (T/F) 
     F- In a static method, instance attributes can also be used, provided they are 
         declared as READ ONLY. 
     T- Instance methods can use both static as well as instance components in their 
          implementation part. 
     F- Both static as well as instance attributes are declared using the DATA 
          statement.
     T- Static methods can be called through the class: 
          <class_name>=><method_name>. 
     T- Static attributes exist only once for each class. 

Thursday, 6 March 2014

SAP OOABAPWide Casting or UpCasting



SAP OOABAP Concept Wide Casting or Up Casting



Definition: - The assignment of a super class instance to a reference variable of the type "points to sub class" is described as a Wide casting, because here we are switching from a more generalized view to a one with more detail (Specialized View).

Note:- In order to implement wide casting first we need to implement the narrow casting.

      Steps:-
Here I am taking the example of calculation of area of rectangle and area of cube.

 a) Definition and implementation of Super Class:-

     CLASS class_super DEFINITION.
        
PUBLIC SECTION.
          DATA:
             w_area 
TYPE i.
          METHODS:
             area 
IMPORTING w_length TYPE i 
                                           w_breadth TYPE i.
     ENDCLASS.                            
"class_super DEFINITION

     CLASS class_super IMPLEMENTATION.
         
METHOD area.
            w_area = w_length * w_breadth.
           WRITE:/ 
'Area of rectangle = ',
                         w_area.
         ENDMETHOD.                    
"area
     ENDCLASS.      

In the above picture the class class_super is the super class and has one method area which is to find the area of rectangle. The method has two parameters w_length, w_breadth for length and breadth.

 b) Definition and implementation of sub class:-

    CLASS class_sub DEFINITION INHERITING FROM class_super.
        
PUBLIC SECTION.
           DATA:
             w_height 
TYPE i.
           METHODS:
              area REDEFINITION.
   ENDCLASS.                            
"class_sub DEFINITION

  CLASS class_sub IMPLEMENTATION.
      
METHOD area.
        w_area = 
* w_length * w_breadth * w_height.
        WRITE:/ 
'Area of the cube ='.
        WRITE: w_area.
      ENDMETHOD.                    
"area
  ENDCLASS.                            
"class_sub IMPLEMENTATION

In the above picture the class class_sub is the sub class which is inheriting from the super class class_super. This sub class has one method area which is same as that of super class and redefined for calculating the area of cube. This method has one more parameter W_height along with w_length and w_breadth.  This method finds the area of cube.

 c) Declaration of reference variables:-

  DATA:
      object_superclass   
TYPE REF TO class_super,
      object_subclass      
TYPE REF TO class_sub,
      object2_superclass 
TYPE REF TO class_super.

In above screen two reference variables have been declared for super class and one reference variable is declared for sub class.

 d) Creation of objects:-

  START-OF-SELECTION.
     
CREATE OBJECT object_superclass.
     
CREATE OBJECT object2_superclass.
     
CREATE OBJECT object_subclass.

Now create the objects for the super and base class. Call the method Area of super class as below:

    CALL METHOD object_superclass->area
       
EXPORTING
         w_length   = 
10
         w_breadth = 
5.

 e) Implementation of Narrow casting:- As I discussed in introduction in order to implement 
wide casting  we need to first implement narrow casting.

    "Narrow casting
      object_subclass->w_height = 
10.
      object_superclass = object_subclass.

     CALL METHOD object_superclass->area
        
EXPORTING
          w_length    = 
10
          w_breadth = 
10.

We are assigning the value ‘10’ to ‘w_height’ instance variable of subclass object.

In above picture we are assigning the sub class instance reference variable to super class instance reference variable. This is known as narrow casting.

Now the instance of the super class(object_superclass) now points or refers to the object of the subclass, thus the modified method 'area' of the subclass is accessible. Now we can call the method Area of subclass class_sub to calculate the area of cube. 
              
  f) Implementation of Wide casting:- From below screen shot we implement the wide casting.

  "Wide casting
     object_superclass ?= object2_superclass.

     
CALL METHOD object_superclass->area
        
EXPORTING
          w_length  = 
10
          w_breadth = 
5.


The object 'object_superclass' now refers to the object of the subclass 'object_subclass'. Thus the 'area' method of the superclass cannot be called by this object. In order to enable it to call the 'area' method of the superclass, wide casting has to be performed.

  "Wide casting
    object_superclass ?= object2_superclass.

So right hand side of wide casting always has object of super class. Left side of wide casting always is object reference declared as ‘type ref to’ to super class.  Now method area of super class is called again to find the area of rectangle.

Note:- Wide Casting cannot be performed on sub class objects. It can only be performed on super class objects that have narrow casting.

      Summary:-  The assignment of a super class instance to a reference variable of the type  "points to sub class" is described as a Wide casting, because here we are switching from a more generalized view to a one with more detail(Specialized View).

      Source Code:- 
REPORT  yh_wide NO STANDARD PAGE HEADING.

CLASS class_super DEFINITION.
  
PUBLIC SECTION.
    DATA:
      w_area 
TYPE i.
    METHODS:
      area 
IMPORTING w_length TYPE i w_breadth TYPE i.
ENDCLASS.                             
"class_super DEFINITION

CLASS class_super IMPLEMENTATION.
  
METHOD area.
    w_area = w_length * w_breadth.

    WRITE:/ 
'Area of rectangle = '.
    WRITE: w_area.
  ENDMETHOD.                      
"area
ENDCLASS.                            
"class_super IMPLEMENTATION

CLASS class_sub DEFINITION INHERITING FROM class_super.
  
PUBLIC SECTION.
    DATA:
      w_height 
TYPE i.
    METHODS:
      area REDEFINITION.
ENDCLASS.                          
"class_sub DEFINITION

CLASS class_sub IMPLEMENTATION.
  
METHOD area.
    w_area = 
* w_length * w_breadth * w_height.
    WRITE:/ 
'Area of the cube =',
                  w_area.
  ENDMETHOD.                    
"area
ENDCLASS.                          
"class_sub IMPLEMENTATION

  DATA:
    object_superclass   
TYPE REF TO class_super,
    object_subclass      
TYPE REF TO class_sub,
    object2_superclass 
TYPE REF TO class_super.

START-OF-SELECTION.
  
CREATE OBJECT object_superclass.
  
CREATE OBJECT object2_superclass.
  
CREATE OBJECT object_subclass.
CALL METHOD object_superclass->area
    
EXPORTING
      w_length    = 
10
      w_breadth  = 
5.

"Narrow casting
  object_subclass->w_height = 
10.
  object_superclass = object_subclass.
CALL METHOD object_superclass->area
   
EXPORTING
      w_length     = 
10
      w_breadth  = 
10.
"Wide casting
object_superclass ?= object2_superclass.
CALL METHOD object_superclass->area
   
EXPORTING
      w_length   = 
10
      w_breadth = 
5.

Output:-