Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

For All Entries Problem

former_member213491
Participant
0 Kudos

Hello Experts,

I am using For All entries with 4 tables as below my code attach , can i another way this code use.

please help me.

16 REPLIES 16

ravi_golla3
Explorer
0 Kudos

That looks good. you didn't use key fields for MSEG table. that might be effect in performance.

0 Kudos

I have only relation make

EKPO-EBELN = MSEG-EBELN

EKPO-EBELP  = MSEG-EBELP.

My Question is can we use FOLL ENTRIES with 4 table .

0 Kudos

You can use FOR ALL ENTRIES with many tables.

But I'm not sure that really answers your question.

Rob

0 Kudos

No. You cane use for all entries for only two tables. That too one data base table and one internal table.

Your code in attachments looks good. Make sy-sunrc statements in between select statements.

You can use inner join to combine multiple tables.but this is not suggestable.

0 Kudos

what i  have requirement ,

I have create a structure in that structure  4 different table field EKPO , RSEG , MSEG other Z _ table .

i want to with  RBKP-BELNR , RBPK-GJHAR  read  REFRENCE Nummer from Z-table  also use

FOR ALL Entries with internal table of RBKP.

Second i want  this field ( MATNR , WRBTR ) from RSEG Table here also use FOR ALL Entries

with RBKP-BELNR and RBKP-GJHAR,

third i want this field TAXZ01 ,NETPR , from EKPO table also use FOR ALL Entries  with RSEG-EBELN and RBKP-EBELP,

fourth i want this field MENGE and MEINS from MSEG table lso use FOR ALL Entries  with EKPO-EBELN and EKPO-EBELP,

after i create loop with EKPO internal to workarea. then I use three READ statement use 1.

for RSEG with   ekpo-ebeln and ekpo-ebeln, second MSEG with ekpo-ebeln and ekpo-ebeln and

third

1. READ TABLE lt_rseg INTO w_rseg WITH w_ekpo ................................

2  ............................................................

3 READ TABLE ztable with key belnr = w_rseg-belnr  gjhar = w_rseg-gjhar ? this statment hier correct.

then after i have use append statement.

0 Kudos

How can use key field  With RSEG and EKPO  and MSEG.

Means that way i use for all entries.


TYPES : BEGIN OF TY_FINAL,

           EBELN TYPE EKPO-EBELN,

           ebelp TYPE EKPO-ebelp,

           TXZ01 TYPE EKPO-TXZ01,

           NETPR TYPE EKPO-NETPR,

           MATNR TYPE RSEG-MATNR,

           WRBTR TYPE RSEG-WRBTR,

           MENGE TYPE MSEG-MENGE,

END OF TY_FINAL.

  DATA: IT_RSEG TYPE TABLE OF RSEG,

        WA_RSEG  LIKE LINE OF IT_RSEG,

        IT_EKPO TYPE TABLE OF EKPO,

        WA_EKPO LIKE LINE OF  IT_EKPO,

        IT_MSEG TYPE TABLE OF MSEG,

        WA_MSEG  LIKE LINE OF IT_MSEG,

        LT_RBKP TYPE TABLE OF rbkp,

        IT_EKKO TYPE TABLE OF EKKO,

        WA_EKKO TYPE EKKO.

CLEAR : WA_RSEG,

         WA_EKPO,

         WA_MSEG.

REFRESH : IT_RSEG,

           IT_EKPO,

           IT_MSEG.

DATA IT_final TYPE TABLE OF TY_final .

DATA WA_final TYPE          TY_final.

SELECT  * FROM RBKP INTO TABLE LT_RBKP.

   IF LT_RBKP IS NOT INITIAL.

   SELECT * FROM RSEG INTO TABLE IT_RSEG

     FOR ALL ENTRIES IN LT_RBKP

     WHERE BELNR EQ LT_RBKP-BELNR

     AND   GJAHR EQ LT_RBKP-GJAHR.

   ENDIF.

  

   IF IT_RSEG IS NOT INITIAL.

    

   SELECT * FROM EKPO INTO TABLE IT_EKPO

     FOR ALL ENTRIES IN IT_RSEG

     WHERE EBELN EQ IT_RSEG-EBELN

     AND   EBELP EQ IT_RSEG-EBELP.

    

SORT IT_EKPO BY EBELN.

     SELECT * FROM mseg INTO TABLE IT_MSEG

     FOR ALL ENTRIES IN IT_RSEG

    WHERE  EBELN EQ IT_RSEG-EBELN

     AND   EBELP EQ IT_RSEG-EBELP.

  SORT IT_MSEG BY MBLNR.

   ENDIF.

