‎2009 Oct 14 8:08 AM
Hi
I am uploading data from excel to internal table itab1.
below is my excel data
Dno Lno KNDNR ARTNR FKART KAUFN KDPOS
1 1 12345 10Itab structure is.
ROW COL VALUE
0001 0001 Dno
0001 0002 Lno
0001 0003 KNDNR
0001 0000 ARTNR
0001 0005 FKART
0001 0006 KAUFN
0001 0007 KDPOS
0002 0001 1
0002 0002 1
0002 0004 12345
0002 0007 10I want to modify the internal table structure like below
Dno Lno char value
1 1 ARTNR 12345
1 1 KDPOS 10How to achieve this. pls help me
‎2009 Oct 14 11:01 AM
Hi,
Try doing like:
DATA: it_raw TYPE truxs_t_text_data.
internal table declared to be passed in the
function module used to convert data from xls to sap
&----
*&Function module called to upload xls data into an internal table
&----
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_line_header = 'X'
i_tab_raw_data = it_raw
i_filename = p_file "file path browsed
TABLES
i_tab_converted_data = it_upload[] "int table populated
EXCEPTIONS
conversion_failed = 1 "browsed file's data
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.
ENDIF.
Hope it helps,
Regards
Mansi
‎2009 Oct 14 8:12 AM
Post the code with what you have tried for any suggestions. Dont expect others to do your work
‎2009 Oct 14 8:23 AM
Hi Vikranth
I have tried below code. But it is not correct.
BEGIN OF it_data_sub OCCURS 0,
dno(3),
lno(3),
char(10),
value(10),
END OF it_data_sub.
IF it_data2[] IS NOT INITIAL.
LOOP AT it_data2 INTO it_data_wa2.
MOVE it_data_wa2-value TO it_data_sub-value.
APPEND it_data_sub.
CLEAR it_data_sub.
ENDLOOP.
ENDIF.Anyone help me pls
‎2009 Oct 14 9:18 AM
If you are using ALSM_EXCEL_TO_INTERNAL_TABLE it would be quite code intensive to get the format you require. Better use GUI_UPLOAD to upload the excel file as it will be comparitively easier to format the internal table as per your requirement
‎2009 Oct 14 9:23 AM
Hi Vikranth
I am required to read multiple excel sheets.
Now I am processing sheet2. I already processed sheet1.
ALSM_EXCEL_TO_INTERNAL_TABLE and GUI_UPLOAD wont support multiple excel. So I cant use this FM.
Thanks
‎2009 Oct 14 9:16 AM
Hi Kumar,
just format your excel data according to the output format and then upload it into itab.
‎2009 Oct 14 11:01 AM
Hi,
Try doing like:
DATA: it_raw TYPE truxs_t_text_data.
internal table declared to be passed in the
function module used to convert data from xls to sap
&----
*&Function module called to upload xls data into an internal table
&----
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_line_header = 'X'
i_tab_raw_data = it_raw
i_filename = p_file "file path browsed
TABLES
i_tab_converted_data = it_upload[] "int table populated
EXCEPTIONS
conversion_failed = 1 "browsed file's data
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.
ENDIF.
Hope it helps,
Regards
Mansi
‎2009 Oct 16 1:07 PM
Hi Kumar!
Sorry for so late answering. Mey be u don't need already it. But your problem had interested me and i decided to test myself in generic programming a little)). So, this is my code:
Moderator message - Please respect the 2,500 character maximum when posting. Post only the relevant portions of code
Instead of initialize method u should insert your own to fill mt_table. And at the end of main method u recieve new generic table table with values from initial table. But it is one mandatory condition - names of columns must be in a first row and they must be called as data elements from ABAP dictionary. Anyway i got
Edited by: Petr.Plenkov on Oct 16, 2009 2:07 PM
Edited by: Petr.Plenkov on Oct 16, 2009 2:07 PM
Edited by: Rob Burbank on Oct 16, 2009 9:20 AM
‎2009 Oct 16 1:11 PM
Hi Kumar! Sorry for so late answering. May be u don't need already it. But your problem had interested me and i decided to test myself in generic programming a little)). Instead of initialize method u should insert your own to fill mt_table. And at the end of main method u recieve new generic table table with values from initial table. But it is one mandatory condition - names of columns must be in a first row and they must be called as data elements from ABAP dictionary. So, this is my code:
Edited by: Petr.Plenkov on Oct 16, 2009 2:32 PM