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

upload data from excel

Former Member
0 Likes
920

when using FM ALSM_EXCEL_TO_INTERNAL_TABLE i am getting dump.i have given all parameters correctly.can anybody tell y i am getting this dump???????

7 REPLIES 7
Read only

Former Member
Read only

manubhutani
Active Contributor
0 Likes
862

hi

what error you are getting inthe dump

study it and tell me the code you have written

Please reward points

Read only

Former Member
0 Likes
862

Hi,

try with FM "TEXT_CONVERT_XLS_TO_SAP". might be this can solve your problem.

Reward if helpfull.

Amit.

Read only

Former Member
0 Likes
862

Hi ,

Read this brief des with example

How can I read an Excel file from presentation server?

You can use the Function module ALSM_EXCEL_TO_INTERNAL_TABLE to read the Excel file into the internal table of type alsmex_tabline.

From this internal table you can fill the target internal table.

TYPES:

BEGIN OF ty_upload,

field1 TYPE c length 12,

field2 TYPE c length 12,

field3 TYPE c length 12,

END OF ty_upload.

DATA it_upload TYPE STANDARD TABLE OF ty_upload WITH DEFAULT KEY.

DATA wa_upload TYPE ty_upload.

DATA itab TYPE STANDARD TABLE OF alsmex_tabline WITH DEFAULT KEY.

FIELD-SYMBOLS: <wa> type alsmex_tabline.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = filename

i_begin_col = 1

i_begin_row = 1

i_end_col = 3

i_end_row = 65535

TABLES

intern = itab.

LOOP AT itab ASSIGNING <wa>.

CASE <wa>-col.

WHEN '0001'.

wa_upload-field1 = <wa>-value.

WHEN '0002'.

wa_upload-field2 = <wa>-value.

WHEN '0003'.

wa_upload-field3 = <wa>-value.

ENDCASE.

APPEND wa_upload TO it_upload.

CLEAR wa_upload.

ENDLOOP.

Reward points if usefull,

Regards

Fareedas

Read only

Former Member
0 Likes
862

hi,

i think the problem is that internal table you are passing to the function module is wrong. you once try with this.

for example : declare another internal table as below.

Data: itab1 like Alsmex_tabline occurs 0 with header line.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

FILENAME = FILEPATH

I_BEGIN_COL = 1

I_BEGIN_ROW = 1

I_END_COL = 8 I_END_ROW = 4

TABLES

INTERN = ITAB1

sort itab1 by row col.

loop at itab1.

case itab1-col.

when 1.

w_itab-lifnr = itab1-value.

when 2.

w_itab1-ktokk = itab1-value.

when 3.

w_itab1-name1 = itab1-value.

endcase.

at end of row.

append w_itab to i_itab.

clear w_itab.

endat.

perform that when condition to how many fileds you declared.

reward marks if useful.

Read only

Former Member
0 Likes
862

Hi...

Generally the short dump comes if we try to upload some other format file except excel.

I had made a code to upload excel file from the presentation layer::

Kindly look into it..if it helps.If your problem still exists let me know.

code::

U can just copy paste this code..hope it will help u.

TYPES:BEGIN OF ty_itab ,

objecttype TYPE string,

objectname TYPE string,

END OF ty_itab.

DATA:

count TYPE i,

file TYPE ibipparms-path,

iexcel TYPE TABLE OF alsmex_tabline ,

wa_itab TYPE ty_itab,

itab type standard table of ty_itab,

wa_iexcel TYPE alsmex_tabline.

field-symbols : <fs> type string.

*Calling function module to get file path from PC

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

IMPORTING

file_name = file.

*Calling function module to upload excel sheet

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = file

i_begin_col = 1

i_begin_row = 1

i_end_col = 2

i_end_row = 65000

TABLES

intern = iexcel

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

OTHERS = 3.

IF sy-subrc <> 0.

WRITE :/15 'FILE NOT UPLOADED. INVALID FILE NAME OR PATH.' COLOR 6 .

EXIT.

ENDIF.

LOOP AT iexcel INTO wa_iexcel.

count = count + 1.

ASSIGN COMPONENT count OF STRUCTURE wa_itab TO <fs>.

<fs> = wa_iexcel-value.

AT END OF row.

CLEAR count.

APPEND wa_itab TO itab.

ENDAT.

CLEAR wa_iexcel.

ENDLOOP.

loop at itab into wa_itab.

Write : / wa_itab-objectname ,wa_itab-objecttype.

endloop.

