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

Amount and Date Formatting Urgent !!

Hello Gurus,

I want to format Amount in the below manner , I need to put this data in a text file ,

When I read it from SAP , irrespective of whatever format

I need to write the data in the text file in the following format

999999999999.999

if the amount is 12 then

000000000012.000

if the amount is 100 then

000000000100.000

Also , I need a help on date formating

My date will always appear in the text file in the following format

YYYY.MM.DD

so irrespective of whatever user settings on has I need the format to appear in the text file as above.

Please help me Points guaranteed , please try it at your end

and please paste the code.

rgds,

Aryan

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 06:45 AM

    U can use FMs

    CONVERSION_EXIT_ALPHA_INPUT

    CONVERSION_EXIT_ALPHA_OUTPUT

    to pad up / remove leading zeroes.

    Try this.

    Narendra

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 06:46 AM

    As for the date formatting:

    REPORT SY-REPID.

    DATA : G_DATE LIKE SY-DATUM,

    L_DATE(10).

    G_DATE = SY-DATUM.

    CONCATENATE G_DATE+00(04) '.' INTO L_DATE.

    CONCATENATE L_DATE G_DATE+04(02) '.' INTO L_DATE.

    CONCATENATE L_DATE G_DATE+06(02) INTO L_DATE.

    WRITE L_DATE.

    will work on amount format adn let you know.. plz reward points.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 06:50 AM

    Hi Aryan,

    for your date format you can simply use the offsets to interchange the year month abnd dat

    eg,

    concatenate sy-datum4(4) sy-datum2(2) sy-datum(2) to lv_yyyymmdd.

    the lv_yyyymmdd will contain data in that format.

    For your amount fields i think tou have a problem of , and .

    If yes then simply use the keyword

    TRANSLATE lv_amount USINAG PATTERN ' , . '

    This will replace all commas with dot.

    If this is not the cae then please elaborate for what is the actuall problem.

    reward if usefull and close the thread if answered ,

    Taher

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi ,

      For the leadinf Zeros simply use the Function Module

      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

      EXPORTING

      input = lv_amount

      IMPORTING

      OUTPUT = lv_amount.

      here your variable will be zero padded accordingly,

      Taher

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 06:58 AM

    Hi,

    Check the below logic:

    data: val(17) type c.

    val = '2.567'.

    write : / val.

    shift val right deleting trailing space.

    write : / val.

    translate val using ' 0'.

    write : / val.

    Date : Use 'EDIT MASK' with WRITE statement.

    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.