Skip to Content
avatar image
Former Member

BW FOX Function to read characteristic value and store in local variable.

Here's a ridiculously simple, but baffling FOX question;

How do you read the value of a characteristic field (ZASEMP) into a local variable (ASE)?

My InfoCube has a characteristic ZASEMP, which has a reference characteristic of 0PERSON and is type NUMC Character string with only digits.


* This works, sets ASE to employee 00000017.
ASE = 00000017.

*This doesn't work

*This doesn't work

*This doesn't work

*This doesn't work
ASE = OBJV ( ).

*Out of desperation, doesn't work

Here's what I am trying to do:
I need to store the value of the characteristics ZASEMP from the first record, so that I can populate subsequent records with that characteristic value, which is now blank.

Any ideas of what I'm doing wrong here?



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • avatar image
    Former Member
    Nov 30, 2016 at 10:45 PM

    Attached is a screen shot of a small record set.

    Note that the first record has sales employee assigned to it to represent annual sales. I want to use the monthly percentages defined for a product group to distribute those annual sales to monthly time periods.

    So I need to be able to capture the value of the employee 17 from the first record to use it when creating the monthly sales records for this employee and product group. What's the best way to accomplish this?



    Thanks again,


    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 30, 2016 at 11:04 PM

    Hi Bob,

    Based on the way you have framed the question, I assume that ZASEMP is positioned in "Flds to be changed".

    If this is the case, make use of FOREACH loop with appropriate order of the chars and read the 1st value of ZASEMP into local variable and EXIT the loop after 1st iteration. To make it still simple, if you confident that there can be only one record among the block data, which can have the value for ZASEMP you can write - FOREACH ASE IN REFDATA. EXIT. ENDFOR. and ASE will have the value based on REFDATA.

    There are more ways to read the value into the local variable such as passing it directly using BEX Variable etc. we can decide the method best suitable based on requirement.

    Let me know if this helps!!


    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 01, 2016 at 01:42 AM

    Hi Raghu,
    Thanks for your reply.

    Yes, I want to confirm that field ZASEMP is included in the list of fields to be changed in my planning function FORMULA.
    And yes, I am using a FOREACH loop as you suggested

    But my problem is doing "read the 1st val of ZASEMP into a local variable." Can you suggest the code that does this? I know this is an extremely dumb question, but I can't make it work. My original post showed my failed code attempts to populate the local variable.

    My attached code works just fine if, AND THIS IS A BIG IF, the monthly records are populated with the value of the employee before the calculation is done, which is another way of saying that each sales employee has his own monthly distribution percentages.

    The problem is that I want the monthly distribution percentages to be defined by product group, and then applied to the annual sales of that product by the sales person.

    Also my research indicates that in such a case (where the receiving records do not already have the value of the sales employee) the FOREACH ENDFOR statement can not be used, and that you must use the DO ENDO statement.

    So I am still stuck trying to read the value of the sales employee from the first record and populate the local variable, which they I can reference in my DO ENDDO loop.

    Here is my code, which has no syntax errors.


    Can you elaborate on other ways to capture the value of the field ZASEMP and store it in a local variable ASE?

    Many thanks,


    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 01, 2016 at 04:14 PM

    Hi Robert,

    Please find the solution with an explanation attached...


    Cube Data,

    Similar to yours:

    The Filter

    for the planning sequence, contains Target Area.

    Planning Function.


    We want to read the record with the employee’s monetary value of $100,000. Since we have employee, we don’t want to change it in the function – Employee thus is a block characteristic and the % is reference data. So the Char. Usage is as follows:

    The FOX:

    *Read the reference amount, this will give the orignial amount against which the % needs to be calcualted,*In effect, return the record with the employee 680 'attached', since employee is a block characteristic.
    REF_AMOUNT = {0AMOUNT, # }.
    *Loop through all the periods in our reference data.
    FOREACH FISCPER IN REFDATA.*Calculate the results records per period of the reference %.

    Planning Sequence:

    Execute in Trace Mode:

    Results in CUBE:

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 03, 2016 at 07:31 PM

    I very much appreciate Lambertus's guidance, but unfortuantely I'm not out of the woods yet. Lambertus responded using examples from BW-IP, but I am working with the dinosaur SEM-BPS. His example works perfectly.

    I think there are differences between the two, for example, my google searches do not return hits for SAP BPS and REFDATA.

    So I have attached my screeprints in BPS to correspond to what Lambertus did in BW-IP.

    Again to state the objective of this seemingly trivial exercise, multiply the annual sales of a product and employee (version 0), by monthly percentages dependent on the product only, with version 100, not the employee to determine that distribution of that product/employee sales over a period of months, 4 in my example (Version 0).

    I find it surprising that imaget doesn't recognize 0AMOUNT, while in image 1, you can clearly see it as a column heading.

    I tried to simplify my example for my original posting, and should that clarify that I want do monthly distributions for multiple products for annual sales of multiple products made by multiple employees.

    Once again, thanks for any assistance.

    pic1-infocube-contents.png pic2-planning-level-and-planning-package-selection.pngpic3-planning-function.pngpic4-fox-parameter-group.png

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 11, 2016 at 12:34 PM

    Below is a solution to the problem I originally posted, but uses a distribution with reference rather than formula planning function. I have documented in the screen images below, beginning with the InfoCube's contents and then documenting the analysis to determine the proper settings for the planning function.

    Here are the images from BPS and the desired results

    Add comment
    10|10000 characters needed characters exceeded