Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Reference field of another table for QUAN / CURR field of a table

Former Member
0 Kudos

What is the meaning / use of refering a CURR / QUAN field to another table and its field?

I do have a reference table T2 with reference field CK of type CUKY. I am assigning this field CK as a reference field to my table T1 with a field SAL of type CURR.

How do I utilize this reference (say I have only 2 entries for the CK with values USD, YEN) for each and every row of my table T1?

Thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Reference field value assignment take place runtime. If a field with currency amounts is filled, the associated currency from the assigned reference field is determined, that is, the value entered at this time in the reference field determines the currency used.

regards,

Pranav

8 REPLIES 8

Sandeep_Kumar
Product and Topic Expert
Product and Topic Expert
0 Kudos

F1 help is the best way to find out .

Former Member
0 Kudos

Reference field value assignment take place runtime. If a field with currency amounts is filled, the associated currency from the assigned reference field is determined, that is, the value entered at this time in the reference field determines the currency used.

regards,

Pranav

0 Kudos

the associated currency from the assigned reference field is determined, that is, the value entered at this time in the reference field determines the currency used

The documentation too says so.

This can mean that we could do with only a single record in T2 and whenever we input values in the T1 table, the current value in the record in T2 is taken as the CUKY.

But then how do we retrieve back the corresponding CUKY for each record in T1?

0 Kudos

This can mean that we could do with only a single record in T2 and whenever we input values in the T1 table, the current value in the record in T2 is taken as the CUKY.

No, the T2 field is the reference for output purposes - there's no table linkage.

But then how do we retrieve back the corresponding CUKY for each record in T1?

If you use a reference field from another structure or table, then that table field should have a value at runtime for output. Otherwise, the fields are rendered without consideration for currencies/units involved, i.e., with all decimals. It's a common mistake that developers make to put a non-relevant reference field on the definition, such as when creating a Z-table currency field and attaching BSID-WAERS to it.

0 Kudos

Thanks for the response Brad, but I am still not getting it ironed out in my mind. Is there more documentation / reference on this somewhere?

the T2 field is the reference for output purposes

Suppose I am using kgs and gms for a UNIT field, how do I differentiate those for my non-output purposes (for calculation)? Do I have to store everything in a single unit but show the output after conversion? Still, on what basis should I convert and output that I got 1000kgs of sugar and only 1000gms of salt left?

then that table field should have a value at runtime for output

Which record of that table field does it take at runtime? The last? Or need the no of records be same in both the tables? I'm confused.

I saw a table MBEW with external reference to fields of T0001 and MARA.

0 Kudos

There is probably some information in the help files or on the individual data elements. If I'm not explaining well enough, I apologize - it's one of those things I take for granted after 15 years but also one of those things I see done incorrectly quite a bit. What you don't want to do is create a 'dead reference' which suffices to activate the table but has no meaning in your application.

Suppose I am using kgs and gms for a UNIT field, how do I differentiate those for my non-output purposes (for calculation)? Do I have to store everything in a single unit but show the output after conversion? Still, on what basis should I convert and output that I got 1000kgs of sugar and only 1000gms of salt left?

For transactional data, you should store both the quantity and uom on the same record. Take sales order items as an example: VBAP-ZMENG has VBAP-ZIEME and VBAP-KWMENG has VBAP-VRKME. The reference field serves not only as the 'reference for output' (how to display it) but also as the indicator for how much the quantity represents and how it needs to be converted (if necessary).

I saw a table MBEW with external reference to fields of T0001 and MARA

Right, because those fields are defined based on those references, e.g., the total valuated stock quantity is in the base uom for the material and the value of the stock is in the currency of the company code to which the valuation area is assigned - there's no need to store the uom or currency again in MBEW. Also keep in mind that in MM applications those fields will have values at runtime and trigger the 'correct' display of the values in screens. If you'll execute SE16 and display the fields, you'll see that the decimals are not handled for those fields because the reference fields do not exist in the generated screens at runtime.

0 Kudos

Hi,

Agree with Brad. Nice explanation Brad.

Most of the time with transactional tables, you will find UOM field maintained in the same table. So, in your case, table T1 will have qty and uom field so that you can clearly figure out 1000 kg of sugar and 1000 gms of salt. Ideally we should use UOM field from same data structure in reference field. But if we want to use external data structure in reference field (like in MBEW) then there should be one to one cardinality between those tables.

regards,

Pranav

0 Kudos

Brad, I can guess how fast thought travels with experience and it is difficult to slow down. Also, might be I need more time grasping as I have to re-write many concepts from my 4 yrs stint with java.

What you don't want to do is create a 'dead reference'

That was the exact doubt in my mind. I should have framed the question so. Sorry.

the total valuated stock quantity is in the base uom for the material and the value of the stock is in the currency of the company code to which the valuation area is assigned

So, there is some relation between the records of the two tables, which the code / consultant need to know for retreiving the corresponding unit / currency key, and that the database will not get us automatically unlike in the same record for an internal reference. I hope I will get a more clear picture once I dive into the business flow and the SAP standard tables.

But if we want to use external data structure in reference field (like in MBEW) then there should be one to one cardinality between those tables

Pranav, I do not think the external reference has any relation with cardinality or the foreign key concept.

Imagine that I have 5 varieties of sugar and 3 varieties of salt in my shop. This makes a total of 7 records in my table T1. As a simplest case, I need to give only 2 records for T2 and assign external reference for T1-QNTY to T2-UNT

My T1 would look like:

ITM_GRP ITM_NO ITEM QNTY

sgr 101 sugar_1 1000

sgr 102 sugar_2 999

sgr 103 sugar_3 750

sgr 104 sugar_4 153

sgr 105 sugar_5 0

slt 201 salt_1 1000

slt 202 salt_2 100

slt 203 salt_3 200

My T2 would be:

ITM_GRP UNT

sgr kgs

slt gms

While retreiving, I might have to query from both.