cancel
Showing results for 
Search instead for 
Did you mean: 

When 2 fields in one table refer to 1 field in another table

Former Member
0 Kudos

Hi friends, I have got 2 tables.

                                                         In 1st table MATNR exists as PMATNR and SMATNR.

                                                         In 2nd table only MATNR exists (logically it has the values of both PMATNR & SMATNR).

Common field is Location(LocNo).

                      Now I need to retrieve fields AT101 and AT104 from 2nd table based on Location and MATNR.

                     

Each record in 1st table will have 2 records in 2nd table (as MATNRs are classified into 2 types)..

                      How do I pass values of both PMATNR and SMATNR  from 1st table to a single MATNR field(in 2nd table) along with Location and retrieve AT101 and AT104 from 2nd table??

Pls help me out...

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Aravindh,

Can you share how MATNR exist as PMATNR and SMATNR in the table with example and also which are standard tables you referencing ?

Thanks & Regards,

Arun

Former Member
0 Kudos

Hi Aruna,

               PMATNR - Predecessor MATNR

               SMATNR - Successor MATNR

Table is APO table.(/SAPAPO/V_MATLOC - 2nd table name )

ALL 3 MATNRs are declared as types of /SAPAPO/MATNR. Am just making changes to already existing program and am a beginer in ABAP. correct me pls if am wrong

Former Member
0 Kudos

Hi,

As I understood in table 1 no field called MATNR instead you have PMATNR and SMATNR and in second table field called MATNR.

1. Are you looking to pass both PMATNR and SMATNR of table 1 to tabl2 ? If yes then you need to     prepare range of MATNR .

Like

       R_MATNR-SIGN = 'I'.

       R_MATNR-OPTION = 'EQ'.

       R_MATNR-LOW = PMATNR.

       APPEND R_MATNR.

       R_MATNR-LOW = SMATNR.

       APPEND R_MATNR.

Pass R_MATNR to second table2.

This is rough code need to correct accordling.  Ranges are used to prepare select option internally . Usage same as select option.

Read more about ranges.Note what i have given in obsolete way of range . Instead you declare range as

DATA: r_matnr type range of /SAPAPO/MATNR.

2. Else case you decide which field (PMATNR or SMATNR )value need to pass table 2 . For that you need to check with functional guy.

Thanks & Regards,

Arun

Former Member
0 Kudos

Hi Arun,

             U r correct with ur point 1.  Am passing both PMATNR and SMATNR. Let me check with Range as u said. Thanks much..