on 01-31-2008 3:21 PM
Hi experts,
My question is how can I add year, month, or date into a datum in case of sapscript.
For Example:
I want to do something like that: '01.01.2008'+5 month
and the expected result is '01.06.2008'
Hi
Check this FM CALCULATE_DATE
Regards
Gregory
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"In script write this code.
/: PERFORM get_date IN PROGRAM (SY-REPID)
/: USING &DATE& "DATE FIELD
/: CHANGING &DATE2&
/: ENDFORM
AS: &DATE2& "output
"In print program write the this routine
FORM get_date TABLES in_tab STRUCTURE itcsy out_tab STRUCTURE itcsy.
DATA: date TYPE sy-datum,
from_date(10),
out_date(10),
read table in_tab WITH KEY 'DATE'.
IF sy-subrc EQ 0.
from_date = in_tab-value. "will be in 12.01.2008 format
CONCATENATE from_date+6(4) from_date+3(2) from_date+0(2)
INTO date.
CALL FUNCTION 'MONTH_PLUS_DETERMINE'
EXPORTING
months = '5' "add months
olddate = date
IMPORTING
newdate = date.
ENDIF.
READ TABLE out_tab WITH KEY 'DATE2'.
IF sy-subrc EQ 0.
CONCATENATE date+6(2) date+4(2) date+0(4) INTO out_date
SEPARATED BY '.'
out_tab-value = out_date.
MODIFY out_tab INDEX 1.
ENDIF.
ENDFORM.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Here it is.
PARAMETERS: DATE LIKE SY-DATUM,
MONTH(2).
DATE+4(2) = DATE+4(2) + MONTH.
WRITE DATE.
" LIke wise for year ---> DATE+0(4)
" Like wise for days ---> DATE+6(2)
Hope this will solve ur issue.
Cheers,
Vasanth
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Call external sub-routine inside your form
Go through this example
Ex.
/: PERFORM <Subroutine name> IN PROGRAM <subroutine prog name>
/:USING &<field name>&
/:CHANGING &<field name1&
/:ENDPERFORM
Then create subroutine pool program and you have to write the code.
FORM ><subroutine name> tables int_cond structure itcsy
outt_cond structure itcsy.
data : value(20), value1(20). "do your own declarations
Read int_cond table index 1.
value = int_cond-value.
value1 = value1 + value.
Read outt_cond table index 1.
outt_cond-value = value1.
Modify outt_cond index 1.
ENDFORM.
Just rough idea given above.
Regards,
SaiRam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
You would have to call a form routine in a program to execute this calculation and give the result back.
Regards,
John.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.