Skip to Content

How to get multiple entries from address table into file ?

Hi All,

Im not finding the way to get multiple entries from address tables (ADR2 , ADR3 and ADR6) .....


ADR6 table data is as below

ADDRNUMBER PERSNUMBER CONSNUMBER Email 0001069279 0001069278 002 1@sdn.com 0001069279 0001069278 003 2@sdn.com 0001069279 0001069278 004 3@sdn.com

ADR2 Table is given below

ADDRNUMBER PERSNUMBER CONSNUMBER Tel_Number 0001069279 0001069278 001 12 0001069279 0001069278 002 123

ADR3 Table is given below

ADDRNUMBER PERSNUMBER CONSNUMBER FAX_NUMBER 0001069279 0001069278 001 1111111 0001069279 0001069278 002 22


Now my requirement is as shown below ...... (For respective Partner and address number i need all the data from above tables)

PARTNER TEL_NUMBER FAX_NUMBER SMTP_ADDR ADDRNUMBER PARTNER1 CONSNUMBER 1 12 1111111 1069279 0011830185 001 1 123 22 1@sdn.com 1069279 0011830185 002 1 2@sdn.com 1069279 0011830185 003 1 3@sdn.com 1069279 0011830185 004



Can anybody help on this issue ? im not getting the logic to do this .

Code is given below

loop at it_final1.

it_final-partner1 = it_final1-partner1.

clear : it_but000.

read table it_but000 with key partner = it_final1-partner2.

if sy-subrc eq 0.

it_final-partner = it_but000-partner.

loop at t_but020.

if sy-subrc eq 0.

it_final-ADDRNUMBER = t_but020-ADDRNUMBER.

endif.

clear : t_adr2, t_adr2-TEL_NUMBER.

**************Issue im facing here - reading only one record***************

read table T_ADR2 with key ADDRNUMBER = t_but020-addrnumber.

if sy-subrc eq 0.

it_final-TEL_NUMBER = t_adr2-TEL_NUMBER .

endif.

clear: t_adr3.

read table T_ADR3 with key ADDRNUMBER = t_but020-addrnumber.

if sy-subrc eq 0.

it_final-FAX_NUMBER = t_adr3-FAX_NUMBER.

endif.

read table T_ADR6 with key ADDRNUMBER = t_but020-addrnumber.

if sy-subrc eq 0.

it_final-SMTP_ADDR = t_adr6-SMTP_ADDR.

************************End of issue ***********************

read table IT_BUT100 with key partner = t_but020-partner.

if sy-subrc eq 0.

it_final-RLTYP = it_but100-RLTYP.

read table t_TB003T with key ROLE = it_but100-rltyp.

* and SPRAS = 'EN'.

if sy-subrc eq 0.

it_final-RELTYP = t_TB003T-RLTXT.

endif.

endif.

append it_final.

endloop.

