Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

read data from application server

Former Member
0 Likes
494

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.

3 REPLIES 3
Read only

uwe_schieferstein
Active Contributor
0 Likes
462

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

Read only

Former Member
0 Likes
462

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

Read only

0 Likes
462

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