0% found this document useful (0 votes)
130 views

How To Download Excel File With Password Protection

This report reads material master data from the MAKT table and exports it along with header fields to an Excel file. It uses a selection screen parameter to allow the user to browse and select the target Excel file. The material data and header fields are then passed to the EXCEL_OLE_STANDARD_DAT function which exports them to the selected file.

Uploaded by

EEE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
130 views

How To Download Excel File With Password Protection

This report reads material master data from the MAKT table and exports it along with header fields to an Excel file. It uses a selection screen parameter to allow the user to browse and select the target Excel file. The material data and header fields are then passed to the EXCEL_OLE_STANDARD_DAT function which exports them to the selected file.

Uploaded by

EEE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

REPORT ztest.

4  
5 DATA : BEGIN OF li_makt OCCURS 0,
6          matnr TYPE matnr,
7          maktx TYPE maktx,
8        END OF li_makt.
9  
10 DATA: BEGIN OF li_head OCCURS 0,
11         field(30) TYPE c,
12       END OF li_head.
13  
14 SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE TEXT-002.
15 PARAMETERS:
16   p_file TYPE rlgrap-filename OBLIGATORY.
17 SELECTION-SCREEN END OF BLOCK b2.
18  
19 AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
20   PERFORM browse_file CHANGING p_file.
21  
22 START-OF-SELECTION.
23  
24   REFRESH li_head.
25  
26   DEFINE mc_head.
27     li_head-field = &1.
28     APPEND li_head.
29   END-OF-DEFINITION.
30  
31   SELECT matnr maktx INTO TABLE li_makt FROM makt UP TO 20 ROWS WHERE spras = sy-langu .
32  
33   mc_head : 'Material No', 'Material Description'.
34  
35   CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
36     EXPORTING
37       file_name                 = p_file
38       create_pivot              = 0
39       data_sheet_name           = 'Data Material'
40       pivot_sheet_name          = ' '
41       password                  = 'plazapp'
42       password_option           = 1
43     TABLES
44       data_tab                  = li_makt
45       fieldnames                = li_head
46     EXCEPTIONS
47       file_not_exist            = 1
48       filename_expected         = 2
49       communication_error       = 3
50       ole_object_method_error   = 4
51       ole_object_property_error = 5
52       invalid_filename          = 6
53       invalid_pivot_fields      = 7
54       download_problem          = 8
55       OTHERS                    = 9.
56   IF sy-subrc <> 0.
57     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
58             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
59   ENDIF.
60  
61  
62 FORM browse_file CHANGING p_file LIKE rlgrap-filename.
63   DATA: filetab   TYPE filetable,
64         rc        TYPE i,
65         lv_offset TYPE i.
66  
67   FREE filetab.
68   CALL METHOD cl_gui_frontend_services=>file_open_dialog
69     EXPORTING
      window_title            = 'Choose File'
70       default_extension       = '*.*'
71       default_filename        = 'c:\*.xls'
72     CHANGING
73       file_table              = filetab
74       rc                      = rc
75     EXCEPTIONS
76       file_open_dialog_failed = 1
77       cntl_error              = 2
78       error_no_gui            = 3
79       OTHERS                  = 4.
80   IF sy-subrc = 0.
81     READ TABLE filetab INTO p_file INDEX 1.
82   ENDIF.
ENDFORM. " browse_file

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy