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: 

how to link two tables?

Former Member
0 Kudos
2,003

Hello everyone,

I have to extract AFVC-VORNR, AFVC-LTXA1.

I have a AUFK-AUFNR for that.

these 2 tables are linked throuh RSEB.

this is how it is:

aufk-aufnr = rseb-aufnr,

rseb-aufpl = afvc-aufpl.

Now how do I go about this in ABAP.

Pls help. This is important.

5 REPLIES 5

Former Member
0 Kudos
265

Answer is there only.

1. Retrieve AUFNR data from AUFK into an internal table itab_aufk.

2. For all those of itab_aufk retrieve AUFPL info from RESB into itab_ resb by comparing AUFNR.

3. For all entries of itab_rseb, retrieve required data from AFVC by comparing AUFPL into itab_AFVC.

4. final itab will have aufnr, vfoc, ltxa1.

for every entry of aufk-aufnr, Using read statemnt get AUFPL from itab_resb, based on this, again do a read on itab_avfc get the required infor by comparing aufpl.

5. At last u need to append an entry to final itab.

Reward if useful

Pra

Edited by: Praneet on Dec 17, 2007 2:38 PM

Former Member
0 Kudos
265

Do you mean RESB?

Rob

0 Kudos
265

yes RESB.

0 Kudos
265

Try:

REPORT ztest MESSAGE-ID 00.

TABLES: afvc, aufk, resb.

SELECT-OPTIONS: s_aufnr FOR aufk-aufnr.

DATA: BEGIN OF itab OCCURS 0,
        vornr LIKE afvc-vornr,
        ltxa1 LIKE afvc-ltxa1,
      END   OF itab.

SELECT afvc~vornr afvc~ltxa1
  INTO CORRESPONDING FIELDS OF TABLE itab
  FROM afvc
    JOIN resb ON
      resb~aufpl = afvc~aufpl
    JOIN aufk ON
      aufk~aufnr = resb~aufnr
  WHERE aufk~aufnr IN s_aufnr.

Rob

Former Member
0 Kudos
265

Hi Goldie,

Please try this one.

PARAMETERS : p_aufnr LIKE aufk-aufnr.

DATA : BEGIN OF it_afvc OCCURS 0,

vornr LIKE afvc-vornr,

ltxa1 LIKE afvc-ltxa1,

END OF it_afvc.

DATA : BEGIN OF it_resb OCCURS 0,

aufpl LIKE resb-aufpl,

aufnr LIKE resb-aufnr,

END OF it_resb.

SELECT aufnr aufpl FROM resb

INTO TABLE it_resb WHERE

aufnr = p_aufnr.

SELECT vornr ltxa1 FROM afvc

INTO TABLE it_afvc

FOR ALL ENTRIES IN it_resb

WHERE

aufpl = it_resb-aufpl.

Regards

Madhu.

Edited by: madhu tatikonda on Dec 17, 2007 10:01 PM