I NEED select ..... for all entries for this logic

From table RBDRSEG, we need to pick up the field RBDRSEG-MATNR where RBDRSEG- RBLNR= RBKP-BELNR. If the program does not find any data then it can pick up the material id field from EKPO-MATNR for all the invoices picked up during the processing.

Hi,
Lets say that Invoices are in Int table ITAB.
IF NOT ITAB[] IS INITIAL.
SELECT MATNR FROM RBDRSEG INTO V_MATNR
for all entries in itab
where RBLNR= ITAB-BELNR.
IF SY-SUBRC <> 0.
SELECT MATNR FROM RSEG INTO V_MATNR
for all entries in ITAB
where BELNR= ITAB-BELNR.
ENDIF.
ENDIF.
Use RSEG instead of EKPO because EKPO don't have BELNR(Invoice) field.
Regards,
Anji
Message was edited by:
        Anji Reddy Vangala
Message was edited by:
        Anji Reddy Vangala

Similar Messages

  • Usage of 'Select for all entries' for dynamic internal tables..

    Hi all,
    I have a situation where I need to use select for all entries for a dynamic internal table.
    select * from /BIC/AZHSD_O1500 into i_table for all entries in <b>Dynamic_table</b> where doc_number = <dynamic_table????????>
    here iam not knowing how to match the <dynamic_table????????> doc_number ?
    the dynamic_table contains the doc_number as one field.
    here dynaimc_table is the internal table which is dynamic.
    I have tried various options but couldnot find the solution.
    Please resolve.
    Sidhartha.

    data : i_dyn_where type char72 occurs 0.
    field-symbols : <fs> type table.
    assign itab[] to <fs>.
    i_dyn_where = 'docno = <fs>-docno'.
    append i_dyn_where.
    select *
    from   vbak
    into   table t_vbak
    for    all entries in <fs>
    where  (I_dyn_where).   "Populate this where condition dynamically too
    Hope this will solve ur prob.

  • Need to read all entris  for field prtxt from table /sapsll/prt

    hi
    i need to read all entries from table /sapsll/prt field prtxt but only one is coming
    pls see below seelct statement
    if not gt_sagmeld[] is initial.
                SELECT /sapsll/cuit~guid_cuit         " PK
                       /sapsll/cuit~QUANT_FLT         " to be displayed
                       /sapsll/cuit~QUAUM             " to be displayed
                       /sapsll/cuit~RPTDT             " to be displayed
                       /sapsll/cuit~guid_cuhd
                       /sapsll/cuit~guid_pr           " needed for gt_prt inttab
                      /sapsll/corref~refno
                       /sapsll/corref~guid_pobj
                INTO corresponding fields of table gt_sapsllcuit
                FROM ( ( /sapsll/cuit
                inner join /sapsll/cuhd on /sapsll/cuit~guid_cuhd = /sapsll/cuhd~guid_cuhd )
                inner join /sapsll/corref on /sapsll/corref~guid_pobj = /sapsll/cuhd~guid_cuhd )
                FOR all entries in gt_sagmeld
                WHERE /sapsll/cuit~guid_cuit = gt_sagmeld-guid_pobj.
             endif.
            if not gt_sapsllcuit[] is initial.
             select /sapsll/prt~prtxt
                    /sapsll/prt~guid_pr       
             into corresponding fields of table gt_prt
             from /sapsll/prt
             for all entries in gt_sapsllcuit
             where /sapsll/prt~guid_pr = gt_sapsllcuit-guid_pr.
    loop at gt_sagmeld into wa_sagmeld.
    read table gt_sapsllcuit into wa_sapsllcuit
    with key guid_cuit = wa_sagmeld-guid_pobj
    binary search.
    Read table gt_prcon into wa_prcon with key
    guid_pr = wa_sapsllcuit-guid_pr.
    if sy-subrc = 0.
    *wa_sagmeld_outtab-guid_pr  = wa_prt-guid_pr. 
    here i am facing problem as multiple entries from table  /sapsll/prt is not being displayed only one.....but i have checked in table it is having two enteries
    pls suggest
    reagards
    Nishant

    Hi Nishant!
    When you use 'for all entries' SAP (or database?) does a 'delete adjacent duplicates' on the result. This is necessary because of the special selection technique in this case.
    You need to select enough columns from /sapsll/prt, so that your two entries will differ in the result.
    Regards,
    Christian

  • Inner join Vs for all entries for performance

    hi,
        i need to fetch data from 5 tables where i have common key vbeln, is this suggestable to write a select query with inner join or write an inner join for 2 tables with more fileds and for remaining using for all entries.... please suggest how can i increase the performance...all points are rewarded....
    thnaks alot.

    Is this a dialog program or a data extract? Rob is right in that the difference is negligible IF the number of records involved are only a few.
    On the other hand, if you are extracting a large number of records, then the performance depends on a number of things and is generally unpredictable.
    The way I approach it is by first developing the extract program with a join because it is easier to code. If the program run time is within the acceptable range, I would let it be and migrate to production. If the performance is of high priority and if the join appears to take long time, then I will comment out the code and try the FAE approach. If the run time with FAE is not markedly better, then I would go back to join.

  • Performance issue with select query and for all entries.

    hi,
    i have a report to be performance tuned.
    the database table has around 20 million entries and 25 fields.
    so, the report fetches the distinct values of two fields using one select query.
    so, the first select query fetches around 150 entries from the table for 2 fields.
    then it applies some logic and eliminates some entries and makes entries around 80-90...
    and then it again applies the select query on the same table using for all entries applied on the internal table with 80-90 entries...
    in short,
    it accesses the same database table twice.
    so, i tried to get the database table in internal table and apply the logic on internal table and delete the unwanted entries.. but it gave me memory dump, and it wont take that huge amount of data into abap memory...
    is around 80-90 entries too much for using "for all entries"?
    the logic that is applied to eliminate the entries from internal table is too long, and hence cannot be converted into where clause to convert it into single select..
    i really cant find the way out...
    please help.

    chinmay kulkarni wrote:Chinmay,
    Even though you tried to ask the question with detailed explanation, unfortunately it is still not clear.
    It is perfectly fine to access the same database twice. If that is working for you, I don't think there is any need to change the logic. As Rob mentioned, 80 or 8000 records is not a problem in "for all entries" clause.
    >
    > so, i tried to get the database table in internal table and apply the logic on internal table and delete the unwanted entries.. but it gave me memory dump, and it wont take that huge amount of data into abap memory...
    >
    It is not clear what you tried to do here. Did you try to bring all 20 million records into an internal table? That will certainly cause the program to short dump with memory shortage.
    > the logic that is applied to eliminate the entries from internal table is too long, and hence cannot be converted into where clause to convert it into single select..
    >
    That is fine. Actually, it is better (performance wise) to do much of the work in ABAP than writing a complex WHERE clause that might bog down the database.

  • Select query 'for all entries'

    Hello Friends,
           SELECT emp_id emp_name
           INTO corresponding fields of table itab_emp
           FROM employee
           for all entries in itab_dept
           WHERE emp_id = itab_dept_emp_id.
    In the above select query we are using 'for all entries' for the internal table itab_dept.What will happen if the join fails?Will we get any data in the output table?
    What is the prerequisites for using 'for all entries'.
    Please advice me on this.
    Regards
    Ashish.

    Hi
    In this case all the records available in employee table are extracted into internal table itab_emp.
    It is safe to check whether itab_dept is initial or not.
    If it is initial then stop the select query.
    Check the following program u will get an idea.
    Also try this program by removing comment to 'REFRESH IT_LFA1'.
    REPORT  ZBM_PG                                  .
    TABLES: LFA1, EKKO.
    DATA:
         IT_LFA1 TYPE TABLE OF LFA1 WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 10,
          IT_LFA1 TYPE TABLE OF LFA1 WITH HEADER LINE,
          IT_EKKO TYPE TABLE OF EKKO WITH HEADER LINE.
    SELECT * FROM LFA1 INTO TABLE IT_LFA1 WHERE LIFNR EQ '0000001000' OR LIFNR EQ '0000001500'.
    SELECT * FROM LFA1 INTO TABLE IT_LFA1 UP TO 1 ROWS.
    refresh it_lfa1.
    SELECT * FROM EKKO INTO TABLE IT_EKKO FOR ALL ENTRIES IN IT_LFA1 WHERE LIFNR = IT_LFA1-LIFNR.
    LOOP AT IT_EKKO.
      WRITE: / IT_EKKO-LIFNR, IT_EKKO-EBELN.
    ENDLOOP.
    Reward me if it is useful

  • Select for all entries+offset

    Folks,
    please find my code below:
    SELECT partner bpkind FROM but000 INTO TABLE i_but000
        FOR ALL ENTRIES IN lt_cmst_rtcm_bw
        WHERE partner = lt_cmst_rtcm_bw-tk_partner_i+0(10).
        SORT i_but000 BY partner.
    partner is of length 10, tk_partner_i is of length 32.
    when i use this offset value for comparison, its giving me the correct output. no errors.
    but am getting this warning:
    Bei der Verwendung von FOR ALL ENTRIES wird die Längenangabe für "TK_PARTNER_I" in dieser Bedingung ignoriert.          
    Do i have to mind this warning??..
    if this is to be considered, please suggest me an alternate solution to use "For all entries" in this case.
    Thanks in advance..
    Yog

    >
    yogaprakash srirangan wrote:
    > Hi,
    >
    > Actually i am writing this code in CRM system's CMOD-User exit program.
    >
    > when i remove the offset i am getting this error:
    >
    > When using the addition "FOR ALL ENTRIES IN itab", the fields "PARTNER"     and "LT_CMST_RTCM_BW-TK_PARTNER_I" must have the same type and length.and length.     
    >
    > but with offset its generating warning and internal table is getting filled..
    >
    > so can you please explain me on this?..
    >
    > Thanks,
    > Yog
    Wow!  It seems you have indeed found a bug!  With the length specification you get a warning, without you get an error!
    I've also written a little test program
    TYPES: BEGIN OF mandt_ty,
             mandt TYPE char6,
           END OF mandt_ty.
    DATA: t_mandt TYPE STANDARD TABLE OF mandt_ty WITH NON-UNIQUE KEY mandt,
          l_mandt TYPE mandt_ty.
    DATA: lt_t000 TYPE STANDARD TABLE OF t000 WITH NON-UNIQUE KEY mandt,
          ls_t000 TYPE t000.
    l_mandt-mandt = '1201'.
    INSERT l_mandt INTO TABLE t_mandt.
    SELECT * FROM t000 INTO TABLE lt_t000 FOR ALL ENTRIES IN t_mandt WHERE mandt = t_mandt-mandt+1(3).
    *SELECT * FROM t000 INTO TABLE lt_t000 FOR ALL ENTRIES IN t_mandt WHERE mandt = t_mandt-mandt.
    LOOP AT lt_t000 INTO ls_t000.
      WRITE: ls_t000-mandt.
    ENDLOOP.
    And it seems that the offset isn't being ignored.  I've also done and SQL trace, and this confirms that the offset isn't being ignored - the SQL issued actually says SELECT WHERE "MANDT" = '020' even though I've set it in the table to be 1201.
    So it seems that, at the moment, you can safely ignore the message.  But if SAP ever enforce it, or they make it an error instead of a warning, there will be problems.
    matt

  • Why should we select all key fields when using for all entries

    Hi,
    Why should we select all key fields in our select query when using for all entries statement?
    I read about for all entries but this point was not clear in any post.
    Please explain me
    Regards,
    Subhashini

    Dear Subhasini,
    It is because FOR ALL ENTRIES deletes the duplicate entries before populating the target internal table.
    Please do an F1 on FOR ALL ENTRIES & read the SAP documentation.
    I mean how duplicate entries will not get deleted when we use this?
    Quite simple, if you select  all key fields then each entry will be unique & there will not be any duplicate entries to delete !!
    BR,
    Suhas
    Edited by: Suhas Saha on Oct 16, 2009 9:41 AM

  • Inner join and select for all entries with respect to performance in SAP

    Hi Friends,
    I just want to know which is more efficient with respect to performance the Inner join or select for all entries?which is more efficient?
    Regards,
    Dinesh

    I did some testing a while ago and found that a JOIN is usually a bit more efficient than FOR ALL ENTRIES. This wasn't always the case though, so the best thing to do is to write it both ways and see which is faster.
    Rob

  • Max no of records in for all entries table

    Hello all,
    Hi have used for all entries in a select statement in BW extractor. This extractor is working fine for the test data. When i moved this code to pre-production for testing, there this extractor has to deal with thousands of records. In pre-prod , this select statement is not picking up all the records available in DB. Can any one give any idea on behavior of for all entries for large number of records. and is the any max limit for for all entries table.
    Thank you..correct answer will be rewarded.
    Regards
    Sravan

    Moderator message - Please search before asking and do not offer rewards (particularly since as far as I can see, you've awarded a total of two points in the last two years - post locked
    Rob

  • For all entries with 2 internal table

    HI experts.
    How to use  2 for all entries in a select statement.
    Below refer to my below code.
    select vbeln matnr lfimg vgbel posnr from lips into corresponding fields of table
      it_lips for all entries in  it_likp   where
                  vbeln = it_likp-vbeln and
                  matnr = it_mara-matnr.
    I want to add another for all entries it_mara.
    Please help me .Thanks in advanced.

    hi,
    it is possible....
    use this query...
    declare another internal table of the same type as it_lips.
    data : it_lips_final like it_lips.
    select vbeln matnr lfimg vgbel posnr from lips into corresponding fields of table
    it_lips for all entries in it_likp where
    vbeln = it_likp-vbeln .
    loop at it_lips.
      read table it_mara into it_mara with key matnr = it_lips-matnr.
      if sy-subrc = 0.
        append it_lips to it_lips_final.
      endif.
    endloop.
    refresh it_lips[].
    it_lips[] = it_lips_final[]
    what the above code does is selects all the entries of vbeln from lips and filters it in the loop reading it from mara checking for matnr value and finally
    all the entries according to your requirement is there in it_lips_final which we move it to it_lips again...
    this is something similar to writing a for all entries for 2 table.... but in another fashion
    Regards
    Siddarth

  • FOR ALL ENTRIES IN Problem

    Hello,
    probably it is a silly problem, but can anybody tell me why this FOR ALL ENTRIES IN statement does not fill all the columns of my internal table?
    At the end of the report only the columns LGOBE contains values.
    data itab type zmm_t_alv.
    select mardmatnr mardwerks mardlgort mardlabst
      maktspras maktmaktx
      into corresponding fields of table itab
      from mard inner join makt
        on mardmatnr = maktmatnr
    where makt~spras = 'D'.
    select lgobe
      into corresponding fields of table itab
      from t001l
      for all entries in itab
      where t001l~werks = itab-werks.
    break-point.
    Thanks,
    Manuel

    Please read the documentation aboutr for all entries
    For all entries selects all records from a db table which correspond to the entries in an internal table, the result must be stored in a different table.
    Otherwise use a loop at itab.
       select single ...
       modify itab
       endloop
    Be careful with empty For all entries tables, it behave like a ranges table, no entry means no restriction and you get all records from the db table. That is a different behavior than the loop above.
    Use   field1 field2 ... in corresponding fields of ....
    If you specify only one field then you get only one result.
    If you want one the field 'lgobe' then use into wa-lgobe and not the much slower into corresponding!
    Siegfried

  • Can we use inner joins with for all entries?

    Hi,
        Can we use innerjoin on two tables MARA and MAKT against the materials in
        the  internal table.
        If so ,please let me know whether there is performance issue.Because if there is
        bad performance issue or something else like thise means,my project manager
        wont allow to include.
        So can one let me know about this.
    Thanks,
    Balaji

    Hi Arunkumar,
                               I think you are not clear.My question is can I use innerjoin with
    for all entries.For example below is my code.
    SELECT A~MATNR
             B~MAKTX
             A~MTART
             A~MATKL
             FROM MARA AS A INNER JOIN MAKT AS B
             ON AMATNR = BMATNR
             INTO TABLE IT_MARA_MAKT
             FOR ALL ENTRIES IN IT_MATNR
             WHERE A~MATNR = IT_MATNR-MATNR
             AND   A~EXTWG = P_EXTWG
             AND   A~SPART = P_SPART.
    Can we use like this for all entries along with innerjoins.
    Thanks,
    Balaji

  • FOR ALL ENTRIES in Object Oriented Context

    Dear all,
                is it possible to use FOR ALL ENTRIES for an internal table with out header line ? I Am using Objected Oriented Programming and I Am not able to create internal table with header line . Please provide your valuable inputs on this issue.
    Thanks In Advance.
    Sri

    Hello,
    Few questions:
    1. Did you do an F1 on FOR ALL ENTRIES(FAE)? Does it say FAE is allowed only for tables w. header line?
    2. Have you tried using FAE on an internal table w/o header line? Does it give an error?
    BR,
    Suhas

  • Performance on Select Single&Write  AND Select*(For All Entries)&Read&Write

    Hi Experts,
    I got a code review problem & we are in a argument.
    I need the best performance code out of this two codes. I have tested this both on 5 & 1000 & 3000 & 100,000 & 180,000 records.
    But still, I just need a second opinion of experts.
    TYPES : BEGIN OF ty_account,
            saknr   TYPE   skat-saknr,
            END OF ty_account.
    DATA : g_txt50      TYPE skat-txt50.
    DATA : g_it_skat    TYPE TABLE OF skat,       g_wa_skat    LIKE LINE OF g_it_skat.
    DATA : g_it_account TYPE TABLE OF ty_account, g_wa_account LIKE LINE OF g_it_account.
    Code 1.
    SELECT saknr INTO TABLE g_it_account FROM skat.
    LOOP AT g_it_account INTO g_wa_account.
      SELECT SINGLE txt50 INTO g_txt50 FROM skat
        WHERE spras = 'E'
          AND ktopl = 'XXXX'
          AND saknr = g_wa_account-saknr.
      WRITE :/ g_wa_account-saknr, g_txt50.
      CLEAR : g_wa_account, g_txt50.
    ENDLOOP.
    Code 2.
    SELECT saknr INTO TABLE g_it_account FROM skat.
    SELECT * INTO TABLE g_it_skat FROM skat
      FOR ALL ENTRIES IN g_it_account
          WHERE spras = 'E'
            AND ktopl = 'XXXX'
            AND saknr = g_it_account-saknr.
    LOOP AT g_it_account INTO g_wa_account.
      READ TABLE g_it_skat INTO g_wa_skat WITH KEY saknr = g_wa_account-saknr.
      WRITE :/ g_wa_account-saknr, g_wa_skat-txt50.
      CLEAR : g_wa_account, g_wa_skat.
    ENDLOOP.
    Thanks & Regards,
    Dileep .C

    Hi Dilip.
    from you both the code I have found that you are selecting 2 diffrent fields.
    In Code 1.
    you are selecting SAKNR and then for these SAKNR you are selecting TXT50 from the same table.
    and in Code 2 you are selecting all the fields from SAKT table for all the values of SAKNR.
    I don't know whats your requirement.
    Better you declare a select option on screen and then fetch required fields from SAKT table for the values entered on screen for SAKNR.
    you only need TXT50 and SAKNR fields.
    so declare two types one for SAKNR and another for TXT50.
    Points to be remember.
    1. while using for all entries always check the for all entries table should not be blank.
    2. you will have to fetch all the key fields in table while applying for all entries,
        you can compare key fields with a constant which is greater than initial value.
    3. while reading the table sort the table by the field on which you are going to read it.
    try this:
    TYPES : BEGIN OF ty_account,
    saknr TYPE skat-saknr,
    END OF ty_account.
    TYPES : begin of T_txt50,
          saknr type saknr,
          txt50 type txt50,
    end of t_txt50.
    DATA: i_account type table of t_account,
          w_account type t_account,
          i_txt50 type table t_txt50,
          w_txt50 type t_txt50.
    select SAKNR from SKAT into table i_account.
    if sy-subrc = 0.
    sort i_account by saknr.
    select saknr txt50 from SKAT into table i_txt50
    for all entries in i_account
    where SAKNR = i_account-SAKNR
    here mention al the primary keys and compare them with their constants.
    endif.     
    Note; here you need to take care that, you will have to fetch all the key fields in table i_txt50.
    and compare those fields with there constants which should be greater than initial values.
    they should be in proper sequence.
    now for writing.
    loop at i_account into w_account.
    clear w_txt50.
    sort i_txt50 by saknr.
    read table i_txt50 into w_txt50 with key SAKNR = w_account-saknr
    if sy-subrc = 0.
    write: w_txt50-saknr, w-txt50-txt50.
    clear w_txt50, w_account.
    endif.
    endloop.
    Hope it wil clear your doubts.
    Thanks
    Lalit

Maybe you are looking for

  • Exporting to Vimeo with Premiere Pro CC?

    Hello, I've searched online for guides on how to properly export video for Vimeo using Premiere Pro CC (8.0.1), but have not had any luck. Does anyone know the proper settings? Apparently with other versions of PP there are presets for vimeo and yout

  • Bootcamp Windows Installer won't boot properly on rBMP late 2013

    I have been redirected to this community. I will repost the same question I asked in the mackbook pro community. I am new to Apple Support Communities, I hope this is okay for me to ask the question here again. Here is my post in the other community:

  • Regarding IDOC and ALE

    Hii...experts... I am new to the topologies IDOC,ALE and RFC connection...my requirment is when I create a sales order in one client (say) development..I want to create that sales order in another client (say) quality automatically, for this i want t

  • ISE and AD.. Users Cant login with domain credentials after changing password

    Hello guys, I have ISE 1.2 running in a live environment. I have a problem that users cant login after password has expired and changed. i have enabled password change under AD settings and have also checked the allow password change in the allowed p

  • [SOLVED] Extending an LVM partition

    Recently did a fresh install of Arch, using encryption with LVM on top and Gnome as the desktop. Soon after I had a pop up warning on logging in about there only being 100Mb left on /usr. So I extended the /usr group by 1Gb with the command: " lvexte