Application Development 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: 

'ALSM__EXCEL_TO_INTERNALTABLE'

Former Member
0 Kudos

i use the FM 'ALSM__EXCEL_TO_INTERNALTABLE' .

My only and strange problem is that when i execute the report i take the notification that i must save my excel file !!!!

I don't open the file for writing !!!! Look my code to see what happens ...

REPORT YDP_EXAG_TRAP .

TYPE-POOLS TRUXS.

TABLES : YREPORTS.

DATA: BEGIN OF ITAB OCCURS 0 ,

REPORTNR

LIKE YREPORTS-REPORTNR,

SALESMAN

LIKE YREPORTS-SALESMAN,

TITLE

LIKE YREPORTS-TITLE,

REPCAT

LIKE YREPORTS-REPCAT,

CDATE

LIKE YREPORTS-CDATE,

TR_DATE

LIKE YREPORTS-TR_DATE,

VI_DATE

LIKE YREPORTS-VI_DATE,

SOFIA

LIKE YREPORTS-SOFIA,

SOF_HAL

LIKE YREPORTS-SOF_HAL,

FILENAME

LIKE YREPORTS-FILENAME,

LAND1

LIKE YREPORTS-LAND1,

KUNNR

LIKE YREPORTS-KUNNR,

TR_DATE1

LIKE YREPORTS-TR_DATE1,

NEW_CUST

LIKE YREPORTS-NEW_CUST,

RADIO,

END OF ITAB.

DATA:

W_CHK LIKE ALSMEX_TABLINE-VALUE.

DATA : MYITAB LIKE TABLE OF ALSMEX_TABLINE WITH HEADER LINE.

*DATA : MYITAB LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.

PARAMETERS : S_FILE LIKE RLGRAP-FILENAME.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_FILE.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

STATIC

= 'X'

CHANGING

FILE_NAME = S_FILE.

START-OF-SELECTION.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

FILENAME

= S_FILE

I_BEGIN_COL

= 1

I_BEGIN_ROW

= 1

I_END_COL

= 19

I_END_ROW

= 19

TABLES

INTERN

= MYITAB

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE

= 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.

LOOP AT MYITAB.

CASE MYITAB-ROW.

WHEN '2'.

CASE MYITAB-COL.

WHEN '1'.

MOVE MYITAB-VALUE TO ITAB-REPORTNR.

WHEN '3'.

MOVE MYITAB-VALUE TO ITAB-SALESMAN.

WHEN '7'.

MOVE MYITAB-VALUE TO ITAB-TITLE.

ENDCASE.

WHEN '7'.

CASE MYITAB-COL.

WHEN '1'.

MOVE MYITAB-VALUE TO ITAB-CDATE.

WHEN '6'.

MOVE MYITAB-VALUE TO ITAB-REPCAT.

ENDCASE.

WHEN '10'.

CASE MYITAB-COL.

WHEN '1'.

MOVE MYITAB-VALUE TO ITAB-TR_DATE.

WHEN '6'.

MOVE MYITAB-VALUE TO ITAB-REPCAT.

ENDCASE.

WHEN '13'.

CASE MYITAB-COL.

WHEN '1'.

MOVE MYITAB-VALUE TO ITAB-TR_DATE1.

ENDCASE.

WHEN '14'.

CASE MYITAB-COL.

WHEN '1'.

MOVE MYITAB-VALUE TO ITAB-TR_DATE1.

WHEN '4'.

MOVE MYITAB-VALUE TO W_CHK.

ENDCASE.

WHEN '19'.

CASE MYITAB-COL.

WHEN '1'.

MOVE MYITAB-VALUE TO ITAB-NEW_CUST.

ENDCASE.

ENDCASE.

ENDLOOP.

APPEND ITAB.

END-OF-SELECTION.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

If you want to change a standard code, you could make a copy of

the program, includes, dynpros, and associated stuff. (Just run se38

and select the copy button in the toolbar). Although you can do it at

your own risk, just let me warn you that this isn't a good practice at

