Monday 18 July 2016

Procedure to find out the BADI definition and Implementation of BADI


Requirements

     

Transaction Code XD01
BADI Definition CUSTOMER_ADD_DATA
Method 1 to be Implemented CHECK_ALL_DATA
Functionality to be Implemented Download the Customer data
Method 2 to be Implemented PRESET_VALUES_CCODE
Functionality to be Implemented Set default values for Company code 



To find out the package.
  • Go to transaction code XD02.
  • Enter the Customer Id and click on continue,
  • Screen looks like,
  • Click on System -> Status.
  • Pop-up will appear.
  • Double Click on Program name.
  • Screen look like,
  • Click on Goto -> Properties.
  • Pop-up will appear.
  • Copy the Package name.

To find out BADI defination
  • Go to Transaction Code SE18.
  • Initial screen looks like,
  • Select BAdi name radio button.
  • Click on F4 help.
  • Pop-up will appear .
  • Click on Information System.
  • Pop-up will appear.
  • Enter the package name and click on execute.
  • In pop-up BADI definition will appear.
  • Double click on BADI definition.
  • Click on Display.
  • Screen look like this,
  • Click on interface tab , to find out the methods.

  • Copy the BADI Definition name.

Implementation of BADI

  • Go to Transaction Code SE19.
  • Initial screen looks like,
  • Click on Classical BADI.



  • Automatically BADI definition will pull's up.
  • Click on Create Impl. Button.
  • Pop-up will appear.
  • Enter the Implementation name start's with Y or Z< implementation BADI name> and click on continue button.

  •  Screen looks like,

  •  Enter the Implementation short text.
 
  • Click on Interface Tab.
  • Automatically , Class will be created.
  • Click on Save button.
  • Save it either in Local Package or Package.

  •  Double click on Class name.
  • Pop-up will appear.
   

  • Click on Yes.
  • One more pop-up will Appear.
  • Click on continue.
  • One more pop-up will appear.

  • Either Select the existing Enhancement Implementation or Create the new  Enhancement Implementation .
  • To Create the new  Enhancement Implementation , Click on Create new  Enhancement Implementation Button .
  • Pop-up will appear.
  • Enter the Enhancement Implementation name start's with Y or Z.
  • Enter the short description.
  • Click on continue.
  • Assign the Package.

  • Select the Enhancement Implementation name and click on continue.
  • Class Builder Looks like,
  • Select the Required methods.
  • To view method Documentation.
  • Select the required method and click on Goto ->Documentation ->To component.
  • Documentation help will appear.
  • Double click on required method name.
  • Screen looks like,
  • Enter the Logic.

method IF_EX_CUSTOMER_ADD_DATA~CHECK_ALL_DATA.

  TYPES : BEGIN OF TY_KNA1,
         KUNNR TYPE KNA1-KUNNR,
         KTOKD TYPE KNA1-KTOKD,
         NAME1 TYPE KNA1-NAME1,
         ORT01 TYPE KNA1-ORT01,
         LAND1 TYPE KNA1-LAND1,
        END OF TY_KNA1.

  DATA : WA_KNA1  TYPE TY_KNA1,
         IT_KNA1 TYPE TABLE OF TY_KNA1.
  DATA : FILENAME TYPE  STRING.
  CLEAR WA_KNA1.

  WA_KNA1-KUNNR = S_KNA1-KUNNR.
  WA_KNA1-KTOKD = S_KNA1-KTOKD.
  WA_KNA1-NAME1 = S_KNA1-NAME1.
  WA_KNA1-ORT01 = S_KNA1-ORT01.
  WA_KNA1-LAND1 = S_KNA1-LAND1.

  APPEND WA_KNA1 TO IT_KNA1.



  CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
   EXPORTING
     WINDOW_TITLE            = 'Select the file save location'
     DEFAULT_EXTENSION       = 'DOC'
