Application Development 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: 

date conversion after SD_PRINT_TERMS_OF_PAYMENT

Former Member
0 Kudos

Hi all,

What is the best way to do the date conversion after the FM "SD_PRINT_TERMS_OF_PAYMENT" or should I do it before the FM???

FROM

if language is DE - Bis zum 20.06.2008 ohne Abzug

if language is EN - Up to 20.06.2008 without deduction.

TO

if language is DE - Bis zum 06.20.2008 ohne Abzug

if language is EN - Up to 06.20.2008 without deduction.

Thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi all,

Anyone has a solution for this?

Please help. Thank you.

8 REPLIES 8

Former Member
0 Kudos

Hi all,

Anyone has a solution for this?

Please help. Thank you.

0 Kudos

Hi ,

u can try like this

WRITE sy-datum TO date DD/MM/YYYY.

regards

Prabhu

0 Kudos

Thanks for you reply.

Actually the whole message "Up to 20.06.2008 without deduction" was return from the Function Module.

I think I need to cut into 3 parts 1)"Up to" 2)"20.06.2008" 3)"without deduction"

After that, convert the date from 20.06.2008 to 06.20.2008, and concatenate it back.

Do you think this is the only way? or there is another altenative way?

0 Kudos

Hi all,

Anyone has solution for this?

Thanks.

0 Kudos

Hi wong ,

i dont think we have such FM's which converts that message, better to Split and do the conversion.

regards

Prabhu

0 Kudos

Hi,

You already have the answer with you.

Just split it and concatenate it according to your requirement.

Regards,

Dileep.

0 Kudos

I am still having same problem. I need to replace the "." and reshuffle the date in the text "'Up to 20.06.2008 without deduction'" to be "'Up to 06-20-2008 without deduction'".

Below is my code, which is giving me the result "Up to 06 - 20 - 2008 without deduction".

Can anyone help me to amend the code below? Thanks.


DATA: gv_zterm1 TYPE VBDKA-ZTERM_TX1,
      str1      TYPE string,
      str2      TYPE string,
      str3      TYPE string,
      str4      TYPE string,
      str5      TYPE string,
      date1     TYPE string,
      date2     TYPE string,
      date3     TYPE string,
      merge1    TYPE string,
      merge2    TYPE string.

CLEAR: gv_zterm1.
gv_zterm1 = 'Up to 20.06.2008 without deduction'.

IF NOT gv_zterm1 IS INITIAL.
  SPLIT gv_zterm1 AT space INTO: str1 str2 str3 str4 str5.

  IF NOT str3 IS INITIAL.
    SPLIT str3 AT '.' INTO: date1 date2 date3.

    CONCATENATE date2 '-' date1 '-' date3
      INTO str3 SEPARATED BY SPACE.

    CONCATENATE str1 str2
      INTO merge1 SEPARATED BY SPACE.

    CONCATENATE str4 str5
      INTO merge2 SEPARATED BY SPACE.

    CONCATENATE merge1 str3 merge2
      INTO gv_zterm1 SEPARATED BY SPACE.

  ENDIF.
ENDIF.

WRITE: / gv_zterm1.

0 Kudos

I think you'd be better off if you set the date format before calling the standard function module and resetting it afterwards.

Your code assumes the date returned by the function in the message is always in the same format, but most probably it depends on the client config or user profile. So if this is modified in the future your code ceases to function (you can try this yourself by going to transaction SU3 and changing your date format parameters, then running the SD_PRINT_TERMS_OF_PAYMENT fm afterwards).

In that case, the SET COUNTRY statement may be of help:

http://help.sap.com/saphelp_scm50/helpdata/en/9f/dba1ef35c111d1829f0000e829fbfe/content.htm

Another way to be independent of date format (although less preferable because you still assume the date position in the message string) is to take the date part and convert it to internal format (i.e. YYYYMMDD) using fm CONVERT_DATE_TO_INTERNAL, then formatting it to your needs and rebuilding the message afterwards.

To fix your code however, remove the SEPARATED BY space addition from the following sentence:


    CONCATENATE date2 '-' date1 '-' date3
      INTO str3 SEPARATED BY SPACE.

Edited by: Alejandro Bindi on Sep 10, 2008 12:37 AM