1 Reply Latest reply: Jul 29, 2008 10:55 PM by Kumar Chakravarthy Bojedla SP4Z126A1595 RSS

Required replace BSEG with BSAK BSIK BSIS BSAS for report performance

Ish Prakash
Currently Being Moderated

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.

         READ TABLE it_tax INTO wa_tax WITH KEY awkey = wa_ekexclf-awkey

                                                ebelp = wa_ekexclf-ebelp

                                                flag = ''.

         IF sy-subrc = 0.

           wa_tax-flag = 'X'.

           MODIFY it_tax FROM wa_tax INDEX sy-tabix.

           wa_final-fi_docno      =  wa_tax-fi_docno.

           wa_final-fwbas         =  wa_tax-fwbas.

           wa_final-gl_accnt      =  wa_tax-gl_accnt.

           wa_final-gl_desc       =  wa_tax-gl_desc.

           wa_final-taxcode       =  wa_tax-taxcode.

           wa_final-taxperc       =  wa_tax-taxperc.

           wa_final-total_value   =  wa_tax-total_value.

  •           wa_final-rate        = ( wa_tax-total_value / wa_final-menge ).

           wa_final-rate        = ( wa_final-exbas / wa_final-menge ).

           IF  wa_final-rate < 1.

               wa_final-rate = wa_final-rate * -1.

           ENDIF.

           wa_final-set_off       =  wa_tax-set_off.

           wa_final-service_tax   =  wa_tax-service_tax  .

           wa_final-service_ecess =  wa_tax-service_ecess.

           wa_final-service_shcess =  wa_tax-service_shcess.      "vincy on 31.01.08

           wa_final-vat_amt      = wa_tax-vat_amt.

 

           wa_final-mwskz         = wa_tax-mwskz.

           IF wa_tax-cond_type = 'JVRD' OR wa_tax-cond_type = 'JVCD' .

             wa_final-cond_type         =  wa_tax-cond_type.

             wa_final-description        = wa_tax-description .

           ENDIF.

 

 

           REFRESH:it_konv.

           IF wa_ekexclf-ebeln IS NOT INITIAL.                  "added by vincy on 16.06.08

           CALL FUNCTION 'ZMMFUN001'

             EXPORTING

               i_ebeln = wa_ekexclf-ebeln

             TABLES

               t_konv  = it_konv.

 

           DATA: vat_per TYPE konv-kbetr,

                cst_per TYPE konv-kbetr.

           CLEAR: vat_per,wa_konv.

 

           d2 = wa_ekexclf-ebelp.

 

           CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

             EXPORTING

               input  = d2

             IMPORTING

               output = d1.

           DATA var TYPE c.

           CLEAR var.

           wa_final-inventorised  = 0.

           wa_final-cond_type2     =  ''.

 

           LOOP AT it_konv INTO wa_konv WHERE kposn = d1.

 

             IF  wa_konv-kvsl1 = 'JP4' OR wa_konv-kvsl1 = 'JP6' OR wa_konv-kvsl1 =

               'JP8'.

 

               var = 'X'.

 

 

               DATA wa_ekpo TYPE ekpo OCCURS 0 WITH HEADER LINE.

 

               SELECT SINGLE * FROM ekpo INTO CORRESPONDING FIELDS OF wa_ekpo

               WHERE ebeln =  wa_ekexclf-rdoc1 AND ebelp = d2 .

               IF sy-subrc = '0'.

 

                 CLEAR :invent,invent1.

                 invent = wa_konv-kwert / wa_ekpo-menge.

                 invent1 = invent * wa_ekexclf-menge.

 

                 wa_final-inventorised  = invent1.

               ENDIF.

               IF  wa_konv-kvsl1 = 'JP4'.

                 wa_final-cond_type2     =  'JVCS'.

                 wa_final-description   = 'CST Inventorised'.

                 wa_final-cst_amt       =  wa_tax-cst_amt + invent1.

                 CLEAR :invent.

               ENDIF.

               IF  wa_konv-kvsl1 = 'JP6'.

                 wa_final-cond_type2     =  'JVRN'.

                 wa_final-description   = 'VAT RM Inventorised'.

                 wa_final-vat_amt       =  wa_tax-vat_amt + invent1.

                 CLEAR :invent.

               ENDIF.

               IF  wa_konv-kvsl1 = 'JP8'.

                 wa_final-cond_type2     =  'JVCN'.

                 wa_final-description   = 'VAT CG Inventorised'.

                 wa_final-vat_amt       =  wa_tax-vat_amt + invent1.

                 CLEAR :invent.

               ENDIF.

 

               CLEAR: wa_konv,invent,wa_ekpo.

             ELSE.

               wa_final-vat_amt      = wa_tax-vat_amt.

             ENDIF.

 

           ENDLOOP.

 

           IF wa_tax-cond_type = 'JSRT'.

             wa_final-cond_type2         =  wa_tax-cond_type.

             wa_final-description        =  wa_tax-description .

           ENDIF.

 

           CLEAR :var,wa_konv,invent,wa_ekpo.

 

 

 

           LOOP AT it_konv INTO wa_konv WHERE kposn = d1.

             IF wa_konv-kschl = 'JVRD' OR  wa_konv-kschl = 'JVRN'.

               vat_per = wa_konv-kbetr + vat_per .

             ENDIF.

             IF wa_konv-kschl = 'JVCD' OR  wa_konv-kschl = 'JVCN'.

               vat_per = wa_konv-kbetr + vat_per .

             ENDIF.

             IF wa_konv-kschl = 'JVCS' .

               cst_per = wa_konv-kbetr + cst_per.

             ENDIF.

             IF wa_konv-kschl = 'JSRT' .

               vat_per = wa_konv-kbetr + cst_per.

             ENDIF.

 

             wa_final-excise_tax = wa_final-vat_amt +  wa_final-cst_amt.

  •             wa_final-total_value1 = wa_final-excise + wa_final-total_value + wa_final-excise_tax.

             wa_final-total_value1 = wa_final-excise +  wa_final-excise_tax.

 

             CLEAR: wa_konv,invent.

           ENDLOOP.

           wa_final-vat_per       = vat_per * '0.1'.

           wa_final-cst_per       = cst_per * '0.1'.

           CLEAR :wa_tax,invent,invent1,vat_per,cst_per,d2,d1.

           REFRESH:it_konv.

         ENDIF.

        ENDIF.

 

         APPEND wa_final TO it_final.

         CLEAR :wa_final,wa_ekexclf,wa_tax,invent,wa_konv,vat_per,d2,d1.

       ENDLOOP.

 

     ENDIF.                                                 "j_1iexcdtl

   ENDIF.  "ekbe

 

 

 

 

