Performance tuning for Sales Order and its configuration data extraction

I write here the data fetching subroutine of an extract report.
This report takes 2.5 hours to extract 36000 records in the quality server.
Kindly provide me some suggestions for performance tuning it.
    SELECT auart vkorg vtweg spart vkbur augru
              kunnr yxinsto bstdk vbeln kvgr1 kvgr2 vdatu
              gwldt audat knumv
              FROM vbak
              INTO TABLE it_vbak
              WHERE vbeln IN s_vbeln
              AND erdat IN s_erdat
              AND  auart IN s_auart
              AND vkorg = p_vkorg
              AND spart IN s_spart
              AND vkbur IN s_vkbur
              AND vtweg IN s_vtweg.
  IF NOT it_vbak[] IS INITIAL.
    SELECT mvgr1 mvgr2 mvgr3 mvgr4 mvgr5
           yyequnr vbeln cuobj
           FROM vbap
           INTO TABLE it_vbap
           FOR ALL ENTRIES IN it_vbak
           WHERE vbeln  =  it_vbak-vbeln
           AND   posnr = '000010'.
    SELECT bstkd inco1 zterm vbeln
           prsdt
           FROM vbkd
           INTO TABLE it_vbkd
           FOR ALL ENTRIES IN it_vbak
           WHERE vbeln  =  it_vbak-vbeln.
    SELECT kbetr kschl knumv
           FROM konv
           INTO TABLE it_konv
           FOR ALL ENTRIES IN it_vbak
           WHERE knumv  =  it_vbak-knumv
           AND   kschl  =  'PN00'.
    SELECT vbeln parvw kunnr
           FROM vbpa
           INTO TABLE it_vbpa
           FOR ALL ENTRIES IN it_vbak
           WHERE vbeln  =  it_vbak-vbeln
           AND parvw IN ('PE', 'YU', 'RE').
  ENDIF.
  LOOP AT it_vbap INTO wa_vbap.
    IF NOT wa_vbap-cuobj IS INITIAL.
      CALL FUNCTION 'VC_I_GET_CONFIGURATION'
           EXPORTING
                instance            = wa_vbap-cuobj
                language            = sy-langu
           TABLES
                configuration       = it_config
           EXCEPTIONS
                instance_not_found  = 1
                internal_error      = 2
                no_class_allocation = 3
                instance_not_valid  = 4
                OTHERS              = 5.
      IF sy-subrc = 0.
        READ TABLE it_config WITH KEY atnam  =  'IND_PRODUCT_LINES'.
        IF sy-subrc  =  0.
          wa_char-obj  =  wa_vbap-cuobj.
          wa_char-atnam  =  it_config-atnam.
          wa_char-atwrt  =  it_config-atwrt.
          APPEND wa_char TO it_char.
          CLEAR wa_char.
        ENDIF.
        READ TABLE it_config WITH KEY atnam  =  'IND_GQ'.
        IF sy-subrc  =  0.
          wa_char-obj  =  wa_vbap-cuobj.
          wa_char-atnam  =  it_config-atnam.
          wa_char-atwrt  =  it_config-atwrt.
          APPEND wa_char TO it_char.
          CLEAR wa_char.
        ENDIF.
        READ TABLE it_config WITH KEY atnam  =  'IND_VKN'.
        IF sy-subrc  =  0.
          wa_char-obj  =  wa_vbap-cuobj.
          wa_char-atnam  =  it_config-atnam.
          wa_char-atwrt  =  it_config-atwrt.
          APPEND wa_char TO it_char.
          CLEAR wa_char.
        ENDIF.
        READ TABLE it_config WITH KEY atnam  =  'IND_ZE'.
        IF sy-subrc  =  0.
          wa_char-obj  =  wa_vbap-cuobj.
          wa_char-atnam  =  it_config-atnam.
          wa_char-atwrt  =  it_config-atwrt.
          APPEND wa_char TO it_char.
          CLEAR wa_char.
        ENDIF.
        READ TABLE it_config WITH KEY atnam  =  'IND_HQ'.
        IF sy-subrc  =  0.
          wa_char-obj  =  wa_vbap-cuobj.
          wa_char-atnam  =  it_config-atnam.
          wa_char-atwrt  =  it_config-atwrt.
          APPEND wa_char TO it_char.
          CLEAR wa_char.
        ENDIF.
    READ TABLE it_config WITH KEY atnam  =  'IND_CALCULATED_INST_HOURS'.
        IF sy-subrc  =  0.
          wa_char-obj  =  wa_vbap-cuobj.
          wa_char-atnam  =  it_config-atnam.
          wa_char-atwrt  =  it_config-atwrt.
          APPEND wa_char TO it_char.
          CLEAR wa_char.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDLOOP. " End of loop on it_vbap
