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

Casting Problem

Hi Guys!

Following problem:

I want to update a csv file and write the information's in it to a database.

two cols of the DB are TYPE INT4, but the csv fields can only be TYPE c,d,n,t or STRING.

source:

MOVE emplo TO db-emplo.

MOVE value TO db-val.

but the value in db-emplo is 0! and not 645.45 !

can i cast type d or string to INT4 ?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Feb 08, 2005 at 10:39 AM

    Hi Marcus.

    I've tried the following:

    data: l_source(20) type c,
          l_target type i.
    
    pack l_source to l_target.
    

    So if l_source has value "123" as string, then l_target has value "123" as number.

    Please let us know if it helped. BR,

    Alvaro

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 08, 2005 at 02:13 PM

    Integer fields do not support decimals.

    Do you want the INT4 fields to have a valid value when you are done?

    Can you post some examples of how you want the INT4 fields to be populated, for example, if the input has the value 645.45, what do you want the INT4 to be set to?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 10, 2005 at 08:37 AM

    Thanks for Help... but I find my own way...

    Solution:

    In CSV File the Cell had the following "style": 102.456

    So I did it this way:

    While sy-subrc = 0.

    REPLACE '.' WITH '' INTO emplo.

    REPLACE '.' WITH '' INTO value.

    EndWhile.

    CONDENSE emplo NO-GAPS.

    CONDENSE value NO-GAPS.

    MOVE emplo TO db-emplo.

    MOVE value TO db-val.

    Now it works...

    Thanks anyway.

    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.