MIRO / PRCTR to be replaced

Hi I have a requirement like ,
I was Posting MIRO document with reference PO.
I want to replace Profit Centre ( PRCTR ) with profit center for particular GL accounts. And It should replace only MIRO level and not other levels like MIGO.
How to do it?
I have applied Badi: AC_DOCUMENT~CHANGE_AFTER_CHECK which not working,
I have applied user exit: EXIT_SAPLFMR4_002 which is working fine and its getting affected all areas like MIGO, which I donu2019t want; I want only MIRO level...
Appreciate Ur valuable solution.
Ramesh.
-> MIRO
-> Enter Invoice date,  Reference,Posting Date  and Amount
-> ( PO Reference Tab ) Enter PO Number
-> Do Simulate
-> Save / Post

exit
EXIT_SAPLFMR4_002
is helpful to achive output.
regards,
ramesh

Similar Messages

  • BAdi / Exit to replace MIRO Invoicing Party with PO Invoicing Party

    Hi,
    Following is the current scenario :
    PO is created on branch vendor (with a HO vendor mentioned in master). While doing MIRO, the system automatically
    replaces the branch vendor with the Head office vendor (as mentioned in master). The region taken for tax purpose
    is the region of the HO vendor.
    Now as per our business requirement, we want to replace MIRO Inv. Party (RBKP-LIFNR) with
    PO Inv. Party (EKKO-LIFRE) and want to do tax calculation based on branch Vendor.
    We have already tried out all BAdis mentioned in SAP Note 1156325 - BAdIs in the Logistics Invoice Verification environment, but not able to map this replacement during t.code MIRO.
    Pls suggest which User Exit / Badi need to be used?
    Thanks & Regards,
    Taral Patel

    Thanks to all

  • Replacement of MIRO Invoicing Party (RBKP-LIFNR) with PO Invoicing Party

    Hi,
    As per one of our business requirement, we want to replace MIRO Invoicing Party (RBKP-LIFNR) with PO Invoicing Party (EKKO-LFRKE) for correct tax calculation during MIRO.
    For that we tried to apply BAdis suggested as per SAP Note 1156325 - BAdIs in the Logistics Invoice Verification environment and others. But these BAdis are not enough useful to resolve above problem.
    Pls suggest another BAdi / exit for above problem, which can replace  MIRO Invoicing Party (RBKP-LIFNR) during MIRO .
    Thanks & Regards,
    Taral Patel

    Hi,
    Thanks for your reply.
    below is our business scenario :
    "PO is created on branch vendor (with a HO vendor mentioned in master).
    While doing MIRO, the system automatically replaces the branch vendor with the Head
    office vendor (as mentioned in master). The region taken for tax purpose is the region of the
      HO  vendor.
    for above problem, I have been suggested Note 1156325 from the forum, but none of the BAdi seems feasible (checked with our SAP ABAP Consultant) for this requirement to replace MIRO Invoicing Party (RBKP-LIFNR) with PO Invoicing Party (EKKO-LFRKE).
    It would be great help if u can suggest ny BAdi / exit for this requirement.
    Thanks & Regards,
    Taral Patel

  • Region to pick based on branch vendor while doing MIRO

    Dear All,
    following is the scenario :
    PO is created on branch vendor (with a HO vendor mentioned in master). While doing MIRO, the system automatically replaces the branch vendor with the Head office vendor (as mentioned in master).  The region taken for tax purpose is the region of the HO vendor.
    Now the requirement is that, while doing the MIRO, the system should pick up the region of the branch vendor and not HO vendor. Will have to create/ write an exit or  use substitution.
    Can somebody eleborate how should the logic be mapped for exit in connection with substitution?
    Thanks,
    Tapan

    Dear Alok,
    Thanks for the reply. We actually already started to work on it. But, as we want to replace HO vendor with branch vendor during MIRO as already mentioned, we are still awaiting what logic should be mapped in substitution as well as exit for that.
    It would be great help if you can throw some light on the same.
    Thanks
    Tapan

  • Decrapify Miro

    Miro has been broken for me since the xine-lib upgrade.   As it turns out, Miro 1.2.x is broken against the latest xine-lib.   However, Miro 2.0.x has just been released, and I am here to save the day!
    First, the Miro 2.0.x PKGBUILD:
    # Maintainer: Ronald van Haren <ronald.archlinux.org>
    # Contributor: Jeremy Sands <[email protected]>
    pkgname=miro
    pkgver=2.0.1
    pkgrel=1
    pkgdesc="The free and open source internet TV platform"
    arch=('i686' 'x86_64')
    url="http://www.getmiro.com"
    license=('GPL2')
    depends=('xine-lib>=1.1.12' 'boost>=1.36.0' 'gnome-python-extras>=2.19.1'
    'dbus-python>=0.82.4' 'pyrex' 'xulrunner>=1.9.0.1' 'gtk2' 'nspr')
    makedepends=('pkgconfig' 'qt3')
    install=miro.install
    conflicts=('democracy')
    replaces=('democracy')
    provides=('democracy')
    source=(http://ftp.osuosl.org/pub/pculture.org/miro/src/Miro-${pkgver}.tar.gz)
    md5sums=('9f180474f97f179e78d919e92b66e3e4')
    build() {
    cd ${srcdir}/Miro-${pkgver}
    cd platform/gtk-x11
    python setup.py install --root=${pkgdir} || return 1
    Next, the miro.install:
    cat miro.install
    post_install() {
    update-desktop-database -q
    post_upgrade() {
    post_install $1
    post_remove() {
    update-desktop-database -q
    op=$1
    shift
    $op $*
    All the extra patches previously needed to build miro are no longer necessary.    Use the above to files to make the PKGBUILD and install it.
    Playback in xine is still broken, in that Miro will crash after playback.   However, gstreamer playback is NO LONGER broken.   So ... open up Miro, go to preferences, and change the Playback to "gstreamer" instead of "xine".
    Exit Miro.
    Do the following:
    pacman -S gstreamer0.10-python gstreamer0.10-ugly-plugins gstreamer0.10-ugly gstreamer0.10-good-plugins gstreamer0.10-good gstreamer0.10-base-plugins gstreamer0.10-bad-plugins gstreamer0.10-bad gstreamer0.10-ffmpeg
    Now open up Miro again and enjoy the first fully working Miro you've had in Arch in some time.
    Last edited by georgia_tech_swagger (2009-02-14 23:58:51)

    pressh wrote:
    georgia_tech_swagger wrote:Playback in xine is still broken, in that Miro will crash after playback.   However, gstreamer playback is NO LONGER broken.   So ... open up Miro, go to preferences, and change the Playback to "gstreamer" instead of "xine".
    gstreamer playback was never broken, it requires gstreamer0.10-python to work
    Allan wrote:I wound be good to ping the maintainer with your PKGBUILD so they don't have to repeat your work.
    nah, I have followed the release candidates locally and also have the final PKGBUILD ready for some time. But well, it is still equally broken with the preferred xine backend...
    1.2.8 was indeed broken with gstreamer.   Simply attempting playback caused, oddly, a xine based segfault.   There's a rather long bug report in Fedora's bug tracker about this matter.
    Last edited by georgia_tech_swagger (2009-02-18 15:40:43)

  • Required replace BSEG with BSAK BSIK BSIS BSAS for report performance

    Hi Experts
    i m optimizing a report in which data is extracting from BSEG , 5 time so i reduses the performance of report
    so i want replace BSEG with BSAK BSIK BSIS BSAS for the same data what I am getting now . this is report of Purchase of item. code is here.
    REPORT  zmm_pur_reg_kanhe LINE-SIZE 1023.
    *& Des         :Purchase Tax Register Report for KANHE
    *& Created on  :12-07-07
    *& Suggested by:Paresh Saini(MM)
    *& Changes By: Lailu Philip
    *& Changed On: 24.09.2007
    *& Changes: New columns for G/L Code Description,VAT Amt,VAT Perc,CST Perc
    *&                         ,SHCESS Amounts,WCT G/L Acc., WCT Amt,Tax Code
    *&                          for Purchase Order,WCT tax code & Percentage.
    *& Request No:  S6DK921577
    Data Declaration
    *& changes: by Vincy on 12.01.2007
    *& changes: display purchase order with vendor type zpsr(get_zpsr)
    *& Request No:  S6DK930821
    TABLES:ekbe, lfa1, faglflexa.",j_1iexcdtl,lfa1,bkpf,bseg.
    TYPE-POOLS: slis.                                 "ALV Declarations
    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
           gd_layout    TYPE slis_layout_alv,
           gd_repid     LIKE sy-repid.
    DATA: it_sortcat   TYPE slis_sortinfo_alv OCCURS 1,
           col_pos LIKE fieldcatalog-col_pos .
    TYPES :BEGIN OF wa1_ekbe,
            belnr         TYPE ekbe-belnr,
            budat         TYPE ekbe-budat,
            menge         TYPE ekbe-menge,
            matnr         TYPE ekbe-matnr,
            ebelp         TYPE j_1iexcdtl-ritem1,
            ebeln         TYPE ekbe-ebeln,
            gjahr         TYPE ekbe-gjahr,
            lfbnr         TYPE ekbe-lfbnr,
            lfpos         TYPE ekbe-lfpos,
            bldat         TYPE ekbe-bldat,
            REEWR         TYPE REEWR,
            END OF wa1_ekbe.
    TYPES :BEGIN OF wa2_ekbe,
            belnr         TYPE ekbe-belnr,
            budat         TYPE ekbe-budat,
            menge         TYPE ekbe-menge,
            ebelp         TYPE ekbe-ebelp,
            ebeln         TYPE ekbe-ebeln,
            gjahr         TYPE ekbe-gjahr,
            lfbnr         TYPE ekbe-lfbnr,
            lfpos         TYPE ekbe-lfpos,
            bldat         TYPE ekbe-bldat,
            REEWR         TYPE REEWR,
            awkey(20)         TYPE c,
            MATNR         TYPE MATNR,
            MWSKZ         TYPE EKBE-MWSKZ,
            END OF wa2_ekbe.
    TYPES :BEGIN OF wa1_j_1iexcdtl,
            exnum         TYPE j_1iexcdtl-exnum,
            exdat         TYPE j_1iexcdtl-exdat,
            lifnr         TYPE j_1iexcdtl-lifnr,
            matnr         TYPE j_1iexcdtl-matnr ,
          maktx         TYPE j_1iexcdtl-maktx ,
          capind      TYPE j_1iexcdtl-capind,
            exbas         TYPE j_1iexcdtl-exbas,
            exbed             TYPE j_1iexcdtl-exbed,
            ecs            TYPE j_1iexcdtl-ecs,
            werks             TYPE j_1iexcdtl-werks,
            ritem1        TYPE j_1iexcdtl-ritem1,
            rdoc1             TYPE j_1iexcdtl-rdoc1,
            docyr         TYPE j_1iexcdtl-docyr,
            bedinv        type J_1IBEDINV,
            ecsinv        type J_1IECSINV,
            EXADDINV1     type J_1IEXADDINV1,
            exaddtax1    TYPE j_1iexcdtl-exaddtax1,
            rdoc2         TYPE j_1iexcdtl-rdoc2,
            ritem2        TYPE j_1iexcdtl-ritem2,
            menge         TYPE j_1iexcdtl-menge,
    ADDED FOR RUDRAPUR ON 08.03.2008 BY ASHOK.CH
    *ENDED ON 08.02.2008
            END OF wa1_j_1iexcdtl.
    TYPES :BEGIN OF wa1_lfa1,
            name1         TYPE lfa1-name1,
            ktokk         TYPE lfa1-ktokk,
            werks         TYPE lfa1-werks,
            lifnr         TYPE lfa1-lifnr,
            END OF wa1_lfa1.
    TYPES :BEGIN OF wa1_ekexclf,
            belnr         TYPE ekbe-belnr,
            budat         TYPE ekbe-budat,
            menge         TYPE ekbe-menge,
            ebelp         TYPE ekbe-ebelp,
            ebeln         TYPE ekbe-ebeln,
            gjahr         TYPE ekbe-gjahr,
            awkey(20)     TYPE c,
            exnum         TYPE j_1iexcdtl-exnum,
            exdat         TYPE j_1iexcdtl-exdat,
            lifnr         TYPE j_1iexcdtl-lifnr,
            matnr         TYPE j_1iexcdtl-matnr ,
          maktx         TYPE j_1iexcdtl-maktx ,
          capind      TYPE j_1iexcdtl-capind,
            exbas         TYPE j_1iexcdtl-exbas,
            exbed             TYPE j_1iexcdtl-exbed,
            ecs            TYPE j_1iexcdtl-ecs,
            werks             TYPE j_1iexcdtl-werks,
            ritem1        TYPE j_1iexcdtl-ritem1,
            rdoc1             TYPE j_1iexcdtl-rdoc1,
            docyr         TYPE j_1iexcdtl-docyr,
            name1         TYPE lfa1-name1,
            ktokk         TYPE lfa1-ktokk,
            exaddtax1     TYPE j_1iexcdtl-exaddtax1,
    added for rudrapur on 08.03.2008 by ASHOK.CH
            bedinv        type J_1IBEDINV,
            ecsinv        type J_1IECSINV,
            EXADDINV1     type J_1IEXADDINV1,
    END OF MODIFICATION ON 08.02.2008
            END OF  wa1_ekexclf.
    TYPES :BEGIN OF wa1_bkpf,
            bukrs TYPE bkpf-bukrs,
            belnr TYPE bkpf-belnr,
            gjahr TYPE bkpf-gjahr,
            budat TYPE bkpf-budat,
            tcode TYPE bkpf-tcode,
            awkey TYPE bkpf-awkey,
            END OF wa1_bkpf.
    TYPES :BEGIN OF wa1_bseg,
            bukrs     TYPE bseg-bukrs,
            belnr     TYPE bseg-belnr,     
            gjahr         TYPE bseg-gjahr,
            buzei     TYPE bseg-buzei,
            bschl     TYPE bseg-bschl,
            fwbas     TYPE bseg-fwbas ,     
            pswbt         TYPE bseg-pswbt,
            hkont         TYPE bseg-hkont,
            wrbtr     TYPE bseg-wrbtr,
            ktosl     TYPE bseg-ktosl,
            koart     TYPE bseg-koart,
            shkzg     TYPE bseg-shkzg,
            mwskz     TYPE bseg-mwskz,
            qsskz     TYPE bsis-qsskz,
            dmbtr     TYPE bseg-dmbtr,
            lifnr     TYPE bseg-lifnr,
            matnr     TYPE bseg-matnr,
            flag      TYPE C,
            flag_21   TYPE C,
            END OF wa1_bseg.
    TYPES :BEGIN OF wa1_tax,
            belnr         TYPE bseg-belnr,
            fi_docno      TYPE bseg-belnr,
            gjahr             TYPE bseg-gjahr,
            bukrs         TYPE bseg-bukrs,
            awkey         TYPE bkpf-awkey,
            fwbas         TYPE bseg-fwbas ,
            cst_amt       TYPE bseg-pswbt,
            vat_amt       TYPE bseg-pswbt,
            shcess_amt    TYPE bseg-pswbt,
            gl_accnt      TYPE bseg-hkont,
            gl_desc       TYPE skat-txt50,
            wctglacc      TYPE bseg-hkont,
            wctamt        TYPE bseg-dmbtr,
            taxcode       TYPE t059z-wt_withcd,
            taxperc       TYPE t059z-qsatz,
            total_value   TYPE bseg-wrbtr,
            set_off       TYPE bseg-wrbtr,
            cond_type     TYPE konv-kschl,
            description(20)   TYPE c,
            service_tax       TYPE bseg-wrbtr,
            service_ecess     TYPE bseg-wrbtr,
            service_shcess     TYPE bseg-wrbtr,      "vincy on 31.01.08
            ebelp         TYPE ekbe-ebelp,           "      on 15.04.08
            flag          TYPE c,
            mwskz     TYPE bseg-mwskz,
            END OF wa1_tax.
    DATA:BEGIN OF itab_skat,
           saknr TYPE skat-saknr,
           spras TYPE skat-spras,
           txt50 TYPE skat-txt50,
           END OF itab_skat.
    DATA: iskat LIKE itab_skat OCCURS 0,
           wa_skat LIKE itab_skat.
    DATA : BEGIN OF zbsis OCCURS 0,
             bukrs TYPE bsis-bukrs,
             hkont TYPE bsis-hkont,
             augdt TYPE bsis-augdt,
             augbl TYPE bsis-augbl,
             zuonr TYPE bsis-zuonr,
             gjahr TYPE bsis-gjahr,
             belnr TYPE bsis-belnr,
             buzei TYPE bsis-buzei,
             budat TYPE bsis-budat,
             qsskz TYPE bsis-qsskz,
            END OF zbsis.
    DATA: BEGIN OF zt059z OCCURS 0,
           land1 TYPE t059z-land1,
           witht TYPE t059z-witht,
           wt_withcd TYPE t059z-wt_withcd,
           qscod TYPE t059z-qscod,
           qsatz TYPE t059z-qsatz,
           hkont TYPE bsis-hkont,
           belnr TYPE bsis-belnr,
           END OF zt059z.
    DATA: BEGIN OF it_faglflexa OCCURS 0,      "added by vincy
          ryear TYPE faglflexa-ryear,
          docnr TYPE faglflexa-docnr,
          rldnr TYPE faglflexa-rldnr,
          rbukrs TYPE faglflexa-rbukrs,
          docln TYPE faglflexa-docln,
          prctr TYPE faglflexa-prctr,
          END OF it_faglflexa.
    Final Table***
    TYPES :BEGIN OF wa1_final,
             belnr         TYPE ekbe-belnr,
             fi_docno      TYPE bseg-belnr,
             budat         TYPE ekbe-budat,
             menge         TYPE ekbe-menge,
             rate          TYPE konv-kbetr,
             ebelp         TYPE ekbe-ebelp,
             ebeln         TYPE ekbe-ebeln,
             mwskz         TYPE bseg-mwskz,
             gjahr         TYPE ekbe-gjahr,
             awkey(20)     TYPE c,
             exnum         TYPE j_1iexcdtl-exnum,
             exdat         TYPE j_1iexcdtl-exdat,
             lifnr         TYPE j_1iexcdtl-lifnr,
             matnr         TYPE j_1iexcdtl-matnr ,
           maktx         TYPE j_1iexcdtl-maktx ,
             capind       TYPE string,
             exbas         TYPE j_1iexcdtl-exbas,
             exbed       TYPE j_1iexcdtl-exbed,
             ecs             TYPE j_1iexcdtl-ecs,
             werks       TYPE j_1iexcdtl-werks,
             ritem1        TYPE j_1iexcdtl-ritem1,
             rdoc1       TYPE j_1iexcdtl-rdoc1,
             docyr         TYPE j_1iexcdtl-docyr,
             name1         TYPE lfa1-name1,
             ktokk         TYPE lfa1-ktokk,
             fwbas         TYPE bseg-fwbas ,
             vat_per       TYPE konv-kbetr,
             vat_amt       TYPE bseg-pswbt,
             cst_per       TYPE konv-kbetr,
             cst_amt       TYPE bseg-pswbt,
             shcess_amt    TYPE bseg-pswbt,
             gl_accnt      TYPE bseg-hkont,
             gl_desc       TYPE skat-txt50,
             wctglacc      TYPE bseg-hkont,
             wctamt        TYPE bseg-dmbtr,
             taxcode       TYPE t059z-wt_withcd,
             taxperc       TYPE t059z-qsatz,
             total_value   TYPE bseg-wrbtr,
             total_value1 TYPE bseg-wrbtr,
             excise_tax    TYPE bseg-wrbtr,
             excise  TYPE bseg-wrbtr,
             set_off       TYPE bseg-wrbtr,
             inventorised  TYPE konv-kawrt,
             cond_type     TYPE konv-kschl,
             cond_type2    TYPE konv-kschl,
             description(20)   TYPE c,
             service_tax       TYPE bseg-wrbtr,
             service_ecess     TYPE bseg-wrbtr,
             service_shcess    TYPE bseg-wrbtr,            "vincy on 31.01.08
            END OF wa1_final.
    DATA :it2_ekbe        TYPE TABLE OF wa1_ekbe WITH HEADER LINE,
           it_ekbe        TYPE TABLE OF wa1_ekbe WITH HEADER LINE,
           it1_ekbe       TYPE TABLE OF wa2_ekbe WITH HEADER LINE WITH KEY ebelp ebeln,
           it_j_1iexcdtl  TYPE TABLE OF wa1_j_1iexcdtl WITH HEADER LINE WITH KEY rdoc1 ritem1,
           it_lfa1        TYPE TABLE OF wa1_lfa1 WITH HEADER LINE WITH KEY lifnr,
           it_lfa2        TYPE TABLE OF wa1_lfa1 WITH HEADER LINE WITH KEY lifnr,
           it_bkpf        TYPE TABLE OF wa1_bkpf WITH HEADER LINE,
           it_bseg        TYPE TABLE OF wa1_bseg WITH HEADER LINE WITH  KEY
                                        bukrs belnr gjahr ktosl shkzg koart,
           it1_bseg        TYPE TABLE OF wa1_bseg WITH HEADER LINE WITH  KEY
                                        bukrs belnr gjahr ktosl shkzg koart,
           it_tax         TYPE TABLE OF wa1_tax WITH HEADER LINE WITH KEY awkey ,
           it_ekexclf     TYPE TABLE OF wa1_ekexclf WITH HEADER LINE,
           it_final       TYPE TABLE OF wa1_final WITH HEADER LINE,
           it_final1      TYPE TABLE OF wa1_final WITH HEADER LINE,         "vincy
           wa_ekbe       TYPE wa1_ekbe,
           wa1_ekbe      TYPE wa2_ekbe,
           wa_j_1iexcdtl TYPE wa1_j_1iexcdtl,
           wa_lfa1       TYPE wa1_lfa1,
           wa_lfa2       TYPE wa1_lfa1,
           wa_bkpf       TYPE wa1_bkpf,
           wa_bseg       TYPE wa1_bseg,
           wa_tax        TYPE wa1_tax,
           wa_ekexclf    TYPE wa1_ekexclf,
           PLANT TYPE WERKS_D,
           wa_final      TYPE wa1_final.
    DATA: it_konv TYPE konv OCCURS 0 WITH HEADER LINE ,
           wa_konv TYPE konv,
           invent TYPE p DECIMALS 4,
           invent1 TYPE konv-kawrt.
    DATA:d1 TYPE konv-kposn,
          d2 TYPE ekbe-ebelp.
    DATA: v_belnr TYPE ekbe-belnr,
           v_gjahr TYPE ekbe-gjahr,
           v_awkey(20) TYPE c,
           idx TYPE sy-tabix.
    **********by vincy on 12.01.07***********
    DATA: BEGIN  OF it_ekko OCCURS 0,
           ebeln LIKE ekko-ebeln,
           bukrs LIKE ekko-bukrs,
           bsart LIKE ekko-bsart,
           lifnr LIKE ekko-lifnr,
           belnr LIKE ekbe-belnr,
           END OF it_ekko.
    DATA: BEGIN  OF it_ekpo OCCURS 0,
           ebeln LIKE ekpo-ebeln,
           ebelp LIKE ekpo-ebelp,
           txz01 LIKE ekpo-txz01,
           END OF it_ekpo.
    DATA: BEGIN  OF it_lfa1v OCCURS 0,
           lifnr LIKE lfa1-lifnr,
           name1 LIKE lfa1-name1,
           END OF it_lfa1v.
    DATA: BEGIN  OF s_prctr OCCURS 0,
           low LIKE faglflexa-prctr,
           END OF s_prctr.
    DATA: it_bsegv TYPE TABLE OF wa1_bseg WITH HEADER LINE.
    DATA: it_konv1 LIKE konv OCCURS 0 WITH HEADER LINE.
    DATA:cnt TYPE i,
          awkey1(250).
    DATA: LIFNR TYPE LIFNR,
          NAME TYPE NAME1_GP,
          MTART TYPE MARA-MTART,
          MAKTX TYPE MAKTX,
          TAX_TOT TYPE KWERT.
    ***********end of changes by vincy ************
    Selection Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: s_werks1 FOR ekbe-werks,
                     s_budat1 FOR ekbe-budat,
                     s_fiscal FOR  ekbe-gjahr,
                     s_lifnr FOR lfa1-lifnr.
    SELECTION-SCREEN END OF BLOCK b1.
    **"changes being by nahid on 16.04.2008
    PARAMETERS : excel AS CHECKBOX DEFAULT 'X'.
    PARAMETERS: infile LIKE rlgrap-filename.
    DATA : zfile TYPE string.
    **"changes ended by nahid on 16.04.2008
    AT SELECTION-SCREEN.
       IF s_werks1 IS INITIAL.
         MESSAGE 'Please Enter Plant details' TYPE 'E'.
       ENDIF.
       IF s_budat1 IS INITIAL.
         MESSAGE 'Please Enter Posting date' TYPE 'E'.
       ENDIF.
       IF s_fiscal IS INITIAL.
         MESSAGE 'Please Enter Fiscal Year' TYPE 'E'.
       ENDIF.
    *start change by nahid on 16.4.08
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR infile.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        CHANGING
          file_name     = infile
        EXCEPTIONS
          mask_too_long = 1
          OTHERS        = 2.
    zfile = infile.
    *end change by nahid on 16.4.08
    START-OF-SELECTION.
    plant = s_werks1-low.
    MODIFIED FOR RUDRAPUR BY ASHOK.CH ON 13.03.2008
    IF PLANT NE 'RD01'.
       PERFORM get_data.
       PERFORM get_zpsr.                        "vincy
    ENDIF.
    IF PLANT EQ 'RD01'.
        PERFORM get_data1.
    ENDIF.
    *END OF MODIFICATION ON 13.03.2008
       PERFORM build_fieldcatalog.
       PERFORM build_layout.
       PERFORM display_alv_report.
    *start chng by nahid on 16.4.08
    IF excel = 'X'.
        IF NOT infile IS INITIAL.
          PERFORM excel_data.
        ELSE.
          MESSAGE e000(0) WITH 'Please Enter the File Path'.
        ENDIF.
      ENDIF.
    *end by nahid on 16.4.08
    *&      Form  get_data
    FORM get_data .
       SELECT belnr budat menge matnr ebelp ebeln gjahr lfbnr lfpos bldat  REEWR FROM ekbe INTO
       TABLE it_ekbe
       WHERE werks IN s_werks1 AND
            (bewtp EQ 'Q' OR bewtp EQ 'N')     AND
             bewtp IN ('Q' , 'N') AND                 "added N  by vincy on 6.07.2008
             budat IN s_budat1 AND
             gjahr IN s_fiscal .
       IF sy-subrc = 0.               "for 1st ekbe
         IF it_ekbe[] IS NOT INITIAL.
         SELECT exnum exdat lifnr matnr maktx capind exbas exbed ecs werks
         ritem1 rdoc1 docyr bedinv ecsinv EXADDINV1 exaddtax1  rdoc2 ritem2 menge
                FROM j_1iexcdtl INTO TABLE it_j_1iexcdtl FOR ALL ENTRIES IN it_ekbe
                WHERE rdoc1  = it_ekbe-ebeln
                AND ritem1 =  it_ekbe-ebelp AND
                lifnr IN s_lifnr.
         ENDIF.
           IF it_j_1iexcdtl[] IS NOT INITIAL.
           SELECT name1 ktokk werks lifnr FROM lfa1 INTO
                            TABLE it_lfa1 FOR ALL ENTRIES IN it_j_1iexcdtl
                             WHERE lifnr = it_j_1iexcdtl-lifnr.
          ENDIF.
           LOOP AT it_ekbe INTO wa_ekbe.
             wa1_ekbe-belnr        = wa_ekbe-belnr.
             wa1_ekbe-budat        = wa_ekbe-budat.
             wa1_ekbe-menge        = wa_ekbe-menge.
             wa1_ekbe-ebelp        = wa_ekbe-ebelp.
             wa1_ekbe-ebeln        = wa_ekbe-ebeln.
             wa1_ekbe-gjahr        = wa_ekbe-gjahr.
             wa1_ekbe-matnr        = wa_ekbe-matnr.
             wa1_ekbe-lfbnr        = wa_ekbe-lfbnr.
             wa1_ekbe-lfpos        = wa_ekbe-lfpos.
             wa1_ekbe-bldat        = wa_ekbe-bldat.
             v_belnr = wa_ekbe-belnr.
             v_gjahr = wa_ekbe-gjahr.
             CONCATENATE v_belnr v_gjahr INTO v_awkey.
             wa1_ekbe-awkey        = v_awkey.
             APPEND wa1_ekbe TO it1_ekbe.
             CLEAR :wa_ekbe.
           ENDLOOP.
    ************changes by vincy on 29.05.08 for 'FB08' and 'FB60'**************
           LOOP AT s_werks1.
             IF s_werks1-low = 'KN01'.
                s_prctr-low  = 'MUKNHSTM'.
             ELSEIF
              s_werks1-low = 'NS01'.
                s_prctr-low  = 'MUNSKSTM'.
             ELSEIF
              s_werks1-low = 'RD01'.
                s_prctr-low  = 'MURDPSTM'.
             ENDIF.
             APPEND s_prctr.
           ENDLOOP.
           SELECT bukrs belnr gjahr budat tcode awkey FROM bkpf INTO TABLE it_bkpf
                          WHERE bukrs = 'MU51'    AND
                          gjahr IN s_fiscal       AND
                          budat IN s_budat1       AND
                          ( tcode = 'FB60' OR  tcode = 'FB08' ).
          IF it_bkpf[] IS NOT INITIAL.
          SELECT ryear docnr rldnr rbukrs docln prctr FROM faglflexa INTO TABLE it_faglflexa
          FOR ALL ENTRIES IN it_bkpf WHERE rbukrs = 'MU51'   AND
                                           ryear  = it_bkpf-gjahr AND
                                           docnr  = it_bkpf-belnr.
          ENDIF.
          LOOP AT it_faglflexa.
            READ TABLE s_prctr WITH KEY low = it_faglflexa-prctr.
            IF sy-subrc <> 0.
            DELETE it_faglflexa.
            ENDIF.
            CLEAR: it_faglflexa, s_prctr.
          ENDLOOP.
    **************************end of change*************************************
           IF it1_ekbe[] IS NOT INITIAL.
           SELECT bukrs belnr gjahr budat tcode awkey FROM bkpf APPENDING
           TABLE it_bkpf FOR ALL ENTRIES IN it1_ekbe
                          WHERE bukrs = 'MU51'    AND
                          gjahr IN s_fiscal AND
                          awkey = it1_ekbe-awkey.
           ENDIF.
           IF sy-subrc = 0.       "bkpf
             IF it_bkpf[] IS NOT INITIAL.
             SELECT bukrs belnr gjahr buzei bschl fwbas pswbt hkont wrbtr  ktosl koart shkzg mwskz qsskz dmbtr lifnr matnr
                          FROM bseg INTO TABLE it1_bseg FOR ALL ENTRIES IN it_bkpf
                           WHERE belnr = it_bkpf-belnr AND
                                 gjahr = it_bkpf-gjahr AND
                                 bukrs = it_bkpf-bukrs AND
                                 ( bschl = '21' ) AND
                                 lifnr IN s_lifnr.                      "added 21 for miro cancelation
              IF it1_bseg[] IS NOT INITIAL.
              SELECT bukrs belnr gjahr buzei bschl fwbas pswbt hkont wrbtr  ktosl koart shkzg mwskz qsskz dmbtr lifnr matnr
                          FROM bseg INTO TABLE it_bseg FOR ALL ENTRIES IN it1_bseg
                           WHERE belnr = it1_bseg-belnr AND
                                 gjahr = it1_bseg-gjahr AND                    "changed it_bkpf to it1_bseg
                                 bukrs = it1_bseg-bukrs .
              LOOP AT it_bseg.
              it_bseg-wrbtr = it_bseg-wrbtr * -1.
              it_bseg-fwbas = it_bseg-fwbas * -1.
              it_bseg-pswbt = it_bseg-pswbt * -1.
              it_bseg-flag_21 = 'X'.
              MODIFY it_bseg.
              CLEAR it_bseg.
              ENDLOOP.
             SELECT name1 ktokk werks lifnr FROM lfa1 INTO
             TABLE it_lfa2 FOR ALL ENTRIES IN it1_bseg
                          WHERE lifnr = it1_bseg-lifnr.
             ENDIF.
             REFRESH it1_bseg.
             SELECT bukrs belnr gjahr buzei bschl fwbas pswbt hkont wrbtr  ktosl koart shkzg mwskz qsskz dmbtr lifnr matnr
                          FROM bseg INTO TABLE it1_bseg FOR ALL ENTRIES IN it_bkpf
                           WHERE belnr = it_bkpf-belnr AND
                                 gjahr = it_bkpf-gjahr AND
                                 bukrs = it_bkpf-bukrs AND
                                 ( bschl = '31' ) AND                      "added bschl and lifnr by vincy
                                 lifnr IN s_lifnr.
             IF it1_bseg[] IS NOT INITIAL.
             SELECT name1 ktokk werks lifnr FROM lfa1 APPENDING
             TABLE it_lfa2 FOR ALL ENTRIES IN it1_bseg
                          WHERE lifnr = it1_bseg-lifnr.
             SELECT bukrs belnr gjahr buzei bschl fwbas pswbt hkont wrbtr  ktosl koart shkzg mwskz qsskz dmbtr lifnr matnr
                          FROM bseg APPENDING TABLE it_bseg FOR ALL ENTRIES IN it1_bseg
                           WHERE belnr = it1_bseg-belnr AND
                                 gjahr = it1_bseg-gjahr AND                    "changed it_bkpf to it1_bseg
                                 bukrs = it1_bseg-bukrs AND
                                 bschl <> '35'.                                "added bschl to avoid vendor paymnt
            ENDIF.
            SELECT bukrs belnr gjahr buzei bschl fwbas pswbt hkont wrbtr  ktosl koart shkzg  mwskz qsskz dmbtr lifnr
                          FROM bseg APPENDING CORRESPONDING FIELDS OF TABLE it_bseg
                          FOR ALL ENTRIES IN it_bkpf
                          WHERE belnr = it_bkpf-belnr AND
                          gjahr = it_bkpf-gjahr AND
                          lifnr IN s_lifnr AND
                          bukrs = it_bkpf-bukrs AND qsskz IN ('WI', 'WJ').
            ENDIF.
          ENDIF.
           SORT it_bseg BY belnr buzei.
           IF NOT it_bseg[] IS INITIAL.
             SELECT saknr spras txt50 FROM skat
                              INTO TABLE iskat
                              FOR ALL ENTRIES IN it_bseg
                              WHERE saknr = it_bseg-hkont AND spras = 'EN'.
             SELECT  bukrs hkont augdt augbl zuonr gjahr belnr buzei budat qsskz FROM bsis
                               INTO TABLE zbsis
                               FOR ALL ENTRIES IN it_bseg
                               WHERE bukrs = 'MU51' AND hkont = it_bseg-hkont
                               AND belnr = it_bseg-belnr AND gjahr = s_fiscal
                               AND budat IN s_budat1.
           ENDIF.
           LOOP AT it_bseg.
             READ TABLE zbsis WITH KEY hkont = it_bseg-hkont.
             IF sy-subrc = 0.
               it_bseg-qsskz = zbsis-qsskz.
               MODIFY it_bseg.
             ENDIF.
             CLEAR: it_bseg,zbsis.
           ENDLOOP.
           LOOP AT zt059z.
             LOOP AT it_bseg WHERE qsskz = zt059z-wt_withcd.
               zt059z-hkont = it_bseg-hkont.
               zt059z-belnr = it_bseg-belnr.
               MODIFY zt059z.
               CLEAR: it_bseg,zt059z.
             ENDLOOP.
           ENDLOOP.
           CLEAR: wa_bkpf.
    *******Filling Wa.
          LOOP AT it_bkpf INTO wa_bkpf.                     "changes by vincy on 14.04.2008
            LOOP AT it1_ekbe INTO wa1_ekbe .
            READ TABLE it_bkpf INTO wa_bkpf
            WITH KEY awkey = wa1_ekbe-awkey.
             wa_tax-belnr     =    wa_bkpf-belnr.
             wa_tax-gjahr     =    wa_bkpf-gjahr.     
             wa_tax-bukrs     =    wa_bkpf-bukrs.
             wa_tax-awkey     =    wa_bkpf-awkey.
             wa_tax-ebelp     =    wa1_ekbe-ebelp.
             CLEAR: wa_bseg,wa_skat.
             READ TABLE it_bseg WITH KEY bukrs = wa_bkpf-bukrs
                                         belnr = wa_bkpf-belnr
                                         gjahr = wa_bkpf-gjahr  INTO wa_bseg.
             IF sy-subrc = 0.
               wa_tax-fi_docno  =    wa_bseg-belnr.
               wa_tax-mwskz     =    wa_bseg-mwskz.
             CLEAR: wa_bseg.
             READ TABLE it_bseg WITH KEY bukrs = wa_bkpf-bukrs
                                           belnr = wa_bkpf-belnr
                                           gjahr = wa_bkpf-gjahr
                                           flag = ''
                                           ktosl = 'JP4' INTO wa_bseg.
             IF sy-subrc = 0.
               wa_bseg-flag = 'X'.
               MODIFY it_bseg INDEX sy-tabix FROM wa_bseg.
               wa_tax-gl_accnt    =  wa_bseg-hkont.
               READ TABLE iskat INTO wa_skat WITH KEY saknr = wa_bseg-hkont.
               IF sy-subrc = 0.
                 wa_tax-gl_desc = wa_skat-txt50.
               ENDIF.
               wa_tax-set_off     =  wa_bseg-wrbtr.
               wa_tax-fwbas       =  wa_bseg-fwbas.
               wa_tax-cst_amt     =  wa_bseg-pswbt.
               wa_tax-description = 'CST CG Sett off'.
               wa_tax-cond_type   =  'JVCS'.
             ENDIF.
             READ TABLE it_bseg WITH KEY bukrs = wa_bkpf-bukrs
                                           belnr = wa_bkpf-belnr
                                           gjahr = wa_bkpf-gjahr
                                           flag = ''
                                           ktosl = 'VS1' INTO wa_bseg.
             IF sy-subrc = 0.
               wa_bseg-flag = 'X'.
               MODIFY it_bseg INDEX sy-tabix FROM wa_bseg.
               wa_tax-fwbas       =  wa_bseg-fwbas.
             ENDIF.
             READ TABLE it_bseg WITH KEY bukrs = wa_bkpf-bukrs
                                            belnr = wa_bkpf-belnr
                                            gjahr = wa_bkpf-gjahr
                                            flag = ''
                                            ktosl = 'JP7' INTO wa_bseg.
             IF sy-subrc = 0.
               wa_bseg-flag = 'X'.
               MODIFY it_bseg INDEX sy-tabix FROM wa_bseg.
               wa_tax-gl_accnt    =  wa_bseg-hkont.
               READ TABLE iskat INTO wa_skat WITH KEY saknr = wa_bseg-hkont.
               IF sy-subrc = 0.
                 wa_tax-gl_desc = wa_skat-txt50.
               ENDIF.
               wa_tax-set_off     =  wa_bseg-wrbtr.
               wa_tax-fwbas       =  wa_bseg-fwbas.
               wa_tax-vat_amt     =  wa_bseg-pswbt.
               wa_tax-description = 'VAT CG Sett off'.
               wa_tax-cond_type   =  'JVCD'.
             ENDIF.
             CLEAR wa_bseg.
            READ TABLE it_bseg WITH KEY bukrs = wa_bkpf-bukrs
                                       belnr = wa_bkpf-belnr
                                       gjahr = wa_bkpf-gjahr
                                       flag = ''
                                       ktosl = 'JP5' INTO wa_bseg.
              READ TABLE it_bseg WITH KEY bukrs = wa_bkpf-bukrs
                                        belnr = wa_bkpf-belnr
                                        gjahr = wa_bkpf-gjahr
                                        hkont = '0002868001' INTO     wa_bseg.       "vat changed for V0 tax code
             IF sy-subrc = 0.
               wa_bseg-flag = 'X'.
               MODIFY it_bseg INDEX sy-tabix FROM wa_bseg.
               wa_tax-gl_accnt  =  wa_bseg-hkont.
               READ TABLE iskat INTO wa_skat WITH KEY saknr = wa_bseg-hkont.
               IF sy-subrc = 0.
                 wa_tax-gl_desc = wa_skat-txt50.
               ENDIF.
               wa_tax-vat_amt   =  wa_bseg-pswbt.
               wa_tax-set_off   =  wa_bseg-wrbtr.
               wa_tax-cond_type =  'JVRD'.
               wa_tax-fwbas     =  wa_bseg-fwbas.
               wa_tax-description        = 'VAT RM Set off'.
             ENDIF.
             CLEAR: wa_bseg,wa_skat.
             READ TABLE it_bseg WITH KEY     bukrs = wa_bkpf-bukrs
                                             belnr = wa_bkpf-belnr
                                             gjahr = wa_bkpf-gjahr
                                             shkzg = 'H'
                                             koart = 'K'
                                             INTO     wa_bseg.
             IF sy-subrc = 0.
               wa_tax-total_value =  wa_bseg-wrbtr.
             ENDIF.
          START OF MODIFICATION BY ASHOK.CH ON 08.02.2008
            service_tax
             CLEAR wa_bseg.
             READ TABLE it_bseg WITH KEY bukrs = wa_bkpf-bukrs
                                        belnr = wa_bkpf-belnr
                                        gjahr = wa_bkpf-gjahr
                                        flag = ''
                                        ktosl = 'VS8'  INTO     wa_bseg.
             IF sy-subrc = 0.
               wa_bseg-flag = 'X'.
               MODIFY it_bseg INDEX sy-tabix FROM wa_bseg.
               wa_tax-gl_accnt  =    wa_bseg-hkont.
               READ TABLE iskat INTO wa_skat WITH KEY saknr = wa_bseg-hkont.
               IF sy-subrc = 0.
                 wa_tax-gl_desc = wa_skat-txt50.
               ENDIF.
               wa_tax-service_tax =  wa_bseg-wrbtr.
               wa_tax-description = 'Service Tax'.
               wa_tax-cond_type =  'JSRT'.
             ENDIF.
         service_ecess
             CLEAR: wa_bseg,wa_skat.
             READ TABLE it_bseg WITH KEY bukrs = wa_bkpf-bukrs
                                        belnr = wa_bkpf-belnr
                                        gjahr = wa_bkpf-gjahr
                                        flag = ''
                                        ktosl = 'VS9'  INTO  wa_bseg.
             IF sy-subrc = 0.
               wa_bseg-flag = 'X'.
               MODIFY it_bseg INDEX sy-tabix FROM wa_bseg.
               wa_tax-service_ecess =  wa_bseg-wrbtr.
             ENDIF.
    **********changes by vincy on 31.01.08*********************
        service_shcess
             CLEAR: wa_bseg.
             READ TABLE it_bseg WITH KEY bukrs = wa_bkpf-bukrs
                                        belnr = wa_bkpf-belnr
                                        gjahr = wa_bkpf-gjahr
                                        flag = ''
                                        ktosl = 'VSE'  INTO  wa_bseg.
             IF sy-subrc = 0.
               wa_bseg-flag = 'X'.
               MODIFY it_bseg INDEX sy-tabix FROM wa_bseg.
               wa_tax-service_shcess =  wa_bseg-wrbtr.
             ENDIF.
    *************************end of changes***********************
    END OF MODIFICATION ON 08.02.2008
             APPEND wa_tax TO it_tax.
             ENDIF.
             CLEAR :wa_tax,wa_bseg,wa_bkpf,wa_skat.
           ENDLOOP.
           CLEAR wa1_ekbe.
           LOOP AT it1_ekbe INTO wa1_ekbe.
            READ TABLE it_j_1iexcdtl INTO wa_j_1iexcdtl
                                    WITH KEY  rdoc1  = wa1_ekbe-ebeln
                                    ritem1 = wa1_ekbe-ebelp.
    *New query added by Nilesh
            READ TABLE it_j_1iexcdtl INTO wa_j_1iexcdtl
                                    WITH KEY  rdoc1  = wa1_ekbe-lfbnr
                                    ritem2 = wa1_ekbe-lfpos.
             READ TABLE it_bkpf INTO wa_bkpf
             WITH KEY awkey = wa1_ekbe-awkey.
             IF sy-subrc = 0.
             READ TABLE it_bseg WITH KEY bukrs = wa_bkpf-bukrs
                                        belnr = wa_bkpf-belnr
                                        gjahr = wa_bkpf-gjahr.
              IF sy-subrc = 0.
               wa_ekexclf-belnr  =       wa1_ekbe-belnr.
               wa_ekexclf-budat  =       wa1_ekbe-budat.
               wa_ekexclf-menge  =       wa1_ekbe-menge.
               wa_ekexclf-ebelp  =       wa1_ekbe-ebelp.
               wa_ekexclf-ebeln  =       wa1_ekbe-ebeln.
               wa_ekexclf-gjahr  =       wa1_ekbe-gjahr.
               wa_ekexclf-awkey  =       wa1_ekbe-awkey.
               wa_ekexclf-lifnr  =       it_bseg-lifnr.
               wa_ekexclf-matnr  =       it_bseg-matnr .
            READ TABLE it_j_1iexcdtl INTO wa_j_1iexcdtl                 "for records for which either rdoc1 or matnr
                                    WITH KEY  rdoc2  = wa1_ekbe-lfbnr   "not maintained in ekbe by vincy on 16.06.08
                                              menge  = wa1_ekbe-menge.
            IF sy-subrc <> 0 .
            READ TABLE it_j_1iexcdtl INTO wa_j_1iexcdtl
                                    WITH KEY  rdoc1  = wa1_ekbe-ebeln
                                              exdat  = wa1_ekbe-bldat
                                              matnr  = wa1_ekbe-matnr
                                              menge  = wa1_ekbe-menge.
            ENDIF.
             READ TABLE it_j_1iexcdtl INTO wa_j_1iexcdtl
                                     WITH KEY  rdoc1  = wa1_ekbe-ebeln
                                               ritem1 = wa1_ekbe-ebelp.
             IF sy-subrc = 0.
              wa_ekexclf-belnr  =       wa1_ekbe-belnr.
              wa_ekexclf-budat  =       wa1_ekbe-budat.
              wa_ekexclf-menge  =       wa1_ekbe-menge.
              wa_ekexclf-ebelp  =       wa1_ekbe-ebelp.
              wa_ekexclf-ebeln  =       wa1_ekbe-ebeln.
              wa_ekexclf-gjahr  =       wa1_ekbe-gjahr.
              wa_ekexclf-awkey  =       wa1_ekbe-awkey.
               wa_ekexclf-exnum  =       wa_j_1iexcdtl-exnum.
               wa_ekexclf-exdat  =       wa_j_1iexcdtl-exdat.
               wa_ekexclf-lifnr  =       wa_j_1iexcdtl-lifnr.
               wa_ekexclf-matnr  =       wa_j_1iexcdtl-matnr .
               wa_ekexclf-maktx  =       wa_j_1iexcdtl-maktx .
               wa_ekexclf-capind =        wa_j_1iexcdtl-capind.
               wa_ekexclf-exbas  =        wa_j_1iexcdtl-exbas.
              wa_ekexclf-exbed  =        wa_j_1iexcdtl-exbed.
              wa_ekexclf-ecs    =        wa_j_1iexcdtl-ecs.
               wa_ekexclf-werks  =        wa_j_1iexcdtl-werks.
               wa_ekexclf-ritem1 =       wa_j_1iexcdtl-ritem1.
               wa_ekexclf-rdoc1  =         wa_j_1iexcdtl-rdoc1.
               wa_ekexclf-docyr  =       wa_j_1iexcdtl-docyr.
              wa_ekexclf-exaddtax1  = wa_j_1iexcdtl-exaddtax1.
               IF it_bseg-flag_21 = 'X'.
               wa_ekexclf-exbas  = wa_ekexclf-exbas * -1.
               ENDIF.
    MODIFIED BY ASHOK.CH ON 08.03.2008
          IF wa_j_1iexcdtl-WERKS NE 'RD01' .
               wa_ekexclf-exbed  =        wa_j_1iexcdtl-exbed.
               wa_ekexclf-ecs    =        wa_j_1iexcdtl-ecs.
               wa_ekexclf-exaddtax1  = wa_j_1iexcdtl-exaddtax1.
               IF it_bseg-flag_21 = 'X'.
                 wa_ekexclf-exbed  =        wa_ekexclf-exbed * -1.
                 wa_ekexclf-ecs    =        wa_ekexclf-ecs * -1.
                 wa_ekexclf-exaddtax1  = wa_ekexclf-exaddtax1 * -1.
               ENDIF.
         ELSE.
               wa_ekexclf-exbed  =        wa_j_1iexcdtl-BEDINV.
               wa_ekexclf-ecs    =        wa_j_1iexcdtl-ecsINV.
               wa_ekexclf-exaddtax1  = wa_j_1iexcdtl-exaddINV1.
         ENDIF.
    END IF MODIFICATION ON 08.03.2008
              APPEND wa_ekexclf TO it_ekexclf.
              CLEAR :wa_lfa1,wa_j_1iexcdtl,wa1_ekbe.
             ENDIF.
               READ TABLE it_lfa2 INTO wa_lfa2
               WITH KEY lifnr = wa_ekexclf-lifnr.
               IF sy-subrc = 0.
                 wa_ekexclf-name1  =        wa_lfa2-name1.
                 wa_ekexclf-ktokk  =        wa_lfa2-ktokk.
               ENDIF.
               APPEND wa_ekexclf TO it_ekexclf.
             ENDIF.
             ENDIF.
               CLEAR :wa_lfa1,wa_j_1iexcdtl,wa1_ekbe,wa_lfa2,wa_ekexclf.
           ENDLOOP.
           CLEAR wa_ekexclf.
           LOOP AT it_ekexclf INTO wa_ekexclf.
             wa_final-belnr     =       wa_ekexclf-belnr.
             wa_final-budat     =       wa_ekexclf-budat.
             wa_final-menge     =       wa_ekexclf-menge.
             wa_final-ebelp     =       wa_ekexclf-ebelp.
             wa_final-ebeln     =       wa_ekexclf-ebeln.
             wa_final-gjahr     =       wa_ekexclf-gjahr.
             wa_final-awkey     =       wa_ekexclf-awkey.
             wa_final-exnum     =       wa_ekexclf-exnum.
             wa_final-exdat     =       wa_ekexclf-exdat.
             wa_final-lifnr     =       wa_ekexclf-lifnr.
             wa_final-matnr     =       wa_ekexclf-matnr .
             wa_final-maktx     =       wa_ekexclf-maktx .
             wa_final-shcess_amt = wa_ekexclf-exaddtax1.
             IF  wa_ekexclf-capind = 'C'.
               wa_final-capind    =  'Consumables'.
             ENDIF.
             IF  wa_ekexclf-capind = 'A'.
               wa_final-capind    =  'Assets'.
             ENDIF.
             IF  wa_ekexclf-capind = 'T'.
               wa_final-capind    =   'Tools'.
             ENDIF.
             IF  wa_ekexclf-capind = ''.
               wa_final-capind    =   'Raw Material'.
             ENDIF.
             IF  wa_ekexclf-capind = 'N'.
               wa_final-capind    =  'Non Cenvatable'.
             ENDIF.
             IF  wa_ekexclf-capind NE 'C' AND wa_ekexclf-capind NE 'A' AND
                 wa_ekexclf-capind NE '' AND wa_ekexclf-capind NE 'N'.
               wa_final-capind    = wa_ekexclf-capind.
             ENDIF.
             wa_final-exbas     =       wa_ekexclf-exbas.
             wa_final-exbed     =       wa_ekexclf-exbed.
             wa_final-ecs       =       wa_ekexclf-ecs.
             wa_final-werks     =       wa_ekexclf-werks.
             wa_final-ritem1    =       wa_ekexclf-ritem1.
             wa_final-rdoc1     =       wa_ekexclf-rdoc1.
             wa_final-docyr     =       wa_ekexclf-docyr.
             wa_final-name1     =       wa_ekexclf-name1.
             wa_final-ktokk     =       wa_ekexclf-ktokk.
             wa_final-excise    =       wa_final-exbas + wa_final-exbed + wa_final-ecs + wa_final-shcess_amt.
             CLEAR :wa_tax.

    Hi ,
    I think you are using the redundant selects to fetch the data from BSEG.
    First select all the data into an internal table based on  bkpf.
    Now you can distribute the data into whatever tables you want using the loop,read-binary search and append statements..
    Loop at it_bseg.
    read it_bseg where
                        xxxxx
                        xxxxx
                        binary search.
    append wa to it2_bseg.
    endloop              
    This avoid several database fetches..
    Thank you..

  • Report for replacement stock to be recived from vendor

    Hi
    I HAVE ONE ISSUE ON ABOUT VENDOR REPLACEMENT STOCK REPORT
    EX:.. i have done GR for material-A qty 100...and ihave done MIRO for this ..pur.order..
    after 20 days i have return the materai-A ..qty 25..(without cancel the MIRO) with movement tuype 122..but this material should be return from vedor.(subsequent deliver).after some days or weeks ..( bcoz money has already paid to vendor)...like this we many materials ..
    for this... i want report for replacement material will be recived from vendor
    regards
    sesidhar

    Hi
    already i have done MIRO..
    then return to vendor qty 25..(through MIRO...w/o creadit memo
    thne again recive the replacement material ..through MIGO (subsequent delivery)
    in this case ..need to create credit memo..?
    if yes.. pls...send me procedure.
    regards
    sesidhar

  • Follow-on documents are not visible in MIRO in TEST server, awsys = PRD300.

    Dear Experts ,
    The Test Server was refreshed around mid-June 2011 with data of
    Production Server. The follow-on documents are not visible for the
    invoice documents in MIRO in TEST server due to value in tables
    BKPF,RBKP : field : AWSYS = PRD300 .
    The newly created Purchase Orders after the refresh, the accounting
    documents can be seen for the Goods Receipt (MIGO_GR-display) and
    Invoice documents (MIRO).
    we had already raised this issue in March & got the feedback from SAP
    as shown below.
    accordingly we have developed & run the program "zzlogsys2" which
    updates the Logsys/Awsys field from PRD300 ( of production server ) to
    that of the current server i.e. TST300 as required.
    after which the FI documents for the material documents are visible in
    MIGO,but follow-on documents are not visible for the invoice documents
    in MIRO.
    we have Checked notes 781498 and 28958 to see if the logical system is
    correctly assigned , where we found that in table RBKP after entering document number, Fiscal Year , the
    Field AWSYS is "PRD300" & not "TST300" as it should be. We will take up the activity of updating table RBKP
    also as we are currently doing for tables MKPF & BKPF.
    But to have clear picture as to what we are doing is correct , pl
    advise about the following :
    1) Is it a correct process done by our SAP-Basis team , that every time
    any Server ( e.g. Test or Quality ) is refreshed with Production server
    data, the Field AWSYS in various transaction tables gets value as
    "PRD300" which then is required to replaced by running program such as
    ZZlogsys.
    REPORT ZZLOGSYS.
    TABLES: T000, MKPF.
    DATA: NEW_SYS LIKE MKPF-AWSYS.
    PARAMETER: OLD_SYS LIKE MKPF-AWSYS.
    SELECT SINGLE * FROM T000 WHERE MANDT EQ SY-MANDT.
    NEW_SYS = T000-LOGSYS.
    CHECK NOT NEW_SYS IS INITIAL.
    UPDATE MKPF SET AWSYS = NEW_SYS
    WHERE AWSYS = OLD_SYS.
    WRITE:/ 'Number of updates: ', SY-DBCNT.
    2) if the above process is correct & normal , then which are the other
    tables in a particular server ,apart from tables MKPF,BKPF,RBKP , which
    needs to be updated the value of field "AWSYS" in the same way
    replacing value "PRD300".
    3) if the process in point no. 1 is not correct , then what is the
    correct process that the Basis team can do while refreshing any target
    server with production data so that target server retains its value in
    Field AWSYS & not showing "PRD300".
    With 3 servers TEST,DEV & Quality , recently refreshed with production
    server to bring all servers in Sync for a HR patch application, we have
    this situation now in all 3 servers .
    Thanks in advance ,
    Anil Shanbhag

    It is appropriate to move this thread from ERP-MM to [Enterprise Resource Planning (ERP)|Enterprise Resource Planning (SAP ERP);
    Edited by: Jeyakanthan A on Jul 7, 2011 4:56 PM

  • USER EXIT or BADI for Vendor field in MIRO

    Hi Experts,
    In MIRO transaction vendor field gets defaulted from Purchase Order. So my requirement is to changes that vendor with alternate payee.
    To <u>replace the vendor with alternate payee</u> I need the <b>USER EXIT or BADI</b>, kindly help me on this will be useful for us.
    Thanks in Advance.
    SAP Consultant

    Transaction Code - MIGO                     Goods Movement
    Exit Name           Description
    MBCF0002            Customer function exit: Segment text in material do
    MBCF0005            Material document item for goods receipt/issue slip
    MBCF0006            Customer function for WBS element
    MBCF0007            Customer function exit: Updating a reservation
    MBCF0009            Filling the storage location field
    MBCF0010            Customer exit: Create reservation BAPI_RESERVATION_
    MBCF0011            Read from RESB and RKPF for print list in  MB26
    MB_CF001            Customer Function Exit in the Case of Updating a Ma
    No of Exits:          8
    BAPI-step by step procedure
    http://www.sapgenie.com/abap/bapi/example.htm
    list of all BAPI's
    http://www.planetsap.com/LIST_ALL_BAPIs.htm
    Rewards if useful.................
    Minal

  • Senario maping for sending goods for replacement

    Hi All,
    We have a senario to be mapped in SAP MM. We are into aircraft maintenence business.
    All our air craft are insured from tip to tail. If any of the part the aircraft shows any problem then it will be send to the OEM and shall be replaced by them free of cost.
    Only we have to pay the customs duty and the freight amount. How to map the complete tracking of sending the material to vendor and getting the replaced material and booking the custom value for that material.
    Regards,
    Mohar

    You can create purchase order(161 movement) with returns tick to return defective part.
    Do goods receipt(MIGO,161 movement).
    Create import & freight condition types(M/06) & link it in pricing procedure (M/08).
    Configure for purchasing & vendor schema settings.
    Add another line item in same p.o for material replaced in same p.o with negligible price to enable
    maintaining customs & freight values in respective condition type.
    When BOE arrives maintain customs rate in condition types of purchase order.
    Do custom invoice by capturing customs rates.
    Do goods receipt based on custom MIRO.

  • Substitution of account(HKONT) when posting in MIGO/MIRO

    Issue: Need to change account(HKONT) when posting in MIGO/MIRO
    example:       HKONT(GL Account)       KTOSL(Transaction type)
                   1000000001              XX1
                   1000000002              XX2
                   1000000003              XX3
    If XX3 exist then replace hkont of XX1 to hkont of XX2
    expected result is:
                   1000000002              XX1
                   1000000002              XX2
                   1000000003              XX3
    Solution with problems:
    1. Used substitution GGB1>Financial Account>line item for field HKONT. My problem with this is, since the data is in line item. How can I get the replacement of my account(shown above sample). if BSEG structure only shows 1 line item. I tried using bool_data-bseg. but its empty. Im assuming bool_data is used when callup 003(complete document) is triggered.
    I used subtitution field G/L - Exit <UXXX>
    Any Ideas or solutions would be great!!

    if your Substituion exit is called then you can directly change the value of
    BSEG-HKONT there according to your requirement.

  • Change of Vendor Master Re-con Account in MIRO Transaction

    Hi Friends.
    Thanks in Advance,
    Requirement : While Posting the MIRO Transaction, Vendor Master Re-con Account has to be Replace by other Re-con account
    Using Business Transactions Events this can be achived and sucessfully replaced. also data based Tables BSEG also updated sucessfully.
    But the problem is when viewing the reports like  FAGLL03, FAGLB03 we can able to view the data against that G/L Account.
    Regards:
    Sridhar.J

    Hi Sridhar,
    Let me know what is the business requirement to assign separate GL account while doing MIRO ? Which BTE used for that ? If you don't mind.
    Rgds
    SumaMani

  • Vendor changed in MIRO

    I have made a PO with one vendor. i have done GR with the same vendor. but in MIRO I have posted miro to some different vendor in details tab under invoicing party. How it is possible, why system is allowing me to change the vendor at the time of miro posting. how to rectify the issue if MIRO has been posted

    Hi,
    You can restrict to change vendor with error msges
    T Code : OMRM
    042     Vendor & for PO & replaced by &        as error
    keeping user name as *
    220     Different vendor: purchase order & placed with vendor &
    Hope Help U !
    Regards,
    Pardeep malik

  • Substitution - Baseline Date to be replaced by the Goods Receipt date

    Dear Forum,
    We have the payment terms defined in the system, with the baseline date corresponding to the 'Document Date' and the credit terms as 60 Days. The users now desire that the Baseline Date should instead correspond to the Goods Receipt Date. To enable this we need to define the substitution such as the Baseline Date at the time of Invoice Verification gets substituted by the Goods Receipt Date, if the GR Date is earlier than the IV date.
    Would appreciate help from the friends as to how to configure this and which feilds to be chosen and replaced.
    Thanks!
    Regards,

    Hi
    You can make the Baseline Date in Invoice (MIRO) with Goods Receipt Date using BADI.
    BADI -->MRM_PAYMENT_TERMS
    Tell your ABAP Guy to work on this BADI.
    In the BADI,  MRM_PAYMENT_TERMS Read the Value in WEBUD of Internal Table TI_DRSEG and Pass it into E_ZFBDT.
    Also if the Baseline Date is changed manually, then after posting you can see the Goods Receipt Date in Baseline Date.
    This resolves your issue.
    regards
    venkat

  • Miro BAPI

    Hi,
    I am trying to use BAPI_INCOMINGINVOICE_CREATE for MIRO transaction.  Can anyone please explain to me how to use component PROFIT_SEGM_NO in structure BAPI_INCINV_CREATE_GL_ACCOUNT?  (This is missing from the documentation as it is a 'late' addition to the BAPI).
    Or:
    Has anyone had success posting Incoming Invoice GL account line - with a profitability segment (COPA)?
    Thanks,
    Michal

    Hi michal,
    Look at the code in th fm:
    <b>BBP_INVOICE_CREATE
    MRM_XMLBAPI_INCINV_CREATE</b>
    Look at this sample code
    REPORT  Z_BAPI_INCOMINGINVOICE_CREATE           .
    *       Create Vendor Invoices using BAPI               *
      Invoice data is sent by the vendors in a text file and an inbound
    *  interface is required to create Vendor Invoices in SAP.
    *  The file contains the Purchase Order information, material quantity
    *  received from vendor along with the amount.
    *  Here the requirement becomes a little complex as there might be
    *  several ocuurences of same Purchase Order item in one  invoice.
    *  Only a incomplete sample coding is given here and it can only be used
    *  as a base for writing a program.
    * Populate internal Table I_ITAB from the data uploaded
    * from text data file.
    * Populate Item Table from item data in data file
    *   Processing for header records of data file.
    *   set up header data for BAPI call.
    *   Check whwther it's an Incoice or Credit Memo.
    *   And populate Invoice indicator accordingly.
    IF I_ITAB-TRANS EQ '-'.
      I_HEADER-INVOICE_IND = C_X.
    ELSE.
      CLEAR I_HEADER-INVOICE_IND.
    ENDIF.
    I_HEADER-PSTNG_DATE = I_ITAB-BUDAT.
    I_HEADER-DOC_DATE = I_ITAB-BLDAT.
    I_HEADER-CURRENCY = W_WAERS.
    I_HEADER-GROSS_AMOUNT = I_ITAB-DMBTR.
    I_HEADER-COMP_CODE = I_ITAB-BUKRS.
    I_HEADER-HEADER_TXT = I_ITAB-SGTXT.
    I_HEADER-REF_DOC_NO = I_ITAB-XBLNR.
    IF NOT I_ITAB-INV_REC_DATE IS INITIAL.
      I_HEADER-INV_REC_DATE = I_ITAB-INV_REC_DATE.
    ELSE.
      I_HEADER-INV_REC_DATE = I_ITAB-BLDAT.
    ENDIF.
    I_HEADER-PYMT_METH = I_ITAB-ZLSCH.
    APPEND I_HEADER.
    * Populate Item Table from item data in data file
    lv_count = 0.
    LOOP AT I_ITAB.
    *   Processing for header records of data file.
      lv_count = lv_count + 1.
    * Item Data
      I_ITEM-INVOICE_DOC_ITEM = lv_COUNT.
      I_ITEM-PO_NUMBER    = I_ITAB-EBELN.
      I_ITEM-PO_ITEM      = I_ITAB-EBELP.
      I_ITEM-TAX_CODE     = I_ITAB-MWSKZ2.
      I_ITEM-ITEM_AMOUNT  = I_ITAB-NETWR.
    * Populate quantities if not a blanket order
      IF I_ITAB-BLANKET EQ SPACE.
        I_ITEM-QUANTITY = I_ITAB-MENGE.
        PERFORM GET_MEINS USING I_ITAB-EBELN       " Use table EKPO
                                I_ITAB-EBELP
                          CHANGING I_ITEM-PO_UNIT.
        I_ACCOUNTINGDATA-PO_UNIT = I_ITEM-PO_UNIT.
        IF I_ITEM-QUANTITY EQ 0.
          I_ITEM-PO_UNIT = SPACE.
        ENDIF.
      ENDIF.
    * Item Text
      I_ITEM-ITEM_TEXT = I_ITAB-ITEM_TEXT.
      APPEND I_ITEM.
    * Populate Accounting Data
      IF I_ITAB-BLANKET EQ SPACE.
        I_ACCOUNTINGDATA-INVOICE_DOC_ITEM = lv_COUNT.
        I_ACCOUNTINGDATA-SERIAL_NO        = '01'.
        I_ACCOUNTINGDATA-TAX_CODE         = I_ITAB-MWSKZ2.
        I_ACCOUNTINGDATA-ITEM_AMOUNT      = I_ITAB-NETWR.
        SELECT SINGLE SAKTO KOSTL VBELN VBELP ANLN1 ANLN2 DABRZ
                      FISTL GEBER GRANT_NBR GSBER IMKEY KOKRS KSTRG PAOBJNR
                      PRCTR PS_PSP_PNR AUFNR MENGE
          FROM EKKN
          INTO (I_ACCOUNTINGDATA-GL_ACCOUNT, I_ACCOUNTINGDATA-COSTCENTER,
                I_ACCOUNTINGDATA-SD_DOC, I_ACCOUNTINGDATA-SDOC_ITEM,
                I_ACCOUNTINGDATA-ASSET_NO, I_ACCOUNTINGDATA-SUB_NUMBER,
                I_ACCOUNTINGDATA-REF_DATE, I_ACCOUNTINGDATA-FUNDS_CTR,
                I_ACCOUNTINGDATA-FUND, I_ACCOUNTINGDATA-GRANT_NBR,
                I_ACCOUNTINGDATA-BUS_AREA, I_ACCOUNTINGDATA-RL_EST_KEY,
                I_ACCOUNTINGDATA-CO_AREA, I_ACCOUNTINGDATA-COSTOBJECT,
               I_ACCOUNTINGDATA-PROFIT_SEGM_NO, I_ACCOUNTINGDATA-PROFIT_CTR,
                I_ACCOUNTINGDATA-WBS_ELEM, I_ACCOUNTINGDATA-ORDERID,
                I_ACCOUNTINGDATA-QUANTITY)
          WHERE EBELN EQ I_ITAB-EBELN
          AND   EBELP EQ I_ITAB-EBELP
          AND   ZEKKN EQ '01'.
        IF EKKO-BSART NE 'LTV'.
          CLEAR I_ACCOUNTINGDATA-QUANTITY.
          CLEAR I_ACCOUNTINGDATA-PO_UNIT.
        ENDIF.
        APPEND I_ACCOUNTINGDATA.
      ENDIF.
    ENDLOOP.
    *   The following coding is to solve the problem
    *   mentioned in OSS Note 518338.
    *   Same PO item within several invoice items.
    SORT I_ITEM BY PO_NUMBER PO_ITEM.
    LOOP AT I_ITEM.
      ON CHANGE OF I_ITEM-PO_NUMBER OR I_ITEM-PO_ITEM.
        W_COUNTER = 1.
        LOOP AT I_ITEM WHERE PO_NUMBER = I_ITEM-PO_NUMBER
                         AND PO_ITEM   = I_ITEM-PO_ITEM.
          IF W_COUNTER EQ 1.
            I_ACCOUNTINGDATA-SERIAL_NO = '01'.
            I_ACCOUNTINGDATA-XUNPL     = ' '.
          ELSE.
            I_ACCOUNTINGDATA-SERIAL_NO = ' '.
            I_ACCOUNTINGDATA-XUNPL     = 'X'.
          ENDIF.
          MODIFY I_ACCOUNTINGDATA
           TRANSPORTING SERIAL_NO XUNPL
          WHERE INVOICE_DOC_ITEM = I_ITEM-INVOICE_DOC_ITEM.
          W_COUNTER = W_COUNTER + 1.
        ENDLOOP.
    *     To solve the repetition of PO item in subsequent invoices.
      ELSEIF SY-TABIX EQ 1.
        W_COUNTER = 1.
        LOOP AT I_ITEM WHERE PO_NUMBER = I_ITEM-PO_NUMBER
                         AND PO_ITEM   = I_ITEM-PO_ITEM.
          IF W_COUNTER EQ 1.
            I_ACCOUNTINGDATA-SERIAL_NO = '01'.
            I_ACCOUNTINGDATA-XUNPL     = ' '.
          ELSE.
            I_ACCOUNTINGDATA-SERIAL_NO = ' '.
            I_ACCOUNTINGDATA-XUNPL     = 'X'.
          ENDIF.
          MODIFY I_ACCOUNTINGDATA
           TRANSPORTING SERIAL_NO XUNPL
          WHERE INVOICE_DOC_ITEM = I_ITEM-INVOICE_DOC_ITEM.
          W_COUNTER = W_COUNTER + 1.
        ENDLOOP.
      ENDON.
    ENDLOOP.
    *   Changes over for  OSS Note 518338.
    SORT I_ITEM BY INVOICE_DOC_ITEM PO_NUMBER PO_ITEM.
    CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
      EXPORTING
        HEADERDATA       = I_HEADER
      IMPORTING
        INVOICEDOCNUMBER = W_BELNR
        FISCALYEAR       = W_GJAHR
      TABLES
        ITEMDATA         = I_ITEM
        ACCOUNTINGDATA   = I_ACCOUNTINGDATA
        TAXDATA          = I_TAX
        RETURN           = I_RETURN.
    if sy-subrc < >  0.
      message e999(re) with  'Problem occured'.
    else.
      loop at return.
        if not return is initial.
          clear bapi_retn_info.
          move-corresponding return to bapi_retn_info.
          if return-type = 'A' or return-type = 'E'.
            error_flag = 'X'.
          endif.
          append bapi_retn_info.
        endif.
      endloop.
      if error_flag = 'X'.
        message e999(re) with  'Problem occured'.
        rollback work.
      else.
         *       Return Table from BAPI call is empty
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            WAIT   = 'X'
          IMPORTING
            RETURN = I_RETURN.
      endif.
    endif.
    Thanks
    Sudheer

Maybe you are looking for

  • Problem with WLAN in my E51 phone...

    hi again everyone, sorry for bothering you, but when i try to connect to wlan through my own router found at home , the web site says: No gateway reply... what can i do to solve this?? am getting crazy...hellpppp plz

  • Can not get Final Cut pro to capture HD footage from Canon HV10

    Ive had soo much trouble with no success, in trying to get footage from my HD camera into Fina cut Pro HD 4.5. I can get normal dv footage when i cahnge the setting s on the camera, and Final cut pro, but HD is not been possible so far.If any one can

  • TS1702 How can I remove an app I no longer want?

    How can I remove an app I no longer want?

  • [HELP] Search Files Function

    Hi, Could someone please help me fix this function below. It's suppost to search files in a dir for a particular string. I have files in the "./" dir but the function does not seem to output nothing at all. The search is also suppost to ignore the fi

  • How to call ExportCollectionActionListener from bean

    In my scenario, I have to get a confirmation from user as "Are you sure you want to export table data to excel document?" And when user clicks "YES", the data should be exported. And I'm trying to achieve this using bean method, where in I can know w