Edited by: jaya rangwani on May 11, 2010 12:50 PM
Edited by: jaya rangwani on May 11, 2010 12:52 PM

Hello Jaya,
Will provide some point which will increase the performance of the program:
1.     VBAK  & VBAP are header & item table. And so the relation will be 1 to many. In this case, you can use inner join instead multiple select statement.
2.     If you are very much confident in handling the inner join, then you can do a single statement to get the data from VBAK, VBAP & VBKD using the inner join.
3.     Before using for all entries, check whether the internal table is not initial.
And sort the internal table and delete adjacent duplicates.
4.     Sort all the resultant internal table based on the required key fields and read always using the binary search.
You will get a number of documents where you can get a fair idea of what should be done and what should not be while doing a program related to performance issue.
Also you can have number of function module and BAPI where you can get the sales order details. You can try with u2018BAPISDORDER_GETDETAILEDLISTu2019.
Regards,
Selva K.

Similar Messages

  • How I can get the Billing Type for the sales order and its items

    How I can get the Billing Type for the sales order and its items. I mean from which SAP tables and how?

    Hi,
    You need to use two tables.
    First use VBFA. Enter the sales order number in the field Predecessar and the value M in SubCt field. This will give all the billing document number for the sales order items.
    Then use the billing document numbers in table VBRK, where in you can get the billing document type.
    Regards,

  • Question about the rescheduling of a Sales Order and its Production Order

    Hello Everybody,
    I experience something strange with the rescheduling of a Sales Order and its corresponding Production Order.
    It will be easier to explain with an example...
    For a material, I have created a Sales Order.
    And from this Sales Order, I have now a Production Order converted from a Planned Order generated by the MRP Run.
    This is what I have in transaction MD04:
    SALES ORDER
    AV DATE: 20/02/2008
    GR DATE: 20/02/2008
    PRODUCTION ORDER
    AV DATE: 20/02/2008
    GR DATE: 18/02/2008    (GR process time is 2 days).
    ==> OK !
    Now, I have to reschedule the Sales Order one week sooner.
    SALES ORDER
    AV DATE: 13/02/2008
    GR DATE: 13/02/2008
    After transaction COHV to reschedule the Production Order, I have:
    PRODUCTION ORDER
    AV DATE: 15/02/2008
    GR DATE: 13/02/2008
    But I expected to have:
    PRODUCTION ORDER
    AV DATE: 13/02/2008
    GR DATE: 11/02/2008
    Do you have an idea about what is wrong?
    Thanks in advance for your help on this subject.
    Regards,
    Rudy

    Hello.
    Thank you for your reply.
    But in fact, I am doing some tests on a test platform, which is using an "old" copy of production database.
    So, there can't be data already scheduled for the dates I am using.
    Moreover, I just tried now to do the same with dates in November 2008, exactly with the same results.
    In production platform, they experience this problem too.
    Summary of my new test:
    Before rescheduling:
    SALES ORDER:
    AV. DATE = 20/11/2008
    GR. DATE = 20/11/2008
    PROD. ORDER:
    AV. DATE = 20/11/2008
    GR. DATE = 18/11/2008
    After rescheduling of one week sooner:
    SALES ORDER:
    AV. DATE = 13/11/2008
    GR. DATE = 13/11/2008
    PROD. ORDER:
    AV. DATE = 15/11/2008  (ipo  13/11/2008)
    GR. DATE = 13/11/2008  (ipo  11/11/2008)
    I really don't understand why I don't have the same kind of dates as the ones I get before the rescheduling...
    In my mind, I expect to have all these dates set back of one week...
    Regards
    Rudy
    Rudy

  • VD05 - Customer master record blocked for sales orders and billing

    Hi,
    I have a scenario whereby I have blocked a customer master record for sales orders and billing using transaction VD05, but it still allows you to create sales orders and post billing documents.
    What is the reason for this?
    Regards
    Gandi

    Hi,
    Block the customer for the sales order, delivery and Billing for the specific sales area in vd05
    and try out,
    Regards
    Pradeep BV.

  • CRM - R-3 integration for sales order and billing

    Hi All,,
    Please could you help me to set up the connectivity between CRM and R-3.
    This will be for Sales order and billing.
    Regards,
    Piyush

    Hi All,
    Thanks for your information.
    I have created a site, subscription, connectivity is established between R-3 and CRM through RFC destination.
    What else do i need to do, Could you please share <b>step by step</b> information for the whole scenario 'Sales order in CRM to R-3 and Billing info from R-3 to CRM ?
    This will help me a lot to do things.
    If you have documents for this please mail me at [email protected]
    Regards,
    Piyush

  • Std report to dispaly Sales Order and Profit center data

    Hi,
    I want to display list of Sales Order and profit center in one report  for that Sales organisation
    Is there any T-code where i can view Sales Order and its Profit center.
    **Plz if anyone knows abt this reply soon.
    Thanks
    AKASH
    Edited by: AKASH TAMBI on May 20, 2008 1:28 PM

    Dear Akash
    There is no standard report to see both the sale order reference and profit center.  However, if you go to SE16 and use table VBAP, you can see the required details
    thanks
    G. Lakshmipathi

  • Sales Order Item level Configuration data

    I need sales order item level configuration data. I use following function modules to get, But my issue some of configuration DON"T have value only description available. I needs configuration with values or without values ( menas all)
    But function modules not giving complete results.
    CE_I_GET_CONFIGURATION
    VC_I_GET_CONFIGURATION_IBASE
    VC_I_GET_CONFIGURATION
    CUD0_GET_VAL_FROM_INSTANCE
    Any info ?

    Tried could not find why the function moudle not considering entries don't have values
    But in sales order config  screen if i press page (list) its showing values that don't have values

  • We are using EBS 12.1.3.  When we input a sales order from a customer we input the sales order and specify the date the customer wants it.  This isn't always the date that we intend on manufacturing it though.  I need to put a customer due date in, but be

    We are using EBS 12.1.3.  When we input a sales order from a customer we input the sales order and specify the date the customer wants it.  This isn't always the date that we intend on manufacturing it though.  I need to put a customer due date in, but be able to put a date in another field that MRP can read in the event we choose to manufacture based on another date.  For example, early.
    Any help would be appreciated.

    What you are experiencing is 100% related to Malware.
    Sometimes a problem with Firefox may be a result of malware installed on your computer, that you may not be aware of.
    You can try these free programs to scan for malware, which work with your existing antivirus software:
    * [http://www.microsoft.com/security/scanner/default.aspx Microsoft Safety Scanner]
    * [http://www.malwarebytes.org/products/malwarebytes_free/ MalwareBytes' Anti-Malware]
    * [http://support.kaspersky.com/faq/?qid=208283363 TDSSKiller - AntiRootkit Utility]
    * [http://www.surfright.nl/en/hitmanpro/ Hitman Pro]
    * [http://www.eset.com/us/online-scanner/ ESET Online Scanner]
    [http://windows.microsoft.com/MSE Microsoft Security Essentials] is a good permanent antivirus for Windows 7/Vista/XP if you don't already have one.
    Further information can be found in the [[Troubleshoot Firefox issues caused by malware]] article.
    Did this fix your problems? Please report back to us!

  • Return Sales Order - And its Status

    Hello Experts,
    I have a question in the sales returns scenario.
    Step 1: I Create a sales order ( With two items and delivery full ) and perform steps till billing ( invoice ).
    Step 2: I Create Return sales order with reference to the first sales order but i take Only one item to return.
    Now the status of the return sales order is Being Processed.
    Step 3: I create a complete ( deliver full quantity of the item ) return delivery with reference to the return sales order and save the document. Now still the return sales order is in status Being Processed. Ideally i should have been Completed.
    Step 4: I do the Goods receipt for the return delivery. Now also the status of the returns sales order is Being Processed instead of Completed
    Kindly suggest any way to control the status of sales document or is this the ideal way( if so what's the functional purpose behind this ? ).
    Is this because the billing block is still set in the Return sales order ?

    Do you mean that only after credit memo creation or clearing of the credit memo from FI the status of return order is set to completed?
    If this is an ideal scenario, in one of our systems the status of return sales order is set to completed immediately after returns delivery creation.
    This behavior is same as that of normal sales order scenario, where the sales order status is set to completed once the delivery happens.
    Kindly suggest, if there is any customizing to control the oeverall status update for specific sales order types or based on the type of sales scenario.

  • Update KOMV-KBETR field for sales order and billing

    I would like to update the KOMV-KBETR (condition amount or percentage) under condition tab for both Sales order and billing.
    example:There are two condition types ZA00 and ZB00 and need to get the KBETR value from ZA00 and add it to KBETR value of ZB00 and update the sum in KBER value of ZB00.
    1. creation of sales order & billing.
    2. Change of sales order & billing.
    3. For single & multiple line items in both sales order & billing.
    4. during updation of price in the change mode of sales order & billing.
    5.When user click on Update button in the condition tab(i.e., when clicked on Carryout new pricing)
    I tried with the VOFM routine but as the routine is triggering multiple times the sum is calculated again and again.For that I set flags also.It is working for sales orders but for billing creation the field XKOMV-KBETR is cleared after this routine.
    So I would like to know are there any EXITS for this scenario or any one entountered the similiar issue which I am facing.

    Hi Brad,
       It is an Client requirement.So need to do the addition of that condition types.
    Can you please let me know the configuration point where we can do it and the condition type which we need to update the Rate/Amount value.ie., KOMV-KBETR is and Price list value and not the subtotal one.
    Thanks,
    Srilakshmi Lagisetty.

  • Query for Sales order and corr.AR Invoice Info

    Hi,
    I need to write a query which gives the flollowing sales order info along with the coressponding AR invoices info
    Sales Order columns reqd:
    OPERATING_UNIT
    ORDER_NUMBER
    CUSTOMER_NUM
    CUSTOMER_NAME
    ORDERED_DATE
    FLOW_STATUS_CODE
    TOTAL_ORDER_AMOUNT
    AR invoice columns reqd for the sales orders:
    Invoice number,
    Invoice date,
    Invoice Total.
    Can anyone help me out with this?
    Thanks,
    Ash

    Hi Ash,
    There are some issues that must be defined before you have the exact query.
    Do you have freight charges or non-inclusive tax? If you have, freight charges and tax amounts must be included?
    Depending on you grouping rule, you can have lines from more than one order in a single invoice. In this case, as invoice amount you want the sum of all lines, or only the lines from that order?
    Below is an example using two views. It assumes that grouping rules split lines from different order into different invoices.
    Hope it helps,
    Ketter Ohnes
    create or replace view order_summary as
    select oh.org_id,
    oh.ORDER_NUMBER,
    oh.header_id,
    ott.name tt_name,
    ca.account_number,
    p.party_name,
    oh.ordered_date,
    oh.flow_status_code,
    sum(ol.ordered_quantity*ol.unit_selling_price) total,
    sum(ol.tax_value) tax,
    (select sum(operand)
    from OE_PRICE_ADJUSTMENTS_v x
    where x.header_id = oh.header_id
    and x.adjustment_type_code='FREIGHT_CHARGE') freight_charge
    from oe_order_headers_all oh,
    oe_order_lines_all ol,
    hz_cust_accounts ca,
    hz_parties p,
    oe_transaction_types_tl ott
    where ol.header_id=oh.header_id
    and oh.sold_to_org_id = ca.cust_account_id
    and ca.party_id = p.party_id
    and oh.order_type_id = ott.transaction_type_id
    and ott.language =
    (select language_code
    from fnd_languages
    where installed_flag = 'B')
    group by oh.org_id,
    oh.header_id,
    oh.ORDER_NUMBER ,
    ott.name,
    ca.account_number,
    p.party_name,
    oh.ordered_date,
    oh.flow_status_code;
    create or replace view invoice_summary as
    select a.interface_header_context,
    a.trx_date,
    a.trx_number,
    b.interface_line_attribute1,
    b.interface_line_attribute2 tt_name,
    a.customer_trx_id,
    sum(b.extended_amount) invoice_total
    from ra_customer_trx_all a,
    ra_customer_trx_lines_all b
    where a.customer_trx_id = b.customer_trx_id
    and b.interface_line_context = 'ORDER ENTRY'
    and b.line_type in ('LINE','FREIGHT')
    group by a.interface_header_context,
    a.trx_date, a.trx_number,
    b.interface_line_attribute1,
    b.interface_line_attribute2,
    a.customer_trx_id;
    select *
    from order_summary o,
    invoice_summary i
    where o.order_number between :1 and :2
    and o.order_number = i.interface_line_attribute1
    and o.tt_name = i.tt_name;

  • Query for Sales Order and AR Invoice Information

    Hi,
    I need to write a query which gives the flollowing sales order info along with the coressponding AR invoices info
    Sales Order columns reqd:
    OPERATING_UNIT     
    ORDER_NUMBER     
    CUSTOMER_NUM     
    CUSTOMER_NAME     
    ORDERED_DATE     
    FLOW_STATUS_CODE     
    TOTAL_ORDER_AMOUNT
    AR invoice columns reqd for the sales orders:
    Invoice number,
    Invoice date,
    Invoice Total.
    Can anyone help me out with this?
    Thanks,
    Ash

    Hi Ash,
    Table RA_CUSTOMER_TRX_ALL can be joined to RA_CUSTOMER_TRX_LINES_ALL table through CUSTOMER_TRX_ID column. The table RA_CUSTOMER_TRX_LINES_ALL.INTERFACE_LINE_ATTRIBUTE6 = OE_ORDER_LINES_ALL.LINE_ID. And from the LineId, you can get the HeaderId os the OE_ORDER_HEADERS_ALL table.
    You must have visualized the query by now.
    Thanks
    Sumit

  • BDC Program for Sales order and Enquiry

    Hi All,
    Pls can you help me.
    To create sales order and enquiry I have bapis .
    BAPI_SALESORDER_CREATEFROMDAT2
    BAPI_INQUIRY_CREATEFROMDATA2
    but i want BDC Programs for that bapis
    pls can you help me
    thanks
    mars

    Hi Krishna ,
    Please check the below links .
    [http://www.sap-basis-abap.com/abap/bapi-sample-to-upload-data-from-flat-file-to-va01.htm]
    [http://abapreports.blogspot.com/2008/06/bapi-sample-code-for.html] -- > Select and Copy from this one.

  • Authority check for sales order and stock transport order

    In my code i have a requirement to enter sales order and Stock transport order. However i want that a WM resource should not be allowed to enter sales order and an SD resouce should not be allowed to enter stock tranpsort order. Please suggest.

    Hi,
    Another way to solve this is create a Z table with field user name and Resource type and compare the user id ( sy-uname) with the Z table and allow accordingly.
    In production environment controlling authorization in this approch is much easier.
    Hope this helps.
    Regards
    Bikas

  • BOM business requirement for sales order and PGI

    Hi Experts,
    Current setting
    The BOM structure is A = A1+A2
    1) Material A created in MM master item category group = ERLA
    2) Sub component material A1 and material A2, MM master item category group = NORM for both component.
    3) Maintained in CS01 BOM header is A and items are A1 and A2.
    4) Item category in IMG was created and assign item category also created.
        4.1) OR-ERLA-TAQ-TAE
    new business requirement as listed below.
    5) The material A is alway zero quantity on hand, no goods receipt required with no physical with such material or package at all. (it is dummy material number in SAP).
    6) while SO created.
        6.1) Fro material A sales price captured at BOM header level only, NO QTY and COSTshow in the sales order.
         6.2) Material A1 and A2 are actual physical inventory item in the ware house.
         6.3) The sub component of material A1 and A2 is required to captured QTY and COST. NO SALES PRICES NEEDED.
    CONCLUSION
    HOW to setup/configure such a business scenario?
    - Is it logic to configure as OR-ERLA-TAE-TAN that's what i think of?
      My problem is how to make the material A is alway ZEROS stock on hand and allow in sales order creation with ZEROS order qty?
    MATERIAL                                          QTY                             COST                                  SALES NET VALUE
           A                                                      0                                   0                                              1,500.00
           A1                                                    1                                  100.00                                           0
           A2                                                    1                                    50.00                                           0
    Thanks & Regards,
    Yong Kok Wah
    Edited by: Yong Kok Wah on Jan 27, 2010 11:16 AM

    As per your post,
    -  You are creating Main item which is a dummy material without any physical inventory maintained, but the pricing/billing should be done @ main item level.
    - here you are not dispatching main item, but billing should be carried at this level. in such case, I suggest you to go with the new sch.line cat w/o maintaining any mov type to it. & use Zitem category for this main item in VOV7, mark "Order qtty=1" so that min order qtty for this main item should be 1, so that you can calculate price.
    -  You want to capture Cost of sub items , summation of sub items cost is total cost of main item & Profit will be calculated accordingly.
    Sub items, sch.line category should have mov type, item cat should be not relevant for pricing & billing , but relevant for sch.lines. In Copy control from delivery - Billing @ item level, for the main item ,- item category, choose "Cumulate cost", so that cost of the sub items will be cumulated to main item.
    eg:
    MATERIAL QTY COST SALES NET VALUE
    A 0 0 1,500.00
    A1 1 100.00 0
    A2 1 50.00 0
    My problem is how to make the material A is alway ZEROS stock on hand and allow in sales order creation with ZEROS order qty?
    To avoid this, mark order qtty=1, in item category for main item, but for the same item, sch.line category should not have mov type. so that there will nt be any PGI document. But PGI should be done for sub items to capture inventory & cost.
    Test & revert, if any issues.

