Skip to Content
author's profile photo Former Member
Former Member

fetch data from internal table into another internal table

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 13, 2011 at 06: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 13, 2011 at 05: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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 13, 2011 at 05: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 13, 2011 at 05:54 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 13, 2011 at 05: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 13, 2011 at 06: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 13, 2011 at 06:49 AM

    SOLVED BY OWN

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.