2006 Sep 07 9:41 AM
Hi Experts,
I have tried uploading the data from a excel sheet to internal table using the Function Module 'ALSM_EXCEL_TO_INTERNAL_TABLE',but this is throwing a type conflict error.
Ex:
data: IEXCEL like alsmex_tabline occurs 0 with header line.
PARAMETER p_file like rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM Pres_List USING p_file.
FORM Pres_List USING p_presl TYPE ibipparms-path.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
STATIC = ' '
MASK = ' '
CHANGING
FILE_NAME = p_file
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
*To upload the data.
DATA:w_preup1 TYPE STRING.
w_preup1 = p_file.
PERFORM Pres_Upload USING w_preup1 t_main.
FORM Pres_Upload USING p_upload TYPE string p_upload_table TYPE table.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_upload
i_begin_col = 1
i_begin_row = 1
i_end_col = 26
i_end_row = 65000
tables
intern = IEXCEL
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.
EXIT.
ENDIF.
ENDIF.
...Type conflict is for p_upload in the Function Module.
Can someone help me out with this.
Thanks in advance.
Shilpa
Hi Experts,
I have tried uploading the data from a excel sheet to internal table using the Function Module 'ALSM_EXCEL_TO_INTERNAL_TABLE',but this is throwing a type conflict error.
Ex:
data: IEXCEL like alsmex_tabline occurs 0 with header line.
PARAMETER p_file like rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM Pres_List USING p_file.
FORM Pres_List USING p_presl TYPE ibipparms-path.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = SYST-REPID
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
STATIC = ' '
MASK = ' '
CHANGING
FILE_NAME = p_file
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
*To upload the data.
DATA:w_preup1 TYPE STRING.
w_preup1 = p_file.
PERFORM Pres_Upload USING w_preup1 t_main.
FORM Pres_Upload USING p_upload TYPE string p_upload_table TYPE table.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_upload
i_begin_col = 1
i_begin_row = 1
i_end_col = 26
i_end_row = 65000
tables
intern = IEXCEL
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.
EXIT.
ENDIF.
ENDIF.
...Type conflict is for p_upload in the Function Module.
Can someone help me out with this.
Thanks in advance.
Shilpa
2006 Sep 07 9:44 AM
Hi shilpa,
1. just change the definition of your form like this.
FORM Pres_Upload
<b>USING p_upload TYPE RLGRAP-FILENAME</b>
p_upload_table TYPE table.
regards,
amit m.
2006 Sep 07 9:45 AM
Hello,
In the function module <b>P_upload should be of type</b>
<b>RLGRAP-FILENAME</b> .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = <b>p_upload</b>
i_begin_col = 1
i_begin_row = 1
i_end_col = 26
i_end_row = 65000
tables
intern = IEXCEL
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
Reward if helps.
Thanks,
Krishnakumar
2006 Sep 07 9:48 AM
hi,
DO thway..
FORM Pres_Upload USING p_upload TYPE string p_upload_table TYPE table.
<b>data : v_file like rlgrap-filename.
v_file = p_upload.</b>
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_upload
i_begin_col = 1
i_begin_row = 1
i_end_col = 26
i_end_row = 65000
tables
intern = IEXCEL
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.
EXIT.
ENDIF.
ENDIF.
2006 Sep 07 10:01 AM
Thanks that was very helpful.
Now how do i get the data from IEXCEL to a internal table.
And How to upload the data from excel sheet to internal table from Application Server.
2006 Sep 07 10:02 AM
Hi again,
1. U want to upload data from EXCEL
into internal table.
2. and u are using ALSM_EXCEL_TO_INTERNAL_TABLE.
3. But We cannot do this direclty !
4. In this FM,
there is one TABLES
INTERN = t_upload1
The definition of this t_upload1
should be as per
INTERN LIKE ALSMEX_TABLINE
and not as per your data.
5. Hence, it is giving error here .
*----
For uploading purpose :
6. There are TWO options.
a) either save the excel to TAB Delimited file,
and use GUI_UPLOAD to upload the data in internal table.
b) use FM for excel purpose.
7. a) is easy and recommended
8. b) there is a FM for it,
but we have to apply some more logic
bcos the FM uploads data of excel
in the intenal table,
CELL BY CELL
9. afTER THAT , we have to convert this cell by cell data,
into our format of internal table.
10. use this code (just copy paste in new program)
(it is tried wit T001 structure data)
(it will AUTOMATICALLY based upon the
fields of internal table,
convert data from cell by cell,
to that of internal table fields)
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.
2006 Sep 07 10:20 AM
My data will be in the format below.
DATA:BEGIN OF w_main,
tdlnr TYPE komg-tdlnr,
trfzna TYPE komg-trfzna,
kbetr(10) TYPE c,
kbetr1(10) TYPE c,
END OF w_main.
DATA:t_main LIKE TABLE OF w_main.
Now the data has to be moved from IEXCEL to t_main.
I didn't understand the logic given below
*----
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.
Can u please elaborate on the same.
And is it possible to Upload the Data from Excel sheet to internal table from Application Sever?
For a tab delimited file ,right now i am using the logic given below
CONSTANTS:c_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
OPEN DATASET p_appup1 FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
IF p_appup1 = c_space.
MESSAGE i001(ztr).
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE i002(ztr).
LEAVE LIST-PROCESSING.
ENDIF. ENDIF.
DO.
READ DATASET p_appup1 INTO w_transfer.
IF sy-subrc = 0.
APPEND w_transfer TO t_transfer.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET p_appup1.
LOOP AT t_transfer INTO w_transfer.
SPLIT w_transfer AT c_tab INTO w_main-tdlnr
w_main-trfzna
w_main-kbetr
w_main-kbetr1.
IF sy-subrc = 0.
APPEND w_main TO t_main.
ELSE.
MESSAGE i006(ztr).
LEAVE LIST-PROCESSING.
ENDIF.
ENDLOOP .