Michael's profileAt world's endBlogGuestbookNetwork Tools Help

Blog


    October 29

    利用Excel显示数据

    REPORT  zrs08056        .

    TABLES: t001,dd02l.
    DATA: zx030l LIKE x030l.
    DATA BEGIN OF zdfies OCCURS 0.
            INCLUDE STRUCTURE dfies.
    DATA END OF zdfies.
    DATA: BEGIN OF flditab OCCURS 0,
          fldname(11) TYPE c,
          END OF flditab.
    DATA itabt001 LIKE t001 OCCURS 0 WITH HEADER LINE.
    DATA tname LIKE dd02l-tabname.

    START-OF-SELECTION.
      SELECT * FROM t001 INTO TABLE itabt001.
      tname = 'T001'.
      PERFORM getfieleds.
      PERFORM showdata.

    *&---------------------------------------------------------------------*
    *&      Form  GETFIELEDS
    *&---------------------------------------------------------------------*
    FORM getfieleds.
      CALL FUNCTION 'GET_FIELDTAB'
        EXPORTING
          langu               = sy-langu
          only                = space
          tabname             = tname
          withtext            = 'X'
        IMPORTING
          header              = zx030l
        TABLES
          fieldtab            = zdfies
        EXCEPTIONS
          internal_error      = 01
          no_texts_found      = 02
          table_has_no_fields = 03
          table_not_activ     = 04.
      CASE sy-subrc.
        WHEN 0.
          LOOP AT zdfies.
            flditab-fldname = zdfies-fieldname.
            APPEND flditab.
          ENDLOOP.
        WHEN OTHERS.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
           WITH  sy-subrc.
      ENDCASE.
    ENDFORM.                    "GETFIELEDS

    *&---------------------------------------------------------------------*
    *&      Form  SHOWdata
    *&---------------------------------------------------------------------*
    FORM showdata.
      CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
        EXPORTING
          file_name                 = 'C:\T001.XLS'
          data_sheet_name           = 'USER LIST'
        TABLES
          data_tab                  = itabt001
          fieldnames                = flditab
        EXCEPTIONS
          file_not_exist            = 1
          filename_expected         = 2
          communication_error       = 3
          ole_object_method_error   = 4
          ole_object_property_error = 5
          invalid_filename          = 6
          invalid_pivot_fields      = 7
          download_problem          = 8
          OTHERS                    = 9.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.           

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://mc272762202.spaces.live.com/blog/cns!B08E7EC9F9BDB327!650.trak
    Weblogs that reference this entry
    • None