*****************changes by vincy on 29.05.2008****************

       LOOP AT it_bkpf INTO wa_bkpf WHERE  tcode = 'FB08' OR tcode = 'FB60'.

 

       READ TABLE it_faglflexa WITH KEY docnr = wa_bkpf-belnr.

       IF sy-subrc = 0.

 

         wa_final-belnr     =    wa_bkpf-belnr.

         wa_final-gjahr     =    wa_bkpf-gjahr.     

  •         wa_final-bukrs     =    wa_bkpf-bukrs.

         wa_final-awkey     =    wa_bkpf-awkey.

         wa_final-ebelp     =    wa1_ekbe-ebelp.

         wa_final-budat     =    wa_bkpf-budat.

         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_final-fi_docno  =    wa_bseg-belnr.

           wa_final-mwskz     =    wa_bseg-mwskz.

 

         CLEAR: wa_bseg,wa_lfa2.

 

       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_final-total_value =  wa_bseg-wrbtr.

           wa_final-lifnr     =    wa_bseg-lifnr.

 

           READ TABLE it_lfa2 INTO wa_lfa2

           WITH KEY lifnr = wa_final-lifnr.

           IF sy-subrc = 0.

             wa_final-name1  =        wa_lfa2-name1.

             wa_final-ktokk  =        wa_lfa2-ktokk.

           ENDIF.

  •           wa_final-gl_accnt  =    wa_bseg-hkont.

 

  •          READ TABLE iskat INTO wa_skat WITH KEY saknr = wa_bseg-hkont.

  •           IF sy-subrc = 0.

  •             wa_final-gl_desc = wa_skat-txt50.

  •           ENDIF.

 

         ENDIF.

         CLEAR: wa_bseg ,wa_lfa2.

 

       READ TABLE it_bseg WITH KEY bukrs = wa_bkpf-bukrs

                                    belnr = wa_bkpf-belnr

                                    gjahr = wa_bkpf-gjahr

                                    hkont = '0002868001' INTO     wa_bseg.       "vat

 

         IF sy-subrc = 0.

             wa_final-vat_amt     =  wa_bseg-pswbt.

             wa_final-gl_accnt  =    wa_bseg-hkont.

         CLEAR: wa_bseg.

 

        READ TABLE iskat INTO wa_skat WITH KEY saknr = wa_bseg-hkont.

           IF sy-subrc = 0.

             wa_final-gl_desc = wa_skat-txt50.

           ENDIF.

        ENDIF.

 

        READ TABLE it_bseg WITH KEY bukrs = wa_bkpf-bukrs

                                    belnr = wa_bkpf-belnr

                                    gjahr = wa_bkpf-gjahr

                                    hkont = '0002823701' INTO     wa_bseg.           "service tax

 

         IF sy-subrc = 0.

             wa_final-service_tax       =  wa_bseg-pswbt.

             wa_final-gl_accnt          =  wa_bseg-hkont.

         CLEAR: wa_bseg.

 

        READ TABLE iskat INTO wa_skat WITH KEY saknr = wa_bseg-hkont.

           IF sy-subrc = 0.

             wa_final-gl_desc = wa_skat-txt50.

           ENDIF.

        ENDIF.

 

 

 

 

       READ TABLE it_bseg WITH KEY bukrs = wa_bkpf-bukrs

                                    belnr = wa_bkpf-belnr

                                    gjahr = wa_bkpf-gjahr

                                    hkont = '0002823801' INTO  wa_bseg.

 

 

 

      IF sy-subrc = 0.

             wa_final-service_ecess     =  wa_bseg-pswbt.

             wa_final-gl_accnt          =  wa_bseg-hkont.

         CLEAR: wa_bseg.

 

        READ TABLE iskat INTO wa_skat WITH KEY saknr = wa_bseg-hkont.

           IF sy-subrc = 0.

             wa_final-gl_desc = wa_skat-txt50.

           ENDIF.

        ENDIF.

 

 

       READ TABLE it_bseg WITH KEY bukrs = wa_bkpf-bukrs

                                    belnr = wa_bkpf-belnr

                                    gjahr = wa_bkpf-gjahr

                                    hkont = '0002823803' INTO  wa_bseg.           "secedu

 

 

       IF sy-subrc = 0.

             wa_final-service_shcess     =  wa_bseg-pswbt.

             wa_final-gl_accnt           =  wa_bseg-hkont.

         CLEAR: wa_bseg.

 

        READ TABLE iskat INTO wa_skat WITH KEY saknr = wa_bseg-hkont.

           IF sy-subrc = 0.

             wa_final-gl_desc = wa_skat-txt50.

           ENDIF.

        ENDIF.

 

 

 

 

 

  •       APPEND wa_tax TO it_tax.

  •       MOVE-CORRESPONDING wa_tax TO wa_final.

       APPEND wa_final TO it_final.

       ENDIF.

       ENDIF.

         CLEAR :wa_tax,wa_bseg,wa_bkpf,wa_final,it_faglflexa.

       ENDLOOP.

