Skip to end of metadata
Go to start of metadata

*&-------------------------------------------------------------------*
*& Report  ZDPS_TABLE_INFO_DOWNLOAD
*&
*&-------------------------------------------------------------------*
*& Simple ALV report -- User enters a table name and gets in ALV the
*& list of all the fields in table with their salient characteristics
*& and the key field is given a different color for quick recognition
*& and when the user presses the button list it downloads all the table
*& data in excel format as DAT file and when user presses EXIT, they
*& can leave the program
*&-------------------------------------------------------------------*
 REPORT  ZDPS_TABLE_INFO_DOWNLOAD NO STANDARD PAGE HEADING.
 *Type pools declaration for ALV.
TYPE-POOLS : SLIS.
*Type pool declarations for ABAP language
TYPE-POOLS : ABAP.
*String for filename
DATA : P_STRING TYPE STRING.
*Structure declaration for the result of Function module
TYPES : BEGIN OF TY_FIES.
        INCLUDE STRUCTURE DFIES.
TYPES : END OF TY_FIES.
*Structure declaration for header - fieldnames
TYPES : BEGIN OF TY_HEADER,
         FIELDNAME TYPE CHAR100,
        END OF TY_HEADER.
*Internal table and work area declaration for header
DATA : IT_HEADER TYPE STANDARD TABLE OF TY_HEADER INITIAL SIZE 0,
       WA_HEADER TYPE TY_HEADER.
*Internal table and work area declaration for FM .
DATA : IT_FIES TYPE STANDARD TABLE OF TY_FIES INITIAL SIZE 0,
       WA_FIES TYPE TY_FIES.
*Dynamic internal table declarations
DATA : STRUCT_REF TYPE REF TO CL_ABAP_STRUCTDESCR,
       WA_FIELDCAT TYPE LVC_S_FCAT,
       IT_FIELDCAT TYPE LVC_T_FCAT,
       DATAREFERENCE TYPE REF TO DATA.
* Field-Symbols for dynamic internal table
FIELD-SYMBOLS:
              <DYN_TAB> TYPE ANY TABLE,
              <DYN_TABLE> TYPE STANDARD TABLE,
              <DESR_COMP> TYPE ABAP_COMPDESCR,
              <MY_FS>  TYPE ANY.
*Structure declaration for dd02t
TYPES : BEGIN OF TY_DESC.
        INCLUDE STRUCTURE DD02T.
TYPES : END OF TY_DESC.
*Internal table and work area declaration for dd02t .
DATA : IT_DESC TYPE STANDARD TABLE OF TY_DESC INITIAL SIZE 0,
       WA_DESC TYPE TY_DESC.
*Structure declaration for the output in ALV format
TYPES : BEGIN OF TY_OUTPUT.
        INCLUDE STRUCTURE DFIES.
TYPES : COLOR_LINE(4) TYPE C,  " Line color
        END OF TY_OUTPUT.
*Internal table and work area declaration for output ALV.
DATA : IT_OUTPUT TYPE STANDARD TABLE OF TY_OUTPUT INITIAL SIZE 0,
       WA_OUTPUT TYPE TY_OUTPUT.
*Data declarations for ALV
DATA: C_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
      C_ALVGD TYPE REF TO CL_GUI_ALV_GRID,
      IT_FCAT            TYPE LVC_T_FCAT,
      IT_LAYOUT          TYPE LVC_S_LAYO.
* Grid title.
DATA : TEXT2 TYPE STRING.
**********************************************************************
* SELECTION-SCREEN
**********************************************************************
SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-001.
*HERE ENTER THE TABLE NAME
PARAMETERS : P_TABLE  LIKE DD02L-TABNAME,
             P_FILE LIKE RLGRAP-FILENAME DEFAULT
           'C:\Documents and Settings\231679\Desktop\FILE.XLS'.
SELECTION-SCREEN END OF BLOCK BLK.
 SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-002.
PARAMETERS : RB_INFO RADIOBUTTON GROUP XXX,
             RB_COUNT RADIOBUTTON GROUP XXX.
SELECTION-SCREEN END OF BLOCK BLK1.
 AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
  PERFORM F4_HELP_FILE.
 **********************************************************************
* START-OF-SELECTION
**********************************************************************
START-OF-SELECTION.
   IF RB_INFO EQ 'X'.
* Fetch values from the DD02t
    SELECT * FROM DD02T INTO TABLE IT_DESC WHERE TABNAME = P_TABLE AND
    DDLANGUAGE = 'E'.
