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

function module -upload(excel sheet)

Former Member
0 Likes
577

the excel sheet is in presentation server ineed to upload that in application server.what is function module for 4.5 version.

4 REPLIES 4
Read only

Former Member
0 Likes
540

hI

USE THIS FM

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = filename

i_begin_col = begcol

i_begin_row = begrow

i_end_col = endcol

i_end_row = endrow

TABLES

intern = intern

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

OTHERS = 3.

IF sy-subrc <> 0.

WRITE:/ 'Upload Error ', SY-SUBRC.

ENDIF.

SEE THE SAMPLE PROGRAM IN

http://www.sap-img.com/abap/upload-direct-excel.htm

Message was edited by: Harikishore Sreenivasulu

Read only

Former Member
0 Likes
540

Hi,

You can use ws_upload.

or you canuse this <b>KCD_EXCEL_OLE_TO_INT_CONVERT</b> in 4.5 it is there

check that..

regards

vijay

Read only

Former Member
0 Likes
540

Hi franklin,

1. The problem with the standard Excel FMs is :

The data is uploaded CELL Wise

Row - Col - Value

Row - Col - Value

Row - Col - Value

Row - Col - Value

It does not function like GUI_UPLOAD

(Straight away in to the table)

2. So, we need to ALSO CONVERT the

above format of data,

into our normal internal table.

(using some abap code/syntax/logic)

3. use this code (just copy paste in new program)

IT uploades an EXCEL File.

It converts the data into T001 format

(any format can be handled by it)

4. REPORT abc.

*----


DATA : ex LIKE TABLE OF alsmex_tabline WITH HEADER LINE.

DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.

DATA : cmp LIKE TABLE OF rstrucinfo WITH HEADER LINE.

DATA : col TYPE i.

DATA : col1 TYPE i.

FIELD-SYMBOLS : <fs> .

DATA : fldname(50) TYPE c.

*----


CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = 'd:\def.xls'

i_begin_col = 1

i_begin_row = 1

i_end_col = 100

i_end_row = 100

TABLES

intern = ex

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

OTHERS = 3.

BREAK-POINT.

*----


CALL FUNCTION 'GET_COMPONENT_LIST'

EXPORTING

program = sy-repid

fieldname = 'T001'

TABLES

components = cmp.

*----


LOOP AT ex.

AT NEW row.

IF sy-tabix <> 1.

APPEND t001.

CLEAR t001.

ENDIF.

ENDAT.

col = ex-col.

col1 = col + 1.

READ TABLE cmp INDEX col.

CONCATENATE 'T001-' cmp-compname INTO fldname.

ASSIGN (fldname) TO <fs>.

<fs> = ex-value.

ENDLOOP.

BREAK-POINT.

regards,

amit m.

Read only

Former Member
0 Likes
540

Hi Franklin,

You can use the func 'KCD_EXCEL_OLE_TO_INT_CONVERT'

in 4.5B version.See my below sample code.

[code]

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

  • DATA TO CREATE AND HOLD INTERNAL TABLE FROM EXCEL

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

DATA : $I_INTERN TYPE KCDE_CELLS OCCURS 0 WITH HEADER LINE.

DATA : $V_INDEX TYPE I.

DATA : $V_START_COL TYPE I VALUE '1',

$V_START_ROW TYPE I VALUE '1',

$V_END_COL TYPE I VALUE '256',

$V_END_ROW TYPE I VALUE '65536'.

FIELD-SYMBOLS : <$FS>.

DATA: P_RC LIKE SY-SUBRC.

DATA: BEGIN OF P_TAB OCCURS 0,

PERNR(8) TYPE C,

END OF P_TAB.

DATA: Q-BEGDA LIKE SY-DATUM,

Q-ENDDA LIKE SY-DATUM.

CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'

EXPORTING

FILENAME = FNAME-S

I_BEGIN_COL = $V_START_COL

I_BEGIN_ROW = $V_START_ROW

I_END_COL = $V_END_COL

I_END_ROW = $V_END_ROW

TABLES

INTERN = $I_INTERN

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 2.

MOVE : SY-SUBRC TO P_RC.

IF SY-SUBRC NE 0.

WRITE:

'FILE CANNOT BE OPENED. REASON: FILE OR DIRECTORY DOES NOT EXIST'.

EXIT.

ELSE.

CHECK NOT $I_INTERN[] IS INITIAL.

SORT $I_INTERN BY ROW COL.

LOOP AT $I_INTERN.

MOVE : $I_INTERN-COL TO $V_INDEX.

ASSIGN COMPONENT $V_INDEX OF STRUCTURE P_TAB TO <$FS>.

MOVE : $I_INTERN-VALUE TO <$FS>.

AT END OF ROW.

APPEND P_TAB.

CLEAR P_TAB.

ENDAT.

ENDLOOP.

ENDIF.

[/code]

Hope this will help you.

Thanks&Regards,

Siri.