************************************************************************

 

 

   LOOP AT it_final INTO wa_final.

     idx = sy-tabix.

     CLEAR: wa_bseg.

     READ TABLE it_bseg INTO wa_bseg WITH KEY belnr = wa_final-fi_docno qsskz = 'WI'.

     IF sy-subrc = 0.

       wa_final-wctglacc = wa_bseg-hkont.

       wa_final-wctamt = wa_bseg-dmbtr.

       wa_final-taxcode = wa_bseg-qsskz.

 

       SELECT land1 witht wt_withcd qscod qsatz FROM t059z

                           INTO CORRESPONDING FIELDS OF TABLE zt059z

                           WHERE land1 = 'IN'

                           AND wt_withcd = wa_bseg-qsskz.

 

       IF sy-subrc = 0.

         READ TABLE zt059z WITH KEY wt_withcd = wa_bseg-qsskz.

         wa_final-taxperc = zt059z-qsatz.

         MODIFY it_final INDEX idx FROM wa_final .

         CLEAR: wa_final,zt059z,idx.

       ENDIF.

     ENDIF.

 

     READ TABLE it_bseg INTO wa_bseg WITH KEY belnr = wa_final-fi_docno qsskz = 'WJ'.

     IF sy-subrc = 0.

       wa_final-wctglacc = wa_bseg-hkont.

       wa_final-wctamt = wa_bseg-dmbtr.

       wa_final-taxcode = wa_bseg-qsskz.

 

       SELECT land1 witht wt_withcd qscod qsatz FROM t059z

                           INTO CORRESPONDING FIELDS OF TABLE zt059z

                           WHERE land1 = 'IN'

                           AND wt_withcd = wa_bseg-qsskz.

 

       IF sy-subrc = 0.

         READ TABLE zt059z WITH KEY wt_withcd = wa_bseg-qsskz.

         wa_final-taxperc = zt059z-qsatz.

         MODIFY it_final INDEX idx FROM wa_final .

         CLEAR: wa_final,zt059z,idx.

       ENDIF.

     ENDIF.

     CLEAR: wa_final,zt059z,idx.

 

   ENDLOOP.

 

SORT it_final BY belnr DESCENDING.

 

 

ENDFORM.                    " get_data

 

&----


*&      Form  build_fieldcatalog

&----


 

FORM build_fieldcatalog .

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'LIFNR'.

   fieldcatalog-seltext_m   = 'Vendor' .

   fieldcatalog-col_pos     = col_pos .

   fieldcatalog-outputlen     = 10.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'NAME1'.

   fieldcatalog-seltext_m   = 'Name Of the Vendor' .

   fieldcatalog-col_pos     =  col_pos.

   fieldcatalog-outputlen     = 35.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'BELNR'.

   fieldcatalog-seltext_m   = 'MIRO No'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen   = 10.

   fieldcatalog-emphasize   = 'X'.

   fieldcatalog-key         = 'X'.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'BUDAT'.

   fieldcatalog-seltext_m   = 'Booking Date'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 10.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'MATNR'.

   fieldcatalog-seltext_m   = 'Material Number'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 18.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'MAKTX'.

   fieldcatalog-seltext_m   = 'Material Description' .

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 40.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'CAPIND'.

   fieldcatalog-seltext_m   = 'Material Type' .

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 12.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'EBELN'.

   fieldcatalog-seltext_m   = 'Pur Order No' .

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 12.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'MWSKZ'.

   fieldcatalog-seltext_m   = 'Tax Code'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen   = 10.

   fieldcatalog-emphasize   = 'X'.

   fieldcatalog-key         = 'X'.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

IF PLANT NE 'RD01'.                 "ADDED ON 13.03.2008

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'FI_DOCNO'.

   fieldcatalog-seltext_m   = 'FI Document No'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen   = 10.

   fieldcatalog-emphasize   = 'X'.

   fieldcatalog-key         = 'X'.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'EXNUM'.

   fieldcatalog-seltext_m   = 'Vendor Excise No'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 10.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'EXDAT'.

   fieldcatalog-seltext_m   = 'Excise Document Date'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 10.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'KTOKK'.

   fieldcatalog-seltext_m   = 'Vendor Type'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 4.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'TOTAL_VALUE'.

   fieldcatalog-seltext_m   = 'Basic Purchase Price'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 13.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

ENDIF.             "ENDED ON 13.03.2008

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'EXBAS'.

   fieldcatalog-seltext_m   = 'Excise Base '.

   fieldcatalog-col_pos     = col_pos .

   fieldcatalog-outputlen     = 13.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'EXBED'.

  • fieldcatalog-seltext_m   = 'Excise/Ser Amt'.           "comment by vincy on 31.01.08

   fieldcatalog-seltext_m   = 'BED Amt' .                  "vincy on 31.01.08

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 13.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'ECS'.

   fieldcatalog-seltext_m   = 'Ecess Amt'.

   fieldcatalog-col_pos     = col_pos .

   fieldcatalog-outputlen     = 13.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'SHCESS_AMT'.

   fieldcatalog-seltext_m   = 'SHCESS(Amt)' .

   fieldcatalog-col_pos     =  col_pos.

   fieldcatalog-outputlen     = 13.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'EXCISE'.

   fieldcatalog-seltext_m   = 'Total Taxable Amount'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 13.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

  •   col_pos = col_pos + 1 .

  •   fieldcatalog-fieldname   = 'FWBAS'.

  •   fieldcatalog-seltext_m   = 'Taxable Amount'.

  •   fieldcatalog-col_pos     = col_pos.

  •   fieldcatalog-outputlen     = 13.

  •   APPEND fieldcatalog TO fieldcatalog.

  •   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'VAT_PER'.

   fieldcatalog-seltext_m   = 'VAT PERC' .

   fieldcatalog-col_pos     =  col_pos.

   fieldcatalog-outputlen     = 11.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'VAT_AMT'.

   fieldcatalog-seltext_m   = 'VAT(Amt)' .

   fieldcatalog-col_pos     =  col_pos.

   fieldcatalog-outputlen     = 13.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'CST_PER'.

   fieldcatalog-seltext_m   = 'CST PERC' .

   fieldcatalog-col_pos     =  col_pos.

   fieldcatalog-outputlen     = 11.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'CST_AMT'.

   fieldcatalog-seltext_m   = 'CST(Amt)' .

   fieldcatalog-col_pos     =  col_pos.

   fieldcatalog-outputlen     = 13.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

  •   col_pos = col_pos + 1 .                                       "comment by vincy on 31.01.08

  •   fieldcatalog-fieldname   = 'EXCISE_TAX'.

  •   fieldcatalog-seltext_m   = 'Total Service Tax'.

  •   fieldcatalog-col_pos     = col_pos.

  •   fieldcatalog-outputlen     = 13.

  •   APPEND fieldcatalog TO fieldcatalog.

  •   CLEAR  fieldcatalog.

 

