BAPI/Function module TO block material which is mentioned in sales order

Hi All
Is there any BAPI to block material which is mationed in sales order....
I am using BAPI_MATERIAL_AVAILABILITY to check material availibility
how to block quantity if it is available whicl creating sales order via
"BAPI_SALESORDER_CREATEFROMDATA2"
..Thanks

The normal SAP ATP done in the sales orders use the figure ''committed qty'' meaning that if the ATP has been done and confirmed, that quantity will not appear in the next sales order as available.
So if You're using the normal BAPI to create the sales order, the normal ATP function will be called in the processing.
Nevertheless another solution to this issue is to have the MTO (Make-to-order) solution where the requirements are ''attached'' to one sales order/line only.....like this the problem of the stock being taken to another customer disappears.
To do this you'll have to configure the following :
- Go to SPRO and go to Sales and distribution -> Basic functions -> Availability check and transfer of requirements -> Determination of requirements using transaction - Here insert the entry with your sales order type - MRP type (from material master - you might want to consider create one only for this solution) and you should use one of the following:
  - KEL      Make-to-order, mat. variants
  - KELV     Make-to-ord.variant + consump
  - KP       Make-to-order with project 
and choose the origin of your requirement - 1 - Item category + MRP Type
- Than configure the association of the requirement type above to the requirement class (normally is the same code) transaction *OVZH*
- Than configure the requirement class (this is what will tell the system the MTO) transaction *OVZG* - On the screen in the field Special stock - E - Sales order stock and please ask for help from an FI consultant because the area of *Account assignment is very important to be well configured*
About the BAPI you're using - Its correct - That's the normal BAPI to be used, taking only into consideration the product allocation issue - MARA-KOSCH
Explaining a little the BAPI you're using :
The program should check if the selected material is allocated or non-allocated.
This information is stored in a field MARA-KOSCH.
We should check this field and if the field is not empty then material is allocated, otherwise is not:
       select kosch into l_kosch
        from mara
       where matnr = <VBAP-MATNR>. " Selected material
        if subrc = 0.
           if l_kosch is initial.
              +" Perform calculation for non-allocated materials+
           else.
              +" Perform calculation for allocated materials+
          endif.
       else.
     " Material not found, skip it ...
      endif.
