12-13-2011 5:39 AM
Dear All,
i am taking name address, and email from lfa1 and adr6 table into IT_LFA1 internal table.
then i use select fro all entries and take data from BSIK table to IT_BSIK.
now i want to add :
name1, ort01, adrnr, pstlz, telf1, smtp_addr fields into IT_BSIK internal table
these all fields are in IT_LFA1.
i am using the code:
loop at it_bsik into wa_bsik.
read table it_lfa1 with key lifnr = it_bsik-lifnr into wa_lfa1 .
wa_bsiK-LIFNR = wa_LFa1-LIFNR.
wa_bsiK-name1 = wa_LFa1-name1.
wa_bsiK-ort01 = wa_LFa1-ort01.
wa_bsiK-adrnr = wa_LFa1-adrnr.
wa_bsiK-pstlz = wa_LFa1-pstlz.
wa_bsiK-TELF1 = wa_LFa1-TELF1.
wa_bsiK-SMTP_ADDR = wa_LFa1-SMTP_ADDR.
modify it_bsiK from wa_bsik.
CLEAR: wa_bsiK ,wa_LFa1.
ENDLOOP.
but in this in wa_lfa1 by default i get last record. so loop runs only for last record not for all the records.
kindly help me for the same.
With Regards,
Sulabh Agrawal
12-13-2011 5:51 AM
Hi
Replace This line only....
read table it_lfa1 with key lifnr = it_bsik-lifnr into wa_lfa1.
to
read table it_lfa1 with key lifnr = wa_bsik-lifnr into wa_lfa1.
regards
Ajit
12-13-2011 5:53 AM
Hi Sulabh Agrawal,
You have used a selection criteria as a "with key lifnr = it_bsik-lifnr" where it selects only one row.
I would like to tell you one thing about this read table/select statement, it always takes a last row, becoz it was assumed that there will be a unique entry for a given KEY field.
IN your case LIFNR (Account Number of Vendor or Creditor) is the key of the table LFA1.
So, in order fetch all the rows into an internal table, you can use the function module "FI_WT_READ_LFA1" instead of a read table statement.
This might work..
Thanks,
Venky.
12-13-2011 5:54 AM
12-13-2011 5:57 AM
HI ,
check the syntax once , in read statement you are using internal table
read table it_lfa1 with key lifnr = *it_bsik-lifnr* into wa_lfa
1
I think you are using for all entries to fetch data from data base tables so you have 2 internal tables think
as Itab1 and Itab2 ,you need to populate all these in in single internal table for this create a new internal table name as it_final
types : begin of tyt_final ,
itab1 fields
itabl2 fields
end of ty_final.
data : it_final type table of ty_final.
data : wa_final type ty_final.
Select statments.
loop at itab1 into wa_itab1.
wa_final-field = wa_itab1-field.
wa_final-field = wa_itab1-field.
wa_final-field = wa_itab1-field.
read itab2 into wa_itab2 with key field = wa_itab1.
if sy-subrc = 0.
wa_final-field = wa_itab2-field.
wa_final-field = wa_itab2-field.
endif.
append wa_final to lt_final.
endloop.
then you will get accurate data in final internal table
Regards
SIva
12-13-2011 6:03 AM
change the code like this:
loop at it_bsik into wa_bsik.
read table it_lfa1 with key *lifnr = wa_bsik-lifnr* into wa_lfa1 .
*if sy-subrc = 0.*
wa_bsiK-LIFNR = wa_LFa1-LIFNR.
wa_bsiK-name1 = wa_LFa1-name1.
wa_bsiK-ort01 = wa_LFa1-ort01.
wa_bsiK-adrnr = wa_LFa1-adrnr.
wa_bsiK-pstlz = wa_LFa1-pstlz.
wa_bsiK-TELF1 = wa_LFa1-TELF1.
wa_bsiK-SMTP_ADDR = wa_LFa1-SMTP_ADDR.
modify it_bsiK from wa_bsik.
*endif*
CLEAR: wa_bsiK ,wa_LFa1.
ENDLOOP.
regards,
Priyanka
12-13-2011 6:49 AM
hi all,
my problem has solved.
in my code before read statement i use :
clear WA_LFA1.
and i get all the records right in IT_BSIK.
THANKS FOR REPLY.
SULABH
12-13-2011 6:52 AM
Hi
You can also try with the above changes given by me.
Regards
Ajit
12-13-2011 6:49 AM