* Function module to get all the fields and their characteristics in a
* Table
    CALL FUNCTION 'DDIF_FIELDINFO_GET'
      EXPORTING
        TABNAME              = P_TABLE
*   FIELDNAME            = ' '
*   LANGU                = SY-LANGU
*   LFIELDNAME           = ' '
*   ALL_TYPES            = ' '
*   GROUP_NAMES          = ' '
*   UCLEN                =
* IMPORTING
*   X030L_WA             =
*   DDOBJTYPE            =
*   DFIES_WA             =
*   LINES_DESCR          =
     TABLES
       DFIES_TAB            = IT_FIES
*   FIXED_VALUES         =
   EXCEPTIONS
     NOT_FOUND            = 1
     INTERNAL_ERROR       = 2
     OTHERS               = 3
              .
    IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
 **********************************************************************
* Append the values fetched through the Function module in the output
* ALV Report
**********************************************************************
    LOOP AT IT_FIES INTO WA_FIES.
      WA_OUTPUT-FIELDNAME = WA_FIES-FIELDNAME.
      WA_OUTPUT-INTTYPE = WA_FIES-INTTYPE.
      WA_OUTPUT-MEMORYID = WA_FIES-MEMORYID.
      WA_OUTPUT-CHECKTABLE = WA_FIES-CHECKTABLE.
      WA_OUTPUT-LENG = WA_FIES-LENG.
      WA_OUTPUT-FIELDTEXT = WA_FIES-FIELDTEXT.
      WA_OUTPUT-KEYFLAG = WA_FIES-KEYFLAG.
      WA_OUTPUT-CONVEXIT = WA_FIES-CONVEXIT.
      WA_OUTPUT-DOMNAME = WA_FIES-DOMNAME.
      WA_OUTPUT-ROLLNAME = WA_FIES-ROLLNAME.
      IF WA_FIES-KEYFLAG = 'X'.
        WA_OUTPUT-COLOR_LINE = 'C600'.
      ENDIF.
      APPEND WA_OUTPUT TO IT_OUTPUT.
      CLEAR WA_OUTPUT.
    ENDLOOP.
 * Table description for pop up
    READ TABLE IT_DESC INTO WA_DESC INDEX 1.
    TEXT2 = WA_DESC-DDTEXT.
 * POP up to show the table and its defintion
    CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
      EXPORTING
        TITEL        = 'Table for display'
        TEXTLINE1    = P_TABLE
        TEXTLINE2    = TEXT2
        START_COLUMN = 25
        START_ROW    = 6.
 * Call the ALV screen with custom container
    CALL SCREEN 0600.
  ELSEIF RB_COUNT EQ 'X'.
    PERFORM TABLE_ENTRIES.
  ENDIF.
 TOP-OF-PAGE.
  WRITE:'The Table entires for:', P_TABLE.
 *&-------------------------------------------------------------------*
*&      Module  STATUS_0600  OUTPUT
*&-------------------------------------------------------------------*
MODULE STATUS_0600 OUTPUT.
  SET PF-STATUS 'GETZ'.        "Defining own PF status
  SET TITLEBAR 'ALV'.          "Defining a title
ENDMODULE.                 " STATUS_0600  OUTPUT
* calling the PBO module ALV_OUTPUT.
*&-------------------------------------------------------------------*
*&      Module  ALV_GRID  OUTPUT
*&-------------------------------------------------------------------*
MODULE ALV_GRID OUTPUT.
*Create object for container
  CREATE OBJECT C_CONT
    EXPORTING
      CONTAINER_NAME = 'C_CONT'.
*Create object for ALV grid
  CREATE OBJECT C_ALVGD
    EXPORTING
      I_PARENT = C_CONT.
* Set field for ALV
  PERFORM ALV_BUILD_FIELDCAT.
* Set ALV attributes FOR LAYOUT
  PERFORM ALV_REPORT_LAYOUT.
  CHECK NOT C_ALVGD IS INITIAL.
* Call ALV GRID
  CALL METHOD C_ALVGD->SET_TABLE_FOR_FIRST_DISPLAY
    EXPORTING
      IS_LAYOUT                     = IT_LAYOUT
    CHANGING
      IT_OUTTAB                     = IT_OUTPUT[]
      IT_FIELDCATALOG               = IT_FCAT
    EXCEPTIONS
      INVALID_PARAMETER_COMBINATION = 1
      PROGRAM_ERROR                 = 2
      TOO_MANY_LINES                = 3
      OTHERS                        = 4.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
 ENDMODULE.                 " ALV_GRID  OUTPUT
