‎2014 Apr 08 8:49 AM
Dear Experts,
I am doing an upload program using BDC.
For this I used ' KD_GET_FILENAME_ON_F4 ' FM for f4 functionality
And used 'TEXT_CONVERT_XLS_TO_SAP' FM for upload dta from excel file.
when i run its not showing any error or not going for dump. But no data upload to itab which has all the fields as in excel file.
Also how to check the upload file ( p_file ) which i got by pressing f4 on selection screen during debug ???
Please guide me what should i need to do to get my data in itab ...
regards,
Ajit
‎2014 Apr 09 10:45 AM
Thank You all for your timed help hand.
In my issue, I did't able to get the data of excel file as because my itab to which i upload and the execel file field format were not same. I got that after a lot debug.
Not its working fine with the same FM.
Thanks Again to all..
‎2014 Apr 08 8:54 AM
Hi AJit, try this code:
remember u need to declare it_raw table
TYPES: BEGIN OF ty_data,
charact_name TYPE atnam, "Characteristic Name
description TYPE atbez, "Descritpion
data_type TYPE atudf, "Data type
length TYPE charnumber, "lenght
decimals TYPE decplaces, "Decimals
status TYPE atmst, "Status (0 - In Prep, 1 - Released, 2 - Locked)
value_assignment TYPE atbew, "(Single, Multple, Restrictable)
unit_of_measurement TYPE meins, "UoM
END OF ty_data.
DATA: it_raw TYPE truxs_t_text_data,
it_data TYPE TABLE OF ty_data.
PARAMETERS : p_file LIKE rlgrap-filename OBLIGATORY .
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.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
DATA: l_date(8) TYPE c,
l_tabix LIKE sy-tabix.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw
i_filename = p_file
TABLES
i_tab_converted_data = it_data[]
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* RAISE upload_problem.
MESSAGE 'Unable to open the file' TYPE 'E'.
ENDIF.
Thanks,
Sachin
‎2014 Apr 08 9:03 AM
Hi Ajit,
Will uploading the Excel data into an internal table and then processing the internal table itself will solve your issue? If so, you can use the FM ALSM_EXCEL_TO_INTERNAL_TABLE.
Thanks,
Anubhab
‎2014 Apr 08 9:23 AM
Hi Ajit,
We have to upload it first to an internal table with component char:
For your reference:
types truxs_t_text_data(4096) type c occurs 0.
In Code:
type-groups: TRUXS.
data: lv_inputdata type truxs_t_text_data.
then after upload to move it to an internal table of the actual type based on offsets.
Maybe this will help:
‎2014 Apr 08 3:42 PM
Hello Ajit,
For uploading excel file data from local system into SAP internal table, may be below piece of code will work for you.
*&- Types decleration
**same fields as that of the excel file
TYPES: BEGIN OF ty_data,
id TYPE char2,
name TYPE char10,
END OF ty_data.
DATA: it_raw TYPE truxs_t_text_data,
it_data TYPE TABLE OF ty_data.
PARAMETERS: s_file TYPE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_file.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
CHANGING
file_name = s_file
EXCEPTIONS
mask_too_long = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_tab_raw_data = it_raw
i_filename = s_file
TABLES
i_tab_converted_data = it_data
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
Now in internal table it_data you will have data from the excel file.
Regards,
Vivek
‎2014 Apr 08 4:03 PM
Hi Ajit,
Instead of TEXT_CONVERT_XLS_TO_SAP use FM ALSM_EXCEL_TO_INTERNAL_TABLE as the previous one has performance issues. You can use FM F4_FILENAME for F4 help.
The path of the file that you select needs to be passed back to the parameter.
Ex: p_path = s_path. Where s_path is the path that you pass to the FM for F4 help(KD_GET_FILENAME_ON_F4).
‎2014 Apr 09 10:45 AM
Thank You all for your timed help hand.
In my issue, I did't able to get the data of excel file as because my itab to which i upload and the execel file field format were not same. I got that after a lot debug.
Not its working fine with the same FM.
Thanks Again to all..