IF PLANT NE 'RD01'.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'GL_ACCNT'.

   fieldcatalog-seltext_m   = 'G/L Account'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 10.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'GL_DESC'.

   fieldcatalog-seltext_m   = 'G/L Description'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 50.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'WCTGLACC'.

   fieldcatalog-seltext_m   = 'WCT G/L Account'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 10.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'WCTAMT'.

   fieldcatalog-seltext_m   = 'WCT Amount'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 13.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'TAXCODE'.

   fieldcatalog-seltext_m   = 'WCT Tax Code'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 10.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'TAXPERC'.

   fieldcatalog-seltext_m   = 'WCT Tax Percentage'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 10.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'MENGE'.

   fieldcatalog-seltext_m   = 'Invoiced Quantity'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 13.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'RATE'.

   fieldcatalog-seltext_m   = 'Rate Per Unit'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 13.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'TOTAL_VALUE1'.

   fieldcatalog-seltext_m   = 'Total Invoice + Total Excise'.

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 20.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'SET_OFF'.

   fieldcatalog-seltext_m   = 'Set off Tax Amount' .

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 13.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'COND_TYPE'.

   fieldcatalog-seltext_m   = 'Condition Type' .

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 4.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'INVENTORISED'.

   fieldcatalog-seltext_m   = 'Inventoried Tax Amount' .

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 15.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'COND_TYPE2'.

   fieldcatalog-seltext_m   = 'Condition Type' .

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 4.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'DESCRIPTION'.

   fieldcatalog-seltext_m   = 'Description' .

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 20.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

ENDIF.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'SERVICE_TAX'.

   fieldcatalog-seltext_m   = 'Service Tax' .

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 13.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'SERVICE_ECESS'.

   fieldcatalog-seltext_m   = 'Service Ecess' .

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 13.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

   col_pos = col_pos + 1 .

   fieldcatalog-fieldname   = 'SERVICE_SHCESS'.

   fieldcatalog-seltext_m   = 'Service Shcess' .

   fieldcatalog-col_pos     = col_pos.

   fieldcatalog-outputlen     = 13.

   APPEND fieldcatalog TO fieldcatalog.

   CLEAR  fieldcatalog.

 

 

ENDFORM.                    " build_fieldcatalog

 

&----


*&      Form  build_layout

&----


 

FORM build_layout .

   gd_layout-no_input          = 'X'.

   gd_layout-colwidth_optimize = 'X'.

   gd_layout-totals_text       = 'Totals'(201).

ENDFORM.                    " build_layout

 

&----


*&      Form  display_alv_report

&----


FORM display_alv_report .

   gd_repid = sy-repid.

 

   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

     EXPORTING

       i_callback_program     = gd_repid

       i_callback_top_of_page = 'TOP-OF-PAGE'  "see FORM

       is_layout              = gd_layout

       it_fieldcat            = fieldcatalog[]

       it_sort                = it_sortcat

       i_save                 = 'X'

     TABLES

       t_outtab               = it_final

     EXCEPTIONS

       program_error          = 1

       OTHERS                 = 2.

   IF sy-subrc <> 0.

     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

   ENDIF.

ENDFORM.                    " display_alv_report

 

----


  • Form  TOP-OF-PAGE                                                 *

----


  • ALV Report Header                                                 *

----


FORM top-of-page.

*ALV Header declarations

   DATA: t_header TYPE slis_t_listheader,

         wa_header TYPE slis_listheader,

         t_line LIKE wa_header-info,

         ld_lines TYPE i,

         ld_linesc(10) TYPE c.

 

  • Title

   wa_header-typ  = 'H'.

   wa_header-info = 'Purchase Tax Register'.

   APPEND wa_header TO t_header.

   CLEAR wa_header.

 

  • Date

   wa_header-typ  = 'S'.

   wa_header-key = 'Date: '.

   CONCATENATE  sy-datum+6(2) '.'

                sy-datum+4(2) '.'

                sy-datum(4) INTO wa_header-info.   "todays date

   APPEND wa_header TO t_header.

   CLEAR: wa_header.

 

  • Total No. of Records Selected

   DESCRIBE TABLE it_final LINES ld_lines.

   ld_linesc = ld_lines.

   CONCATENATE 'Total No. of Records Selected: ' ld_linesc

                     INTO t_line SEPARATED BY space.

   wa_header-typ  = 'A'.

   wa_header-info = t_line.

   APPEND wa_header TO t_header.

   CLEAR: wa_header, t_line.

 

   CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

     EXPORTING

       it_list_commentary = t_header.

  •            i_logo             = 'Z_LOGO'.

ENDFORM.                    "top-of-page

&----


*&      Form  get_zpsr

&----


  •       text

----


  • -->  p1        text

  • <--  p2        text

----


FORM get_zpsr .

   DATA: vat_per TYPE konv-kbetr,

         cst_per TYPE konv-kbetr,

         basb  TYPE konv-kwert,

         zasb  TYPE konv-kwert.

 

IF PLANT NE 'RD01'.

 

   IF it_ekbe[] IS NOT INITIAL.

   SELECT ebeln bukrs bsart lifnr FROM ekko

   INTO CORRESPONDING FIELDS OF TABLE it_ekko

   FOR ALL ENTRIES IN it_ekbe

   WHERE ebeln = it_ekbe-ebeln AND

                 lifnr IN s_lifnr AND

                 bsart = 'ZPSR' .

   ENDIF.

 

   IF it_ekko[] IS NOT INITIAL.

 

   LOOP AT it_ekko.

   READ TABLE it_ekbe WITH KEY ebeln = it_ekko-ebeln.

   IF sy-subrc = 0.

   it_ekko-belnr = it_ekbe-belnr.

   MODIFY it_ekko.

   ENDIF.

   ENDLOOP.

 

   SELECT ebeln ebelp txz01 FROM ekpo INTO TABLE it_ekpo

   FOR ALL ENTRIES IN it_ekko

   WHERE ebeln = it_ekko-ebeln .

 

 

 

   SELECT lifnr name1  FROM lfa1 INTO TABLE it_lfa1v

   FOR ALL ENTRIES IN it_ekko

   WHERE  lifnr = it_ekko-lifnr .

 

 

   SELECT bukrs belnr gjahr buzei bschl fwbas pswbt hkont wrbtr  ktosl koart shkzg mwskz qsskz dmbtr lifnr matnr

   FROM bseg INTO TABLE it_bsegv

   FOR ALL ENTRIES IN it_ekko

   WHERE bukrs = 'MU51'    AND

         gjahr IN s_fiscal AND

         valut IN s_budat1 AND

         belnr = it_ekko-belnr.

   ENDIF.

 

