05-22-2007 9:35 AM
Hi,
I am having tab delimit file. I have declared the internal table for uploading data from the file exactly as the type of data to be uploaded. When, I am Calling the GUI_UPLOAD Function Module, I am passing the file name and making the HAS_FIELD_SEPARATOR TO 'X'.
It is working very fine with the tab delimit text(.txt) file.
But, when I am giving the Excel File(.xls), it is throwing and Error Message and coming out of the program. The Error Message displayed is 'Cannot Interpret data in file'.
I am not able to understand, where the error is. Please help.
Regards,
Ishaq.
05-22-2007 9:37 AM
remove this HAS_FIELD_SEPARATOR TO 'X'. when your are using .xls
you can use the function module ALSM_EXCEL_TO_INTERNAL_TABLE instead of that if it is excel file
05-22-2007 9:37 AM
remove this HAS_FIELD_SEPARATOR TO 'X'. when your are using .xls
you can use the function module ALSM_EXCEL_TO_INTERNAL_TABLE instead of that if it is excel file
05-22-2007 9:55 AM
Thanks guys.
One more thing. I will be using Call Transaction. In that we will be passing the MODE, right. I want to declare this field on the selection screen which will show
'A' for All Screen Mode
'N' for No Screen Mode
'E' for Error Screen Mode
Can you tell me, what will be the type of this parameter
Parameters: p_mode type ??
Thanks in advance,
Ishaq.
05-22-2007 10:42 AM
just declare it of char 1
parameters : p_mode(1)
call transaction .... mode p_mode....
05-22-2007 9:39 AM
Hi , You cannot pass HAS_FIELD_SEPARATOR TO 'X'.
and XL file both as feild separator is Used only for the ASCII format.
Please mark Useful answers
05-22-2007 9:39 AM
Hi,
To upload XLS files use the FM in the below example :-
Check this Sample code.
TABLES : LFA1,RF02K.
DATA : BEGIN OF ITAB OCCURS 0,
LIFNR LIKE RF02K-LIFNR,
KTOKK LIKE RF02K-KTOKK,
NAME1 LIKE LFA1-NAME1,
SORTL LIKE LFA1-SORTL,
LAND1 LIKE LFA1-LAND1,
SPRAS LIKE LFA1-SPRAS,
END OF ITAB.
DATA : ITAB1 LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
DATA : B1 TYPE I VALUE 1,
C1 TYPE I VALUE 1,
B2 TYPE I VALUE 10,
C2 TYPE I VALUE 99.
INCLUDE BDCRECX1.
START-OF-SELECTION.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = 'C:xl1.XLS'
I_BEGIN_COL = B1
I_BEGIN_ROW = C1
I_END_COL = B2
I_END_ROW = C2
TABLES
INTERN = ITAB1
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.
PERFORM ORGANIZE_UPLOADED_DATA.
*----------------------------------------------------------------------*
PERFORM OPEN_GROUP.
LOOP AT ITAB.
PERFORM BDC_DYNPRO USING 'SAPMF02K' '0100'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RF02K-KTOKK'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RF02K-LIFNR'
ITAB-LIFNR.
PERFORM BDC_FIELD USING 'RF02K-KTOKK'
ITAB-KTOKK.
PERFORM BDC_DYNPRO USING 'SAPMF02K' '0110'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'LFA1-SPRAS'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'LFA1-NAME1'
ITAB-NAME1.
PERFORM BDC_FIELD USING 'LFA1-SORTL'
ITAB-SORTL.
PERFORM BDC_FIELD USING 'LFA1-LAND1'
ITAB-LAND1.
PERFORM BDC_FIELD USING 'LFA1-SPRAS'
ITAB-SPRAS.
PERFORM BDC_DYNPRO USING 'SAPMF02K' '0120'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'LFA1-KUNNR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_DYNPRO USING 'SAPMF02K' '0130'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'LFBK-BANKS(01)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_DYNPRO USING 'SAPLSPO1' '0300'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=YES'.
PERFORM BDC_TRANSACTION USING 'XK01'.
PERFORM CLOSE_GROUP.
ENDLOOP.
FORM ORGANIZE_UPLOADED_DATA .
SORT ITAB1 BY ROW
COL.
LOOP AT ITAB1.
CASE ITAB1-COL.
* ....................................................
WHEN 1.
ITAB-LIFNR = ITAB1-VALUE.
WHEN 2.
ITAB-KTOKK = ITAB1-VALUE.
WHEN 3.
ITAB-NAME1 = ITAB1-VALUE.
WHEN 4.
ITAB-SORTL = ITAB1-VALUE.
WHEN 5.
ITAB-LAND1 = ITAB1-VALUE.
WHEN 6.
ITAB-SPRAS = ITAB1-VALUE.
* ....................................................
ENDCASE.
AT END OF ROW.
* wa_tabdata-mandt = sy-mandt.
* APPEND wa_tabdata TO it_tabdata.
* CLEAR: wa_tabdata.
APPEND ITAB.
CLEAR ITAB.
ENDAT.
ENDLOOP.
ENDFORM. " ORGANIZE_UPLOADED_DATA
Regards,
Deepu.K
05-22-2007 9:53 AM
Hi Ishaq,
Gui_Upload does not read Exel files directly. Use TEXT_CONVERT_XLS_TO_SAP, to read Exel files direcly to SAP. Its much better option then converting your exel file to tab limited and then using gui_upload.
Hope this helps.
Reward if helpful
Regards,
Karan
12-05-2007 1:01 PM
hiiii
i read that u used this FM
TEXT_CONVERT_XLS_TO_SAP
It doesn't work for me