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

Transfer data to final internal table from 2 internal tables

Hi guru, Please check the following code :

TYPES : BEGIN OF T_CUSTOMER,
            BUKRS TYPE BSAD-BUKRS,
            KUNNR TYPE BSAD-KUNNR,
            NAME1 TYPE KNA1-NAME1,
            HKONT TYPE BSAD-HKONT,
            BELNR TYPE BSAD-BELNR,
            BUDAT TYPE BSAD-BUDAT,
            DMBTR TYPE BSAD-DMBTR,
            WAERS TYPE BSAD-WAERS,
            blart TYPE bsad-blart,
        END OF T_CUSTOMER.

DATA : CUSTOMER TYPE STANDARD TABLE OF T_CUSTOMER INITIAL SIZE 0,
            WA_CUSTOMER TYPE T_CUSTOMER.

TYPES : BEGIN OF T_VENDOR,
            BUKRS TYPE BSAK-BUKRS,
            LIFNR TYPE BSAK-LIFNR,
            NAME1 TYPE LFA1-NAME1,
            HKONT TYPE BSAK-HKONT,
            BELNR TYPE BSAK-BELNR,
            BUDAT TYPE BSAK-BUDAT,
            DMBTR TYPE BSAK-DMBTR,
            WAERS TYPE BSAK-WAERS,
    END OF T_VENDOR.
  DATA  : VENDOR TYPE STANDARD TABLE OF T_VENDOR INITIAL SIZE 0,
          WA_VENDOR  TYPE T_VENDOR.
TYPES : BEGIN OF ITYPE,
            BUKRS TYPE BSAK-BUKRS,
            LIFNR TYPE BSAK-LIFNR,
            NAME1 TYPE LFA1-NAME1,
            HKONT TYPE BSAK-HKONT,
            BELNR TYPE BSAK-BELNR,
            BUDAT TYPE BSAK-BUDAT,
            DMBTR TYPE BSAK-DMBTR,
            WAERS TYPE BSAK-WAERS,
            BUKRS2 TYPE BSAD-BUKRS,
            KUNNR TYPE BSAD-KUNNR,
            NAME2 TYPE KNA1-NAME1,
            HKONT2 TYPE BSAD-HKONT,
            BELNR2 TYPE BSAD-BELNR,
            BUDAT2 TYPE BSAD-BUDAT,
            DMBTR2 TYPE BSAD-DMBTR,
            WAERS2 TYPE BSAD-WAERS,
            blart TYPE bsak-blart,
            UMSKZ TYPE BSAK-UMSKZ,
        END OF ITYPE.

  DATA : IT TYPE STANDARD TABLE OF ITYPE INITIAL SIZE 0,
                WA_IT TYPE ITYPE.

can anybody please tell me how can i take data from table VENDOR & CUSTOMER into IT. Only BUKRS is the matching condition.

LOOP AT VENDOR INTO WA_VENDOR.
                READ TABLE CUSTOMER INTO WA_CUSTOMER WITH  KEY BUKRS = WA_VENDOR-BUKRS.
                WA_IT-BUKRS = WA_VENDOR-BUKRS.
                WA_IT-LIFNR = WA_VENDOR-LIFNR.
             ......
               APPEND  WA_IT TO IT.
         ENDLOOP.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 18, 2010 at 08:15 AM

    Since there is no matching field, except BUKRS, it indicates that both vendor and customer documents are independent one.

    Now the population will depends on the business requirement.

    Consider few scenarios.

    1. There might be some condition for vendors againist customers, stating for this customers, I have recieved data from these vendors.

    2. Blindly displaying all the vendor and customer combination. X * Y records.

    Please check with the business for the actua functionality.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 19, 2010 at 06:44 AM

    Hi,

    A small addition to your code.

    Sort CUSTOMER by bukrs.
    LOOP AT VENDOR INTO WA_VENDOR.
                    READ TABLE CUSTOMER INTO WA_CUSTOMER binary search WITH  KEY BUKRS = WA_VENDOR-BUKRS .
                    " Use binary search when you are reading the record for better performance .             
                   if sy-subrc eq 0.  " Use this condition
                   WA_IT-BUKRS = WA_VENDOR-BUKRS.
                   WA_IT-LIFNR = WA_VENDOR-LIFNR.
                 ......
                  APPEND  WA_IT TO IT.
                  endif.
             ENDLOOP.
    

    Regards and Best wishes.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 23, 2011 at 10:38 AM

    hi sir,

    i have the scenerio i request to edit to WA_IT-BUKRS = WA_VENDOR-BUKRS or.

    WA_IT-LIFNR = WA_VENDOR-LIFNR.

    ..........................................................

    ..........................................................

    append .

    thanking you

    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.