REFRESH IT_KONV1.

CLEAR IT_KONV1.

 

   LOOP AT it_ekko   .

 

     CALL FUNCTION 'ZMMFUN001'

       EXPORTING

         i_ebeln                        = it_ekko-ebeln

       TABLES

         t_konv                         = it_konv1[]

  •   EXCEPTIONS

  •     PURCHASE_ORDER_NOT_FOUND       = 1

  •     VENDOR_NOT_FOUND               = 2

  •     TAX_NOT_FOUND                  = 3

  •     NO_PERCENTAGE_RATE             = 4

  •     TAX_CODE_NOT_VALID             = 5

  •     OTHER                          = 6

  •     OTHERS                         = 7

               .

     IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  •         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

 

     ENDIF.

 

     LOOP AT it_konv1.

 

 

       CASE it_konv1-kschl.

         WHEN 'BASB'.

           MOVE it_konv1-kwert TO it_final1-total_value.

           MOVE it_konv1-kwert TO basb.

 

         WHEN 'ZASB'  .

           MOVE it_konv1-kwert TO it_final1-exbas.

           MOVE it_konv1-kwert TO zasb.

 

         WHEN 'ZJVD' OR 'YJVD' .

           MOVE it_konv1-kwert TO it_final1-vat_amt.

 

         WHEN 'JSRT' OR 'ZSRT' OR 'YSRT'.

           MOVE it_konv1-kwert TO it_final1-exbed.

 

         WHEN 'JEC3' OR 'ZEC3' OR 'YEC3'.

           MOVE it_konv1-kwert TO it_final1-ecs.

 

         WHEN 'JES3' OR 'ZES3' OR 'YES3'.

           MOVE it_konv1-kwert TO it_final1-shcess_amt.

 

         WHEN 'JVRD' OR 'ZVRD' OR 'YVRD'.

           vat_per = it_konv1-kbetr + vat_per .

.

       ENDCASE.

 

     ENDLOOP.

 

     IF zasb IS INITIAL.

       MOVE it_final1-total_value TO it_final1-exbas.

     ENDIF.

     IF basb IS INITIAL.

       MOVE it_final1-exbas TO it_final1-total_value.

     ENDIF.

 

     it_final1-vat_per       = vat_per * '0.1'.

     it_final1-excise = it_final1-exbas + it_final1-exbed + it_final1-ecs + it_final1-shcess_amt.

     it_final1-excise_tax = it_final1-vat_amt +  it_final1-cst_amt.

     it_final1-total_value1 = it_final1-excise +  it_final1-excise_tax.

 

     READ TABLE it_lfa1v WITH KEY lifnr = it_ekko-lifnr.

     IF sy-subrc = 0.

       MOVE it_lfa1v-name1 TO it_final1-name1.

     ENDIF.

 

     READ TABLE it_ekbe WITH KEY ebeln = it_ekko-ebeln.

     IF sy-subrc = 0.

       MOVE it_ekbe-belnr TO it_final1-belnr.

       MOVE it_ekbe-budat TO it_final1-budat.

       MOVE it_ekbe-budat TO it_final1-exdat.

       MOVE it_ekbe-gjahr TO it_final1-gjahr.

 

  • START OF MODIFICATION ON 08.03.2008 BY ASHOK.CH FOR SERVICE TAX FOR RUDRAPUR

IF PLANT = 'RD01'.

     it_final1-service_tax = it_ekbe-REEWR * '0.12'.

     it_final1-service_ecess = it_final1-service_tax * '.02'.

     it_final1-service_shcess = it_final1-service_tax * '.01'.

 

 

ENDIF.

*END OF MODIFICTION ON 08.03.2008

 

     ENDIF.

 

     CONCATENATE it_final1-belnr it_final1-gjahr INTO awkey1.

     READ TABLE it_bkpf WITH KEY awkey = awkey1.

     IF sy-subrc = 0.

       MOVE it_bkpf-belnr TO it_final1-fi_docno.

     ENDIF.

 

 

     READ TABLE it_bsegv WITH KEY belnr = it_bkpf-belnr.

     IF sy-subrc = 0.

       MOVE it_bsegv-mwskz TO it_final1-mwskz.

     ENDIF.

 

     READ TABLE it_ekpo WITH KEY ebeln = it_ekko-ebeln.

     IF sy-subrc = 0.

       MOVE it_ekpo-txz01 TO it_final1-maktx.

     ENDIF.

 

     MOVE it_ekko-lifnr TO it_final1-lifnr.

     MOVE it_ekko-ebeln TO it_final1-ebeln.

     MOVE it_ekko-bsart TO it_final1-ktokk.

  • START OF MODIFICATION ON 08.03.2008 BY ASHOK.CH

 

