04-30-2008 9:58 AM
hi all,
how to data in all the internal tables to the final table t_data
*selecting fields from bkpf table
SELECT bukrs
belnr
gjahr
bldat
xblnr
usnam
FROM bkpf
INTO TABLE t_bkpf
WHERE bukrs EQ po_bukrs AND
belnr IN so_belnr AND
budat IN so_budat AND
blart IN so_blart.
IF t_bkpf[] IS INITIAL.
MESSAGE a999(zfi_ap_gl) WITH text-011.
STOP.
ELSE.
*selecting fields from bseg table.
SELECT bukrs
belnr
gjahr
koart
shkzg
dmbtr
zuonr
sgtxt
kostl
hkont
lifnr
prctr
FROM bseg
INTO TABLE t_bseg
FOR ALL ENTRIES IN t_bkpf
WHERE bukrs EQ t_bkpf-bukrs AND
belnr EQ t_bkpf-belnr AND
gjahr EQ t_bkpf-gjahr AND
lifnr IN so_lifnr.
ENDIF.
IF t_bseg[] IS INITIAL.
MESSAGE a999(zfi_ap_gl) WITH text-011.
STOP.
ELSE.
*selecting the companies address from adrc table
SELECT SINGLE addrnumber street str_suppl2 city1
region post_code1
FROM adrc
INTO wa_adrc
WHERE addrnumber EQ w_adrnr.
*selecting adrnr from the lfa1 table
SELECT lifnr adrnr name1 ort01 regio pstlz
FROM lfa1
INTO TABLE t_adrnr
FOR ALL ENTRIES IN t_bseg
WHERE lifnr EQ t_bseg-lifnr.
IF NOT t_adrnr[] IS INITIAL.
*populating the t_vaddress table.
SELECT addrnumber
street
str_suppl2
FROM adrc
INTO TABLE t_vaddress
FOR ALL ENTRIES IN t_adrnr
WHERE addrnumber EQ t_adrnr-adrnr.
*populating the t_vendor table with the vendor address
SELECT lifnr
adrnp_2
namev
name1
INTO TABLE t_vendor
FROM knvk
FOR ALL ENTRIES IN t_adrnr
WHERE lifnr EQ t_adrnr-lifnr AND
adrnp_2 EQ t_adrnr-adrnr.
ENDIF.
ENDIF.
04-30-2008 10:10 AM
Loop the internal table which is having the maximum number of records,then use read table....for other internal tables....in that loop and then append them into final internal table.
Ex-LOOP AT IT_VBRP INTO WA_VBRP.
WA_FINAL-WERKS = WA_VBRP-WERKS_I.
WA_FINAL-KUNAG = WA_VBRP-KUNAG.
WA_FINAL-AEDAT = WA_VBRP-AEDAT.
READ TABLE IT_KONV INTO WA_KONV WITH KEY KNUMV = WA_VBRP-KNUMV
KPOSN = WA_VBRP-POSNR_I.
IF SY-SUBRC EQ 0.
WA_FINAL-KSCHL = WA_KONV-KSCHL.
CLEAR WA_KONV.
ENDIF.
READ TABLE IT_KNA1 INTO WA_KNA1 WITH KEY KUNNR = WA_VBRP-KUNAG.
IF SY-SUBRC EQ 0.
WA_FINAL-NAME1 = WA_KNA1-NAME1.
CLEAR WA_KNA1.
ENDIF.
ENDIF.
APPEND WA_FINAL TO IT_FINAL.
CLEAR: WA_FINAL,WA_KONV,wa_kna1.
ENDLOOP.
04-30-2008 10:17 AM
HI,
loop the large amount of data internal data and read the remaing internal table in that loop and pass values into final internal table.
Regards,
Kranthi.
04-30-2008 10:19 AM
HI Bharath,
Do like this.
Create one final internal table with the fields u want.
LOOP AT i_bseg INTO wa_bseg.
Here use READ TABLE statement to read the data from all other tables and Populate ur final table.
Be carefull of passing right keys.
ENDLOOP.
After this u have ur final internal table with all the required data.
Thanks,
Vinod.