Insert code in prgram to check sales order exits in your own program

Hi Experts
I want to insert a coding in IDOC , can anyone write in abap coding and show .....The program is to check if sales order for category PSTYV ( CATEGORY ) for items ...
if found set flag true else set flag false...
Eg
clear flag
insert code
to check s/o for ZTAC item found
if found
set flag = true
else
set flag = false
So how can I write a a code in ABAP
Thanks in advanced
Piroz

Hi Fracis
Thanks for your advice I did in this way ,  Is there any correction required
form look_sap_saleord  using    p_in_string
                                p_material_in          " Material No exits
                                p_site_in              " plant
                       changing p_out_saleord_e        " sales order
                                p_out_material_e       " Mat No
                                p_out_order_e          " Prod Order
                                p_out_wemng_e          " QTY goods received for order item
                                p_out_psmng_e.         " Ordered Qty Item
  data: lva_prodord like afpo-aufnr,   " Production Order
        lva_prodmat like afpo-matnr,   " Material Number
        lva_saleord like vbkd-vbeln,   " Sales Order
        lva_pstyv   like vbap-pstyv,   " Category
        lva_wemng   like afpo-wemng,   " Quantity of goods received for the order item
        lva_psmng   like afpo-psmng,   " Ordered Qty Item
        lva_count   type i.            " counter validation
CHECK FOR SALES ORDER IN VBAP IF EXITS
GO TO DELIVERES
ELSE CHECK REQUIRED PRODUCTION ORDER
       ihrez_e Ship to party
check single if the sales order exits
  select vbeln from vbkd into vbkd-vbeln
    where ihrez_e eq p_in_string.
  Is the sales order exits for ZTAN Category ?
    select vbeln from vbap into vbap-vbeln
      where vbeln eq vbkd-vbeln and
            werks eq p_site_in and
            matnr eq p_material_in and
            pstyv = 'ZTAN'.
    The sales order is for the specified plant.
      lva_saleord = vbap-vbeln.
      lva_prodmat = vbap-matnr.
      exit.
    endselect.
  when an order for this plant has been found.
    if not lva_saleord is initial.
    exit.
    endif.
  endselect.
  check not lva_saleord is initial.
  select count(*) into lva_count from vbap
    where vbeln = lva_saleord.
  if lva_count eq 1.
    select vbeln matnr aufnr pstyv
    into (lva_saleord, lva_prodmat, lva_prodord, lva_pstyv) from vbap
      where vbeln = lva_saleord and
            matnr = p_material_in and
            pstyv = 'ZTAN'.
      exit.
    endselect.
  else.
    select vbeln matnr aufnr pstyv
    into (lva_saleord, lva_prodmat, lva_prodord, lva_pstyv) from vbap
      where vbeln = lva_saleord
      and matnr   = p_material_in.
      exit.
    endselect.
  endif.
   move: lva_saleord to p_out_saleord_e,           " sales order
         lva_prodord to p_out_order_e,             " production order
         lva_prodmat to p_out_material_e,          " material no
         lva_psmng   to p_out_psmng_e,             " QTY Ordered
         lva_wemng   to p_out_wemng_e.             " Qty Received goods
        lva_wemng   to p_out_wemng_e.             " Quantity of goods received for the order item
endform.                    " look_sap_sales ord
Regards