For allocated materials it will be checked allocation for the netting market of that Order.
The calculation rules for allocated and non-allocated materials are different.
For Non-allocated materials
BAPI 'BAPI_MATERIAL_AVAILABILITY' should be used for getting the ATP quantity.
Bapi should be called as follows --
data: lfl_bapiwmdvs type bapiwmdvs,
lit_bapiwmdvs type standard table of bapiwmdvs,
lfl_bapiwmdve type bapiwmdve,
lit_bapiwmdve type standard table of bapiwmdve,
l_dialogflag type bapicm61v-diafl.
call function 'BAPI_MATERIAL_AVAILABILITY'
exporting
plant = <VBAP-WERKS>
material = <VBAP-MATNR>
unit = <VBAP- VRKME>
check_rule = 'A'
+* STGE_LOC =+
+* BATCH =+
+* CUSTOMER =+
importing
+* ENDLEADTME =+
+* av_qty_plt =+
DIALOGFLAG = l_dialog
+* RETURN =+
tables
wmdvsx = lit_bapiwmdvs
wmdvex = lit_bapiwmdve.
Please note that table lit_bapiwmdvs is the input table and to this following input should be passed -
lfl_bapiwmdvs-req_date = sy-datum. "Current date
lfl_bapiwmdvs- REQ_QTY = <Unconfirmed Quantity> in Sales Order Unit
append lfl_bapiwmdvs to lit_bapiwmdvs.
The return value l_dailog will be --
' ' --- Quantity can be Delivered -- Item to be displayed in the Report!
'X' --- Complete quantity cannot be delivered -- ATP failed, Item not to be displayed.
'N' --- Material not relevant for ATP --- Item not to be displayed in the Report.
For Allocated materials
For the allocated Materials, we have to first do the ATP check in same fashion as for Non-allocated Materials and then in addition to this ATP check, we have to also check for Allocation from SIS table S941.
If ATP check fails, straight away the Item should be ignored from Output display.
If ATP check passes, we further check allocation as follows --
Valid entry should select from S941 as -
data: l_period like s941-spbup,
l_BUPER LIKE T009B-POPER,
l_GJAHR LIKE T009B-BDATJ,
lfl_s941 type t_s941.
data: l_bukrs type tvko-bukrs,
l_periv type t001-periv.
* Select company code
select single bukrs into l_bukrs
from tvko
where vkorg = <VBAK-VKORG>.
* Select fiscal year variant
select single periv into l_periv
from t001
where bukrs = l_bukrs.
* Get Period
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
I_DATE = sy-datum
I_PERIV = l_periv
IMPORTING
E_BUPER = l_buper
E_GJAHR = l_gjahr
EXCEPTIONS
INPUT_FALSE = 1
T009_NOTFOUND = 2
T009B_NOTFOUND = 3
OTHERS = 4
IF SY-SUBRC <> 0.
* Ignore entry and skip further processing
ENDIF.
concatenate l_gjahr l_buper+1(2) into l_period.
select single kcqty aemenge from s941
into corresponding fields of lfl_s941
where SPBUP = l_period
and KONOB = 'OBJ_ALL_MATERIALS'
AND MATNR = <VBAP-MATNR>
and zzcnetmark = <VBAK-ZZCNETMARK>
and VRSIO EQ '000'.
IF SY-SUBRC <> 0.
*Ignore entry and skip further processing
ENDIF.
Remaining Allocation = difference between product allocation quantity and incoming order quantity
i.e. (S941-KCQTY - S941-AEMENGE). Now we have to compare this qty with the Unconfirmed qty.
Ensure same Material UOM for quantity comparison as follows --
IF <VBAP-VRKME> NE <S941-BASME>.
CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
EXPORTING
i_matnr = <VBAP-MATNR>
i_in_me = <VBAP-VRKME>
i_out_me = <S941-BASME>
i_menge = <Unconfirmed qty in Sales UOM>
IMPORTING
e_menge = l_menge
EXCEPTIONS
error_in_application = 1
error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Ignore entry and skip further processing
ENDIF.
ELSE.
*If both Units are same no need for conversion
l_menge = <Unconfirmed qty in Sales UOM>
ENDIF.
Then, compare if Remaining Allocation > = l_menge i.e. Unconfirmed quantity converted to S941-BASME unit, then there is enough allocation for this Material for the Unconfirmed quantity and should be displayed in the report.
Else, the Item should be ignored.