*&-------------------------------------------------------------------*
*&      Module  USER_COMMAND_0600  INPUT
*&-------------------------------------------------------------------*
MODULE USER_COMMAND_0600 INPUT.
  CASE SY-UCOMM.
    WHEN 'EXCL'.
      PERFORM LIST_DOWNLOAD.
    WHEN 'EXIT'.
      LEAVE PROGRAM.
  ENDCASE.
ENDMODULE.                 " USER_COMMAND_0600  INPUT
*&-------------------------------------------------------------------*
*&      Form  alv_build_fieldcat
*&-------------------------------------------------------------------*
*      BUILD FIELD CATALOGUE
*--------------------------------------------------------------------*
FORM ALV_BUILD_FIELDCAT.
  DATA: L_FLDCAT TYPE LVC_S_FCAT.
  CLEAR: L_FLDCAT.
   L_FLDCAT-ROW_POS   = '1'.
  L_FLDCAT-COL_POS   = '1'.
  L_FLDCAT-FIELDNAME = 'FIELDNAME'.
  L_FLDCAT-TABNAME   = 'IT_OUTPUT'.
  L_FLDCAT-OUTPUTLEN = 15.
  L_FLDCAT-SCRTEXT_M = 'Fieldname'.
  L_FLDCAT-ICON = 'X'.
  APPEND L_FLDCAT TO IT_FCAT.
  CLEAR L_FLDCAT.
   L_FLDCAT-ROW_POS   = '1'.
  L_FLDCAT-COL_POS   = '2'.
  L_FLDCAT-FIELDNAME = 'INTTYPE'.
  L_FLDCAT-TABNAME   = 'IT_OUTPUT'.
  L_FLDCAT-OUTPUTLEN = 5.
  L_FLDCAT-SCRTEXT_M = 'Datatype'.
  L_FLDCAT-ICON = ''.
  APPEND L_FLDCAT TO IT_FCAT.
  CLEAR L_FLDCAT.
   L_FLDCAT-ROW_POS   = '1'.
  L_FLDCAT-COL_POS   = '3'.
  L_FLDCAT-FIELDNAME = 'LENG'.
  L_FLDCAT-TABNAME   = 'IT_OUTPUT'.
  L_FLDCAT-OUTPUTLEN = 5.
  L_FLDCAT-SCRTEXT_M = 'Length'.
  L_FLDCAT-ICON = ''.
  APPEND L_FLDCAT TO IT_FCAT.
  CLEAR L_FLDCAT.
   L_FLDCAT-ROW_POS   = '1'.
  L_FLDCAT-COL_POS   = '4'.
  L_FLDCAT-FIELDNAME = 'FIELDTEXT'.
  L_FLDCAT-TABNAME   = 'IT_OUTPUT'.
  L_FLDCAT-OUTPUTLEN = 60.
  L_FLDCAT-SCRTEXT_M = 'Description'.
  L_FLDCAT-ICON = ''.
  APPEND L_FLDCAT TO IT_FCAT.
  CLEAR L_FLDCAT.
   L_FLDCAT-ROW_POS   = '1'.
  L_FLDCAT-COL_POS   = '6'.
  L_FLDCAT-FIELDNAME = 'MEMORYID'.
  L_FLDCAT-TABNAME   = 'IT_OUTPUT'.
  L_FLDCAT-OUTPUTLEN = 5.
  L_FLDCAT-SCRTEXT_M = 'ParameterID'.
  L_FLDCAT-ICON = ''.
  APPEND L_FLDCAT TO IT_FCAT.
  CLEAR L_FLDCAT.
   L_FLDCAT-ROW_POS   = '1'.
  L_FLDCAT-COL_POS   = '7'.
  L_FLDCAT-FIELDNAME = 'CHECKTABLE'.
  L_FLDCAT-TABNAME   = 'IT_OUTPUT'.
  L_FLDCAT-OUTPUTLEN = 8.
  L_FLDCAT-SCRTEXT_M = 'Checktable'.
  L_FLDCAT-ICON = ''.
  APPEND L_FLDCAT TO IT_FCAT.
  CLEAR L_FLDCAT.
   L_FLDCAT-ROW_POS   = '1'.
  L_FLDCAT-COL_POS   = '8'.
  L_FLDCAT-FIELDNAME = 'DOMNAME'.
  L_FLDCAT-TABNAME   = 'IT_OUTPUT'.
  L_FLDCAT-OUTPUTLEN = 8.
  L_FLDCAT-SCRTEXT_M = 'Domain'.
  L_FLDCAT-ICON = ''.
  APPEND L_FLDCAT TO IT_FCAT.
  CLEAR L_FLDCAT.
   L_FLDCAT-ROW_POS   = '1'.
  L_FLDCAT-COL_POS   = '9'.
  L_FLDCAT-FIELDNAME = 'ROLLNAME'.
  L_FLDCAT-TABNAME   = 'IT_OUTPUT'.
  L_FLDCAT-OUTPUTLEN = 8.
  L_FLDCAT-SCRTEXT_M = 'DataElement'.
  L_FLDCAT-ICON = ''.
  APPEND L_FLDCAT TO IT_FCAT.
  CLEAR L_FLDCAT.
   L_FLDCAT-ROW_POS   = '1'.
  L_FLDCAT-COL_POS   = '10'.
  L_FLDCAT-FIELDNAME = 'CONVEXIT'.
  L_FLDCAT-TABNAME   = 'IT_OUTPUT'.
  L_FLDCAT-OUTPUTLEN = 8.
  L_FLDCAT-SCRTEXT_M = 'Conversion Routine'.
  L_FLDCAT-ICON = ''.
  APPEND L_FLDCAT TO IT_FCAT.
