07-24-2020 9:27 AM
can I connect the two mseg and marc tables with the matnr and werks fields?
07-24-2020 9:35 AM
Hello nick99999
Yes, you can find MARC record for each of the MSEG records by joining MARC with MSEG on mentioned fields.
MARC~MATNR = MSEG~MATNR and MARC~WERKS = MSEG~WERKS
Kind regards,07-24-2020 10:36 AM
thanks for the answer, another question, joining and also doing a where with the MARC fields with the input parameters and in addition a condition between marc and mseg, does the system understand which material it is referring to?
07-24-2020 10:39 AM
Hello nick99999
If you prefix the field with the table name, like shown in my example, then yes, system knows. Otherwise, if it's unknown but required, you will receive an error message, that the field name is ambiguous.
Kind regards,07-24-2020 11:32 AM
Hello nick99999,
Yes you can join the fields from both tables, the ambiguity between the fields are removed using the alias names given to the tables. When the alias names are given system can understand the table to which it is referred to.
Please find the code below for your reference.
SELECT a~matnr,
a~werks,
b~mblnr
FROM marc AS a ---> A is the alias for MARC
INNER JOIN mseg AS b ---> B is the alias for MSEG
ON a~matnr = b~matnr AND
a~werks = b~werks ---> Alias Names used as reference in Join Condition
INTO TABLE @DATA(it_tab)
WHERE a~matnr IN @s_matnr. ---> Alias Names used as reference in where Condition
IF sy-subrc EQ 0.
SORT it_tab BY matnr.
ENDIF.
Regards!