LOOP AT IT_RSEG INTO WA_RSEG .

    wa_final-matnr = wa_rseg-matnr.

    WA_FINAL-WRBTR = WA_rseg-WRBTR.

    READ TABLE IT_EKPO INTO WA_EKPO WITH KEY EBELN = WA_RSEG-EBELN EBELP = WA_RSEG-EBELP BINARY SEARCH.

    IF SY-SUBRC = 0.

     wa_final-ebeln = wa_ekpo-ebeln.

    wa_final-ebelp = wa_ekpo-ebelp.

    WA_FINAL-TXZ01 = WA_EKPO-TXZ01.

    wa_final-NETPR = wa_ekpo-NETPR.

    ENDIF.

    READ TABLE IT_MSEG INTO WA_MSEG WITH KEY EBELN = WA_RSEG-EBELN EBELP = WA_RSEG-EBELP BINARY SEARCH .

IF SY-SUBRC = 0.

    WA_FINAL-MENGE = WA_MSEG-MENGE.

APPEND WA_FINAL  TO IT_FINAL.

ENDIF.

ENDLOOP.

thiago_stefanini
Explorer
0 Kudos

Hello.

You need check if the table that you will use in the FOR ALL ENTRIES is initial, that will eliminate  some problems.

Hope that help too.

Former Member
0 Kudos

What exactly is the problem?

Rob

Former Member
0 Kudos

Hi Muhammad,

Can you ellobrate the issue that you are facing.

Problems that I see/understand in the screen shots that you have provided

1) Using for all entries you can have data of multiple transperant tables into one single internal table.

2) Before using For all entries sort the internal table and delete duplicate entries

3) Whenver you are going to use For all entries you have to check the internal table contains any records. If the table is blank and you write a select query then the system is going to pull out for all entries and take longer processing time.

eg. if LT_RBKP[] is not initial.

     Select query based on for all entries in table LT_RBKP.

endif.

Hope this helps.

Thanks,

Tooshar Bendale

0 Kudos

I have create a structure in that structure  4 different table field EKPO , RSEG , MSEG other Z _ table .

i want to with  RBKP-BELNR , RBPK-GJHAR  read  REFRENCE Nummer from Z-table  also use

FOR ALL Entries with internal table of RBKP.

Second i want  this field ( MATNR , WRBTR ) from RSEG Table here also use FOR ALL Entries

with RBKP-BELNR and RBKP-GJHAR,

third i want this field TAXZ01 ,NETPR , from EKPO table also use FOR ALL Entries with RSEG-EBELN and RBKP-EBELP,

fourth i want this field MENGE and MEINS from MSEG table lso use FOR ALL Entries  with EKPO-EBELN and EKPO-EBELP,

after i create loop with EKPO internal to workarea. then I use three READ statement use 1.

for RSEG with   ekpo-ebeln and ekpo-ebeln, second MSEG with ekpo-ebeln and ekpo-ebeln and

third

LOOP AT IT_EKPO INTO W_EKPO.

1. READ TABLE lt_rseg INTO w_rseg WITH w_ekpo ................................

2  ............................................................

3 READ TABLE ztable with key belnr = w_rseg-belnr  gjhar = w_rseg-gjhar ? this statment here correct.


ENDLOOP.

then after i have use append statement.

0 Kudos

What is the error message?

0 Kudos

Hi Muhammad,

If you are using For ALL enteries Key word,

1. You have to sort the data based on conditon you want

2. Delete Adjacent duplicates

before using for all enteries.

One more thing is that you have to specify all key fields, otherwise data will be wrong.

With Regards

Arun VS

Former Member
0 Kudos

HI

In screen shot problem2 is final internal table population in that you have written if <cond>  condition but there is no endif.

and one more thing you need to check sy-subrc for every read statement and you need to fill final internal table in that if- endif.

like below

LOOP AT IT_EKPO INTO W_EKPO.

1. READ TABLE lt_rseg INTO w_rseg WITH w_ekpo ................................

     if sy-subrc = 0

          fill the entries from w_resg to final internal table

          READ TABLE ztable with key belnr = w_rseg-belnr  gjhar = w_rseg-gjhar

               if sy-subrc = 0

                         fill the entries

                endif.

     endif.

    

append statement.

ENDLOOP.

regards

laxman

vamsilakshman_pendurti
Active Participant
0 Kudos

Hi

Before Read statement you should Clear the work area which you want to used in Read statement

after the Read Statement you should Check SY_SUBRC value and then assign your required value into final work area if that SUBRC value is 0..

This is the rule you should follow for the READ statement..

Clear : lrs_rseg,

            lms_mseg,

           lv_xblnr.

and one more thing you can place binary search also in Read statement then it will give much performance to retrieve the data...

Thanks ,

vamsi.

Former Member
0 Kudos

Hi,

if you find this coding is time consuming and confusing for you. then go with Join concepts. You can use inner join instead of For all entries. But the performance will be low.

