Read Internal Table based on Multiple Values for Key Field

Hi Gurus,
i have one query can you tell me how read an internal table it_kna1 for multiple values of land1 DE US IND etc.
i had tried as below but i could not can you try and let me knwo at the earliest.
here i want read the values with DE or US and want further prosess them.
REPORT  YC001.
tables kna1.
select-options: cust for kna1-kunnr.
data: begin of it_kna1 occurs 0,
        kunnr like kna1-kunnr,
        name1 like kna1-name1,
        land1 like kna1-land1,
        end of it_kna1.
select kunnr name1 land1 into table it_kna1 from kna1 where kunnr in cust.
read table it_kna1 with key land1 = ( 'DE' OR 'US' ) .
can anybody suggest me some solution.
Thanks,
Jeevi.

This should be what you need:
REPORT ztest NO STANDARD PAGE HEADING LINE-SIZE 80 MESSAGE-ID 00.
TABLES kna1.
SELECT-OPTIONS: cust FOR kna1-kunnr.
DATA: BEGIN OF it_kna1 OCCURS 0,
        kunnr LIKE kna1-kunnr,
        name1 LIKE kna1-name1,
        land1 LIKE kna1-land1,
      END OF it_kna1.
DATA: itab_index LIKE sy-tabix.
SELECT kunnr name1 land1
  INTO TABLE it_kna1
  FROM kna1
  WHERE kunnr IN cust.
SORT it_kna1 BY land1.
READ TABLE it_kna1 WITH KEY
  land1 = 'DE'
  BINARY SEARCH.
itab_index = sy-tabix.
WHILE sy-subrc = 0.
  itab_index = itab_index + 1.
  WRITE: /001 it_kna1-kunnr, it_kna1-land1, it_kna1-name1.
  READ TABLE it_kna1 INDEX itab_index.
  IF it_kna1-land1 <> 'DE'.
    sy-subrc = 99.
  ENDIF.
ENDWHILE.
SKIP 1.
READ TABLE it_kna1 WITH KEY
  land1 = 'US'
  BINARY SEARCH.
itab_index = sy-tabix.
WHILE sy-subrc = 0.
  itab_index = itab_index + 1.
  WRITE: /001 it_kna1-kunnr, it_kna1-land1, it_kna1-name1.
  READ TABLE it_kna1 INDEX itab_index.
  IF it_kna1-land1 <> 'US'.
    sy-subrc = 99.
  ENDIF.
ENDWHILE.
Rob

