Select single problem...

hi all,
i have to take first value of table BSIS according to condition. i m using select single statement in table BSIS, but problem is that i m getting the value only in header by which i m not able to apply loop at itab. can anyone please help me?
code.
SELECT single bukrs hkont gjahr monat shkzg prctr FROM bsis INTO itab
                                WHERE hkont IN hkont
                                AND   bukrs IN bukrs
                                AND   prctr IN prctr
                                AND   gjahr IN gjahr
                                AND   monat IN monat.
here sy-subrc is 0. but value is only in header.
regards saurabh.

Hi Saurabh,
i don't know what your program does but if you process the data you retrieve from table bsis more than once, it may be useful to create your internal table identical to table bsis;
data: itab like bsis occurs 0 with header line.
then get all the data from table bsis to your internal table at once.
  select * from bsis
    into table itab.
then process itab with your selection criteria as you wish.
avoid using the statement ...into corresponding fields of table (i assume you already are not using this)
well i don't know what else you can do..
regards;
Murat Kaya

Similar Messages

  • Problem while using select single

    Hii,
    I am using a select single command, My code is
    Select single * from zbe_gpfd_comment into wa_gpfd_comment where program_name = program
                                              and  box_type = box_type
                                              and     box_name = box_name.
    even though the required data is in the database still nothing is retrived in wa_gpfd_comment.No problem with datatype, I have checked them all..but still I am not able to get where the problem is?
    PS : program_name,box_type,box_name are primary key of the table zbe_gpfd_comment.

    Hi Priya,
    Did u checked what values are u passing in where condition for program , box_type , box_name .
    are there any values in the above the fields ,
    or just try to check once by hardcoding the values of the above 3 like 
    Select single * from zbe_gpfd_comment into wa_gpfd_comment where program_name = 'ZABC'
    and box_type = 'CUBE'
    and box_name = 'NOKIA'.
    give the 3 values which are existing in your zbe_gpfd_comment table .
    if it works then nothing wrong with select query ,
    and check the values in debugging whether the values are coming in :  program , box_type , box_name .
    I guess in ur query all the values are null or space , so it is not retriving values.
    check subrc also for the query.
    Regards,
    Aby

  • Problem with SELECT SINGLE

    hi
    can you find any error in this
    select single * from makt where matnr = p_matnr and spras = 'sv'.

    Hi,
    Use like this.
    data: BEGIN OF it_makt OCCURS 0,
    matnr LIKE maKT-matnr,
    maktx LIKE makt-maktx,
    END OF it_makt.
    data: process_tab_struct_tmp like IT_MAKT.
    field-symbols: <fs1>.
    after downloading file(excel) to excel_tab....code follows
    LOOP AT EXCEL_TAB.
    assign component excel_tab-col of structure
    process_tab_struct_tmp to <fs1>.
    <fs1> = excel_tab-value.
    at end of row.
    move-corresponding: process_tab_struct_tmp to IT_MAKT.
    CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
    EXPORTING
    INPUT = <b>it_makt-matnr</b>
    IMPORTING
    OUTPUT = <b>it_makt-matnr</b>.
    append IT_MAKT.
    endat.
    ENDLOOP.
    Do reward points to useful answers.
    Regards,
    Atish

  • Problem in select single statement : its urgent

    Dear ,
    i written one select single stmt i.e
    tables : ser03 .
        SELECT SINGLE  * FROM  ser03
               WHERE  obknr  = objk-obknr
               AND    bwart  = '101'
               AND    shkzg  = 'S'.
    based on this select stmt their are 5 records in database table satisfying the select stmt where clause  and this select stmt is picking the  fourth record . why this record is picking forth record only even this 4th record is not most recently created record and nor old record this record is middle one if any one plz tell me . points must be given . to access most recently recreated record how to write select stmt. plz tell me .

    Hi,
    hope this code will help you.
    just added the mandt in the where condition.
    SELECT SINGLE * FROM ser03
    WHERE mandt = sy-mandt
    AND obknr = objk-obknr
    AND bwart = '101'
    AND shkzg = 'S'.
    reward if helpful,
    teja.

  • Problem in SELECT SINGLE Query

    Hi,
    I am writing a small quesry in PS, Though the entry exist in database table PRPS, The sy-subrc is 4 for this query.Can u help me.
    data : wa_src_prps like prps-posid.
    start-of-selection.
    wa_src_prps  = '3-3310-02-01-01-10-20'.
        DATA: lv_pbukr LIKE prps-pbukr.
        CLEAR: lv_pbukr.
        SELECT SINGLE pbukr INTO lv_pbukr
                             FROM prps
                             WHERE posid EQ wa_src_prps.
    if sy-subrc = 0.
    write:/5 wa_src_prps, lv_pbukr.
    endif.

    hi,
    DATA : wa_src_prps LIKE prps-posid.
    START-OF-SELECTION.
      wa_src_prps = '0-1000-0'.
    " Conversion Routine for domain PS_POSID
      CALL FUNCTION 'CONVERSION_EXIT_ABPSN_INPUT'
        EXPORTING
          input  = wa_src_prps
        IMPORTING
          output = wa_src_prps.
      DATA: lv_pbukr LIKE prps-pbukr.
      CLEAR: lv_pbukr.
      SELECT SINGLE pbukr INTO lv_pbukr
      FROM prps
      WHERE posid EQ wa_src_prps.
      IF sy-subrc = 0.
        WRITE:/5 wa_src_prps, lv_pbukr.
      ENDIF.

  • Problem in using Select Single

    Hi Experts,
    This is Prabhakar
    The following requirement is giving littlebit trouble to me. Here I don't know how to use Select single for selecting maktx field from MAKT table and how to link it to MARC and MBEW tables. How i will write code using without headerline.
    <b>Requirement is :</b>
    What this is asking is to create a report that contains the following fields in both the Selection Screen and in the report output:
    •     Material Number  -  MARC-MATNR
    •     Material Description  -  *
    •     Warehouse Cycle Count Indicator  -  MARC-ABCIN
    •     Standard Cost  -   MBEW-STPRS**
    •     Profit Center  -  MARC-PRCTR
    Use the following code to get Material Description (RESULT is the material that results from selecting from MARC):
    FORM GET_MATERIAL_DESCRIPTION.
      CLEAR MAKT.
      SELECT SINGLE MAKTX INTO MAKT-MAKTX FROM MAKT
                          WHERE MATNR = RESULT-MATNR
                          AND   SPRAS = SY-LANGU.
    ENDFORM.                               " GET_MATERIAL_DESCRIPTION
    For now, select standard price with the following criteria:
          SELECT SINGLE STPRS
                 FROM MBEW
                WHERE MATNR = RESULT-MATNR
                AND   BWTAR = SPACE.
    There is another field in the key to MBEW – it is BWKEY, and it is related to plant.
    So, first select from MARC, and with the results of MARC, select from MBEW

    Hi,
    It is advisable that dont include Material Description(MAKTX_ and Cost(STPRS), as, if you miss a single letter in material description in the selection screen you will not get your required data, Cost is also same like that so many materials will having same cost and validating will become difficult. If you include these two unnessesarily you are increasing your program complexity. See the code below which satisfy your requirement with good performance.
    Hope This Info Helps YOU.
    <i>Reward Points If It Helps YOU.</i>
    Regards,
    Raghav
    TABLES : mara,marc,mbew,makt.
    DATA : BEGIN OF itab OCCURS 0,
           matnr LIKE  marc-matnr,
           prctr LIKE  marc-prctr ,
           abcin LIKE  marc-abcin,
           maktx LIKE  makt-maktx,
           stprs LIKE  mbew-stprs,
           END OF itab.
    DATA : BEGIN OF itab1 OCCURS 0,
           matnr LIKE marc-matnr,
           stprs LIKE mbew-stprs ,
           END OF itab1.
    DATA : BEGIN OF itab2 OCCURS 0,
           matnr LIKE mara-matnr,
           maktx LIKE makt-maktx,
           END OF itab2.
    *Selection Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1.
    SELECT-OPTIONS : s_matnr FOR marc-matnr,
                     s_prctr FOR marc-prctr,
                     s_abcin FOR marc-abcin.
    SELECTION-SCREEN END OF BLOCK b1.
    *Validations of the selection-screen
    AT SELECTION-SCREEN.
    PERFORM selection_screen_validation.
    START-OF-SELECTION.
      SELECT matnr
             prctr
             abcin
             INTO TABLE itab
             FROM marc
             WHERE matnr IN s_matnr
             AND abcin IN s_abcin
             AND prctr IN s_prctr.
    if not itab[] is initial.
      SELECT matnr
             maktx
             INTO TABLE itab2
             FROM makt
             for all entries in itab
             WHERE matnr = itab-matnr
             AND spras = sy-langu.
    endif.
    if not itab[] is initial.
      SELECT matnr
             stprs
             INTO TABLE itab1
             FROM mbew
             for all entries in  itab
             WHERE matnr = itab-matnr.
    endif.
    sort itab by matnr.
    sort itab1 by matnr.
    sort itab2 by matnr.
    clear : itab, itab1, itab2.
      LOOP AT itab.
        READ TABLE itab2 WITH KEY matnr = itab-matnr BINARY SEARCH .
        if sy-subrc eq 0.
          itab-maktx = itab2-maktx.
        endif.
        READ TABLE itab1 WITH KEY matnr = itab-matnr BINARY SEARCH .
        if sy-subrc eq 0.
          itab-stprs = itab1-stprs.
        endif.
        MODIFY itab.
        clear: itab, itab1, itab2.
      ENDLOOP.
    END-OF-SELECTION.
      LOOP AT itab.
        WRITE : /  itab-matnr,
                   itab-maktx,
                   itab-abcin,
                   itab-stprs,
                   itab-prctr.
      ENDLOOP.
    *&      Form  selection_screen_validation
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form selection_screen_validation .
    data : v_matnr type mara-matnr,
           v_prctr type cepc-prctr,
           v_abcin type t159c-abcin.
    ** validations for material number
    if not s_matnr[] is initial.
       select matnr from mara
                    into v_matnr
                    up to 1 rows
                    where matnr in s_matnr.
       endselect.
       if sy-subrc = 0.
          message e001 with ' Material '.
       endif.
    endif.
    ** validations for Profit Center
    if not s_prctr[] is initial.
       select prctr from cepc
                    into v_prctr
                    up to 1 rows
                    where prctr in s_prctr.
       endselect.
       if sy-subrc = 0.
          message e001 with ' Profit Center '.
       endif.
    endif.
    ** validations for Cycle Count Indicator
    if not s_abcin is initial.
       select abcin from t159c
                    into v_abcin
                    up to 1 rows
                    where abcin in s_abcin.
       endselect.
       if sy-subrc = 0.
          message e001 with ' Count Indicator '.
       endif.
    endif.
    endform.                    " selection_screen_validation

  • Diff b/w select single * .... and select....up to 1 row

    Hi Abapers,
    What is the diff b/w Select single * from.... and select * ...up to 1 row.
    Thanks in advance.
    Subbu.

    Select SINGLE...
    SINGLE
    The result of the selection should be a single entry. If it is not possible to identify a unique entry, the system uses the first line of the selection. If you use the FOR UPDATE addition, the selected entry is protected against parallel updates from other transactions until the next database commit (see LUW and database lock mechanism). If the database system identifies a deadlock, a runtime error occurs.
    ... UP TO n ROWS
    Effect
    The set of results is restricted to a maximum of nrows.
    Example
    To output a list of the 3 business customers with the greatest discount:
    DATA WA_SCUSTOM TYPE SCUSTOM.
    SELECT * FROM SCUSTOM INTO WA_SCUSTOM UP TO 3 ROWS
             WHERE CUSTTYPE = 'B'
             ORDER BY DISCOUNT DESCENDING.
      WRITE: / WA_SCUSTOM-ID, WA_SCUSTOM-NAME, WA_SCUSTOM-DISCOUNT.
    ENDSELECT.
    Notes
    If you use an UP TO n ROWS addition in an ORDER-BY clause , the lines read are sorted into the correct order. The first n lines are then displayed. The system may need to read more than n lines from the database to be able to do this.
    If n = 0, all selected lines are displayed.
    n < 0 results in a runtime error.
    <b>Knowing when to use SELECT SINGLE or SELECT ... UP TO 1 ROWS</b>
    A lot of people use the SELECT SINGLE statement to check for the existence of a value in a database. Other people prefer to use the 'UP TO 1 ROWS' variant of the SELECT statement.
    <b>So what's the difference between using 'SELECT SINGLE' statement as against a 'SELECT .... UP TO 1 ROWS' statement ?</b>
    If you're considering the statements
    SELECT SINGLE field INTO w_field FROM table.
    and
    SELECT field INTO w_field FROM table UP TO 1 ROWS. ENDSELECT.
    then looking at the result, not much apart from the extra ENDSELECT statement. Look at the run time and memory usage and they may be worlds apart.
    Why is this ?? The answer is simple.
    The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.
    The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.
    Get the difference ??
    If not, here is a good example, credit for this example goes to Richard Harper, a friend of mine on sapfans.com :
    Create a Ztable called ZDifference with 2 fields in it, MANDT of type MANDT and POSNR of type POSNR. Make sure both of these are keys. Also create a table maintenance dialog for it (SE11->Utilities->Table Maintenance Generator). Fill the table with ten rows 000001-000010.
    Then run the program shown below:
    Report Z_Difference
           Message-id 38
           Line-Size  80
           Line-Count 0
           No Standard Page Heading.
    Start-Of-Selection.
      Data: w_Single type Posnr,
            t_Rows   type standard table of Posnr
                     initial size 0
                     with header line.
      Select single Posnr
        from zDifference
        into w_Single.
      Select Posnr
        into table t_Rows
        from zDifference
       up to 1 rows
       order by Posnr descending.
       Write :/ 'Select single:', w_Single.
       Skip 1.
       Write :/ 'Up to 1 rows :'.
       Loop at t_Rows.
            Write t_Rows.
       EndLoop.
    You should see the output:
    Select single: 000001
    Up to 1 rows : 000010
    The first 'SELECT' statement selected the first record in the database according to any selection criterion in the 'WHERE' clause. This is what a 'SELECT SINGLE' does. The second 'SELECT' has asked the database to reverse the order of the records before returning the first row of the result.
    In order to be able to do this the database has read the entire table, sort it and then return the first record. If there was no ORDER BY clause then the results would have been identical (ie both '000001') but the second select if given a big enough table to look at would be far slower.
    Note that this causes a problem in the Extended Program Check if the full key is not specified in a 'SELECT SINGLE'. Replacing the 'SELECT SINGLE' by an "UP TO 1 ROWS" will give the same exact results without any warning but the program will run slower and consume more memory. This is a good example of a warning that we should ignore... considering you are sure of what you are doing !!
    Message was edited by:
            Judith Jessie Selvi

  • 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

  • "select count(*)" and "select single *" returns different result

    Good day!
    product version SAP ECC 6.0
    oracle10
    data transfers from external oracle db into customer tables using direct oracle db link
    sometimes I get case with different results from 2 statements
    *mytable has 10 rows
    *1st statement
    data: cnt type I value 0.
    select count( * ) into cnt from mytable WHERE myfield_0 = 123 and myfield_1 = '123'.
    *cnt returns 10 - correct
    *2nd statement
    select single * from  mytable WHERE myfield_0 = 123 and myfield_1 = '123'.
    *sy-dbcnt returns 0
    *sy-subrc returns 4 - incorrect, 10 rows are "invisible"
    but
    1. se16 shows correct row number
    2. I update just one row from "invisible" rows using se16 and 2nd statement returns correct result after that
    can not understand why
    thank you in advance.

    Thank you, Vishal
    but,
    general problem is that
    1. both statements have the same WHERE conditions
    2. 1st return resultset with data (sy-dbcnt=10), 2nd return empty dataset, but must return 1 in sy-dbcnt
    Yes, different meaning, you are right, but must 2nd must return 1, because of "select single *" construction, not 0.
    Dataset to process is the same, WHERE conditions are equal...
    I think the problem is that how ABAP interperets select count(*) and "select single *".
    Maybe "select count (*)" scans only PK from index page(s)? and "select single *" scans data pages? and something is wrong with that?
    I'm new in SAP and didn't find any SAP tool to trace dump of data and indexes pages with Native SQL.
    se16 shows all records.
    And why after simple manual update of just one record using se16 "select single *" returns 1?
    I've just marked one row to update, didn't change any data, then pressed "save".

  • Select Single * is not fetching all Data

    Hi,
    I have a peculiar problem, when i am extending the customer to a new company code, we are getting Dump saying 'ASSERTION_FAILED'
    when i debugg i am geeting issue with following Code of a FM 'KNA1_SINGLE_READER'
    IF NOT i_bypassing_buffer IS INITIAL.
        *SELECT SINGLE * FROM kna1*
                        INTO o_kna1
                        WHERE kunnr = i_kunnr.
        IF sy-subrc <> 0.
          MESSAGE e300(vs) WITH 'KNA1' RAISING not_found.
        ENDIF.
    i am passing customer number (i_kunnr), this code is executed 2 times first time it is fetching all columns but second time it is only fetching customer number and no other information regarding customer. But in data base all information is present. Can any one help me in this.
    Thanks a lot...
    Reddy
    Edited by: JAGAN MOHAN REDDY on Jun 2, 2010 11:30 AM

    Hi Jagan,
    It'll be helpful to others if you can please post how and what was done to resolve the issue.
    Thanks!
    Sandeep

  • Selection Screen problem Urgent  ...

    Please find below  ; It doesn't care of selection screen .For example I want to take all material mtart is 'abc'  . How can I build that .For example there is one record instead of mtart (abc ) but when I enter bcd it also get something.
      SELECT  * FROM mbew
         WHERE matnr in s_matnr
         AND bwkey IN s_bwkey.
        ytab-matnr = mbew-matnr .
        ytab-kaln1 = mbew-kaln1 .
        SELECT SINGLE * FROM makt
        WHERE matnr = ytab-matnr.
        ytab-maktx = makt-maktx .
        SELECT SINGLE * FROM mara
                 WHERE matnr = ytab-matnr
              AND matkl IN s_matkl
                AND mtart IN s_mtart.
        ytab-matkl = mara-matkl .
        ytab-mtart = mara-mtart .
        SELECT SINGLE * FROM mvke
        WHERE matnr = ytab-matnr
        AND  kondm IN s_kondm .
        ytab-kondm = mvke-kondm .
        SELECT SINGLE * FROM ckmlcr
        WHERE kalnr = ytab-kaln1
        AND bdatj EQ s_bdatj
        AND curtp EQ s_curtp.
        ytab-kalnr = ckmlcr-kalnr .
        ytab-bdatj = ckmlcr-bdatj .
        ytab-curtp = ckmlcr-curtp .
        SELECT SINGLE * FROM vbrp
                  WHERE matnr = ytab-matnr.
        ytab-vbeln = vbrp-vbeln .
        ytab-fbuda = vbrp-fbuda .
        ytab-posnr = vbrp-posnr .
        ytab-fkimg = vbrp-fkimg .
        ytab-netwr = vbrp-netwr .
    APPEND ytab.
        CLEAR  ytab.
      ENDSELECT.
    Message was edited by:
            yusuf tunay çilesiz

    Hi,
    The code looks good..Explain your problem clearly..
    What ever you give in the selection screen is not getting filtered..??
    AFter this select check for sy-subrc..
    SELECT SINGLE * FROM mara
    WHERE matnr = ytab-matnr
    AND matkl IN s_matkl
    AND mtart IN s_mtart.
    IF SY-SUBRC <> 0.
    if you want to skip the record if there is no material found for the corresponding
    material, matkl and mtart...use CONTINUE..Which will process the next record in the MBEW select..
    CONTINUE.
    ENDIF.
    Thanks,
    Naren

  • CALL SELECTION SCREEN problem

    Hello!
    I have a problem. In my riport I have a selection screen (1000), a main screen (2000), and a screen (400) this is called inside a loop, to fill some datas when you hit the print button.
      CLEAR L_TOTAL.
      SORT LT_EBAN BY BNFPO.
      LOOP AT LT_EBAN.
        GT_ITEM2-FIELD01 = SY-TABIX.
        GT_ITEM2-FIELD02 = LT_EBAN-MATNR.
    *---Part name, Type, Maker
        SPLIT LT_EBAN-TXZ01 AT ',' INTO GT_ITEM2-FIELD03 GT_ITEM2-FIELD04 GT_ITEM2-FIELD05.
         CONCATENATE GT_ITEM2-FIELD03 '/' GT_ITEM2-FIELD04 INTO DESCR.
         ITEM = LT_EBAN-BNFPO.
         CALL SCREEN 400 STARTING AT 20 7 ENDING AT 60 18.
    *---Machine
        GT_ITEM2-FIELD06 = ST_400-MACHINE.
    After this, i could not use the LEAVE TO SCREEN 0, because it's not going back to secreen '2000' , I'm getting a blank 400 screen.
    Thatswhy I used CALL SCREEN '2000', and it's fine.
    But in the case of the Selection screen (1000) something is wrong.
    On the screen 2000 I using this logic.
    MODULE EXIT_2000 INPUT.
      CASE OK_CODE.
        WHEN 'BACK' OR 'EXIT'.
          CLEAR OK_CODE.
           CALL SELECTION-SCREEN '1000'.
           LEAVE PROGRAM.
        WHEN 'CANC'.
          PERFORM EXIT_PROGRAM.
          LEAVE PROGRAM.
      ENDCASE.
      CLEAR OK_CODE.
    ENDMODULE.                 " exit_2000  INPUT
    With this logic, the program is going to the SELECTION-SCREEN, when I hit the back button, and when we are already on the SELECTION-SCREEN, it's leaving the program. This is also ok.
    But when I hit the back button, and on the SELECTION-SCREEN I want to run the program again, it's not going to the program logic, it's jumping to this CALL SELECTION-SCREEN '1000', and leaving of course.
    START-OF-SELECTION.
      PERFORM DSP1_PROC.
      IF GT_DISPLAY[] IS INITIAL.
        MESSAGE S208(00) WITH 'No data.'.
        EXIT.
      ENDIF.
      IF S_RET = '1'.
        MESSAGE I208 WITH 'Document not found'.
        S_RET = ' '.
      ELSE.
        S_RET = ' '.
        CALL SCREEN '2000'.
      ENDIF.
    So my question is, that the above logic, when I running the program first time It's working good, at the START-OF-SELECTION, but when I trying to runnig from the SELECTION-SCREEN "second time", from the   START-OF-SELECTION it's jumping to the CALL SELECTION-SCREEN '1000'. How can I avoid this. I want that from the  START-OF-SELECTION, never go to the CALL SELECTION-SCREEN '1000'.
    Thank You
    Edited by: Roland on Dec 5, 2011 11:27 AM

    Hi Max!
    Yeah, I was thinking the same, that the problem is with that loop.
    But I don't know, how can I solved in a different way, because when we hit the print button, we getting all the items from a table, and we starting looping on them. In the loop we passing the values to a GT_ITEM table, later this table is connected with an excell, so it will be printed out in an excell form.
    So I have to call this screen so many times, how many items we have. Sometimes just 1, sometimes 4, 6, 9, and so on.
    For this items I have to add 2 more fields, wich are uploaded by the user. ( The other fields are coming from the table)
    So if I going out from the loop after the CALL SCREEN 400, I think the next item wont be get the values. Or maybe any of them, because this is before the APPEND GT_ITEM. So this methode wont be called, no data would be in the table, nothing will be printed.
    *-Item
      SELECT BNFPO MATNR TXZ01 MENGE MEINS ERNAM PREIS BEDNR EBELN EBELP
        INTO CORRESPONDING FIELDS OF TABLE LT_EBAN
        FROM EBAN
       WHERE BANFN  =  GT_DISPLAY-BANFN
         AND LOEKZ  =  ' '.
      CLEAR L_TOTAL.
      SORT LT_EBAN BY BNFPO.
      LOOP AT LT_EBAN.
        GT_ITEM2-FIELD01 = SY-TABIX.
        GT_ITEM2-FIELD02 = LT_EBAN-MATNR.
    *---Part name, Type, Maker
        SPLIT LT_EBAN-TXZ01 AT ',' INTO GT_ITEM2-FIELD03 GT_ITEM2-FIELD04 GT_ITEM2-FIELD05.
         CONCATENATE GT_ITEM2-FIELD03 '/' GT_ITEM2-FIELD04 INTO DESCR.
         ITEM = LT_EBAN-BNFPO.
         CALL SCREEN 400 STARTING AT 20 7 ENDING AT 60 18.
    *---Machine
        GT_ITEM2-FIELD06 = ST_400-MACHINE.
    *---Using Qty
        WRITE ST_400-USING UNIT LT_EBAN-MEINS TO GT_ITEM2-FIELD08.
    *---Now Stock
        CLEAR L_LABST.
        SELECT SUM( LABST ) INTO L_LABST
          FROM ZMM0460T
         WHERE MATNR = LT_EBAN-MATNR
           AND WERKS = '3A10'.
        WRITE L_LABST UNIT LT_EBAN-MEINS TO GT_ITEM2-FIELD09.
        WRITE LT_EBAN-MENGE UNIT LT_EBAN-MEINS TO GT_ITEM2-FIELD10.
        IF NOT LT_EBAN-EBELN IS INITIAL.
          CLEAR LS_EKPO.
          SELECT SINGLE NETPR WAERS PEINH
            INTO CORRESPONDING FIELDS OF LS_EKPO
            FROM EKPO AS A INNER JOIN EKKO AS B ON A~EBELN EQ B~EBELN
           WHERE A~EBELN = LT_EBAN-EBELN
             AND A~EBELP = LT_EBAN-EBELP.
          IF LS_EKPO-WAERS <> 'HUF'.
            CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
              EXPORTING
                DATE             = SY-DATUM
                FOREIGN_AMOUNT   = LS_EKPO-NETPR
                FOREIGN_CURRENCY = LS_EKPO-WAERS
                LOCAL_CURRENCY   = 'HUF'
              IMPORTING
                LOCAL_AMOUNT     = LS_EKPO-NETPR.
          ENDIF.
          IF LS_EKPO-PEINH IS INITIAL. LS_EKPO-PEINH = 1. ENDIF.
          LT_EBAN-PREIS = LS_EKPO-NETPR / LS_EKPO-PEINH.
        ENDIF.
        WRITE LT_EBAN-PREIS CURRENCY 'HUF' TO GT_ITEM2-FIELD11.
        CONDENSE GT_ITEM2-FIELD11.
        CONCATENATE GT_ITEM2-FIELD11 'Ft' INTO GT_ITEM2-FIELD11
          SEPARATED BY SPACE.
        L_NETWR = LT_EBAN-MENGE * LT_EBAN-PREIS.
        WRITE L_NETWR CURRENCY 'HUF' TO GT_ITEM2-FIELD12.
        CONDENSE GT_ITEM2-FIELD12.
        CONCATENATE GT_ITEM2-FIELD12 'Ft' INTO GT_ITEM2-FIELD12
          SEPARATED BY SPACE.
        L_TOTAL = L_TOTAL + L_NETWR.
    *---Unit
        SELECT SINGLE UNIT INTO GT_ITEM2-FIELD13
          FROM ZMM0500T
         WHERE PERNR = LT_EBAN-BEDNR.
    *---Name
        SELECT SINGLE SNAME INTO GT_ITEM2-FIELD14
          FROM PA0001
         WHERE PERNR = LT_EBAN-BEDNR
           AND ENDDA = '99991231'.
    *---Append
        GT_ITEM2-CNTR01 = ''.
        APPEND GT_ITEM2. CLEAR: GT_ITEM2, ST_400, DESCR, ITEM.
      ENDLOOP.
      GT_ITEM2-FIELD11 = 'Total'.
      WRITE L_TOTAL CURRENCY 'HUF' TO GT_ITEM2-FIELD12.
      CONDENSE GT_ITEM2-FIELD12.
      CONCATENATE GT_ITEM2-FIELD12 'Ft' INTO GT_ITEM2-FIELD12
        SEPARATED BY SPACE.
      GT_ITEM2-CNTR01 = 'B'.
      APPEND GT_ITEM2. CLEAR GT_ITEM2.
    ANy idea?
    Thank You
    Edited by: Roland on Dec 5, 2011 1:36 PM
    Edited by: Roland on Dec 5, 2011 1:50 PM

  • Code tuning on SELECT SINGLE statement

    Hi,
    Is there a way to optimize a SINGLE SELECT statement ?
    SELECT SINGLE pernr bukrs FROM pa0001
                INTO (it_pernr-pernr,it_pernr-bukrs)
               WHERE pernr = lv_pa9070-pernr
                 AND endda GE lv_yhr_py_pdidom-begda
                 AND begda LE lv_yhr_py_pdidom-endda.
          APPEND it_pernr.
    Thanks in advance for your help.
    Thibault

    What do you mean by optimize? Runtime?
    If the statement is inside a huge loop, there could be room for improvement.
    Please describe the actual problem in detail.
    Also look into the ABAP performance forum and Please Read before Posting in the Performance and Tuning Forum.
    Thomas

  • Select  single  n   select upto

    frends please provide me the detail document and scenarios where we use with examples about select single and select upto n rows ?

    Hi,
    A lot of people use the SELECT SINGLE statement to check for the existence of a value in a database. Other people prefer to use the 'UP TO 1 ROWS' variant of the SELECT statement.
    So what's the difference between using 'SELECT SINGLE' statement as against a 'SELECT .... UP TO 1 ROWS' statement ?
    If you're considering the statements
    SELECT SINGLE field INTO w_field FROM table.
    and
    SELECT field INTO w_field FROM table UP TO 1 ROWS. ENDSELECT.
    then looking at the result, not much apart from the extra ENDSELECT statement. Look at the run time and memory usage and they may be worlds apart.
    Why is this ?? The answer is simple.
    The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.
    The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.
    Get the difference ??
    If not, here is a good example, credit for this example goes to Richard Harper, a friend of mine on sapfans.com :
    Create a Ztable called ZDifference with 2 fields in it, MANDT of type MANDT and POSNR of type POSNR. Make sure both of these are keys. Also create a table maintenance dialog for it (SE11->Utilities->Table Maintenance Generator). Fill the table with ten rows 000001-000010.
    Then run the program shown below:
    Report Z_Difference
           Message-id 38
           Line-Size  80
           Line-Count 0
           No Standard Page Heading.
    Start-Of-Selection.
      Data: w_Single type Posnr,
            t_Rows   type standard table of Posnr
                     initial size 0
                     with header line.
      Select single Posnr
        from zDifference
        into w_Single.
      Select Posnr
        into table t_Rows
        from zDifference
       up to 1 rows
       order by Posnr descending.
       Write :/ 'Select single:', w_Single.
       Skip 1.
       Write :/ 'Up to 1 rows :'.
       Loop at t_Rows.
            Write t_Rows.
       EndLoop.
    You should see the output:
    Select single: 000001
    Up to 1 rows : 000010
    The first 'SELECT' statement selected the first record in the database according to any selection criterion in the 'WHERE' clause. This is what a 'SELECT SINGLE' does. The second 'SELECT' has asked the database to reverse the order of the records before returning the first row of the result.
    In order to be able to do this the database has read the entire table, sort it and then return the first record. If there was no ORDER BY clause then the results would have been identical (ie both '000001') but the second select if given a big enough table to look at would be far slower.
    Note that this causes a problem in the Extended Program Check if the full key is not specified in a 'SELECT SINGLE'. Replacing the 'SELECT SINGLE' by an "UP TO 1 ROWS" will give the same exact results without any warning but the program will run slower and consume more memory. This is a good example of a warning that we should ignore... considering you are sure of what you are doing !!
    Regards,
    Ferry Lianto

  • Diff between select single and select upto 1 rows.

    Hello aLL,
    PL tell what is technical diff between select single and select upto 1 rows and how it is affecting the performance.
    Rushikesh

    Hi
    Knowing when to use SELECT SINGLE or SELECT ... UP TO 1 ROWS
    A lot of people use the SELECT SINGLE statement to check for the existence of a value in a database. Other people prefer to use the 'UP TO 1 ROWS' variant of the SELECT statement.
    So what's the difference between using 'SELECT SINGLE' statement as against a 'SELECT .... UP TO 1 ROWS' statement ?
    If you're considering the statements
    SELECT SINGLE field INTO w_field FROM table.
    and
    SELECT field INTO w_field FROM table UP TO 1 ROWS. ENDSELECT.
    then looking at the result, not much apart from the extra ENDSELECT statement. Look at the run time and memory usage and they may be worlds apart.
    Why is this ?? The answer is simple.
    The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.
    The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.
    Get the difference ??
    If not, here is a good example, credit for this example goes to Richard Harper, a friend of mine on sapfans.com :
    Create a Ztable called ZDifference with 2 fields in it, MANDT of type MANDT and POSNR of type POSNR. Make sure both of these are keys. Also create a table maintenance dialog for it (SE11->Utilities->Table Maintenance Generator). Fill the table with ten rows 000001-000010.
    Then run the program shown below:
    Code:
    Program: Z_Difference
    Purpose: A program that demonstrates the difference
    between SELECT SINGLE and SELECT UP TO n ROWS.
    This program requires the data table Z_DIFFERENCE
    to have been created according to the structure
    outlined in the text above and populated with
    at least 10 records.
    Creation Date: 21/04/2004
    Requested By:
    Reference Doc:
    Author: R Harper
    Modification History:
    Date Reason Transport Who
    Report Z_Difference
    Message-id 38
    Line-Size 80
    Line-Count 0
    No Standard Page Heading.
    Start-Of-Selection.
    Data: w_Single type Posnr,
    t_Rows type standard table of Posnr
    initial size 0
    with header line.
    Select single Posnr
    from zDifference
    into w_Single.
    Select Posnr
    into table t_Rows
    from zDifference
    up to 1 rows
    order by Posnr descending.
    Write :/ 'Select single:', w_Single.
    Skip 1.
    Write :/ 'Up to 1 rows :'.
    Loop at t_Rows.
    Write t_Rows.
    EndLoop.
    You should see the output:
    Select single: 000001
    Up to 1 rows : 000010
    The first 'SELECT' statement selected the first record in the database according to any selection criterion in the 'WHERE' clause. This is what a 'SELECT SINGLE' does. The second 'SELECT' has asked the database to reverse the order of the records before returning the first row of the result.
    In order to be able to do this the database has read the entire table, sort it and then return the first record. If there was no ORDER BY clause then the results would have been identical (ie both '000001') but the second select if given a big enough table to look at would be far slower.
    Note that this causes a problem in the Extended Program Check if the full key is not specified in a 'SELECT SINGLE'. Replacing the 'SELECT SINGLE' by an "UP TO 1 ROWS" will give the same exact results without any warning but the program will run slower and consume more memory. This is a good example of a warning that we should ignore... considering you are sure of what you are doing !!

Maybe you are looking for

  • SQL Dataset errors in BIP 11G Trial Edition

    Hi I'm trialling 11G and trying to get a SQL dataset to work which is used in our 10.1.3.4.2 installation. The SQL queries a package which calls an inline function to return results based on Parameter values. This works without error both in the 10G

  • CS4 & CS5 will not edit Home Page. All other pages edit fine.

    Called tech support and they said to make this duplicate post, so I will.   I am using CS4 Trial in XP 32 bit, and CS5 Trial in Vista 64-bit.  Neither version will edit my home page.  All other pages edit fine. http://www.audiofilesolutions.com. I ha

  • Br Crash

    I'm haveing trouble with my Adobe Br crashing I start to access the photographs and as soon as scroll through a box appears and says Click Here and then just beeps when I click here? Any Ideas would be helpful.

  • OHW in ADF ( Exception - 'helpProvider' returned null )

    Hi, I am new to OHW, tried using it in ADF and got stuck with below exception. Kindly suggest to resolve. i added following to adf-config.xml ( adf/META-INF/adf-config.xml ) <help-provider> <help-provider-class> oracle.help.web.rich.helpProvider.OHWH

  • CS3/CS4 Critical Security Update

    This crossed my desk this morning and thought it would be of interest here: http://www.creativepro.com/article/illustrator-cs3-and-cs4-users-protect-yourself Link to Adobe cited at the end of article. I make no claims as to authenticity or it being a