if you want to use For all entries in sense, then go for professional coding standards,

1. Refresh the internal table.

2. Check whether the table used for (for all entries) is initial or not.

3. Check Sy-subrc value and sort the records.

4. Use Delete adjacent duplicates.

5. Use Binary Search in read

6. For final Table use the looping statement like this.

loop at it_mara1 into wa_mara1.

     wa_final-matnr = wa_mara1-matnr.

     wa_final-ernam = wa_mara1-ernam.

     wa_final-mtart = wa_mara1-mtart.

     wa_final-meins = wa_mara1-meins.

     wa_final-bstme = wa_mara1-bstme.

     read table it_makt into wa_makt with key matnr = wa_mara1-matnr binary search.

     wa_final-maktx = wa_makt-maktx.

     read table it_mbew into wa_mbew with key matnr = wa_mara1-matnr binary search.

     wa_final-bwkey = wa_mbew-bwkey.

     wa_final-lbkum = wa_mbew-lbkum.

     wa_final-salk3 = wa_mbew-salk3.

     wa_final-stprs = wa_mbew-stprs.

     wa_final-peinh = wa_mbew-peinh.

     wa_final-bklas = wa_mbew-bklas.

     append wa_final to it_final.

endloop.

0 Kudos

Means that way i use for all entries.


TYPES : BEGIN OF TY_FINAL,

           EBELN TYPE EKPO-EBELN,

           ebelp TYPE EKPO-ebelp,

           TXZ01 TYPE EKPO-TXZ01,

           NETPR TYPE EKPO-NETPR,

           MATNR TYPE RSEG-MATNR,

           WRBTR TYPE RSEG-WRBTR,

           MENGE TYPE MSEG-MENGE,

END OF TY_FINAL.

  DATA: IT_RSEG TYPE TABLE OF RSEG,

        WA_RSEG  LIKE LINE OF IT_RSEG,

        IT_EKPO TYPE TABLE OF EKPO,

        WA_EKPO LIKE LINE OF  IT_EKPO,

        IT_MSEG TYPE TABLE OF MSEG,

        WA_MSEG  LIKE LINE OF IT_MSEG,

        LT_RBKP TYPE TABLE OF rbkp,

        IT_EKKO TYPE TABLE OF EKKO,

        WA_EKKO TYPE EKKO.

CLEAR : WA_RSEG,

         WA_EKPO,

         WA_MSEG.

REFRESH : IT_RSEG,

           IT_EKPO,

           IT_MSEG.

DATA IT_final TYPE TABLE OF TY_final .

DATA WA_final TYPE          TY_final.

SELECT  * FROM RBKP INTO TABLE LT_RBKP.

   IF LT_RBKP IS NOT INITIAL.

   SELECT * FROM RSEG INTO TABLE IT_RSEG

     FOR ALL ENTRIES IN LT_RBKP

     WHERE BELNR EQ LT_RBKP-BELNR

     AND   GJAHR EQ LT_RBKP-GJAHR.

   ENDIF.

  

   IF IT_RSEG IS NOT INITIAL.

    

   SELECT * FROM EKPO INTO TABLE IT_EKPO

     FOR ALL ENTRIES IN IT_RSEG

     WHERE EBELN EQ IT_RSEG-EBELN

     AND   EBELP EQ IT_RSEG-EBELP.

    

SORT IT_EKPO BY EBELN.

     SELECT * FROM mseg INTO TABLE IT_MSEG

     FOR ALL ENTRIES IN IT_RSEG

    WHERE  EBELN EQ IT_RSEG-EBELN

     AND   EBELP EQ IT_RSEG-EBELP.

  SORT IT_MSEG BY MBLNR.

   ENDIF.

LOOP AT IT_RSEG INTO WA_RSEG .

    wa_final-matnr = wa_rseg-matnr.

    WA_FINAL-WRBTR = WA_rseg-WRBTR.

    READ TABLE IT_EKPO INTO WA_EKPO WITH KEY EBELN = WA_RSEG-EBELN EBELP = WA_RSEG-EBELP BINARY SEARCH.

    IF SY-SUBRC = 0.

     wa_final-ebeln = wa_ekpo-ebeln.

    wa_final-ebelp = wa_ekpo-ebelp.

    WA_FINAL-TXZ01 = WA_EKPO-TXZ01.

    wa_final-NETPR = wa_ekpo-NETPR.

    ENDIF.

    READ TABLE IT_MSEG INTO WA_MSEG WITH KEY EBELN = WA_RSEG-EBELN EBELP = WA_RSEG-EBELP BINARY SEARCH .

IF SY-SUBRC = 0.

    WA_FINAL-MENGE = WA_MSEG-MENGE.

APPEND WA_FINAL  TO IT_FINAL.

ENDIF.

ENDLOOP.