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

For all entries usage

I have a small doubt on FOR ALL ENTRIES usage.. I awant to get kunnr,name1 from KNA1

and vbeln, netwr from VBAK. In this scenario How can I declare the INTERNAL tables and the SELECT STATEMENTS..

Regards,

bhargava

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2007 at 11:19 PM

    Hi,

    Check this example.

    TABLES: VBAK.

    SELECT-OPTIONS: SO_ERDAT FOR VBAK-ERDAT.

    DATA: BEGIN OF ITAB OCCURS 0,

    VBELN TYPE VBELN,

    NETWR TYPE VBAK-NETWR,

    KUNNR TYPE VBAK-KUNNR,

    NAME1 TYPE KNA1-NAME1,

    END OF ITAB.

    DATA: BEGIN OF ITAB_KUNNR OCCURS 0,

    KUNNR TYPE VBAK-KUNNR,

    NAME1 TYPE KNA1-NAME1,

    END OF ITAB_KUNNR.

    • GET THE SALES ORDERS..

    SELECT VBELN NETWR KUNNR

    FROM VBAK

    INTO TABLE ITAB

    WHERE ERDAT IN SO_ERDAT.

    • GET THE CUSTOMERS.

    IF NOT ITAB[] IS INITIAL.

    SELECT KUNNR NAME1

    INTO TABLE ITAB_KUNNR

    FROM KNA1

    FOR ALL ENTRIES IN ITAB

    WHERE KUNNR = ITAB-KUNNR.

    IF SY-SUBRC = 0.

    SORT ITAB_KUNNR BY KUNNR.

    ENDIF.

    ENDIF.

    • MODIFY THE INTERNAL TABLE.

    LOOP AT ITAB.

    READ TABLE ITAB_KUNNR

    WITH KEY KUNNR = ITAB-KUNNR

    BINARY SEARCH.

    IF SY-SUBRC = 0.

    ITAB-NAME1 = ITAB_KUNNR-NAME1.

    MODIFY ITAB.

    ENDIF.

    ENDLOOP.

    Hope this helps..

    Thanks,

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2007 at 01:58 PM

    hai

    u declare two internal tables one contain data of kna1 table and another one is

    abt vbak table.

    write select query as like this,

    select * from kna1

    into table it_kna1 where <cond>.

    select * from vbak

    into table it_vbak for all entries in table it_kna1

    where <cond> with relate to it_kna1 table key.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 28, 2007 at 02:16 PM

    k b ram,

    try selecting from both tables together using join:

    DATA:
      BEGIN OF gs_data,
      kunnr TYPE KNA1-kunnr,
      name1 TYPE KNA1-name1, 
      vbeln TYPE VBAK-vbeln,  
      netwr TYPE VBAK-netwr, 
      END OF gs_data,
      gt_itab LIKE TABLE OF gs_data.
    
    SELECT-OPTIONS:
      s_vbeln FOR gs_data-vbeln,
      s_kunnr FOR gs_data-kunnr.
    
    SELECT KNA1~kunnr KNA1~name1 VBAK~vbeln  VBAK~netwr 
      INTO CORRESPONDING FIELDS OF TABLE gt_itab
      FROM KNA1 
      JOIN VBAK
        ON KNA1~KUNNR = VBAK~KUNNR
      WHERE vbeln in s_vbeln
         AND kunnr in s_kunnr.
    

    Sorry, no FOR ALL ENTRIES this time. Modify/extend to your needs.

    Regards,

    Clemens

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2007 at 06:59 PM

    Hi Ram,

    The FOR ALL ENTRIES as follows :

    DATA : BEGIN OF I_KNA1 OCCURS 0,

    KUNNR LIKE KNA1-KUNNR,

    NAME1 LIKE KNA1-NAME1,

    END OF I_KNA1.

    DATA : BEGIN OF I_VBAK OCCURS 0,

    VBELN LIKE VBAK-VBELN,

    NETWR LIKE VBAK-NETWR,

    END OF I_KNA1.

    SELECT-OPTIONS : S_KUNNR FOR KAN1-KUNNR.

    SELECT KUNNR

    NAME1

    FROM KNA1 INTO TABLE I_KNA1

    WHERE KUNNR IN S_KUNNR.

    IF NOT I_KNA1[] IS INITIAL. --->>> This condition is mandatory

    SELECT VBELN

    NETWR

    FROM VBAK

    INTO TABLE I_VBAK

    FOR ALL ENTRIES IN I_KNA1

    WHERE KUNNR = I_KNA1-KUNNR.

    ENDIF.

    This is the way we need to write the code..

    Srini.

    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.