Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Formula planning function not executed the fox code

Hi All,

The formula planning function hadn't executing the fox code. Previously it used to work, i hadn't changed any thing (fields to be changed) in the planning function (it is same as previous). Please look at below

Your valuable inputs are appreciated

Thanks in advance

Regards,

Narendra

Fields to be changed:

0CALDAY.

0DOC_CURRCY.

IO_U2_UN.

0VERSION.

0MATERIAL.

0SOLD_TO.

IODSOPER.

0DOC_CURRCY

The fox code is as follows.

  • This fox calculates plan-sales per day according to

  • business days.

  • Internal Characteristics

DATA DAY TYPE 0CALDAY.

DATA CURR TYPE 0DOC_CURRCY.

DATA UNIT TYPE IO_U2_UN.

DATA VERSION TYPE 0VERSION.

DATA DOC_VERSION TYPE 0VERSION.

DATA PROD TYPE 0MATERIAL.

DATA SOLD_TO TYPE 0SOLD_TO.

DATA OPER TYPE IODSOPER.

  • Internal key figures

DATA WEIGHT TYPE F.

DATA SALES TYPE F.

DATA QUAN TYPE F.

DATA SUM TYPE F.

DATA BUS_DAY TYPE I.

DATA WEIGT_BUS TYPE F.

DATA SALES_DAY TYPE F.

DATA QUAN_DAY TYPE F.

  • Initiate keyfigures and read variable

WEIGHT = 0. SALES = 0. QUAN = 0. SUM = 0.

VERSION = VARV(DSIVERS).

  • Calculate sum of weigtet business days.

FOREACH DOC_VERSION,OPER, DAY, PROD.

IF OPER = 00000100.

WEIGHT = {IODSWGT,DAY,#,#,#,#,00000100,#,DS000001}.

BUS_DAY = {IODSINV,DAY,#,#,#,#,00000100,#,DS000001}.

IF WEIGHT = 0. WEIGHT = 1. ENDIF.

SUM = SUM + (BUS_DAY * WEIGHT).

ENDIF.

ENDFOR.

SALES = 0. QUAN = 0.

  • calculate daily plan-sales

FOREACH DAY,OPER.

  • read business day and weight.

WEIGHT = {IODSWGT,DAY,#,#,#,#,00000100,#,DS000001}.

IF WEIGHT = 0. WEIGHT = 1. ENDIF.

BUS_DAY = {IODSINV,DAY,#,#,#,#,00000100,#,DS000001}.

WEIGT_BUS = WEIGHT * BUS_DAY.

IF WEIGT_BUS <> 0.

FOREACH DOC_VERSION, CURR,UNIT,PROD, SOLD_TO.

  • Split executed on selected version

IF VERSION = DOC_VERSION.

  • Read plan-data

SALES =

{IODSPSAL,#,CURR,PROD,SOLD_TO,DOC_VERSION,

#,UNIT,DS000004}.

QUAN =

{IODSPQTY,#,CURR,PROD,SOLD_TO,DOC_VERSION,

#,UNIT,DS000004}.

  • Calculate daily sales.

IF SALES <> 0 OR QUAN <> 0.

SALES_DAY = (SALES/SUM) * WEIGT_BUS.

QUAN_DAY = (QUAN/SUM) * WEIGT_BUS.

  • write result

{IODSPSAL,DAY,CURR,PROD,SOLD_TO,VERSION,

#,UNIT,DS000004}

= SALES_DAY.

{IODSPQTY,DAY,CURR,PROD,SOLD_TO,VERSION,

#,UNIT,DS000004}

= QUAN_DAY.

ENDIF.

ENDIF.

ENDFOR.

ENDIF.

ENDFOR.

  • Delete original planposting on not-allocated day

FOREACH DAY, DOC_VERSION, CURR, UNIT, PROD.

IF DOC_VERSION = VERSION.

{IODSPSAL,#,CURR,PROD,SOLD_TO,DOC_VERSION

,#,UNIT,DS000004} = 0.

{IODSPQTY,#,CURR,PROD,SOLD_TO,DOC_VERSION

,#,UNIT,DS000004} = 0.

ENDIF.

ENDFOR.

Former Member
Not what you were looking for? View more on this topic or Ask a question