ENDFORM.                    " alv_build_fieldcat
*&-------------------------------------------------------------------*
*&      Form  alv_report_layout
*&-------------------------------------------------------------------*
*      Report layout
*--------------------------------------------------------------------*
FORM ALV_REPORT_LAYOUT.
  IT_LAYOUT-CWIDTH_OPT = 'X'.
  IT_LAYOUT-ZEBRA = 'X'.
  IT_LAYOUT-INFO_FNAME  = 'COLOR_LINE'.
ENDFORM.                    " alv_report_layout
*&-------------------------------------------------------------------*
*&      Form  LIST_DOWNLOAD
*&-------------------------------------------------------------------*
*       text
*--------------------------------------------------------------------*
FORM LIST_DOWNLOAD .
*Subroutine to create a dynamic internal table
  PERFORM CREATE_TABLE.
*Subroutine to download the values of table into excel
  PERFORM DOWNLOAD_TABLE.
ENDFORM.                    "LIST_DOWNLOAD
*--------------------------------------------------------------------*
*       FORM DOWNLOAD_TABLE                                          *
*--------------------------------------------------------------------*
*       Downloads the table data.
*--------------------------------------------------------------------*
FORM DOWNLOAD_TABLE.
* Assignment of the file to a string for gui download
  P_STRING = P_FILE.
* Select to fetch the table data
  SELECT *
  INTO TABLE <DYN_TAB>
  FROM (P_TABLE).
  ASSIGN <DYN_TAB> TO <DYN_TABLE>.
* Download values as a DAT format with the fieldnames as headings
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
*   BIN_FILESIZE                    =
      FILENAME                        =  P_STRING
      FILETYPE                        = 'DAT'
    TABLES
      DATA_TAB                        = <DYN_TABLE>
     FIELDNAMES                      = IT_HEADER
   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 EQ 0.
*POP up to inform Whether download is successful or not
    CALL FUNCTION 'POPUP_TO_INFORM'
      EXPORTING
        TITEL = 'Success!'
        TXT1  = P_TABLE
        TXT2  = 'was correctly downloaded.'.
  ELSE.
    CALL FUNCTION 'POPUP_TO_INFORM'
      EXPORTING
        TITEL = 'Error!'
        TXT1  = P_TABLE
        TXT2  = 'NOT downloaded.'.
  ENDIF.
ENDFORM.                    "DOWNLOAD_TABLE
*--------------------------------------------------------------------*
*       FORM CREATE_TABLE                                            *
*--------------------------------------------------------------------*
*       Creates a dynamic internal table.
*--------------------------------------------------------------------*
FORM CREATE_TABLE.
  CREATE DATA DATAREFERENCE TYPE (P_TABLE).
  ASSIGN DATAREFERENCE->* TO <MY_FS>.
  STRUCT_REF ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA( <MY_FS> ).
  LOOP AT STRUCT_REF->COMPONENTS ASSIGNING <DESR_COMP>.
    WA_FIELDCAT-FIELDNAME     = <DESR_COMP>-NAME.
    WA_FIELDCAT-REF_TABLE     = P_TABLE.
    WA_FIELDCAT-REF_FIELD     = <DESR_COMP>-NAME.
    WA_HEADER-FIELDNAME       = <DESR_COMP>-NAME.
    APPEND WA_FIELDCAT TO IT_FIELDCAT.
    APPEND WA_HEADER TO IT_HEADER.
  ENDLOOP.
  CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
    EXPORTING
      IT_FIELDCATALOG           = IT_FIELDCAT
    IMPORTING
      EP_TABLE                  = DATAREFERENCE
    EXCEPTIONS
      GENERATE_SUBPOOL_DIR_FULL = 1
      OTHERS                    = 2.
  ASSIGN DATAREFERENCE->* TO <DYN_TAB>.
