cancel
Showing results for 
Search instead for 
Did you mean: 

Lookup in FOX using REFDATA

Former Member
0 Kudos

Hello Everyone,

      I'm trying to do a look up in FOX to read Prices from another DSO. In my case, I won't be able to use "|" method as I need to loop Reference Data to apply some conditions. Prices DSO has the data at granularity customer & material, validity dates, price type. Filter was restricted to Plan DSO. Pricing DSO is already part of MP and Agg Level.

I don't see my code is working... even in debugging XF_REF_DATA internal table has Plan Data, not reference data. Am i missing something? I can see reference data for "|" method. Please let me know if you need more information. Thanks a lot for all your help.

Code:

CURDATE = VARV( 0DAT ).

FOREACH MATERIAL, CUSTOMER.

FOREACH MATERIAL_REF, CUSTOMER_REF,CALDAY_REF, CALDAY_FR, CALDAY_TO, CURRENCY, KNART IN REFDATA.

  IF MATERIAL_REF = MATERIAL AND

       KNART = 'ZNLP' AND

       CURDATE >= CALDAY_FR AND

       CURDATE <= CALDAY_TO.

    L_LPRC = { 0KNVAL, CALDAY_REF, #, CUSTOMER_REF,CURRENCY,KNART, MATERIAL_REF, CALDAY_FR, CALDAY_TO }.

  ENDIF.

ENDFOR.

  { 0PRICELIST, #, USD, CUSTOMER, #, #, MATERIAL, #, # } = L_LPRC.

ENDFOR.

Regards,

Benarji.

Accepted Solutions (1)

Accepted Solutions (1)

cornelia_lezoch
Active Contributor
0 Kudos

Hi Benarji,

your loops don´t work, becasue with the

FOREACH MATERIAL, CUSTOMER

you are within one combination of material and customer.

within this you can not do another loop for the same char.


regards

Cornelia

Former Member
0 Kudos

i'm trying to loop reference data in the 2nd loop, not the current package.

cornelia_lezoch
Active Contributor
0 Kudos

well, but as you experienced it - it is not working the way you defined the loops.

In your code you have to change as following:

1) take the material out of the fields to be changed, because of the IF MATERIAL_REF = MATERIAL

2) do the loops as below:

FOREACH CUSTOMER_REF, CALDAY_REF, CALDAY_FR, CALDAY_TO, CURRENCY, KNART IN REFDATA.

  IF  KNART = 'ZNLP' AND

     

change the logic here, you used the terms in wrong direction:

CALDAY_FR <= CURDATE  AND

CALDAY_TO >= CURDATE.

    L_LPRC = { 0KNVAL, CALDAY_REF, #, CUSTOMER_REF,CURRENCY,KNART, CALDAY_FR, CALDAY_TO }.

  ENDIF.

ENDFOR.

foreach customer.

  { 0PRICELIST, #, USD, CUSTOMER, #, #,  #, # } = L_LPRC.

ENDFOR.

what is still strange, if there are more than one data redord foun within the reference data, the last one will win ...

regards

Cornelia

Answers (1)

Answers (1)

former_member194957
Active Participant
0 Kudos

Hi Benarji,

          You can seperate the 2 loops.You can try this..

FOREACH MATERIAL, CUSTOMER,MATERIAL_REF, CUSTOMER_REF,CALDAY_REF, CALDAY_FR, CALDAY_TO, CURRENCY, KNART IN REFDATA.

  IF MATERIAL_REF = MATERIAL AND

       KNART = 'ZNLP' AND

       CURDATE >= CALDAY_FR AND

       CURDATE <= CALDAY_TO.

    L_LPRC = { 0KNVAL, CALDAY_REF, #, CUSTOMER_REF,CURRENCY,KNART, MATERIAL_REF, CALDAY_FR, CALDAY_TO }.

**pass the value here

{ 0PRICELIST, #, USD, CUSTOMER, #, #, MATERIAL, #, # } = L_LPRC.

  ENDIF.

ENDFOR.


this should work. Also make sure that whatever characteristics you have used after FOREACH is selected as characteristics to be changed .

Let me know the result..after trying this..

Thanks,

Tharun