Sunday, August 30, 2009

Add n number of working days to date

Simply add the below FORM into you ABAP code and call it using the usual PERFORM command:
   DATA: ld_date TYPE sy-datum.
PERFORM calculate_date using '-4'
changing ld_date.



*&---------------------------------------------------------------------*
*& Form CALCULATE_DATE
*&---------------------------------------------------------------------*
* Add/Subtract n number of months from a date
*----------------------------------------------------------------------*
* --> p_months Number of months to add/subtract
* <-- p_date Start date and result date
*----------------------------------------------------------------------*

FORM calculate_date USING p_months
CHANGING p_date.

DATA: ld_datestor TYPE sy-datum.

ld_datestor = p_date.

CALL FUNCTION 'MONTH_PLUS_DETERMINE'
EXPORTING
MONTHS = p_months
OLDDATE = p_date
IMPORTING
NEWDATE = p_date.
ENDFORM. " CALCULATE_DATE

No comments:

Tutorials on SAP-ABAP

Adobe Interactive Forms Tutorials

Business Server Pages (BSP)

Userexits/BADIs

Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro,)

ALV Tutorials

goodsites