Quantcast
Channel: SCN: Message List - ABAP Development
Viewing all articles
Browse latest Browse all 10425

Re: Excel file not getting uploaded in the internal table

$
0
0

Hello Ajinkya,

 

Create a internal table in ABAP report with same fields as in Excel file.

 

Below is the code worked for me.

 

*******************************************************************************************************

type-pools: truxs, trwbo.

 

data: begin of gt_record occurs 0,

         reswk(004),     "Supplying plant

         werks(004),     "Plant

         bsart(004),      "Type   

       end of gt_record.


data: gt_raw     type truxs_t_text_data,

         gv_file1   type rlgrap-filename.


data: gv_file type string.


parameters: p_file(128) type c.

 

*----------------------------------------------------------------------*

*   at selection screen on value-request for                           *

*----------------------------------------------------------------------*

at selection-screen on value-request for p_file.

   call function 'F4_FILENAME'

     exporting

       program_name  = syst-cprog

       dynpro_number = syst-dynnr

     importing

       file_name     = p_file.


*-----------------------------------------------------------------------

* START OF SELECTION

*-----------------------------------------------------------------------

start-of-selection.

 

   gv_file = p_file.

   clear gt_record.

   gv_file1 = gv_file.


***FM to get data from Excel***


   call function 'TEXT_CONVERT_XLS_TO_SAP'

     exporting

       i_tab_raw_data       = gt_raw

       i_filename              = gv_file1

     tables

       i_tab_converted_data = gt_record[]

     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.

   else.

     delete gt_record index 1.

   endif.

******************************************************************************************************


Now gt_record[] will have data from excel.


And excel file should look like this--


reswk(004)werks(004)bsart(004)
N114N202N1UB
N114N203N1UB
N114N204N1UB
N114N205N1UB
N114N206N1UB
N114N207N1UB
N114N208N1UB
N114N209N1UB





Viewing all articles
Browse latest Browse all 10425

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>