Querry Based Approval-AR Invocice-Batch Expiry Date

Hi All,
I want to set a query based approval which will check the expiry date of the batch no of the item being sold in AR Incoice. If the diffrence between the expiry date and today's date is less than or equal to 60, the AR Invoice should go for approval.
CAn anybody please help me with the querry??
Edited by: Philip Eller on Jun 9, 2008 11:22 AM
Edited by: Philip Eller on Jun 26, 2008 10:24 AM*
Edited by: Rui Pereira on Aug 6, 2008 4:18 PM

Hi,
try this query approval:
IF @transaction_type = 'A' AND @object_type = '13'
BEGIN
IF EXISTS (SELECT T0.DocNum FROM Oinv T0 INNER JOIN inv1 T1
ON T0.docentry = T1.docEntry inner join ibt1 t2 on t1.itemcode = t2.itemode and t2.whscode = t1.whscode inner join oibt t3 on t2.batchnum = t3.batchnum
WHERE (T3.ExpDate - getdate()) <= 60 and T0.DOCENTRY = @list_of_cols_val_tab_del)
BEGIN
SELECT @Error = 1, @error_message = 'expire date less/equal than 60'
END
END
Rgds,

Similar Messages

  • BAPI_GOODSMVT_CREATE - Batch Expiry Date......

    HI Im,
    using this BAPI to post a goods movement from one location to another in the same plant.
    The stock is being posted to a specific Batch.  When I do this the material document gets created okay and the stock moves.
    The problem is that the batch expiry date is not updating.  The stock I'm moving has a later expiry date than the current date.  If I do this manually in MIGO it works fine and updates the batch expiry date with the later date.
    Has anyone else experienced this or know of a work around ?

    Hi
    I am populating the item data like:
    *- Populate item data
      LOOP AT i_items_trans.
        CLEAR ibapigm_item.
    *- Convert the matnr backto 18 char form (External)
        CALL FUNCTION 'CONVERSION_EXIT_MATN2_INPUT'
          EXPORTING
            input            = i_items_trans-matnr
          IMPORTING
            output           = i_items_trans-matnr
          EXCEPTIONS
            number_not_found = 1
            length_error     = 2
            OTHERS           = 3.
        IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
        ibapigm_item-material   = i_items_trans-matnr.
        ibapigm_item-plant      = x_user-werks.
        ibapigm_item-stge_loc   = x_user-lgort.
        ibapigm_item-move_type  = '101'.   "Goods Receipt
        ibapigm_item-mvt_ind    = 'B'.     "Goods Movement for PO
        ibapigm_item-po_number  = i_items_trans-ebeln.
        ibapigm_item-po_item    = i_items_trans-ebelp.
        ibapigm_item-gr_rcpt    = sy-uname.
        ibapigm_item-quantity   = i_items_trans-ktmng.
        ibapigm_item-base_uom   = i_items_trans-meins.
        ibapigm_item-entry_qnt  = i_items_trans-ktmng.
        ibapigm_item-entry_uom  = i_items_trans-meins.
        ibapigm_item-batch      = i_items_trans-charg.
        APPEND ibapigm_item.
      ENDLOOP.
    Header data like:
      MOVE: sy-datum TO bapigm_head-pstng_date,
            sy-datum TO bapigm_head-doc_date,
            sy-uname TO bapigm_head-pr_uname,
            v_mblnr  TO bapigm_head-ref_doc_no,
            con_bfwms_bestand TO bapigm_head-ext_wms.
    *- Document Header Text
      IF NOT v_bktxt IS INITIAL.
    *- Preceed "INV=" to the Invoice number entered
        CONCATENATE 'INV='(003) v_bktxt INTO v_bktxt
        SEPARATED BY space.
        bapigm_head-header_txt = v_bktxt.
      ENDIF.
      MOVE gmcode_01 TO bapigm_code-gm_code.
    And calling the BAPI as:
      CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
        EXPORTING
          goodsmvt_header  = bapigm_head
          goodsmvt_code    = bapigm_code
        IMPORTING
          goodsmvt_headret = bapigm_headret
        TABLES
          goodsmvt_item    = ibapigm_item
          return           = ibapigm_ret.
    *- Commit on Success
      IF NOT bapigm_headret-mat_doc IS INITIAL.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
      ENDIF.
    Havent faced any problem so far...
    Did you populate <b>EXPIRYDATE</b> in  structure <b>BAPI2017_GM_ITEM_CREATE</b>? If yes, see in debugging, whatz happening to this value.
    Regards,
    Raj

  • Expiry date for items

    Hi all,
    Is it possible to set Expiry date for Item. if so, how?
    Plz let me know,
    thanks in advance
    Kumar

    Hi,
    There is no Expiry date field available in the Item Master Data. However, you can check the option of the Validity dates in Item Master Data or if your item is a batch managed item, then you can have the batch expiry date.
    Kind Regards,
    Jitin
    SAP Business One Forum Team

  • Issue regarding Batch determination in Production order as per Expiry date.

    Dear all,
                    first of all  happy Navratri.
    I have issue regarding batch determination in production order.
    I have to compare P.O header materialu2019s expiry date and issuing components expiry date at the time of batch determination.
    lets take example,  Material having self life is u201CXu201D years and batch determination against PO is based on FEFO with the help of self life we can determine Expiry date of manufacturing material  suppose it is u201CYu201D  I have to introduce restriction at the time of good issue if expiry date of issuing components u201CZu201D is less than expiry date u201CYu201D.
    Please give your valuable suggestions either standard or through SAP enhancements.
    thanks & Regards
    SIVA

    Dear
    Thanks for your reply, i am layman about batch derivation can u elaborate it.
    Thanks & Regard

  • Same Batch with different expiry dates

    Dear all,
    My vendor produced the same batch Y28 at an interval of 3 days eg 10/10/2008 , 11/10/2008, 12/10/2008 with an expiry date of 1year.
    He sent in the batch Y28 to me with the following expiry date 10/10/2009, 11/10/2009 and 12/10/2009.
    During GR, I need to enter the expiry date. However, I realised that the Batch Master for the same batch can only have 1 expiry date. I end up with the latest expiry date of 12/10/2009.
    Could anyone advise on how the above scenario sould be handled?
    Can I maintain 3 different expiry date for the same batch?
    Is it a norm that the same batch can have different expiry date?
    Thank you

    You should create a separate batch per day, if you really think that the exact date of expiry matters for a material that has a shelf life of one year.

  • Sales report with Batch number & expiry dates

    Hello friends,
    would any one please help me to frame this query to achieve the above ..
    my query is as bellow, but I want to add the batch number & expiry dates along with the other information.....
    SELECT T0.[DocNum], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[NumAtCard], T1.[ItemCode], T1.[Dscription], T1.[Quantity] FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry WHERE T1.[ItemCode] >=[%0] AND  T1.[ItemCode] <=[%1] AND  T0.[DocDate] >=[%2] AND  T0.[DocDate] <=[%3]
    So which table to join to get the batch & expiry...
    Rgds
    Suman

    HI
    Batch table is OIBT, IBT1,OBTN
    SELECT distinct T0.[DocNum], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[NumAtCard], T1.[ItemCode], T1.[Dscription], T1.[Quantity], T4.[ExpDate] FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry inner join
    IBT1 T2 on T1.ItemCode = t2.ItemCode and T0.objtype=T2.basetype and T2.baseentry=T1.Docentry inner join
    oitm T3 on T1.Itemcode=T3.Itemcode inner join OIBT T4 on T1.Itemcode=T4.Itemcode  WHERE T1.[ItemCode] >=[%0] AND  T1.[ItemCode] <=[%1] AND  T0.[DocDate] >=[%2] AND  T0.[DocDate] <=[%3]
    group by T0.[DocNum], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[NumAtCard], T1.[ItemCode], T1.[Dscription], T1.[Quantity],T4.[ExpDate]
    Thanks
    Mohammad Imran

  • Batch shelf life expiry date at Plant level

    Hi All,
                We have a requirement from the client to maintain Batch shelf life at plant level.
    Current process: Batch shelf life expiry date is maintained at the global level.
    Requirement: Shelf life data to be maintained at Global level and plant level both.We want flexibility to maintain shelf life both at Global level and plant level .
    If any one has worked in this scenario then kindly throw some light to resolve this issue.And also let me know if we move ahead to maintain shelf life data at  global n plant level then which all the area it will get effected in other stream reagrding shelf life best before date.
    This is very critical requirement from client prospective as we have legacy system involved like LIMS & COREDB.
    Your valuable input will be highly appreciated.
    Thanks n Regards,
    Vikas Soni.

    Hi Vikas,
    A doubt out of your query,
    How the expiry date is maintained Globally .
    Whenever a GR is done then the expiry date will be tagged to the particulat batch & the expiry date is valid for the batch in the particulat plant. Am I right?
    Thanks & regards
    Mahesh

  • Reg blocking of batch on expiry date

    Dear all,
    What are the selections to be done in QA07 for blocking a batch on expiry date which is 3 days from today, we also have batch status active.
    Thanks in advance
    Madhav

    Hi
    In QA07 select
    1. Block batch at lot creation.
    2.Initial Run  in days : 3 or maore
    3.click on the check box of Block batch
    Also Mainatin shelf life data in MM and keep expiry date 3 days later.
    schedule the batch run in the background.
    I hope this will add some values
    Regards
    Sujit

  • In the packing list, batch number and expiry date is not appearing for a ma

    Dear Friends,
    I have an issue in the packinglist.
    In the packing list, batch number and expiry date is not appearing for a material.
    But in the delivery the batch number and expiry date is appearing.
    Why this has triggered and how to solve this?
    With regards

    Hi Vamsi,
              Please go through the output type Smart form or script programe of the packing list and check with the abaper If is there any Bug.
    Regard's
    Murali.

  • Batch selection as per expiry date

    Hi,
    Please have alook at my requirement and suggest the possible solution.
    We have raw material which is handles in batches. Let's say a raw material has three batch in the stock M1, M2 and M3.
    M1 expiry date is on march10,  M1 expiry date is on april10,  M1 expiry date is on June 10.
    So when i create a process order system should always pick a batch for which expiry date is close. That is it should select batch M1.
    Please let me know if it is possible.
    Thanks,
    Dutta

    Hi Debasish,
    Please follow the given below link. I hope this will serve your purpose.
    Re: BATCH SELECTION DURING ISSUE
    Regards,Kundan

  • Alert query not working based on expiry date

    Hi Experts,
    I want to set up an alert for a UDF fields in my Sales Order Title based on the date which is put. The field is expiry date and I want that before 7 days of expiry date Alert should pop up. I am using the below query but No Alert is coming which is already set in Alert Management 
    I also want that 2 alerts should come which is before 7 days and before 15 days of expiry date.
    declare @datevar datetime
    select @datevar = getdate()
    SELECT T0.[DocNum], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[U_LCVal], T0.[U_LCSDate], T0.[U_LCEdate] FROM ORDR T0 WHERE DATEDIFF(DD, T0.U_LCEdate, @datevar) > 7
    Please guide what might be wrong.
    Regards,
    kamlesh

    hi,
    SELECT T0.[DocNum], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[U_LCVal], T0.[U_LCSDate], T0.[U_LCEdate] FROM ORDR T0 WHERE DATEDIFF(DD, T0.U_LCEdate, getdate()) <= 7
    OR DATEDIFF(DD, T0.U_LCEdate, getdate()) <= 15
    Jeyakanthan

  • A/R Invoice PLD - Expiry Date, Mfg Date, Batch No.

    Hi,
    We are using SAP 2007A.
    We have customized the Print Layout. for the Delivery and A/R Invoice documents.  In both docs, we have used system variables for batch, exp date & mfg date.
    When we create an invoice directly (i.e. without a base document), then print it, we are able to get the batch, exp and mfg date perfectly.
    However, when we create the Invoice from the base document i.e. Delivery, and then try to print it, we are unable to print the batch, exp & mfg. When we print the Delivery, it prints the batch, exp & mfg just fine.
    We need to be able to create a/r invoice from delivery & print the batch, exp & mfg on the Invoice.
    Please advise.
    Thanks.

    Hi Afzal,
    Gordon is very much right,
    Atually PLD is very basic tool , one time its ilnk with only one marketing document either delivery, invoice or sales order etc.
    when someone prints invoice , PLD related to invoice will ativate so data fron Delivery is no where in any case as when u copy the invoice from delivery the  concern data is copied fron delivery (odln,dln1.....)tables to oinv,inv1....... tables from which pld took the  data , so u can use UDF and apply formateed search on invoice to fill the batch no or all other field u want , u an also take help of sdk as on making of invoice from delivery the specified data should copied.
    You an use crystal report and geet all data as u want .
    rgds,
    Premraj

  • Report for recieved, expiry dates of shelf life of materials

    Dear Gurus,
    I did nt find the solution in MB5M, because i want report for shelf life of materials based on recived date, expiry date, please share.

    Hi,
    When ever a material is having a shelf life , based upon the manyfactring date and the receiving date , the remaining shelf life can be found . If you want have a report which says the shelf life and receve date of a perticular batch and what should be the remaining shlef life or whather expired , once come into the plant , if not utilized , can be done through a ZREPORT or a query for the same .
    Regards,

  • Wrong Expiry date in MSc2N

    Dear All
    As per my business process i need expiry and retest date one day before from the Mfg date.
    Fo that i have maintained the data in remaining shelf life /Maximum shelf life/Total shelf life and inspection interval in MM.
    I.e If mfg date : 12.12.2008 and based on stability i need recurring inspection after 1 year and want to keep expiry as 3 year.
    data maintained in MM as
    MM                                                                                Date appear in MSC2N
    Inspection interval : 364 days                                              11.12.2009
    Remaining shelf life : 1094                                                   12.12.2011
    Maximum and total shelf life : 1095.
    My requirement is, expiry date shall update as 11.12.2011 insead of 12.12.2008
    AYK

    Hi,
    Maintain Min. Rem. Shelf Life : 1, Total shelf life : 1094, Period Ind. for SLED : D in Plant data/stor.1 and Inspection interval :365 in Quality Management views of Material master.
    Now create batch, enter manufacturing date and check for expiry date.
    Check it and revert back for further clarifications
    regards
    Venkat.V

  • The stock consumption as per expiry date and not as per availability date

    Hi All,
    We had a requirement like below for our client:
    While creating batch in ECC we put the expiry date for the batch as per the business requirement.
    Suppose batch creation date: 01.01.2011
    If in case the SKU shelf life is 1 year the logical expiry date should be 31.12.2011.
    But here user can put any expiry date (there is genuine business reasons behind that), so for one SKU for one Availability date of the batch we can have 2 expiry date.
    Please see below one example for the same:
                         EXPIRY DATE                 SHELF LIFE                    AVL DATE
    batch-1        08.10.2012                       720                              19.10.2010
    batch-2        06.06.2012                       365                              12.06.2011
    batch-3        01.08.2012                       360                              03.08.2011
    In the above case the SKU which is available first is having a long expiry period and vice versa.
    As per standard SAP the stock which is available first will be consumed first. So as per standard SAP batch1 will be consumed first than batch-2 and than batch-3.
    But our requirement is to consume stock based on the expiry date of the stock.So the stock which is going to expire first will be consumed first. In the above scenario the consumption should happen like batch-2 first than batch-3 and than batch-1.
    The client requirement is to consume the stock as per the expiry date and not as per the Availability date (this is what happens in the usual scenario).
    Could you please suggest how to incorporate this?
    Thanks in Advance,
    Mukesh Pandey

    Hi Mani,
    Thanks for your prompt reply.
    I tried using the characteristic for Expiry date as the sort criteria as per sap note 377186.
    After doing the changes in the structure as suggested by SAP note i was able to see this characteristics as one of the sorting criteria. But when I am trying to create pegging relationship between demand and supply element he message i am gtting is "MAX_SL_DATE" can not be used as a sorting criteria in a fix pegging.
    System is just ignoring it.
    We have batch managed stock here and stock availability date is batch creation date.But since we are manually creating batch in ECC and cifing it to APO we are getting scenarios where for the same creation date of batches we have different expiry dates.
    I hope i am clear now.
    Could you please suggest any other option as sorting is not working .
    Regards,
    Mukesh Pandey