IF PLANT NE 'RD01'.

 

  •         service_tax

         CLEAR wa_bseg.

 

         READ TABLE it_bseg WITH KEY bukrs = it_bkpf-bukrs

                                     belnr = it_bkpf-belnr

                                     gjahr = it_bkpf-gjahr

                                     ktosl = 'VS8' INTO wa_bseg .

 

         IF sy-subrc = 0.

         MOVE wa_bseg-wrbtr TO it_final1-service_tax.

         ENDIF.

 

  •         service_ecess

         CLEAR wa_bseg.

 

         READ TABLE it_bseg WITH KEY bukrs = it_bkpf-bukrs

                                     belnr = it_bkpf-belnr

                                     gjahr = it_bkpf-gjahr

                                     ktosl = 'VS9' INTO wa_bseg .

         IF sy-subrc = 0.

         MOVE wa_bseg-wrbtr TO it_final1-service_ecess.

         ENDIF.

 

  •         service_ecess

         CLEAR wa_bseg.

 

         READ TABLE it_bseg WITH KEY bukrs = it_bkpf-bukrs

                                     belnr = it_bkpf-belnr

                                     gjahr = it_bkpf-gjahr

                                     ktosl = 'VSE' INTO wa_bseg .

         IF sy-subrc = 0.

         MOVE wa_bseg-wrbtr TO it_final1-service_shcess.

         ENDIF.

ENDIF.

  • END OF MODIFICATION ON 08.03.2008

 

     IF  it_konv1[] IS NOT INITIAL.

       APPEND it_final1.

     ENDIF.

     REFRESH it_konv1.

     CLEAR:it_konv1, it_final1.

     CLEAR: vat_per, basb,zasb.

 

   ENDLOOP.

   APPEND LINES OF it_final1 TO  it_final.

 

ENDIF.

 

IF PLANT EQ 'RD01'.

 

   IF it_ekbe[] IS NOT INITIAL.

   SELECT ebeln bukrs bsart lifnr FROM ekko INTO TABLE it_ekko

   FOR ALL ENTRIES IN it_ekbe

   WHERE ebeln = it_ekbe-ebeln AND

                 lifnr IN s_lifnr AND

                 ( bsart = 'ZPSR' OR BSART = 'ZPSC' ).

   ENDIF.

 

   IF it_ekko[] IS NOT INITIAL.

 

   LOOP AT it_ekko.

   READ TABLE it_ekbe WITH KEY ebeln = it_ekko-ebeln.

   IF sy-subrc = 0.

   it_ekko-belnr = it_ekbe-belnr.

   MODIFY it_ekko.

   ENDIF.

   ENDLOOP.

 

   IF it_ekBE[] IS NOT INITIAL.

   SELECT ebeln ebelp txz01 FROM ekpo INTO TABLE it_ekpo

   FOR ALL ENTRIES IN it_ekBE

   WHERE ebeln = it_ekBE-ebeln .

   ENDIF.

 

 

   SELECT lifnr name1  FROM lfa1 INTO TABLE it_lfa1v

   FOR ALL ENTRIES IN it_ekko

   WHERE  lifnr = it_ekko-lifnr .

 

 

   SELECT bukrs belnr gjahr buzei bschl fwbas pswbt hkont wrbtr  ktosl koart shkzg mwskz qsskz dmbtr lifnr matnr

   FROM bseg INTO TABLE it_bsegv

   FOR ALL ENTRIES IN it_ekko

   WHERE bukrs = 'MU51'    AND

         gjahr IN s_fiscal AND

         valut IN s_budat1 AND

         belnr = it_ekko-belnr.

   ENDIF.

 

   LOOP AT it_ekKO   .

     LOOP AT IT_EKBE WHERE EBELN = IT_EKKO-EBELN.

 

REFRESH IT_KONV1.

CLEAR IT_KONV1.

 

     CALL FUNCTION 'ZMMFUN001'

       EXPORTING

         i_ebeln                        = it_ekBE-ebeln

       TABLES

         t_konv                         = it_konv1[]

  •   EXCEPTIONS

  •     PURCHASE_ORDER_NOT_FOUND       = 1

  •     VENDOR_NOT_FOUND               = 2

  •     TAX_NOT_FOUND                  = 3

  •     NO_PERCENTAGE_RATE             = 4

  •     TAX_CODE_NOT_VALID             = 5

  •     OTHER                          = 6

  •     OTHERS                         = 7

               .

     IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  •         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

 

     ENDIF.

 

     LOOP AT it_konv1.

 

 

       CASE it_konv1-kschl.

         WHEN 'BASB'.

           MOVE it_konv1-kwert TO it_final1-total_value.

           MOVE it_konv1-kwert TO basb.

 

         WHEN 'ZASB'  .

           MOVE it_konv1-kwert TO it_final1-exbas.

           MOVE it_konv1-kwert TO zasb.

 

         WHEN 'ZJVD' OR 'YJVD' .

           MOVE it_konv1-kwert TO it_final1-vat_amt.

 

         WHEN 'JSRT' OR 'ZSRT' OR 'YSRT'.

           MOVE it_konv1-kwert TO it_final1-exbed.

 

         WHEN 'JEC3' OR 'ZEC3' OR 'YEC3'.

           MOVE it_konv1-kwert TO it_final1-ecs.

 

         WHEN 'JES3' OR 'ZES3' OR 'YES3'.

           MOVE it_konv1-kwert TO it_final1-shcess_amt.

 

         WHEN 'JVRD' OR 'ZVRD' OR 'YVRD'.

           vat_per = it_konv1-kbetr + vat_per .

.

       ENDCASE.

 

     ENDLOOP.

 

  •     IF zasb IS INITIAL.

       MOVE it_EKBE-REEWR TO it_final1-exbas.

  •     ENDIF.

  •     IF basb IS INITIAL.

       MOVE it_EKBE-REEWR TO it_final1-total_value.

  •     ENDIF.

 

     it_final1-vat_per       = vat_per * '0.1'.

     it_final1-excise = it_final1-exbas + it_final1-exbed + it_final1-ecs + it_final1-shcess_amt.

     it_final1-excise_tax = it_final1-vat_amt +  it_final1-cst_amt.

     it_final1-total_value1 = it_final1-excise +  it_final1-excise_tax.

 

     READ TABLE it_lfa1v WITH KEY lifnr = it_ekko-lifnr.

     IF sy-subrc = 0.

       MOVE it_lfa1v-name1 TO it_final1-name1.

     ENDIF.

 

  •     READ TABLE it_ekbe WITH KEY ebeln = it_ekBE-ebeln.

  •     IF sy-subrc = 0.

       MOVE it_ekbe-belnr TO it_final1-belnr.

       MOVE it_ekbe-budat TO it_final1-budat.

       MOVE it_ekbe-budat TO it_final1-exdat.

       MOVE it_ekbe-gjahr TO it_final1-gjahr.

 

  • START OF MODIFICATION ON 08.03.2008 BY ASHOK.CH FOR SERVICE TAX FOR RUDRAPUR