please reward if helpful.

Read only

Former Member
0 Likes
862

Hi Radhika,

Try this way it may be helpful to you.

report zbdc_mm01 no standard page heading line-size 255.

&----


  • table declaration *

&----


tables : rmmg1,

mlgn,

mlgt.

&----


  • Internal table declaration *

&----


types: begin of typ_out,

matnr type rmmg1-matnr, " Material Number

mbrsh type rmmg1-mbrsh, "Industry Sector

mtart type rmmg1-mtart, "Material Type

werks type rmmg1-werks, "Plant

lgnum type rmmg1-lgnum, "Ware House Number

lgtyp type rmmg1-lgtyp, "Storage type

**********************************************

  • maktx type makt-maktx, "material description

  • meins type mara-meins, "base unit of measure

**********************************************

ltkza type mlgn-ltkza, "Storage type indicator for stock removal

ltkze type mlgn-ltkze, "Storage type indicator for stock placement

lgpla type mlgt-lgpla, "Storage Bin

end of typ_out.

data: ta_mm01 type standard table of typ_out initial size 0,

wa_mm01 type typ_out.

data: ta_excel type standard table of alsmex_tabline initial size 0,

wa_excel type alsmex_tabline.

        • for Material Master data Upload.

data: ta_bdcdata type standard table of bdcdata ,

wa_bdcdata type bdcdata,

ta_bdcmessage type table of bdcmsgcoll,

wa_bdcmessage type bdcmsgcoll.

data: tp_currentrow type i.

constants : cn_batch(4) type c value 'MM01',

cn_tcode(4) type c value 'MM01' .

----


  • Selection screen *

----


selection-screen begin of block session_process with frame title text-001.

parameter: pa_file type rlgrap-filename obligatory. "File Name

selection-screen end of block session_process.

----


  • At Selection screen *

----


at selection-screen on value-request for pa_file.

call function 'F4_FILENAME'

exporting

field_name = 'PA_FILE'

importing

file_name = pa_file.

----


  • Start of selection *

----


start-of-selection.

perform upload.

perform bdc_open.

perform bdc_screens .

perform bdc_close.

call transaction 'SM35'.

&----


*& Form UPLOAD

&----


form upload .

call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

exporting

filename = pa_file

i_begin_col = 1

i_begin_row = 1

i_end_col = 255

i_end_row = 65000

tables

intern = ta_excel

exceptions

inconsistent_parameters = 1

upload_ole = 2

others = 3.

if sy-subrc <> 0.

  • MESSAGE E000 WITH TEXT-E01 PA_FILE.

endif.

  • Sorting table by Rows and Columns.

sort ta_excel by row col.

  • Get ROW 1.

read table ta_excel into wa_excel index 1.

  • Match First Row to Current Row

tp_currentrow = wa_excel-row.

loop at ta_excel into wa_excel.

  • Reset Values for Next Row

if wa_excel-row ne tp_currentrow.

append wa_mm01 to ta_mm01.

clear wa_mm01.

tp_currentrow = wa_excel-row.

endif.

case wa_excel-col.

when'0001'.

wa_mm01-matnr = wa_excel-value.

when'0002'.

wa_mm01-mbrsh = wa_excel-value.

when'0003'.

wa_mm01-mtart = wa_excel-value.

when'0004'.

wa_mm01-werks = wa_excel-value.

when'0005'.

wa_mm01-lgnum = wa_excel-value.

when'0006'.

wa_mm01-lgtyp = wa_excel-value.

*********************************************************

  • when'0007'.

  • wa_mm01-maktx = wa_excel-value.

  • when'0008' .

  • wa_mm01-meins = wa_excel-value.

*

  • when'0009'.

  • wa_mm01-ltkza = wa_excel-value.

  • when'0010'.

  • wa_mm01-ltkze = wa_excel-value.

*

  • when'0011'.

  • wa_mm01-lgpla = wa_excel-value.

********************************************************

when'0007'.

wa_mm01-ltkza = wa_excel-value.

when'0008'.

wa_mm01-ltkze = wa_excel-value.

when'0009'.

wa_mm01-lgpla = wa_excel-value.

endcase.

endloop.

append wa_mm01 to ta_mm01.

endform. " UPLOAD

&----


*& Form BDC_OPEN

&----


form bdc_open .

  • TP_TIMEA = SY-UZEIT.

call function 'BDC_OPEN_GROUP'

exporting

client = sy-mandt

group = 'MM01'

user = sy-uname

keep = 'X'.