Similar Messages

  • How to read an internal table by comparing the values of key fields

    hi ,
      i want to read internal table with multiple  values for the key field . can anyone suggest the syntax or method for doing this,
    thanks in advance.
    regards,
    manoj

    Hi,
    Read statement will read only one value at a time..
    You can only compare with different values.
    example :
    read table it_mara into wa_mara with key matnr = '1000'
                                                                        matnr = '2000'
                                                                        matnr = '3000'.
    if all the 3 records are found in the internal table then it will read the 1 record.
    Regards
    Satish Boguda

  • Multiple values for single field

    hi
    In order to upload Purchase order details, how you handle multiple values for a single field? 
          Eg: Item field may contain no. of values for a record

    Hi,
    It is generally taken care using BDC's by Table Control, and if you are using BAPI's then there are tables for ITEMS.
    Regards,
    Atish

  • Enter multiple values for a field in dialog programming

    I need to enter multiple values for some of the fields in screen , which screen element do i use for this or is there any other way of doing it?

    That would be a table control. In this you can enter multiple values for multiple fields.
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbac5e35c111d1829f0000e829fbfe/content.htm
    Thanks,
    SKJ

  • Multiple values for a field

    Hi All,
            In the vendor repository, i have fields like Phone No, Fax Number, Email addresss which should hold multiple values. i.e One vendor may have have multiple phone no's or email address. How should this be managed. Is it by the Qualifier table or how ? Because i dont want to have Phone No 1, Phone No 2 etc .
    Thanks in Advance !

    In the scenario you mention (the Vendor repository), both the Phone Number and Fax Number fields are links to corresponding Qualified Lookup tables. These are inherently multi-value fields.
    Just for the sake of clarity - with the exception of Measurement type fields, it is only lookup fields that can be set to have multiple values. Refer to the matrix <a href="http://help.sap.com/saphelp_mdm550/helpdata/en/1f/2ddb4203d82b78e10000000a155106/content.htm">here</a>.
    Mark

  • Selecting Records based on multiple values in one field

    Excuse the basic request.
    I want to select all records from one table depending on the value in 2 specific fields. Each of these fields has a single value in it.
    What I have written is as below
    1.select nm_idno "EZAID", nm_fname, nm_lname, nm_et_tt "Position", nm_mt_mt "Status", nm_type, nm_wemal, nm_mailshot from MNME
    2.where nm_type = 'M' and where nm_mailshot = 'Y' and nm_wemal > ' '
    3.and where nm_mt_mt = (1 or 6 or 3 or 10) *** these are the bits that I don't understand why they will not work.
    4. and where nm_et_tt = (408 or 329 or 283)
    Basically every record should have one of the values I have highlighted in it.
    Any help greatly appreciated.

    select nm_idno "EZAID"
          ,nm_fname
          ,nm_lname
          ,nm_et_tt "Position"
          ,nm_mt_mt "Status"
          ,nm_type
          ,nm_wemal
          ,nm_mailshot
    from   MNME
    where  nm_type = 'M'
    and    nm_mailshot = 'Y'
    and    nm_wemal > ' ' --< not sure what you mean here
    and    nm_mt_mt IN (1, 6, 3, 10)
    and    nm_et_tt IN (408, 329, 283)
    ;

  • Plz. help,table does not show value for one field

    hi all,
    i have a really strange problem , i have a string field in access database that contains the date and time value,this field for some strange reason does not show in my table created through html,
    i tried all combination(arranging the fields) ,renaming it w/o help, it shows the value using out.println(but then why is it not showing me in the table???)
    plz. help ASAP.
    the code is as under
    <HTML>
    <HEAD><TITLE> LOGGED IN ok</TITLE> </HEAD>
    <BODY bgcolor = "yellow">
    <%@ page import = "java.sql.*" %>
         <%! // declaring variables
    String s = "";
    java.sql.ResultSet rs=null,rs1=null,rs2=null;
    java.sql.Connection con;
    java.sql.Statement stmt,stmt1;
    String empId = "",compid ="",calltype ="",probheader="",probdescription ="",probcomment ="",priority ="",a="";
    %>
    Following are the pending complaints ..
         <TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 width="100%">
         <TR>
         <TD> ComplainD </TD>
    <TD> ComplainId </TD>     
    <TD> ProbHeader </TD>     
    <!--
    <TD> ProblemDescription </TD>     
    <TD> Problem Comments </TD>     
    -->
    </TR>
         <%
         try
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         java.sql.Connection con = java.sql.DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};" +"DBQ=c:/vishal/HelpDesk.mdb;DriverID=22;READONLY=false","","");
         //java.sql.Connection con = java.sql.DriverManager.getConnection("jdbc:odbc:Portal");
              java.sql.Statement stmt = con.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
              s = "select * from Complains";
         java.sql.ResultSet rs = stmt.executeQuery(s);               
                        while(rs.next())
                        //getting data from database
                                                           empId = rs.getString("EmpId");                    // out.print(" " + empId);
              compid = rs.getString("ComplainId");
              // out.print(" " + compid);
              calltype = rs.getString("CallType");
              // out.print(" " + calltype);
                        a = rs.getString("Complaindate"); //problem with this field
    out.print(a); // prints value
              %>               
                        <TR>      
                        <TD> <%=compid %> </TD>
                        <TD> <%=calltype %> </TD>     
                        <TD <%=a %> </TD>
                                       </TR>
    <%
                        }//while loop          
         %>
         </TABLE>     
         <%                
         }//try
              catch(Exception ep)
              out.println(ep);
              System.exit(1);
    %>
    </BODY>
    </HTML>
    value in database is as follows :-
    Complaindate
    5/18/2003 1:30:27 PM
    5/18/2003 7:32:43 PM
    5/18/2003 7:34:02 PM
    5/18/2003 7:49:19 PM
    5/18/2003 7:50:27 PM
    5/18/2003 10:49:42 PM
    5/18/2003 10:58:24 PM
    thanking u ,plz ask if any further clarifications

    Hi
    I am seeing nothing wrong with ur code..
    what about "view source" result.....plz check with that...
    whether u r getting all the trs and tds...
    revert back on this Issue..
    Mars Amutha

  • Filtering internal table using select-option values

    Hi,
    I got an internal table with select-option values. for eg.  it_perno with the values  I  BT    000160    000170.
    Now i got another second internal table which is have the person number. Now i need to filter this second internal table based on the values from the select option table. my question is
    i can collect all the values from 160 to 170 in a separate table by looping over the select option table. and then based on the values filter the second internal table person number.
    But what would be the case if the select option contains both intervals and multiple options. For eg.
    I BT 000160      000170.
    I EQ 000185.
    So can you suggest any good solution, that based on this select option table i need to filter the second internal table Person number.
    Thanks in advance.
    Regards,
    anbu.

    Hi,
    Can you not use the select-options in the Select query while populating the internal table.
    SELECT pernr FROM pa0000 INTO it_tab WHERE pernr IN s_pernr.
    If you cannot do this and you do not want to delete the unwanted entries, then you can use the WHERE clause in the LOOP statement to process the specific entries required:
    LOOP AT it_tab INTO wa_tab WHERE pernr IN s_pernr.
    Regards,
    Aparna Alashe.

  • Multiple records to be created for multiple values in a field

    I am having a requirement in which i will have multiple values for a field.The values are seperated by commas.I need a record to be created for each value.(eg: if there are 4 values i need 4 records to be created). Any one please help me out.

    Hi !
    You can try solve it at File Content Conversion level, by specifing your value separator as the endSeparator.
    Or you can import all values as a unique record and then solve it via graphical mapping, using an advanced UDF, where you receive N records, then inside the UDF, you split the values via its separator and create new array values (one for each input value after splitting) and output that array to be used to fill destination structure.
    Regards,
    Matias.

  • How to assigne multiple value in key of read table

    Hi gurus,
    I want read table xxxx with key field1 = ' xxx' or field1 = 'yyy'.
    how to assign multiple value as key for the same field while reading internal table.
    Regards
    sagar

    Hi ,
    You can loop the internal table like
    loop at  <table xxxx> where field1 = ' xxx' or field1 = 'yyy'
    or you can write two read statements to read the internal table in wrk area.
    read table   <table xxxx> with key field1 = ' xxx'.
    if sy-subrc <>0
    read table   <table xxxx> with key field1 = 'yyy'.
    if sy-subrc = 0
    endif.
    else.
    do your data processing.
    endif.
    Thans.

  • Multiple values for one key in hashtable k, v

    So, I know that java.util.hashtable (as of Java 1.5) uses separate chaining to handle collisions. What I want to know is how to get a certain value somewhere in that bucket if they all share a common key? Javadoc says I have to search it sequentially but doesn't say how.

    OK, there's a lot of confusion on here for such a short thread :-)
    Firstly, HashMaps pick which "bucket" to store your object in based on the hash value of your object (see Object.hashCode()). However, the actual object equality test (applied to the keys during a search) is based on Object.equals(). Therefore which bucket your object is in is irrelevant - the bucketting concept is just used as a way of quickly locating a subset of all the keys in the map which might match your search value. There could very well be just a single bucket in a map and it wouldn't change its logical behaviour.
    This statement: "any Map including Hashtable, can only have a single (key,value) pair" is poorly worded. What it should say is that for any given key, a map can only hold a single value.
    Really, you don't need to think about the internal structure of maps (i.e. buckets, etc.).
    If you want to store multiple values for any given key, then make your value a list (java.util.List) and store your multiple real values inside that list.

  • Passing multiple values for a single field in URL to call sap Transaction

    Hi All,
    I need to pass multiple values for a single field to SAP transaction .
    means if i have say a field "Date" which can contain more than one value, <b>but its not a range which has two fields</b> . How is it possible.
    Let me know pls.
    Regards,
    Sirisha.R.S.

    Hi Satyajit,
    I need to call a transaction with multiple values which gives me the report based on those values.
    So I need to pass multiple values for a single parameter.
    I hope u got it.
    Regards,
    Sirisha.R.S.

  • Any way to pass Multiple Values for a single Label in the Parameter?

    I have a Report that Contains 2 Parameters, @Customer & @Area. When trying to set up the Available Values for @Area, I'm having issues using multiple values for one Label, i.e. = "4006" Or "4610"
    One of the Filters in the Report is an Operation number, which is the [OPERATION] field, which is setup as a filter on the Tablix referencing the @Area parameter. 
    PROBLEM: I cannot retrieve any data when trying to use the ‘Or’ Operator here. If I simply put “4006” or “4610” I retrieve data, but when trying to combine it returns no data.
    Example, I need to allow a user to select ‘Chassis Incoming’, which would include data from Operations 4006 & 4610.
    QUESTION:
    Any way to pass Multiple Values for a single Label in the Parameter?
    I realize the typical solution may be to use ‘Multi-Value’ selection, but in this case we want the User to select the Area and the multiple values for Filtering will be automatically determined for them. Otherwise, they are subject to not getting
    it correct.
    I have tried several different ways, such as =”4006” Or “4610”, =(“4006”, “4610”), = In(“4006”, “4610”), etc….
    Note: We are using Report Builder 3.0

    Based on my experience, there's no way to 'intercept' the query that gets passed back to SQL Server, so a Split wouldn't work.
    Try creating either a function or stored procedure using the code below (compliments to
    http://www.dotnetspider.com/resources/4680-Parse-comma-separated-string-SQL.aspx) to parse the string: 
    CREATE FUNCTION dbo.Parse(@Array VARCHAR(1000), @Separator VARCHAR(10))
    RETURNS @ResultTable TABLE (ParseValue VARCHAR(100))AS
    BEGIN
    DECLARE @SeparatorPosition INT
    DECLARE @ArrayValue VARCHAR(1000)
    SET @Array = @Array + @Separator
    WHILE PATINDEX('%' + @Separator + '%' , @Array) <> 0
    BEGIN
    SELECT @SeparatorPosition = PATINDEX('%' + @Separator + '%', @Array)
    SELECT @ArrayValue = LEFT(@Array, @SeparatorPosition - 1)
    INSERT @ResultTable VALUES (CAST(@ArrayValue AS VARCHAR))
    SELECT @Array = STUFF(@Array, 1, @SeparatorPosition, '')
    END
    RETURN
    END
    Once created you can do things like this:
    SELECT * FROM Parse('John,Bill,David,Thomas', ',')
    SELECT * FROM (SELECT 'John' AS TestName union select 'David' AS TestName) AS Main
    WHERE TestName IN (SELECT ParseValue FROM dbo.Parse('John,Bill,David,Thomas', ','))
    This is what your SQL query would probably look like:
    SELECT OperationID, OperationName FROM dbo.Operations
    WHERE AreaID IN (SELECT ParseValue FROM dbo.Parse(@Area, ','))
    You may need to fiddle around with the Separator depending on whether SQL Server inserts a space between the comma and next value.

  • How to prepare final internal table based on no. of records of individual t

    Hi all,
       I have to prepare final internal table based on the no. of records of individual table. i.e.  I should append  the data from the table which has large no of records first. Then I should modify the final table with other individual tables. I have reservation list table(RESB), purchase  requisition table(EBAN), purchase order delivery schedules table(EKET) , GRs table (MESG) .I have prepared data for individual tables. We can't say particularly that this table'll have large no. of records always. So how can I append the first table into final internal table ? I have separate work areas for each table in my SMARTFORM.
    Edited by: Jayasri P. on Aug 30, 2008 6:02 AM

    HI,
    DESCRIBE TABLE statement with LINE addition will give you the no of record in an internal table.
    For further detail check,
    http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3798358411d1829f0000e829fbfe/content.htm
    you can stire the LINE value of each and comare them to get the table with max record.
    Regards,
    Anirban

  • Storing multipl values for meta data in DOCUMENT_META_DATA

    Hi,
    We currently have 3 content types in our system: news, announcements, and events.
    They are currently stored in 3 different tables. We want to make this content
    available via the various CM (select) and PZ tags (contentquery, contentselector).
    I'd like to avoid writing my own doc provider (file:///D:/bea7/weblogic700/wlp/docs70/dev/conmgmt.htm#999019)
    and instead would like to begin to publish document data directly to the reference
    implementation tables (DOCUMENT and DOCUMENT_METADATA).
    It seems like I should be able to do that with one exception. It doesn't seem
    like we can store multiple values for meta data attributes. If you take the out
    of the box p13n example, a lot of the data is tagged with 'genre' = Something
    (i.e. Rock, Hip-hop, etc). Then content queries use this genre to personalize
    pages.
    What if I have a band that has multiple genres? What if I want to tag my band
    as Rock and Hip-hop? And then also want that band to appear on both a Rock lovers
    and a Hip hop groupies page? Is this possible with the default implementation?
    I know when I tried entering multiple 'genre' meta data values for a same document
    ID, it gave me a PK constraint violation. Any other trick around this?
    Thanks,
    Will Young
    ps. using weblogic 7...

    Yes Subler http://code.google.com/p/subler/ does support adding the HD tag.
    On the Mac I wouldn't use anything but Subler for tagging, best UI, best metadata lookup, best underlying libraries for mp4 files (I'm biased on the libraries part).
    Cheers Ed.

Maybe you are looking for