This is really a SQL question. How to get a record for the max value

I have a table ZTX with the following fields and values
VBELN  POSNR SEQNR DESCRIPTION
3001             10   001  Desc1
3001             10   002  Desc2
3001             10   003  Desc3
I want to create a query so that I can join tables VBAK-VBELN, and VBAP and ZTX. So that I only get the row of ZTX which has max (SEQNR) i.e 003 in this case. How can I write the SQL statement. Is there a way to write a single SQL statement which can retrieve from all three table VBAK, VBAP and ZTX maybe with a subquery or do I really have to first take the results of VBAK and VBAP join into internal table then fire query on ZTX.
Thanks for reading

Something like this
Select * into table my_table from ztx as z
join vbak as b on b~vbeln = z~vbeln
join vbap as p on p~vbeln = z~vbeln " maybe posnr also?
where
z~seqnr = ( select max( seqnr ) from ztx where vbeln = z~vbeln ).

Similar Messages

  • How to get Open Balance for the year and Total Ending Balance?

    For a given account, how to get Open Balance for the year (Cumulative Ending Balance) and Total Ending Balance (Cumulative Ending Balance)?
    Is there any function module available? or should I read from some tables? Please advice.

    Hello Paul,
    You could try calling one of the following BAPIs - see which one meets your requirement. They are documented well so shouldn't be a problem finding out the correct one for your requirements.
    BAPI_GL_GETGLACCBALANCE      
    BAPI_GL_GETGLACCCURRENTBALANCE
    BAPI_GL_ACC_GETBALANCE      
    BAPI_GL_ACC_GETCURRENTBALANCE
    BAPI_GL_ACC_GETPERIODBALANCES
    BAPI_COND_VAL_DECRE_BALANCES
    You might have to put in some of your own logic after the BAPI call to get what you want.
    Hope this helps,
    Cheers,
    Sougata.
    p.s. Also look at FM FAGL_GET_ACCOUNT_BALANCE
    Edited by: Sougata Chatterjee on May 7, 2008 11:47 AM

  • SQL question - how to get only the leafs

    i have a table of departments
    create table departments (
      dept   number ,
      father number
    )this is the data
    1
    1/2
    1/2/4
    1/2/4/6
    1/2/4/7
    1/2/4/8
    1/3
    1/3/5
    1/3/9given a department number i need only the leafs (the lowest member in the hierarchy).
    for dept 2 i need 6, 7, 8
    for dept 3 i need 5 , 9
    for dept 5 i need 5
    this is my query
    select dept
    from departments
    where connect_by_isleaf = 1
    start with father = :X
    connect by prior dept = father;this query will work only if :X is not a leaf. for 2 and 3 this query will work but for 5 it will return nothing (since connect_by_isleaf is 0 if the department apears in the start with clause).
    thanks !

    try
    select dept
    from departments
    where connect_by_isleaf = 1
    start with dept = :X
    connect by prior dept = father;Dang very late
    Message was edited by:
    Versatile

  • How to create a graph for the exact values in pivot table

    hi all,
    how can i create a graph exactly that shows pivoted values. i created one pivot table and deleted the table view. when i am creating the graph it is not showing the graph for pivot table values.

    for that you need to edit the pivot table properties and then select graph pivot results tab in the top middle .. hope this helps

  • How to get warning by using the previous value of the column and new value

    Hi all,
    Suppose the column A has the true and when I click on button which also sets the value of the column as true I should dispaly warning that column a is already true.How can I achieve this.How to store the original value of the column and then check wirth the new value.
    Thanks in advance.

    You dont have to store the value anywhere
    You can do this from setMethod of EOImpl.java
    eg:
    void setAttributeXXX(String Value)
    // value contains new value
    // getAttributeXXX() contains oldValue
    if (value.equals(getAttributeXXX()))
    // Verify value is > 0 if (value.compareTo(0) <= 0)
    throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT, // indicates EO source
    getEntityDef().getFullName(), // entity name
    getPrimaryKey(), // entity primary key
    "AttributeXXX", // attribute Name
    value, // bad attribute value
    "AK", // nessage application short name
    "FWK_TBX_T_EMP_SALARY_REQUIRED"); // message name
    setAttributeInternal(AttributeXXX, value);
    --Prasanna                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to get pop-up for entering some value on it by user on Adobe INTERACTIV

    Hello
    We are developing a interactive adobe form,
    1) User would like get some popups for entering the values in the popup and clicking either OK or CONTINUE, pls. let me know how to handle this?
    2) can i get CALENDER, when user tries to input DATE entry? how its?

    Hi,
    You can create a subform overlapping you main body page and you can use this subform as pop-up.
    You just need to do following things:
    1. Create a subform over you main body page in the area where you want to show the pop-up, say SF_POPUP is the name of this subform.
    2. Give it a background colour(So that it looks different from the main page).
    3. On this subform SF_POPUP, create the fields you want the user to enter. along with these fields create a button 'OK' or 'Continue' as per your requirement.
    4. Write the below code on click event of this button:
        SF_POPUP.presence = "Hidden".
    5. On you main body area create a button to show this popup and write the below code on it:
       SF_POPUP.presence = "Visible".
    6. By default set this popup SF_POPUP as hidden from subform properties.
    Hope this will help for your first requirement, for your second requirement Arvind has already given a solution.
    Regards,
    Vaibhav

  • How to get check number for the employee's paycheck

    Hello
    Anyone can advise on how to get the check number for an employee's pacheck
    I got employee first name,last name,GROSS salary,Tax Info,and NET salary.I need the CHECK NUMBER.
    please advise
    thanks
    kp
    Edited by: user8612301 on Dec 16, 2010 1:26 PM

    Hi,
    Or are you looking for this:
    SELECT serial_number, paaf.assignment_number
    FROM pay_assignment_actions paa, per_all_assignments_f paaf
    WHERE action_status = 'C'
    AND paaf.assignment_id = paa.assignment_id
    AND serial_number IS NOT NULL
    AND SYSDATE BETWEEN paaf.effective_start_date AND paaf.effective_end_date;
    - Viky
    Edited by: Viky on Dec 17, 2010 11:42 AM

  • How to get an AppID for the Microsoft Academic Data?

    Hi,
    I have just signed up for the Microsoft Academic Data at http://datamarket.azure.com/dataset/mrc/microsoftacademic, but I need to get an Application ID to make it work on my website. 
    Perhaps, this this requirement could be found in this file: http://academic.research.microsoft.com/about/Microsoft%20Academic%20Search%20API%20User%20Manual.pdf
    Where can I find the AppID?
    Thanks in advance

    Hi,
    From the PDF file that you provided, we can found how to request a AppID.
    Here is snippet of PDF file.
    Requesting an AppID
    To identify each application using the MAS API, an AppID is required. To request an AppID, please provide the following information in an email request to
    [email protected]
    Contact Person
    Contact Email
    Project URL
    Project Brief Introduction
    Confirmation that you agree to the
    MAS Terms of Useand
    MS Terms of Use.
    o
    E.g. "We have read and agreed with the Microsoft/MAS Terms of Use" 
    o
    Include a link to theMAS
    Terms of Use,
    MS Terms of Use. 
    What we can do just follow as above process. Hope this helps.
    Best Regards
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • In BAM, how to get activity ID for the running instance in the orchestration.

    I am trying to add document reference URL to the active instance in the orchestration for the activity which is already started.
    Please let me know how to get such activity ID.
    Thanks
    Jagadeesh 
    Jagadeesh RS

    Are you using TPE to set up the Activity Tracking or BAM API. If you are using TPE then identify what has been set as the Activity Id in the BTT file. If the Message Id is used then use "BTS.InterchangeID" [refer
    http://msdn.microsoft.com/en-us/library/aa562116.aspx] on the received message to get the Activity Id.
    If however you've mapped the Activity Id in BTT to the InstanceId then use
    "Microsoft.XLANGs.Core.Service.RootService.InstanceId"
    to get the activity id.
    Regards.

  • How to get blank records at the start of report output for label sheet?

    Hello -
    What is the best way to get an arbitrary # of blank records at the start of report output?
    I am writing a report that will be printed out on label sheets -- some of which might already be used. For example, there might be 3 labels per page but the first 2 have been used the last time the report was run.. so the report needs to display 2 blank records first so that the first record that gets printed on a label is in the 3rd position on the page. (the user would indicate - through a parameter - what the starting postion would be)

    Hi Scott
    Create a user parameter that reads in the number of blanks you need to 'print' before starting the actual printing.
    In the Format trigger of the outermost frame of your report write code using SRW.SET_BEFORE_PRINTING_CODE.
    Loop this method based on the user parameter and call this method with skip-line-command of your printer as its argument.
    Regards
    Sripathy

  • How to get stop script for the server

    Hello everyone,
    I installed weblogic server8.1 on my Linux machine and used $WL_HOME/server/bin/startWLS.sh
    to create a new domain and server. But I did not find any stop script(like stopWLS.sh)
    which can stop myserver. How can I get it?
    Thanks for your helps.
    Iris

    which can stop myserver. How can I get it?Here's an etc/rc3.d script I use for my RH9 server. You'll notice there is
    a line in there for stop(), you can run that manually if you so choose, or
    you can use it via the xinetd (I think that's what it's called?). Good luck.
    # processname: weblogic
    # pidfile: /var/run/weblogic.pid
    PIDFILE=/var/run/weblogic.pid
    # Source function library
    . /etc/init.d/functions
    #check to see if we can write to config.xml...so non-root uses stop here
    [ -w /Domain/config.xml ] || exit 0
    #setup the environment for the java commands
    . /bea/weblogic81/server/bin/setWLSEnv.sh
    cd /Domain
    start(){
    echo "Starting WebLogic for Domain"
    cd /Domain
    daemon ./startWebLogic.sh &
    echo $! > $PIDFILE
    RETVAL=$?
    echo "WebLogic Server started."
    return $RETVAL
    stop(){
    echo "Stopping WebLogic for Domain"
    rm -f $PIDFILE
    java weblogic.Admin -url localhost:80 FORCESHUTDOWN
    status(){
    echo "Getting Weblogic status for Domain"
    java weblogic.Admin -url localhost:80 GETSTATE
    restart(){
    echo -n "Restarting WebLogic for Domain"
    stop
    start
    # See how we were called.
    case "$1" in
    start)
    start
    stop)
    stop
    restart|reload)
    stop
    start
    status)
    status
    echo $"usage: $0 {start|stop|status|restart|reload}"
    exit 1
    esac
    exit $RETVAL

  • How to get  --Last date of the Last value .

    Dear All,
    I have a report like
    Material – Country – Current Price
    1112-----  Singapore  -
      100
    1112-----  Japan  -
      120
    1112-----  Malesia   -
      99
    Here current price is Last Value of the particular Material on particular Date.
    This I can get based on Key figure Aggregation ( Last Value and reference Character 0CALDAY ), It is giving the last Value of the Particular Material.
    Now my user wants to see Last date of the value ( Date of the Value )
    Example :-
    Material – Country –  Date --Current Price
    1112-----  Singapore  -
    01/04/2008 -- 100
    1112-----  Japan  -
    04/05/2008 -- 120
    1112-----  Malesia   -
    05/05/2008 -- 99
    If  I drill down the date in my  report  it is showing all dates , my user wants to see only last date .
    Hope some one has solved this issue , please help me to solve this issue.
    Regards,
    SHAIK.

    I have created a keyfigure with date as a data type.
    In aggregation tab, I selected  aggregation Maximum.
    Upto DSO, data is Loaded perfect. Ok.
    I added the same key figure in cube , When I am trying to Activate the Transformation,
    It is giving Error message.
    Rule 17 is invalid and is being deleted. The reason for this is that a field or InfoObject that is used in rule 17 has been deleted in the source or target of the transformation ODSO ZPL_DSO1 -> CUBE ZPLATT_C (0GH6MHANQ2J79LXZBLGIJ9ZK9LWHK6RS)
    Plz Advice.
    Regards,
    SHAIK
    Edited by: shaik on May 7, 2008 5:46 PM

  • How to get label text  for the Input Field in code

    Hi,
    I have created Two UI elements InputField  and Label.  I set the property 'labelFor' of the UI element Label to 'InputField'.
    This is my requirement .  I am having the Id of InputField in the code . I want to get the value of 'text' of  the UI element Label.
    Please suggest how to proceed.
    Points will be rewarded for helpful answers.
    Best Wishes
    Idhaya R

    Not sure why you really need this, but you could do something like
    IWDInputField field = (IWDInputField) view.getElement("inputFieldID");
    IWDLabel fieldLabel = null;
    for (Iterator children = field.getContainer().iterateChildren(); children.hasNext(); )
      IWDUIElement child = (IWDUIElement) children.next();
      if (child instanceof IWDLabel)
        IWDLabel  label = (IWDLabel) child;
        if ( field.getId().equals(label.getLabelFor())
          fieldLabel = label;
          break;
    Armin

  • How to get CLASS name for the generic item?

    Hi,
    I wrote following method to create a service instance.
    public static <IType> IType GetServiceInstance()
           IType type=null;
            try
            InitialContext ic=new InitialContext();
    //ERROR:      type=   ic.lookup(IType.class.getName());
            catch(Exception ex)
            //do handle
            return type;
        }please see the //Error: here its giving error, also i m not getting "class" variable in IDE!!!
    i want use like this;
    IUserService userService=ServiceFactory.GetServiceInstance<IUserService>();so how can i do this?
    Edited by: Manikandan.Java on Oct 31, 2007 3:02 AM

    I don't know if I understand your question, but you cannot find the class name because it is in run time just an object. You can, however, check if it is an instanceof.
    if (genericType instanceof MyType) {
         doMyThing();
    }

  • How to put a loop for the entered value

    hi all,
    I have 6 different scenario or cases and in my selection screen i am entering a value say 10. then in my program, it should go to all the 6 cases along with the first 4 cases. so the total turn is 10.
    if the value is 20, then it should go 3 times to all the 6 cases + first 2 cases.
    how can i handle this. provide the coding if possible.
    thanks in advance
    points will be rewarded

    Hi!
    If i understand right, maybe you can do something like that:
    data: v_mod type i,
          v_div type i.          
    Selection-screen...
    P_input (type)
    start-of-selection.
    v_mod = p_input MOD 6.
    v_div = p_input DIV 6.
    *For my 6 scenario
    Do v_div times.
    *     do 6 things....
    enddo.
    *For my first cases.
    do v_mod times.
    *     do my first case things
    enddo.
    I hope it helps,
    Regards,
    John

Maybe you are looking for

  • Sequence frame size/black border

    I created several sequences in Final Cut Pro 4, which all seem to have the same settings, but some of them have a black border around the picture and a smaller picture size. When I export a Quick Time Movie of the sequence, the boarder still exists i

  • Why can't I turn on Photostream?

    I open iPhoto and regardless if I go to the Photostream tab and click "Turn On Photostream" or go to iPhoto Preferences and check "Enable Photostream", nothing happens. The button does it's little animation to acknowledge I clicked it and the check b

  • Document splitting-wbs, Order

    Hi users Is it possible to have document splitting by characteristics wbs, order and GL accounts  is payable in nature. Please clarify how. suppose i make two characteristics will i be posting a single transaction to both the characteristic or it sho

  • IPhone 4S video sound not working.

    Hey, My iPhone 4S won't play back sound when a video has been recorded, it makes a weird fuzzy noise. However it works fine during calls and people can hear me, just not on the videos. Are there any solutions or do I need to get it fixed in store?

  • Inventory SnapShot ODS

    The key figures which are defined in the How to Inventory guide for the SnapShot ODS are overwrite or addition? Thanks