*     DEFAULT_FILE_NAME       =
*     WITH_ENCODING           =
*     FILE_FILTER             =
*     INITIAL_DIRECTORY       =
   IMPORTING
     FILENAME                = FILENAME
*     PATH                    =
*     FULLPATH                =
*     USER_ACTION             =
*     FILE_ENCODING           =
            .

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
*   BIN_FILESIZE                    =
    FILENAME                        = FILENAME
   FILETYPE                        = 'ASC'
*   APPEND                          = ' '
*   WRITE_FIELD_SEPARATOR           = ' '
*   HEADER                          = '00'
*   TRUNC_TRAILING_BLANKS           = ' '
*   WRITE_LF                        = 'X'
*   COL_SELECT                      = ' '
*   COL_SELECT_MASK                 = ' '
*   DAT_MODE                        = ' '
*   CONFIRM_OVERWRITE               = ' '
*   NO_AUTH_CHECK                   = ' '
*   CODEPAGE                        = ' '
*   IGNORE_CERR                     = ABAP_TRUE
*   REPLACEMENT                     = '#'
*   WRITE_BOM                       = ' '
*   TRUNC_TRAILING_BLANKS_EOL       = 'X'
*   WK1_N_FORMAT                    = ' '
*   WK1_N_SIZE                      = ' '
*   WK1_T_FORMAT                    = ' '
*   WK1_T_SIZE                      = ' '
* IMPORTING
*   FILELENGTH                      =
  TABLES
    DATA_TAB                        = IT_KNA1
*   FIELDNAMES                      =
 EXCEPTIONS
   FILE_WRITE_ERROR                = 1
   NO_BATCH                        = 2
   GUI_REFUSE_FILETRANSFER         = 3
   INVALID_TYPE                    = 4
   NO_AUTHORITY                    = 5
   UNKNOWN_ERROR                   = 6
   HEADER_NOT_ALLOWED              = 7
   SEPARATOR_NOT_ALLOWED           = 8
   FILESIZE_NOT_ALLOWED            = 9
   HEADER_TOO_LONG                 = 10
   DP_ERROR_CREATE                 = 11
   DP_ERROR_SEND                   = 12
   DP_ERROR_WRITE                  = 13
   UNKNOWN_DP_ERROR                = 14
   ACCESS_DENIED                   = 15
   DP_OUT_OF_MEMORY                = 16
   DISK_FULL                       = 17
   DP_TIMEOUT                      = 18
   FILE_NOT_FOUND                  = 19
   DATAPROVIDER_EXCEPTION          = 20
   CONTROL_FLUSH_ERROR             = 21
   OTHERS                          = 22
          .
IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.



endmethod.



  • Save ->Check ->Activate.
  • Click on Back button.
  • To implement the second method.
  • Select the method.
  • For method documentation.
  • Goto -> Documentation -> To Component.
  • Go through on Documentation.
  • Go back, Double click on method.
  • Implement the method.
method IF_EX_CUSTOMER_ADD_DATA~PRESET_VALUES_CCODE.
  
  E_KNB1-AKONT = '14000'.
  E_KNB1-ZTERM = 'ZB01'.

endmethod.

  • Save -> Check -> Activate.
  • Activate the Class.


  • Click on back button.
  • Save ->Check -> Activate.

Test Enhancement.

  • Go to transaction code : XD01.
  • Screen looks like,
  • Select Account Group as : Bill-to-party.
  • Customer number.
  • Company code and press Enter.
  • Select the Title.
  • Name and search term and press  ENTER,
  • Click on Company Code data.
  • Notice the Default value AKONT.
  • Click on payment Transaction.
  • Notice the Default value ZB01.
  • Click on Save.
  • Pop-up will appear ( Customized ).

  • Select the path and enter the file name.
  • Click on Save.
  • Click on Generate.
  • Check the status bar.
  • Go to file saved path.
  • Open file.




No comments:

Post a Comment