How to select a single entry with latest date just LE system date?

Hi all,
Suppose there are 5 entries with first day (ertag) in table prow:
01.05.2005
01.06.2005
01.07.2005
01.08.2005
01.09.2005
Suppose system date (sy-datum) is 25.07.2005, I want a SQL that should select the third entry (01.07.2005).
FYI:
This SQL only selects the first entry:
Select single * from PROW into corresponding fields of ITAB where ERTAG LE SY-DATUM.
Could anyone help ? Thx.

another option.
data: first_day type sy-datum ,
      periv type T009B-PERIV ,
      poper type T009B-Poper ,
      year type T009B-BDATJ .
data: iprow type standard table of prow .
move: 'K4' to periv ,
      sy-datum+4(2) to poper ,
      sy-datum+0(4) to year .
CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'
  EXPORTING
    i_gjahr              = year
*    I_MONMIT             = 00
    i_periv              = periv
    i_poper              = poper
IMPORTING
   E_DATE               = first_day
EXCEPTIONS
   INPUT_FALSE          = 1
   T009_NOTFOUND        = 2
   T009B_NOTFOUND       = 3
   OTHERS               = 4
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
select * from prow into table iprow where ertag between first_day and sy-datum .
Regards
Raja

Similar Messages

  • How to restore a single Photo with time machine in Aperture 3 / iphoto?

    How to restore a single Photo with time machine in Aperture 3 / iphoto?

    Its been awhile since I used iPhoto, but I have done it.
    If I recall correctly this is how.
    In iPhoto open event that you need to restore the photo to ( the event that originally contained it )
    Then open TM it should show that same event and then go back in time until you find the missing shot
    Highlight the one you need to restore and tell TM to restore it.
    Good luck

  • How to maintaing E-Business suite with latest product levels and bug/securi

    Hi All,
    How to maintaing E-Business suite with latest product levels and bug/security fixes?
    backup strataegies for database and E-BS suite?
    what is mean by gather user requirements?
    Please some one explain briefly...........
    Thanks

    Please post your question in the appropriate forum.
    E-Business Suite
    http://forums.oracle.com/forums/category.jspa?categoryID=3
    Thanks,
    Hussein

  • HT1386 My system got crashed and I dont have backup fo my iphone.... now how do i synch my iphone with new itunes without loosing my data ?

    My system got crashed and I dont have backup fo my iphone.... now how do i synch my iphone with new itunes without loosing my data ?

    See if this user-tip for syncing to a new computer helps : https://discussions.apple.com/docs/DOC-3141
    If you have music from other sources on your phone (e.g. copied from CDs) and you don't have them on a backup, then there are some program listed half-way down this page which might be able to copy them back : https://discussions.apple.com/docs/DOC-3991

  • How can I set document date automatically as system date?

    I use FBV1, FBV2, F-02, FB02. Posting date is automatically set as system date. I want to set document date automatically as system date.
    How can I set document date automaticall as system date?
    Wbr.
    İlker Çokkeçeci
    Computer Engineer
    Ankara, Turkey

    Hi Expert,
    Please refer the below link..
    Document date to be defaulted as system date for all FI transactions
    as there mentioned, please go to T-Code: SHD0.
    Regards,
    GK
    SAP

  • How do you select a single image with the keyboard?

    I can use the "/" key to deselecting the current photo but how do I select the current photo with the keyboard? Usually the space bar is used for this but that displays the image. Is the only way to select the current photo by using the mouse?

    OK, now that the question has been clarified....
    Pressing and holding the Shift key as you move through the grid with the arrow keys will individually multi-select them, but that breaks down if you want non-contiguous selections, i.e. lifting off the shift key to skip a photo will cause all previous selections to be lost when you use the arrow key to advance. I think the only way for non-contiguous selection is ctrl-click.

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

    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? and how? can you explain me in detail ?
    Regards,
    Dinesh

    INNER JOIN->
    The data that can be selected with a view depends primarily on whether the view implements an inner join or an outer join. With an inner join, you only get the records of the cross-product for which there is an entry in all tables used in the view. With an outer join, records are also selected for which there is no entry in some of the tables used in the view.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ec77446011d189700000e8322d00/content.htm
    FOR ALL ENTRIES->
    Outer join can be created using this addition to the where clause in a select statement. It speeds up the performance tremendously, but the cons of using this variation are listed below
    Duplicates are automatically removed from the resulting data set. Hence care should be taken that the unique key of the detail line items should be given in the select statement.
    If the table on which the For All Entries IN clause is based is empty, all rows are selected into the destination table. Hence it is advisable to check before-hand that the first table is not empty.
    If the table on which the For All Entries IN clause is based is very large, the performance will go down instead of improving. Hence attempt should be made to keep the table size to a moderate level.
    Not Recommended
    Loop at int_cntry.
    Select single * from zfligh into int_fligh
    where cntry = int_cntry-cntry.
    Append int_fligh.
    Endloop.
    Recommended
    Select * from zfligh appending table int_fligh
    For all entries in int_cntry
    Where cntry = int_cntry-cntry.

  • How to supress the single Entries in the report?

    Hi
    I have a report of  "Customer unpaid Cheques". This report displays Customer wise.
    For eg. Let say Customer 1234 cheques have been unpaid and returned many times. Some customers have single time retrns.
    In a report I want to filter the Customers with Single Entry.
    Report is like ths.
    Cust No: Ret.Doc: Cheque No: Amount:
    1234 7999 3331 100
    1234 8999 3332 100
    1234 9999 3333 100
    1235 7777 4444 200
    Customer 1234 has been returned 3 times where as Customer 1235 is ed one time.
    I want a report which displays the customers with more than one returns. The report should be like this. How can I do this..
    1234 7999 3331 100
    1234 8999 3332 100
    1234 9999 3333 100
    Thanks for your help.
    Sudha..

    HI Sudhakar,
    It's bit complex but will work.
    Just create a new formuale with this option F= SUMCT(Amount)( This is basiclly the "result" option you get when you try to create a formlae.
    Now make a calculate key figure with the logic CKF=( Amount - F)
    This will give you basically this kind of difference
                        F   CKF
    1234 7999 3331 100 300 -200
    1234 8999 3332 100 300 -200
    1234 9999 3333 100 300 -200
    1235 7777 4444 200 200  0
    Now put a condition on the report level that show only those rows where the CKF!=0
    IT will show only those value which have moer then one rows.
    Also you can hide these additional columns depending upon your need.
    I think it will work
    If helpful assign points.
    Thanks

  • Select For all entries with multiple keys

    Dear Developers,
    im writing a program which reads the last the last mseg entry with bwart 101 and bwart 201 an writes it into different fields of a table. In dependance of the bwart the max-value of mkpf-budat should be moved into field wedat or wadat.
    At the moment i use this coding:
    loop at gt_daten assigning <fs_daten>.
        select distinct max( budat ) from wb2_v_mkpf_mseg2 into <fs_daten>-wedat
          where matnr_i = <fs_daten>-matnr
            and werks_i = <fs_daten>-werks
            and lgort_i = <fs_daten>-lgort
            and bwart_i = '101'.
        select distinct max( budat ) from wb2_v_mkpf_mseg2 into <fs_daten>-wadat
        where matnr_i = <fs_daten>-matnr
          and werks_i = <fs_daten>-werks
          and lgort_i = <fs_daten>-lgort
          and bwart_i = '201'.
      endloop.
    wb2_v_mkpf_mseg2 is a view combining mkpf an mseg by primary keys.
    Searching the internet i read, using FOR ALL ENTRIES should be prefered to selectstatements in loops.
    So i tried:
    *selectstatement
    select budat matnr_i werks_i lgort_i bwart_i from wb2_v_mkpf_mseg2 into table lt_mseg for all entries in gt_daten
        where matnr_i = gt_daten-matnr
          and werks_i = gt_daten-werks
          and lgort_i = gt_daten-lgort
          and ( bwart_i = '101' or bwart_i = '201' )
    *Substitute the MAX( )-Function
      sort lt_mseg descending by matnr werks lgort bwart budat.
      delete adjacent duplicates from lt_mseg comparing matnr werks lgort bwart.
    *Differ between wedat and wadat
      loop at gt_daten assigning <fs_daten>.
        loop at lt_mseg assigning <fs_mseg>
          where matnr = <fs_daten>-matnr
            and werks = <fs_daten>-werks
            and lgort = <fs_daten>-lgort.
          case <fs_mseg>-bwart.
            when '101'.
              <fs_daten>-wedat = <fs_mseg>-budat.
            when '201'.
              <fs_daten>-wadat = <fs_mseg>-budat.
          endcase.
        endloop.
    Even in the dev-system this takes twice the time of the "nested" selects.
    Imho this is because of the internal OR interpretation of the FOR ALL ENTRIES-statement and the size of the result.
    Can somebody give me a hint, how to tune this code?
    Select Inner join should be difficult because the target field differs, dependent of the value in bwart...
    Thanks in advance!

    I understand that you are trying to capture the maximum value of posting date MKPF-BUDAT for movement types 101 and 201 for each combination of material, plant and storage location.
    Few things, that makes the below coding more efficient at both application and database level and I confirmed this on an IDES sandbox
    1. Along with MKPF and MSEG, there is another table WBGT, in the view WB2_V_MKPF_MSEG join and also WBGT has select condition restrictions imposed on its fields. So if this restriction impacts your selection you may want to do a INNER JOIN of MSEG with MKPF only (with MSEG as leading table, as it has an active secondary index with MATNR, WERKS, LGORT and BWART ) and also there won't be overhead from the unnecessary join with WBGT table whose fields you are not using.
    2. The below SORT on lt_mseg will ensure that the record having greatest BUDAT will be at the top of all rows (least index) for each combination of MATNR, WERKS, LGORT and BWART.
    3. DELETE ADJACENT DUPLICATES will ensure that only the top row (having greatest BUDAT) remains in the table lt_mseg for each combination of MATNR, WERKS, LGORT and BWART. This will ensure that subsequent READs with BINARY SEARCH will always and efficiently read the row with maximum value of BUDAT for each unique combination of MATNR, WERKS, LGORT and BWART.
    4. The below logic will require more memory (even though it is more efficient performance wise) compared to direct SELECT with MAX for each MATNR, WERKS, LGORT and BWART in a LOOP the way you were doing before. So if the size of lt_mseg is causing memory issues, your logic with aggregate function MAX at database level will be your only option.
    So, I propose you revise your coding like below for most optimal results
    CHECK NOT gt_daten[] IS INITIAL.
    *selectstatement
    *SELECT budat matnr_i werks_i lgort_i bwart_i
    *  FROM wb2_v_mkpf_mseg2
    *  INTO TABLE lt_mseg
    *    FOR ALL ENTRIES IN gt_daten
    *    WHERE matnr_i = gt_daten-matnr
    *      AND werks_i = gt_daten-werks
    *      AND lgort_i = gt_daten-lgort
    *      AND ( bwart_i = '101' OR bwart_i = '201' ).
    * The below SELECT is more economical than the one commented above
    SELECT mkpf~budat mseg~matnr mseg~werks mseg~lgort mseg~bwart
      FROM mseg INNER JOIN mkpf
        ON mseg~mblnr = mkpf~mblnr AND
           mseg~mjahr = mkpf~mjahr
        INTO TABLE lt_mseg
          FOR ALL ENTRIES IN gt_daten
            WHERE mseg~matnr = gt_daten-matnr
              AND mseg~werks = gt_daten-werks
              AND mseg~lgort = gt_daten-lgort
              AND ( mseg~bwart = '101' OR mseg~bwart = '201' ).
    *Substitute the MAX( )-Function
    SORT lt_mseg BY matnr werks lgort bwart DESCENDING budat.
    DELETE ADJACENT DUPLICATES FROM lt_mseg COMPARING matnr werks lgort bwart.
    *Differ between wedat and wadat
    LOOP AT gt_daten ASSIGNING <fs_daten>.
      READ TABLE lt_mseg ASSIGNING <fs_mseg>
        WITH KEY matnr = <fs_daten>-matnr
                 werks = <fs_daten>-werks
                 lgort = <fs_daten>-lgort
                 bwart = '101' BINARY SEARCH.
      IF sy-subrc = 0.
        <fs_daten>-wedat = <fs_mseg>-budat.
      ENDIF.
      READ TABLE lt_mseg ASSIGNING <fs_mseg>
        WITH KEY matnr = <fs_daten>-matnr
                 werks = <fs_daten>-werks
                 lgort = <fs_daten>-lgort
                 bwart = '201' BINARY SEARCH.
      IF sy-subrc = 0.
        <fs_daten>-wadat = <fs_mseg>-budat.
      ENDIF.
    ENDLOOP.

  • How to select all single values in the header area

    Dear Experts
    I got a request that the user wants to select a single value or all single values in the header area. E.g. if the values from characteristic master data are A, B, C and D, the selection can be one of these values or all of them. With the standard BPS configuration, due to the unique combination in the header area, selection of  'All' single values is not possible. Is there a way to select all single values in the header area?
    Thanks, Jessica

    Hi Jessica,
    Here is a solution where you need not to change your planning layout or to create a new variable or any exit function.
    Step 1 - Maintain master data value 'ALL' in the required characteristic.
    Step 2 - Create a copy function to copy all the required data records to 'ALL'. you can use standard copy function where you have to include only this characteristic in the fields to be change.
    Copy -
    From = all values (A,B,C,D etc)
    To = "ALL".
    Step 3 - Call this function on layout opening. you can include it in the planning folder and change the function attribute to call it on layout opening.
    Step 4 - Create a standard Delete function. you have to call this function on save operation. In this function, you have to delete all data records present in the buffer where required char contains 'ALL' value.
    This approach can impact the performance of the planning application. It depends on the number of data records you are dealing with. Standard Copy and Delete functions are pretty fast in nature.
    I hope it will help you. please let me know if you need more inputs.
    Regards
    Tarun

  • Selection on single-click with custom TreeCellEditor

    Hi,
    In a JTree with a custom treecell editor (contains checkbox, label with icon) that overrides abstractcelleditor, selection of nodes does not highlight the selection on a single click. The selection is highlighted on a double click. clicking on the checkbox works fine. any ideas? the treecellrenderer works fine. So if i remove the custom editor and only have the renderer (for checkbox, label and icon) selections are highlighted properly.
    Thanks!

    Ok, came up with a solution - it makes keyboard navigation and mouse-based multiple selection work. Here's the fixed code:
    creating the tree :
    JTree tree = new JTree( root  );
    tree.setUI( new MyTreeUI() );
    tree.setCellRenderer( new OverlayTreeCellRenderer() );
    tree.setCellEditor( new OverlayTreeCellRenderer() );
    tree.setEditable(true);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    tree.setInvokesStopCellEditing( true );
    scrollPane.setViewportView( tree );
    add( scrollPane );the renderer / editor:
      protected static class OverlayTreeCellRenderer extends JPanel implements TreeCellRenderer, TreeCellEditor
        protected Color selBdrColor = UIManager.getColor( "Tree.selectionBorderColor" );
        protected Color selFG = UIManager.getColor( "Tree.selectionForeground" );
        protected Color selBG = UIManager.getColor( "Tree.selectionBackground" );
        protected Color txtFG = UIManager.getColor( "Tree.textForeground" );
        protected Color txtBG = UIManager.getColor( "Tree.textBackground" );
        protected JCheckBox visibleCheckBox = new JCheckBox();
        protected JLabel overlayName = new JLabel();
        protected JCheckBox showLabelCheckBox = new JCheckBox();
        protected LinkedList<CellEditorListener> listeners = new LinkedList<CellEditorListener>();
        protected final ActionListener checkBoxListener = new ActionListener() {
          public void actionPerformed ( ActionEvent ae )
            if ( stopCellEditing() )
              fireEditingStopped();
        protected final MouseListener labelListener = new MouseAdapter() {       
          public void mouseReleased ( MouseEvent e )
            if ( stopCellEditing() )
              fireEditingStopped();
         * Constructor.
        public OverlayTreeCellRenderer ()
          setLayout( new BoxLayout( this, BoxLayout.LINE_AXIS ) );
          visibleCheckBox.setOpaque( false );
          showLabelCheckBox.setOpaque( false );
          add( visibleCheckBox );
          add( overlayName );
          add( showLabelCheckBox );
          setBackground( txtBG );
          setForeground( txtFG );     
          visibleCheckBox.addActionListener( checkBoxListener );
          showLabelCheckBox.addActionListener( checkBoxListener );
          overlayName.addMouseListener( labelListener );
         * Returns the renderer
        public Component getTreeCellRendererComponent ( JTree tree, Object value,
            boolean selected, boolean expanded, boolean leaf, int row,
            boolean hasFocus )
          DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;           
          OverlayDescriptor data = (OverlayDescriptor) node.getUserObject();
          overlayName.setText( data.overlayName );
          visibleCheckBox.setSelected( data.visible );
          showLabelCheckBox.setSelected( data.label );   
          if ( selected )
            setBackground( selBG );
            setForeground( selFG );
          else
            setBackground( txtBG );
            setForeground( txtFG );
          return this;
        // ------------------------------------------------- Cell Editor
        // Returns the editor
        public Component getTreeCellEditorComponent ( JTree tree, Object value,
            boolean isSelected, boolean expanded, boolean leaf, int row )
          return getTreeCellRendererComponent( tree, value, true, expanded, leaf, row, true );
        // Implement the CellEditor methods.
        public void cancelCellEditing ()
        // Stop editing only if the user entered a valid value.
        public boolean stopCellEditing ()
          requestFocusInWindow();
          return true;
        // This method is called when editing is completed.
        // It must return the new value to be stored in the cell.
        public Object getCellEditorValue ()
          return new OverlayDescriptor( overlayName.getText(), showLabelCheckBox.isSelected(), visibleCheckBox.isSelected() );
        // Start editing when the mouse button is clicked.
        public boolean isCellEditable ( EventObject eo )
          return true;
        public boolean shouldSelectCell ( EventObject eo )
          return true;
        // Add support for listeners.
        public void addCellEditorListener ( CellEditorListener cel )
          listeners.add( cel );
        public void removeCellEditorListener ( CellEditorListener cel )
          listeners.remove( cel );
        protected void fireEditingStopped ()
          if ( listeners.size() > 0 )
            ChangeEvent ce = new ChangeEvent( this );
            for ( CellEditorListener l : listeners )
              l.editingStopped( ce );
      }subclass of BasicTreeUI:
       * Fix multiple-selection handling in BasicTreeUI which doesn't appear to work
       * when the tree has a custom editor.
      protected static class MyTreeUI extends BasicTreeUI {   
        protected boolean startEditing ( TreePath path, MouseEvent event )
           * BasicTreeUI startEditing(..) method doesn't handle multiple selection
           * well. This circumvents that for when Ctrl or Shift is held down by
           * first saving the current selection, and then restoring it after calling
           * super.startEditing(..).
          ArrayList<TreePath> selectedPaths = null;
          if ( tree.getSelectionCount() > 0 && event.isControlDown() )
            selectedPaths = new ArrayList<TreePath>( tree.getSelectionCount() + 1 );
            for ( TreePath p : tree.getSelectionPaths() )
              selectedPaths.add( p );
            if ( !tree.isPathSelected( path ) )
              selectedPaths.add( path );
            else
              selectedPaths.remove( path );
          else if ( tree.getSelectionCount() > 0 && event.isShiftDown() )
            int endRow = tree.getRowForPath( path );
            int startRow = tree.getAnchorSelectionPath() == null ? endRow : tree
                .getRowForPath( tree.getAnchorSelectionPath() );
            if ( startRow > endRow )
              int temp = endRow;
              endRow = startRow;
              startRow = temp;
            selectedPaths = new ArrayList<TreePath>( endRow - startRow + 1 );
            for ( int row = startRow; row <= endRow; row++ )
              selectedPaths.add( tree.getPathForRow( row ) );
          boolean val = super.startEditing( path, event );
          if ( selectedPaths != null )
            tree.setSelectionPaths( selectedPaths.toArray( new TreePath[0] ) );
          return val;
      };

  • 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

  • How to select a single day from month view

    From my ipad on IOS7 I can not select a single day from the month view? From the old versions all I had to do was double click a single date even if it had multiple appointments in it to view it. Was this feature removed?  Please help

    It appears to me as though it has indeed been removed. You can tap and hold down on a day while in month view to create or view an event, but you cannot tap on the day to open the whole day's events.

  • How to bind a single Entity with Odata

    Hi experts,
    just playing around with UI5...short question:
    I have created a WebService in GW, reading user data (using  BAPI_USER_GET_DETAIL).
    Very easy, just for testing.
    No I want to show my own user data on a SAPUI5 page.
    Have created a controller:
    onInit: function() {
    var odataUrl = "/sap/opu/odata/sap/ZXYZ_SRV/";
    var odataUser = "user";
    var odataPass = "password";
    var oModel = new sap.ui.model.odata.ODataModel(odataUrl, false, odataUser, odataPass);
    this.getView().setModel(oModel);
    Okay, this is working
    Now I want to read a single entity with my WebService (this would be the GetEntity one, NOT the GetEntitySet).
    I have created a very simple view, including a MatrixLayout with 2 columns, here I wanto to add a Label and the value of the WebService.
    What I have done:
    var oMatrixPers = new sap.ui.commons.layout.MatrixLayout({
    layoutFixed: false,
    width : "300px",
    columns: 2
    var oLabel = new sap.ui.commons.Label({
    text : "Lastname"
    var oTF = new sap.ui.commons.TextField({
    editable: false,
    }).bindValue("value", "{/own_dataSet(TEST)}");
    oLabel.setLabelFor(oTF);
    oMatrixPers.createRow(oLabel, oTF);
    I'm sure it is an easy question - maybe someone can help?
    Thanks
    Michael

    All right, One more suggestion ,
    var oTF = new sap.ui.commons.TextField({ 
    editable: false, 
    value: "{THE PROPERTY NAME FROM THE ENTITY}"
    oMatrixPers.bindElement('/own_dataSet('TEST')');
    oMatrixPers.setModel(oModel); 
    This will most probably get you the value, if you do not get any other error in the Console

  • How to use a Web Template with queries from multiple BW Systems?

    Hi all,
    can anybody help me how to use a Web Template with queries (DATA PROVIDER)in it from multiple BW Systems?
    Thanks in advance, best regards
    Frank

    Great! Thanks for the quick response.
    Have you tried this for XMLA datasources created within the EP system also?
    i.e use Web Analyzer to create a view from the XMLA source and use that view within WAD?
    Thanks.

Maybe you are looking for

  • Billing problem for cash sales document

    Hi all , Greetings we are customizing for cash sales. Required Three configuration setting are done for sales document i.e 1. Shipping condition Immediatly 2. Lead Time 0 3. Immediate delivery must be switch on and order and delivery is done at the s

  • Cash flow in PS

    Dear Experts, Is there any method, T Code , or configuration needed, to see CASHFLOW MANAGEMENT in PS Module Regards Chandra

  • AR Reconciliation report

    Hi all I have submitted AR reconciliation report and it shows an Difference of around 6000 . How to trouble shoot to make the difference to Zero ?

  • Reading .sql files

    am reading .sql file using {BufferedReader in= new BufferedReader(new FileReader("my_sql_file.txt"));} when i get the string from the buffered reader it has spaces in between the characters eg s a m p l e o u t p u t but when i try with ..txt the out

  • Syncing contacts with Google Contacts causes duplicates

    I don't use MobileMe, I just sync with my Google contacts, however it puts them in my iPod Touch twice, I tried removing one of them for each contact, it ended up wiping out my google contacts completely. I attempted to sync again hoping it would put