all, as you don't have standard support over this changed code.

A better approach is to write your own program (or ask an abaper to do

so). This new program (custom program) should meet your specifications

Cheers,

Chaitanya.

3 REPLIES 3

Former Member
0 Kudos

Hi Haresha,

The problem occurs when i try to upload the same ( downloaded file ) using

ALSM_EXCEL_TO_INTERNAL_TABLE

However if the downloaded file is opened and then saved in the proper excel format the the FM :ALSM_EXCEL_TO_INTERNAL_TABLE seems to function as expected.

pls. try FM MS_EXCEL_OLE_STANDARD_DAT!

Also,

We can down load in the EXCEL format directly using the Download or GUI_DOWNLOAD Function module..

But there are some problems in it..

If u only downloading less fields having small data length means it is ok when we download in EXCEL sheet..When there are more fields with many data length means it will be not advisable to use excel directly..

For that purpose we want to use .dbf format..This is a format for Foxpro database structure..So when u give download func. mod,u can choose the file type as dbf..

But u want to install Foxpro..Tell Basis people to do that..It will be very effective..From there we can covert to excel sheet format.

And you can check this FM,

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

  • I_FIELD_SEPERATOR =

  • i_line_header = ''

i_tab_raw_data = it_raw " WORK TABLE

i_filename = l_fname

TABLES

i_tab_converted_data = i_tab "ACTUAL DATA

EXCEPTIONS

conversion_failed = 1

OTHERS = 2.

Reward points if it is useful.

cheers,

Hema.

Former Member
0 Kudos

EXCEL to INTERNAL table and then to APPLICATION SERVER

&----


*& Report ZSD_EXCEL_INT_APP

*&

&----


*&

*&

&----


REPORT ZSD_EXCEL_INT_APP.

parameter: file_nm type localfile.

types : begin of it_tab1,

f1(20),

f2(40),

f3(20),

end of it_tab1.

data : it_tab type table of ALSMEX_TABLINE with header line,

file type rlgrap-filename.

data : it_tab2 type it_tab1 occurs 1,

wa_tab2 type it_tab1,

w_message(100) TYPE c.

at selection-screen on value-request for file_nm.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

  • PROGRAM_NAME = SYST-REPID

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

STATIC = 'X'

  • MASK = ' '

CHANGING

file_name = file_nm

EXCEPTIONS

MASK_TOO_LONG = 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.

start-of-selection.

refresh it_tab2[].clear wa_tab2.

file = file_nm.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = file

i_begin_col = '1'

i_begin_row = '1'

i_end_col = '10'

i_end_row = '35'

tables

intern = it_tab

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 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.

loop at it_tab.

case it_tab-col.

when '002'.

wa_tab2-f1 = it_tab-value.

when '004'.

wa_tab2-f2 = it_tab-value.

when '008'.

wa_tab2-f3 = it_tab-value.

endcase.

at end of row.

append wa_tab2 to it_tab2.

clear wa_tab2.

endat.

endloop.

data : p_file TYPE rlgrap-filename value 'TEST3.txt'.

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

*--- Display error messages if any.

IF sy-subrc NE 0.

MESSAGE e001(zsd_mes).

EXIT.

ELSE.

*---Data is downloaded to the application server file path

LOOP AT it_tab2 INTO wa_tab2.

TRANSFER wa_tab2 TO p_file.

ENDLOOP.

ENDIF.

*--Close the Application server file (Mandatory).

CLOSE DATASET p_file.

loop at it_tab2 into wa_tab2.

write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.

endloop.

Former Member
0 Kudos

If you want to change a standard code, you could make a copy of

the program, includes, dynpros, and associated stuff. (Just run se38

and select the copy button in the toolbar). Although you can do it at

your own risk, just let me warn you that this isn't a good practice at

all, as you don't have standard support over this changed code.

A better approach is to write your own program (or ask an abaper to do

so). This new program (custom program) should meet your specifications

Cheers,

Chaitanya.