IF PLANT = 'RD01'.

     it_final1-service_tax = it_ekbe-REEWR * '0.12'.

     it_final1-service_ecess = it_final1-service_tax * '.02'.

     it_final1-service_shcess = it_final1-service_tax * '.01'.

 

 

ENDIF.

*END OF MODIFICTION ON 08.03.2008

 

  •     ENDIF.

 

     CONCATENATE it_final1-belnr it_final1-gjahr INTO awkey1.

     READ TABLE it_bkpf WITH KEY awkey = awkey1.

     IF sy-subrc = 0.

       MOVE it_bkpf-belnr TO it_final1-fi_docno.

     ENDIF.

 

 

     READ TABLE it_bsegv WITH KEY belnr = it_bkpf-belnr.

     IF sy-subrc = 0.

       MOVE it_bsegv-mwskz TO it_final1-mwskz.

     ENDIF.

 

     READ TABLE it_ekpo WITH KEY ebeln = it_ekko-ebeln.

     IF sy-subrc = 0.

       MOVE it_ekpo-txz01 TO it_final1-maktx.

     ENDIF.

 

 

 

     MOVE it_ekko-lifnr TO it_final1-lifnr.

     MOVE it_ekko-ebeln TO it_final1-ebeln.

     MOVE it_ekko-bsart TO it_final1-ktokk.

  • START OF MODIFICATION ON 08.03.2008 BY ASHOK.CH

 

IF PLANT NE 'RD01'.

 

  •         service_tax

         CLEAR wa_bseg.

 

         READ TABLE it_bseg WITH KEY bukrs = it_bkpf-bukrs

                                     belnr = it_bkpf-belnr

                                     gjahr = it_bkpf-gjahr

                                     ktosl = 'VS8' INTO wa_bseg .

 

         IF sy-subrc = 0.

         MOVE wa_bseg-wrbtr TO it_final1-service_tax.

         ENDIF.

 

  •         service_ecess

         CLEAR wa_bseg.

 

         READ TABLE it_bseg WITH KEY bukrs = it_bkpf-bukrs

                                     belnr = it_bkpf-belnr

                                     gjahr = it_bkpf-gjahr

                                     ktosl = 'VS9' INTO wa_bseg .

         IF sy-subrc = 0.

         MOVE wa_bseg-wrbtr TO it_final1-service_ecess.

         ENDIF.

 

  •         service_ecess

         CLEAR wa_bseg.

 

         READ TABLE it_bseg WITH KEY bukrs = it_bkpf-bukrs

                                     belnr = it_bkpf-belnr

                                     gjahr = it_bkpf-gjahr

                                     ktosl = 'VSE' INTO wa_bseg .

         IF sy-subrc = 0.

         MOVE wa_bseg-wrbtr TO it_final1-service_shcess.

         ENDIF.

ENDIF.

  • END OF MODIFICATION ON 08.03.2008

 

     IF  it_konv1[] IS NOT INITIAL.

       APPEND it_final1.

     ENDIF.

     REFRESH it_konv1.

     CLEAR:it_konv1, it_final1.

     CLEAR: vat_per, basb,zasb.

 

   ENDLOOP.

   ENDLOOP.

   APPEND LINES OF it_final1 TO  it_final.

 

ENDIF.

ENDFORM.                    " get_zpsr

&----


*&      Form  get_data1

&----


  •       text

----


  • -->  p1        text

  • <--  p2        text

----


FORM get_data1 .

 

REFRESH IT_EKBE.

CLEAR WA_EKBE.

 

   SELECT belnr budat menge  ebelp ebeln gjahr lfbnr lfpos bldat matnr REEWR MWSKZ FROM ekbe

   INTO CORRESPONDING FIELDS OF TABLE it_ekbe

   WHERE werks IN s_werks1 AND

  •         bewtp EQ 'Q'     AND

         bewtp IN ('Q' , 'N') AND           "added by vincy on 06.07.2008

         budat IN s_budat1 AND

         gjahr IN s_fiscal .

 

 

 

************by vincy on 03.07.2008************

  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.

         wa1_ekbe-reewr        = wa_ekbe-reewr.

         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.

 

       IF it1_ekbe[] IS NOT INITIAL.

       SELECT bukrs belnr gjahr budat tcode awkey FROM bkpf INTO

       TABLE it_bkpf FOR ALL ENTRIES IN it1_ekbe

                      WHERE bukrs = 'MU51'    AND

                      gjahr IN s_fiscal AND

                      awkey = it1_ekbe-awkey.

       ENDIF.

 

       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 it_bseg FOR ALL ENTRIES IN it_bkpf

                       WHERE belnr = it_bkpf-belnr AND

                             gjahr = it_bkpf-gjahr AND

                             bukrs = it_bkpf-bukrs .

       ENDIF.

 

 

     SORT it_bseg BY belnr buzei.

**********end of change*******************

 

   IF sy-subrc = 0.               "for 1st ekbe

 

   LOOP AT IT1_EKBE INTO wa1_ekbe.

       WA_FINAL-BELNR = WA1_EKBE-BELNR.

       WA_FINAL-BUDAT = WA1_EKBE-BUDAT.

       WA_FINAL-MATNR = WA1_EKBE-MATNR.

       WA_FINAL-EBELN = WA1_EKBE-EBELN.

       WA_FINAL-MWSKZ = WA1_EKBE-MWSKZ.

       WA_FINAL-EXBAS = WA1_EKBE-REEWR.

 

************by vincy on 03.07.2008************

READ TABLE it_bkpf INTO wa_bkpf

        WITH KEY awkey = wa1_ekbe-awkey.

 

IF sy-subrc = 0.