Maybe you are looking for

  • How do I transfer arrange  regions   from Logic 8 to Logic 9 Pro?

    I am tired of waiting for Logix X or whatever it will be called and  intend to download Logic 9 pro  from the app store.   I  moved  my old Logic 8 to the  new  mountian lion macbook pro, but  am having  dreaded system error notifcations on the first

  • How to get products based on Material Group 2

    Hi all, I want to find out all the products for a particular "Material Group 2". COMM_PRODUCT table dosent contain the Material Group 2 field. I tried finding in other tables, but couldnt find relation between Material Group 2 and the product. any hi

  • SOAP to IDOC scenario

    Hello All, I have a scenario where the sender system is outside our landscape and I need to post the PO data to SAP system using XI. I know its a SOAP to IDOC scenario but I am not given a wsdl but am given only a xsd and one XML as input. Can I use

  • Find/Replace Extended Character Set characters in filenames in one pipeline

    Hello all, I have to work with some very bored people. Instead of putting a dash (hex 2d) into a filename, they opt for something from this set of extended characters, which makes my regular expressions fail.  IS there a way I can efficiently find &

  • External clock

    Hi, when Using the Cont Acq&Graph Voltage-Ext Clk.vi i have Rate and Samples to read controls. Is that means that evry time my external clock rise (for example) the Acq is done by a sorce clock inside the daq card at the sample rate value is what Rat