BAPI_BILLINGDOC_CREATEMULTIPLE u0096 Duplication of line item in billing docume

Hi All,
I am using BAPI “<b>BAPI_BILLINGDOC_CREATEMULTIPLE</b>” to create billing document. Creation of billing document is fine, but issue is I am passing individual line item along with <b>quantity</b> to be billed. But what’s happening is if I got 3 item line in sales order with quantity 1-3-5, billing document getting created 3 quantity ‘1’, 3 quantity ‘3’ and 3 quantity ‘5’. So I end up with 9 line item on billing document which is incorrect.
Please see the code below which I am using, can anyone tell me what I am doing wrong here. I basically need to create 3 billing line item with respective quantity I pass. Any hint is much appreciated. Thanks in advance.
Regards,
Tim
loop at GT_INIT_ITAB2 into GS_INIT_ITAB2.
    select single * into gs_vbak
                    from vbak
                    where vbeln = GS_INIT_ITAB2-VBELN.
    select single * into gs_vbap
                   from vbap
                   where vbeln = GS_INIT_ITAB2-VBELN AND
                         posnr = GS_INIT_ITAB2-posnr.
    select single * into gs_mara
                   from mara
                   where matnr = gs_vbap-matnr.
    refresh GT_BILLINGDATAIN.
    GT_BILLINGDATAIN-SALESORG   = gs_vbak-vkorg.
    GT_BILLINGDATAIN-DISTR_CHAN = gs_vbak-vtweg.
    GT_BILLINGDATAIN-DIVISION   = gs_vbak-spart.
    GT_BILLINGDATAIN-DOC_TYPE   = GS_INIT_ITAB2-auart.
    GT_BILLINGDATAIN-ORDBILLTYP = p_fkart.
    GT_BILLINGDATAIN-SOLD_TO    = GS_INIT_ITAB2-kunnr.
  GT_BILLINGDATAIN-ITEM_CATEG = GS_INIT_ITAB2-pstyv.
    GT_BILLINGDATAIN-REQ_QTY    = GS_INIT_ITAB2-kwmeng.
    GT_BILLINGDATAIN-SALES_UNIT = gs_vbap-vrkme.
    GT_BILLINGDATAIN-CURRENCY   = gs_vbak-waerk.
    GT_BILLINGDATAIN-SHORT_TEXT = 'Test'.
    GT_BILLINGDATAIN-BILL_DATE   = gl_date.
write GS_INIT_ITAB2-afdat to GT_BILLINGDATAIN-BILL_DATE ddmmyy.
GT_BILLINGDATAIN-BILL_DATE  = GS_INIT_ITAB2-afdat.
    GT_BILLINGDATAIN-PRICE_DATE = SY-DATUM.
    GT_BILLINGDATAIN-REF_DOC    = GS_INIT_ITAB2-VBELN.
    GT_BILLINGDATAIN-DOC_NUMBER = GS_INIT_ITAB2-VBELN.
    GT_BILLINGDATAIN-ITM_NUMBER = GS_INIT_ITAB2-POSNR.
  GT_BILLINGDATAIN-ORIGINDOC  = GS_INIT_ITAB2-VBELN.
    GT_BILLINGDATAIN-ITEM       = GS_INIT_ITAB2-POSNR.
    GT_BILLINGDATAIN-NO_MATMAST = co_x.
    GT_BILLINGDATAIN-COUNTRY    = 'AUS'.
    GT_BILLINGDATAIN-MATERIAL   = gl_matnr.
    GT_BILLINGDATAIN-TAXCL_1MAT = '1'.
    GT_BILLINGDATAIN-REF_DOC_CA = 'C'.
    append GT_BILLINGDATAIN.
  endloop.
Prepare for BAPI call
    CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE'
      EXPORTING
        CREATORDATAIN         = GS_CREATORDATAIN
      TESTRUN               = co_x
      POSTING               = co_x
      TABLES
        BILLINGDATAIN         = GT_BILLINGDATAIN
    CONDITIONDATAIN       = GT_CONDITIONDATAIN
    CCARDDATAIN           =
    TEXTDATAIN            =
    ERRORS                =
        RETURN                = GT_RETURN
        SUCCESS               = GT_SUCCESS
    clear gl_return.
    loop at GT_RETURN.
      if GT_RETURN-type EQ 'E' OR
         GT_RETURN-type EQ 'A'.
        move: GT_RETURN to gl_return.
        exit.
      endif.
    endloop.
    if gl_return is initial.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
     EXPORTING
      WAIT   = '1'
        IMPORTING
          RETURN = gt_return_commit.
    endif.

