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

regarding for all entries

can i use more than one FOR ALL ENTRIES in single select statament

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 09:29 AM

    NO

    see example below

    *Internal table for mara

    DATA : BEGIN OF itab_mara OCCURS 0,

    matnr LIKE mara-matnr,

    mtart LIKE mara-mtart,

    meins LIKE mara-meins,

    matkl LIKE mara-matkl,

    ernam LIKE mara-ernam,

    END OF itab_mara.

    *Internal table for makt

    DATA : BEGIN OF itab_makt OCCURS 0,

    matnr LIKE makt-maktx,

    maktx LIKE makt-maktx,

    END OF itab_makt.

    *Internal table for t023t

    DATA : BEGIN OF itab_t023t OCCURS 0,

    matkl LIKE t023t-matkl,

    wgbez LIKE t023t-wgbez,

    END OF itab_t023t.

    *Internal table for marc

    DATA : BEGIN OF itab_marc OCCURS 0,

    matnr LIKE marc-matnr,

    werks LIKE marc-werks,

    END OF itab_marc.

    &----


    *& Form GET_DATA

    &----


    FORM get_data.

    SELECT matnr

    werks

    FROM marc INTO TABLE itab_marc WHERE werks IN s_werks AND

    matnr IN s_matnr.

    IF NOT itab_marc[] IS INITIAL.

    SELECT matnr

    mtart

    meins

    matkl

    ernam

    FROM mara INTO TABLE itab_mara

    FOR ALL ENTRIES IN itab_marc

    WHERE matnr = itab_marc-matnr

    AND mtart IN s_mtart

    AND meins IN s_meins.

    ENDIF.

    IF NOT itab_mara[] IS INITIAL.

    SELECT matnr

    maktx

    FROM makt INTO TABLE itab_makt

    FOR ALL ENTRIES IN itab_mara

    WHERE matnr = itab_mara-matnr AND

    spras = sy-langu.

    ENDIF.

    IF NOT itab_mara[] IS INITIAL.

    SELECT matkl wgbez

    FROM t023t

    INTO TABLE itab_t023t

    FOR ALL ENTRIES IN itab_mara

    WHERE matkl = itab_mara-matkl AND

    spras = sy-langu.

    ENDIF.

    ENDFORM. " GET_DATA

    &----


    *& Form fill_data

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM fill_data.

    SORT : itab_mara BY matnr,

    itab_marc BY matnr,

    itab_makt BY matnr,

    itab_t023t BY matkl.

    • loop at itab_mara.

    LOOP AT itab_t023t.

    CLEAR : f_itab.

    READ TABLE itab_mara WITH KEY matkl = itab_t023t-matkl BINARY SEARCH.

    IF sy-subrc = 0.

    f_itab-wgbez = itab_t023t-wgbez.

    f_itab-mtart = itab_mara-mtart.

    f_itab-matnr = itab_mara-matnr .

    f_itab-ernam = itab_mara-ernam.

    f_itab-matkl = itab_mara-matkl.

    ENDIF.

    READ TABLE itab_makt WITH KEY matnr = itab_mara-matnr BINARY SEARCH.

    IF sy-subrc = 0.

    f_itab-maktx = itab_makt-maktx.

    ENDIF.

    READ TABLE itab_marc WITH KEY matnr = itab_makt-matnr BINARY SEARCH.

    IF sy-subrc = 0.

    f_itab-werks = itab_marc-werks.

    ENDIF.

    • Read table itab_t023t with key matkl = itab_mara-matkl binary search

    *.

    • if sy-subrc = 0.

    *

    • f_itab-wgbez = itab_t023t-wgbez.

    *

    • endif.

    APPEND f_itab.

    ENDLOOP.

    SORT f_itab BY mtart matnr ernam.

    ENDFORM. " fill_data

    &----


    *& Form WRITE_REPORT

    &----


    FORM write_report.

    LOOP AT f_itab.

    WRITE : / sy-vline, f_itab-mtart, 17 sy-vline,

    f_itab-matnr, 35 sy-vline,

    f_itab-maktx, 78 sy-vline,

    f_itab-ernam, 93 sy-vline,

    f_itab-matkl, 111 sy-vline,

    f_itab-wgbez, 134 sy-vline.

    ULINE AT /(134).

    ENDLOOP.

    ENDFORM. " WRITE_REPORT

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 09:31 AM

    Hi janakiram,

    It is not possible to use multiple "For All entries in itab" in a Single select statement.

    And you should not need to have this in your requirement because you can fetch the data from only one single statement using "For All entries in itab".If you want to fetch the data from multiple tables then use Inner Join with select statement and that should serve your purpose.

    In case you have any further clarifications,do let me know.

    Regards,

    Puneet Jhari.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 09:31 AM

    Its not possible

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 19, 2007 at 09:32 AM

    I DONT THINK U CAN USE MORE THAN ONE FOR ALL ENTRIES IN SINGLE SELECT STATEMENT.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 09:37 AM

    Hi,

    This is not possible. why you want this?

    you can do one thing.

    Accumulate all the fields of multiple itabs into a single itab.

    then use the new itab in your select query.

    <i><b>Regards

    Debjani

    Do reward point for helpful answers</b></i>

    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.