ENDFORM.                    "CREATE_TABLE
*&---------------------------------------------------------------------*
*&      Form  TABLE_ENTRIES
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM TABLE_ENTRIES .
   TYPES : BEGIN OF TY_LINE,
            LINE TYPE CHAR100,
          END OF TY_LINE.
   DATA : L_FEILD TYPE ABSBT,
         L_COUNT TYPE CHAR4 VALUE '0',
         IT_DD03L TYPE STANDARD TABLE OF DD03L,
         WA_DD03L TYPE DD03L,
         L_TABNAME TYPE TABNAME,
         L_CHAR TYPE CHAR100,
         L_CURR TYPE DMBTR,
         L_CUKY TYPE WAERS,
         L_DEC  TYPE KURSR,
         L_UNIT TYPE MEINS,
         L_DATS TYPE MBDAT,
         L_TIM  TYPE ABHOZ,
         L_QUAN TYPE MENGE_D,
         L_NUM  TYPE ATINN,
         L_INIT TYPE I,
         VAR TYPE I,
         L_ACCP TYPE ABPER_RF,
         L_OBJECT TYPE DOKU_OBJ,
         LINE   TYPE TABLE OF TY_LINE,
         WA_LINE TYPE TY_LINE.
   SELECT
        *
        FROM
        DD03L
        INTO TABLE IT_DD03L
        WHERE TABNAME EQ P_TABLE.
  IF SY-SUBRC EQ 0 .
     DELETE IT_DD03L WHERE FIELDNAME = '.INCLU--AP' .
     DELETE IT_DD03L WHERE FIELDNAME = '.INCLUDE' .
   ENDIF.
   SORT IT_DD03L BY FIELDNAME.
   LOOP AT IT_DD03L INTO WA_DD03L.
    CASE WA_DD03L-DATATYPE.
      WHEN 'ACCP'.
        VAR = 0.
        SELECT
               (WA_DD03L-FIELDNAME)
               FROM (WA_DD03L-TABNAME)
               INTO L_ACCP.
          IF L_CHAR IS NOT INITIAL.
            VAR = VAR + 1.
          ENDIF.
         ENDSELECT.
      WHEN 'CHAR'.
        VAR = 0.
        SELECT
               (WA_DD03L-FIELDNAME)
               FROM (WA_DD03L-TABNAME)
               INTO L_CHAR.
          IF L_CHAR IS NOT INITIAL.
            VAR = VAR + 1.
          ENDIF.
        ENDSELECT.
        L_OBJECT = WA_DD03L-FIELDNAME.