endif.


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Jan 02, 2014 at 04:34 AM

    Hi Smitha,


    If you want to display more than one row in internal table please use loop at statement, instead of read table.

    Arivazhagan S

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 02, 2014 at 04:46 AM

    Hi,

    Use the function module to get the partner address: BAPI_BUPA_ADDRESSES_GET

    By the way its very simple!

    LOOP AT adr6.

    read table ADR2 with key adrnr = adr6-adrnr

    persunumber = adr6-adrnr

    if sy-subrc = 0.

    move fields to final internal table

    endif.

    read table ADR3 with key adrnr = adr6-adrnr

    persunumber = adr6-adrnr

    if sy-subrc = 0.

    move fields to final internal table

    endif.

    finally adr6 fields to final internal table.

    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 02, 2014 at 06:09 AM

    Hi @Smitha KB

    Can you check with below sample code .

    TABLES : ADR2 , ADR3 , ADR6.

    TYPES: BEGIN OF TY_ITAB,

    ADDRNUMBER TYPE AD_ADDRNUM,

    PERSNUMBER TYPE AD_PERSNUM,

    CONSNUMBER TYPE AD_CONSNUM,

    TEL_NUMBER TYPE AD_TLNMBR,

    FAX_NUMBER TYPE AD_FXNMBR,

    SMTP_ADDR TYPE AD_SMTPADR,

    END OF TY_ITAB.

    TYPES : BEGIN OF TY_FINAL,

    PARTNER TYPE SY-TABIX,

    ADDRNUMBER TYPE AD_ADDRNUM,

    PERSNUMBER TYPE AD_PERSNUM,

    CONSNUMBER TYPE AD_CONSNUM,

    TEL_NUMBER TYPE AD_TLNMBR,

    FAX_NUMBER TYPE AD_FXNMBR,

    SMTP_ADDR TYPE AD_SMTPADR,

    END OF TY_FINAL.

    DATA : ITAB TYPE STANDARD TABLE OF TY_ITAB ,

    WA TYPE TY_ITAB,

    IFINAL TYPE STANDARD TABLE OF TY_FINAL ,

    WA_FINAL TYPE TY_FINAL.

    DATA : INC TYPE SY-TABIX,

    FLAG TYPE C.

    SELECT-OPTIONS : S_ADDNUM FOR ADR3-ADDRNUMBER .

    SELECT ADR2~ADDRNUMBER

    ADR2~PERSNUMBER

    ADR2~CONSNUMBER

    ADR2~TEL_NUMBER

    ADR3~FAX_NUMBER

    ADR6~SMTP_ADDR

    INTO CORRESPONDING FIELDS OF TABLE ITAB

    FROM ( ADR2

    INNER JOIN ADR3

    ON ADR3~ADDRNUMBER = ADR2~ADDRNUMBER

    AND ADR3~CONSNUMBER = ADR2~CONSNUMBER

    AND ADR3~DATE_FROM = ADR2~DATE_FROM

    AND ADR3~PERSNUMBER = ADR2~PERSNUMBER

    INNER JOIN ADR6

    ON ADR6~ADDRNUMBER = ADR3~ADDRNUMBER

    AND ADR6~CONSNUMBER = ADR3~CONSNUMBER

    AND ADR6~DATE_FROM = ADR3~DATE_FROM

    AND ADR6~PERSNUMBER = ADR3~PERSNUMBER )

    WHERE ADR2~ADDRNUMBER IN S_ADDNUM " Change as per your requirement

    ORDER BY ADR2~ADDRNUMBER .

    LOOP AT ITAB INTO WA .

    ON CHANGE OF WA-ADDRNUMBER.

    INC = INC + 1.

    WA_FINAL-ADDRNUMBER = WA-ADDRNUMBER .

    WA_FINAL-PERSNUMBER = WA-PERSNUMBER .

    WA_FINAL-CONSNUMBER = WA-CONSNUMBER .

    WA_FINAL-TEL_NUMBER = WA-TEL_NUMBER .

    WA_FINAL-FAX_NUMBER = WA-FAX_NUMBER .

    WA_FINAL-SMTP_ADDR = WA-SMTP_ADDR .

    WA_FINAL-PARTNER = INC .

    APPEND WA_FINAL TO IFINAL .

    CLEAR : WA , WA_FINAL .

    FLAG = 'X'.

    ENDON.

    IF FLAG <> 'X'.

    MOVE-CORRESPONDING WA TO WA_FINAL .

    WA_FINAL-PARTNER = INC .

    APPEND WA_FINAL TO IFINAL .

    CLEAR : WA_FINAL , WA.

    ENDIF.

    CLEAR : FLAG.

    ENDLOOP.

    LOOP AT IFINAL INTO WA_FINAL.

    WRITE : / WA_FINAL-PARTNER ,'|', WA_FINAL-ADDRNUMBER , '|' , WA_FINAL-PERSNUMBER ,'|', WA_FINAL-CONSNUMBER ,'|',WA_FINAL-TEL_NUMBER ,'|',WA_FINAL-FAX_NUMBER,'|', WA_FINAL-SMTP_ADDR .

    CLEAR : WA_FINAL.

    ENDLOOP.

    Regard's

    Smruti


    s1.png (17.5 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 03, 2014 at 09:57 AM

    Thank u all for the replies ....

    I have used Do and End Do .. which resolved my problem .. Inner join will not help on this ......

    Regards

    smitha

    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.