Monday, January 29, 2018

Interface

·         Interface is a collection of Methods and attributes.
·         An interface contain only definition no implementation.
·         For Interface we can define the reference, but we cannot create object for Interface.
·         We can declare same interface in any number of classes under public section.
·         Interface Components are always access through object.
·         An interface is also known as pure abstract class, because all methods in interface are abstract.
·         Interface contain abstract Methods always in public section only.            
·         Object of a class can be assigned to interface reference if the class implements all methods of that interface.
·         Syntax of Declaring the Interface.
Interface <interface Name>.
------------
-----------

Endinterface.

Example:
      REPORT ZINTERFACE.

   ******Interafce.
   INTERFACE IF1.
         DATA N1 TYPE I.
         METHODS METHOD1.
   ENDINTERFACE.

   *****Declare Class.
  CLASS CL1 DEFINITION.
       PUBLIC SECTION.
           METHODS METHOD1.
       INTERFACES IF1.
  ENDCLASS.

  *****Implementation Class.
  CLASS CL1 IMPLEMENTATION.
  *****Implement Class Method.
        METHOD METHOD1.
             WRITE 'This is class Method...!'.
        ENDMETHOD.

 *****Implement Interface Method.
        METHOD IF1~METHOD1.
            WRITE'This is Interface Method...!'.
        ENDMETHOD.
  ENDCLASS.

START-OF-SELECTION.
****Create Refernce for Class.
     DATA CL1_REF TYPE REF TO CL1.
*****Create Object for Class.
     CREATE OBJECT CL1_REF.
*****Call Method in Class.
     CALL METHOD CL1_REF->METHOD1.
*****Call Method for Interface.
     CALL METHOD CL1_REF->IF1~METHOD1.

Output:











Example 2:

REPORT ZINTERFACE.

*****Structure Declaration.
TYPES BEGIN OF TY_T001,
                  BUKRS  TYPE BUKRS,
                  BUTXT  TYPE BUTXT,
                  ORT01  TYPE ORT01,
                  LAND1  TYPE LAND1,
              END OF TY_T001.

*****Internal Table and Workarea Declaration.
DATA T_T001   TYPE STANDARD TABLE OF TY_T001,
              W_T001 TYPE TY_T001.

*****Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
  PARAMETERS P_BUKRS TYPE BUKRS.
SELECTION-SCREEN END OF BLOCK A1.

*****Declare Interface.
INTERFACE IF1.
  METHODS DISPLAY.
ENDINTERFACE.

*****Declare Class.
CLASS GET_DATA DEFINITION.
  PUBLIC SECTION.
    METHODS GET_T001 IMPORTING I_BUKRS TYPE BUKRS.
    INTERFACES IF1.
ENDCLASS.

*****Implement GET_DATA Class.
CLASS GET_DATA IMPLEMENTATION.
*****Implement Class Method.
  METHOD GET_T001.
    REFRESH T_T001.
    SELECT BUKRS
                  BUTXT
                 ORT01
                 LAND1
      FROM T001 INTO TABLE T_T001 WHERE BUKRS I_BUKRS.
  ENDMETHOD.

*****Implement Interface Method.
  METHOD IF1~DISPLAY.
    CLEAR W_T001.
    LOOP AT T_T001 INTO W_T001.
      WRITE / W_T001-BUKRS,
                        W_T001-BUTXT,
                        W_T001-ORT01,
                        W_T001-LAND1.
    ENDLOOP.
  ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.

  DATA RDT   TYPE REF TO GET_DATA,  "Reference for Get Data Class
                RIDIS TYPE REF TO IF1.         "Refence for Interface.

*****Create Object for Class
  CREATE OBJECT RDT.

*****Call the Method.
  CALL METHOD RDT->GET_T001
  EXPORTING
     I_BUKRS P_BUKRS.

******Call Interface Method to Display Data.
  CALL METHOD RDT->IF1~DISPLAY.

Output:



Saturday, January 27, 2018

TMG (Table Maintaince Generator)


TMG (Table Maintenance Generator) :

  • Table Maintenance Generator is used to insert, update and delete the data of data base table without any code (without DML Commands).
  • Table Maintaince Generator is only possible for custom tables.
  • The transaction code for TMG is SM30.
Step to Create TMG:
Note : I Already create table if you don't know how to create Transparent table then please follow the link.
http://abaptutorialspot.blogspot.in/2018/01/create-transparent-table.html

Execute SE11






Provide Data base Table Name and Click on change.



















Click on Utilities and click on Table Maintenance Generator




















Provide Authorization Group &NC&(Default Group), Provide Function group same as Data base Table Name, Select Radio Button One step or two step base on requirement and provide screen number and click on Create

Note: If you select single screen then Provide only one screen number (9000) or if you provide two step then provide two screen number.































Click on Create
























Save in our package or local object




















Click on save and back button.











Execute SE93

Provide Transaction Code and Click on Create Button.




Provide Short Description and Select the Radio Button Transaction with parameters.























Provide Transaction SM30 and check Skip initial screen check box.



















Select all GUI Check Box.










Scroll down and Provide VIEWNAME as Data Base Name and UPDATE = 'X'



















Click on SAVE Button





Save the Transaction in Package or Local Object




















Now Execute Transaction: ZTRANSACTION















Now you see the + if you want to give the name then in MENU Bar Click on System and select Status.






















Double Click on the Screen 9000

























Now click on Layout


















In Screen Painter Screen is coming and click on Edit, Double click on + Symbol provide the Name






















Provide Name in Text
















Click on save button and back button.








Activate Screen and Click on Back Button
















Once again Execute Transaction and you can see Name is showing.