Application Development and Automation 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: 
Read only

scripts

Former Member
0 Likes
626

hi to all,

pplz help me in the issue,

i am having a field 'mhnk-ausdt' it is rundate in dunning

i need mhnk-ausdt + 7th day day like ex

mhnk-ausdt is 14th sep and 7th day of it is 21st sep

how can i achieve this.

thanks in advance

kiran kumar

Message was edited by: kiran kumar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
588

Hi Kiran,

It is very simple since all date type fields in abap (in tables - type 'DATS', in programs - type d, also sy-datum in system table, etc.) are treated as simple numbers (integers, if u will...).

This means that if u check the value of these fields (in debugger) u will find the date today is 20060914 - this is YYYYMMDD format but it is treated as a number. With numbers u can do arithmetic operations: add, sub, etc.

Now all u have to do is add 7 and get the date u r looking for...

U don't have to check if it went to the next month or year since the system knows to do that. For example: if your field, mhnk-ausdt, has 30th dec 2006 in it, after adding 2 the result will be 1st jan 2007.

The system will calculate 20061230 + 2 and the result is 20070101.

Hope this covers it...

Igal

(Pls reward if it helps)

5 REPLIES 5
Read only

Former Member
0 Likes
588

Use the function module DATE_IN_FUTURE.

You can add 7 days to the date you pass.

Read only

Former Member
0 Likes
588

to add 7 days to field 'MHNK-AUSDT' can be done by

MHNK-AUSDT = MHNK-AUSDT + 7.

The above statement will add 7 days to the date. The above statement has to writted in the print program.

If you want to add the 7 days to the date in the form then you have to use PERFORM control command by passing the 'MHNK-AUSDT'.

In SAPSCRIPT:

/: DEFINE &V_DATE&

/: PERFORM GET_DATE IN PROGRAM ZPROG

/: USING &MHNK-AUSDT&

/: CHANGING &V_DATE&

/: ENDPERFORM

Coding of the calling ABAP program:

REPORT ZPROG.

FORM GET_DATE TABLES IN_PAR STUCTURE ITCSY
                     OUT_PAR STRUCTURE ITCSY.
data: l_date like sy-datum.
*-- if the date is in MM/DD/YYYY format


READ TABLE IN_PAR WITH KEY ‘MHNK-AUSDT’.

IF SY-SUBRC = 0.
l_date+0(4) = IN_PAR-VALUE+6(4).
l_date+4(2) = IN_PAR-VALUE+0(2).
l_date+6(2) = IN_PAR-VALUE+3(2).
ENDIF.
l_date = l_date + 7.

READ TABLE OUT_PAR WITH KEY ‘V_DATE’.
IF SY-SUBRC = 0.
  write l_date to OUT_PAR-VALUE.
  MODIFY OUT_PAR INDEX SY-TABIX.
ENDIF.

ENDIF.

Read only

0 Likes
588

hi sid

how to use perfrom control command for getting the desired date

tahnks in advance,

kiran kumar

Read only

0 Likes
588

/: DEFINE &V_DATE&

/: PERFORM GET_DATE IN PROGRAM ZPROG

/: USING &MHNK-AUSDT&

/: CHANGING &V_DATE&

/: ENDPERFORM

Coding of the calling ABAP program:

REPORT ZPROG.

FORM GET_DATE TABLES IN_PAR STUCTURE ITCSY

OUT_PAR STRUCTURE ITCSY.

data: l_date like sy-datum.

*-- if the date is in MM/DD/YYYY format

READ TABLE IN_PAR WITH KEY ‘MHNK-AUSDT’.

IF SY-SUBRC = 0.

l_date0(4) = IN_PAR-VALUE6(4).

l_date4(2) = IN_PAR-VALUE0(2).

l_date6(2) = IN_PAR-VALUE3(2).

ENDIF.

l_date = l_date + 7.

READ TABLE OUT_PAR WITH KEY ‘V_DATE’.

IF SY-SUBRC = 0.

write l_date to OUT_PAR-VALUE.

MODIFY OUT_PAR INDEX SY-TABIX.

ENDIF.

ENDIF.

Read only

Former Member
0 Likes
589

Hi Kiran,

It is very simple since all date type fields in abap (in tables - type 'DATS', in programs - type d, also sy-datum in system table, etc.) are treated as simple numbers (integers, if u will...).

This means that if u check the value of these fields (in debugger) u will find the date today is 20060914 - this is YYYYMMDD format but it is treated as a number. With numbers u can do arithmetic operations: add, sub, etc.

Now all u have to do is add 7 and get the date u r looking for...

U don't have to check if it went to the next month or year since the system knows to do that. For example: if your field, mhnk-ausdt, has 30th dec 2006 in it, after adding 2 the result will be 1st jan 2007.

The system will calculate 20061230 + 2 and the result is 20070101.

Hope this covers it...

Igal

(Pls reward if it helps)