READ TABLE it_bseg WITH KEY bukrs = 'MU51'

                                    belnr = wa_bkpf-belnr

                                    gjahr = wa_bkpf-gjahr

                                    flag = ''

                                    ktosl = 'JP5' INTO wa_bseg.

         IF sy-subrc = 0.

           wa_bseg-flag = 'X'.

           MODIFY it_bseg INDEX sy-tabix FROM wa_bseg.

           wa_final-vat_amt   =  wa_bseg-wrbtr.

         ENDIF.

ENDIF.

    CLEAR LIFNR.

     SELECT SINGLE LIFNR INTO LIFNR FROM EKKO WHERE EBELN = WA1_EKBE-EBELN.

 

     IF SY-SUBRC = 0.

      WA_FINAL-LIFNR = LIFNR.

     ENDIF.

 

   CLEAR NAME.

     SELECT SINGLE NAME1 INTO NAME FROM LFA1 WHERE LIFNR = LIFNR.

     IF SY-SUBRC = 0.

       WA_FINAL-NAME1 = NAME.

     ENDIF.

 

  CLEAR MTART.

  CLEAR WA_FINAL-CAPIND.

     SELECT SINGLE MTART INTO MTART FROM MARA WHERE MATNR = WA1_EKBE-MATNR.

      IF SY-SUBRC = 0.

        WA_FINAL-CAPIND = MTART.

      ENDIF.

 

  CLEAR MAKTX.

  CLEAR WA_FINAL-MAKTX.

      SELECT SINGLE MAKTX INTO MAKTX FROM MAKT WHERE MATNR = WA1_EKBE-MATNR.

       IF SY-SUBRC = 0.

         WA_FINAL-MAKTX = MAKTX.

       ENDIF.

 

  •   WA_FINAL-EXBED = WA1_EKBE-REEWR * '0.14'.

  •   WA_FINAL-ECS = WA_FINAL-EXBED * '0.02'.

  •   WA_FINAL-SHCESS_AMT = WA_FINAL-EXBED * '0.01'.

*

  •   TAX_TOT = WA1_EKBE-REEWR + WA_FINAL-EXBED + WA_FINAL-ECS + WA_FINAL-SHCESS_AMT.

*

  •   WA_FINAL-EXCISE = TAX_TOT.

 

   clear: WA_FINAL-VAT_PER,

          WA_FINAL-CST_PER,

          WA_FINAL-CST_AMT,

          WA_FINAL-EXBED,

          WA_FINAL-ECS,

          WA_FINAL-SHCESS_AMT,

          WA_FINAL-EXCISE,

          WA_FINAL-SERVICE_TAX,

          WA_FINAL-SERVICE_ECESS,

          WA_FINAL-SERVICE_SHCESS.

 

   REFRESH IT_KONV1.

   CLEAR IT_KONV1.

 

        CALL FUNCTION 'ZMMFUN001'

       EXPORTING

         i_ebeln                        = WA1_ekBE-ebeln

       TABLES

         t_konv                         = it_konv1[]

  •   EXCEPTIONS

  •     PURCHASE_ORDER_NOT_FOUND       = 1

  •     VENDOR_NOT_FOUND               = 2

  •     TAX_NOT_FOUND                  = 3

  •     NO_PERCENTAGE_RATE             = 4

  •     TAX_CODE_NOT_VALID             = 5

  •     OTHER                          = 6

  •     OTHERS                         = 7

               .

     IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  •         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

 

     ENDIF.

 

     LOOP AT it_konv1.

 

       CASE it_konv1-kschl.

 

       WHEN 'JMIP'.

            WA_FINAL-EXBED = WA1_EKBE-REEWR * IT_KONV1-KBETR * '.001'.

 

       WHEN 'JEC2'.

            WA_FINAL-ECS = WA_FINAL-EXBED * IT_KONV1-KBETR * '.001'.

 

       WHEN 'JSEI'.

            WA_FINAL-SHCESS_AMT = WA_FINAL-EXBED * IT_KONV1-KBETR * '.001'.

 

       WHEN 'ZNRT'.

 

            WA_FINAL-SERVICE_TAX = WA1_EKBE-REEWR * IT_KONV1-KBETR * '.001'.

 

       WHEN 'ZNC3'.

 

            WA_FINAL-SERVICE_ECESS = WA_FINAL-SERVICE_TAX * IT_KONV1-KBETR * '.001'.

 

       WHEN 'ZNS3'.

 

            WA_FINAL-SERVICE_SHCESS = WA_FINAL-SERVICE_TAX * IT_KONV1-KBETR * '.001'.

 

       ENDCASE.

 

    ENDLOOP.

 

   TAX_TOT = WA1_EKBE-REEWR + WA_FINAL-EXBED + WA_FINAL-ECS + WA_FINAL-SHCESS_AMT.

 

  WA_FINAL-EXCISE = TAX_TOT.

 

 

     LOOP AT it_konv1.

 

       CASE it_konv1-kschl.

 

       WHEN 'JVRD' OR 'JVRN' OR 'JVCD' OR 'JVCN'.

            WA_FINAL-VAT_PER = IT_KONV1-KBETR / 10.

  •           WA_FINAL-VAT_AMT = TAX_TOT * IT_KONV1-KBETR * '.001'.        "comment by vincy on 03.07.2008

 

          WHEN 'JVCS'.

            WA_FINAL-CST_PER = IT_KONV1-KBETR / 10.

            WA_FINAL-CST_AMT = TAX_TOT * IT_KONV1-KBETR * '.001'.

 

       ENDCASE.

 

    ENDLOOP.

 

APPEND wa_final TO it_final.

clear: wa1_ekbe, WA_BSEG, wa_final.

 

 

   ENDLOOP.          " FOR IT1_EKBE

   ENDIF.            "FOR 1ST EKBE

 

 

 

 

ENDFORM.                    " get_data1

 

*start change by nahid on 16.4.08

 

FORM excel_data .

 

 

  CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

     filename                        = zfile

     filetype                        = 'DAT'

     WRITE_FIELD_SEPARATOR           = 'X'

    TABLES

      data_tab                        = IT_FINAL.

 

 

ENDFORM.                    "excel_data

*end change by nahid on 16.4.08

Actions