Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Subroutine in sapscript for net due date

Hi,

This is the first time I am creating a subroutine for sapscript and I could not get it to work. I need to calculate the net due date using the baseline date plus cash discount days. But the form is just printing out 0000000. I am just trying to extract one due date here but I will have to get it for all line items then sort descending to get the latest one. Can anyone help me to see the gap why this is not working?

In the sapscript I have the following:

DEFINE &BASEDATE& = &REGUP-ZFBDT&

DEFINE &PAYTERMS& = &REGUP-ZBD1T&

PERFORM NET_DUE_DATE IN PROGRAM Z_SAPSCRIPT_FUNCTIONS

USING &BASEDATE&

USING &PAYTERMS&

CHANGING &DUEDATE&

ENDPERFORM

In program Z_SAPSCRIPT_FUNCTIONS

Thanks in advance!

Cholen

Former Member replied

Hi Cholen,

I believe your lv_laufd is a 10 character field in format MM/DD/YYY or DD/MM/YYYY. You should move that data to a 8 character variable (say lv_date) in YYYYDDMM format.

Please try this conversion

    CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

      EXPORTING

        date_external            = lv_laufd

      IMPORTING

        date_internal            = lv_date

      EXCEPTIONS

        date_external_is_invalid = 1

        OTHERS                   = 2.

Check in debug, you should get lv_date in YYYYMMDD. Now use lv_date in your WHERE clause.

If you still do not get data after lv_date eq YYYYMMDD, check your LIFNR and KUNNR. They should be 10 charaters with leading zeroes if not 10 .

If needed use the conversion for lv_lifnr and lv_kunnr.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

      EXPORTING

        date_external            = lv_lifnr

      IMPORTING

        date_internal            = lv_lifnr.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

      EXPORTING

        date_external            =  lv_kunnr

      IMPORTING

        date_internal            =  lv_kunnr.

Cheers,

Raju.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question