‎2008 Feb 08 4:19 AM
Hi Gurus,
i have to read an excel sheet from application server into internal table.the excel sheet has 7 fields.out of the 7 fields four fields have multiple data entries.how to read all into a single internal table.
E.g.
let us suppose the fields are
pri,pric,prit,vfro,vto,frbl & pamt.
out of these in vfro,vto,frbl & pamt the data is repeated for the same set of data in pri,pric,prit.
So can you tell me how to populate the iternal table with syntax and the same example?
All replies will be rewarded.
‎2008 Feb 08 4:43 AM
Hello Ananad
Perhaps there are tricks available to upload such an Excel sheet directly into SAP. However, I would recommend to use a .csv file instead since it will simplify the task rigorously.
Define an internal table with the line structure of your record, i.e.:
pri,pric,prit,vfro,vto,frbl & pamt
Define a second itab of table type TRUXS_T_TEXT_DATA (NOTE: requires TYPE-POOL: TRUXS).
Steps:
1. Read your .csv file into the unstructured itab (2nd itab)
2. Convert unstructured records into structured record (1st itab)
DATA: gt_data_raw TYPE TRUXS_T_TEXT_DATA,
gd_data_raw LIKE LINE OF gt_data_raw,
gt_data TYPE STANDARD TABLE OF z_my_structure. " could be type definition as well
OPEN DATASET gd_csvfile FOR INPUT IN TEXT MODE ENCODING DEFAULT.
CHECK ( sy-subrc = 0 ).
REFRESH: gt_data_raw.
DO.
READ DATASET gd_csvfile INTO gd_data_raw.
IF ( syst-subrc NE 0 ).
EXIT.
ENDIF.
APPEND gd_data_raw TO gt_data_raw.
ENDDO.
CLOSE DATASET gd_csvfile.
CALL FUNCTION 'TEXT_CONVERT_CSV_TO_SAP'
EXPORTING
i_tab_raw_data = gt_data_raw " unstructured record
TABLES
i_tab_converted_data = gt_data. " structured record
Regards
Uwe
‎2008 Feb 08 4:54 AM
Hi,
Can you give a reply for the same question but if the file is from the presentation serrver?
I will reward points.
Thanks in advance
‎2008 Feb 08 5:49 AM
Hello Anand
Simply provide a filename ( I_FILENAME ) instead of the itab containing the raw data.
For a sample have a look at
Regards
Uwe