Skip to Content
author's profile photo Former Member
Former Member

uploading excel data to database table

Dear Experts,

I have an Excel file which was downloaded from SQL database, now I need to export this data into my 'ztable', for this first I created an internal table of ztable structure and tried to upload into this table through ''TEXT_CONVERT_XLS_TO_SAP".

But I was unable to get data into the internal table(incompatible type), so now I created an internal table of character type fileds now I able to get data to this internal table, but to put this internal table data to actual database table it gives error, here the actual problem is the fields of internal table are getting concated with blank spaces(observed through debug), I unable to condense these blanks also, (I have created an Excel of my own and put data into it and uploaded that data there is no problem working fine but this problem occurs only for the excel downloaded from SQL db)

The problem occurs for quantity and currency fields(I tried through standard FMs also to convert data types ), Could plz suggest something..........

Thank you

Regards

Srinivas

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Aug 11, 2009 at 05:09 AM

    Hi,

    Try using pack and shift delete to remove the extra spaces for the quantity and currency fields and then try to upload into the Ztable

    
    loop at itab.
    pack itab-menge to itab-menge.
    shift itab-menge left deleting leading space.
    
    pack itab-wears to itab-wears.
    shift itab-weards left deleting leading space.
    
    modify itab transpoting menge wears.
    endloop.
    

    Regards,

    Vik

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Vikranth Reddy

      Hai,

      I already used shift also, but there is no use.......,it works for split statement but I have large no.of records in my excel, it is hard to write split statement in loop for every fields of 54 fields...........

      Edited by: Sri on Aug 11, 2009 11:37 AM

  • author's profile photo Former Member
    Former Member
    Posted on Aug 11, 2009 at 05:50 AM

    hi sri!

    can you paste your code here..

    Sumit

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 11, 2009 at 06:07 AM

    Hi,

    To upload excel sheet into database table, define a types which is of same as table fields.

    and try it with the function module TEXT_CONVERT_XLS_TO_SAP

    Here is a sample code:

    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
            EXPORTING
             I_FIELD_SEPERATOR          ='X'    
              i_tab_raw_data             = fs_truxs( TYPE of  truxs_t_text_data.)
              i_filename                 = '<FILE-PATH>'
          tables
              i_tab_converted_data       = <Internal Table>
           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.
    
    LOOP AT <internal-table> INTO field string.
     INSERT <DATABASE- TABLE> FROM <field string>.
    ENDLOOP.

    Hope this solves the issue.

    Regards,

    Rajani

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 11, 2009 at 06:13 AM

    How did you get blanks if you are using FM "text_convert.."

    Instead of makin all the fields of type char in your int tab, make only the quant and curr fields(those that are giving error) of type char in you itab. Then in your code copy them into quant and currency variables manually.

    Regards,

    Sumit

    Edited by: Sumit Nene on Aug 11, 2009 8:19 AM

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.