Reg logic to get sales docu no

i need logic to get the highest value and corresponding sales order no placed by the customer belonging
to a credit control area for previous and current fiscal year.

Hi Orlang,
You have VBELN (Sales Order No) in MSEG table as KDAUF also. check once
You can use MBLNR field available in both table to join them
SELECT c~mblnr c~kdauf c~kdpos
       INTO CORRESPONDING FIELDS OF TABLE itab
       FROM  mseg AS c
         INNER JOIN mkpf AS p ON p~mblnr   = c~mblnr.
Cheerz
Ram
Edited by: Ramchander Krishnamraju on Nov 19, 2009 7:18 AM

Similar Messages

  • Getting Sales document data from VBKD to the Account Receivable Line items

    Hi Friends,
    We have to enhance 0FI_AR_4 With the Sales data from the VBKD Table where we can have Sales document Number.
    Can you please let me know how to make link with FI-AR  Accounting document with Sales documewnt. So that I can get data from the VBKD table.
    Thanks &Regards,
    Revathi

    Hi,
    Sales document(VBELN) is already avialable in 0FI_AR_4. Also see the link  http://help.sap.com/saphelp_tm80/helpdata/en/70/10e73a86e99c77e10000000a114084/content.htm.
    Regards,
    Prakash

  • Get Sales Document number from Project Defintion,WBS,N/w,N/w Activity

    dear all,
      I am working in PS module ,
    I need to get the sales document no from Project definition ,WBS element ,N/w and N/w activity .
    plz let me know any FM or the table relatio to get the Sales document Number .
    Note :
       In AFKO table i have a field called RMANR(sales Docu)  this field is always empty . Kindly
       give any other solution .
    Regards,
      Vinoth.v

    Hi Vinoth ,
    Please refer the below link for Some of the SAP-PS Master and transaction tables.
    [http://www.sapfans.com/sapfans/forum/logps/messages/1347.html]
    Project and Sales Doc Number Relation
      AFKO  and PROJ linked with field PRONR.
    WBS and Sales Doc Number relation
    VBAK                           PS_PSP_PNR                     PRPS
    VBAP                           PS_PSP_PNR                     PRPS
    You can use the Program  RSPRTBEZ to get those relation between the tables. Above mentioned table details have been taken through the same.

  • In BI SD how to get Sales Document wise Order Delivery and balance Quantity

    We are on the verge of SAP BI implementation. We are facing a problem as in BI we have to
    show Sales Order wise - Order Quantity then associated all the deliveries and the Quantity delivered
    and finally Billed Quantity
    Format Required is
    Order No         Order Qty      Delivery Qty     Billed Qty
    We are using 0sd_c03 cube here Order , delivery and Billing come as separate Line items
    Now bringing them to one line item is a chellange for us
    can any body help us
    Thanks
    Shivani

    Hi,
    Merging of Order, delivery and billing information is not so easy.
    In ECC we have a new datasource for Open order quntity against delivery available check those datasources once may be useful.
    [Extraction SD Sales: Order Delivery|http://help.sap.com/saphelp_nw04/helpdata/en/21/ca6d07d5b807459ec8957dad97c179/frameset.htm]
    --> This datasouce provides information regarding order qty, delivered qty and status. But no billing related information available.
    --> Pull billing information into a separate datasource and merge using sales doc no (with reference doc no in billing). to get billing related info.
    --> Multiple orders can be billed together, so distribution may not be correct. check ...
    Hope it helps
    Srini

  • Reg-Round off in sales documents

    Dear all
    I need a solution for given below point.
    For Purchase and local sales there should option for rounded off on total amount,but incase of export sales roundoff should not effect.
    Please kindly suggest.
    Regards
    M Auditya
    Functional Consultant

    hi,
    There is no system functionality in rounding off for local / export sales.
    Check document for rounding off in below link
    https://websmp201.sap-ag.de/~sapidb/011000358700000243172007E/CW12_Learn_about_Rounding.pdf
    Jeyakanthan

  • How to right a logic to get sales order from agnetry in salesordercreateBAPI

    I am working on a Agentry project where I need to get the Sales Order number from backend SAP, for any newly created SalesOrder. When the User creates a new Sales order, he gets a local order id on the client device. When the user transmits data, the Original Sales Order number should be fetched from the backend.
    Kindly help me to create the JAVA coding for this task.
    Regards,
    Sumit Goyal
    Tags edited by: Michael Appleby

    Hello Surya,
    There is no such direct way to get the data but you can follow the below process.
    You can get this details by defining/designing a new Query.
    To develop a new query
    1. use SQ01 through infoset create query
    2. Use SQVI direct query by giving table.
    Purchase Requision :-
    Use Table EBKN  for the same and give field VBELN as selection field. Input your sales order it will give you the purchase requisitions exist against the sales order at output level.
    Purchase Order :-
    Use Table EKKN  for the same and give field VBELN as selection field. Input your sales order it will give you the purchase orders exist against the sales order at output level.
    Hope it will help.
    Regards
    AG.

  • MV45AFZB, MV45AFZZ  (VA01) Sales Document No

    Hi All,
    I have created screen exit for sales order creation tcode, and storing some data in ztable,
    everything is fine till here, only problem is i am not getting sales document number at the time of save event which should be captured at run time when number is getting generated.
    can anyone suggest which field i should pass to store sales doc no,
    i am updating,Inserting data in MV45AFZZ, subrtn USEREXIT_SAVE_DOCUMENT.
    Thanks
    sujeet

    Hi Sujeet Mishra,
    try with
    XVBAK-VBELN
    or
    YVBAK-VBELN
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7
    ilesh Nandaniya

  • Sales document number based on pricing procedure ,sales area , customer pri

    Hi,
    where can i get saler document number based on pricing procedure ,sales area , customer pricing procedure and document pricing procedure.
    please tell me the table name.
    Thanks
    Edited by: pandu123 on Jun 16, 2011 8:22 PM

    I never heard of this requirement before, pulling sales document number based on pricing procedure based on customer pricing proc + document pricing procedure +sales area. These data are found in tables VBAK, T683,KNVV and TVAK. I dont think you can use ABAP query to join these table, check with an ABAP'er to develop a program for this requirement.
    Regards,

  • FM to get sales order details with billing document .

    hi ,
    is there any standard FM or BAPI to get the sales order details with input as billing document ?
    i have the billing document number now i need to get the sales order number and its details ..
    is that possible ..
    i very well know how to get it by using query, i need standard FM.
    Points will be awarded for sure , if it helps .
    Thanks and regards
    JK

    Here is the list of BAPIs
    BAPI_QUOTATION_GETDETAILBOS
    BAPI_INQUIRY_GETDETAILBOS
    BAPI_SALESORDER_GETDETAILBOS
    SALES ORDER->
    BAPISDORDER_GETDETAILEDLIST Sales Order: List of All Order Data
    BAPI_ORDER_CHANGE_STATUS_GET Change status for order
    BAPI_SALESDOCU_CREATEFROMDATA Creating a Sales Document
    BAPI_SALESORDER_CHANGE Sales Order: Change Sales Order
    BAPI_SALESORDER_CREATEFROMDAT1 Sales Order: Create Sales Order
    BAPI_SALESORDER_CREATEFROMDAT2 Sales Order: Create Sales Order
    BAPI_SALESORDER_CREATEFROMDATA Create sales order, no more maintenance
    BAPI_SALESORDER_GETLIST Sales order: List of all orders for customer
    BAPI_SALESORDER_GETSTATUS Sales order: Display status
    BAPI_SALESORDER_SIMULATE Sales Order: Simulate Sales Order

  • How can I get the correct Ship To (KNVP-KUNNR2) for a Sales Document?

    I am trying to generate a report that will (among other things) display the Ship To ID and Name for a given Sales Document.  I know the following information:
    VBAK-VBELN - Sales Document
    VBAK-VKORG - Sales Org
    VBAK-VTWEG - Distribution Channel
    VBAK-SPART - Division
    VBAK-KUNNR - Sold To Party
    I know that the table KNVP will return a list of Ship-To Customer numbers (KUNNR2) for a Sold-To Customer (VBAK-KUNNR) if I also filter by VKORG, VTWEG, and SPART (using SE16N).  What I don't know is which one of the returned values is being used in a particular Sales Document.  The customer in question has 29 Ship-To locations.  How do I find out which Partner Counter (KNVP-PARZA) the Sales Document uses? I don't know where that value would come from.  Once I can get the correct Ship-To Customer Number, I should be able to search the table KNA1 by WHERE KUNNR = KNVP-KUNNR2 and return KNA1-NAME1 for the Name of the Ship-To location.

    For a sales document?  Use VBPA with PARVW = 'WE'.  Also, use the ADRDA field to determine whether the address on the document has been manually changed.  In any case, you can use one of the many address management functions or just ADRC directly to get the name, address, etc., using the ADRNR field from VBPA or if the address is from the customer master, KNA1.

  • Getting valid idoc number from the sales document

    hi,
    Iam sending the code for getting the idoc number from sales document.
    but iam not getting the result.
    please see the code and correct the code so that i will get the idoc number from the sales document.
    tables edid4.
    data l_docnum like edid4-docnum.
    parameters:p_vbeln like vbak-vbeln.
    call function 'CONVERSION_EXIT_ALPHA_INPUT'
      exporting
        input         = p_vbeln
    IMPORTING
       OUTPUT        = p_vbeln
    select single docnum from edid4 into l_docnum where sdata like '&p_vbeln&'.
    if sy-subrc = 0.
    write edid4-docnum.
    else.
    write ' the record is not found'.
    endif.
    it is very urgent..............
    thanks in advance......

    See the below code :
    report zxyz.
    tables edid4.
    data l_docnum like edid4-docnum.
    parameters:p_vbeln like vbak-vbeln.
    <b>data sdata like edid4-sdata.</b>
    start-of-selection.
    call function 'CONVERSION_EXIT_ALPHA_INPUT'
    exporting
    input = p_vbeln
    IMPORTING
    OUTPUT = p_vbeln
    <b>concatenate '%' p_vbeln '%' into sdata.</b>
    select single docnum from edid4 into l_docnum
                  where sdata like <b>sdata.</b>
    if sy-subrc = 0.
    write edid4-docnum.
    else.
    write ' the record is not found'.
    endif.
    Thanks
    Seshu

  • Service or Discount Condition to get printed in Sales Document.

    Today we use materials and services during the sales orders creation, but the services go directly to billing without passing by the delivery document. We are offering a $3.50 USD Coupon to the Customers and I want to see it printed in the Sales Order when the sales is completed. I tried creating a Condition a header level, it works and I can automate the discount during the price determination, etc. But it doesn't get printed in the Customer Document.
    How Can I get this discount printed in the sales document using either a Service and/or a Condition?

    In V/08 pricing procedure maintain the printing indicator to print. If you allready maintain that indicator for your condition type then check with the ABAPer for the same.
    Regards,
    Ramesh

  • Reg: Sales document creation

    Hi Abapers,
    As i am new to SD Module, would like to get some ideas from your end. My requirement is to create a sales order using Programming. After creation of sales order it should post to finance. Could anyone help me how this can be done.

    REPORT  ZSALESORDER.
    * Parameters
    * Sales document type
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text FOR FIELD p_auart.
    PARAMETERS: p_auart TYPE auart OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    * Sales organization
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text1 FOR FIELD p_vkorg.
    PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    * Distribution channel
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text2 FOR FIELD p_vtweg.
    PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    * Division.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text3 FOR FIELD p_spart.
    PARAMETERS: p_spart TYPE spart OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    SKIP 1.
    * Sold-to
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text4 FOR FIELD p_sold.
    PARAMETERS: p_sold  TYPE kunnr OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    * Ship-to
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text5 FOR FIELD p_ship.
    PARAMETERS: p_ship  TYPE kunnr OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    SKIP 1.
    * Material
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text6 FOR FIELD p_matnr.
    PARAMETERS: p_matnr TYPE matnr   OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    * Quantity.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text7 FOR FIELD p_menge.
    PARAMETERS: p_menge TYPE kwmeng  OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    * Plant
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text9 FOR FIELD p_plant.
    PARAMETERS: p_plant TYPE werks_d .
    SELECTION-SCREEN END OF LINE.
    * Complete Deliver
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text10 FOR FIELD p_autlf.
    PARAMETERS: p_autlf TYPE autlf DEFAULT 'X'.
    SELECTION-SCREEN END OF LINE.
    * Data declarations.
    DATA: v_vbeln            LIKE vbak-vbeln.
    DATA: header             LIKE bapisdhead1.
    DATA: headerx            LIKE bapisdhead1x.
    DATA: item               LIKE bapisditem  OCCURS 0 WITH HEADER LINE.
    DATA: itemx              LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
    DATA: partner            LIKE bapipartnr  OCCURS 0 WITH HEADER LINE.
    DATA: return             LIKE bapiret2    OCCURS 0 WITH HEADER LINE.
    DATA: lt_schedules_inx   TYPE STANDARD TABLE OF bapischdlx
                             WITH HEADER LINE.
    DATA: lt_schedules_in    TYPE STANDARD TABLE OF bapischdl
                             WITH HEADER LINE.
    DATA: lt_schedules_ink    TYPE STANDARD TABLE OF bapisdhead1
                             WITH HEADER LINE.
    * Initialization.
    INITIALIZATION.
    v_text   = 'Order type'.
    v_text1  = 'Sales Org'.
    v_text2  = 'Distribution channel'.
    v_text3  = 'Division'.
    v_text4  = 'Sold-to'.
    v_text5  = 'Ship-to'.
    v_text6  = 'Material'.
    v_text7  = 'Quantity'.
    v_text9  = 'Plant'.
    v_text10 = 'Complete delivery'.
    * Start-of-selection.
    START-OF-SELECTION.
    * Header data
    * Sales document type
      header-doc_type = p_auart.
      headerx-doc_type = 'X'.
    * Sales organization
      header-sales_org = p_vkorg.
      headerx-sales_org = 'X'.
    * Distribution channel
      header-distr_chan  = p_vtweg.
      headerx-distr_chan = 'X'.
    * Division
      header-division = p_spart.
      headerx-division = 'X'.
      headerx-updateflag = 'I'.
    *Complete delivery
        header-COMPL_DLV = p_autlf.
        header-COMPL_DLV = 'X'.
    * Partner data
    * Sold to
      partner-partn_role = 'AG'.
      partner-partn_numb = p_sold.
      APPEND partner.
    * Ship to
      partner-partn_role = 'WE'.
      partner-partn_numb = p_ship.
      APPEND partner.
    * ITEM DATA
      itemx-updateflag = 'I'.
    * Line item number.
      item-itm_number = '000010'.
      itemx-itm_number = 'X'.
    * Material
      item-material = p_matnr.
      itemx-material = 'X'.
    * Plant
      item-plant    = p_plant.
      itemx-plant   = 'X'.
    * Quantity
      item-target_qty = p_menge.
      itemx-target_qty = 'X'.
    * item category
      itemx-ITEM_CATEG = 'X'.
      APPEND item.
      APPEND itemx.
    *   ITEM DATA
      itemx-updateflag = 'I'.
    * Line item number.
      item-itm_number = '000020'.
      itemx-itm_number = 'X'.
    * Material
      item-material = p_matnr.
      itemx-material = 'X'.
    * Plant
      item-plant    = p_plant.
      itemx-plant   = 'X'.
    * Quantity
      item-target_qty = p_menge.
      itemx-target_qty = 'X'.
      APPEND item.
      APPEND itemx.
    *   Fill schedule lines
      lt_schedules_in-itm_number = '000010'.
      lt_schedules_in-sched_line = '0001'.
      lt_schedules_in-req_qty    = p_menge.
      APPEND lt_schedules_in.
    *   Fill schedule line flags
      lt_schedules_inx-itm_number  = '000010'.
      lt_schedules_inx-sched_line  = '0001'.
      lt_schedules_inx-updateflag  = 'X'.
      lt_schedules_inx-req_qty     = 'X'.
      APPEND lt_schedules_inx.
    *   Fill schedule lines
      lt_schedules_in-itm_number = '000020'.
      lt_schedules_in-sched_line = '0001'.
      lt_schedules_in-req_qty    = p_menge.
      APPEND lt_schedules_in.
    *   Fill schedule line flags
      lt_schedules_inx-itm_number  = '000020'.
      lt_schedules_inx-sched_line  = '0001'.
      lt_schedules_inx-updateflag  = 'X'.
      lt_schedules_inx-req_qty     = 'X'.
      APPEND lt_schedules_inx.
    * Call the BAPI to create the sales order.
      CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
           EXPORTING
                sales_header_in     = header
                sales_header_inx    = headerx
           IMPORTING
                salesdocument_ex    = v_vbeln
           TABLES
                return              = return
                sales_items_in      = item
                sales_items_inx     = itemx
                sales_schedules_in  = lt_schedules_in
                sales_schedules_inx = lt_schedules_inx
                sales_partners      = partner.
    * Check the return table.
      LOOP AT return WHERE type = 'E' OR type = 'A'.
        EXIT.
      ENDLOOP.
      IF sy-subrc = 0.
        WRITE: / 'Error in creating document'.
      ELSE.
    * Commit the work.
        COMMIT WORK AND WAIT.
        WRITE: / 'Document ', v_vbeln, ' created'.
      ENDIF.
    Code Formatted by: Alvaro Tejada Galindo on Dec 26, 2008 10:58 AM

  • How to get sales order data in substitution of fi-docu from GM posting ?

    How to get sales order data in substitution of FI documents from goods movement posting?
    When I posting a material document with movement type "501E", the system will creating a FI document automatically. And I need to get the sales order data in the substitution of FI document.
    I tried to export the data of the material document in user-exit "MB_CF001 Updating of material document data upon posting", but this user-exit does not triggered in the posting process at all. what's the problem?
    Do you have better solution or idea for this? Please help me. Thank you!

    Hello Harish,
    Please use BAPI_BUSPROCESSND_GETDETAILMUL to read details of sales order. This works as a remote enabled counterpart of CRM_ORDER_READ.
    Similarly if you want to display sales order from R/3, use FM BAPI_BUSPROCESSND_DISPLAY.
    Regards
    Kaushal

  • Error getting when saving the sales document in third party sales order

    in third party sales order,when i am saving the sales order i am gettingthe following error
    subsequent function 'purchase requistion from sales document' not possible due to credit block.earlier i have maintained credit checks for some customers,but for this customer i have not maintained any credit check. i dont know why system is blocking for this customer also.pls help me where i went wrong.
    highly rewarded if help full.
    thank you

    Please go to FD32, check any default risk category and credit limit is maintained for the customer.
    Also check OB45, any default risk category & credit limit is maintained for the credit control area.
    Also, which order type u r creating sales order? for that order type, Goto VOV8, remove the credit grp and credit check settings.
    Also goto XD02, check in sales area data, billing tab, credit control area field, please remove that also.
    Hope it Helpful.
    Reward points if useful..

Maybe you are looking for