2007 Dec 10 1:10 PM
What is the way to fetch data from different fields of multiple tables which are connected ?
Please give me an example of more than 3 tables .
What is the way to fetch data from different fields of multiple tables which are connected ?
Please give me an example of more than 3 tables .
2007 Dec 10 1:12 PM
Hi,
Use FOR ALL ENTRIES
Refer this code
&----
*& Form SUB_READ_VBRK
&----
text
----
FORM sub_read_vbrk.
SELECT vbeln
rplnr
bukrs
FROM vbrk
INTO TABLE it_vbrk
WHERE vbeln IN s_vbeln
AND rplnr NE ' '.
IF sy-subrc EQ 0.
SORT it_vbrk BY rplnr.
ENDIF.
ENDFORM. " SUB_READ_VBRK
&----
*& Form SUB_READ_FPLTC
&----
text
----
FORM sub_read_fpltc.
IF NOT it_vbrk[] IS INITIAL.
SELECT fplnr
fpltr
ccnum
FROM fpltc
INTO TABLE it_fpltc
FOR ALL ENTRIES IN it_vbrk
WHERE fplnr EQ it_vbrk-rplnr
AND ccins EQ 'GIFC'.
IF sy-subrc EQ 0.
SORT it_fpltc BY fplnr.
ENDIF.
ENDIF.
ENDFORM. " SUB_READ_FPLTC
&----
*& Form SUB_COLLECT_DATA
&----
text
----
FORM sub_collect_data.
*--Local variables
DATA : lv_count(3) TYPE c.
IF NOT it_fpltc[] IS INITIAL.
LOOP AT it_fpltc INTO wa_fpltc.
lv_count = wa_fpltc-fpltr+3(3).
wa_final-ccnum = wa_fpltc-ccnum.
wa_final-rfzei = lv_count.
CLEAR : wa_vbrk.
READ TABLE it_vbrk INTO wa_vbrk WITH KEY rplnr = wa_fpltc-fplnr
BINARY SEARCH.
IF sy-subrc EQ 0.
wa_final-vbeln = wa_vbrk-vbeln.
wa_final-bukrs = wa_vbrk-bukrs.
ENDIF.
APPEND wa_final TO it_final.
CLEAR : wa_vbrk,
wa_fpltc,
lv_count.
ENDLOOP.
ENDIF.
ENDFORM. " SUB_COLLECT_DATA
Regards,
PRashant
2007 Dec 10 1:13 PM
Hi Jyotirmoy,
Try out with the following code.
SELECT a~matnr
a~berid
a~dismm
a~ausss
a~sobsl
b~berty
INTO TABLE it_mdma_mdlv_mdll
FROM mdma AS a
INNER JOIN mdlv AS b
ON aberid EQ bberid
INNER JOIN mdll AS c
ON bberid EQ cberid
FOR ALL ENTRIES IN it_bomitems
WHERE a~matnr EQ it_bomitems-idnrk
AND a~dispo IN s_cdispo
AND b~berty EQ '3'
AND a~sobsl IN s_csobsl
AND c~lbear IN s_lifnr.
this query contains join for 3 different tables.
regards,
vikas.
plz reward if helpful..
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |