Invoice Control

I am fi certified and working in ap team. Currently i am working on invoice control support which is an internal module and part of ap in my company. I not able to relate it with my fi studies. Can somebody help me telling where exactly ic comes in standard sap or which module?

Hello Shashank,
I think the component should be FI-AP-AP.
Thanks and best regards,
Ronghua Fan

Similar Messages

  • Duplicate Invoice Control.

    With regards to duplicate invoice control, can anyone advise if they have found a method to ensure that invoices are not processed more than once? Current process in ECC is too rudimentary. Is there a way to configure the system such that it displays a list of both FV60 and MIRO invoices that are potential duplicates based on parameters such as Reference, Amount, Vendor, Name etc?
    Any help here is appreciated.

    Hello,
    If you want to make it from warning to error message, you can restrict it.
    Try to post a same invoice. The system gives a warning message, double click on the warning message. Note down the message number.
    Then go to OBA5
    Give the application area (alphabeticals in the message number is application area)
    and give the message number and switch off the message for online and batch entries.
    In case if the message is not available in OBA5, then go to OBMSG and add the message there, click on switch off button, then you come to OBA5 and switch off.
    If you make this as error, in future, if you post the same invoice reference, the system will stop you. You need to keep that in mind.
    Hope this will solve the purpose.
    Regards,
    Ravi

  • Invoice control on material

    Hi,
    Without quality inspection approval how to prevent invoice posting to the vendor?
    Anirudh,

    Hi,
    The correct process is to block the invoice rather than not post it.
    This is done by activating QM processing and ticking the appropriate key in QM Control keys.
    It works for us. Try it out and let us know if you require any help.
    Regards,
    Deepak.

  • Excise invoice controlling Document???

    Hi Gurus,
    what is the transaction code or menupath for controlling of excise invoice document...?
    can we define some other transaction code forexcise invoice instead of J1IIN or J1IS or J1IJ ???
    How is it posssible?
    Thanks in Advance...
    Ravi kumar

    hi lakshmi pathi,,
    controlling means...
    when we are creating the commercial invoice the controlling doucment is F2, VOFA- it goes to billing document type, F2 is a billing type like wise for excise invoice anything is there???
    RAVI

  • A/R invoice control based on the advace payment %

    Hi all,
    Greetings!
    One of our customer requires,
    They should able to prepare A/R Invoice, when they got 90% of the Invoice amount as advance payment. Otherwise the user should not able to prepare the A/R Invoice.
    Let me know please how this can be achieved in SAP B1.
    Thanks & Regards,
    Venkatesan G.

    By Advanced Payment do you mean down payment invoice?
    There was a similar question which I anwered.  Please click on link below to view the same
    How to track unpaid Down Payment Invoices Before creat the AR Invoice?
    Suda

  • Quality Based Invoice

    Dear Experts,
    Our clients wanted to go quality based invoice,  the following steps i made for the process,
    1. In OQB1 I have set  invoice control key 0007  & assigned in material master and activated.
    2. And message set in MM Invoice M8 280
    When i do MIRO  the document is getting blocked against the payment.
    I tried in F-53 to make the payment system gives error like (document blocked against online payment)
    Where will i get Message NO 280 while releasing the document in MRBR,making payment F-53 or at the time Invoice post MIRO.
    I did t not  get message any where.
    Please guide me How the cyle will work and  is there any other setting required for Quality Based invoice block to get message.
    Thanks & Regards,
    Venkat.

    Dear All,
    Thanks to All
    My question was about Quality based invoice
    The scnerio is if quality is not cleared invoice get blocked for quality clear
    For that invoice we cant make payment.
    Without quality clearing also it  allowing to relase to payment.
    My question is after clear the quality will it realse automatically?
    Thanks
    Venkat

  • SUS ASN & Invoice

    Hi !
    I would like to know the following with respect to the MM-SUS Scenario.
    1. Is it possile to create an Invoice with respect to a PO instead of ASN .
    2. Is it possible to switch off the ASN functionality in SUS.
    3. How do we control follow on docs in SUS scenario.
    Thanks .

    hi,
    1) it is possible to create invoice with respect to a PO instead of ASN.
    2) There will be 'flags' for follow on documents in the 'confirmation' tab , in the  purchase order in MM system ( there will be flags for ASN & purchase order response).
    3) there will be flags for invoice control on the 'invoice' tab in the purchase order in MM system, with this you can control the invoice creation function in SUS

  • Differential invoice creation

    Hi gurus,
    Need urgent help..how are differentials invoices created stepwise.?
    The way I am going about it is.....Sales order-Delivery- invoice-differential invoice in ref to del doc.
    just the concept ? The error I am facing is that while creating a differential invoice from LF to S1, where in no relation between creating a differential invoice and cancellation, As a cancellation should not be allowed while creating a Diff. Invoice.
    regards,
    Vineet

    Hi John,
    Support package which the client is using is 4.0B 38. Whenever I am trying to create Differential invoice in Quality environment which is copy of production, I am getting these mesgs
    " Ind. for differential invoice requires final eval. of all invoice cyles"
    and sometimes
    "Billing type OID2 contains cycls 123456789, uninvoiced cycles: &, nothing
    Differential invoice control requires at least one provisional cycle"
    Somehow it is working in production. So clearly, I am not missing a point here.
    Can you please help me out in this.
    Thank and regards
    Vikram
    Edited by: Vikram Saigal on Feb 10, 2009 11:27 AM

  • Creating XML file from ABAP internal table data....

    Hello,
    I am fethcing data froma  custom table and I have to write data in XMl format. Following is the XML format in which I want data. Is there any function module iN SAP which will help me in writing data from internal table to XML file ?
    <batch>
      <invoice>
        <StatusCode>10</StatusCode>
        <paymentamount>122.00</paymentamount>
         <ReferenceNumber>70980934</ReferenceNumber>
      </invoice>
      <invoice>
         <StatusCode>90</StatusCode>
        <paymentamount>122.00</paymentamount>
         <ReferenceNumber>70980934</ReferenceNumber>
      </invoice>
      <control>
        <InvoiceCount>2</InvoiceCount>
      </control>
    </batch>
    Please help.
    Regards,
    Jainam.

    I suggest you look into "simple transformations". That's SAP's most recent technology for such purposes, as far as I know.
    http://help.sap.com/abapdocu_70/en/ABENABAP_ST.htm
    Thomas

  • Authorizations

    Hi Experts
    In BEx Analyzer there are huge reports (for e.g. 225 reports) but i want to create authorizations for only dealer statement report, daily invoice control report and i want to create authorizations for individual InfoObjectsis it possible in the same report or else is there any solution for that.( in BI.7.0) Could you pls explain to me.
    Thanks and Regards,
      Vikas Raj.

    Hello Vikas,
    As you said, you want to give access to   dealer statement report, daily invoice control report  is it?
    Then collect the info areas, info cubes and the owners of it.
    Do like this. create one role in common and add these authorization objects.
    S_RS_COMP, S_RS_COMP1, S_RS_MPRO and S_RS_ICUBE. These authorization objects are related to authorization of reports, queries and BEx.
    in S_RS_COMP1, maintain the specific authorization by mentioning the owner and the users.
    add S_RS_COMP1 twice. First time mention the owner and give full access to the owners. And second time those who are end users they can execute and display queries.
    Remember that in all the authorization objects, you have maintain the info areas, info/multi providers.
    You dont have to create authorization for each and every info objects inside your info cubes.
    Hope this would help you more.

  • Adding new segment in IDOC

    Hi,
           i have a requirement where based on a condition i need to add a new segment dynamically in Inbound IDOC.
    I have written the code in the user exit of the inbound FM. Its adding new segments and process it perfectly.
    But when i see the IDOC in we02 or we19, i am not able to see the newly added segment.
    Will the newly added segment in FM appear in the We02?
    PS: i have changed the idoc_control-maxsegnum.
    Regards,
    Niyaz

    Hi Niyaz,
    Check out the below program ....Similar to your requirement
    IDoc creation from inbound file
    REPORT ZS7BM000006 message-id ZS7.
    */ Program Name: Creation of DESADV & INVOIC IDocs from file E021
    */ Description : This program reads in external file E021 containing
    *                shipping and invoice data from internal vendors and
    *                creates one DESADV and one INVOIC IDoc per invoice.
    */ Transaction : n/a - run from job Z_ccc_S7B_Annnnn, where
    *                'ccc' = 3-digit client and 'nnnnn' = zero-filled
    *                sequence number matching the scheduled job for E020.
    tables:  lfa1,
             lfm1,
             ekpo,
             eine,
             e1edk01,
             e1edk02,
             e1edk07,
             e1edk08,
             e1edk06,
             e1edk03,
             e1edka1,
             e1edka2,
             e1edp07,
             e1edp09,
             e1edp19,
             e1edp01,
             e1edp02,
             e1edp26,
             e1edp04,
             e1eds01,
             e1eds02,
             zst7f_ty_vendors.
    parameters:  p_path like PATH-PATHEXTERN
                       default '/ftp/atac/in/'.
    data:  INFILE LIKE PATH-PATHEXTERN,
           back_path(7) type c value 'backup/',
           offset like sy-fdpos,
           p07_ctr like sy-index,
           invoice_total type p decimals 3,
           d_seg_num like sy-index,
           i_seg_num like sy-index.
    data:  OUTFILE LIKE PATH-PATHEXTERN,
           today(8)     type c.
    data:  begin of uty_vendors occurs 10,
              lifnr like lfa1-lifnr,
              waers like lfm1-waers,
              name_abbr like zst7f_ty_vendors-name_abbr,
              ship_days like zst7f_ty_vendors-ship_days,
           end of uty_vendors.
    data:  iZSS7B21 like ZSS7B21.
    data:  desadvdata like edi_dd occurs 5 with header line.
    data:  invoicdata like edi_dd occurs 5 with header line.
    data:  dedidc like edi_dc occurs 1 with header line.
    data:  iedidc like edi_dc occurs 1 with header line.
    data:  begin of ie021 occurs 10,
            lifnr            like lfa1-lifnr,
            ship_days        like zst7f_ty_vendors-ship_days,
            invoice_no       like e1edk08-vbeln,
            stat             like e1edk01-action,
            po_number(10)    type n,
            po_lineno(5)     type n,
            slip_number      like e1edp09-vbeln,
            shipto_id        like e1edka1-partn,
            vendor_id        like e1edka1-partn,
            endcust_name     like e1edka1-name1,
            cust_partno      like e1edp09-kdmat,  "char 35
            vendor_partno    like e1edp09-matnr,  "char 35
            invoice_qty      like e1edp09-lfimg,
            qty_uom          like e1edp01-menee,
            unit_price       like e1edp01-vprei,
            price_uom        like e1edp01-pmene,
            price_qty        like e1edp01-peinh,
            line_amount      like e1edp26-betrg,
            currency         like e1edk01-curcy,
            etd              like e1edk06-datum, "ship date
            eta              like e1edk06-datum, "delivery date
            ship_id          like e1edk08-traid,
            ship_method      like e1edk08-traty,
            create_date      like e1edk03-datum,
            plant            like ekpo-werks,
           end of ie021.
    data: save_po like ie021-po_number,
          save_line like ie021-po_lineno,
          save_stat like ie021-stat,
          save_invoice like ie021-invoice_no.
    constants: hun_thou type p decimals 5 value '100000',
               thou type p decimals 3 value '1000'.
    *&      DEFINITION:  append_idoc_rec
    *       add a data record to the IDoc internal table
    define append_idoc_rec.
    &1-tabnam = &1-segnam.
    &2_seg_num = &2_seg_num + 1.
    &1-segnum = &2_seg_num.
    shift &1-segnum left deleting leading space.
    append &1.
    clear &1.
    end-of-definition.       " append_idoc_rec
    * MAIN PROCESSING LOOP
    START-OF-SELECTION.
    today = sy-datum.
    * find all internal vendors
    select a~lifnr
           b~waers
           c~name_abbr  c~ship_days
       into corresponding fields of table uty_vendors
         from lfa1 as a
              inner join lfm1 as b
                 on a~lifnr = b~lifnr
              inner join zst7f_ty_vendors as c
                 on a~lifnr = c~lifnr
         where a~ktokk = 'ZZTY' and
               b~ekorg = '7100' and
               c~ship_code = ' '.
    perform init_desadv.
    perform init_invoic.
    concatenate 'SAP' sy-sysid(3) into: iedidc-sndpor, dedidc-sndpor.
    loop at uty_vendors.
      clear ie021. refresh ie021.
      if not uty_vendors-name_abbr is initial.
    * datafiles are received with naming convention:
    * E020_<customer name abbreviation>_UTY
        concatenate p_path 'E021_' uty_vendors-name_abbr '_UTY'
            into infile.
        if not sy-subrc is initial.  "pathname too long
    * Filename too long: &
          message i016 with infile.
          continue.
        endif.
        condense infile.
        OPEN DATASET INFILE FOR INPUT IN TEXT MODE.
        if not sy-subrc is initial.
    *'Cannot open dataset & on &'
          message i013 with infile sy-datum.
          continue.
        else.
          concatenate p_path back_path 'E021_'
              uty_vendors-name_abbr '_UTY' today
                    into outfile.
          if not sy-subrc is initial.  "pathname too long
    * Filename too long: &
            message i016 with outfile.
            continue.
          endif.
          condense outfile.
          OPEN DATASET OUTFILE FOR OUTPUT IN TEXT MODE.
    * if the datestamped file cannot be created, do not process the
    * input file, because the input file is deleted after processing,
    * and there would be no record of the data.
          if not sy-subrc is initial.
    *'ERROR opening file & for output'
            close dataset infile.
            message i033 with outfile.
            continue.  "process next vendor's file
          endif.
          do.
            read dataset infile into izss7b21.
            case sy-subrc.
              when 0.
                transfer izss7b21 to outfile.
                if izss7b21-datacode = 'T'. "trailer rec
                  perform process_one_vendor using infile.
                  exit.  "process next vendor's file
                endif.
                check: izss7b21-datacode = 'A'. "data rec
                case izss7b21-status.
                  when ' '.  "new
                    ie021-stat = '000'.
                  when 'M'.  "modification
                    ie021-stat = '002'.
                  when 'D'.  "deletion
                    ie021-stat = '003'.
                endcase.
                move-corresponding uty_vendors to ie021.
                move-corresponding izss7b21 to ie021.
                perform convert_po_no using izss7b21-pono_poline
                                   changing ie021-po_number
                                            ie021-po_lineno.
                perform convert_dates using ie021-lifnr
                                            izss7b21-etd
                                            izss7b21-eta
                                            izss7b21-ship_method
                                            izss7b21-create_date
                                   changing ie021-eta
                                            ie021-ship_days.
                perform quantity_conversion
                                    using izss7b21-qty_uom
                                          izss7b21-invoice_qty
                                          izss7b21-unit_price
                                    changing ie021-qty_uom
                                             ie021-invoice_qty
                                          izss7b21-line_amount.
                perform money_conversion
                                    using izss7b21-currency
                                          izss7b21-unit_price
                                          izss7b21-price_uom
                                          izss7b21-line_amount
                                    changing ie021-currency
                                             ie021-price_uom
                                             ie021-price_qty
                                             ie021-unit_price
                                             ie021-line_amount.
                perform SAP_vendor_partno
                                    changing ie021-cust_partno.
                append ie021.
              when 4.  "EOF
                perform process_one_vendor using infile.
                exit.  "process next vendor's file
              when others.
    *ERROR reading dataset & - &
                message i015 with infile sy-datum.
                exit.
            endcase.
          enddo.
          close dataset: infile, outfile.
          delete dataset infile.
        endif.
      endif.
    endloop. "UTY_VENDORS
    *&      Form  process_one_vendor
    *       Pre-processed records from one vendor file are now in the
    *       internal table ie021 - ready to create IDocs
    FORM process_one_vendor using value(infile).
      sort ie021 by invoice_no stat po_number po_lineno.
      loop at ie021.
        if ( ie021-invoice_no <> save_invoice or
             ie021-stat <> save_stat ).
          if sy-tabix > 1.
            perform post_idocs using ie021-stat.
          endif.
          perform idoc_header_segs using ie021-stat.
        endif.
        if ( ie021-stat <> save_stat or
             ie021-po_number <> save_po or
             ie021-po_lineno <> save_line or
             ie021-invoice_no <> save_invoice ).
          if ( sy-tabix > 1 and
               ie021-stat = '000' ).
            perform idoc_poheader_segs.
          endif.
        endif.
        perform idoc_item_segs using ie021-stat.
        save_po = ie021-po_number.
        save_line = ie021-po_lineno.
        save_invoice = ie021-invoice_no.
        save_stat = ie021-stat.
      endloop.
      perform post_idocs using ie021-stat.
    * File successfully processed: &
      message s035 with infile.
    ENDFORM.                    " process_one_vendor
    *&      Form  convert_po_no
    *       Break the PO number & line field into separate fields
    FORM convert_po_no using value(infield)
                       changing po_number like ie021-po_number
                                po_line like ie021-po_lineno.
    data:  cpos like sy-fdpos,
           lpos like sy-fdpos,
           cline(6) type c.
    * if the infield contains a hyphen, assume that the preceding characters
    * represent the po number, if they are numeric. The po line number is
    * assumed to be all numeric characters after the hyphen.
      if infield ca '-'.
        if infield(sy-fdpos) co ' 0123456789'.  "numeric
          po_number = infield(sy-fdpos).
          cpos = sy-fdpos + 1.
        endif.
      else.  "no hyphen - PTY
        if infield(2) = '71'.  "SAP number range
          cpos = 10.
        else.                  "SyteLine number
          cpos = 6.
        endif.
        if infield(cpos) co ' 0123456789'.  "numeric
          po_number = infield(cpos).
        endif.
      endif.
      if not po_number is initial.
        while infield+cpos(1) co '0123456789'.
          cline+lpos(1) = infield+cpos(1).
          lpos = lpos + 1.
          cpos = cpos + 1.
        endwhile.
        shift cline left deleting leading '0'.
        if not cline is initial.
          po_line = cline.
        endif.
      endif.
    * Put out a warning in the job log, but create the IDoc to save the data
      if ( po_number is initial or
           po_line is initial ).
    * PO number - line item conversion failed: &
        message i034 with infield.
      endif.
    ENDFORM.                    " convert_po_no
    *&      Form  convert_dates
    *       Convert ship date to delivery date, if necessary
    FORM convert_dates using value(vendor_no)
                             value(i_ship_date)
                             value(i_delivery_date)
                             value(i_ship_code)
                             value(i_create_date)
                    changing o_delivery_date
                             ship_days.
    data:  ship_date type d.
    * if delivery date not sent, calculate it from ship date plus
    * ship days.
    * Note that this logic could leave delivery date blank,
    * if ship date is not numeric.
      if ( i_delivery_date is initial or
           i_delivery_date co ' 0' ).  "no delivery date sent
        if ( i_ship_date co ' 0123456789' and
             i_ship_date cn ' 0' ).    "ship date sent
    * move the ship date into a date field to add days
          ship_date = i_ship_date.
        elseif ( i_create_date co ' 0123456789' and
                 i_create_date cn ' 0' ).
          ship_date = i_create_date.
        endif.
        if not i_ship_code is initial.
          select single ship_days from zst7f_ty_vendors
                   into ship_days
                  where lifnr = vendor_no
                    and ship_code = i_ship_code.
        endif.
        if not ship_date is initial.
          if ship_days > 0.
            ship_date = ship_date + ship_days.
            o_delivery_date = ship_date.
            shift o_delivery_date left deleting leading ' '.
          endif.
        endif.
      else.  "delivery date sent
        o_delivery_date = i_delivery_date.
      endif.
    ENDFORM.                    " convert_dates
    *&      Form  quantity_conversion
    *       The quantities in the input file are implied 3-decimal,
    *       so need to be converted into a "real" number.
    *       Also, the unit of measure may be 'KP' indicating that the qty
    *       is given in thousands.
    FORM quantity_conversion USING    value(i_UOM)
                                      value(i_invoice_qty)
                                      value(i_unit_price)
                        CHANGING o_uom like iE021-qty_UOM
                                 o_invoice_qty like IE021-INVOICE_QTY
                                 c_LINE_AMOUNT like izss7b21-line_amount.
    data:  f_invoice_qty type f.
    data:  n_invoice_qty like lips-kcmeng.
    data:  f_unit_price type f.
    data:  f_line_amt type f.
    data:  n_line_amt0 type p decimals 0.
      if ( i_invoice_qty co ' 0123456789' and
           i_invoice_qty cn ' 0' ).
        f_invoice_qty = i_invoice_qty.
    * if no extended price is sent, calculate it
        if c_line_amount is initial.
    * the qty is implied 3-dec, the price is still implied
    * 5-dec, and line amount should be implied 3-dec.
          f_unit_price = i_unit_price.
          f_line_amt = ( f_invoice_qty * f_unit_price ) / 100000.
          n_line_amt0 = f_line_amt.
          c_line_amount = n_line_amt0.
          shift c_line_amount left deleting leading space.
        endif.
    * if the invoice qty is per 1000, the implied 3-dec times 1000 equals
    * the unconverted value. Otherwise, divide by 1000 to get the PCE qty
        if i_uom = 'KP'.
          n_invoice_qty = f_invoice_qty.
        else.
          n_invoice_qty = f_invoice_qty / thou.
        endif.
      endif.
      o_uom = 'PCE'.
      if not n_invoice_qty is initial.
        o_invoice_qty = n_invoice_qty.
        shift o_invoice_qty left deleting leading space.
      else.
        clear o_invoice_qty.
      endif.
    ENDFORM.                    " quantity_conversion
    *&      Form  money_conversion
    *       Add the implied decimals and store price-per qty, if
    *       price per 1,000 is sent.
    FORM money_conversion USING    value(I_CURR)
                                   value(i_UNIT_PRICE)
                                   value(i_UOM)
                                   value(i_LINE_AMOUNT)
                          CHANGING o_CURRENCY like ie021-currency
                                   o_PRICE_UOM like ie021-price_uom
                                   o_PRICE_QTY like ie021-price_qty
                                   o_UNIT_PRICE like ie021-unit_price
                                   o_LINE_AMOUNT like ie021-line_amount.
    data:  n_unit_price type p decimals 5,
           n_line_amount type p decimals 3.
    * not all of the vendors send the currency code, so use the vendor
    * master default
      case i_curr(2).
        when 'US'.
          o_currency = 'USD'.
        when 'JP'.
          o_currency = 'JPY'.
        when others.
          o_currency = uty_vendors-waers.
      endcase.
    * unit price is implied 5-dec
      if ( i_unit_price cn ' 0' and
           i_unit_price co ' 0123456789' ).
        n_unit_price = i_unit_price.
        n_unit_price = n_unit_price / hun_thou.
      endif.
    * line price is implied 3-dec
      if ( i_line_amount co ' 0123456789' and
           i_line_amount cn ' 0' ).
        n_line_amount = i_line_amount.
        n_line_amount = n_line_amount / thou.
      endif.
    * 'KP' = price per thousand
      if i_uom = 'KP'.
        o_price_qty = '1000'.
      else.
        o_price_qty = '1'.
      endif.
      o_price_uom = 'PCE'.
      if not n_unit_price is initial.
        o_unit_price = n_unit_price.
        shift o_unit_price left deleting leading space.
      else.
        clear o_unit_price.
      endif.
      if not n_line_amount is initial.
        o_line_amount = n_line_amount.
        shift o_line_amount left deleting leading space.
      else.
        clear o_line_amount.
      endif.
    ENDFORM.                    " money_conversion
    *&      Form  SAP_vendor_partno
    *       replace UTY part number sent by vendor with SAP material no.
    *       from PO line item.
    FORM SAP_vendor_partno changing cust_partno like ie021-cust_partno.
    tables: makt.
    data: partno_sent like makt-maktx.
      partno_sent = cust_partno.
      clear: makt, cust_partno.
      select single matnr from ekpo into cust_partno
             where ebeln = ie021-po_number and
                   ebelp = ie021-po_lineno.
      if sy-subrc is initial.
    *compare material description to part number sent by vendor
        select single maktx from makt into makt-maktx
            where matnr = cust_partno.
        if partno_sent <> makt-maktx.
    * 'Part No. Mismatch: PO & - &, Part sent &, SAP mat.no. &'
          message i031 with ie021-po_number ie021-po_lineno
                            partno_sent makt-maktx.
        endif.
      else.  "PO line not found
    *try to find SAP material number using 20-char catalog no. sent
        select single matnr from makt into cust_partno
            where maktx = partno_sent.
        if not sy-subrc is initial.
    * 'SAP material no. not found for & - PO & - &'
          message i032 with partno_sent ie021-po_number ie021-po_lineno.
        endif.
      endif.
    *if not found, IDoc will go to workflow for missing material no.
    ENDFORM.                    " SAP_vendor_partno
    *&      Form  idoc_header_segs
    *       create internal table entries for header segments.
    *  DESADV:
    *          E1EDK07
    *          E1EDKA1
    *          E1EDK03
    *          E1EDK08
    *          E1EDKA2
    *          E1EDK06
    *  INVOIC:
    *          E1EDK01
    *          E1EDKA1(s)
    *          E1EDK02
    *          E1EDK03(s)
    FORM idoc_header_segs using value(desadv_ok).
    * INVOIC
      clear i_seg_num.
      invoicdata-segnam = 'E1EDK01'.
      e1edk01-action = ie021-stat.
      if ie021-currency(2) = 'US'.
        e1edk01-curcy = 'USD'.
      else.
        e1edk01-curcy = 'JPY'.
      endif.
      invoicdata-sdata = e1edk01.
      append_idoc_rec invoicdata i.
      clear e1edka1.
      invoicdata-segnam = 'E1EDKA1'.
      e1edka1-parvw = 'RE'.
      e1edka1-partn = ie021-shipto_id.
      invoicdata-sdata = e1edka1.
      append_idoc_rec invoicdata i.
      clear e1edka1.
      invoicdata-segnam = 'E1EDKA1'.
      e1edka1-parvw = 'LF'.
      e1edka1-partn = ie021-lifnr.
      e1edka1-lifnr = ie021-shipto_id.
      invoicdata-sdata = e1edka1.
      append_idoc_rec invoicdata i.
      if not ie021-endcust_name is initial.
        clear e1edka1.
        invoicdata-segnam = 'E1EDKA1'.
        e1edka1-parvw = 'WE'.
        e1edka1-name1 = ie021-endcust_name.
        invoicdata-sdata = e1edka1.
        append_idoc_rec invoicdata i.
      endif.
      clear e1edk02.
      invoicdata-segnam = 'E1EDK02'.
      e1edk02-qualf = '009'.
      e1edk02-belnr = ie021-invoice_no.
      invoicdata-sdata = e1edk02.
      append_idoc_rec invoicdata i.
      clear e1edk03.
      invoicdata-segnam = 'E1EDK03'.
      e1edk03-iddat = '012'.
      e1edk03-datum = ie021-create_date.
      invoicdata-sdata = e1edk03.
      append_idoc_rec invoicdata i.
      invoicdata-segnam = 'E1EDK03'.
      e1edk03-iddat = '024'.
      invoicdata-sdata = e1edk03.
      append_idoc_rec invoicdata i.
      check desadv_ok = '000'.
    * DESADV
      clear d_seg_num.
      desadvdata-segnam = 'E1EDK07'.
      e1edk07-action = ie021-stat.
      e1edk07-bolnr = ie021-invoice_no.
      desadvdata-sdata = e1edk07.
      append_idoc_rec desadvdata d.
      clear e1edka1.
      desadvdata-segnam = 'E1EDKA1'.
      desadvdata-sdata = e1edka1.
      append_idoc_rec desadvdata d.
      clear e1edk03.
      desadvdata-segnam = 'E1EDK03'.
      desadvdata-sdata = e1edk03.
      append_idoc_rec desadvdata d.
      clear e1edk08.
      desadvdata-segnam = 'E1EDK08'.
      e1edk08-vbeln = ie021-invoice_no.
      e1edk08-traid = ie021-ship_id.
      e1edk08-traty = ie021-ship_method.
      desadvdata-sdata = e1edk08.
      append_idoc_rec desadvdata d.
      clear e1edka2.
      desadvdata-segnam = 'E1EDKA2'.
      desadvdata-sdata = e1edka2.
      append_idoc_rec desadvdata d.
      clear e1edk06.
      desadvdata-segnam = 'E1EDK06'.
      e1edk06-iddat = '025'.  "document date
      e1edk06-datum = ie021-create_date.
      desadvdata-sdata = e1edk06.
      append_idoc_rec desadvdata d.
      if not ie021-eta is initial.
        clear e1edk06.
        desadvdata-segnam = 'E1EDK06'.
        e1edk06-iddat = '001'.  "delivery date
        e1edk06-datum = ie021-eta.
        desadvdata-sdata = e1edk06.
        append_idoc_rec desadvdata d.
      endif.
      if not ie021-etd is initial.
        clear e1edk06.
        desadvdata-segnam = 'E1EDK06'.
        e1edk06-iddat = '010'.  "ship date
        e1edk06-datum = ie021-etd.
        desadvdata-sdata = e1edk06.
        append_idoc_rec desadvdata d.
      endif.
    ENDFORM.                    " idoc_header_segs
    *&      Form  idoc_poheader_segs
    *       create internal table entries for DESADV PO/item segments
    *          E1EDP07
    FORM idoc_poheader_segs.
    *DESADV
      clear e1edp07.
      desadvdata-segnam = 'E1EDP07'.
      e1edp07-bstnk = ie021-po_number.
      e1edp07-posex = ie021-po_lineno.
      desadvdata-sdata = e1edp07.
      append_idoc_rec desadvdata d.
      p07_ctr = p07_ctr + 1.
    ENDFORM.                    " idoc_poheader_segs
    *&      Form  idoc_item_segs
    *       create internal table entries for PO item segments:
    *          DESADV:   E1EDP09
    *          INVOIC:   E1EDP01        Qtys
    *                    E1EDP02        ref nos. (PO number / line)
    *                    E1EDP19        part numbers
    *                    E1EDP26        amounts
    *                    E1EDP04        taxes
    FORM idoc_item_segs using value(desadv_ok).
    data:  n_line_amt  type p decimals 3.
    *INVOIC
      clear e1edp01.
      invoicdata-segnam = 'E1EDP01'.
      e1edp01-menee = ie021-qty_uom.
      e1edp01-menge = ie021-invoice_qty.
      e1edp01-vprei = ie021-unit_price.
      e1edp01-pmene = ie021-price_uom.
      e1edp01-peinh = ie021-price_qty.
      e1edp01-netwr = ie021-line_amount.
      invoicdata-sdata = e1edp01.
      append_idoc_rec invoicdata i.
      clear e1edp02.
      invoicdata-segnam = 'E1EDP02'.
      e1edp02-qualf = '001'.
      e1edp02-belnr = ie021-po_number.
      e1edp02-zeile = ie021-po_lineno.
      invoicdata-sdata = e1edp02.
      append_idoc_rec invoicdata i.
      clear e1edp19.
      invoicdata-segnam = 'E1EDP19'.
      e1edp19-qualf = '001'.
      e1edp19-idtnr = ie021-cust_partno.
      invoicdata-sdata = e1edp19.
      append_idoc_rec invoicdata i.
      clear e1edp19.
      invoicdata-segnam = 'E1EDP19'.
      e1edp19-qualf = '002'.
      e1edp19-idtnr = ie021-vendor_partno.
      invoicdata-sdata = e1edp19.
      append_idoc_rec invoicdata i.
      clear e1edp26.
      invoicdata-segnam = 'E1EDP26'.
      e1edp26-qualf = '003'.
      e1edp26-betrg = ie021-line_amount.
      invoicdata-sdata = e1edp26.
      append_idoc_rec invoicdata i.
    * dummy tax seg
      clear e1edp04.
      invoicdata-segnam = 'E1EDP04'.
      e1edp04-msatz = '0.00'.
      invoicdata-sdata = e1edp04.
      append_idoc_rec invoicdata i.
      n_line_amt = ie021-line_amount.
      invoice_total = invoice_total + n_line_amt.
      check desadv_ok = '000'.
    *DESADV
      clear e1edp09.
      desadvdata-segnam = 'E1EDP09'.
      e1edp09-vbeln = ie021-slip_number.
      e1edp09-matnr = ie021-vendor_partno.
      e1edp09-vrkme = ie021-qty_uom.
      e1edp09-lfimg = ie021-invoice_qty.
      desadvdata-sdata = e1edp09.
      append_idoc_rec desadvdata d.
    ENDFORM.                    " idoc_item_segs
    *&    Form  post_idocs
    *     create database IDocs from the idocdata tables and clear tables.
    FORM post_idocs using value(desadv_ok).
    *INVOIC
      clear e1eds01.
      invoicdata-segnam = 'E1EDS01'.
      e1eds01-sumid = '010'.
      e1eds01-summe = invoice_total.
      e1eds01-waerq = ie021-currency.
      shift e1eds01-summe left deleting leading space.
      invoicdata-sdata = e1eds01.
      append_idoc_rec invoicdata i.
      CALL FUNCTION 'INBOUND_IDOC_PROCESS'
        TABLES
          IDOC_CONTROL       =  iedidc
          IDOC_DATA          =  invoicdata.
      commit work.
    *DESADV
      if desadv_ok = '000'.
        clear e1eds02.
        desadvdata-segnam = 'E1EDS02'.
        e1eds02-sumid = '001'.
        e1eds02-summe = p07_ctr.
        shift e1eds02-summe left deleting leading space.
        desadvdata-sdata = e1eds02.
        append_idoc_rec desadvdata d.
        CALL FUNCTION 'INBOUND_IDOC_PROCESS'
          TABLES
            IDOC_CONTROL       =  dedidc
            IDOC_DATA          =  desadvdata.
        commit work.
      endif.
      refresh: desadvdata,
               invoicdata.
      clear:
        desadvdata,
        invoicdata,
        p07_ctr,
        invoice_total,
        save_stat,
        save_po,
        save_line,
        save_invoice.
    ENDFORM.                    " post_idocs
    *&      Form  init_desadv
    *       add a DESDAV control record and initialize fields
    FORM init_desadv.
    clear dedidc. refresh dedidc.
    * initialize control record:
    move:  '2'        to  dedidc-direct,
          'DESADV01'  to  dedidc-doctyp,
          'DESADV'    to  dedidc-mestyp,
          'F'         to  dedidc-std,
          'E021'      to  dedidc-stdmes,
          'LS'        to  dedidc-sndprt,
          'TY_VENDORS' to dedidc-sndprn,
          sy-datlo    to  dedidc-credat,
          sy-timlo    to  dedidc-cretim.
    append dedidc.
    ENDFORM.              " init_desadv
    *&      Form  init_invoic
    *       add a INVOIC control record and initialize fields
    FORM init_invoic.
    clear iedidc. refresh iedidc.
    * initialize control record:
    move:  '2'        to  iedidc-direct,
          'INVOIC01'  to  iedidc-doctyp,
          'INVOIC'    to  iedidc-mestyp,
          'MM'        to  iedidc-mescod,
          'F'         to  iedidc-std,
          'E021'      to  iedidc-stdmes,
          'LS'        to  iedidc-sndprt,
          'TY_VENDORS' to iedidc-sndprn,
          sy-datlo    to  iedidc-credat,
          sy-timlo    to  iedidc-cretim.
    append iedidc.
    ENDFORM.              " init_invoic
    REWARD POINTS IF HELPFUL
    Lakshmiraj.A

  • Help with combining SQL

    Hello,
    I'm not very familiar with SQL. I have these following two business areas where the SQL code listed below for each works fine as their own stand alone areas. I need to create a report that gets information from both areas, and I can't get the two to join successfully.
    Could anyone help?
    Business Area 1
    select gjb.name "Batch Name",
    gjh.name "Journal Name",
    gjs.user_je_source_name "Journal Source",
    gjh.je_category "Journal Category",
    gjl.je_line_num "Journal Line",
    gjh.period_name "GL Period",
    gjl.description "Line Description",
    to_number(gir.reference_1) "Amount",
    gir.reference_2 "Employee Name",
    to_char(to_date(gir.reference_3,'DD-MON-YY'),'DD-MON-YY') "Date",
    gir.reference_4 "Payroll/Paypoint/Staff No1",
    gir.reference_5 "Payroll/Paypoint/Staff No2",
    gir.reference_6 "Type of Payroll Run",
    gir.reference_7 "Week / Month",
    gir.reference_8 "Pay Scale/Point on Scale",
    gir.reference_10 "Payscale Type/Hrs/Allw/DC",
    gcc.*
    from gl_je_lines gjl,
    gl_import_references gir,
    gl_je_batches gjb,
    gl_je_headers gjh,
    xxcust_gl_code_combs_mv gcc,
    gl_je_sources gjs
    where gir.je_batch_id=gjb.je_batch_id
    and gjb.je_batch_id=gjh.je_batch_id
    and gir.je_header_id=gjh.je_header_id
    and gjh.je_header_id=gjl.je_header_id
    and gjl.code_combination_id=gcc.code_combination_id_x
    and gjh.je_source=gjs.je_source_name
    and gir.je_line_num=gjl.je_line_num
    and gjl.set_of_books_id=gjh.set_of_books_id
    and gjh.set_of_books_id=gjl.set_of_books_id
    and UPPER(gjs.user_je_source_name)='PAYROLL'
    and gjb.status='P'
    Business Area 2
    select 'AP Invoice Dists' "Transaction Type"
    ,jb.set_of_books_id SoB
    ,jb.journal_batch_id BatchId
    ,jb.journal_batch_name BatchName
    ,jb.period_name Period
    ,jb.balance_type BatchType
    ,jh.journal_entry_name JournalName
    ,jh.journal_source JournalSource
    ,jh.journal_category JournalCategory
    ,jh.currency Currency
    ,aal.accounted_dr AmountDr
    ,aal.accounted_cr AmountCr
    ,jl.journal_entry_id HeaderId
    ,jl.journal_line_number LineNum
    ,gix.gl_sl_link_id LinkId
    ,aal.reference1 Name
    ,aal.reference5 TransactionNumber
    ,aia.invoice_date TransactionDate
    ,decode(pha.segment1,null,'',pha.segment1||' (PO Number)') Other
    ,to_char(aal.reference2) SourceId1
    ,null SourceId2
    ,null SourceId3
    ,'AP_INVOICES' SourceTableA
    ,to_char(pha.po_header_id) SourceIdB
    ,'PO_HEADERS_ALL' SourceTableB
    ,gcc.*
    from glfg_journal_batches jb
    ,glfg_journal_entries jh
    ,glfg_journal_lines jl
    ,gl_import_references gix
    ,ap_ae_lines_all aal
    ,ap_invoices_all aia
    ,ap_invoice_distributions_all aida
    ,po_distributions_all pda
    ,po_headers_all pha
    ,xxcust_gl_code_combs_mv gcc
    where jb.batch_status = 'Posted'
    and jb.balance_type <> 'Encumbrance'
    and jb.journal_batch_id = jh.journal_batch_id
    and jh.journal_source = 'Payables'
    and jh.journal_category = 'Purchase Invoices'
    and jh.journal_entry_id = jl.journal_entry_id
    and jl.journal_entry_id = gix.je_header_id
    and jl.journal_line_number = gix.je_line_num
    and gix.gl_sl_link_table = 'APECL'
    and gix.gl_sl_link_id = aal.gl_sl_link_id
    and aal.reference2 = aia.invoice_id
    and aal.source_table = 'AP_INVOICE_DISTRIBUTIONS'
    and aal.source_id = aida.invoice_distribution_id
    and aida.po_distribution_id = pda.po_distribution_id(+)
    and pda.po_header_id = pha.po_header_id(+)
    and gcc.CODE_COMBINATION_ID_X = jl.account_id
    union all
    select 'AP Invoice Control' "Transaction Type"
    ,jb.set_of_books_id SoB
    ,jb.journal_batch_id BatchId
    ,jb.journal_batch_name BatchName
    ,jb.period_name Period
    ,jb.balance_type BatchType
    ,jh.journal_entry_name JournalName
    ,jh.journal_source JournalSource
    ,jh.journal_category JournalCategory
    ,jh.currency Currency
    ,aal.accounted_dr AmountDr
    ,aal.accounted_cr AmountCr
    ,jl.journal_entry_id HeaderId
    ,jl.journal_line_number LineNum
    ,gix.gl_sl_link_id LinkId
    ,aal.reference1 Name
    ,aal.reference5 TransactionNumber
    ,aia.invoice_date TransactionDate
    ,null Other
    ,to_char(aal.reference2) SourceId1
    ,null SourceId2
    ,null SourceId3
    ,'AP_INVOICES' SourceTableA
    ,null SourceIdB
    ,null SourceTableB
    ,gcc.*
    from glfg_journal_batches jb
    ,glfg_journal_entries jh
    ,glfg_journal_lines jl
    ,gl_import_references gix
    ,ap_ae_lines_all aal
    ,ap_invoices_all aia
    ,xxcust_gl_code_combs_mv gcc
    where jb.batch_status = 'Posted'
    and jb.balance_type <> 'Encumbrance'
    and jb.journal_batch_id = jh.journal_batch_id
    and jh.journal_source = 'Payables'
    and jh.journal_category = 'Purchase Invoices'
    and jh.journal_entry_id = jl.journal_entry_id
    and jl.journal_entry_id = gix.je_header_id
    and jl.journal_line_number = gix.je_line_num
    and gix.gl_sl_link_table = 'APECL'
    and gix.gl_sl_link_id = aal.gl_sl_link_id
    and aal.source_table = 'AP_INVOICES'
    and aal.source_id = aia.invoice_id
    and gcc.CODE_COMBINATION_ID_X = jl.account_id
    union all
    select 'AP Payments' "Transaction Type"
    ,jb.set_of_books_id SoB
    ,jb.journal_batch_id BatchId
    ,jb.journal_batch_name BatchName
    ,jb.period_name Period
    ,jb.balance_type BatchType
    ,jh.journal_entry_name JournalName
    ,jh.journal_source JournalSource
    ,jh.journal_category JournalCategory
    ,jh.currency Currency
    ,aal.accounted_dr AmountDr
    ,aal.accounted_cr AmountCr
    ,jl.journal_entry_id HeaderId
    ,jl.journal_line_number LineNum
    ,gix.gl_sl_link_id LinkId
    ,aal.reference1 Name
    ,to_char(aca.check_number) TransactionNumber
    ,aca.check_date TransactionDate
    ,decode(aca.payment_method_lookup_code, 'CHECK', 'Cheque', 'EFT', 'BACS', 'Other')||' (Pay Method)' Other
    ,to_char(aca.check_id) SourceId1
    ,null SourceId2
    ,null SourceId3
    ,'AP_CHECKS' SourceTableA
    ,null SourceIdB
    ,null SourceTableB
    , gcc.*
    from glfg_journal_batches jb
    ,glfg_journal_entries jh
    ,glfg_journal_lines jl
    ,gl_import_references gix
    ,ap_ae_lines_all aal
    ,ap_checks_all aca
    ,xxcust_gl_code_combs_mv gcc
    where jb.batch_status = 'Posted'
    and jb.balance_type <> 'Encumbrance'
    and jb.journal_batch_id = jh.journal_batch_id
    and jh.journal_source = 'Payables'
    and jh.journal_category = 'Payments'
    and jh.journal_entry_id = jl.journal_entry_id
    and jl.journal_entry_id = gix.je_header_id
    and jl.journal_line_number = gix.je_line_num
    and gix.gl_sl_link_table = 'APECL'
    and gix.gl_sl_link_id = aal.gl_sl_link_id
    and (aal.source_table = 'AP_INVOICE_PAYMENTS' or aal.source_table = 'AP_CHECKS')
    and aal.reference3 = aca.check_id
    and gcc.CODE_COMBINATION_ID_X = jl.account_id
    union all
    select 'AR Transaction' "Transaction Type"
    ,jb.set_of_books_id SoB
    ,jb.journal_batch_id BatchId
    ,jb.journal_batch_name BatchName
    ,jb.period_name Period
    ,jb.balance_type BatchType
    ,jh.journal_entry_name JournalName
    ,jh.journal_source JournalSource
    ,jh.journal_category JournalCategory
    ,jh.currency Currency
    ,jl.entered_dr AmountDr
    ,jl.entered_cr AmountCr
    ,jl.journal_entry_id HeaderId
    ,jl.journal_line_number LineNum
    ,gix.gl_sl_link_id LinkId
    ,ac.customer_name Name
    ,gix.reference_4 TransactionNumber
    ,rcta.trx_date TransactionDate
    ,decode(rctla.description,null,'',rctla.description||' (Line Desc)') Other
    ,to_char(gix.reference_2) SourceId1
    ,null SourceId2
    ,null SourceId3
    ,'RA_CUSTOMER_TRX' SourceTableA
    ,null SourceIdB
    ,null SourceTableB
    ,gcc.*
    from glfg_journal_batches jb
    ,glfg_journal_entries jh
    ,glfg_journal_lines jl
    ,gl_import_references gix
    ,ar_customers ac
    ,ra_customer_trx_all rcta
    ,ra_cust_trx_line_gl_dist_all rctlgda
    ,ra_customer_trx_lines_all rctla
    ,xxcust_gl_code_combs_mv gcc
    where jb.batch_status = 'Posted'
    and jb.balance_type <> 'Encumbrance'
    and jb.journal_batch_id = jh.journal_batch_id
    and jh.journal_source = 'Receivables'
    and jh.journal_entry_id = jl.journal_entry_id
    and jl.journal_entry_id = gix.je_header_id
    and jl.journal_line_number = gix.je_line_num
    and gix.reference_10 = 'RA_CUST_TRX_LINE_GL_DIST'
    and gix.reference_7 = ac.customer_id
    and gix.reference_2 = rcta.customer_trx_id
    and gix.reference_3 = rctlgda.cust_trx_line_gl_dist_id
    and rctlgda.customer_trx_line_id = rctla.customer_trx_line_id(+)
    and gcc.CODE_COMBINATION_ID_X = jl.account_id
    union all
    select 'AR Cash Receipt 1' "Transaction Type"
    ,jb.set_of_books_id SoB
    ,jb.journal_batch_id BatchId
    ,jb.journal_batch_name BatchName
    ,jb.period_name Period
    ,jb.balance_type BatchType
    ,jh.journal_entry_name JournalName
    ,jh.journal_source JournalSource
    ,jh.journal_category JournalCategory
    ,jh.currency Currency
    ,ada.acctd_amount_dr AmountDr
    ,ada.acctd_amount_cr AmountCr
    ,jl.journal_entry_id HeaderId
    ,jl.journal_line_number LineNum
    ,gix.gl_sl_link_id LinkId
    ,ac.customer_name Name
    ,gix.reference_4 TransactionNumber
    ,acra.receipt_date TransactionDate
    ,decode(acra.type,null,'',acra.type||' (Receipt Type)') Other
    ,substr(gix.reference_2,1,instr(gix.reference_2,'C')-1) SourceId1
    ,null SourceId2
    ,null SourceId3
    ,'AR_CASH_RECEIPTS' SourceTableA
    ,null SourceIdB
    ,null SourceTableB
    ,gcc.*
    from glfg_journal_batches jb
    ,glfg_journal_entries jh
    ,glfg_journal_lines jl
    ,gl_import_references gix
    ,ar_customers ac
    -- ,ra_customer_trx_all rcta
    ,ar_distributions_all ada
    ,ar_cash_receipt_history_all acrha
    ,ar_cash_receipts_all acra
    ,xxcust_gl_code_combs_mv gcc
    where jb.batch_status = 'Posted'
    and jb.balance_type <> 'Encumbrance'
    and jb.journal_batch_id = jh.journal_batch_id
    and jh.journal_source = 'Receivables'
    and jh.journal_entry_id = jl.journal_entry_id
    and jl.journal_entry_id = gix.je_header_id
    and jl.journal_line_number = gix.je_line_num
    and gix.reference_10 = 'AR_CASH_RECEIPT_HISTORY'
    and gix.reference_7 = ac.customer_id(+)
    and gix.reference_3 = ada.line_id
    and ada.source_table = 'CRH'
    and ada.source_id = acrha.cash_receipt_history_id
    and acrha.cash_receipt_id = acra.cash_receipt_id
    and gcc.CODE_COMBINATION_ID_X = jl.account_id
    union all
    select 'AR Cash Receipt 2' "Transaction Type"
    ,jb.set_of_books_id SoB
    ,jb.journal_batch_id BatchId
    ,jb.journal_batch_name BatchName
    ,jb.period_name Period
    ,jb.balance_type BatchType
    ,jh.journal_entry_name JournalName
    ,jh.journal_source JournalSource
    ,jh.journal_category JournalCategory
    ,jh.currency Currency
    ,ada.acctd_amount_dr AmountDr
    ,ada.acctd_amount_cr AmountCr
    ,jl.journal_entry_id HeaderId
    ,jl.journal_line_number LineNum
    ,gix.gl_sl_link_id LinkId
    ,ac.customer_name Name
    ,gix.reference_4 TransactionNumber
    ,acra.receipt_date TransactionDate
    ,decode(acra.type,null,'',acra.type||' (Receipt Type)') Other
    ,substr(gix.reference_2,1,instr(gix.reference_2,'C')-1) SourceId1
    ,null SourceId2
    ,null SourceId3
    ,'AR_CASH_RECEIPTS' SourceTableA
    ,null SourceIdB
    ,null SourceTableB
    ,gcc.*
    from glfg_journal_batches jb
    ,glfg_journal_entries jh
    ,glfg_journal_lines jl
    ,gl_import_references gix
    ,ar_customers ac
    ,ar_distributions_all ada
    ,ar_receivable_applications_all araa
    ,ar_cash_receipts_all acra
    ,xxcust_gl_code_combs_mv gcc
    where jb.batch_status = 'Posted'
    and jb.balance_type <> 'Encumbrance'
    and jb.journal_batch_id = jh.journal_batch_id
    and jh.journal_source = 'Receivables'
    and jh.journal_entry_id = jl.journal_entry_id
    and jl.journal_entry_id = gix.je_header_id
    and jl.journal_line_number = gix.je_line_num
    and gix.reference_10 = 'AR_RECEIVABLE_APPLICATIONS'
    and gix.reference_7 = ac.customer_id(+)
    and gix.reference_3 = ada.line_id
    and ada.source_table = 'RA'
    and ada.source_id = araa.receivable_application_id
    and araa.cash_receipt_id = acra.cash_receipt_id
    and gcc.CODE_COMBINATION_ID_X = jl.account_id
    union all
    select 'AR Misc Receipt' "Transaction Type"
    ,jb.set_of_books_id SoB
    ,jb.journal_batch_id BatchId
    ,jb.journal_batch_name BatchName
    ,jb.period_name Period
    ,jb.balance_type BatchType
    ,jh.journal_entry_name JournalName
    ,jh.journal_source JournalSource
    ,jh.journal_category JournalCategory
    ,jh.currency Currency
    ,ada.acctd_amount_dr AmountDr
    ,ada.acctd_amount_cr AmountCr
    ,jl.journal_entry_id HeaderId
    ,jl.journal_line_number LineNum
    ,gix.gl_sl_link_id LinkId
    ,'MISC RECEIPT' Name
    ,gix.reference_4 TransactionNumber
    ,acra.receipt_date TransactionDate
    ,decode(acra.type,null,'',acra.type||' (Receipt Type)') Other
    ,substr(gix.reference_2,1,instr(gix.reference_2,'C')-1) SourceId1
    ,null SourceId2
    ,null SourceId3
    ,'AR_CASH_RECEIPTS' SourceTableA
    ,null SourceIdB
    ,null SourceTableB
    ,gcc.*
    from glfg_journal_batches jb
    ,glfg_journal_entries jh
    ,glfg_journal_lines jl
    ,gl_import_references gix
    ,ar_distributions_all ada
    ,ar_misc_cash_distributions_all amcda
    ,ar_cash_receipts_all acra
    ,xxcust_gl_code_combs_mv gcc
    where jb.batch_status = 'Posted'
    and jb.balance_type <> 'Encumbrance'
    and jb.journal_batch_id = jh.journal_batch_id
    and jh.journal_source = 'Receivables'
    and jh.journal_entry_id = jl.journal_entry_id
    and jl.journal_entry_id = gix.je_header_id
    and jl.journal_line_number = gix.je_line_num
    and gix.reference_10 = 'AR_MISC_CASH_DISTRIBUTIONS'
    and gix.reference_3 = ada.line_id
    and ada.source_table = 'MCD'
    and ada.source_id = amcda.misc_cash_distribution_id
    and amcda.cash_receipt_id = acra.cash_receipt_id
    and gcc.CODE_COMBINATION_ID_X = jl.account_id
    union all
    select 'Payroll' "Transaction Type"
    ,jb.set_of_books_id SoB
    ,jb.journal_batch_id BatchId
    ,jb.journal_batch_name BatchName
    ,jb.period_name Period
    ,jb.balance_type BatchType
    ,jh.journal_entry_name JournalName
    ,jh.journal_source JournalSource
    ,jh.journal_category JournalCategory
    ,jh.currency Currency
    ,jl.converted_dr AmountDr
    ,jl.converted_cr AmountCr
    ,jl.journal_entry_id HeaderId
    ,jl.journal_line_number LineNum
    ,null LinkId
    ,gix.reference_4 Name
    ,gix.reference_5 TransactionNumber
    ,to_date(gix.reference_3) TransactionDate
    ,gix.reference_7 Other
    ,to_char(jb.journal_batch_id) SourceId1
    ,null SourceId2
    ,null SourceId3
    ,null SourceTableA
    ,null SourceIdB
    ,null SourceTableB
    ,gcc.*
    from glfg_journal_batches jb
    ,glfg_journal_entries jh
    ,glfg_journal_lines jl
    ,gl_import_references gix
    ,xxcust_gl_code_combs_mv gcc
    where jb.batch_status = 'Posted'
    and jb.balance_type <> 'Encumbrance'
    and jb.journal_batch_id = jh.journal_batch_id
    and upper(jh.journal_source) = 'PAYROLL'
    and jh.journal_entry_id = jl.journal_entry_id
    and jl.journal_entry_id = gix.je_header_id
    and jl.journal_line_number = gix.je_line_num
    and gcc.CODE_COMBINATION_ID_X = jl.account_id
    union all
    select 'Other' "Transaction Type"
    ,jb.set_of_books_id SoB
    ,jb.journal_batch_id BatchId
    ,jb.journal_batch_name BatchName
    ,jb.period_name Period
    ,jb.balance_type BatchType
    ,jh.journal_entry_name JournalName
    ,jh.journal_source JournalSource
    ,jh.journal_category JournalCategory
    ,jh.currency Currency
    ,jl.converted_dr AmountDr
    ,jl.converted_cr AmountCr
    ,jl.journal_entry_id HeaderId
    ,jl.journal_line_number LineNum
    ,null LinkId
    ,null Name
    ,null TransactionNumber
    ,null TransactionDate
    ,null Other
    ,to_char(jb.journal_batch_id) SourceId1
    ,to_char(jh.journal_entry_id) SourceId2
    ,null SourceId3
    ,'GL_JE_HEADERS' SourceTableA
    ,null SourceIdB
    ,null SourceTableB
    ,gcc.*
    from glfg_journal_batches jb
    ,glfg_journal_entries jh
    ,glfg_journal_lines jl
    ,xxcust_gl_code_combs_mv gcc
    where jb.batch_status = 'Posted'
    and jb.balance_type <> 'Encumbrance'
    and jb.journal_batch_id = jh.journal_batch_id
    and gcc.CODE_COMBINATION_ID_X = jl.account_id
    and (jh.journal_source != 'Payables'
    or (jh.journal_source = 'Payables' and (jh.journal_category not in ('Purchase Invoices','Payments')
    or (jh.journal_category in ('Purchase Invoices','Payments') and
    not exists (select *
    from gl_import_references gix
    where jl.journal_entry_id = gix.je_header_id
    and jl.journal_line_number = gix.je_line_num
    and (jh.journal_source != 'Receivables'
    or (jh.journal_source = 'Receivables' and (not exists (select *
    from gl_import_references gix
    where jl.journal_entry_id = gix.je_header_id
    and jl.journal_line_number = gix.je_line_num
    or exists (select *
    from gl_import_references gix
    where jl.journal_entry_id = gix.je_header_id
    and jl.journal_line_number = gix.je_line_num
    and gix.reference_10 not in ('AR_MISC_CASH_DISTRIBUTIONS'
    ,'AR_CASH_RECEIPT_HISTORY'
    ,'RA_CUST_TRX_LINE_GL_DIST')
    and gix.reference_8 = 'CMAPP'
    and (upper(jh.journal_source) != 'PAYROLL'
    or (upper(jh.journal_source) = 'PAYROLL' and not exists (select *
    from gl_import_references gix
    where jl.journal_entry_id = gix.je_header_id
    and jl.journal_line_number = gix.je_line_num
    and jh.journal_entry_id = jl.journal_entry_id
    Thanks,
    Gecko

    I did not spend the time analyzing these queries to determine what key columns are shared by both record sets, but rather than trying to put these together and adding join conditions, you could make them both in-line views and then join on the key columns:
    SELECT a.keycol1, a.keycol2, a.cola, a.colb, b.colc, b.cold
    FROM
            SELECT keycol1, keycol2, cola, colb
            FROM GIANT QUERY1
           ) a,
            SELECT keycol1, keycol2, colc, cold
            FROM GIANT QUERY2
           ) b
    WHERE  a.keycol1 = b.keycol1
    AND    a.keycol2 = b.keycol2;Greg Pike
    http://www.singlequery.com

  • TRYING TO REGISTER MY MACBOOK PRO THAT I HAVE PURCHASED TODAY, THE REGISTRATION SYSTEM DOESNT APPROVE MY CORRECT PRODUCT SERIAL NUMBER (WHICH I PROPERLY CONTROLLED ON BOX AND ON INVOICE)

    TRYING TO REGISTER MY MACBOOK PRO THAT I HAVE PURCHASED TODAY, THE REGISTRATION SYSTEM DOESNT APPROVE MY CORRECT PRODUCT SERIAL NUMBER (WHICH I PROPERLY CONTROLLED ON BOX AND ON INVOICE)

    Where did you buy the machine? An Apple store, an authorized reseller, or ??
    Also, what is the model/identifier? Is it the latest or was it purchased used?

  • Complaint wth ref. to invoice in CRM - Copy control not taken into account!

    Hi all,
    We are facing problems when replicating return orders (business object Complaint)  with reference to invoices in ERP.
    The copy control in ERP is not taken into account. Does anyone know if it is possible to check the copy control when replicating the complaint to ERP with reference to the invoice?
    The return order is being replicated correctly and the link to the invoice is shown (so, the flow is correct).
    But:
    1.- The manual pricing conditions in the invoice in ERP are not being copied in the return order.
    2.- Some data as the 'Incoterms' is being redetermined from the customer master data and is not being copied from the invoice.
    3.- Data related to material is also being redetermined when the order is replicated
    The copy control is not being taken into account and we can replicate return orders from CRM to ERP with reference to invoices for which the copy control is not maintained in ERP...
    Please help...
    Thanks in advance!
    Yolanda

    Try something like this, in place of  ls_input_field_names-fieldname = 'ZZDEP2PVNDPGM'..
    ls_input_field_names-objectname = 'ORDERADM_H'.
      ls_input_field_names-ref_handle = '100'.
      insert ls_input_field_names into table lt_input_field_names.
    Edited by: Kevin Alcock on Aug 10, 2009 4:03 PM

  • AP G를 씌운후 INVOICE BATCH CONTROL TOTALS 이 틀릴때

    제품 : FIN_AR
    작성날짜 : 2003-05-21
    AP G를 씌운후 INVOICE BATCH CONTROL TOTALS 이 틀릴때========================================================================
    PURPOSE
    Payables Open Interface Program 실행후 invoice batch에 생기는 잘못된 control invoice count, control invoice total 해결
    Problem Description
    AP.G 를 씌운후 Payables Open Interface Program 실행하면 Invoice Batch의
    Control Invoice count, Control Invoce Total 이 잘못 나오는 현상.
    Workaround
    Data fix script
    Solution Description
    REM $Header: b2059687.sql 115.2 2001/12/03 11:20:40 lgopalsa noship $|
    REM **************************************************************************
    REM * Copyright (c) 2000 Oracle Corporation Belmont, California, USA *
    REM * All rights reserved. *
    REM **************************************************************************
    REM * *
    REM * FILENAME *
    REM * *
    REM * b2100875.sql *
    REM * *
    REM * DESCRIPTION *
    REM * This is for updating the AP_BATCHES in which the data was corrupted *
    REM * after applying the patch 1721820.This can be applied after applying *
    REM * the patch 2003024 which will set the correct values in ap_batches. *
    REM * i.e., control invoice count and control invoice total *
    REM * *
    REM * MODIFICATION HISTORY *
    REM * 03-DEC-2001 LGOPALSA Create *
    REM **************************************************************************
    REM dbdrv: sql ~PROD ~PATH ~FILE none none none sqlplus &phase=upg+52
    SET VERIFY OFF
    WHENEVER SQLERROR EXIT FAILURE ROLLBACK;
    PROMPT
    Define enter_org_id = '&org_id'
    PROMPT
    exec fnd_client_info.set_org_context('&enter_org_id');
    UPDATE AP_BATCHES
    SET Control_Invoice_Count=Ap_Batches_pkg.GET_ACTUAL_INV_COUNT(batch_id),
    Control_Invoice_Total=Ap_Batches_pkg.GET_ACTUAL_INV_AMOUNT(batch_id)
    commit;
    exit;
    Reference Documents
    bug 2059687

Maybe you are looking for

  • Satellite A200 - need help with USB boot

    Hi to all, I have a startup problem with my Satellite A200. I am booting from my USB key. It is bootable Linux to install the tutorial is this: Insert the USB key or drive you want to boot from. Restart the computer. During startup, when prompted, pr

  • How to find out all table names which has a particular data

    Hi, How could i get all the table names from a database(for a schema) which has data 'KST6490' in one of the fileds in the table.There are many tables with this data. Data type is Varchar2. Thanks.

  • MobileMe Calendar Problem Help ASAP!!

    Hi Guys I'd appreciate some advice with this pretty annoying problem. This is an iPhone 4 problem not a mobile me so I'd appreciate it if the MOD does not move this. My MobileMe calendars do not appear to be syncing anymore, problem only just started

  • Trace a java class

    Hello! How can I trace a java class (Logging) which has been created and located inside src/packages/.... You can see these folders inside Web Dynpro Explorer after  "Dictionaries" node. Regards sas

  • HT204088 newly purchased app won't open

    just purchased an audiobook app it is showing in my account under apps but won't open and play wen i double click on it