cancel
Showing results for 
Search instead for 
Did you mean: 

date in digits

Former Member
0 Kudos

i want to display following date in script.

i want to add and subtract following dates and display in digits.

BSEG-ZFBDT + BSEG-ZBDIT - BKPF-BUDAT = No .of days.

Ex : 19.05.2009 + 30.05.2009 - 20.06.2009 = 20 days.

above case in my script i want to display 20.

Pls clarify the same.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ,

BSEG-ZFBDT+0(2) + BSEG-ZBDIT0(2) - BKPF-BUDAT0(2) = No .of days.

Ex : 19.05.2009 + 30.05.2009 - 20.06.2009 = 20 days.

or else u have function modules to calculate difference between two dates, and then u can calculate by passing to variables.

Regards,

Vijaya Lakshmi.T

Answers (3)

Answers (3)

Former Member
0 Kudos

hi Subba,,

In a sapscript it self you cannot subtract, add, divide or multifly.

If you really need it then you have to possiblities.

1. In the printprogram

Do the calculation and put the answer in a global variable

BSEG-ZFBDT + BSEG-ZBDIT - BKPF-BUDAT = GV_DAYS.

2. Use a PERFORM

PERFORM DELTA_DAYS IN PROGRAM Z_SCRIPT_FUNCTIONS

DELTA_DAYS is a FORM you must develop

Z_SCRIPT_FUNCTIONS is a module-pool you must create..

Yuo get something like

/: DEFINE &GV_DAYS& := ' '

/: PERFORM DELTA_DAYS IN PROGRAM Z_SCRIPT_FUNCTIONS

/: USING &BSEG-ZFBDT&

/: USING &BSEG-ZBDIT&

/: USING &BKPF-BUDAT&

/: CHANGING &GV_DAYS&

/: ENDPERFORM

i would choose method 1. With method2 you will need some extra statements to avoid problems with

the format of string and date fields.

Gr., Frank

Former Member
0 Kudos

Hi Subba,

You can directly write the statement:

BSEG-ZFBDT + BSEG-ZBDIT - BKPF-BUDAT = No .of days.

The system will return the result.

Former Member
0 Kudos

Hi,

Move the dates into 3 different integer fields and it will give you number of days so that you can add

them and subtract them to get the number of days.

Data: w_i type i,
      w_j type i,
      w_k type i.

Move BSEG-ZFBDT to w_i
Move BSEG-ZBDIT to w_j
Move BKPF-BUDAT to to w_k

w_tot = w_i + w_j - w_k.

Ex: if date is 20090513.
      when you move it to an integer it will give you number of days from 00010101 to 20090513.
  "  i.e.   733,541 days

Do this in a perform so you can get total...

Thanks&Regards

Sarves Sombhatla