08-20-2010 11:19 AM
Hi Champs
I am trying to upload an excel fiel to SAP system.
Below is my code:
TYPES: BEGIN OF TY_ITAB,
WF_NO(9),
DR_CR,
GL_ACCNT(6),
CARDHOLDER(25),
DESC_OF_CHARGE(30),
VENDOR(25),
COST_CENTER(5),
AMOUNT(12),
NETWORK(12),
WBS(12),
ACTV_NO(4),
DATE_OF_TANSC(8),
CHARGE_TYPE,
COMPANY_CODE(4),
POST_DATE(8),
DOC_DATE(8),
REF_NO(12),
POST_INDIC,
END OF TY_ITAB.
DATA: ITAB TYPE STANDARD TABLE OF TY_ITAB,
WA_ITAB TYPE TY_ITAB.
DATA: FILENAME TYPE STRING.
PARAMETERS P_FILE TYPE LOCALFILE.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
* FIELD_NAME = ' '
IMPORTING
FILE_NAME = P_FILE .
FILENAME = P_FILE.
START-OF-SELECTION.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = FILENAME
I_BEGIN_COL = 1
I_BEGIN_ROW = 2
I_END_COL = 14
I_END_ROW = 2
TABLES
INTERN = ITAB
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.
Here in my internal table the last 4 fields are extra and don't want to add data from my excel sheet , rather I want to update it later.
Its giving me a dump stating that:
The function module interface allows you to specify only
fields of a particular type under "FILENAME".
The field "FILENAME" specified here is a different
field type
Please help
Thanks in Advance
Please enclose your between ... tags for better readability.
Edited by: kishan P on Aug 20, 2010 4:04 PM
08-20-2010 11:29 AM
Declare your file name field as of type "RLGRAP-FILENAME". This should solve your problem.
Regards,
08-20-2010 12:00 PM
08-20-2010 12:21 PM
Hi Lalit.
try this FM 'TEXT_CONVERT_XLS_TO_SAP'.
it should work for u.
08-20-2010 12:17 PM
Does the excel file has the fields corresponding to your internal table? Here I think there are either extra fields in your excel or you dont have in excel the last 3 fields that you have defined in your type declaration for later modification.
When you are uploading through this function module, both the excel header and your internal table type should match. Otherwise it will throw the error.
If you want another 3 fields for later modifications, either you can enter those fieldnames in the excel header and leave the content blank or you can append those 3 fields with blank values after importing the content from excel into internal table.
08-20-2010 12:21 PM
HI All First of all thanks to u all for your replies.
I got the reason why I was getting dump.
I think my table which I am passing to the
TABLES
INTERN = ITAB
should be of type ALSMEX_TABLINE becasue FM's table INTERM is of type this.
then I need to upload data in my internal table by creating a logic.
Thanks
Lalit Gupta