Similar Messages

  • Check sales order exits for category ZTAC

    Hi Experts
    I have a requirement to modify the iDOC interfaced program,
    In the routien which checks for the existence of a production order, I have to modify the following
    1.  Inspect each item on the sales order
    2. If (and only if) there is atleast one item with a category of "ZTAC" then check for a production order otherwise processing the order in the usual manner.
    Could anyone tell me how to check (Is there a sales order) if no then display error message if yes then is there a production order if no display error message if yes Create confirmation .......................
    I want to know how to write a coding to check sales order exits from table VBAP,VBAK Etc., .
    Thanks in Advanced
    Regards
    Piroz

    Hi Prabhu
    Thanks for your email and response but I need to check this in program for IDOC ....Modification
    Insert code in this way
    check sales order for category = 'ZTAN' inspect for each item on sales order
    and if you found item with cateogry ZTAN then check for production order otherwise go asual manner
    I WANT TO WRITE A CODING HERE **********************
      if production order required then check
                    for each item on sales order item list
                          with item category = 'ZTAC' then
                                     return true
                                next
                                  end function
      VBAP TABLE field VBELN and PSTYV (ZTAC,ZTAN Etc)
    Eg of coding
    if lva_saleord is initial
            select single * from vbap into l_saleord
              where vbelv = lva_saleord
              and   vbeln = lva_vbeln and
              exit.
            endselect.
          endif.
    I want to write a small program in between to check the sales order exits if it is then I have to go to deliveries ...................
    Regards
    Eslam

  • How to check Sales Order complete or incomplete in program?

    Hi, Gurus:
    In the program, how to check Sales Order complete or incomplete based on Order Number vbeln?
    Thanks,

    You can check the status table VBUK for this.
    VBUK has all the status related fields in it.
    Search for the field which suits to your specific requirment.
    Regards,
    Naimesh Patel

  • Calling "Check Sales Order" on HU2 fails

    Hello,
    I'm trying to use the ES "Check Sales Order" (Manage Sales Order In) on HU2, by providing the minimal required information (ProcessingTypeCode, BuyerParty and SalesOrganisationID/DistributionChannelCode/DivisionCode).
    Calling the ES returns an error "[040(SLS_LORD)] Document type TA does not support user status" (I'm using Order type "OR").
    I also tried to use a couple of other order types (RO, TAV, ...) without success.
    The same information used with "Create Sales Order" would work.
    I have the feeling that it is more likely a role/permission issue.
    Is the "Check Sales Order" ES forbidden to standard users ?
    Any way to confirm/solve this ?
    Any other order type ?
    Thanks,
    Nicolas.

    Hi Prabhu
    Thanks for your email and response but I need to check this in program for IDOC ....Modification
    Insert code in this way
    check sales order for category = 'ZTAN' inspect for each item on sales order
    and if you found item with cateogry ZTAN then check for production order otherwise go asual manner
    I WANT TO WRITE A CODING HERE **********************
      if production order required then check
                    for each item on sales order item list
                          with item category = 'ZTAC' then
                                     return true
                                next
                                  end function
      VBAP TABLE field VBELN and PSTYV (ZTAC,ZTAN Etc)
    Eg of coding
    if lva_saleord is initial
            select single * from vbap into l_saleord
              where vbelv = lva_saleord
              and   vbeln = lva_vbeln and
              exit.
            endselect.
          endif.
    I want to write a small program in between to check the sales order exits if it is then I have to go to deliveries ...................
    Regards
    Eslam

  • How to check sale order stock

    Hi,
    Which T-code used for view the  sales order stock
    thanks.

    Hi Balaji,
    You can View Sales Order Stock using MB52 with Special stock Indicator E and with MMBE and also try in CO09.
    Reg,
    Ashok
    Please close issue, if answered.

  • Requied code in abap to display sales order header text

    hi all,
    can anybody help me to send the code in abap to display sales order header text.

    Use FM, Read_text. Pass the necessary parameters like object name, id, language. You can see some of the infos in by clicking the scroll-like button.
    Reward points if useful

  • Lock Insertion of new position in a Sales Order

    Hi guru!
    I've to lock the insertion of new position in a Sales Order from VA02 transaction, users can update only some fields of existing positions but thay can't insert a new position in order.
    I have to lock the blank position in a position's table control so they can't insert data for a new position.
    Is it possible to do?
    Thanks!!

    If you're talking about "new POSNR" (item), you could change the visibility of the insertion button, any menu drop downs, probably with user exit or (perhaps better) with screen variants (transaction SHD0) for transcode VA02....perhaps a combination of the two would get you the results you need.

  • Workflow identification in Sales Order Exit

    Hi,
    In my Sales order exit, under some conditions Iam raising an error message, when the order is being created in background this order will move to workflow. Now if any one process this order through the workflow i want to allow the order to get posted with out raising my exception.
       So I would like to know how I can identify whether my order is being posted through the workflow or directly, in the Sales order exit code.
    Thanks in advance friends,
    Anvitha.

    Hi friends,
    Thanks for your response.
    Checking whether the order is posted in Background or foreground doesn't solve my problem, because my order may be posted in Background or foreground. But when the order is processed through workflow, the processing option depends on the configuration of the Workflow object type. So SY-BATCH doesn't serve my purpose.
       Coming to using SY-UNAME, I observed that the value during the Order process through Workflow is the UserID who process it. So i can't distinguish it.
    Friends, any one had any other option to identify whether the order is being posted through Workflow.
    please help me out.
    Regards,
    Anvitha.

  • Ignore Production order if sales order exits

    Hi Experts
    I want to check some validation for sales order , The system goes in this way  ...I have to modify in this way
    we are extracting the command orders from Command QC System and inserting into SAP . Once it is extracted the Interface coding was written.....to extract sales order, production order etc.,
    Now I want to check only those records in which category are ZTAN. because some time in our company they will sold pigments which does not contain production order directly it will check for qty and delivered to customer.
    Select * from VBAP where VBELN = 'SALES ORDER' and
             MATNR = 'Material nO' and
             PSTYV = 'ZTAN'
    This is because it should not check the production order in AFPO table it must directly go to create deliveries etc for that I created to check sales order ignoring production order So can anyone help me to modify the below coding to check only sales order bu
    SALES ORDER EXITS MODIFICATION****************
    *&      Form  find_sap_salord Exits
          Find an SAP production order for a material.
         -->P_IN_STRING    COMMAND order number
         -->P_MATERIAL_IN  Material number in
         -->P_SITE_IN      Material number in
         <--P_OUT_SALEORD  Sales order number
         <--P_OUT_MATERIAL Material number out
         <--P_OUT_ORDER    Production order number
    form look_sap_saleord  using    p_in_string         " 
                                    p_material_in       " Material No exits
                                    p_site_in           " plant
                           changing p_out_saleord       " sales order
                                    p_out_material      " Material No
                                    p_out_order         " Prod Order
                                    p_out_wemng         " Qty of Goods Rec for Order Item
                                    p_out_psmng.        " Ordered Qty Item
      data: lva_prodord like afpo-aufnr,   " Production Order
            lva_prodmat like afpo-matnr,   " Material Number
            lva_saleord like vbkd-vbeln,   " Sales Order
            lva_pstyv   like vbap-pstyv,   " Category
            lva_wemng   like afpo-wemng,   " Quantity of goods received for the order item
            lva_psmng   like afpo-psmng,   " Ordered Qty Item
            lva_count   type i.            " counter validation
           ihrez_e Ship to party       
      select vbeln from vbkd into vbkd-vbeln
       where ihrez_e eq p_in_string.
      select vbeln from vbap into vbap-vbeln
        where vbeln eq p_in_string.
      Is the order for the specified plant?
        select vbeln from vbap into vbap-vbeln
          where vbeln eq vbap-vbeln and
                matnr eq vbap-p_material_in and
                pstyv in ('ZTAN')
          and   werks eq p_site_in.
        The order is for the specified plant.
          lva_saleord = vbap-vbeln.
          exit.
        endselect.
      Exit when an order for this plant has been found.
        if not lva_saleord is initial.
          exit.
        endif.
      endselect.
      check not lva_saleord is initial.
      select count(*) into lva_count from afpo
        where kdauf = lva_saleord.
      if lva_count eq 1.
        select aufnr matnr wemng psmng
        into (lva_prodord, lva_prodmat, lva_wemng, lva_psmng) from afpo
          where kdauf = lva_saleord.
          exit.
        endselect.
      else.
        select aufnr matnr wemng psmng
        into (lva_prodord, lva_prodmat, lva_wemng, lva_psmng) from afpo
          where kdauf = lva_saleord
          and matnr   = p_material_in.
          exit.
        endselect.
      endif.
      move: lva_saleord to p_out_saleord,
            lva_prodord to p_out_order,
            lva_prodmat to p_out_material,
            lva_psmng   to p_out_psmng,
            lva_wemng   to p_out_wemng.
    endform.                    " find_sap_prodord
    END OF MODIFICATION 22/09/2008*******

    Thanks  thread close
    Piroz

  • Standard T Code to release list of sales orders in 'Delivery Block'

    Dear All,
    Is there any standard transaction code in SAP which provides the facility to release list of sales orders in 'Delivery Block'. (Additional information - List of sales orders in 'Delivery block' is available in V.14,however it does not have release facility).
    For example, VKM3 gives the list of sales orders in 'Credit block' with release facility.On the same lines, is there any standard T code or any other facility in standard SAP which provides the facility to release list of sales orders in 'Delivery Block'.
    Thanks and Regards,
    Zahid

    As already suggested, if you execute VA14L you can see all sale orders that are blocked at
    -  header level
    -  item level
    -  credit check
    Wherever you see "X" under the tab Header level, double click on the respective sale order, so that system will take you to sale order in change mode.  You can remove the header level delivery block and save.
    thanks
    G. Lakshmipathi

  • APO gATP vs R/3 ATP - To check sales order ATP across multiple plants

    Hi There,
    I am trying to evaluate gATP functionality for SD sales orders.
    The primary requirement is to have sales order ATP checking take place across multiple plants.
    E.G.
    Sales order line is entered for qty 100
    60 is available in plant A, 40 is available in plant B
    System checks both plants and creates 2 lines - one for delivery from plant A and one for delivery from plant B
    (we are currently heading down the road of writing ABAP to do this 'multi-plant' check in R/3 but the more complex the requirements get the more interested I am in understanding more about APO/gATP)
    I would like to understand the benefit of implementing APO / gATP as opposed to using standard R/3 ATP and perhaps writing custom ABAP code to search for inventory across multiple plants.
    I would appreciate any insight regarding what is required to setp gATP to perform such checking and any other feedback regarding this issue - especially if you have had to implement something similar at your company.
    I have looked here but not much clear help:
    http://help.sap.com/saphelp_scm50/helpdata/en/26/c2d63b18bc7e7fe10000000a114084/frameset.htm
    Thanks,
    Niall

    Hi Niall
    you are probably looking at RBATP (Rule based ATP). Look at transaction /sapapo/rba04 in APO where you develop your own location and product substitution rules. Going down an ABAP road in R/3 may work short-term but not long-term as the requirements may get more complex.
    Regards
    Srinivas

  • Availability check - sales order

    Hi experts,                              
    I've gone through the relevant info, but still hit the issue below. Pls help. Thx.                                                       
    Issue: How to include the created order (not delivered ) when running availability check?                                                       
    Example:                              
    Stock (storage location C) - 1pc                              
    sales order A - 1pc (confirmed in schedule line)                         
    sales order B - 2pcs (1pc confirmed, 1pc unconfirmed)                                                       
    Those two orders are created agaisnt storage location C. No other stocks against storage location C are available, such as on-order stock.                              
    In my understanding, order B cannot be confirmed as order A has been created firstly.                                    
    Background: As the customer just sells the purchased product, he places PO firstly, then sales order following. Thus, he requests new sales order creation to be based on the stock qty, created sales order qty, PO qty to be received & delivered sales order qty.                                                       
    For this sales scenario, availability check with ATP is activated, but not against product allocation. And the check boxes "incl.purchase orders", "include sales reqmts", "include deliveries" are checked in OVZ9 only.                              
    ps. "Check sales requirements" has been checked in Availability check control while "No storage location inspection" has not been checked.

    Dear Cathy
    Can you please reconfirm that the combination of availability check and checking rule in OVZ9 in which, you have selected the box "Include sales reqmts"  is the same value what you have maintained in material master MRP3 view for availability check ??
    If the availability check is same in both the cases, then try to create a fresh order and post the outcome.
    thanks
    G. Lakshmipathi

  • Stored Procedure for lead code to be entered in sales order

    Hi All,
    I was trying to work on stored procedure for lead code not to be allowed to enter in sales order.
    It is system behaviour that it is allowing to take even lead code in sales order and add the transaction but my customer wants to block if any one of you could help me out to develop stored procedure.
    Thanks & regards-
    Monika

    Hi Monika,
    Try:
    If @object_type='17' and @transaction_type IN ('A','U')
    BEGIN
    If Exists (Select T0.DocEntry from ORDR
    Where T0.CardCode IN (SELECT CardCode FROM OCRD WHERE CardType = 'L')
    And T0.DocEntry = @list_of_cols_val_tab_del)
    Begin
    Select @error = 17, @error_message = 'Lead is not allowed for Sales Order'
    End
    END
    Thanks,
    Gordon

  • ATP Check - Sales order

    Dear All
    Our company requirement is not to save the sales order if stock is not available for any of the line item. This requirement is for specific order type or item catagories.
    Currently system is saving the order even if quantity is not available. 
    Can you please help me how to configure the same in SAP.
    Regards
    K.C Choudhury

    hi,
    ATP Check is checking of availablty quantities i.e ATP = Total Warehouse Stock + Planned receipts(Incoming Stock) - Planned Issues (Out going stock)
    Availbilty Check is an integral part of business process it determines the if the desire deliverible quantity can be met on requested delivery date or not.Then it passes to Material Requirement Planning. Or
    avability check is nothing but checking of availibility of stock which is placed in the order , sys carries out this check through a available to promise (ATP)
    When we create a sales order, there are several basic functions which are executed automatically for the dynamic order management . among these basic functions , availability check and transfer of requirements are crucial.
    the system first prepares schedule line containing the information on the desired delivery date and quantities , this information is passed to MRP and an avialability check and transfer of requiremnts are executed
    First the system carries out backward scheduling and establishes the material avaialbility date = desired delivery date-transit time-loading time-picking & packing time and on this date an availability check is carried out using ATP logic which means avialable to promise quanity =total ware house stock+incoing orders-outgoing
    along with the avialability check the requirements also are transferred to MRP.
    the configuration involves following
    1. switching on at schedule line catagegory the avialability check and TOR
    2. configure the avilability check using ATP and using the checking group and Checking rule
    Regards,
    Raj

  • Availability Check / Sales Order / Planning Strategy 50

    Hi,
    the material master has been setup with planning strategy 50.
    now if i sales order is created. the system directly created planned order for the sales order quantity.
    Now, there is smtimes a situation that some stock is already present in unrestricted stock for that material. thus during order creation, the system should first check the stock available in unrestricted stock...and if the stock is available, then system should confirm the stock without creating any planned order. and if there is no stock available, then system should go with creating planned order.
    now what should i do in ATP check to cater this requiements? Please guide.
    Hope i have explained the issue correctly.

    Hi Robert,
    check this thread Re: Emergent! Can MRP consider unrestricted-use stock with MTO plan strategy???
    Best regards,
    Zuzana

Maybe you are looking for