Similar Messages

  • Function Module available to get Stock lying against a Sale-Order

    Dear Sir,
    We have function module "KPKA_UTILS_PROJECT_STOCK_CHECK" for getting Stock lying against a WBS (Project Stock) .
    We are looking for a function module to get the Stock lying against a Sale-Order (Sale-Order plus it's Line Item) .
    We request SAP experts to kindly guide us about the availability of such Function Module please .
    We will award full points for the suggested solution pl .
    Rgds
    B Mittal

    Hi
    table MSKA - Sales Order Stock is availble whcih will give the Stock pertainig to a sales Order & line item.
    Hope this helps
    Thanks & Regards
    Kishore

  • Reg: function module to fetch the overall taxs for  a sales order

    Hi Experts,
    I need a fuction module which fetches all the taxes for a sales order with the tax values.
    (i.e) i need a function module with displays the overall tax values and not line itemwise..
    Regards,
    Vikram.S

    Hi,
    Check if it works
    POS_SALES_DOCUMENT_HEAD_TAXES

  • Is there a BAPI function module which reverses the sign of an integer

    Hi Friends,
                     Could u plz tell me  a BAPI function module which can reverse the
    sign of an integer ?
    For example:       
    if i get the integer value in work area as <number> <sign> , i need to change it to <sign><number>. 
    i.e if i get the integer value in work area as    "248-" ("-" indicates minus sign) to " -248 ".
    i.e if i get the sign after the value , my requirement is to get the sign before the value.
    The actual ABAP query is:
    data: QTY_1 TYPE CHAR10,
            QTY_2  TYPE CHAR10,
            WA_DISTK_PORTLET-QUANTITY TYPE INT4.
    QTY_1 = WA_DISTK_PORTLET-QUANTITY.
                    SEARCH QTY_1 FOR '-'.
            IF SY-SUBRC = 0 AND SY-FDPOS <> 0.
              SPLIT  QTY_1 AT '-' INTO  QTY_1 QTY_2.
              CONDENSE  QTY_1.
              CONCATENATE '-'  QTY_1  INTO QTY_1.
              CONDENSE  QTY_1.
            ELSE.
              CONDENSE  QTY_1.
            ENDIF.
            CLEAR: WA_DISTK_PORTLET-QUANTITY.
         MOVE : QTY_1 TO  WA_DISTK_PORTLET-QUANTITY.
    when i move this QTY_1 to work area  quantity field The sign is coming after the numeric value.
    Note: There is no possibility to change the datatype of quantity field.
    I have tried my level best with 'CLOI_PUT_SIGN_IN_FRONT' function module.
    I will assign full points to the correct function module.

    Hi Ram,
    try this ang look into fields.
    data: fields type table of SVAL with header line.
    fields-tabname = 'MARA'. fields-fieldname = 'MATNR'. append fields.
    fields-tabname = 'BKPF'. fields-fieldname = 'BUDAT'. append fields.
    CALL FUNCTION 'POPUP_GET_VALUES'
      EXPORTING
        POPUP_TITLE           = 'Value Insert'
      TABLES
        FIELDS                = fields.
    Regards, Dieter

  • Stuck with Bapi Function module BAPI_STSRVAPS_SAVEMULTI2

    Hi all,
    I have been given the requirement to get the stock quantity using the bapi function module BAPI_STSRVAPS_GETLIST2 from the Livacache and depending upon some stock reservation percent split the stock into two as (NEW STOCK and STOCK RESERVED ).And then write it back to Livecache as  change and create.
    Please do tell me how to proceed with it.
    Thanks and Regards.
    syed.

    hi
    hope the following helps u to know what is to be passsed.
    1.  Required entries     :
          BILLING_DATA_IN-SALESORG
          BILLING_DATA_IN-DISTR_CHAN
          BILLING_DATA_IN-DIVISION
          BILLING_DATA_IN-DOC_TYPE
          BILLING_DATA_IN-ORDBILLTYP
          BILLING_DATA_IN-SOLD_TO
          BILLING_DATA_IN-ITEM_CATEG
          BILLING_DATA_IN-REQ_QTY
          BILLING_DATA_IN-SALES_UNIT
          BILLING_DATA_IN-CURRENCY
          If a material is billed for which a material master needs to be
          determined (BILLING_DATA_IN-NO_MATMAST = ' '), you must make the
          following entries :
          BILLING_DATA_IN-PLANT
          BILLING_DATA_IN-MATERIAL
          If, on the other hand, a material is billed for which no material
          master is to be determined (BILLING_DATA_IN_NO_MATMAST = 'X'), you
          must make the following entries :
          BILLING_DATA_IN-COUNTRY
          BILLING_DATA_IN-MATERIAL
          BILLING_DATA_IN-TAXCL_1MAT
    2.  COMMIT control :
          In the update run (TESTRUN = ' ')  the update is carried out by
        COMMIT
          WORK as part of the method available.

  • Creating/confirming transfer order (WM) using bapi/function modules

    Hi,
    I usually use BDC to create transfer orders or other documents in WM, but i've been told that using BAPI is more correct. I'm new to this concept, so could you please tell me how i can find the apropriate BAPI/function modules available for this purpose in 46C ?
    I thank you in advance,
    Bruno

    Hi Gisk,
    i am trying ot create a TO based on a material document and year. Same function as transaction LB12. Do you know which function module i can use for this.
    I am trying to use the function module L_TO_CREATE_SINGLE, i fill in the T_LTAK-MBLNR and T_LTAK-MJAHR. But do not know which fields to fill in.
    Hope you can help me.
    Grtz
    Coeno

  • How to define null or empty value in BAPI function modules?

    Hi,
    I have problem with BAPI functions, where some parameters are mandatory.
    For example: when I try to use HR BAPI's(BAPI_PERSDATA_CHANGE, etc.) I have to insert parameters like SUBTYPE,OBJECTID,LOCKINDICATOR. The PA0002 table that is used from this BAPI doesn't have SUBTYPE, OBJECTID, LOCKINDICATOR, for any of the records that I would like to select.
    So what I tried, was to put a ' ', to indicate that is empty. It returned an error message saying "Make an entry in all required fields". Next tried to put in some values for these fields -- and it returned an error message saying "No data selected from 0002 for this period".
    I also tried to run BAPI_FAMILY_CHANGE that uses data from table PA0021. Here I found some records with  SUBTYPE, OBJECTID fields that were not empty, but LOCKINDICATOR was still missing. So I tried to put LOCINDICATOR value directly in to database (with MS SQL Enterprise Manager).  After that I was able to use BAPI_FAMILY_CHANGE.
    I think that manually inserting data in database is not normal procedure.
    Is there something that I have missed out?
    I mean -- how can I get this to work without inserting data directly in database?
    How can I define null or empty value in BAPI function modules?
    Thank you in advance.
    Best regards,
    Mihail

    Defining an empty value for a parm in a table is easy.
    First get the function's definition from the SAP system
    Second only populate the fields for which you have a value to set
    Third execute the function.
    The JCO takes care of the rest.
    Enjoy

  • HOw to find the BAPI function module

    Hi all,
    I have a field called IEVER in table EIKP.
    How to find the related BAPI function module and BAPI structure for this filed.
    Thanks in advance
    KP

    Hi KP,
       can you tell us the name of the transaction in which you saw this field?
    If it is in PO Creation or Change you can probably look at the bapis
    BAPI_PO_CREATE or BAPI_PO_CHANGE
    Regards,
    Ravi

  • BAPI function module name and mandatory fields

    Give the name of BAPI function module for pricing change into the transaction VA05 ?
    What are the mandatory fields ?
    Please give a exemple code to do this.

    Hi,
    VA05 is for list of sales order. But if you want to change pricing of material stocks go for follwoing fn module.
    BAPI_SALESORDSTCK_PRICE_CHANGE
    If you want other BAPI for sales related, just go to SE37, give BAPISALE and press F4, you will get all the BAPI fn modules.
    Rewards points if helpful.
    Regards,
    CS.

  • LSMW or ABAP Program:- I need BAPI function module or Direct input program

    hi experts,
    I have to develop the program which uploads the transportation pricing data for freight cost management.
    the transcation code is XK15 for the application A.
    There is a program called RV14BTCI which will uploads for the application V or M not for A.
    So i can use lsmw or direct input program in both lsmw and abap program so plz help me if there is any BAPI function module or Direct input program for Application A.
    thank you,
    waiting for u r reply.
    Edited by: SANTOSH MARUPALLY on Jan 22, 2008 6:27 AM

    Hi Santosh
    Am not really sure if RV14BTCI can not be used for other applications apart from V and M.
    You can try using BAPI: BAPI_PRICES_CONDITIONS. Over the forum you can find few example coding.
    Regards
    Eswar

  • Bapi function module  for the transaction VBO2 in 4.6 version

    can u please tell me the how to proceed for the uploading rebate agreement data into transaction VBO2(change rebate agreement) USING the which bapi function module in 4.6c version.

    I am also looking for the same requirment . could you please let me know if you find any BAPI.

  • Any BAPI/Function Module for adding new record with dates in PA0027

    Hi all,
    I am tryig to find is there any BAPI/Function module for updating new record with Start Date and End date for specified Personal Number in PA0027 Table.
    In PA0027 table i will be passing start date and end date for selected personal number, it needs to add new record with this details in the table checking the condition that this start date and end dates should not be between any of of start date and end dates for the specified personal number.
    thanks for ur time.
    Murali

    Hi Raj/Suresh thanks for ur answers.
    but i am having a problem,i gave this values.
    INFTY               -
                0027
    NUMBER              -
                00000010
    SUBTYPE             -
                010
    OBJECTID
    LOCKINDICATOR
    VALIDITYEND         -
                03/12/2006
    VALIDITYBEGIN       -
                03/01/2006
    RECORDNUMBER        -
                000
    RECORD              -
                P0027
    OPERATION           -
                CHK
    TCLAS               -
                A
    DIALOG_MODE         -
                0
    NOCOMMIT            -
                Y
    VIEW_IDENTIFIER
    SECONDARY_RECORD
    i am getting short dump saying that
    The source field is too short.
    The current program, "SAPLHRMM", tried to assign a field to a field symbo
    However, the field is shorter than the type of the field symbol, which
    is not allowed.
    The statement in question is in the form ASSIGN f TO <fs> CASTING or
    ASSIGN f TO <fs> with a field symbol that was created using the
    STRUCTURE addition.
    I tried  operation - Chage,Create (same thing for all inputs)
    is this correct funtion moduel for my requirment?
    what ever i am passing the start and end dates this should check in the table records with this personal number and if this start date and end dates are not between of any start and end dates then it should add new record with this dates.
    Thanks for ur time.
    Murali.

  • Bapi function module to update PRPS table

    Hi ,
    Presently i have a requirement which needs to update some data from ZIOS table  into PRPS table. Can any one tell me what is the Bapi function module for updating data into PRPS table.
    <REMOVED BY MODERATOR - REQUEST OR OFFER POINTS ARE FORBIDDEN>
    Thanks,
    Satish Raju
    Edited by: Alvaro Tejada Galindo on Jan 12, 2010 11:46 AM

    These ZZ fields are specific to your application, use the EXTENSION parameters.
    Look in BAPI_PS_INITIALIZATION documentation, there is an explanation how-to fill specific fields.
    For the BAPIs used to create and change project definitions, WBS       
    elements, networks, activities, and activity elements, you can         
    automatically fill the fields of the tables PROJ, PRPS, AUFK, and AFVU 
    that have been defined for customer enhancements in the standard system.
    For this purpose, help structures that contain the respective key      
    fields, as well as the CI include of the table are supplied. The BAPIs 
    contain the parameter ExtensionIN in which the enhancement fields can be
    entered and also provide BAdIs in which the entered values can be      
    checked and, if required, processed further.                           
    CI Include  Help Structure                      Key                  
    CI_PRPS     BAPI_TE_WBS_ELEMENT                 WBS_ELEMENT
    Procedure for Filling Standard Enhancements                                                                               
    Before you call the BAPI for each object that is to be created or     
    changed, for which you want to enter customer-specific table enhancemen
    fields, add a data record to the container ExtensionIn:                                                                               
    o   STRUCTURE:    Name of the corresponding help structure                                                                               
    +o   VALUEPART1:   Key of the object + start of the data part+                                                                               
    o   VALUEPART2-4: If required, the continuation of the data part                                                                               
    VALUPART1 to VALUPART4 are therefore filled consecutively, first with 
    the keys that identify the table rows and then with the values of the 
    customer-specific fields. By structuring the container in this way, it
    is possible to transfer its content with one MOVE command to the      
    structure of the BAPI table extension.                                                                               
    Note that when objects are changed, all fields of the enhancements are
    overwritten (as opposed to the standard fields, where only those fields
    for which the respective update indicator is set are changed).        
    Therefore, even if you only want to change one field, all the fields  
    that you transfer in ExtensionIn must be filled.                      
    You have to use these parameters in BAPI_BUS2054_GETDATA as well as in BAPI_BUS2054_CHANGE_MULTI.
    Regards

  • BADI /BAPI /Function Module in PP

    PP Experts,
    I need help to identify the BADI /BAPI /Function Module in PP for
    BOM Explosion multilevel (TXn CS11)
    Planned Order Create and Change (Txn MD11/MD12)
    Production Order Create and Change (CO01/CO02)
    Simulation Order (Co01S/Co02S)
    Appreciate your valuable inputs.
    Thanks and Regards,
    Pradeep

    Hi,
    Following Enhancements available for the said T-Codes
    Transaction Code - CS11 Display BOM Level by Level
    Enhancement
    PCSD0014 Wissensbasierte AuftragsStl:Status setzen beim fixieren
    PCSD0013 Customer-specific processing of an explosion for BOM browse
    PCSD0012 Customer - Mat. number/mat. number during material exchange
    PCSD0011 Knowledge-based order BOM, parallel update
    PCSD0010 Order/WBS BOM, determine explosion date
    PCSD0009 Order/WBS BOM, determine URL page
    PCSD0008 WBS BOM: Customer-specific explosion for creating
    PCSD0001 Applications development R/3 BOMS
    PCSD0002 BOMs: Customer fields in item
    PCSD0003 BOMs: Customer fields in header
    PCSD0004 BOM comparison
    PCSD0005 BOMs: component check for material items
    PCSD0006 Mass changes user exit
    PCSD0007 Check changes in STKO
    Business Add-in
    BOM_EXIT BOM User Exit
    BOM_IPPE iPPE Checks Within BOM Maintenance
    BOM_UPDATE Maintain BOMS
    CEWB_BOM_CUS_FIELDS EWB: Customer Fields with BOM Header (Screen Enhancement)
    CEWB_BOM_UPDATE Check Bill of Material on Saving
    CEWB_ITM_CUS_FIELDS EWB: Customer Fields with BOM Item (Screen Enhancement)
    Transaction Code - MD11/MD12 Create Planned Order
    Enhancement
    LMDR2001 User exits restr. profiles of opt. pur.ord.-based load bldg
    LMDZU001 User exits in additional planning
    Transaction Code - CO01/CO02/CO01S/CO02s Create production order
    Enhancement
    PPCO0010 Enhancement in make-to-order production - Unit of measure
    PPCO0012 Production Order: Display/Change Order Header Data
    PPCO0013 Change priorities of selection crit. for batch determination
    PPCO0015 Additional check for document links from BOMs
    PPCO0016 Additional check for document links from master data
    PPCO0017 Additional check for online processing of document links
    PPCO0018 Check for changes to production order header
    PPCO0019 Checks for changes to order operations
    PPCO0021 Release Control for Automatic Batch Determination
    PPCO0022 Determination of Production Memo
    PPCO0023 Checks Changes to Order Components
    STATTEXT Modification exit for formatting status text lines
    PPCO0009 Enhancement in goods movements for prod. process order
    CCOWB001 Customer exit for modifying menu entries
    COIB0001 Customer Exit for As-Built Assignment Tool
    COZF0001 Change purchase req. for externally processed operation
    COZF0002 Change purchase req. for externally procured component
    PPCO0001 Application development: PP orders
    PPCO0002 Check exit for setting delete mark / deletion indicator
    PPCO0003 Check exit for order changes from sales order
    PPCO0004 Sort and processing exit: Mass processing orders
    PPCO0005 Storage location/backflushing when order is created
    PPCO0006 Enhancement to specify defaults for fields in order header
    PPCO0007 Exit when saving production order
    PPCO0008 Enhancement in the adding and changing of components
    Business Add-in
    SIDAT_UPDATE Change date of price simulation
    CAUFVD_CHANGE BAdI: Overall Network Scheduling with Selection Option
    AFABD_CHANGE Change Relationship
    PPPI_SEL_ORD_EXT_REL
    Regards
    Ahsan

  • BAPI/Function module for FAIV06

    Hi All,
    I want post the debit/credit material document using transaction FAIV06.I searched for BAPI/function module but nothing found.
    if you know any bapi/function module or is there any alternate method for posting the document.
    please help.
    Thanks.

    I think there is  only a BAPI to get the details of a Info record BAPI_INFORECORD_GETLIST. For creagting / updating you will have to write a BDC.
    regards,
    Ravi
    Note : Please mark the helpful answers

Maybe you are looking for

  • F110 - Automatic Payment Run - Checks Will Not Print!!

    Hi! My client executed transaction F110 - Automatic Payment Run for a range of vendors (100000 - 599999).  He was able to execute the run but could not print checks and found out that payments weren't assigned check numbers in the system.  However, p

  • Price is not transferred from materail contract to po

    Dear Experts,                     When i create a service po , the price is not transferred from material contract to po , for material po it is working fine.In debugging i got to know that it is picking up purchase requisitions package number , and

  • Syncing my iphone calendar with mac computer calendar

    I want to sync my iPhone3 calendar to my mac computer calendar, with all the info in my iPhone overriding the computer calendar. When I sync, typically the computer calendar will trumph all the info in my phone and I lose valuable info on my phone...

  • Credit period based credit block

    Hello Experts, In one of our client's requirement, the client requires a credit block if the period exceeds 90 days and this is to be configured for one sales area and account group. In short- sales areacredit periodaccount group=credit block. what c

  • About using rsbdcsub to run BDC session .

    Hi all, I use rsbdcsub to run a bdc session , But the job created by the program is always in "ready" status and never run(complete) . How can I solve the problem? Thanks Pole Message was edited by: gw gw