Hi,
Check this code...For creating billing document from sales order..
TABLES: vbak.
PARAMETERS: p_vbeln LIKE vbak-vbeln OBLIGATORY,
            p_fkart LIKE vbrk-fkart.
DATA:
s_vbsk LIKE  vbsk.
DATA:
xkomfk     LIKE     komfk    OCCURS 0 WITH HEADER LINE,
xkomv     LIKE     komv     OCCURS 0 WITH HEADER LINE,
xthead     LIKE     theadvb  OCCURS 0 WITH HEADER LINE,
xvbfs     LIKE     vbfs     OCCURS 0 WITH HEADER LINE,
xvbpa     LIKE     vbpavb   OCCURS 0 WITH HEADER LINE,
xvbrk     LIKE     vbrkvb   OCCURS 0 WITH HEADER LINE,
xvbrp     LIKE     vbrpvb   OCCURS 0 WITH HEADER LINE,
xvbss     LIKE     vbss     OCCURS 0 WITH HEADER LINE.
SELECT SINGLE * FROM vbak
       WHERE vbeln = p_vbeln.
IF sy-subrc <> 0.
  MESSAGE s208(00) WITH 'Invalid vbeln'.
  LEAVE LIST-PROCESSING.
ENDIF.
CALL FUNCTION 'RV_INVOICE_REFRESH'
     EXPORTING
          with_posting = 'B'
     TABLES
          xkomfk       = xkomfk
          xkomv        = xkomv
          xthead       = xthead
          xvbfs        = xvbfs
          xvbpa        = xvbpa
          xvbrk        = xvbrk
          xvbrp        = xvbrp
          xvbss        = xvbss.
DATA: BEGIN OF t_vbap OCCURS 0,
        vbeln TYPE vbeln,
        posnr TYPE posnr,
      END OF t_vbap.
SELECT vbeln posnr INTO TABLE t_vbap
       FROM vbap WHERE vbeln = p_vbeln.
LOOP AT t_vbap.
Fill the values.
  xkomfk-mandt  = sy-mandt.
  xkomfk-vbeln  = p_vbeln.
  xkomfk-posnr  = t_vbap-posnr.
  xkomfk-vbtyp  = vbak-vbtyp.
  xkomfk-seldat = sy-datum.
  xkomfk-fkart  = p_fkart.
  xkomfk-fkimg  = '1.000'.
  xkomfk-vrkme  = 'EA'.
  APPEND xkomfk.
ENDLOOP.
CALL FUNCTION 'RV_INVOICE_CREATE'
     EXPORTING
          vbsk_i       = s_vbsk
          with_posting = 'B'
     IMPORTING
          vbsk_e       = s_vbsk
     TABLES
          xkomfk       = xkomfk
          xkomv        = xkomv
          xthead       = xthead
          xvbfs        = xvbfs
          xvbpa        = xvbpa
          xvbrk        = xvbrk
          xvbrp        = xvbrp
          xvbss        = xvbss.
READ TABLE xvbfs WITH KEY msgty = 'S'.
WRITE:/ sy-subrc.
WRITE:/ xvbfs-msgv1,xvbfs-msgv2,xvbfs-msgv3.
Thanks,
Naren