endform. "BDC_OPEN

&----


*& Form BDC_SCREENS

&----


form bdc_screens.

loop at ta_mm01 into wa_mm01.

refresh ta_bdcdata.

perform bdc_dynpro using 'SAPLMGMM' '0060'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-MATNR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RMMG1-MATNR'

wa_mm01-matnr.

perform bdc_field using 'RMMG1-MBRSH'

wa_mm01-mbrsh.

perform bdc_field using 'RMMG1-MTART'

wa_mm01-mtart.

perform bdc_dynpro using 'SAPLMGMM' '0070'.

perform bdc_field using 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(01)'.

perform bdc_field using 'BDC_OKCODE'

'=P+'.

perform bdc_dynpro using 'SAPLMGMM' '0070'.

perform bdc_field using 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(04)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'MSICHTAUSW-KZSEL(03)'

'X'.

perform bdc_field using 'MSICHTAUSW-KZSEL(04)'

'X'.

perform bdc_dynpro using 'SAPLMGMM' '0080'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-LGTYP'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'RMMG1-WERKS'

wa_mm01-werks.

perform bdc_field using 'RMMG1-LGNUM'

wa_mm01-lgnum.

perform bdc_field using 'RMMG1-LGTYP'

wa_mm01-lgtyp.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=SP22'.

*************************************************************

perform bdc_field using 'BDC_CURSOR'

'MAKT-MAKTX'.

            • sri *************

  • perform bdc_field using 'MAKT-MAKTX'

  • WA_MM01-MAKTX.

  • perform bdc_field using 'MARA-MEINS'

  • WA_MM01-MEINS.

perform bdc_field using 'MLGN-LTKZA'

wa_mm01-ltkza.

perform bdc_field using 'MLGN-LTKZE'

wa_mm01-ltkze.

perform bdc_dynpro using 'SAPLMGMM' '4000'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_field using 'MAKT-MAKTX'

'ROH-ZZ03'.

perform bdc_field using 'BDC_CURSOR'

'MLGT-LGPLA'.

perform bdc_field using 'MLGT-LGPLA'

wa_mm01-lgpla.

*****************************************************

  • perform bdc_field using 'BDC_CURSOR'

  • 'MLGN-LTKZA'.

  • perform bdc_field using 'MLGN-LTKZA'

  • wa_mm01-ltkza.

  • perform bdc_field using 'MLGN-LTKZE'

  • wa_mm01-ltkze.

*

*

  • perform bdc_dynpro using 'SAPLMGMM' '4000'.

  • perform bdc_field using 'BDC_OKCODE'

  • '=BU'.

  • perform bdc_field using 'MAKT-MAKTX'

  • 'ROH-ZZ03'.

  • perform bdc_field using 'BDC_CURSOR'

  • 'MLGT-LGPLA'.

  • perform bdc_field using 'MLGT-LGPLA'

  • wa_mm01-lgpla.

call function 'BDC_INSERT'

exporting

tcode = 'MM01'

tables

dynprotab = ta_bdcdata.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

endloop.

endform. "bdc_screens

&----


*& Form BDC_INSERT

&----


*form bdc_insert tables ta_bdcdata. " using cn_tcode.

    • clear wa_bdcdata.

  • call function 'BDC_INSERT'

  • exporting

  • tcode = 'MM01'

  • tables

  • dynprotab = ta_bdcdata.

*

  • Refresh ta_bdcdata.

*

*endform. "BDC_INSERT

&----


*& Form bdc_dynpro

&----


form bdc_dynpro using program type sy-repid

dynpro type any.

wa_bdcdata-program = program.

wa_bdcdata-dynpro = dynpro.

wa_bdcdata-dynbegin = 'X'.

append wa_bdcdata to ta_bdcdata.

clear wa_bdcdata.

endform. "bdc_dynpro

&----


*& Form bdc_field

&----


form bdc_field using fnam type any

fval type any.

  • IF FVAL <> ''.

wa_bdcdata-fnam = fnam.

wa_bdcdata-fval = fval.

append wa_bdcdata to ta_bdcdata.

clear wa_bdcdata.

  • ENDIF.

endform. "bdc_field

&----


*& Form BDC_CLOSE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form bdc_close .

call function 'BDC_CLOSE_GROUP'.

  • FORMAT COLOR 5.

  • WRITE: / TEXT-T01, TP_BATCH.

  • WRITE: TEXT-T02.

  • FORMAT RESET.

endform. "BDC_CLOSE