Add a new line item in VA01/VA02 using user exits.

Hi Experts,
I have a problem regarding adding of line items in VA01/VA02. I was able to add a line item but my problem is, there is no validation for the added line. I want SAP to validate it before posting it to database. I'm using USEREXIT_SAVE_DOCUMENT_PREPARE for this one.
I also found out from other threads, that adding line items in XVBAP is not advisable since no checking will be done after USEREXIT_SAVE_DOCUMENT_PREPARE.
I'm thinking if I can use FM DYNP_VALUES_UPDATE on one of the user exits to add a line item in VA01/VA02 and let SAP do the checking and validation. This way, I'm sure that the added line is correct and data integrity will be maintained.
Do you have any comments/suggestions about this?
Thanks a lot,
Arman.

Hi,
I am trying to do this as well but I don't get it working...
I am able to add records to XVBAP, but those never show up in my sales order.
I have found that I should also add records to XVBEP, XKOMV and XKOMP before it will be working, but when I add something to XVBEP I do get a dump on SAVE.
I would like to ask people that managed to get this working to post the code as an example here.
Thanks and best regards,
Marnix

Similar Messages

  • How to insert a new line item in VA01/VA02 by using ABAP code?

    Hi Gurus
    i have a very tough requirement. the customer wants to insert a free goods after an item has been populated in VA01/VA02 automatically according to some certain rules. the input material may be a main material of a sales BOM.
    for example. let's suppose there is a material A who has two sub-material B and C which is maintained in a sales BOM via CS01/CS02. when the material A has been input in the line item in VA01/VA02, its quantity input and after the ENTER key has been clicked, another material D may be displayed in a new line as a gift if the condition met.  the condition relates to customer/material/quanity and these information are stored in a Z-table.
    on the other hand, if the material A is only a single material(not a BOM), the gift(material D) will also be filled automatically if the condition met.
    i have already enhance the FM cs_bom_explosion to filfill the requirment for BOM materials. whereas it is very hard to find the enhanment point for the single material.
    so my question is where is the correct place for me to insert the ABAP code, which decides whether the gift should be given or not and furthermore inserts the new line item into XVBAP. i tried to use MV45AFZZ, whereas the data is always inconsistant if a new line has been inserted. it is very strange that there is no temperary internal table storing line item data input in the table controal of VA01/VA02. system reads the line item data , line by line, via a system kernal function call.
    any hints are welcome. thanks

    HI Stephen,
    I have the same prolem. I modified the 5 global tables, but I don't see the new line in the screen.
    Can you help me with some details?
    Thx!
    Mihaela

  • Insert new line item in va01&va02 - urgent

    Hi frndz,
    At the time of creation standard sales order using va01.
    When user enters the sold to party in header and then
    material & quantity in line item reocrds. After user enters the details in first line. I have some checks to be executed and on the basis of that customer will get the free material that should come on second line item.
    I am getting the details which i will be inserting on new line item but the problem is that in which exit i should write the code for the same.
    So frndz could you please let me know, in which userexit I should insert this new line item. There can be more than one free material.
    If anyone has done this already, please let me know.
    I know one exit i.e.MV45AFZB but in that there are many forms. so exactly which form i should where i will write the code to insert new line item???
    Points will be awarded surely.
    Regards,
    Prashant

    HI Stephen,
    I have the same prolem. I modified the 5 global tables, but I don't see the new line in the screen.
    Can you help me with some details?
    Thx!
    Mihaela

  • To add line items to sales order using User exit.

    Hi ,
    I have to add line items to sales order .
    I have tried adding the code in usr exit move field _VBAP // Check VBAP and in savedocument _prepare . But in all the places I dont see it in VA01 . I can see it in the VA02 and VA03 . But I am not able to save the order as they have made the flooring term as mandatory field, and I am supposed to populate the XVBKD structure for this.
    Pls tell me whts the procedure like say , should I popluate the XVBKD / XVBAP / and should i use the bapi_SALES_ITEM_CHECK to populate the structures at the save_document prepare.

    Hi,
    1. It is not possible to delete records using DTW, only importing new records or updating existing ones are supported. These are the only valid operations via DTW.
    2. It is possible to delete the contents of an edit text field by using the character / or -1. However it is not possible to clear an entire row/line using this notation.
    Thanks & Regards,
    Nagarajan

  • How to add a new line item to a Purchase Requisition number

    Hello All,
    Can anyone please provide me with some FM or BAPI to add a new line item to an existing Purchase Requisition number.
    Can it be done using BAPI_REQUISITION_CHANGE; if yes, then how do I pass the parameters into the BAPI tables..?
    Useful pointers would be appreciated...!!
    Thanks & Regards,
    Tarun Gambhir

    @Gautham,
    Thanks for the quick reply.
    I want to update the table EBAN, so should I use the parameter table XEBAN to put in the new line item and then execute..
    Also to fill up this table I need to pass certain value, so can I use BAPI_REQUISITON_GETDETAIL and pass the same details as found from the same BAPI and create a new line item...
    Regards,
    Tarun Gambhir

  • How can I add a new line item for production order?

    HI all,
    How can I add a new line item for production order through BAPI/FM? Thanks in advance.

    Hi Mil,
      Unfortunetly SAP is not in front of me.
    But if possible go to BAPI transaction , check for any production order's bapi for CHANGE purpose. Where you will be able to add your new line.
    Reward if useful!

  • How to add a new line item when i click on UPDATE in orderpage B2B webshop?

    Hi Gurus,
    I need to add a new line item based on some condition when i click on update in the order page in b2b web shop. Is there any way to pass some parameters to the BADI crm_isa_basket_items and create a new line item when i update? If so can you please tell the parameters that i need to pass to the badi.
    Any help will be highly appreciated!!!!!
    Thanks in advance,
    Lakshman.

    You can put condition when you call java script function while clicking on "update" button.
    On order.jsp  update button call "submit_refresh()" java script function. You can check your condition over here.
    You can find this function in "orderTools.js" file.
    And when you enter item in last line on order page and click on the update button it will automatically add new empty lines on your order page as per your selected new line items from drop down box.
    Or may be you can call your custome action class when you click on update to check particular condition.
    I hope it will help you.
    Thanks and Regards.
    eCommerce Developer

  • Inserting new line item into existing delivery using BAPI

    Hi
    can you send me the code for inserting new line item into existing delivery either using BAPI or
    Function module.
    We are using SAP 4.7 version

    Hi Sreekanth,
    Refer to this links
    New item for outbound delivery via FM/BAPI?
    /message/3976349#3976349 [original link is broken]
    BAPI_OUTB_DELIVERY_CHANGE Help - Add new line item
    hope it is useful to you.
    Regards!

  • To add new Line Items in Accounting Document using BTE

    Hi,
    We have a requirement to add new GL line items while doing PGI through VL02N. The requirement is as below. Please confirm, if we can use BTE 1120 for this and if yes, how to use it to add new line items.
    Orig line items:
    Item PK Acct No USD
    001 99 12200 565.00
    002 81 40000 565.00
    New DESIRED line items:
    Item PK Acct No USD
    001 99 12200 565.00
    002 81 40000 565.00
    003 91 40000 565.00
    004 81 40001 565.00
    Regards
    Sai

    Hi,
    I need to add new line items previously to save the FI document too.
    Could you explain how we can use BTE 1120 to change or add new lines, please?
    I have done a test but it don't work:
    (Function open_fi_perform_00001120_p)
    L_BSEG[] = T_BSEG[].
    Call to the function that handle the BTE, with L_BSEG[] parameter.
    T_BSEG[]  = L_BSEG[].                                "Note 996552
    Then our new values in T_BSEG table are replace for the original table, and our changes are be deleted.
    Thanks in advance,
    Susana

  • Idoc Type to add a new line item to existing Inbound delivery

    Hi Friends,
    we have one requirement.
    In the system Inbound delivery is created through Idoc. Once the inbound delivery is created, we need to change that inbound delivery by adding a new line item to that inbound delivery where the line item belongs to another PO. Means, I have an existing inbound delivery number for a PO having one line item. Now I want to add another line item into the inbound delivery for another PO. I have created the inbound delivery through Idoc using the idoc type DESADV. Now I want to change the inbound delivery for adding the line item. Can anybody please tell me which idoc type should I use for this above highlighted requirement?
    Thanks & Regards
    Satya

    Hi.
    I have one PO 4500000001 for which I have created the inbound delivery 180000001. This inbound delivery has been created through an IDOC. I have another PO 4500000002 having one line item. Now i want to add another line item into the inbound delivery 180000001 for the PO 4500000002 as second line item. To add a second line item to the existing inbound delivery, which IDOC type should I use.
    Hope it clarifies the requriement.
    Thanks & Regards
    Satya

  • Unable to add a new line item to a sales document when hitting save

    Dear All,
    When ever the end user save the sales quotation document, a new line item has to add automatically with a default item with some quantity.
    I am trying to solve this issue with user exit USEREXIT_SAVE_DOCUMENT_PREPARE in SAPMV45A. But it is not allow me to do so. Is there any solution?
    Thanks in advance.
    Regrads,
    Suresh Yerra.

    Write the proper code in USEREXIT_SAVE_DOCUMENT_PREPARE, it will solved.

  • How to ChangePlantfor each item of Sales order using User Exit SAVE_DOCUMEN

    Hi All,
    I have to change plant for Each line item of sales order using (MV45AFZZ) (USEREXIT_SAVE_DOCUMENT) based on first Schedule line.
    if Confirmed Quantity is Less than Ordered Quantity.
    based on first Schedule line.
    it has to select other Plant and need to populate it in line item of sales order.Please see the below code and let me knoe if any changes required... Thanks in Advance.
    data : wa_vbep like xvbep,
           Lv_matnr type mara-matnr,
           lv_werks type marc-werks.
    DATA: it_vbap TYPE STANDARD TABLE OF vbap,
          wa_vbap TYPE vbap.
    field-symbols: <wa_vbap> type VBAPVB.
    clear wa_vbap.
    *loop at xvbap into wa_vbap.
    loop at xvbap assigning <wa_vbap>.
    read table xvbep into wa_vbep with key posnr = <wa_vbap>-posnr.
    if wa_vbep-ETENR = '0001'.
    if sy-subrc = 0.
    IF wa_VBEP-BMENG LT wa_VBEP-WMENG.
        SELECT SINGLE DWERK
                     INTO lv_werks
                     FROM MVKE WHERE matnr = <wa_VBAP>-matnr
                                and  DWERK ne <wa_VBAP>-werks.
    if not Lv_werks is initial.
    if lv_werks EQ 1033.
    move '1002' to <wa_vbap>-werks.
    if sy-subrc eq 0.
      xvbap-werks =  <wa_vbap>-werks.
    modify xvbap from <wa_vbap> .
    endif.
    elseif lv_werks EQ 1003.
    move '1003' to <wa_vbap>-werks.
    elseif lv_werks EQ 1010.
    move '1010' to <wa_vbap>-werks.
    endif.
    endif.
    endif.
    endif.
    endif.
    endloop.
    endif.
    Regards,
    Sudhakar Reddy.A

    You have to use the form routine "USEREXIT_SAVE_DOCUMENT_PREPARE"
    regards
    Vinod

  • New Line Item in VA01

    Hi,
    I need to create a sales order in VA01. So when enter the material number, it should check the available stock in table mchb. Once this in done, it should dispay all the batches that is required for the material.
    For ex -  Material Number (001) and quantity 100. From MCHB, I have 5 batches for the material 001.
    Batch     Quantity
    01            10
    02            85
    03            50
    04            10
    05            30
    So, it should display 3 item now with batch 01,02 and 03. I managed to get this item and append to xvbap but having difficulities to display it.
    PLEASE HELP. Thanx..

    Hi,
    I am trying to do this as well but I don't get it working...
    I am able to add records to XVBAP, but those never show up in my sales order.
    I have found that I should also add records to XVBEP, XKOMV and XKOMP before it will be working, but when I add something to XVBEP I do get a dump on SAVE.
    I would like to ask people that managed to get this working to post the code as an example here.
    Thanks and best regards,
    Marnix

  • Add New Line item while creating a new PO in ME21N

    Hi All,
    I have a requirement to add a new line item when user is pressing enter on the Line item 1 based on some condition.
    I am using the BADI 'ME_PROCESS_PO_CUST' and Method is 'PROCESS_ITEM'.
    I have tried lots of options and also look for method 'Create_Item ' but not able to understand what exactly I need to pass in that method.
    Can somebody elaborate on it if somebody has work on it? Even sample code will also help me.
    Thanks in advance.
    With regards
    Sachin Gupta

    Hi Sachin,
    Please find the sample code :
    METHOD if_ex_me_process_po_cust~process_item .
      DATA: ls_mepoitem TYPE mepoitem,
            ls_customer TYPE mepo_badi_exampl,
            ls_tbsg     TYPE tbsg.
    * here we check customers data
      ls_mepoitem = im_item->get_data( ).
      IF ls_mepoitem-loekz EQ 'D'.
    * a physical deletion of the item was carried out. therrefor we have to
    * delete customer data on the level of the item
        ls_customer-ebeln = ls_mepoitem-ebeln.
        ls_customer-ebelp = ls_mepoitem-ebelp.
        CALL FUNCTION 'MEPOBADIEX_SET_DATA'
          EXPORTING
            im_data                    = ls_customer
            im_physical_delete_request = 'X'.
      ELSE.
    * update/insert operation
        CALL FUNCTION 'MEPOBADIEX_GET_DATA'
          EXPORTING
            im_ebeln = ls_mepoitem-ebeln
            im_ebelp = ls_mepoitem-ebelp
          IMPORTING
            ex_data  = ls_customer.
    * check customers data
    * check field badi_bsgru. This should be carried out only for new items. Once the PO is posted the
    * field should no longer be changeable. This is done in Method FIELDSELECTION_ITEM.
        IF im_item->is_persistent( ) EQ mmpur_no.
          IF ls_customer-badi_bsgru IS INITIAL.
    * Place the cursor onto field badi_bsgru. The metafield was defined in BAdI ME_GUI_PO_CUST,
    * Method MAP_DYNPRO_FIELDS.
            mmpur_metafield mmmfd_cust_01.
            mmpur_message_forced 'W' 'ME' '083' text-002 '' '' ''.
          ELSE.
    * check whether the field is valid
            SELECT SINGLE * FROM tbsg INTO ls_tbsg WHERE bsgru EQ ls_customer-badi_bsgru.
            IF NOT sy-subrc IS INITIAL.
              mmpur_metafield mmmfd_cust_01.
              mmpur_message_forced 'E' 'ME' '083' text-004 '' '' ''.
    * invalidate the object
              CALL METHOD im_item->invalidate( ).
            ENDIF.
          ENDIF.
        ENDIF.
    Try to check the import and export paremeters to pass the vales.
    I hope this may helpfull.
    Thank you,
    Thanks,
    AMS

  • Add New line item from Quote to Contract using CRM_ORDER_MAINTAIN

    HI Gurus,
    I need to add a new line item with entire item details such as SALES PRICING etc in contract,
    i am confused like what are the parameters i need to pass to FM CRM ORDER MAINTAIN,
    Please help me on this regard.
    Thanks & regards.

    Experts,
    any luck i have please help me on the same.
    Thanks.

Maybe you are looking for