Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Program for Excel upload and download

Former Member
0 Likes
749

Hi Experts,

I have an Excel sheet with almost 5000 records with 2 columns.

I need to get the distinct combinations of the records of these.

I need to check only the last 2 charecters of the 1st column

and the value in the 2nd column when comparing.

Again the result needs to be downloaded into an Excel.

Please let me know if there is already an program existing for teh same.

Thanks,

Varun

Hi Experts,

I have an Excel sheet with almost 5000 records with 2 columns.

I need to get the distinct combinations of the records of these.

I need to check only the last 2 charecters of the 1st column

and the value in the 2nd column when comparing.

Again the result needs to be downloaded into an Excel.

Please let me know if there is already an program existing for teh same.

Thanks,

Varun

5 REPLIES 5
Read only

Former Member
0 Likes
717

Hi Varun .,

Get the Data into Itab1 which has two fields similar to the excel file .

then loop the itab1 .

convert the itab1-field1 to its SAP data type .

compare the last 2 digits if yes push the record to ITAB2 (which again have the same structure as ITAB1)

down load the the itab2 to excel file that you want as output .

thanks

Sreenivas Reddy

Read only

Former Member
0 Likes
717

Hi,

For excel upload

try the code

TYPE-POOLS truxs.
 
types: begin of t_tab,
col1(5) type c,
col2(5) type c,
col3(5) type c,
end of t_tab.
data : itab type standard table of t_tab,
wa type t_tab.
 
data it_type type truxs_t_text_data.
 
parameter p_file type rlgrap-filename.
data ttab type tabname.
 
at selection-screen on value-request for p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
 
    * PROGRAM_NAME = SYST-CPROG
    * DYNPRO_NUMBER = SYST-DYNNR
 
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = p_file
.
 
start-of-selection.
 
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
 
    * I_FIELD_SEPERATOR =
    * I_LINE_HEADER = 'X'
 
i_tab_raw_data = it_type
i_filename = p_file
tables
i_tab_converted_data = itab[]
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
 
end-of-selection.
 
loop at itab into wa.
write : wa-col1.
write : wa-col2.
write : wa-col3.
endloop.

For download to an .exl file

REPORT ZTESTPROG003.

TYPES:
BEGIN OF ty_upload,
matnr like mara-matnr,
meins like mara-meins,
mtart like mara-mtart,
mbrsh like mara-mbrsh,
END OF ty_upload.

DATA it_upload TYPE STANDARD TABLE OF ty_upload WITH header line.
DATA wa_upload TYPE ty_upload.
DATA: itab TYPE STANDARD TABLE OF alsmex_tabline WITH header line.


CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = 'C:\Documents and Settings\venkatapp\Desktop\venkat.xls'
i_begin_col = 1
i_begin_row = 1
i_end_col = 4
i_end_row = 65535
TABLES
intern = itab.

if not itab[] is initial.
loop at itab .
case itab-col.
when '0001'.
it_upload-matnr = itab-value.
when '0002'.
it_upload-meins = itab-value.
when '0003'.
it_upload-mtart = itab-value.
when '0004'.
it_upload-mbrsh = itab-value.
append it_upload.
clear it_upload.
clear itab.
endcase.

Regards,

Anirban

Read only

Former Member
0 Likes
717

Have you attempted to help yourself yet and looked at the SAP examples for excel output?. Try searching for these programs.

Failing that search for FM "ALSM_EXCEL_TO_INTERNAL_TABLE" to read an Excel file

And

FM 'GUI_DOWNLOAD' to output to Excel, although you may have to format the filename correctly for this to work.

There are also samples, using both of these that can be found using a google search.

Gary

Read only

Former Member
0 Likes
717

hi,

Use the FM 'WS_UPLOAD' .

data : itab type VBAK OCCURS 0 WITH HEADER LINE.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = 'ABC.TXT'

FILETYPE = 'ASC'

TABLES

data_tab = itab

Read only

Former Member
0 Likes
717

hi,

Use the FM 'WS_UPLOAD' .

data : itab type VBAK OCCURS 0 WITH HEADER LINE.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = 'ABC.TXT'

FILETYPE = 'ASC'

TABLES

data_tab = itab