cancel
Showing results for 
Search instead for 
Did you mean: 

Transformation routine - ABAP Code required

Former Member
0 Kudos

Hello ALL,

I am new to ABAP programming.

I have requirement where I need to calculate the field ZATTN based on the sales quantity and Invoice date.

The formula required for ZATTN is as follows

ZATTN = (sales qty * no.of days in Invoice Month) / Invoice date (DD)

For example -

Sales Qty = 100 and Invoice date = 2009.06.05

ZATTN = (100* 30) / 5

Here

value 30 is based on the month from Invoice date (2009.06.05), for month 06, no of days = 30.

value 5 is based on the day from Invoice date(2009.06.05), for day DD = 05

Please provide logic for the above.

thanks,

Pra

Accepted Solutions (0)

Answers (1)

Answers (1)

dennis_scoville4
Active Contributor
0 Kudos

To get the number of days in the month, use the Function Module /OSP/GET_DAYS_IN_MONTH. The input for this is the invoice date and the output from it will provide you with the number of calendar days in that month. To get the day number for the month, you could just do a substring on the date field into a variable - something like l_dd = invoice_date+6(2).


DATA: l_days_in_month TYPE /OSP/DT_DAY,
      l_dd(2) TYPE n.

CALL FUNCTION '/OSP/GET_DAYS_IN_MONTH'
  EXPORTING
    iv_date       = invoice_date
  IMPORTING
    EV_DAYS       = l_days_in_month
          .

l_dd = invoice_date+6(2).

ZATTN = ( invoice_qty * l_days_in_month ) / l_dd.

Former Member
0 Kudos

Hi Dennis Scoville,

Thanks for the reply - Pra.