cancel
Showing results for 
Search instead for 
Did you mean: 

Major performance issue in FOX

Former Member
0 Kudos

Hi,

I've a performance issue in FOX code & appreciate if anyone could be of any help.

I'm using distribution funciton to distribute quantities & later I'm using a FOX formula function to adjust prices back to "distributed quantity records".

Distribution funciton is running ok with just 20 seconds but, assigning prices is taking long time in FOX if records are more.

Could someone please suggest any changes in the FOX code that I've written.

FOX formula took 350 seconds for 5000 records & 500 seconds for 7000 records & 700 seconds for 10000 records.

When I say 7000 records, total number of records are double = 14000 as distribution quantity records are stored in 7000 records & prices are stored in different 7000 records.

so, now, I'm deleting 7000 price records & assigning these prices into other 7000 quantity records.

in real time, We'll be dealing with around 14000 records at a time.

Here are 2 sample records

Material Group MONTH CURRENCY DOCCURRENCY WAREA Quantity Price

===============================================================

Materal1 11111 1/2005 ___USD__ _____USD___ USA 500 0.00

Materal1 11111 1/2005 ____#__ ______#____ USA 0 15.45

from the above 2 records, I'm trying to get following record

Material Group MONTH CURRENCY DOCCURRENCY WAREA Quantity Price

===============================================================

Materal1 11111 1/2005 ___USD__ _____USD___ USA 500 15.45

logic is that look for all unassinged (#) records with qunatity equals 0 & assign this record price (2nd record in the above 2 records) to non-unassinged records with quantity > 0 (1st record in the above 2 records) with keys Material, Group, Month, Warea.

here is the FOX code.

DATA MAT TYPE 0MATERIAL.

DATA MAT_1 TYPE 0MATERIAL.

DATA MAT_2 TYPE 0MATERIAL.

DATA MAT_3 TYPE 0MATERIAL.

DATA MFGP TYPE 0MATL_GRP_1.

DATA MFGP_1 TYPE 0MATL_GRP_1.

DATA MFGP_2 TYPE 0MATL_GRP_1.

DATA MFGP_3 TYPE 0MATL_GRP_1.

DATA CMTH TYPE 0CALMONTH.

DATA CMTH_1 TYPE 0CALMONTH.

DATA CMTH_2 TYPE 0CALMONTH.

DATA CMTH_3 TYPE 0CALMONTH.

DATA CURY TYPE 0CURRENCY.

DATA CURY_1 TYPE 0CURRENCY.

DATA CURY_2 TYPE 0CURRENCY.

DATA CURY_3 TYPE 0CURRENCY.

DATA DCUR TYPE 0DOC_CURRCY.

DATA DCUR_1 TYPE 0DOC_CURRCY.

DATA DCUR_2 TYPE 0DOC_CURRCY.

DATA DCUR_3 TYPE 0DOC_CURRCY.

DATA WAR TYPE ZWORLDARE.

DATA WAR_1 TYPE ZWORLDARE.

DATA WAR_2 TYPE ZWORLDARE.

DATA WAR_3 TYPE ZWORLDARE.

DATA PRC_USD TYPE F.

                    • first loop through keys "month, material, group, warea".

FOREACH CMTH,MAT,MFGP,WAR.

**********initialize price to 0 before reading each record

PRC_USD = 0.

FOREACH CMTH_1,MAT_1,MFGP_1,WAR_1,CURY_1,DCUR_1.

                    • look for same keys***********************

IF CMTH_1 = CMTH AND MAT_1 = MAT AND WAR_1 = WAR AND

MFGP_1 = MFGP.

                    • check if quantity is 0

IF {ZQTY_BASE,CMTH,#,#,MAT,MFGP,WAR} = 0.

                    • check if price > 0

IF {Z_USDPRC,CMTH,#,#,MAT,MFGP,WAR} > 0.

**********found a hit with unassigned currency fields & qunatity = 0 & price > 0.

**********store it in a variable.

PRC_USD = {Z_USDPRC,CMTH,#,#,MAT,MFGP,WAR}.

EXIT.

ENDIF.

ENDIF.

ENDIF.

ENDFOR.

FOREACH CMTH_2,MAT_2,MFGP_2,CURY_2,DCUR_2,WAR_2.

                    • look for same keys***********************

IF CMTH_2 = CMTH AND MAT_2 = MAT AND WAR_2 = WAR AND

MFGP_2 = MFGP.

                    • check if quantity > 0***********************

IF {ZQTY_BASE,CMTH,CURY_2,DCUR_2,MAT,MFGP,WAR} > 0.

                    • check if currencies are unassinged as shown in the 2nd record*********

IF CURY_2 <> '#' AND DCUR_2 <> '#'.

                        • found hits for the same keys "material, group, month, warea".

                        • assign price from variable to each non-unassigned (currency <> #) quantity record.

{Z_USDPRC,CMTH,CURY_2,DCUR_2,MAT,MFGP,WAR} = PRC_USD.

ENDIF.

ENDIF.

ENDIF.

ENDFOR.

FOREACH CMTH_3,CURY_3,DCUR_3,MAT_3,MFGP_3,WAR_3.

                    • look for same keys***********************

IF CMTH_3 = CMTH AND MAT_3 = MAT AND WAR_3 = WAR AND

MFGP_3 = MFGP.

                    • check if qunatity = 0 to make sure we delete only price records with no quantity & unassinged currencies

IF {ZQTY_BASE,CMTH,CURY_3,DCUR_3,MAT,MFGP,WAR} = 0.

  • make all record prices = 0 if quantity = 0 as we already

  • assigned prices in the previous loop.

{Z_USDPRC,CMTH,CURY_3,DCUR_3,MAT,MFGP,WAR} = 0.

ENDIF.

ENDIF.

ENDFOR.

ENDFOR.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Also you use two nested loops in you FOX, this should be avoided in FOX.

In ABAP, you can achive your goal by only loop Xth_data table once.

Former Member
0 Kudos

Why you not use ABAP user exit inseatd of FOX? If you get into debug mode, you will notice that one FOX statement will be converted to multiple ABAP statement, considering you use a lot loop in FOX, this will take a lot time to run the FOX.

Former Member
0 Kudos

Hi JW,

Could you explain how we can debug user exits on characteristic relationships.I would like to know what it is delivering when I give the source charcteristic as input . What error mesages it is giving when it is not able to derive . Could you please give the knowhow on this.

Best regards,

Ananth.

Former Member
0 Kudos

Hi Ananth,

I have replied to this particular question about debugging characteristic earlier. You will have to create an exit type function and write the ABAP logic for processing.

Here's the post on debugging characteristic relationship

Hi Ananth,

For debugging the characteristic relationship please put a break point for function module UPC_CHAS_DERIVE, all the characteristic relationships are derived using this FM.

Regarding the exists while executing a function, there's only 2 standard SAP exists provided for the data one is called from the function mentioned above and I will provide you with the name of the second exit in few min.

hope this was helpfull.

thanks