cancel
Showing results for 
Search instead for 
Did you mean: 

How to iterate master data values from a characteristic in FOX Code?

07-26-2018 3:09 AM
2788 views 9 comments
0 Likes
SAP Managed Tags
Subscribe

Hi, experts,

I need to iterate through all the values a characteristic has. I need to iterate 0EMPLOYEE because I need to make calculations specific to each employee, and to store that information in specific values for each employee.

I can not use exiting transactional data to iterate because I don't have any related to all the employees.

I tried using FOREACH employee in REF DATA but I also get '#' values.

Does anyone know what the correct syntax is or if it's possible?

Thank you in advance.

0 Likes

Accepted Solutions (0)

Answers (5)

Answers (5)

Noel_Munday
Product and Topic Expert
Product and Topic Expert
0 Likes

I did the following:

1. Set the characteristic to be an InfoProvider - this enables you to create a query directly on the InfoObject

2. Create a query on the InfoProvider and use it's ID as the output

3. Create a replacement path variable which uses a query and use the query from 2

4. In your filter to the planning sequence use your new replacement path variable as the selection as this will now contain all master data values

5. In your fox code use the following statement: FOREACH var IN SELECTION. .... ENDFOR.

0 Likes

Typo, It's ENDFOR.

0 Likes

Hi Nidia,

If you wanted all the transaction records of your reference data to be part of calculation logic and exclude only a part of your dimension member,

Use

FOR EACH DIM1,DIM2,DIM3,....,#, DIMn in REFDATA,

IF DIM1<> 'Exclusion set' AND DIM2 <> 'Exclusion set'.

--- Logic ---

ELSE

--- Logic ---

ENDIF.

END.

Hope this will help you. If you think, your concern isn't addressed yet, please post the sample data set and explain your requirement on that data set. It will help us to answer more appropriate to the requirement.

Thank you

Regards,

Harsha

sheldon_piao
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Nidia,

I try understanding your requirement and seems you need to enhance the reference data selection. If it is, please refer to link:
https://help.sap.com/viewer/0ecf5244825c4742a7b062a89d11c2ac/7.5.12/en-US/f1f5721c63e6482cbbd89ee683...

The example in this page is:

---

  • By using the KEEP statement, you can prevent the system from deleting the reference data:

    KEEP REFDATA SELECTION FOR 0FISCPER.

  • To explicitly request additional reference data, you can use the ENHANCE statement:

    ENHANCE REFDATA SELECTION FOR 0FISCPER: 2015001, 2016001, #.

    You can also use global variables in this list:

    ENHANCE REFDATA SELECTION FOR 0FISCPER: 2015001, VARIABLE FISCPERVAR.

    To request all available data that corresponds to the deletion of the filter, write the following:

    ENHANCE REFDATA SELECTION FOR 0FISCPER: *.

---

If it is not what you need, maybe you can try to illustrate your issue with one vivid example and then we can know your issue better.

Best Regards,

Sheldon

cornelia_lezoch
Active Contributor
0 Likes

Hi Nidia,

you might want to use "foreach in selection" but then you also need a selection for the employees.

if you want to use "foreach in refdata" you need to read in the upcoming code some refdata - that needs to be transactional data from a cube or DSO.

regards

Cornelia

former_member381836
Participant
0 Likes

Hi, Cornelia. Thank you for your answer but I do not want the user to have to select all employees each time. Is there any other way you can think of? 😮

cornelia_lezoch
Active Contributor
0 Likes

probably yes, but without knowing your data model, all the selections that you use and the target what the function shall do, it´s hard to tell

former_member381836
Participant
0 Likes

Sure, but based on on what I've described, is there a way to do that?

cornelia_lezoch
Active Contributor
0 Likes

you did not give enough information to come up with more ideas than what I had already written.

So if you want to have more help, give more info about what exactly you want to do, post the code that you already have ...