Determine Length of Field in Select Statement

Hi Experts!
My officemate has this little problem regarding selection of data based on a certain condition...
Here is the situation:
For Example...
In table KNA1....
KUNNR       NAME1         Length of Data in Name1
000001        AA                2           
000002        AB                2
000003        ABCD           4
000004        ABCDE         5
She only wants to get the records that has the length of 2 in KNA1-NAME1,
i.e., 'AA' and 'AB' without having to put it in the internal table then make a loop and update the table using the strlen() condition....
Experts, is this possible? Knowing the length of the data in the select statement? She wants this alternative because it is faster rather than having to loop in internal tables and check if this data has the length of 2 or 3 or 4 and so on....
Can you please help me out with this one? Thanks in advance!
<b></b>

Hi
If the lenghtn is 6 characters and if you want to fetch only first 2 characters.
you can use offset
fetch data from internal table and take variable
v_var1 = itab-name1+0(2).
you get only first 2 characters....
if you want last 2 characters itab-name1+4(2).
Thanks

Similar Messages

  • Dynamic fields in select statement

    Hi all,
       In selection screen we are having period as select option.The values for period are 01 to 16. Based on 
          the values entered in selection screen for period we need to select HSLXX from FAGLFLEXT.
       For example if we enter 01 to 03 in selection screen then we need to select HSL01 HSL02 HSL03  
           from FAGLFLEXT.
      Like this we need to select fields dynamically in select statement. Can any one tell me how to restrict fields dynamically.
    Regards,
    Swetha

    hi Swetha,
    the  third select statemnet will work for  you..
    try this..
    _Dynamic where clause in select query.._
    * With a variable, result: AND rbusa = '5145'
    concatenate 'AND rbusa = '  ''''  i_tab-zgsber  ''''
    append where_clause to where_tab.                                  
    * Select
    select * from zcostfreq                                           
         where (where_tab).                                              
    endselect.
    _Using a dynamic table name_
    parameters:
    p_tab type tabname.
    start-of-selection.
      select count(*) from (p_tab) into l_count.
    _Dynamic retrieval and writing of data_
    FIELD-SYMBOLS:
      <row>         TYPE ANY,
      <component>   TYPE ANY.
    PARAMETERS:
    p_tab TYPE tabname.
    CREATE DATA dataref TYPE (p_tab).
    * The variable dataref cannot be accessed directly, so a field symbol is
    * used
      ASSIGN dataref->* TO <row>.
      SELECT *
        FROM (p_tab) UP TO 10 ROWS
        INTO <row>.
        NEW-LINE.
        DO.
    *     Write all the fields in the record   
          ASSIGN COMPONENT sy-index
            OF STRUCTURE <row>
            TO <component>.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          WRITE <component>.
        ENDDO.
      ENDSELECT.
    Regards,
    Prabhduas

  • Where condition with optional fields in select statement

    Hi,
    In a function module I have to fetch data based on 7 fields out of which 6 are optional.
    If we won't enter values for optional fields it will take default values as zeroes .
    So this is not fetching data. But for some fields some values has zero values.
    How to solve this condition?
    Regards,
    maha.

    Hi,
    For those import parameters for which its mentioned as optional, use like condition in the where clause of select statement in the function module.
    try like this,
    concatenate pfield2 '%' into pfield2.
    concatenate pfield3 '%' into pfield3.
    concatenate pfield4 '%' into pfield4.
    concatenate pfield5 '%' into pfield5.
    concatenate pfield6 '%' into pfield6.
    concatenate pfield7 '%' into pfield7.
    select *
    from db table
    into itab
    where field1 = pfield1 and
               field2  like pfield2 and
               field3  like pfield3 and
               field7 like pfield7.
    Now even if the optional fields are blank, data will be selected
    Regards,
    Vik

  • Dynamic field in Select Statement

    I am able to create a dynamic statement to insert into the where clause of my sql, but I am unable to dynamically create a select statement. Oracle Reports produces the following error:
    REP-0499: Column " selected by the query is incompatible with report definition.
    Here is an example of my select:
    Select
    &dynamic_field
    from
    any_table
    Any help is appreciated.

    I figured it out. Thanks

  • Using a varchar field to select statement

    Hi all
    I have a single row and single column table
    T(command varchar2(4000))
    and the row is
    sno,name
    And I have another table T1(sno number,name varchar)
    Now can any body tell how can i use command column in table T to query T1 to get sno,name from T1
    I am looking for a select statement like this
    select (select command from T) from T1;
    but it is printing out the data in T i mean sno, name
    This is a copy of thread Selecting output of a select statement
    but explained more clearly
    Thanks,
    ganesh.

    I don't know why your tables are designed like this but what I think you want to do is join T1 with the data in T.
    select sno, name from T1
    where sno in (select substr(command,0,instr(command,',')-1) from T)
    and name in (select substr(command,instr(command,',')+1) from T);
    substr returns a string up to a position
    instr returns the position of a string
    and the other post you refer to as about as confusing as your one.

  • How to get around Ampersand in text field in Select statement

    I have an SQL statement I am trying to run in SQL*Plus. In one of my subqueries, I have a select statment in which some of the fields I am trying to pull have an "&" within the text. So, when I try and run the query it returns "Enter value for 35:". I've even tried wildcard characters and it is still not working. If anyone could help me with this, I would appreciate it. Here is a sample of my statement (the subquery is at the bottom of the statement):
    select real_case.file_dt, real_case.dscr, pty_cd, first_name, last_name, addr_line1, addr_line2, city, st_cd, zip_cd
    from real_case, pty, idnt, ptyaddr s1, addr
    where real_case.case_id = pty.case_id
    AND pty.idnt_id = idnt.idnt_id
    AND pty.case_id = s1.case_id
    and pty.seq = s1.seq
    and s1.addr_id = addr.addr_id
    and (real_case.file_dt >= '01-NOV-06'
    and real_case.file_dt <= current_date)
    and (real_case.dscr like '79D01-%'
    or real_case.dscr like '79C01-%'
    or real_case.dscr like '79D02-%')
    and (pty.pty_cd like 'DFNDT')
    and (s1.ins_dttm in
    (select max(s2.ins_dttm) from ptyaddr s2
    where s2.case_id = s1.case_id
    and s2.seq = s1.seq))
    and (real_case.case_id in
    (select case_id from ptychrg
    where ptychrg.actn_cd IN ('35-41-5-1&35-48-4-1')));Thanks,
    Shannon

    this?
    SQL> set define off
    SQL> ed
    Wrote file afiedt.buf
      1  with t as
      2    (select 'a&b' col from dual
      3      union all
      4      select 'abc' from dual)
      5   select    * from t
      6*  where col like '%\&%'
      7  /
    COL
    a&b
    or this
    SQL> ed
    Wrote file afiedt.buf
      1  with t as
      2    (select 'a&b' col from dual
      3      union all
      4      select 'abc' from dual)
      5   select    * from t
      6*  where col like '%'||chr(38)||'%'
    SQL> /
    COL
    a&bjust '%'||chr(38)||'%' will not work.
    You nedd either set scan off or set define off
    correction
    Message was edited by:
    devmiral

  • Group by function with CLOB fields in Select statement

    I have the following sql trying to query our database. Removing the Clob field (a.description) I am successful. But I need the Clob field (a.description). Here is my current sql
    select  a.id_number, a.id_owner,  MAX (n.next_action_required)
                KEEP (DENSE_RANK LAST ORDER BY n.modified_date),
             MAX (n.modified_date) KEEP (DENSE_RANK LAST ORDER BY n.modified_date)
    from table1 a, table2 n
    where a.id_number = n.id_number
    group by a.id_number, a.id_ownerI tried the following which works sometimes but not always because the Clob field (a.description)'s length varies; anywhere from 10 characters up to 12,000 characters. I get some blanks with the following and some where text is cut off. I may not be writing the dbms_lob.substr function correct.
    select  a.id_number, a.id_owner,  MAX (n.next_action_required)
                KEEP (DENSE_RANK LAST ORDER BY n.modified_date),
             MAX (n.modified_date) KEEP (DENSE_RANK LAST ORDER BY n.modified_date) , DBMS_LOB.SUBSTR (a.description, 8001, 10000)
    from table1 a, table2 n
    where a.id_number = n.id_number
    group by a.id_number, a.id_owner, DBMS_LOB.SUBSTR (a.description, 8001, 10000)Please help. Thank you,

    Maybe,
    but throw it away if the combination a.id_number,a.id_owner,n.next_action_required(a.id_number = n.id_number),n.modified_date(a.id_number = n.id_number) is not unique
    select nd.id_number,
           nd.id_owner,
           nd.next_action_required,
           nd.modified_date,
           a.description
      from (select a.id_number,
                   a.id_owner,
                   MAX (n.next_action_required) KEEP (DENSE_RANK LAST ORDER BY n.modified_date) next_action_required,
                   MAX (n.modified_date) KEEP (DENSE_RANK LAST ORDER BY n.modified_date) modified_date
              from table1 a,
                   table2 n
             where a.id_number = n.id_number
             group by a.id_number,
                      a.id_owner
           ) nd,
           table1 a
    where nd.id_number = a.id_number
       and nd.id_owner = a.id_owner
       and nd.id_number = (select id_number
                             from table2
                            where next_action_required = nd.next_action_required
                              and modified_date = nd.modified_date
                          )Regards
    Etbin

  • Validation of a field in select statement

    In selection screen, skunag(vbrk-kunag) and swerks(vbrp-werks) fields are there.these two fileds are obligatory.
    If skunag field values start with 'P'.I have to remove the initial 'P' in that values,because I have to validate that field with ztable-kunag.
    i have written folllowing way.but no result.
    AT SELECTION-SCREEN ON SKUNAG.
    PERFORM check_skunag.
    form check_skunag.
    data: p_kunag(10) type c.
    if not skunag is initial.
        p_kunag = skunag+4(4).
        move p_kunag to skunag.
    endif.
    endform.
    one more thing this skunag filed is also using in another form for database selection.In this form i want to use the above skunag field, after validation....
    form gatherdata.
      SELECT vbeln kunag zuonr vkorg waerk fkart FROM vbrk INTO CORRESPONDING FIELDS OF TABLE itab
            WHERE vbeln IN svbeln
           AND   kunag IN <b>skunag</b>.
    endform.
    how can i write the above scenario...
    thanks in advance,
    fractal

    Looks like skunag is a select-option. In that case, it will be very difficult to validate it because if the user enters a range like P00001 to P99999, how are you going to validate this against the Z table.
    First you will have to restrict the user from using ranges. That you can do by defining your skunag with no-intervals. Then you will be able to validate that easily as user can only enter single values, no ranges.
    You need to have your validation in AT SELECTION-SCREEN ON <b>skunag-low</b>.
    In your FORM check_skunag, you need to change the code as follows
    data: p_kunag(10) type c.
    LOOP AT skunag.
    *-- only if the first character is P
      CHECK skunag-low+0(1) = 'P'.
      p_kunag = skunag-low+1(remove the first P)
    *-- check against the Z table with p_kunag
      SELECT KUNAG FROM ztable WHERE kunag = p_kunag.
      IF sy-subrc <> 0.
    *-- invalid KUNAG
        DELETE skunag.
      ELSE.
    *-- If you want to move the value without P back into
    *   your skunag then do the following
        MOVE p_kunag to skunag-low.
        MODIFY skunag.
      ENDIF.
    ENDLOOP.

  • Problem accessing TABLE fields in SELECT statement

    Hi,
    We are currently using Oracle Database 10.2.0.2.0.
    In the following code, using a function to access TABLE fields works, but not when accessing the table fields directly (in the latter case, I get a no data found exception).
    Why is that?
    Thanks for your help.
    Olivier
    PS: I do have a lengthy explanation of why we would want to do that as well as the full packages, etc... But I didn't want to bore you to no end.
    I'll post it if required.
    CREATE OR REPLACE PACKAGE PA_TEST_DEVTBL AS
       TYPE TBL_ROLCODE IS TABLE OF LANROLE.ROLCODE%TYPE INDEX BY BINARY_INTEGER;
       TYPE TBL_ROLLABEL IS TABLE OF LANROLE.ROLLABEL%TYPE INDEX BY BINARY_INTEGER;
    end PA_TEST_DEVTBL;
    CREATE OR REPLACE PACKAGE BODY PA_TEST AS
       -- Array containing the selected data
       TblRolCode PA_TEST_DEVTBL.TBL_ROLCODE;
       TblRolLabel PA_TEST_DEVTBL.TBL_ROLLABEL;
       -- Functions created to retrieve each array data
       FUNCTION F_GET_ROLCODE( nIndex NUMBER ) RETURN LANROLE.ROLCODE%TYPE IS
       BEGIN
          RETURN TblRolCode( nIndex );
       END F_GET_ROLCODE;
       FUNCTION F_GET_ROLLABEL( nIndex NUMBER ) RETURN LANROLE.ROLLABEL%TYPE IS
       BEGIN
          RETURN TblRolLABEL( nIndex );
       END F_GET_ROLLABEL;
       PROCEDURE S_TEST (
    -- THIS DOESN'T WORK (ORA-01403: no data found)
    OPEN cReturn FOR
    SELECT TblRolCode( ROWNUM ),
    TblRolLabel( ROWNUM )
    FROM TABLE( CAST( tblRows AS T_TBL_NUMBER ) );
    -- BUT THIS WORKS !!!
    OPEN cReturn FOR
    SELECT F_GET_ROLCODE( ROWNUM ) AS ROLCODE,
    F_GET_ROLLABEL( ROWNUM ) AS ROLLABEL
    FROM TABLE( CAST( tblRows AS T_TBL_NUMBER ) );
    ..

    well it could be managed by simple HTML tags or simple javascript properties and events itself...
    All you have to do is encode URL and pass it as the request parameters to the next page.
    Checkout a simple example down below.
    MainTable.jsp:
    ============
    <table>
    <thead>
    <tr>
    </tr>
    </thead>
    <tbody>
    <c:forEach var="DTOBean" items="${request.dbList}">
      <tr>
         <td><c:out value="${DTOBean.rowId}"/></td>
         <td onClick="window.location.href='/testpage.jsp?col2='+escape('<c:out value="${DTOBean.col2}"/>')+'&col3='+escape('<c:out value="${DTOBean.col3}"/>'); " ><c:out value="${DTOBean.col1"/></td>
        <!-- or try with to work with simple hyperlink
          <td><a href="# " onclick="window.location.href='/testpage.jsp?col2='+escape('<c:out value="${DTOBean.col2}"/>')+'&col3='+escape('<c:out value="${DTOBean.col3}"/>');"><c:out value="${DTOBean.col1"/></a></td>
        -->
          <td><c:out value="${DTOBean.col2"/></td>
          <td><c:out value="${DTOBean.col3"/></td>
      </tr>
    </c:forEach>
    </tbody>
    </table>
    --------------------------------------------------testpage.jsp:
    ==========
    Column2 : <c:out value="${param.col2}"/>
    Column3 : <c:out value="${param.col3}"/>
    --------------------------------------------------Hope that might help.
    REGARDS,
    RaHuL

  • Restrict number of characters in table field for select statement.

    SELECT * FROM table
                    WHERE  column1  = z-column.
    The field column1 is of  type char and size 20
    The field z-column is of type char size 10.
    how do we perform this select?
    Anyone can guide me?
    Edited by: Hadesfx on Sep 11, 2009 3:56 PM
    Edited by: Hadesfx on Sep 11, 2009 3:59 PM

    Hello,
    In your OP did you mention this? Please be specific when you post the next time.
    Can you please post your code?
    I think you have to try a work around:
    DATA:
    RS_STOCKID TYPE SELOPT,
    RT_STOCKID TYPE STANDARD TABLE OF SELOPT.
    LOOP AT GT_ZB1PUT_STOCKTMP.
    RS_STOCKID-SIGN = 'I'.
    RS_STOCKID-OPTION = 'EQ'.
    RS_STOCKID-LOW = GT_ZB1PUT_STOCKTMP-STOCKID.
    APPEND RS_STOCKID TO RT_STOCKID.
    CLEAR RS_STOCKID.
    ENDLOOP.
    You can use this RANGE table to SELECT data from the table.
    SELECT * FROM zb1xxt_param
                FOR ALL ENTRIES IN gt_zb1put_stocktmp[]
                WHERE zzcode    = 'DEV036'
                AND   zzdomain  = 'SD'
                AND   zzdata    = 'INBOUND'
                AND   zzinput1  = 'STOCKID'
                AND   zzinput2  IN RT_STOCKID. "Use RT_STOCKID for SELECT'ing data
    BR,
    Suhas

  • Select Statement Doubt

    Moderator message: Please use meaningful subject in future
    Hi,
    I've a requirement that I need to get a record from EREV table for a Purchase Requisition no. based on Latest Version No. (REVNO. ) at a single shot.
    I hav used the following code but i dint get desired values.
    Select EDOKN
              FGNAM
              FGDAT
              REVNO
           from EREV into ls_erev
           where edokn eq p_edokn and
                     revno eq (select Max(revno) from erev)).
    Any body pl help me.
    -Rajiv
    Edited by: Vaddepati on Dec 3, 2008 11:01 AM
    Edited by: Matt on Dec 3, 2008 10:03 AM

    Hi veddapati,
    Your sequence of using the fields in Select statement is wrong...thats why, you are not getting the required output..
    You should select revno in the select statement before FGNAM as it is present in the table..
    Please modify your select statement like this..... ::
    Select EDOKN
    REVNO
    FGNAM
    FGDAT
    from EREV into ls_erev
    where edokn eq p_edokn and
    revno eq (select Max(revno) from erev)).
    Hope it will solve your problem
    Regards,,
    Nikita
    Edited by: Nikita Jain on Dec 3, 2008 2:29 PM

  • Nested select statements.

    Hi, I am writing a piece of code in which i use nested select statements for 4 tables to retrieve one column's data (ie: POSNR). But when i execute it, it takes way too long to get the data. I'm quite new to ABAP so very in need of your help. Thanks
    REPORT  z_impos_test.
    TABLES: coss,       "CO Object: Cost Totals for Internal Postings
            afvc,       "Operation within an order
            prps,       "WBS (Work Breakdown Structure) Element Master Data
            imzo.       "Table: CO Object - Capital Investment Prog.Pos.
    TYPES: BEGIN OF st_impos,
      objnr       TYPE coss-objnr,
      gjahr       TYPE coss-gjahr,
      kstar       type coss-kstar,
      projn       type afvc-projn,
      pspnr       type prps-pspnr,
      posnr       type imzo-posnr,
    END OF st_impos.
    data: year TYPE coss-gjahr value '2007'.
    DATA: t_output  TYPE STANDARD TABLE OF st_impos WITH HEADER LINE,
          st_output TYPE st_impos,
          t_output2 TYPE STANDARD TABLE OF st_impos WITH HEADER LINE,
          st_output2 TYPE st_impos.
    SELECT objnr gjahr kstar FROM coss
    INTO CORRESPONDING FIELDS OF st_output
    WHERE ( objnr LIKE 'NV%' OR
          objnr LIKE 'PR%' ) AND
           gjahr = year.
       SELECT SINGLE projn from afvc into CORRESPONDING FIELDS OF st_output
           WHERE objnr = st_output-objnr.
    APPEND st_output to t_output.
    ENDSELECT.
    SORT t_output BY objnr.
    DELETE ADJACENT DUPLICATES FROM t_output.
    LOOP AT t_output into st_output.
    SELECT objnr pspnr
           INTO CORRESPONDING FIELDS OF st_output2
           FROM prps
           WHERE objnr = st_output-objnr
           AND   pspnr = st_output-pspnr.
      SELECT SINGLE posnr from imzo into CORRESPONDING FIELDS OF st_output2
           WHERE objnr = st_output2-objnr.
    APPEND st_output2 to t_output2.
    ENDSELECT.
    ENDLOOP.
    LOOP AT t_output2 to st_output2.
    WRITE:   st_output2-posnr.
    ENDLOOP.
    Edited by: Jacie Johns on Apr 23, 2009 11:26 PM

    HI John,
    Try to avoid INTO CORRESPONDING FIELDS in SELECT statement.
    As you are not using PSPNR and POSNR fields in the first SELECT statement. If you remove these fields, in structure, INTO CORRESPONDING FIELDS can be avoided. Create a separate structure with the fields that are required for T_OUTPUT table (i.e. create another structure with only first 4 fields, as T_OUTPUT1.
    And as mentioned in your code,
      WHERE objnr = st_output-objnr
           AND   pspnr = st_output-pspnr
    in select statement, ST_OUTPUT-PSPNR value is not fetched in the previous select statements.
    Create Another structure with fields OBJNR, PSPNR, POSNR for table T_OUTPUT2 to store the data from tables, PRPS and IMZO.
    Use JOINS and FOR ALL ENTRIES to fetch the desired data.
    The sample code is as follows:
    ===
    TYPES: BEGIN OF ty_output1,
      objnr       TYPE coss-objnr,
      gjahr       TYPE coss-gjahr,
      kstar       type coss-kstar,
      projn       type afvc-projn,
    END OF ty_output1,
    BEGIN OF ty_output2,
      objnr       TYPE coss-objnr,
      pspnr       type prps-pspnr,
      posnr       type imzo-posnr,
    END OF ty_output2,
    BEGIN OF ty_output3,
      objnr       TYPE coss-objnr,
      gjahr       TYPE coss-gjahr,
      kstar       type coss-kstar,
      projn       type afvc-projn,
      pspnr       type prps-pspnr,
      posnr       type imzo-posnr,
    END OF ty_output3.
    data: year TYPE coss-gjahr value '2007'.
    DATA:
           wa_output1 TYPE ty_output1,   
           wa_output2 TYPE ty_output2,
           wa_output3 TYPE ty_output3,
           t_output1  TYPE STANDARD TABLE OF ty_output1 ,
           t_output2 TYPE STANDARD TABLE OF ty_output2 ,
           t_output3 TYPE STANDARD TABLE OF ty_output3..
    SELECT cobjnr cgjahr ckstar aprojn FROM coss as c
         INNER JOIN afvc as A on aobjnr = cobjnr
      INTO table t_output1
      WHERE ( c~objnr like 'NV%'   or
              c~objnr like 'PR%' ) and
            c~gjahr = year.
    SELECT pobjnr ppspnr i~posnr FROM prps as P
         INNER JOIN imzo AS I on pobjnr = iobjnr
         INTO TABLE t_output2
         for all entries in table T_OUTPUT1
         WHERE      p~objnr = t_output1-objnr.
    SORT : t_output1 BY objnr,
                t_output2 BY objnr.
    DELETE ADJACENT DUPLICATES FROM : t_output1 COMPARING objnr,
                                                                     t_output2 COMPARING objnr.
    LOOP AT t_output1 INTO wa_output1
    READ TABLE t_output2 INTO wa_output2 WITH KEY objnr - wa_output1-objnr BINARY SEARCH.
    if sy-subrc = 0.
      MOVE <wa_output1 fiels> and <wa_output2 fields> to WA_OUTPUT3.
      append wa_output3 to T_OUTPUT3.
    endif.
    ENDLOOP.
    Hope this will solve your problem.
    Regards,
    Sai Prasad

  • Select statement spliting

    Hi Gurus,
        How can i split this select statement..can you please tell me .its veru urgent.
    SELECT MARA~MATNR
             MAKT~MAKTX
             MARA~MEINS
             MCHA~WERKS
             MCH1~CHARG
             MCH1~LICHA
             MCH1~VFDAT
             MCH1~ERSDA
             MCH1~LWEDT
             MCH1~HSDAT
        INTO TABLE TB_BATCH
        FROM MCH1 INNER JOIN MCHA ON
        MCHAMATNR = MCH1MATNR AND
        MCHACHARG = MCH1CHARG
        INNER JOIN MARA ON
        MARAMATNR = MCH1MATNR
        INNER JOIN MAKT ON
        MAKTMATNR = MCH1MATNR
        WHERE MCH1~MATNR IN S_MATNR AND
              MCHA~WERKS = P_WERKS AND
              MARA~MTART IN R_MTART AND
              MAKT~SPRAS = SY-LANGU.

    take three different internal tables and one final internal table which will contains fields of the three fields.
    write select statements to fetch the data from each internal tables using for entries statement for 2nd and 3rd table and move all the corresponding values to the final table.
    loop at final table and display that.

  • SELECT statement INTO TABLE - what determines order of entries in in.table?

    Hello everyone.
    I habe a question: A select statement selects multiple entries from a data base table that are put into an internal table.
    The question : What determines the order of the entries in the internal table? 
    And what might change the order all of a suddden in that internal table?
    Could reorg. activities/archiving (even ongoing) cause any different result in the order as before ?
    I do not mean different entries but I rather refer to the sorting of the internal table, if it is not explicitly stated in the select or in parts of the coding.
    Any explaination is appreciated!
    Thanks!
    CN.

    Hi,
    Its not the order in which you specify the fields in the where clause that affects the sequence of the selection.
    What I said is that by default the entries are sorted by the primary key of the table.
    I did a bit of a test out of curiosity and after seeing so many different replies on the thread. I was surprised to see the results of the different scenarios.
    REPORT  Z_TEST_SELECTION                        .
    tables vbap.
    data it_vbap type table of vbap.
    data it_vbak type table of vbak.
    select-options s_vbeln for vbap-vbeln.
    select-options s_posnr for vbap-posnr.
    "======================================================================
    "s_vbeln has following entries
    " 5
    " 6
    " 1
    " 2
    "s_posnr has following entries.
    " 10
    " Sorts in ascending order by VBELN and POSNR by default
    select * up to 20 rows from vbap into table it_vbap.
    refresh it_vbap.
    "Below two cases are absolutely unreliable and I would suggest that a
    "sort should be mentioned after these statements. So when we use select
    "options specify values with the in clause, the sort is not reliable.
    "Strangely , neither the sequence is not determined by the order in
    "which the data was entered in the select option nor in the sequence of
    "the primary key. And this is still a mystery to me about the order in which
    "the entries are selected.
    " Any answeres anyone ?
    "1.
    select * from vbap into table it_vbap
    where  vbeln in ('0000000002','0000000006','0000000005','0000000001')
    and posnr in s_posnr.
    * Resulted in
    *900  |0000000001|000010|
    *900  |0000000005|000010|
    *900  |0000000006|000010|
    *900  |0000000002|000010|
    "=========================================================
    "2.
    select * from vbap into table it_vbap
    where  posnr in s_posnr
    and    vbeln in s_vbeln.
    * Resulted in
    *900  |0000000002|000010|
    *900  |0000000001|000010|
    *900  |0000000005|000010|
    *900  |0000000006|000010|
    refresh it_vbap.
    "Here the orders were selected in Decending order of Sales order, however
    "the posnr is not mentioned in the order by clause, hence posnr was
    "still in ascending order.
    select * from vbap into table it_vbap
    where posnr in s_posnr and vbeln in s_vbeln
    order by vbeln descending.
    write : 'done!'.
    refresh it_vbap.
    "Here the orders were selected in Descending order of Sales order.
    select * from vbak into table it_vbak where vbeln in s_vbeln
    order by vbeln descending.
    " The entries were selected in the ascending order of the key VBELN and
    " POSNR, so it seems that for all entries does not affect the selection of records.
    select * from vbap into table it_vbap
    for all entries in it_vbak
    where vbeln = it_vbak-vbeln
    and   posnr in s_posnr.
    Of course if you change the order of the primary key (in the transparent table, not in the where clause), the entries will be sorted as per the changed key.
    But we seldom change the the sequence of the primary key. In most cases we normally add a new field and make it a key field in addition to the existing key fields.
    I hope this helps you.
    There might be many more cases and examples than given above, which you can try and reply on this post. Lets see what we come up with.
    regards,
    Advait

  • How do I validate one field's length based on another field's selection?

    I am creating a form for our offices where I need to check one field for length of a serial number based on the answer to a previous field's selection.  Depending on the product selection, the serial number has two different lengths.  Both fields are marked as required, but I want to make sure that we receive the full serial number for our product.  Previous forms were done on paper and instructions were for the last 4 digits only which now we want the full serial number.  One product has a 12 digit number and the other is 6.
    I'm guessing that I need a validation script in the serial number field, but I am not a JavaScript coder and haven't found the right thing when searching.  Any help would be great!
    Thanks!

    Never trust your users to follow what you expect them to do... That often leads to mistakes and problems later on.
    I would reset the s/n field when a selection is made in the drop-down. To do so set the drop-down field to commit the selected value immediately and add code as its custom validation script:
    this.getField("Serial Number").value = "";
    To validate the s/n field you can use something like this as that field's custom validation script (of course, you'll need to adjust the field names and values to match the actual ones in your file):
    event.rc = true;
    if (event.value) {
         var selection = this.getField("Dropdown1").valueAsString;
         if (selection=="1" && event.value.length!=6) {
              app.alert("Error! The s/n must be 6 digits long.");
              event.rc = false;
         if (selection=="2" && event.value.length!=12) {
              app.alert("Error! The s/n must be 12 digits long.");
              event.rc = false;

Maybe you are looking for

  • How do you make a custom button that is Invisible When not selected

    Im just recently switching over to using a mac for authoring. I really like all the features in DVD Studio more than what i was using on a PC for the past 6 years. Which was ulead DVD Workshop 2. The only problem im having (For Now) is that i cant ma

  • Invalid number of extended attributes during Verify Disk.

    I keep getting invalid number of extended attributes when I run Verify Disk.  I run Repair Disk from the Recovery HD, it appears to fix the problem, and then when I restart, I get the same error again.  It is causing some apps not to open.  It seems

  • Acuqisition de données sous LABVIEW

    Salut!!! je suis en train de réalsier projet qui concerne l'acquisiton de données entre PC(LABVIEW) et une carte qui contien un PIC16f877 et cela via le port RS232. J'ai terminé tous les taches necessaires pour assurrer la comminication ;mais j'ai re

  • Can anyone recomend the SD Configuration Package from ...

    http://www.sap-topjobs.com/SpecialPP/sapsd20071919.html Are the powerpoint presentations and documents worth the cost (400 Us Dlls)? Has anyone seen the Pwp presentations from this package? I need to provide an introduction to JDE Consultants ( Organ

  • IPhone 5 won't synch Contacts with Yahoo Mail

    I have Yahoo Mail and an iPhone 5s with iOS 7.0.4. I cannot get Contacts to flow from one to the other. In SETTINGS I have both iCloud & Yahoo! as Accounts. I disabled CONTACTS in iCloud. For the Yahoo Account I have Mail, Contact6s, Calendars, Remin