Difference between revisions of "SAP ABAP CLASES"

From SapWiki
(Created page with "==CLASS-METHODS== The CLASS-METHODS statement declares a static method meth. For the name meth, the naming conventions apply. With the class component selector (=>), static...")
 
Line 2: Line 2:
 
The CLASS-METHODS statement declares a static method meth. For the name meth, the naming conventions apply.  
 
The CLASS-METHODS statement declares a static method meth. For the name meth, the naming conventions apply.  
  
With the class component selector (=>), static methods can be used independently of objects. In static methods, the static components of the class or its superclasses can be accessed only if the component selector is not used.  
+
'''With the class component selector (=>), static methods can be used independently of objects'''. In static methods, the static components of the class or its superclasses can be accessed only if the component selector is not used.  
  
 
  <nowiki>REPORT ytest_clases.
 
  <nowiki>REPORT ytest_clases.

Revision as of 17:37, 7 April 2020

CLASS-METHODS

The CLASS-METHODS statement declares a static method meth. For the name meth, the naming conventions apply.

With the class component selector (=>), static methods can be used independently of objects. In static methods, the static components of the class or its superclasses can be accessed only if the component selector is not used.

REPORT ytest_clases.
CLASS cl_gui DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS gui_download IMPORTING i_filename TYPE string
                                         i_data_tab TYPE STANDARD TABLE.

ENDCLASS.

CLASS cl_gui IMPLEMENTATION.
  METHOD gui_download.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename                = i_filename
      TABLES
        data_tab                = i_data_tab
*       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.
* Implement suitable error handling here
    ENDIF.

  ENDMETHOD.

ENDCLASS.

DATA gt_t001 TYPE STANDARD TABLE OF t001.

START-OF-SELECTION.

  SELECT * INTO TABLE gt_t001 FROM t001 UP TO 10 ROWS.

  cl_gui=>gui_download( EXPORTING i_filename = 'c:\temp\ytest_t001.txt'
                                  i_data_tab = gt_t001 ).