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

Excel upload Error!!!!!!!!!!!

sudarshan_d29
Active Participant
0 Likes
3,840

Hi Friends,

I am uploading Excel to Internal Table Using  F4_FILENAME and  TEXT_CONVERT_XLS_TO_SAP!!!!!!

Sometime It getting uploaded and sometime is not.

I have searched lot in SCN not able to find the solution.

My file path :  C:\Users\Sony\Desktop\Go Colors\Upload1.xls

Upload program for FB60.

Program:

CALL FUNCTION 'F4_FILENAME'

    EXPORTING

      FIELD_NAME          = 'PA_FILE'

    IMPORTING

      FILE_NAME           = pa_file

             .

   if sy-subrc <> 0.

     message id sy-msgid type sy-msgty number sy-msgno

           with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

   endif.

call function 'TEXT_CONVERT_XLS_TO_SAP'

     exporting

*     I_FIELD_SEPERATOR    =

       i_line_header        = 'X'

       i_tab_raw_data       = it_raw

       i_filename           = v_file

     tables

       i_tab_converted_data = it_data1[]

     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.

   endif.

   clear v_file.


Please guide I don't know why is not working!!!!!!!



Regards,

Sudarshan D

1 ACCEPTED SOLUTION
Read only

former_member185116
Active Participant
0 Likes
1,922

hi sudharshan,

try below code, i have tested it , it works fine...


DATA: IT_RAW TYPE TRUXS_T_TEXT_DATA,
           IT_FNAM TYPE FILETABLE.

*sel screen declaration *****************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

  PARAMETERS : FILE LIKE RLGRAP-FILENAME OBLIGATORY.

  SELECTION-SCREEN skip 1.
  
SELECTION-SCREEN END OF BLOCK b1.
*****************************************************


AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE.
   CALL FUNCTION 'F4_FILENAME'
     IMPORTING
       FILE_NAME = FILE.



start-of-selection.

  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
     EXPORTING
       I_FIELD_SEPERATOR    = 'X' "is an .xls file
       I_LINE_HEADER        = 'X' "has a header line
       I_TAB_RAW_DATA       = IT_RAW
       I_FILENAME           = FILE
     TABLES
       I_TAB_CONVERTED_DATA = it_itab.

here it_itab i s your internal table that holds data of uploaded excel file...

10 REPLIES 10
Read only

former_member196331
Active Contributor
0 Likes
1,922

May i know what is the error message.

Read only

former_member196331
Active Contributor
0 Likes
1,922

Any Error like File conversion failed, please check the file.

Read only

sudarshan_d29
Active Participant
0 Likes
1,922

Hi bro,

While executing the file first getting executed successfully.

But if executing again for testing purpose, its not getting uploaded.

Regards,

Sudarshan D

Read only

0 Likes
1,922

If you put break point AT sy-subrc . Some return parameter will comes, have you got my point.

Read only

0 Likes
1,922

Hi bro,

I didn't get it!!!!!!!!!!!!

Please clarify....

Regards,

Sudarshan D

Read only

0 Likes
1,922

   if sy-subrc <> 0.

     message id sy-msgid type sy-msgty number sy-msgno

             with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

   endif.

   clear v_file.



you Can put break point at if sy-subrc <> 0.

then execute the code.

Read only

PeterJonker
Active Contributor
0 Likes
1,922

What is the error you are getting ? Did you debug ? If yes, At which step it is going wrong ?

Read only

0 Likes
1,922

Hi Bro's,

I tried Till now, while debugging it run normally without capturing data

it don't also entered into break point inside sy-subrc <> 0 .

Instead it also doesnt provide any session transaction (A-display all screen) for FB60.

Regards,

Sudarshan D

Read only

former_member185116
Active Participant
0 Likes
1,923

hi sudharshan,

try below code, i have tested it , it works fine...


DATA: IT_RAW TYPE TRUXS_T_TEXT_DATA,
           IT_FNAM TYPE FILETABLE.

*sel screen declaration *****************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

  PARAMETERS : FILE LIKE RLGRAP-FILENAME OBLIGATORY.

  SELECTION-SCREEN skip 1.
  
SELECTION-SCREEN END OF BLOCK b1.
*****************************************************


AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE.
   CALL FUNCTION 'F4_FILENAME'
     IMPORTING
       FILE_NAME = FILE.



start-of-selection.

  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
     EXPORTING
       I_FIELD_SEPERATOR    = 'X' "is an .xls file
       I_LINE_HEADER        = 'X' "has a header line
       I_TAB_RAW_DATA       = IT_RAW
       I_FILENAME           = FILE
     TABLES
       I_TAB_CONVERTED_DATA = it_itab.

here it_itab i s your internal table that holds data of uploaded excel file...

Read only

sudarshan_d29
Active Participant
0 Likes
1,922

Thanks a lot vinay!!!!!!!!!!!!

Regards,

Sudarshan D