Max line item to be selected

Hi Friends,
I need to pick only records where line item number is maximum,
Ex:   invoice no     Line Item
       ab001               1
       ab001               2
       ab001               3
       ab002               1
       ab002               2
       ab003               1
       ab003               2
I want to pick only the records where the line item number is max:
       ab001               3
       ab002               2
       ab003               2
Can any one tell me how to code it.
Regards,
Line

Hi,
SQL query
select max ( distinct lineitemno) invoice from <table> group by invoice lineitemno
regards
suresh krishnan

Similar Messages

  • The question about max line item in material document

    Dear  sir:
    I want to excute CO27 for an FP . It will create material documents. The max line item is 100 in each material document. But I want to record 400 lines in a material document.  Is it possbile to change the number of max line in material document?   How could I do to change that ?   Thanks !!

    I know about 333 in case of physical inventory because the finacial document has a technical limitation of 3 digits for Fi document item number, which means the FI document cannot take more than 999 lines.
    In case of physical inventory a material document item can create up to 3 FI item lines. So the limit for physical inventory became 333.
    I dont know from where you have the 100 as limitation, but take the above said into consideration before you change anything.

  • Max line items in FI reached..

    Hi,
        We are posting an invoice using MIRO and it is giving an error that "Max line items in FI has reached".
    So is there any way that we can post if the total line items are more than 999.
    Regards>

    Hello,
    Please check the note
    36353 - AC interface: Summarizing FI documents
    But be aware that contents in many fields can prevent the summarization.
    So please thoroughly compare the entries in database table BSEG, which were not
    summarized together, with each other. Do really all fields have the same content in all line items, of course except for the amount fields? If not, these fields, which are no amount fields and whose
    content is different in the line items, can be added in transaction OBCY.
    As per the note 1070206 if you have the setting Determine taxes line-by-line (Customizing transaction OBCO: TTXD-XTXIT = X. Please implement the notes 1051914 and 1070206 this should help here.
    The enhanced logic also makes postings from MM and SD are not summarized completely although the settings in note 36353 are correctly made. As a solution, note 645356 releases BSEG-XREF3 in transaction OBCY.
    The aggregation is prevented through different content in the fields of EBELN (Purchasing document or purchase order) and EBELP (Purchasing document or ordering item). Thus a higher aggregation could be achieved with SAP Note 77161 (for dummy operation 'VBRK').
    Per note 77161, you have to setup up point no. 2 by maintaining table TTYPS with fields
    TABLE   FIELDNAME
    BSEG     EBELP
    BSEG     EBELN
    In point no. 3 setup in your system. Please insert the following field in table TTYPV for object type 'RMRP'
    TABLE   FIELDNAME
    BSEG    EBELP
    Please take note that the account assignments to the purchase order (EBELN) and to the purchase order item (EBELP) are NOT deleted by default. In both the goods receipt with reference to the purchase order (MB01) and the invoice verification, they are assigned to an account in the FI document and thus PREVENT the summarization of the FI document.
    This makes it possible to clear the GR/IR clearing account at PURCHASE ORDER ITEM level.
    By implementing the changes as per notes 77161 and 36353, the clearing of the GR/IR is at PURCHASE ORDER NUMBER level.
    Also, refer to the following notes:
      645356 No summarization of FI documents from MM due to
      545137 FAQ Interface - summarization
      117708 A maximum of 999 items can be posted in the FI doc
      743744 MIRO/MR1M: FI follow-on documents or MM documents missing
    Please, check carefully the customizing with the reference notes.
    I think that this should help to resolve your inquiry.
    Best Regards,
    Vanessa.

  • Splitting sales ord line items to diff deliveries based on max line items

    Hi,
    I'm trying to split sales order line items to different deliveries based on the max line items on Sales Organization ( TVKO-MAXBI ) . I activated a new routing (copying standard 001 ) but an error is happening
    Item 000200: delivery split due to conflicting header data (ZUKRL: M106 <-> M1061)
    However the split does not work as expected. Does anyone have any ideas ?
    Pls help me
    The code is:
    data: ITEMNO        LIKE TVKO-MAXBI,
          BILLNO        LIKE TVKO-MAXBI.
    *}   INSERT
    FORM DATEN_KOPIEREN_601.
    *{   INSERT         MTDK905083                                        1
      LIKP-VKORG = CVBAK-VKORG.
      LIKP-AUTLF = CVBAK-AUTLF.
      LIKP-VSBED = CVBAK-VSBED.
      LIKP-FKARV = TVAK-FKARV.
      LIKP-TRAGR = MAAPV-TRAGR.
    Fill field ZUKRL with combination criteria
      LIKP-ZUKRL(2)      = CVBAK-VTWEG.
      LIKP-ZUKRL+2(2)    = CVBAK-SPART.
        IF NOT TVKO-MAXBI IS INITIAL.
          IF ITEMNO < TVKO-MAXBI.
            ITEMNO = ITEMNO + 1.
          else.
            LIKP-ZUKRL+4(2) = BILLNO + 1.
            ITEMNO = 1.
          endif.
        endif.
      LIKP-STAFO = CVBAK-STAFO.
      LIKP-STWAE = CVBAK-STWAE.
      MOVE CVBAK-KKBER TO LIKP-KKBER.
      MOVE CVBAK-KNKLI TO LIKP-KNKLI.
      MOVE CVBAK-KKBER TO LIKP-KKBER.
      MOVE CVBAK-GRUPP TO LIKP-GRUPP.
      MOVE CVBAK-SBGRP TO LIKP-SBGRP.
      MOVE CVBAK-CMWAE TO LIKP-CMWAE.
      MOVE CVBAK-WAERK TO LIKP-WAERK.                      "46C/note 184914
      MOVE CVBAK-CTLPC TO LIKP-CTLPC.
      IF LIKP-LFART = TVAK-KORLI.
        LIKP-KLIEF = CHARX.
      ENDIF.
      MOVE CVBAK-LIFSK TO LIKP-LIFSK.                           "45B
    Pick-up sheet number in delivery order processing is external dlv. no.
      IF CVBAK-VBKLT EQ VBKLT_AUSL_AUFT OR
         CVBAK-VBKLT EQ VBKLT_AUSL_AUFT_KORR.
        MOVE CVBAK-BSTNK TO LIKP-LIFEX.
      ENDIF.
    Consignment issue by service agent is external delivery number
      IF CVBAK-VBKLT EQ VBKLT_EDL_ENTN OR
         CVBAK-VBKLT EQ VBKLT_EDL_ENTN_KORR.
        MOVE CVBAK-BSTNK TO LIKP-LIFEX.
      ENDIF.
    *}   INSERT
    ENDFORM.

    hi friend i solved the problem.. was a mistake on my source... I send u the code to help u in advanced... thanks for your time
    data: ITEMNO        LIKE TVKO-MAXBI,
          BILLNO        LIKE TVKO-MAXBI.
    *}   INSERT
    FORM DATEN_KOPIEREN_601.
    *{   INSERT         MTDK905083                                        1
      LIKP-VKORG = CVBAK-VKORG.
      LIKP-AUTLF = CVBAK-AUTLF.
      LIKP-VSBED = CVBAK-VSBED.
      LIKP-FKARV = TVAK-FKARV.
      LIKP-TRAGR = MAAPV-TRAGR.
    Fill field ZUKRL with combination criteria
      LIKP-ZUKRL(2)      = CVBAK-VTWEG.
      LIKP-ZUKRL+2(2)    = CVBAK-SPART.
        IF NOT TVKO-MAXBI IS INITIAL.
          IF ITEMNO le TVKO-MAXBI.
            ITEMNO = ITEMNO + 1.
          else.
            BILLNO = BILLNO + 1.
            ITEMNO = 1.
          endif.
        endif.
      LIKP-ZUKRL+4(3) = BILLNO.
      LIKP-STAFO = CVBAK-STAFO.
      LIKP-STWAE = CVBAK-STWAE.
      MOVE CVBAK-KKBER TO LIKP-KKBER.
      MOVE CVBAK-KNKLI TO LIKP-KNKLI.
      MOVE CVBAK-KKBER TO LIKP-KKBER.
      MOVE CVBAK-GRUPP TO LIKP-GRUPP.
      MOVE CVBAK-SBGRP TO LIKP-SBGRP.
      MOVE CVBAK-CMWAE TO LIKP-CMWAE.
      MOVE CVBAK-WAERK TO LIKP-WAERK.                      "46C/note 184914
      MOVE CVBAK-CTLPC TO LIKP-CTLPC.
      IF LIKP-LFART = TVAK-KORLI.
        LIKP-KLIEF = CHARX.
      ENDIF.
      MOVE CVBAK-LIFSK TO LIKP-LIFSK.                           "45B
    Pick-up sheet number in delivery order processing is external dlv. no.
      IF CVBAK-VBKLT EQ VBKLT_AUSL_AUFT OR
         CVBAK-VBKLT EQ VBKLT_AUSL_AUFT_KORR.
        MOVE CVBAK-BSTNK TO LIKP-LIFEX.
      ENDIF.
    Consignment issue by service agent is external delivery number
      IF CVBAK-VBKLT EQ VBKLT_EDL_ENTN OR
         CVBAK-VBKLT EQ VBKLT_EDL_ENTN_KORR.
        MOVE CVBAK-BSTNK TO LIKP-LIFEX.
      ENDIF.

  • Max # line items in a purchase order

    What is the maximun number of line items that can be created in a purchase order or in a contract?
    Thanks

    >
    mamamoraga wrote:
    > What is the maximun number of line items that can be created in a purchase order or in a contract?
    >
    > Thanks
    Best practice would be to stay with 99 line items, as if created more, than you will have trouble in Goods receipt. GR allows just 99 line items receiving. If more than 99 line items are used in PO, then you need to do multiple GR's against the said PO.

  • How to select line items in recording(BDC)

    Hi All,
    we are trying to Recording QP02 transaction ,we have inputs like material,plant,Group,Group Counter.
    after entering these inputs we will get multiful line items(inspection characteristics).we need to check one field for each item.
    How can we get this?
    Please help me?
    Thanks,
    Peddi reddy.

    Hi Kamesh,
    Thanks.
    After selecting line items i am selecting control indicators Tab.
    then Pop up screen called as (Edit characteristic control indicators) will open ,..then just pressing enter..the it will show another pop up ..here i am selecting one field(Long term Inspection)..the process has to do for all line items.
    In My program i have copied BDC performs which i got from Recording.
    Do i need to change tha performs or will it work?
    i tested in foreground with another material .... upto 3 or 4 line items its working fine.after that sytem does.t say anything.
    if i need to chage performs please help me .

  • Select last line item from VBAP

    Dear SAP experts,
    This might sound very silly question but I am new to SAP world.
    is there a simple select statement to select only higest line item.
    Say for example in VBAP, I have 9 line items.
    then my select statement should find the last line item. ie. 9th item.
    Actually, I have a situation where a custom table has 2 key fields and I want to select the only 1 line with higest number in 2nr column. Thank you.
    Anitha.

    Hi,
    types: BEGIN OF ls_vbap,
             vbeln TYPE vbap-vbeln,
             posnr TYPE vbap-posnr,
           END OF ls_vbap.
    DATA : t_vbap TYPE STANDARD TABLE OF vbap WITH HEADER LINE,
           wa_vbap type ls_vbap.
    data: lv_line type int4.
    SELECT vbeln posnr FROM kna1 INTO TABLE t_vbap.
    *****If you just need the last record then write the code  as shown below:
    DESCRIBE TABLE t_vbap LINES lv_line.
    READ TABLE t_vbap INTO wa_vbap INDEX lv_line.
    if sy-subrc = 0.
    write:/ wa_vbap-vbeln.
    endif.
    If you the need the last record after sorting then use the below code:
    SORT t_vbap by vbeln posnr DESCENDING.
    READ TABLE t_vbap into wa_vbap index 1.
    if sy-subrc = 0.
    write:/ wa_vbap-vbeln.
    endif.

  • Restrict purchase order line item selection in MEMASSPO

    How to restrict in authorizations of role which purchase order line item can be selected by user in the memasspo.
    I have a scenario where Business wants that no user should be allowed to select all the Purchase Order line items rather should be displayed sub set of the entire purchase Order line items while attempting to do mass change in the PO created.
    Thanks & Regards,
    Abhimanu

    The mass transaction is meant to change many POs and their items at one time.
    The user can not change anything with mass which he cannot do in ME22N.
    if he can do it in ME22N, why should he not be able to do it in MEMASSPO?
    Based on what criteria should a item be restricted from a change in your special case, how do you define your subset?

  • Unable to see line items in segment clearing account

    Friends,
    Why we are unable to see the line items in intersegment clearing account/zero balance clearing account, eventhough the master is maintained as open item  and line item display.

    Hi,
    I have received the following error message.
    Account 1999990, company code xxxx is clearing account
    Message no. MSITEM111
    Diagnosis
    You have stored account 1999990 in company code xxxx as a clearing account. At the same time, you use line item management with this account.
    System Response
    Error message issued because line item display cannot read data for an account in a ledger if line items exist partially in the entry view together with clearing items for which there are no line items. In such cases, only the data with line items would be selected.
    Procedure
    Check the Customizing settings or account control. Change the settings so that only automatic postings without line items can be made to the account, or select a different account as the clearing account.

  • Line items are not showing in fbl3n,fs10n,faglb03,fagll03

    hi experts,
    i am facing a problem to see the line item of inter unit clearing a/c. i am not able to see the line items in fbl3n,fs10n,fagll03 and faglb03. system response is "You have stored account 300000 in company code L001 as a clearing account. At the same time, you use line item management with this account" and"Error message issued because line item display cannot read data for an account in a ledger if line items exist partially in the entry view together with clearing items for which there are no line items. In such cases, only the data with line items would be selected"
    i do not understand the system response. can anyone please help me to solve this problem?
    thanks &regards
    konishko

    sir
    thanks for your reply. as per your suggestion i am trying to change in fs00 to uncheck the line item management but  i am unable to do that,system shows that i have to uncheck the open item managemt also but the said account contain the open item. so i am not able to change the same. is there any other way to do that. can you please suggest me in detail? and one more thing that i am able to see only the balaces in fs10n. but not able to see the line item.this is probably for missing the business area in line item.
    but i needs to see the line items.
    can you please tell me any alternate way in detail to solve this problem?
    thanks and regards
    konishko

  • Difference between cumulative balance and line items total in FS10N

    hi,
    when I am executing FS10n, I observed that the cumulative balance amount is not equal to line items total .  This is due to some amounts in previous years are varying from the line ltem totals in those periods of previous years.
    This is not happening with QA server only Prdn server is facing this problem.  Can anybody provide me a way to solve this..!?
    Regards,
    AJo
    I have checked the master data for the GL and the check box for line item display is selected. It has not been changed for years.
    Edited by: Anil Jonnalagadda on Oct 22, 2008 10:57 AM

    Hi Anil,
    The reason for the differences that you are viewing can be various. As the differences are found in the cummulative balance then it means that the differences might have occurred in previous fiscal years. The first stetp is to find when these differences were originated: You can run report SAPF190 (in se38) for previous fiscal years, and company code in question- This report should show the differences with message "Errors" in the log. If differences are found then you have to creeate a message and send it to SAP for further analysis and corrections.(only SAP experts can do this kind of corrections - component FI-GL-GL-X)
    Also bear in mind that if you did archiving in previous fiscal years then this would not be an error:
    If you already did archiving and secondary index deletion on this accounts with SAPF048I. So this explains why line items balance and GL summary balance differ ! There is no programm error.
    See consulting note 81489 which describes this issue:
    The balance of an account results from the balance of the open items. In
    connection with an archiving that has been carried out, the line item
    display - used with cleared items - must not therefore be interpreted as
    a balance display. For the balance display, there are separate
    correspond to the display balance of the open items from the line item
    display.
    Having archived and deleted secondary indexes ( with SAPF048I )
    for an account you can not use line item drill down as a balance
    display any more for a line item managed account.
    ( as not all line items are existing any more in table BSIS ! )
    The transactions meant to display the binding balances are  FS10N,
    FK10N and FD10N.
    They also give you the line items details, but only of those line
    items not yet deleted ( by SAPF048I ).
    kind regards,
    Oscar Diaz

  • Total and Line Item dataload (1 or 2 datasources)

    Hi all,
    When realignment happens on R/3 it does not update line items, only totals.
    If you have been loading line items in BW how to you get the new "totals" when realignment happens?  I read the notes that state COPA will decide what table to read when loading (most appropriate).
    Do you need to create 2 datasources (1 for line item and 1 for totals) or does the system know (even when your loading line items) to update totals and read appropriate table?
    Thanks,  Mike

    Hi Manfred,
    Thanks for replying...
    I have a COPA extractor that has line items selected in addition to totals.
    When a realignment happens in R/3 I understand that it updates totals, but not line items. 
    When I load to BW I have a COPA ODS that I am leaving line item information in.  Then updating "totals" to the InfoCube.
    So I am not sure if the "totals" is getting updated after realignment because I have line item char's selected also in my datasource.
    Do I need to worry about this, or simply when a realignment happens all I have to do is re-init and the "totals" will be updated to BW.
    This is why I was asking if I should have 2 COPA datsources, 1 for line item the other for just totals (not selecting any line item char's).  Then just update the line item extractor to ODS and update total extractor to InfoCube.
    Thanks so much.
    Mike

  • "Line items  of Outpput tax a/c  is not  displayed in FBL3N"

    Dear Consultants,
    When I was practicing the following problem is encountered.
    "Line items  of Outpput tax a/c  is not  displayed in FBL3N"
    Thanks in advance,
    Siva

    Hi Siva,
    Isn't the "Line item display" not selected in the GL master (FS00)?
    RFSEPA01 program allows to switch line itme management. Therefore you can excute this via SE38 after first blocking the account for postings temporary. First try this in test sytem (I haven't used this programm for tax accounts so try in test first).
    Regards
    Nadini

  • Message MSITEM033 in New GL - Cannot Display GL Line Items

    Hi All,
    I wonder if you can advise me on a similar issue we are experiencing.
    Recently we activated the New GL. We are now configuring a new company code.
    I have posted documents to a GL account. I can see the items the total balances on the GL account if I run FAGLB03. However, if I try to drilldown into the line items from FAGLB03 I get the message MSITEM033 as below.
    If I run transaction FAGLL03 and execute for the same GL account I still gte the same message. If I run transaction FBL3N I also get the message.
    I check authorizations immediately after each of FAGLB03 and FAGLL03 and it states the last authorization check was successful. Therefore it is not an authorization issue.
    If I run SE16 I can see the data in balance data in FAGLFLEXT and the line data in FAGLFLEXA.
    I can also see the data in GLT0 as we have currently the update to the Classic GL active in parallel.
    The GL Account has the LID (Line Item Display) active but not the OIM (Open Item Management)
    In summary, it appears that the line item disply transactions (classic and New GL) are not working for this new company code. These transactions do work if I post to accounts for existing company codes. That suggests it might be some issue in the configuration of the new company code.
    I have checked the SAPOSS but have not found anyything there for this.
    We are on ECC6 SAP-APPL 604 003 (ie  SAPKH60403)
    Can you advise what can be the issue here please?
    Thanks and regards
    Michael
    No items selected (see long text)
    Message no. MSITEM033
    Diagnosis
    No line items meeting your selection criteria could be read. This could be for the following reasons:
    1.) No corresponding items have been posted.
    2.) You are not authorized to display this data.
    3.) The items have already been archived.

    Hi Hans,
    We had to open this issue with SAP on the OSS Support Site. This is a technical issue which occurs when you use one of the GL Account 'copy' programs (eg RFBISA40 or RFBISA10) to copy GL Accounts from an existing non-New GL company code. In our case we copied from an old (ie pre New GL setup) company code into a company code that had been setup for New GL. That causes the field BSEG-XLGCLR to be filled with a '/' value. That is what causes the issue.
    To get around this the '/' must be deleted from BSEG. SAP advised us a Z report to create. Having done this SAP will then access your system, run the report to detect the affected line items and then clear these up.
    You should log a messaghe on OSS to get the report.
    Regards
    Michael

  • More than 999 line items in Invoice

    Hi All,
    We are having a scenario where more than 999 line items needs to be invoiced in a single billing document. If more than 999 line items are invocied in a single billing document, system can not post the acct document. Our requirement is to create single billing doc for more than 999 and post acct document also successfully.
    Please advise if any one has worked on the simillar issue.
    Thanks,
    Ravi

    Hi,
    You can not do that with 999 line items in one billing document, the reason is the line items limit in the accounting document, because one line item of billing document must generate two line items (D&C) in the accounting document, although you can maintain the max 999 line items in billing document, but actually the max line items of billing document is 499.
    So the other line items more 499 must be generate in a new billing document! Hope can help you understand the scenario.
    Regards
    Tao

Maybe you are looking for