*      CALL FUNCTION 'DOCU_READ'
*        EXPORTING
*          ID                      = 'DE'
*          LANGU                   = 'E'
*          OBJECT                  = l_object
*          TYP                     = 'E'
*          VERSION                 = '0001'
*        TABLES
*          LINE                    = line
*                .
       WHEN 'CUKY'.
        VAR = 0.
        SELECT
                 (WA_DD03L-FIELDNAME)
                 FROM (WA_DD03L-TABNAME)
                 INTO L_CUKY  .
          IF L_CHAR IS NOT INITIAL.
            VAR = VAR + 1.
          ENDIF.
        ENDSELECT.
      WHEN 'CURR'.
        VAR = 0 .
        SELECT
                (WA_DD03L-FIELDNAME)
                FROM (WA_DD03L-TABNAME)
                INTO L_CURR.
           IF L_CHAR IS NOT INITIAL.
            VAR = VAR + 1.
          ENDIF.
        ENDSELECT.
      WHEN 'DATS'.
        VAR = 0.
        SELECT
               (WA_DD03L-FIELDNAME)
               FROM (WA_DD03L-TABNAME)
               INTO L_DATS.
          IF L_CHAR IS NOT INITIAL.
            VAR = VAR + 1.
          ENDIF.
         ENDSELECT.
      WHEN 'DEC'.
        VAR = 0.
        SELECT
               (WA_DD03L-FIELDNAME)
               FROM (WA_DD03L-TABNAME)
               INTO L_DEC.
          IF L_CHAR IS NOT INITIAL.
            VAR = VAR + 1.
          ENDIF.
         ENDSELECT.
      WHEN 'FLTP'.
        VAR = 0.
        SELECT
               (WA_DD03L-FIELDNAME)
               FROM (WA_DD03L-TABNAME)
               INTO L_CHAR.
          IF L_CHAR IS NOT INITIAL.
            VAR = VAR + 1.
          ENDIF.
         ENDSELECT.
      WHEN 'INT1'.
        VAR = 0.
        SELECT
               (WA_DD03L-FIELDNAME)
               FROM (WA_DD03L-TABNAME)
               INTO L_INIT.
          IF L_CHAR IS NOT INITIAL.
            VAR = VAR + 1.
          ENDIF.
         ENDSELECT.
      WHEN 'INT2'.
        VAR = 0.
        SELECT
               (WA_DD03L-FIELDNAME)
               FROM (WA_DD03L-TABNAME)
               INTO L_INIT.
          IF L_CHAR IS NOT INITIAL.
            VAR = VAR + 1.
          ENDIF.
         ENDSELECT.
      WHEN 'INT4'.
        VAR = 0.
        SELECT
               (WA_DD03L-FIELDNAME)
               FROM (WA_DD03L-TABNAME)
               INTO L_INIT.
          IF L_CHAR IS NOT INITIAL.
            VAR = VAR + 1.
          ENDIF.
         ENDSELECT.
      WHEN 'LANG'.
        VAR = 0.
        SELECT
               (WA_DD03L-FIELDNAME)
               FROM (WA_DD03L-TABNAME)
               INTO L_CHAR.
          IF L_CHAR IS NOT INITIAL.
            VAR = VAR + 1.
          ENDIF.
         ENDSELECT.
      WHEN 'NUMC'.
        VAR = 0.
        SELECT
               (WA_DD03L-FIELDNAME)
               FROM (WA_DD03L-TABNAME)
               INTO L_NUM.
          IF L_CHAR IS NOT INITIAL.
            VAR = VAR + 1.
          ENDIF.
         ENDSELECT.
      WHEN 'QUAN'.
        VAR = 0.
        SELECT
               (WA_DD03L-FIELDNAME)
               FROM (WA_DD03L-TABNAME)
               INTO L_QUAN.
          IF L_CHAR IS NOT INITIAL.
            VAR = VAR + 1.
          ENDIF.
         ENDSELECT.
      WHEN 'TIMS'.
        VAR = 0.
        SELECT
               (WA_DD03L-FIELDNAME)
               FROM (WA_DD03L-TABNAME)
               INTO L_TIM.
          IF L_CHAR IS NOT INITIAL.
            VAR = VAR + 1.
          ENDIF.
         ENDSELECT.
      WHEN 'UNIT'.
        VAR = 0.
        SELECT
               (WA_DD03L-FIELDNAME)
               FROM (WA_DD03L-TABNAME)
               INTO L_UNIT.
          IF L_CHAR IS NOT INITIAL.
            VAR = VAR + 1.
          ENDIF.
         ENDSELECT.
    ENDCASE.
     READ TABLE LINE INTO WA_LINE INDEX 1 .
    WRITE:/ WA_DD03L-FIELDNAME,VAR.
    L_COUNT = L_COUNT + 1 .
  ENDLOOP.
   WRITE:/ 'no of feild:', L_COUNT.
ENDFORM.                    " TABLE_ENTRIES
*&---------------------------------------------------------------------*
*&      Form  F4_HELP_FILE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM F4_HELP_FILE .
   DATA: L_FOLDER TYPE STRING.
  CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_BROWSE
    EXPORTING
      WINDOW_TITLE         = 'Select Folder'
      INITIAL_FOLDER       = 'C:\'
    CHANGING
      SELECTED_FOLDER      = L_FOLDER
    EXCEPTIONS
      CNTL_ERROR           = 1
      ERROR_NO_GUI         = 2
      NOT_SUPPORTED_BY_GUI = 3
      OTHERS               = 4.
  IF SY-SUBRC = 0.
    P_FILE = L_FOLDER.
  ENDIF.
 ENDFORM.                    " F4_HELP_FILE

  • No labels