Rewrite draft document batch query for live document

Hello Experts,
I have written a query that returns data from DRAFT A/P Credit Memos.  It returns all line items and includes all linked batch numbers if any.
I want to run the same query against A/P Credit memos once the document is 'added'.  Here's the current query...
select odrf.docentry, DRF1.itemcode, DRF1.dscription, odrf.cardcode, obtn.distnumber, odrf.Docdate as 'Date Opened'
from odrf
join DRF1 on odrf.docentry = DRF1.docentry
left join DRF16 on DRF1.docentry = DRF16.absentry AND DRF1.linenum = drf16.linenum
left join obtn on DRF16.objabs = obtn.absentry
where DRF1.dscription IS NOT NULL
AND odrf.objtype = 19
I'm having a difficult time translating this logic over to live documents.  It seems there is no equivalent table to DRF16 on live documents? 

Yes I tried that.  However my RPC16 table is empty.  Which is odd because you would think after adding a draft document into a live document the data from DRF16 would show up in RPC16.  This appears to be the case for DRF1 to RPC1 tables at least...

Similar Messages

  • Advise on sql query for batch job

    Hi all,
    I'm planning to perform a batch query for 4000 records.
    The query is as follows and we will loop it for 4000 times.
    select w.idno, w.place, e.user_arrival_dt from main.tbl_user w, main.tbl_job e
    where w.idno = e.idno and w.idno = <idno>
    I find that rather inefficient in term of performance.
    I can use the below too but the the in clause has a limit.
    select w.idno, w.place, e.user_arrival_dt from main.tbl_user w, main.tbl_job e
    where w.idno = e.idno and w.idno in <idno1, idno2, idno3, idno4, etc>
    Another way that I can think of is to loop for 10 times and use this query
    select w.idno, w.place, e.user_arrival_dt from main.tbl_user w, main.tbl_job e
    where w.idno = e.idno and w.idno in <idno1, idno2, idno3, idno4, until idno400>
    is there any other more efficient way of coding to achive the above?
    kindly advise.
    thanks!

    Hi,
    Qwerty and Surachart are right; the best way is to put the 4000 values into 4000 rows of a table (perhaps a Global Temporary Table) and use a sub-query.
    If you really must have 4000 literals, then you can have 4000 items in a list like this:
    where      w.idno      = e.idno
    and      (w.idno, 0) IN     ( (idno1,    0)
                   , (idno2,    0)
                   , (idno3,    0)
                   , (idno4000, 0)     
                   )See [this thread|http://forums.oracle.com/forums/thread.jspa?messageID=3508573&#3508573] for discussion.

  • See batch numbers allocate in draft document

    Hi,
    I have doing a good exit and I have chosed batch numbers. I have doing a draft of this good exit. When I want to do a query about the draft I haven't table to see the batch numbers which are allocated. How I can link batch numbers with my draft?
    Thank you
    Séverine

    You can select batch numbers for a good deliveries (Right click/Batch Numbers or CTRL TAB on the quantity field) and then save this document as a draft.
    When you open this draft and again Right click/Batch Numbers on the quantity field, you can see the batch numbers previously selected.
    These batch numbers are not allocated (you can select them when you create another good issue), but there are saved somewhere, and linked to the draft.
    However I can't find in which table these batch numbers are saved (I checked OIBT, IBT1, OSRD).
    I think that the question is : where are these batch numbers saved?

  • Draft documents for Sales return and Goods return

    Morning, Exports,
    I got two questions, pls kindly help!
    1) The draft documents regually if not with approval process, can be removed from draft list, but once it's with approved process, the "approved" draft document can't be removed. How to have it deleted from the list of draft documents?  As there are two many drafts and we need to take them out once its data was adding into system....
    2) Where we can see the serial# that picked for the draft document?
    Thanks!
    Emily

    Here are the answers ---
    1) The draft documents regually if not with approval process, can be removed from draft list, but once it's with approved process, the "approved" draft document can't be removed. --> TRUE
    How to have it deleted from the list of draft documents? --> NOT POSSIBLE FOR DRAFT DOCUMENTS
    As there are two many drafts and we need to take them out once its data was adding into system.... --> USE THE "OPEN ONLY" OPTION TO AVOID THE CLOSED / UNNECESSARY DRAFT DOCS.
    2) Where we can see the serial# that picked for the draft document? -->  GO TO ANY MODULE -> REPORTS -> "Document Drafts Report" --> Document No. [BUT THIS NO. WILL NOT TAKEN IF ANY DOCUMENT IS CREATED AFTER THIS DRAFT OF THE SAME DOCUMENT TYPE. THE FINAL NO. WILL BE THE LAST NO. + 1 OF A PARTICULAR DOCUMENT TYPE]

  • FMS Query for Document Header UDF

    Hi,
    I have created an UDF in the header level of Marketing Document. I want to add FMS on it. UDF Value will be 4% of DocTotal Value and auto Refresh on DocTotal.
    What will be the query for Sales Order.

    I am saving this query
    Select ($[$29.0.number]) * 0.04
    and setting this query in the udf by.
    now when i am creating an order and pressing shift+f2 on it it's giving an error msg : internal error(3006) occured.
    Edited by: Sibasish Sengupta on Dec 8, 2008 1:11 PM

  • User Does Not See Watermark for Draft Document

    Good afternoon experts,
    One of our client has a user that is unable to see the water-marks for draft documents. Watermarks ARE enabled for all documents, and other users can see the watermark for the same document. It is just this one user.
    Any suggestions for what may be causing this? Thanks in advance for the help!

    Hi Cynthia,
    Please check again there may be some difference in Authorization for this User from Other User.
    By the way you are talking about PLD or Crystal.
    Regards::::
    Atul Chakraborty

  • Batch Processing for ACCRUAL documents

    Hi All,
    I am running into this error when processing a batch session for accruals t-code FBS1, it works fine for most accounts however this particular account stops the processing with an error.
    G/L account 125010 requires a valid tax code
    what can I check or fix that would be different about this account?

    I read this in the documentation:
    If necessary, the G/L account can also be set so that the tax code is not a required entry when posting transactions not relevant to tax
    How would I set this?? Or where is it done?

  • Draft Document Question - Credit Memo

    Hopefully one fo the experts will come through for me again!!!
    I have yet another challange.  When printing a Draft Credit memo,  I do not want to print the DRAFT water mark across the document.  I know how to shut that feature off.  Instead,  I would like to print my own message on the Draft Credit Memo, basically stating that is it not yet approved.  I see that ALL draft versions of the Marketing Documents are found in table ODRF and Credit Memos are found in ORIN.  When printing using the PLD,  how do I determine that the document is a DRAFT Credit Memo versus an actual LIVE  Credit Memo?  Is there a flag set similar to ObjType (14 is a Credit Memo)  that species that is a Draft document?  Sounds like a simple question but I am again pulling my hair out on this one!
    Thanks in advance - Again!!!
    Dana

    HI Dana,
    I donu2019t think you can have a different watermark for Draft documents. Instead, you can create a field of type u201CPictureu201D and position it as per the requirements. If this is supposed to be a watermark, rather than a regular field, then uncheck the u201Cbackgroundu201D field in the color tab for all other fields except for this picture/message field. Also create another field (FIELD_XYZ)as variable and the variable no. is 275 u2013 Name it as Doc Status. Create a text field (FIELD_ABC) with value = 6. Create another formula field with formula as FIELD_XYZ==FIELD_ABC. Now the picture field created above needs to be linked to this formula field so that it will print only when the doc is in draft mode.
    Hope this will help u .
    Rgds,
    Premraj

  • Print Draft Document using Crystal Report in SAP 8.8

    I created a Crystal Report Layout using SQL View as data source for AR Invoice which prints out fine. (everthing on 1 page)
    To print Draft Invoice, I copied the view to use ODRF/RDF1 instead of OINV/INV1, copied the Crystal report and updated the data source to the new view. When print Draft Invoice, it prints 3 pages - page 1 blank, page 2 just the "DRAFT" watermark, page 3 the crystal report without watermark.
    Steps to print Draft Invoice: Sales-A/R > Sales Report > Document Drafts Report > Open selected Draft Invoice document > File > Select Layout and Print...
    What is happening behind the scene when printing Draft documents? What is the correct way to print Drafts (e.g. special settings designing Crystal Reports)?
    Thanks,
    Grace

    Thank you for your reply. It works in this specific report.
    But we have both PLD and Crystal Report in the system, changing the settings means the PLD will lose their watermark...
    Also, I don't know how the Draft is displayed, but when select Print Preview for Draft, it's asking for parameter (DocEntry), which I have setup a DocKey@ in Crystal Report and set it in the Selection Manager. Does SAP provide DocEntry in Draft Invoice (ODRF) the same way as in Invoice (OINV)?
    Thanks,
    Grace

  • How to freeze the column edit in Draft document?

    Hi,
    I try the following code and want to freeze the column edit in Item code, Item description and quantity.  However, it just work in Sales Order or PUrchase Order those normal marketing document.  it doesn't work in Draft document.  Anyone can help?
      If BusinessObjectInfo.FormTypeEx = "133" And BusinessObjectInfo.Type = 112 And BusinessObjectInfo.EventType = SAPbouiCOM.BoEventTypes.et_FORM_DATA_LOAD Then
                    If BusinessObjectInfo.BeforeAction = True Then
                        oForm = SBO_Application.Forms.Item(BusinessObjectInfo.FormUID)
                        oboDS = oForm.DataSources.DBDataSources.Item("ODRF")
                        oGenvalue = oboDS.GetValue("U_InvoiceFlag", 0)
                        Dim oOrderMat As SAPbouiCOM.Matrix = oForm.Items.Item("38").Specific  'Content Row'
                        Dim oColumns As SAPbouiCOM.Columns = oOrderMat.Columns
                        Dim oItemColumn As SAPbouiCOM.Column = oColumns.Item("1")       'Item No
                        Dim oItemColumn3 As SAPbouiCOM.Column = oColumns.Item("3")
                        Dim oItemColumn11 As SAPbouiCOM.Column = oColumns.Item("11")
                        If oGenvalue.Trim = "Y" Then
                            'Set Itemcode and Quantity to non-editable
                            oItemColumn3.Editable = False
                            oItemColumn.Editable = False
                            oItemColumn11.Editable = False
                        Else
                            oItemColumn3.Editable = True
                            oItemColumn.Editable = True
                            oItemColumn11.Editable = True
                        End If
                    End If
                End If

    Hi Anna,
    Thanks for posting your code - that helps a lot isolating the issue!
    While your code could work, if the SDK would have been implemented differently, it won't do what you want it to:
    - There is no et_FORM_DATA_LOAD event fired when a draft is loaded (use EventLogger from the B1DE tools - it would have told you that you are looking at an event that doesn't get fired...).
    - Not sure how "BusinessObjectInfo" is defined, but oForm.BusinessObject.Type = "112" does not occurr:
    The business object behind the form is the "real" business object - an Invoice ("13") in your case.
    Thus your code never reaches the lines where you disable the relevant columns... - you could e.g. use .NET Profiler form B1TE to get at least a better idea of what is happening inside the add-on, if you don't like to step through you add-on code.
    - oForm.BusinessObject.Type is a string (remember UDOs!) - not a number.
    - Table "ODRF" is not a datasource behind form "133" - please check the form's XML!
    If you would like to run that check you have to do it differently - using DI API...
    HTH,
    Frank
    Edited by: Frank Moebius on Aug 3, 2009 4:28 PM

  • Can pending draft document edit by approvals?

    Hi all expert,
    I would like to ask your about the pending draft document. Can it be allow edit by approvals(The person who allow approve the document)?
    Example:
    new Purchase Order create by originator, when the approvals received the message & want to revised the amount in the purchase order. Can he/she amend the document amount or quantity?
    It doesn't make sense where the manager cannot revise the document created by users. Right?
    Regards,
    Eric Tan

    Hi
    I think so .He can take a look from alert window and make necessary change and post it .
    I think in alert window ,you need to dbl click on the message and you will see the doocument number and you can link to document and make some changes and post it .
    I donot have test environment to test but i think it should be fine .
    Originator cannot make changes in the document while it is in process . That's for sure.
    Thank you
    Bishal
    Hi Bishal,
    I had test before. It doesn't work.
    Regards,
    Eric Tan
    Edited by: Eric Tan Yan Liang on Apr 13, 2009 4:42 AM

  • How to create Draft Document in CR

    Hi all,
    I try to create draft document in CR using store procedure script.
    So i can preview the document if it's in draft mode and non draft mode.
    When i preview it in draft mode , every thing is ok
    But when i preview it in non draft mode, the draft and non draft data combine together.
    Here is my code
    Create Procedure PO
    @Dockey numeric(19,6)
    @ObjectId numeric(19,6)
    as
    begin
    select PO.* from
      select 'DR' as tipedoc,ODRF.DocNum ,ODRF.DocEntry ,ODRF.CardCode,ODRF.CardName,ODRF.ObjType ,
          ODRF.DocDate,TaxDate, DRF1.ItemCode as itemcode, DRF1.Quantity ,DRF1.unitMsr ,
         OITM.ItemName ,OITM.CodeBars
              from          ODRF
              inner join  DRF1 on ODRF.DocEntry = DRF1.DocEntry
              inner join     OITM on DRF1.ItemCode = OITM.ItemCode
         where ODRF.ObjType = 22
    union all
       select 'ND' as tipedoc,OPOR.DocNum ,OPOR.DocEntry ,OPOR.CardCode,OPOR.CardName,OPOR.ObjType ,
          OPOR.DocDate,TaxDate, POR1.ItemCode as Itemcode, POR1.Quantity ,POR1.unitMsr ,
         OITM.ItemName ,OITM.CodeBars
              from          OPOR
              inner join  POR1 on OPOR.DocEntry = POR1.DocEntry
              inner join     OITM on POR1.ItemCode = OITM.ItemCode
    )PO
    where PO.docentry = @Dockey
    and PO.Objtype = @ObjectId
    end
    Do i miss some thing in my code
    Thanks in advance
    Regards
    Kahkian

    Hello, I think something more efficent could be like this: (ignore the RFQ calculation as it is for integration with an external database other than SAP Business ONE)
    create
    procedure SP_PO_FORMAT
    @DOCKEY
    INTEGER,
    @OBJECTID
    INTEGER
    AS
    if
    @OBJECTID = 112 begin
    select
    t0.docentry,T0.docnum,T0.lictradnum,T0.address,T0.address2, T0.CardCode, T0.CardName, T0.DocDate, T0.DocDueDate, T0.comments,T2.slpname,T3.officetel,T3.email,T4.pymntgroup,T5.firstname, T5.lastname, T5.E_MailL, T5.tel1,
    case
    when T0.doccur = 'USD' THEN T0.DocTotalFC ELSE T0.DocTotal END AS DOCTOTAL, case when T0.doccur = 'USD' THEN T0.vatsumfc ELSE T0.vatsum END AS vatsum,T0.DocCur,
    case
    when T0.Comments like 'Basada en Cotizacion a Proveedores%' then
    case when ISNUMERIC(SUBSTRING(T0.comments,36,CHARINDEX('.',T0.comments,1)-36)) = 1
    then convert(int,SUBSTRING(T0.comments,36,CHARINDEX('.',T0.comments,1)-36))
    else
    case when T0.Comments like 'Basada en solucitud de eProcurement%'
    then
    case when ISNUMERIC(SUBSTRING(T0.comments,37,CHARINDEX('.',T0.comments,1)-37)) = 1
    then convert(int,SUBSTRING(T0.comments,37,CHARINDEX('.',T0.comments,1)-37))
    else 0
    end
    else 0
    end
    end
    else
    case
    when T0.Comments like 'Basada en solucitud de eProcurement%'
    then
    case when ISNUMERIC(SUBSTRING(T0.comments,37,CHARINDEX('.',T0.comments,1)-37)) = 1
    then convert(int,SUBSTRING(T0.comments,37,CHARINDEX('.',T0.comments,1)-37))
    else 0
    end
    else 0
    end
    end
    as rfq,
    T1
    .LineNum,
    T1
    .ItemCode, T1.Dscription, T1.freetxt,T1.unitmsr,T1.Quantity,T1.packqty, T1.Price, T1.vatprcnt,case when T0.doccur = 'USD' THEN T1.totalfrgn else T1.linetotal end as linetotal from sbo_mno.dbo.ODRF T0
    inner
    join sbo_mno.dbo.DRF1 T1 on T0.DocEntry = T1.DocEntry
    left
    join OSLP T2 on T0.slpcode = T2.slpcode
    left
    join OHEM T3 on T2.slpcode = T3.salesprson
    left
    join OCTG T4 on T0.groupnum= T4.groupnum
    left
    join OCPR T5 on T0.cntctcode = T5.cntctcode
    where
    T0.Docentry = @DOCKEY
    END
    ELSE
    select
    t0.docentry,T0.docnum,T0.lictradnum,T0.address,T0.address2, T0.CardCode, T0.CardName, T0.DocDate, T0.DocDueDate, T0.comments,T2.slpname,T3.officetel,T3.email,T4.pymntgroup,T5.firstname, T5.lastname, T5.E_MailL, T5.tel1,
    case
    when T0.doccur = 'USD' THEN T0.DocTotalFC ELSE T0.DocTotal END AS DOCTOTAL, case when T0.doccur = 'USD' THEN T0.vatsumfc ELSE T0.vatsum END AS vatsum,T0.DocCur,
    case
    when T0.Comments like 'Basada en Cotizacion a Proveedores%' then
    case when ISNUMERIC(SUBSTRING(T0.comments,36,CHARINDEX('.',T0.comments,1)-36)) = 1
    then convert(int,SUBSTRING(T0.comments,36,CHARINDEX('.',T0.comments,1)-36))
    else
    case when T0.Comments like 'Basada en solucitud de eProcurement%'
    then
    case when ISNUMERIC(SUBSTRING(T0.comments,37,CHARINDEX('.',T0.comments,1)-37)) = 1
    then convert(int,SUBSTRING(T0.comments,37,CHARINDEX('.',T0.comments,1)-37))
    else 0
    end
    else 0
    end
    end
    else
    case
    when T0.Comments like 'Basada en solucitud de eProcurement%'
    then
    case when ISNUMERIC(SUBSTRING(T0.comments,37,CHARINDEX('.',T0.comments,1)-37)) = 1
    then convert(int,SUBSTRING(T0.comments,37,CHARINDEX('.',T0.comments,1)-37))
    else 0
    end
    else 0
    end
    end
    as rfq,
    T1
    .LineNum,
    T1
    .ItemCode, T1.Dscription, T1.freetxt,T1.unitmsr,T1.Quantity,T1.packqty, T1.Price, T1.vatprcnt,case when T0.doccur = 'USD' THEN T1.totalfrgn else T1.linetotal end as linetotal from sbo_mno.dbo.OPOR T0
    inner
    join sbo_mno.dbo.POR1 T1 on T0.DocEntry = T1.DocEntry
    left
    join OSLP T2 on T0.slpcode = T2.slpcode
    left
    join OHEM T3 on T2.slpcode = T3.salesprson
    left
    join OCTG T4 on T0.groupnum= T4.groupnum
    left
    join OCPR T5 on T0.cntctcode = T5.cntctcode
    where
    T0.Docentry = @DOCKEY

  • Save as draft - Document Number

    hi experts,
    Can we reserve a document number for draft document?
    I added a Purchase Order (draft) and then i created another PO but for this PO i want its number to auto-start with 2.
    Document No 1 is reserved for Draft PO.
    Is that possible?
    I do not want to use Manual Numbering.
    Thank you.
    Regards,
    Lim

    Hi
    Its not possible.if u have post one more doc. then system will increment the no. from the last post doc. no. only..
    for ex: last doc no is 100.
    u r saving a doc. as draft it no. will be 101.
    then when u r posting one more doc. the no will be 101 only ...
    now if u posted the draft doc. then no will be 102..
    Giri

  • First row is empty in draft document

    I have created a DI addon for posting a draft delivery document.  However, in each document there's a empty blank row.  I know that you only need to invoke the lines.add function for second plus rows so I have already made sure that I am not adding a new line on first add.  Any advice for you would much be appreciated.
    Regards
           Dim retVal As Object
            Dim i As Integer = 0
            Dim oDeliveryDoc As SAPbobsCOM.Documents
            oDeliveryDoc = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts)
            oDeliveryDoc.DocObjectCode = SAPbobsCOM.BoObjectTypes.oDeliveryNotes
            oDeliveryDoc.CardCode = selectedBPCode
            oDeliveryDoc.DocDueDate = Today
            Dim row As Object
            While i < CType(DataGrid1.DataSource, DataTable).Rows.Count
                If DataGrid1.IsSelected(i) Then
                    If i > 0 Then
                        oDeliveryDoc.Lines.Add()
                    End If
                    oDeliveryDoc.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oOrders
                    oDeliveryDoc.Lines.BaseEntry = CInt(DataGrid1.Item(i, 8))
                    oDeliveryDoc.Lines.BaseLine = DataGrid1.Item(i, 9)
                End If
                i = i + 1
            End While
            retVal = oDeliveryDoc.Add
            If retVal <> 0 Then
                oCompany.GetLastError(lErrCode, sErrMsg)
                MsgBox(lErrCode & " " & sErrMsg)
            End If

    Hi Alan,
    The blank row that you are referring to, where is that line? Is it the last line in the document? If so, that is standard SBO practice. I tested your code and did the same in SBO itself. I create a Delivery draft with 3 lines and 4 lines are added to the document. The fourth line is the new line that is created automatically when you press tab. The reason is that you can add more lines to a draft document. As soon as you save that draft as an actual document, the last line gets deleted.
    Hope it helps,
    Adele
    Message was edited by: Adele le Roux
    Didn't read properly... see that it's the first row that's empty... Should your code not read:
    If i > 1 Then

  • Converting draft document to invoice document

    Hi everyone -- new SBO developer here, trying to come up to speed on the SDK.  I'm curious how you manage to "convert" an existing draft document (in my case, a draft A/R invoice) to an actual A/R invoice, and then add it at the same time.  Say, for instance, you were to add an "Add" button to the Document Drafts form (3002) so the system would convert the draft to an actual document (just like it does when you double-click the matrix line) and then add that document right then-and-there.
    Right now, my guess is that you simply change several properties on the document object, but I cannot figure out which ones.  I'm assuming I can call the Add method once I change the right properties.  Am I on the right track?
    Thanks for your help!
    Anthony

    Hi Anthony,
    Surprisingly, you cannot "convert" a draft document into a real one.
    If I remember correctly, you will have to copy the data (header + line-by-line) into the invoice (When you want to create an Invoice e.g. based on an order it is a bit easier, but still you have to touch every line setting the reference to the base document... - check-out the sample code in the helpfile + the SDK "COM DI" samples).
    DI API is very much "straightforward" in such things.
    As you certainly already discovered, you have to specify the exact object type when you request a business object (it's just a "container"/reference - no real object on your side of the interface) from Company object.
    This means that in DI API itself would have to happen some more things than just to set a value in case you wanted to set the "type" from draft e.g. to invoice...
    Therefore this feature is unfortunately not yet available.
    Regards,
    Frank

Maybe you are looking for