Similar Messages

  • Is it possible to have more than one Tax code per line item in Billing docu

    Is it possible to have more than one Tax code per line item in Billing document ?

    Hi,
    I have a different perspective there.
    If an item is applicable for two different taxes which are represented by two different tax condition types and these tax conditions are configured in the tax procedure, FTXP and so on....then these two condition records can have two different tax codes.
    We actually have this scenario in EU now, where EU talks about service tax in 2010 apart from the normal VAT. So now we have MWST and ZWST(Say)
    Now there are some materials which come with a service associated with it. So a service charge is also levied when the material is sold. So the material price will become applicable for VAT and the service charge becomes applicable for service tax. In this case, the tax classification of the customer will have two entries in sales orders updated in the fields VBAK-TAXK1 and VBAK-TAXK2 based on the sequence number of these condition types.
    Now based on different tax classification of the customer, we have 2 different tax codes representing different %of tax.
    Hope it helps

  • Can we change pricing date for line item in billing

    Hi Expert,
    Can we change pricing date , while raising inoice for particular line iteam

    Hi,
    We can not change the pricing date for perticular line item at billing document level, the only option is we can enter the required date at the time of invoice creation in VF01 screen.
    If your requirement is copying the same pricing date that is entered at sales order, then do the following.
    Go to T Code:VTFL and choose your DElivery Type and Billing Type, then choose your item category and then change the pricing type as 'D' .
    Regards,
    Pasapula.

  • How to read product characteristics of a line item in Billing document?

    Hi Friends,
        I need to read the product characteristics of a line item in Billing document. Can you please help me with which tables or function modules I should use?
    Thanks in advance.
    Regards
    Jaker.

    Hi,
    Use the following BAPI's:
    BAPI_OBJCL_GETDETAIL
    or use the fun module:
    CLAF_CLASSIFICATION_OF_OBJECTS.
    Regards
    ANJI

  • How to increase line item in billing document

    Hi
    I know that maximum line item in billing is 999, but my requirement is to increase the line item number may be up to 9999. Is there any way
    Kindly replay.
    Thanks in advance
    Vinod

    Hello,
    I don't think there is a standard settings for this, you need to think of an enhancement, check with your ABAP expert.
    Prase

  • Multiple line item in billing but only one line item in accounting document

    Hi Everyone,
    I am having one scenario in which sales order has more than one line item. Only one billing document is create for all line items in Sales Order but billing document contains as many items as sales order has. In accounting document of billing i find only one customer line which has total amount of all line items in billing as debited. My requirement is Accounting document also should have as many line of customer-debit as in billing items i.e sales order. For example :
    (1) Sales order has 2 line items.
    (2) Billing document is only ONE and has 2 line items
    (3) currently accounting document has only ONE line of Customet - Debit ( Total amount of both items)
    My requirement is
    Accounting document should have 2 line item of customer - Debit
    Customer - Debit (amount of first line item)
    Customer - Debit (amount of Second line item)
    Sales - Credit
    How can it be done ?
    Regards,
    Manish

    Hi,
    This is the SAP expected behaviour
    As far as the values correspond to same account key and same GL account as per account determination, then ti will be posted as a single line item in FI document.
    If you want the customer specific items to be posted in two GL accounts , then you have to do the account determination that way.
    For example, you should have a condition table in FICO as follows.
    Sales org/ Account key / Customer
    For this condition table, the entries shoudl be as follows.
    5110/ERS/Customer A  GL ACCOUNT IS 5000100
    5110/ERS/Customer B GL ACCOUNT IS  5000200
    In this case, there will be 2 entries for the invoice instead of just one line entry.

  • Total line items in billing document

    Dear Fnds,
    I want to Find total line items in Billing document VBRk-posnr
    Thanks in advance
    Regards
    raj.

    Hi,
    You can get the line items details in internal table then write the following command:
    DESCRIBE TABLE itab LINES lv_lines.
    In Lv_lines you will get the count for that Sales Order Number (VBELN).
    Hope this may be useful..
    Regards,
    Prashant

  • TXT Type in Line Item for Billing

    Hi Folks !
    I am trying to create a text type in Billing Line Item, but I want my user to enter numerics only.
    Will it be possible to configure ?
    Rgds,
    Indrajit Dey

    Yes this setting is there in the Financail Accounting :
    SPRO. Financial Accounting> Document --> Define Text for the Line Items.
    reward points if helpful.
    Amlan Sarkar
    Mumbai Thake...............

  • Line item wise billing

    Hi All,
    Can we do sale order related billing for individual line item wise and quantity wise?
    If this is for delivery related billing then the setting will be in item category, billing relevance as K. But what will be the settings for order related billing?
    Kumar

    Hi,
    In two ways you can achieve your requirement.
    1.Goto the T.Code VF01
    Enter your sales order number.Donot press Enter.
    Click on "Selection list".
    Select your items.Click on Copy.
    Save the invoice.In "VOV7" T.Code maintain the billing relevance as "C".
    2.Goto the T.Code "VA02".
    Double click on the item.Goto Billing document tab.
    Maintain the billing block under "Billing" tab.
    Save.
    Goto the T.Code "VF01".Enter your order number.
    Create the billing document.
    Next Goto VA02 and remove the another block.
    Create the invoice.
    Regards,
    Krishna.

  • Line items in billing

    Hi Friends,
    I did batch split into 2 batches for a line item in delivery. Now in billing if one of my client asked to display this line item without batches i.e., in single line item total quantity delivered, what should I do the settings. And if another client asked to display with batches i.e., only two line items for that single material, what should I do the settings?
    Urgent please.
    Regards
    Ramesh

    Hi Ramesh,
    We have the same requirement.  Were you able to figure out the solution? If yes, please let us know.
    Thanks
    Rajeev

  • SO Multiple Line Items but one line item in billing

    Hi Experts,
    I have a requirement from a client whereby they want to consolidate the items in the sales order and create billing as one line item.
    Example: in sales order there are 5 line items (user need to have separate line items due to PR need to be generated for different vendors via 3rd party).
    Line item 10: Miscellaneous charges - $20.00
    Line item 20: Miscellaneous charges - $20.00
    Line item 30: Miscellaneous charges - $20.00
    Line item 40: Miscellaneous charges - $20.00
    Line item 50: Miscellaneous charges - $20.00
    In standard SAP, when the user generates billing document - the billing will show 5 line items. However user wants to consolidate them into 1 single line item  i.e. Miscellaneous charges - $100.00
    Please advice how can this be done.
    Rgds

    Hi,
    Go to Tcode : VTFL.
    There select your  Billing Type with respect to Delivery type. e.g F1 --- LF or F2 -
    LF.
    Select thet option and goto Items.
    There at item level , select the item category of your materials. There In Details :
    Maintain Billing Quantity : H as Cumulity Batch Quantity.
    Let me know weather is has solved ur problem or not.
    Thanks.

  • Report for conditions per line item in Billing document

    Hi all,
    Is there any report that can tell me all the price conditions that are allocated to a billing document line item? I am talking about the actual conditions relevant for a line item, not only conditions that have a condition record setup.
    So I would like to key in billing document number, the line item and get a report of all conditions that are allocated to that line item in the specific billing document.
    If there is no such standard report, does anyone know what tables to link?
    Thanks in advance,
    Lars

    Hi,
    Tables VBRK and VBRP. And with field VBRK-KNUMV go to table KONV to obtain the data of all conditions.
    Regards,
    Eduardo

  • Add or Delete Line Item in Billing Creation (VF01)

    Hi,
    During the billing document creation (VF01) for Order-Related Billing (example: Doc Type F5 - Pro Forma for Order), can you
    manually add or delete line items?
    Let's say if Sales Order was created with 3 line items and only 2 line items should be included in Billing Doc F5.  During the
    billing document creation (VF01), it automatically copies all 3 line items.  How can I delete the line item that I don't want
    to be included in Billing Doc F5?  Only way that I know is to put a billing block on Sales Order item so it won't automatically
    copied into a billing document.  But this process is inconvenient.  After F5 document is created, my user will then need to
    remember to go back to Sales order and remove a billing block from that line item.
    Also vice verse, can an item be manually added to a billing document during the creation mode (VF01)?  Is there somewhere
    in the configuration that I can change to allow this?  Or is it a standart SAP practice all items on a billind document have to
    be Order or Delivery-Related?
    Thanks,
    Michelle

    Hi,
    While creating the invoice via VF01. Please go to selection list icon. this will take to you another screen. here you can select the line item you want to copy/bill.
    Please try and let us know.
    Thanks,
    Vishal

  • Extra accouning line item in billing document with zero value

    Hi,
    I am using TAXINN procedure, the following accounting document has been generated during billing.This accounting document contains an extra line item with zero value.
    However, There is no necessary for this line item with zero value. Can you tell me how to remove this line item?
    000       50          VAT Payable                       A0             0.00
    001       01          Sale within state                 A0      1,212.00
    002       50          Sales f/goods-Dome.          A0      1,000.00-
    003       50          ED Collected Clr.                 A0          160.00-
    004       50          ED Collected Clr.                 A0              3.00-
    005       50          ED Collected Clr.                 A0              2.00-
    006       50         VAT Payable                      A0            47.00-
    Thanks,
    Kanhu

    Hi
    Check if there is any summarization active for billing documents generated through SD. The path for the same is:
    IMG>Financial Acxounting>General Ledger Accounting>Integration>Sales & distribution
    Check for table VBRK
    Regards
    Sanil  K Bhandari

  • Sales bom line item in billing for information

    Dear All,
    I have the scenario of Header pricing and line item stock reduction.
    Now  the client needs in the billing the line item of header should appear for only information purposes.
    Please suggest how can we do this
    how do we do this?

    HI,
    please go to the item category TAE, there u  wl find a field statistical value , enter X there.
    i think ur problem wl b solved.
    rewards welcome.
    cheers

Maybe you are looking for