Maybe you are looking for

  • Error While Creating Asset Class

    Hi Friends, I am getting the following error in development client while creating the asset class AB2200. "Screen Layout 200 was not created"  but the same was created. Please guide me how to handle this error and the reason for me getting this error

  • PO going to Held :Partner Overview all data missing

    Hi, SRM 5.0, ECS After approving shopping carts, PO getes creating but going to held status. Dont know what happened. when i am checking held PO getting below error messages 4 Messages   Data inconsistency during tax calculation       Output: No deta

  • Ownership of folders in file server

    Hi Guys, I am facing a problem with my file server. I have a file server installed windows server 2008 R2 Standard SP1 in it. There are 4 drives and almost 99% folders are created by 1st domain user account having domain admin rights. Because I was f

  • I received my order around 5 days but i didn,t got my receipt...

    Hello... I ever call to callcenter for asking about my receipt 2 days ago. The opertor tell me that he will send E-Receipt of my order to my email but I check my email everyday, I didn't got any email from apple... PLZ, SEND IT TO ME ON MY EMAIL OR M

  • Why is Indeisgn CS5 crashing every time I try to make a print PDF?

    No problem  generating an interactive PDF, but every time I try to create a print PDF-ID crashes. This is happening on two other computers in my department. Does anybody have any intel on this? Thanks for your help...