KONP-KBETR - Rate condition percentage - REUSE_ALV_GRID_DISPLAY

Hi Experts,
I have a strange behaviour with function reuse_alv_grid_display.
(It is not used with field catalogue, but we pass the name of the structure)
In the structure we have two fields:
  kbetr_pi02 like konp-kbetr,
  konwa_pi02 like konp-konwa.
We read a rate condition percentage.   ( i.e.  65 % )
If I check the condition table with tcode SE16  ( KONP )
konp = 650
kbetr = %
in quality system values with % are displayed with 2 integer and 2 decimals, ( 65,00 % )
while in production system are displayed with 3 integer and 2 decimals. ( 650,00 % )
How is it possible???
Thanks a lot!

This is my data structure
data: begin of tb_precom occurs 0,
  matnr like marc-matnr,
  werks like marc-werks,
  cuobj like marc-cuobj,
  stdpd like marc-stdpd,
  atnam like conf_out-atnam,
  atbez like conf_out-atbez,
  atwrt like conf_out-atwrt,
  atwtb like conf_out-atwtb,
  kappl like a691-kappl,
  vkorg like a691-vkorg,
  kschl like a691-kschl,
  pltyp like a691-pltyp,
  waerk like a691-waerk,
  kbetr like konp-kbetr,
  konwa like konp-konwa,
  kpein like konp-kpein,
  kmein like konp-kmein,
  kbetr_pi02 like konp-kbetr,
  konwa_pi02 like konp-konwa.
data: end of tb_precom.

Similar Messages

  • FM to change condition rate (konp-kbetr)

    Hi ALL,
    I need to change the condition rate field (KONP-KBETR) . I am using FM SD_CHANGE_COND_REC_NUMBER and MAP2I_BAPICONDIT_TO_KONP
    but unable to get the expected output.
    Kindly advice on the solution.
    Regards,
    Bharat.

    Moved to ABAP Forum.
    Regards,
    RIch Heilman

  • How can I have conditional percentage in MXML?

    I love the fact that you can set a components width or height to a percentage of its parent container.
    <mx:Button height="100%" />
    What I would like to do is have a conditional percentage based on some bindable boolean
    [Bindable] public var switch:Boolean = true;
    <mx:Button height="{switch ? '100%' : '20%'}" />
    Unfortunately I get an error saying that I can't use a string in place of a number.  I also tried this syntax and it still wont work,
    <mx:Button height="{switch ? 100% : 20%}" />
    Any suggestions?  Is this even possible?  Thanks.

    There is a secret piece of metadata called [PercentProxy(
    "percentHeight")]
    that you can use... It redirects percentage values elsewhere.
    Take a look at UIComponent.get height()

  • Value error during type conversion (KONP-KBETR to packed nos).

    Hi,
    I am using TYPE KONP-KBETR whose data element is 'KBETR_KOND'. Its Length is 11 and decimal Places is 2.
    Now I want to store this value in a variable with 3 decimal places.
    For this I have taken a variable with type P.
    Eg : DATA  : VALUE2(7) type P decimals 3.
    When I store the value of KONP-KBETR in var VALUE2, I get some confusing value.
    For Eg: if KONP-KBETR = 300.00 and I pass this value to var VALUE2, then VALUE2 becomes 30.000.
    Ideally VALUE2 should have been 300.000.
    Can anybody tell why this is so and what needs to be done to get the correct value.?
    Thanks.

    Hi Kumar,
    TABLES KONP.
    data: val1 TYPE KONP-KBETR value '300.00',
          VALUE2(7) type P decimals 3.
    value2 = val1.
    write: val1,
           value2.
    the output of the above code, 300.00     300.000.
    i didn't get any problem.. check it out once..
    Ram

  • Rate (condition amount or percentage)

    Hi All,
    We need to change the rate from fixed value to %ge value for 5000 Articles(Materials).
    For individual articles we were doing through the transaction VKP5. How can we do in mass.
    Regards,
    Madhukar

    Hello,
      perhaps I didn't understand well your requirement or the scenario. But can't you run transaction VKP5 for all the 5000 articles  you need to update price for?
    Let me know.
    Best regards,
    Andrea

  • Condition percentage rate

    hi,
    may i know e1edp05-kperc can be mapped to which component in bapicond?
    thanks
    rgds

    Hi
    Based on the The field CALCTYPCON type (H or I  means Percentage) the field
    CONBASEVAL will hold the values.
    see the reference
    KONV table which stores the same type of values
    based on the field KRECH the value KAWRT is maintained
    Regards
    Anji

  • P.O Condition Percentage mainenance

    Hi Gurus,
    Could you please advise where can be the purchase order item condition record value maintained ?
    I got two TAX conditions NAVS & NAVM is to be maintained as 3% & 7& accordingly.
    Thanks in advance
    Rgds
    RG

    But as far as my knowledge goes in standard SAP both the condition types are of Fixed amount i.e. not in percentage,Not possible to process manually and the non-deductible tax amount gets flowed in this condition type automatically (if access sequence is not maintained in the condition type) against the tax code used in invoice tab
    If access sequence is maintained then check /people/jimmy.zhang/blog/2010/02/22/non-deductible-tax-in-procurement
    Regards,
    Indranil

  • Header condition Percentage Value

    Dear Gurus,
    I have created a Header condition, wherein with calculation type as %. Now if i try to enter 5.5% it is not allowing and giving format error. System is accepting only rounded numbers only like 5,6,7 %. But i need as 4.5/ 5.5 . Please through some light.
    Regards
    Praveen

    Hi Praveen,
    this because of system/user settings, go to System>User Profile>Own data>Default tab>change the decimal Notation to X1,234,567,.89.. and after logoff and relogin and maintain in Vk11 it will take like 5.5 percentage..
    Thanks
    Rao

  • Multiple (and quite too much) lines in konp while creating condition record

    Hi,
    i'm trying to create a webdypro application to maintain prices and conditions for materials.
    Therefore I'm using the FM RV_CONDITION_COPY.
    If I create a condition (i.e. with Condtype ZPR0) the FM creates many lines in KONP for every other condition maintained (Z***) in customizing. Any ideas ?
    Is there perhaps another way to create conditions ?
    The FM MUST be working dark !!!
    Big Thanks

    Hi
    U can try to use the BAPI BAPI_PRICES_CONDITIONS
    Max

  • Why This Report Not Working in Production Server But in Development Server

    I just need your help in solving one issue. There is one report which is working fine in development server but it is not getting executed in production server.
    Although the code is same in both the server. Could you please guide me in locating the problem. I am attaching that report with this mail. Please do the needful help.
    TABLES : a363,
             mara,
             marc,
             makt,
             ekko,
             ekpo,
             mkpf,
             mseg,
             konp,
             konh.
    SELECTION-SCREEN
    SELECTION-SCREEN   :   BEGIN OF BLOCK cst WITH FRAME TITLE text-001.
    SELECT-OPTIONS :   s_matnr FOR mara-matnr,                            "Material Number
                       s_lifnr FOR ekko-lifnr,                            "Account Number of the Vendor
                       s_bedat FOR ekko-bedat,                            "Purchasing Document Date
                       s_kschl FOR konh-kschl OBLIGATORY NO INTERVALS,    "Condition type
                       s_bwart FOR mseg-bwart OBLIGATORY NO INTERVALS.    "Movement Type (Inventory Management)
    PARAMETERS     :   p_werks LIKE marc-werks OBLIGATORY.                "Plant
    SELECTION-SCREEN   :   END OF BLOCK cst.
    INCLUDES
    INCLUDE zalv_data.
    DATA - INTERNAL TABLES AND FIELD LISTS
    DATA :  BEGIN    OF     a363_itab  OCCURS 0,
            matnr    LIKE   a363-matnr,                    "Material Number
            lifnr    LIKE   a363-lifnr,                    "Account Number of the Vendor
            werks    LIKE   a363-werks,                    "Plant
            kschl    LIKE   a363-kschl,                    "Condition type
            knumh    LIKE   a363-knumh,                    "Condition record number
            kbetr    LIKE   konp-kbetr,                    "Rate (condition amount or percentage) where no scale exists
            END      OF     a363_itab.
    DATA :  BEGIN    OF     konp_itab  OCCURS 0,
            knumh    LIKE   a363-knumh,                    "Condition record number
            kbetr    LIKE   konp-kbetr,                    "Rate (condition amount or percentage) where no scale exists
            lifnr    LIKE   a363-lifnr,                    "Account Number of the Vendor
            END      OF     konp_itab.
    DATA :  BEGIN    OF     ekko_itab  OCCURS 0,
            ebeln    LIKE   ekko-ebeln,                    "Purchasing Document Number
            lifnr    LIKE   ekko-lifnr,                    "Account Number of the Vendor
            bedat    LIKE   ekko-bedat,                    "Purchasing Document Date
            END      OF     ekko_itab.
    DATA :  BEGIN    OF     ekpo_itab  OCCURS 0,
            ebeln    LIKE   ekpo-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   ekpo-ebelp,                    "Item Number of Purchasing Document
            matnr    LIKE   ekpo-matnr,                    "Material Number
            werks    LIKE   ekpo-werks,                    "Plant
            menge    LIKE   ekpo-menge,                    "Purchase order quantity
            END      OF     ekpo_itab.
    DATA :  BEGIN    OF     v_po_det  OCCURS 0,            "VENDOR + PLANT + PO DEATILS
            lifnr    LIKE   ekko-lifnr,                    "Account Number of the Vendor
            ebeln    LIKE   ekko-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   ekpo-ebelp,                    "Item Number of Purchasing Document
            bedat    LIKE   ekko-bedat,                    "Purchasing Document Date
            matnr    LIKE   ekpo-matnr,                    "Material Number
            werks    LIKE   ekpo-werks,                    "Plant
            menge    LIKE   ekpo-menge,                    "Purchase order quantity
            kbetr    LIKE   konp-kbetr,                    "Rate (condition amount or percentage) where no scale exists
            END      OF     v_po_det.
    DATA :  BEGIN    OF     mseg_itab  OCCURS 0,
            mblnr    LIKE   mseg-mblnr,                    "Number of Material Document
            ebeln    LIKE   mseg-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   mseg-ebelp,                    "Item Number of Purchasing Document
            matnr    LIKE   mseg-matnr,                    "Material Number
            lifnr    LIKE   mseg-lifnr,                    "Account Number of the Vendor
            werks    LIKE   mseg-werks,                    "Plant
            menge    LIKE   mseg-menge,                    "Quantity
            dmbtr    LIKE   mseg-dmbtr,                    "Amount in local currency
            bwart    LIKE   mseg-bwart,                    "Movement Type (Inventory Management)
            END      OF     mseg_itab.
    DATA :  BEGIN    OF     mkpf_itab  OCCURS 0,
            mblnr    LIKE   mkpf-mblnr,                    "Number of Material Document
            bldat    LIKE   mkpf-bldat,                    "Document Date in Document
            END      OF     mkpf_itab.
    DATA :  BEGIN    OF     zeou_pcrdtl_itab  OCCURS 0,
            matnr    LIKE   zeou_pcrdtl-matnr,             "Material Number
            lifnr    LIKE   zeou_pcrdtl-lifnr,             "Account Number of the Vendor
            mblnr    LIKE   zeou_pcrdtl-mblnr,             "Number of Material Document
            whssn    LIKE   zeou_pcrdtl-whssn,             "Warehouse Records Entry Serial No.
            whsdt    LIKE   zeou_pcrdtl-whsdt,             "Warehouse Records Entry date
            END      OF     zeou_pcrdtl_itab.
    DATA :  BEGIN    OF     gr_wh_info  OCCURS 0,          "INFO OF GR & WH BASED ON MVMT TYPE & PO
            mblnr    LIKE   mseg-mblnr,                    "Number of Material Document
            bldat    LIKE   mkpf-bldat,                    "Document Date in Document
            ebeln    LIKE   mseg-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   ekpo-ebelp,                    "Item Number of Purchasing Document
            matnr    LIKE   mseg-matnr,                    "Material Number
            lifnr    LIKE   mseg-lifnr,                    "Account Number of the Vendor
            werks    LIKE   mseg-werks,                    "Plant
            menge    LIKE   mseg-menge,                    "Quantity
            dmbtr    LIKE   mseg-dmbtr,                    "Amount in local currency
            bwart    LIKE   mseg-bwart,                    "Movement Type (Inventory Management)
            whssn    LIKE   zeou_pcrdtl-whssn,             "Warehouse Records Entry Serial No.
            whsdt    LIKE   zeou_pcrdtl-whsdt,             "Warehouse Records Entry date
            END      OF     gr_wh_info.
    DATA :  BEGIN    OF     bseg_itab  OCCURS 0,
            ebeln    LIKE   bseg-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   bseg-ebelp,                    "Item Number of Purchasing Document
            matnr    LIKE   bseg-matnr,                    "Material Number
            lifnr    LIKE   bseg-lifnr,                    "Account Number of the Vendor
            werks    LIKE   bseg-werks,                    "Plant
            buzid    LIKE   bseg-buzid,                    "Identification of the Line Item
            bschl    LIKE   bseg-bschl,                    "Posting Key
            wrbtr    LIKE   bseg-wrbtr,                    "Amount in document currency
            bukrs    LIKE   bseg-bukrs,                    "Company Code
            belnr    LIKE   bseg-belnr,                    "Accounting Document Number
            gjahr    LIKE   bseg-gjahr,                    "Fiscal Year
            END      OF     bseg_itab.
    DATA :  BEGIN    OF     bkpf_itab  OCCURS 0,
            bukrs    LIKE   bkpf-bukrs,                    "Company Code
            belnr    LIKE   bkpf-belnr,                    "Accounting Document Number
            gjahr    LIKE   bkpf-gjahr,                    "Fiscal Year
            xblnr    LIKE   bkpf-xblnr,                    "Reference Document Number
            bldat    LIKE   bkpf-bldat,                    "Document Date in Document
            END      OF     bkpf_itab.
    DATA :  BEGIN    OF     vend_inv  OCCURS 0,            "VENDOR INVOICE DETAILS
            ebeln    LIKE   bseg-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   bseg-ebelp,                    "Item Number of Purchasing Document
            matnr    LIKE   bseg-matnr,                    "Material Number
            lifnr    LIKE   bseg-lifnr,                    "Account Number of the Vendor
            werks    LIKE   bseg-werks,                    "Plant
            buzid    LIKE   bseg-buzid,                    "Identification of the Line Item
            bschl    LIKE   bseg-bschl,                    "Posting Key
            wrbtr    LIKE   bseg-wrbtr,                    "Amount in document currency
            bukrs    LIKE   bseg-bukrs,                    "Company Code
            belnr    LIKE   bseg-belnr,                    "Accounting Document Number
            gjahr    LIKE   bseg-gjahr,                    "Fiscal Year
            xblnr    LIKE   bkpf-xblnr,                    "Reference Document Number
            bldat    LIKE   bkpf-bldat,                    "Document Date in Document
            END      OF     vend_inv.
    DATA :  BEGIN    OF     chckinit  OCCURS 0,            "CHEQUE INIT INFO
            ebeln    LIKE   bseg-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   bseg-ebelp,                    "Item Number of Purchasing Document
            matnr    LIKE   bseg-matnr,                    "Material Number
            lifnr    LIKE   bseg-lifnr,                    "Account Number of the Vendor
            werks    LIKE   bseg-werks,                    "Plant
            buzid    LIKE   bseg-buzid,                    "Identification of the Line Item
            bschl    LIKE   bseg-bschl,                    "Posting Key
            bukrs    LIKE   bkpf-bukrs,                    "Company Code
            belnr    LIKE   bkpf-belnr,                    "Accounting Document Number
            gjahr    LIKE   bkpf-gjahr,                    "Fiscal Year
            koart    LIKE   bseg-koart,                    "Account type
            augbl    LIKE   bseg-augbl,                    "Document Number of the Clearing Document
            END      OF     chckinit.
    DATA :  BEGIN    OF     chckpayer  OCCURS 0,           "CHEQUE BANK DETAILS
            vblnr    LIKE   payr-vblnr,                    "Document Number of the Payment Document
            zbukr    LIKE   payr-zbukr,                    "Paying company code
            gjahr    LIKE   payr-gjahr,                    "Fiscal Year
            chect    LIKE   payr-chect,                    "Check Number
            zaldt    LIKE   payr-zaldt,                    "Probable Payment Date (Cash Discount 1 Due)
            hbkid    LIKE   payr-hbkid,                    "Short key for a house bank
            END      OF     chckpayer.
    DATA :  chckpayer_u LIKE chckpayer OCCURS 0 WITH HEADER LINE.      "UNIQUE CHEQUE DETAILS
    DATA :  BEGIN    OF     chckfinal  OCCURS 0,           "CHEQUE FINAL INFO
            ebeln    LIKE   bseg-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   bseg-ebelp,                    "Item Number of Purchasing Document
            matnr    LIKE   bseg-matnr,                    "Material Number
            lifnr    LIKE   bseg-lifnr,                    "Account Number of the Vendor
            werks    LIKE   bseg-werks,                    "Plant
            buzid    LIKE   bseg-buzid,                    "Identification of the Line Item
            bschl    LIKE   bseg-bschl,                    "Posting Key
            bukrs    LIKE   bkpf-bukrs,                    "Company Code
            belnr    LIKE   bkpf-belnr,                    "Accounting Document Number
            gjahr    LIKE   bkpf-gjahr,                    "Fiscal Year
            koart    LIKE   bseg-koart,                    "Account type
            augbl    LIKE   bseg-augbl,                    "Document Number of the Clearing Document
            vblnr    LIKE   payr-vblnr,                    "Document Number of the Payment Document
            zbukr    LIKE   payr-zbukr,                    "Paying company code
            chect    LIKE   payr-chect,                    "Check Number
            zaldt    LIKE   payr-zaldt,                    "Probable Payment Date (Cash Discount 1 Due)
            hbkid    LIKE   payr-hbkid,                    "Short key for a house bank
            END      OF     chckfinal.
    DATA :  BEGIN    OF     mat_desc OCCURS 0,
            matnr    LIKE   mara-matnr,
            maktx    LIKE   makt-maktx,
            END      OF     mat_desc.
    DATA :  BEGIN      OF     vend_det OCCURS 0,
            lifnr      LIKE   lfa1-lifnr,
            name1      LIKE   lfa1-name1,
            j_1icstno  LIKE   j_1imovend-j_1icstno,
            END        OF     vend_det.
    DATA :  BEGIN    OF     cst_rep  OCCURS 0,             "FINAL CST REPORT
            lifnr    LIKE   a363-lifnr,                    "Account Number of the Vendor
            name1    LIKE   lfa1-name1,                    "Vendor Name
            j_1icstno  LIKE   j_1imovend-j_1icstno,        " Vendor CST No.
            werks    LIKE   a363-werks,                    "Plant
           kschl    LIKE   a363-kschl,                    "Condition type
            ebeln    LIKE   ekko-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   ekpo-ebelp,                    "Item Number of Purchasing Document
            bedat    LIKE   ekko-bedat,                    "Purchasing Document Date
            matnr    LIKE   ekpo-matnr,                    "Material Number
            maktx    LIKE   makt-maktx,                    "Material Description.
            kbetr    LIKE   konp-kbetr,                    "Rate (condition amount or percentage) where no scale exists
            mblnr    LIKE   mseg-mblnr,                    "Number of Material Document
            bldat    LIKE   mkpf-bldat,                    "Document Date in Document
            menge    LIKE   mseg-menge,                    "Quantity
            dmbtr    LIKE   mseg-dmbtr,                    "Amount in local currency
            cst_dmbtr LIKE  mseg-dmbtr,                    "CST Amount in local currency
            bwart    LIKE   mseg-bwart,                    "Movement Type (Inventory Management)
            whssn    LIKE   zeou_pcrdtl-whssn,             "Warehouse Records Entry Serial No.
            whsdt    LIKE   zeou_pcrdtl-whsdt,             "Warehouse Records Entry date
            buzid    LIKE   bseg-buzid,                    "Identification of the Line Item
            bschl    LIKE   bseg-bschl,                    "Posting Key
            wrbtr    LIKE   bseg-wrbtr,                    "Amount in document currency
            cst_wrbtr LIKE  bseg-wrbtr,                    "CST Amount in document currency
            belnr    LIKE   bseg-belnr,                    "Accounting Document Number
            gjahr    LIKE   bseg-gjahr,                    "Fiscal Year
            xblnr    LIKE   bkpf-xblnr,                    "Reference Document Number
            koart    LIKE   bseg-koart,                    "Account type
            augbl    LIKE   bseg-augbl,                    "Document Number of the Clearing Document
            vblnr    LIKE   payr-vblnr,                    "Document Number of the Payment Document
            zbukr    LIKE   payr-zbukr,                    "Paying company code
            chect    LIKE   payr-chect,                    "Check Number
            zaldt    LIKE   payr-zaldt,                    "Probable Payment Date (Cash Discount 1 Due)
            hbkid    LIKE   payr-hbkid,                    "Short key for a house bank
            END      OF     cst_rep.
    DATA :  BEGIN    OF     gt_output  OCCURS 0,              "ALV OUTPUT
            slno     LIKE   sy-tabix,                      "Serial Number
            lifnr    LIKE   a363-lifnr,                    "Account Number of the Vendor
            name1    LIKE   lfa1-name1,                    "Vendor Name
            j_1icstno  LIKE   j_1imovend-j_1icstno,        " Vendor CST No.
            werks    LIKE   a363-werks,                    "Plant
           kschl    LIKE   a363-kschl,                    "Condition type
            ebeln    LIKE   ekko-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   ekpo-ebelp,                    "Item Number of Purchasing Document
            bedat    LIKE   ekko-bedat,                    "Purchasing Document Date
            matnr    LIKE   ekpo-matnr,                    "Material Number
            maktx    LIKE   makt-maktx,                    "Material Description
            mblnr    LIKE   mseg-mblnr,                    "Number of Material Document
            bldat    LIKE   mkpf-bldat,                    "Document Date in Document
            menge    LIKE   mseg-menge,                    "Quantity
            dmbtr    LIKE   mseg-dmbtr,                    "Amount in local currency
            cst_dmbtr LIKE  mseg-dmbtr,                    "CST Amount in local currency
            bwart    LIKE   mseg-bwart,                    "Movement Type (Inventory Management)
            whssn    LIKE   zeou_pcrdtl-whssn,             "Warehouse Records Entry Serial No.
            whsdt    LIKE   zeou_pcrdtl-whsdt,             "Warehouse Records Entry date
            buzid    LIKE   bseg-buzid,                    "Identification of the Line Item
            bschl    LIKE   bseg-bschl,                    "Posting Key
            wrbtr    LIKE   bseg-wrbtr,                    "Amount in document currency
            cst_wrbtr LIKE  bseg-wrbtr,                    "CST Amount in document currency
            belnr    LIKE   bseg-belnr,                    "Accounting Document Number
            gjahr    LIKE   bseg-gjahr,                    "Fiscal Year
            xblnr    LIKE   bkpf-xblnr,                    "Reference Document Number
            koart    LIKE   bseg-koart,                    "Account type
            augbl    LIKE   bseg-augbl,                    "Document Number of the Clearing Document
            vblnr    LIKE   payr-vblnr,                    "Document Number of the Payment Document
            zbukr    LIKE   payr-zbukr,                    "Paying company code
            chect    LIKE   payr-chect,                    "Check Number
            zaldt    LIKE   payr-zaldt,                    "Probable Payment Date (Cash Discount 1 Due)
            hbkid    LIKE   payr-hbkid,                    "Short key for a house bank
            usr_txt1(20) TYPE c,
            usr_txt2(20) TYPE c,
            END      OF     gt_output.
    *Working Variables
    DATA : cst_gr  LIKE  mseg-dmbtr,
           cst_inv LIKE  bseg-wrbtr,
           usr_txt1(20) TYPE c,
           usr_txt2(20) TYPE c.
    START-OF-SELECTION.
    *Retreiving Data from a363 table for the given input
      SELECT  matnr
              lifnr
              werks
              kschl
              knumh
              FROM a363
              INTO TABLE a363_itab
              WHERE matnr IN s_matnr AND lifnr IN s_lifnr AND werks EQ p_werks AND kschl IN s_kschl.
      SELECT  *
              FROM konp
              INTO CORRESPONDING FIELDS OF TABLE konp_itab
              FOR ALL ENTRIES IN a363_itab
              WHERE knumh EQ a363_itab-knumh.
      LOOP AT a363_itab.
        READ TABLE konp_itab WITH KEY knumh = a363_itab-knumh.
        IF sy-subrc EQ 0.
          MOVE : konp_itab-kbetr TO a363_itab-kbetr.
          MODIFY a363_itab.
        ENDIF.
        CLEAR : a363_itab, konp_itab.
      ENDLOOP.
      SELECT *
             FROM makt
             INTO CORRESPONDING FIELDS OF TABLE mat_desc
             FOR ALL ENTRIES IN a363_itab
             WHERE matnr EQ a363_itab-matnr.
      SELECT a~lifnr
             a~name1
             b~j_1icstno
             INTO TABLE vend_det
             FROM lfa1 AS a JOIN j_1imovend AS b
             ON alifnr EQ blifnr
             FOR ALL ENTRIES IN a363_itab
             WHERE a~lifnr EQ a363_itab-lifnr.
    Retreiving Data from EKKO & EKPO table for the given input
    And Populating the V_PO_DETAILS itab
      SELECT  *
              FROM ekko
              INTO CORRESPONDING FIELDS OF TABLE ekko_itab
              FOR ALL ENTRIES IN a363_itab
              WHERE lifnr EQ a363_itab-lifnr AND bedat IN s_bedat.
      SELECT  *
              FROM ekpo
              INTO CORRESPONDING FIELDS OF TABLE ekpo_itab
              FOR ALL ENTRIES IN a363_itab
              WHERE matnr EQ a363_itab-matnr AND werks EQ a363_itab-werks AND mwskz NE 'V0'.
      LOOP AT ekpo_itab.
        MOVE :   ekpo_itab-ebelp TO v_po_det-ebelp,
                 ekpo_itab-matnr TO v_po_det-matnr,
                 ekpo_itab-werks TO v_po_det-werks,
                 ekpo_itab-menge TO v_po_det-menge.
        READ TABLE ekko_itab WITH KEY ebeln = ekpo_itab-ebeln.
        IF sy-subrc EQ 0.
          MOVE  :  ekko_itab-lifnr TO v_po_det-lifnr,
                   ekko_itab-ebeln TO v_po_det-ebeln,
                   ekko_itab-bedat TO v_po_det-bedat.
          APPEND : v_po_det.
        ENDIF.
        CLEAR  : ekko_itab, ekpo_itab, v_po_det.
      ENDLOOP.
      LOOP AT v_po_det.
        READ TABLE a363_itab WITH KEY matnr = v_po_det-matnr lifnr = v_po_det-lifnr werks = v_po_det-werks.
        IF sy-subrc EQ 0.
          MOVE : a363_itab-kbetr TO v_po_det-kbetr.
          MODIFY v_po_det.
        ENDIF.
        CLEAR : a363_itab, v_po_det.
      ENDLOOP.
    Retreiving Data from MKPF & MSEG & ZEOU_PCRDTL table for the given input
    And Populating the GR_WH_info itab
      SELECT  *
              FROM mseg
              INTO CORRESPONDING FIELDS OF TABLE mseg_itab
              FOR ALL ENTRIES IN v_po_det
              WHERE ebeln EQ v_po_det-ebeln AND matnr EQ v_po_det-matnr AND bwart IN s_bwart.
      SELECT  *
              FROM mkpf
              INTO CORRESPONDING FIELDS OF TABLE mkpf_itab
              FOR ALL ENTRIES IN mseg_itab
              WHERE mblnr EQ mseg_itab-mblnr.
      SELECT  *
              FROM zeou_pcrdtl
              INTO CORRESPONDING FIELDS OF TABLE zeou_pcrdtl_itab
              FOR ALL ENTRIES IN mseg_itab
              WHERE mblnr EQ mseg_itab-mblnr AND matnr EQ mseg_itab-matnr.
      LOOP AT mseg_itab.
        MOVE  :  mseg_itab-mblnr TO gr_wh_info-mblnr,
                 mseg_itab-ebeln TO gr_wh_info-ebeln,
                 mseg_itab-ebelp TO gr_wh_info-ebelp,
                 mseg_itab-matnr TO gr_wh_info-matnr,
                 mseg_itab-lifnr TO gr_wh_info-lifnr,
                 mseg_itab-werks TO gr_wh_info-werks,
                 mseg_itab-menge TO gr_wh_info-menge,
                 mseg_itab-dmbtr TO gr_wh_info-dmbtr,
                 mseg_itab-bwart TO gr_wh_info-bwart.
        READ TABLE mkpf_itab WITH KEY mblnr = mseg_itab-mblnr.
        IF sy-subrc EQ 0.
          MOVE  :  mkpf_itab-bldat TO gr_wh_info-bldat.
        ENDIF.
        READ TABLE zeou_pcrdtl_itab WITH KEY mblnr = mseg_itab-mblnr.
        IF sy-subrc EQ 0.
          MOVE  :  zeou_pcrdtl_itab-whssn TO gr_wh_info-whssn,
                   zeou_pcrdtl_itab-whsdt TO gr_wh_info-whsdt.
        ENDIF.
        APPEND : gr_wh_info.
        CLEAR : mseg_itab, mkpf_itab, gr_wh_info.
      ENDLOOP.
    Retreiving Data from BSEG & BKPF table
    And Populating the Vendor Invoice Details
      SELECT  *
              FROM bseg
              INTO CORRESPONDING FIELDS OF TABLE bseg_itab
              FOR ALL ENTRIES IN v_po_det
              WHERE ebeln EQ v_po_det-ebeln AND matnr EQ v_po_det-matnr AND buzid EQ 'W' AND bschl EQ '96'.
      SELECT  *
              FROM bkpf
              INTO CORRESPONDING FIELDS OF TABLE bkpf_itab
              FOR ALL ENTRIES IN bseg_itab
              WHERE bukrs EQ bseg_itab-bukrs AND belnr EQ bseg_itab-belnr AND gjahr EQ bseg_itab-gjahr.
      LOOP AT bseg_itab.
        MOVE  :  bseg_itab-ebeln TO vend_inv-ebeln,
                 bseg_itab-ebelp TO vend_inv-ebelp,
                 bseg_itab-matnr TO vend_inv-matnr,
                 bseg_itab-lifnr TO vend_inv-lifnr,
                 bseg_itab-werks TO vend_inv-werks,
                 bseg_itab-buzid TO vend_inv-buzid,
                 bseg_itab-bschl TO vend_inv-bschl,
                 bseg_itab-wrbtr TO vend_inv-wrbtr,
                 bseg_itab-bukrs TO vend_inv-bukrs,
                 bseg_itab-belnr TO vend_inv-belnr,
                 bseg_itab-gjahr TO vend_inv-gjahr.
        READ TABLE bkpf_itab WITH KEY bukrs = bseg_itab-bukrs belnr = bseg_itab-belnr gjahr = bseg_itab-gjahr.
        IF sy-subrc EQ 0.
          MOVE  :  bkpf_itab-xblnr TO vend_inv-xblnr,
                   bkpf_itab-bldat TO vend_inv-bldat.
          APPEND  :  vend_inv.
        ENDIF.
        CLEAR : vend_inv, bseg_itab, bkpf_itab.
      ENDLOOP.
    Retreiving Data from BSEG & BKPF table
    And Populating the Cheque Info Details
      SELECT  *
              FROM bseg
              INTO CORRESPONDING FIELDS OF TABLE chckinit
              FOR ALL ENTRIES IN v_po_det
              WHERE ebeln EQ v_po_det-ebeln AND matnr EQ v_po_det-matnr AND buzid EQ 'W' AND bschl EQ '86' AND koart EQ 'K'.
      SELECT  *
              FROM payr
              INTO CORRESPONDING FIELDS OF TABLE chckpayer
              FOR ALL ENTRIES IN chckinit
              WHERE vblnr EQ chckinit-augbl.
      SORT chckpayer BY vblnr DESCENDING.
      LOOP AT chckpayer.
        ON CHANGE OF chckpayer-vblnr.
          MOVE   : chckpayer TO chckpayer_u.
          APPEND : chckpayer_u.
          CLEAR  : chckpayer_u, chckpayer.
        ENDON.
      ENDLOOP.
      LOOP AT chckinit.
        MOVE  :  chckinit-ebeln TO chckfinal-ebeln,
                 chckinit-ebelp TO chckfinal-ebelp,
                 chckinit-matnr TO chckfinal-matnr,
                 chckinit-lifnr TO chckfinal-lifnr,
                 chckinit-werks TO chckfinal-werks,
                 chckinit-buzid TO chckfinal-buzid,
                 chckinit-bschl TO chckfinal-bschl,
                 chckinit-bukrs TO chckfinal-bukrs,
                 chckinit-gjahr TO chckfinal-gjahr,
                 chckinit-koart TO chckfinal-koart,
                 chckinit-augbl TO chckfinal-augbl.
        READ TABLE chckpayer_u WITH KEY vblnr = chckinit-augbl gjahr = chckinit-gjahr.
        IF sy-subrc EQ 0.
          MOVE  :  chckpayer_u-vblnr TO chckfinal-vblnr,
                   chckpayer_u-zbukr TO chckfinal-zbukr,
                   chckpayer_u-chect TO chckfinal-chect,
                   chckpayer_u-zaldt TO chckfinal-zaldt,
                   chckpayer_u-hbkid TO chckfinal-hbkid.
          APPEND : chckfinal.
        ENDIF.
        CLEAR : chckfinal, chckpayer_u, chckinit.
      ENDLOOP.
    Populating the final CST TABLE
      LOOP AT v_po_det.
        MOVE  :   v_po_det-lifnr TO cst_rep-lifnr,
                  v_po_det-werks TO cst_rep-werks,
                  v_po_det-ebeln TO cst_rep-ebeln,
                  v_po_det-ebelp TO cst_rep-ebelp,
                  v_po_det-bedat TO cst_rep-bedat,
                  v_po_det-matnr TO cst_rep-matnr,
                  v_po_det-kbetr TO cst_rep-kbetr.
        READ TABLE gr_wh_info WITH KEY ebeln = v_po_det-ebeln ebelp = v_po_det-ebelp."matnr = v_po_det-matnr.
        IF sy-subrc EQ 0.
          MOVE :  gr_wh_info-mblnr TO cst_rep-mblnr,
                  gr_wh_info-bldat TO cst_rep-bldat,
                  gr_wh_info-menge TO cst_rep-menge,
                  gr_wh_info-dmbtr TO cst_rep-dmbtr,
                  gr_wh_info-bwart TO cst_rep-bwart,
                  gr_wh_info-whssn TO cst_rep-whssn,
                  gr_wh_info-whsdt TO cst_rep-whsdt.
        ENDIF.
        READ TABLE vend_inv WITH KEY ebeln = v_po_det-ebeln ebelp = v_po_det-ebelp."matnr = v_po_det-matnr.
        IF sy-subrc EQ 0.
          MOVE : vend_inv-buzid TO cst_rep-buzid,
                 vend_inv-bschl TO cst_rep-bschl,
                 vend_inv-wrbtr TO cst_rep-wrbtr,
                 vend_inv-belnr TO cst_rep-belnr,
                 vend_inv-gjahr TO cst_rep-gjahr,
                 vend_inv-xblnr TO cst_rep-xblnr.
        ENDIF.
        READ TABLE chckfinal WITH KEY ebeln = v_po_det-ebeln ebelp = v_po_det-ebelp."matnr = v_po_det-matnr.
        IF sy-subrc EQ 0.
          MOVE : chckfinal-augbl TO cst_rep-augbl,
                 chckfinal-vblnr TO cst_rep-vblnr,
                 chckfinal-zbukr TO cst_rep-zbukr,
                 chckfinal-chect TO cst_rep-chect,
                 chckfinal-zaldt TO cst_rep-zaldt,
                 chckfinal-hbkid TO cst_rep-hbkid.
        ENDIF.
        READ TABLE mat_desc WITH KEY matnr = v_po_det-matnr.
        IF sy-subrc EQ 0.
          MOVE : mat_desc-maktx TO cst_rep-maktx.
        ENDIF.
        READ TABLE vend_det WITH KEY lifnr = v_po_det-lifnr.
        IF sy-subrc EQ 0.
          MOVE : vend_det-name1 TO cst_rep-name1,
                 vend_det-j_1icstno TO cst_rep-j_1icstno.
        ENDIF.
        APPEND : cst_rep.
        CLEAR  : cst_rep, v_po_det, gr_wh_info, vend_inv, chckfinal.
      ENDLOOP.
    Populating GT_output
      LOOP AT cst_rep.
        cst_gr = cst_rep-dmbtr * ( cst_rep-kbetr / 1000 ).
        cst_inv = cst_rep-wrbtr * ( cst_rep-kbetr / 1000 ).
        MOVE : cst_gr  TO cst_rep-cst_dmbtr,
               cst_inv TO cst_rep-cst_wrbtr.
        MODIFY : cst_rep.
        CLEAR : cst_rep, cst_gr, cst_inv.
      ENDLOOP.
      LOOP AT cst_rep.
        MOVE :  sy-tabix TO gt_output-slno,
                cst_rep-lifnr TO gt_output-lifnr,
                cst_rep-name1 TO gt_output-name1,
                cst_rep-j_1icstno TO gt_output-j_1icstno,
                cst_rep-werks TO gt_output-werks,
                cst_rep-matnr TO gt_output-matnr,
                cst_rep-maktx TO gt_output-maktx,
                cst_rep-ebeln TO gt_output-ebeln,
                cst_rep-ebelp TO gt_output-ebelp,
                cst_rep-bedat TO gt_output-bedat,
                cst_rep-mblnr TO gt_output-mblnr,
                cst_rep-bldat TO gt_output-bldat,
                cst_rep-menge TO gt_output-menge,
                cst_rep-dmbtr TO gt_output-dmbtr,
                cst_rep-cst_dmbtr TO gt_output-cst_dmbtr,
                cst_rep-bwart TO gt_output-bwart,
                cst_rep-whssn TO gt_output-whssn,
                cst_rep-whsdt TO gt_output-whsdt,
                cst_rep-buzid TO gt_output-buzid,
                cst_rep-bschl TO gt_output-bschl,
                cst_rep-wrbtr TO gt_output-wrbtr,
                cst_rep-cst_wrbtr TO gt_output-cst_wrbtr,
                cst_rep-belnr TO gt_output-belnr,
                cst_rep-gjahr TO gt_output-gjahr,
                cst_rep-xblnr TO gt_output-xblnr,
                cst_rep-augbl TO gt_output-augbl,
                cst_rep-vblnr TO gt_output-vblnr,
                cst_rep-zbukr TO gt_output-zbukr,
                cst_rep-chect TO gt_output-chect,
                cst_rep-zaldt TO gt_output-zaldt,
                cst_rep-hbkid TO gt_output-hbkid.
        APPEND gt_output.
        CLEAR : cst_rep, gt_output, sy-tabix.
      ENDLOOP.
    END-OF-SELECTION.
    *-ALV Routine
      PERFORM alv_forms.
    *&      Form  alv_forms
    FORM alv_forms.
      PERFORM alv_routines.
      gx_variant = sy-repid.
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save     = g_save
        CHANGING
          cs_variant = gx_variant
        EXCEPTIONS
          not_found  = 2.
      IF sy-subrc = 0.
        vari = gx_variant-variant.
      ENDIF.
      PERFORM comment_build  USING gt_list_top_of_page[].
      PERFORM fieldcat_init  USING gt_fieldcat[].
      PERFORM layout_build USING gs_layout.
      PERFORM print_build  USING gs_print.
      PERFORM alv_output.
    ENDFORM.                    " alv_forms
    *&      Form  alv_routines
    FORM alv_routines.
      PERFORM eventtab_build USING gt_events[].
      PERFORM e06_t_sort_build  USING gt_sort[].
      PERFORM sp_group_build USING gt_sp_group[].
      g_save = 'A'.
      PERFORM variant_init.
    ENDFORM.                    " alv_routines
    *&      Form  eventtab_build
    FORM eventtab_build USING p_gt_events TYPE slis_t_event.
      DATA: ls_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = p_gt_events.
      READ TABLE p_gt_events WITH KEY name =  slis_ev_top_of_page
                             INTO ls_event.
      IF sy-subrc = 0.
        MOVE slis_ev_top_of_page TO ls_event-form.
        APPEND ls_event TO p_gt_events.
      ENDIF.
      READ TABLE p_gt_events WITH KEY name =  slis_ev_user_command
                             INTO ls_event.
      IF sy-subrc = 0.
        MOVE slis_ev_user_command TO ls_event-form.
        APPEND ls_event TO p_gt_events.
      ENDIF.
      READ TABLE p_gt_events WITH KEY name =  slis_ev_pf_status_set
                             INTO ls_event.
      IF sy-subrc = 0.
        MOVE slis_ev_pf_status_set TO ls_event-form.
        APPEND ls_event TO p_gt_events.
      ENDIF.
      SORT p_gt_events BY name.
      DELETE ADJACENT DUPLICATES FROM  p_gt_events.
      DELETE  p_gt_events WHERE form IS INITIAL.
    ENDFORM.                    " eventtab_build
    *&      Form  sort_build
    FORM e06_t_sort_build USING e06_lt_sort TYPE slis_t_sortinfo_alv.
      DATA: ls_sort TYPE slis_sortinfo_alv.
      CLEAR ls_sort.
      ls_sort-fieldname = 'SLNO'.
      ls_sort-spos      = 1.
      ls_sort-up        = 'X'.
      APPEND ls_sort TO e06_lt_sort.
    CLEAR ls_sort.
    ls_sort-fieldname = 'CNCNR'.
    ls_sort-spos      = 1.
    ls_sort-up        = 'X'.
    APPEND ls_sort TO e06_lt_sort.
    CLEAR ls_sort.
    ls_sort-fieldname = 'MATNR'.
    ls_sort-spos      = 1.
    ls_sort-up        = 'X'.
    APPEND ls_sort TO e06_lt_sort.
    ENDFORM.                    " sort_build
    *&      Form  sp_group_build
    FORM sp_group_build USING    p_gt_sp_group TYPE slis_t_sp_group_alv.
      DATA: ls_sp_group TYPE slis_sp_group_alv.
      CLEAR  ls_sp_group.
      ls_sp_group-sp_group = 'A'.
      ls_sp_group-text     = 'PRODUCT'.
      APPEND ls_sp_group TO p_gt_sp_group.
    ENDFORM.                    " sp_group_build
    *&      Form  variant_init
    FORM variant_init.
      CLEAR g_variant.
      g_repid = sy-repid.
      g_variant-report = g_repid.
    ENDFORM.                    " variant_init
    *&      Form  comment_build
    FORM comment_build USING   e04_lt_top_of_page TYPE slis_t_listheader.
      DATA: ls_line     TYPE slis_listheader.
      DATA: l_date(10)  TYPE c,
            l_time(8)   TYPE c,
            l_out(255)  TYPE c.
      WRITE sy-datum TO l_date.
      WRITE sy-uzeit TO l_time.
      CONCATENATE l_date '/' l_time INTO l_out.
      CLEAR ls_line.
      ls_line-typ  = 'H'.
      CLEAR ls_line.
      ls_line-typ  = 'S'.
      ls_line-key  = 'RUN BY :'.
      ls_line-info = sy-uname.
      APPEND ls_line TO e04_lt_top_of_page.
      CLEAR ls_line.
      ls_line-typ  = 'S'.
      ls_line-key  = 'RUN ON :'.
      ls_line-info = l_out.
      APPEND ls_line TO e04_lt_top_of_page.
    ENDFORM.                    " comment_build
    *&      Form  fieldcat_init
    FORM fieldcat_init    USING e01_lt_fieldcat TYPE slis_t_fieldcat_alv.
      DATA: ls_fieldcat TYPE slis_fieldcat_alv.
      DATA n1(3).
      DATA count(2)    TYPE c.
      DATA h1(10).
      DATA: l_week     LIKE scal-week,
            l_text(17) TYPE c.
      DATA cnt TYPE i.
      cnt = cnt + 1.
      CLEAR ls_fieldcat.
      ls_fieldcat-row_pos      = 1.
      ls_fieldcat-col_pos      = 1.
      ls_fieldcat-fieldname    = 'SLNO'.
      ls_fieldcat-seltext_m    = 'SL.NO'.
      ls_fieldcat-hotspot      = 'X'.
      ls_fieldcat-key          = 'X'.
      ls_fieldcat-key_sel      = 'X'.
      ls_fieldcat-just         = 'R'.
      ls_fieldcat-sp_group = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      cnt = cnt + 1.
      CLEAR ls_fieldcat.
      ls_fieldcat-row_pos      = 1.
      ls_fieldcat-col_pos      = cnt.
      ls_fieldcat-fieldname    = 'LIFNR'.
      ls_fieldcat-seltext_m    = 'VENDOR NO.'.
      ls_fieldcat-hotspot      = 'X'.
      ls_fieldcat-key          = 'X'.
      ls_fieldcat-key_sel      = 'X'.
      ls_fieldcat-just         = 'R'.
      ls_fieldcat-sp_group = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      cnt = cnt + 1.
      CLEAR ls_fieldcat.
      ls_fieldcat-row_pos      = 1.
      ls_fieldcat-col_pos      = cnt.
      ls_fieldcat-fieldname    = 'NAME1'.
      ls_fieldcat-seltext_m    = 'VENDOR NAME'.
      ls_fieldcat-hotspot      = 'X'.
      ls_fieldcat-key          = 'X'.
      ls_fieldcat-key_sel      = 'X'.
      ls_fieldcat-just         = 'L'.
      ls_fieldcat-sp_group = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      cnt = cnt + 1.
      CLEAR ls_fieldcat.
      ls_fieldcat-row_pos      = 1.
      ls_fieldcat-col_pos      = cnt.
      ls_fieldcat-fieldname    = 'J_1ICSTNO'.
      ls_fieldcat-seltext_m    = 'VENDOR CST NO.'.
      ls_fieldcat-hotspot      = 'X'.
      ls_fieldcat-key          = 'X'.
      ls_fieldcat-key_sel      = 'X'.
      ls_fieldcat-just         = 'R'.
      ls_fieldcat-sp_group = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
    cnt = cnt + 1.
    CLEAR ls_fieldcat.
    ls_fieldcat-row_pos      = 1.
    ls_fieldcat-col_pos      = cnt.
    ls_fieldcat-fieldname    = 'WERKS'.
    ls_fieldcat-seltext_m    = 'PLANT'.
    ls_fieldcat-key          = 'X'.
    ls_fieldcat-key_sel      = 'X'.
    ls_fieldcat-just         = 'R'.
    ls_fieldcat-sp_group = 'A'.
    APPEND ls_fieldcat TO e01_lt_fieldcat.
      cnt = cnt + 1.
      CLEAR ls_fieldcat.
      ls_fieldcat-row_pos      = 1.
      ls_fieldcat-col_pos      = cnt.
      ls_fieldcat-fieldname    = 'EBELN'.
      ls_fieldcat-seltext_m    = 'PO NO.'.
      ls_fieldcat-key          = 'X'.
      ls_fieldcat-key_sel      = 'X'.
      ls_fieldcat-just         = 'R'.
      ls_fieldcat-sp_group = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
    cnt = cnt + 1.
    CLEAR ls_fieldcat.
    ls_fieldcat-row_pos      = 1.
    ls_fieldcat-col_pos      = cnt.
    ls_fieldcat-fieldname    = 'EBELP'.
    ls_fieldcat-seltext_m    = 'PO ITEM'.
    ls_fieldcat-key          = 'X'.
    ls_fieldcat-key_sel      = 'X'.
    ls_fieldcat-just         = 'R'.
    ls_fieldcat-sp_group = 'A'.
    APPEND ls_fieldcat TO e01_lt_fieldcat.
      cnt = cnt + 1.
      CLEAR ls_fieldcat.
      ls_fieldcat-row_pos      = 1.
      ls_fieldcat-col_pos      = cnt

    Hi ,  
      This is a sort of performance issue , because your program takes more than the max time set for the program to execute in foreground.
    There are many stuff in program which will hamper your performance.
    I will list down a few
    1. SELECT *
    FROM konp
    INTO CORRESPONDING FIELDS OF TABLE konp_itab
    FOR ALL ENTRIES IN a363_itab
    WHERE knumh EQ a363_itab-knumh
    in this statement you are using for all entries a363_itab , but before this statement you are not checking if the table has any entry or not , please do remember that for all entries has this characterstic , that if you internal table does not contain any record , then all the records are selected from the database table. So in this case if you table a363_itab is empty , so what you want is no data must be seelcted from table konp , but what will happen is all the records in KONP will be seelcted.
    2. While retreiving data you are using seelct * even though you do not require all the fields , an example is
    <b>SELECT *
    FROM mkpf
    INTO CORRESPONDING FIELDS OF TABLE mkpf_itab
    FOR ALL ENTRIES IN mseg_itab
    WHERE mblnr EQ mseg_itab-mblnr.</b>
    in this your internal table contains only 2 fields
    <b>mblnr LIKE mkpf-mblnr, "Number of Material Document
    bldat LIKE mkpf-bldat, "Document Date in Document</b> , but to get these 2 fields you are selecting all the fields of the table.
    3. In select you are using into corresponding fields of table , it is not a good practice., so please avoidd it.
    Please understand that you must try to reduce the access to your database tables and try to keep it minimal , because this same thing may happen becasue data in DEV is very less compared to the volume of data in production , so a program working in DEV will take much more time in PRD if not written properly and may result in timeouts , as in your case.
    Please try to make chanegs to the prorgam and see if it works.
    In case you have more queries , please do revert back.
    Regards
    Arun
    *Reward points if replay is helpful

  • Need help in the Report Program!!!

    Hi,
    This is SAI KUMAR.
    <b>Selection Screen</b>
    Sales Org: <b>VKORG</b>
    Distribution Channel: <b>VTWEG</b>
    Division: <b>SPART</b>
    Billing Type: <b>FKART</b>
    Plant: <b>WERKS</b>
    Payment Terms: <b>ZTERM</b>
    Sold-to Party: <b>KUNAG</b>
    Billing Date: <b>FKDAT</b>
    Now Using the above Selection screen inputs, I want to generate the following fields in the output.
    <b>Output Screen</b>
    Invoice No: <b>VBELN</b>
    Invoice Date: <b>FKDAT</b>
    Customer Number: <b>KUNNR</b>
    Customer Name: <b>NAME1</b>
    Material Description: <b>MAKTX</b>
    Payment Terms: <b>ZTERM</b>
    Net Value: <b>NETWR</b>
    Ship-to City: <b>ORT01</b>
    Sold-to party: <b>KUNAG</b>
    Ship-to party: <b>KUNNR</b>
    <u><b>Tables Used: </b></u>
    Delivery: <b>LIKP, LIPS</b>
    Invoice:<b>VBRK, VBRP</b>
    Customer: <b>KNA1</b>
    Material: <b>MARA</b>
    Material Description: <b>MAKT</b>
    <b>
    Now the Problem what I got is....How to link between these tables...ie., what common fields can be used between these tables so that I can use FOR ALL ENTRIES and retrieve the above output fields.</b>
    Can anyone please help me out in giving a REPORT program or a pseudo code for the above data.
    Thanks & Regards,
    SAI KUMAR
    <b>ID: [email protected]</b>

    See the below code :
    REPORT zjpvrom323 NO STANDARD PAGE HEADING LINE-SIZE 200 LINE-COUNT 35
    MESSAGE-ID zjpv001 .
    *& Development ID:   OM_DD_323_LJP                                    *
    *& Report        :   ZJPVROM323                                       *
    *& This application is used to Develop a new billing document that    *
    *& fulfills  the  NPKK  Requirement That does not exist in JSP        *
    *& functionality.according to the delivery date it displays Monthly   *
    sales notes report                                                *
    *& Change Log:                                                        *
    *&  Init.        Who             Date         Text                    *
    *& MALIKDH1     Seshu Reddy     2003/07/20   Initial Development      *
              Constants
    CONSTANTS :c_vkorg(4) VALUE 'JP20', " Sale Organization
               c_vtweg(2) VALUE 'TR',   " Distribution Channel
               c_rfbsk VALUE 'C',       " Status for transfer to accounting
               c_spart(2) VALUE '01',   " Division
               c_kvgr2(3) VALUE 'Z51',  " Customer Group 2
               c_fkart(4) TYPE c VALUE 'ZJPW', " Billing Type
               c_waerk(5) TYPE c VALUE 'JPY',  " SD document currency
               c_kschl(4) TYPE c VALUE 'ZJPC', " Condition type
               c_no_of_lines TYPE i VALUE '35',
               C_CONS_5(1) TYPE C VALUE '5',
               C_CONS_8(1) TYPE C VALUE '8',
               C_CONS_10(2) TYPE C VALUE '10',
               c_konwa(5) TYPE c VALUE 'JPY'. " Rate unit (currency or
    "            percentage)
              DB-Tables                                                *
    *TABLES : vbrk,           " Billing : Header Data
            vbrp,           " Billing : Item Data
            kna1,           " Customer master : General data
            knvv,           " Customer master : sales data
            likp,           " Delivery : Header data
            konv,           " Condition : Transaction data
            konp,           " Condition : items
            zjpv_torihiki,  " Add on table:Business transaction category
            zjpv_rebate.    " Add on table : rebate table
               Variables/Internal table                                 *
    DATA :g_date(2) TYPE n,           " Date
          g_month(2) TYPE n,          " Month
          g_year(4) TYPE n ,          " Year
          g_bill_low(10) TYPE n,       " From date
          g_bill_high(10) TYPE n,      " To date
          g_month1(2) TYPE n,         " Month
          g_year1(4) TYPE n,          " Year
          g_date1(2) TYPE n,          " Date
          g_year2(4) TYPE n,          " Year
          g_datum LIKE sy-datum,      " System date
          g_skip(4) TYPE c ,          " Line break
          g_ctax(8) TYPE c,           " Consumption tax
          g_ctax1(10) TYPE c,         " Consumption tax
          g_ctax2(16) TYPE c,         " Consumption tax
          g_vol(6) TYPE c,            " Volume
          g_vol1(6) TYPE c,           " Volume
          g_vol2(7) TYPE c,           " Volume
          g_tamt(10) TYPE c,          " Total amount
          g_tamt1(13) TYPE c,         " Total amount
          g_tamt2(16) TYPE c,         " Total amount
          g_gtotal(10) TYPE c,        " Net total
          g_gtotal1(13) TYPE c,       " Net total
          g_gtotal2(16) TYPE c,       " Net total
          g_uprice(8)  TYPE c,        " Unit Price
          g_uprice1(10)  TYPE c,      " Unit Price
          g_uprice2(11)  TYPE c,      " Unit Price
          g_amount(10) TYPE c,        " Amount
          g_amount1(13) TYPE c,       " Amount
          g_amount2(14) TYPE c,       " Amount
          g_fctax(16) TYPE c,      " Consumption Tax (Total)
          g_ftamnt(16) TYPE c,     " Total amount (Total)
          g_ftotal(16) TYPE c,     " net total (Total)
          g_fctax1(8) TYPE c,      " Totals with Comma (Consumption tax)
          g_fctax2(10) TYPE c,     " Totals with Comma (Consumption tax)
          g_fctax3(11) TYPE c,     " Totals with Comma (Consumption tax)
          g_ftamt1(10) TYPE c,     " Totals with comma (Total amount)
          g_grand_total(16),
          g_grand_total1(14),
          g_net_total(16),
          g_net_total1(14),
          g_middle_val(16),
          g_middle_val1(11),
          g_ftamt2(13) TYPE c,     " Totals with Comma(Total amount)
          g_ftamt3(14) TYPE c,     " Totals with comma(Total amount)
          g_ftotal1(10) TYPE c,    " Totals with comma(Net total)
          g_ftotal2(13) TYPE c,    " Totals with comma(Net total)
          g_ftotal3(14) TYPE c.    " Totals with comma(Net total)
    *Internal table for billing document header
    DATA : BEGIN OF t_vbrk OCCURS 0,
           vbeln LIKE vbrk-vbeln,      " Billing Doc number
           vbtyp LIKE vbrk-vbtyp,      " Document Category
           kunag LIKE vbrk-kunag,      " sold-to-party
           vkorg LIKE vbrk-vkorg,      " sales organization
           vtweg LIKE vbrk-vtweg,      " Distribution Channel
           kunrg LIKE vbrk-kunrg,      " Payer
           fkart_rl LIKE vbrk-fkart_rl," Billing Type
           fkdat LIKE vbrk-fkdat,      " Billing date
           mwsbk LIKE vbrk-mwsbk,      " Tax amount in document currency
           netwr LIKE vbrk-netwr,      " Net value in document currency
           waerk LIKE vbrk-waerk,      " SD document currency
           knumv LIKE vbrk-knumv,      " Number of the document condition
           END OF t_vbrk.
    internal table for Output formatting
    DATA : BEGIN OF t_oput OCCURS 0,
           rbcode(4) TYPE c,                     " Regulating Branch Code
           tpcode(10)  TYPE c,                   " trading partner code
           bdgrp(3) TYPE c,                      " Billing Document Group
           zjd_torihikikubn(3) TYPE c,           "   business transaction
                                                  "category
           tpname1(35) TYPE c,                   " trading partner name 1
           tpname2(35) TYPE c,                   " trading partner name 2
           bdgnm(10) TYPE c,                     " Billing Doc Group Name
           dcode(10) TYPE c,                     " destination code
           dname(35),                            " destination name
           fkdat(10) TYPE c,                     " Date of Issue
           vbeln(10) TYPE c,                     " Billing Doc No
           zzjp_remarks(30) TYPE c,              " Remarks
           ctax(16) TYPE c,                      " Consumption Tax
           tamnt(16) TYPE c,                    " Total Amount
           gtotal(16) TYPE c,                    " Grand total,
           pcode(9) TYPE n,                      " Product Code
           pname(40) TYPE c,                     " Product name
           volume(16) TYPE p decimals 3,          " volume
           volume1 type i,
           volume2(16) type c,
           uprice(13) TYPE c,                    " Unit Price
           amount(16) TYPE c,                    " Amount
           posnr(6) TYPE n,                      " Billing Item
           END OF t_oput.
    *Internal table for Customer Master Sales Data
    DATA : BEGIN OF t_knvv OCCURS 0,
           kunnr LIKE knvv-kunnr, " Customer Number
           vkorg LIKE knvv-vkorg, " Sales Organization
           vtweg LIKE knvv-vtweg, " Distribution Channel
           spart LIKE knvv-spart, " Division
           kvgr2 LIKE knvv-kvgr2, " Customer Group 2
           vkbur LIKE knvv-vkbur, " sales office
           END OF t_knvv.
    *Internal table for Customer Master Data
    DATA : BEGIN OF t_kna1 OCCURS 0,
           kunnr LIKE kna1-kunnr,   " Customer number
           name1 LIKE kna1-name1,   " Customer Name 1
           name2 LIKE kna1-name2,   " Customer Name 2
           END OF t_kna1.
    Internal table used for billing document items
    DATA : BEGIN OF t_vbrp OCCURS 0,
           vbeln LIKE vbrp-vbeln,                       " Billing Document
           posnr LIKE vbrp-posnr,        " Billing item
           zjd_torihikikubn LIKE vbrp-zjd_torihikikubn, " Business
                                                      " Transaction Category
           vgbel LIKE vbrp-vgbel,                   " Document number of the
                                                    "   reference  document
           vgtyp LIKE vbrp-vgtyp,                   " Document category of
                                                    " preceding SD document
           zzjp_remarks LIKE vbrp-zzjp_remarks,     " Remarks
           zjd_kanamei LIKE vbrp-zjd_kanamei,
           fkimg LIKE vbrp-fkimg,                   " Actual billed quantity
           netwr LIKE vbrp-netwr,        " Net value of the
                                         " billing item in document currency
           zjd_touitsumatnr LIKE vbrp-zjd_touitsumatnr,
           END OF t_vbrp.
    Internal table used for Rebate Table
    DATA : BEGIN OF t_zjpv_rebate OCCURS 0,
           fkart LIKE zjpv_rebate-fkart,              " Billing type
           rebate_code LIKE zjpv_rebate-rebate_code,  " Rebate Code
           rebate_name LIKE zjpv_rebate-rebate_name,  " Rebate Name
           END OF t_zjpv_rebate.
    *Internal table used for Delivery Header
    DATA : BEGIN OF t_likp OCCURS 0,
           vbeln LIKE likp-vbeln,    " Delivery  No
           kunnr LIKE likp-kunnr,    " Ship-to party
           END OF t_likp.
    *Internal table for conditions (Transaction Data)
    DATA : BEGIN OF t_konv OCCURS 0,
           knumv LIKE konv-knumv,      " Number of the document condition
           kposn LIKE konv-kposn,      " Condition item number
           kschl LIKE konv-kschl,      " Condition type
           knumh LIKE konv-knumh,      " Condition type
           END OF t_konv.
    Internal table for conditions (Item)
    DATA : BEGIN OF t_konp OCCURS 0,
           knumh LIKE konp-knumh,      " Number of the document condition
           kbetr LIKE konp-kbetr,      " Rate (condition amount or
                                       " percentage) where no scale exists
           konwa LIKE konp-konwa,      " Rate unit (currency or percentage)
           END OF t_konp.
    Internal table for table Torihiki Kubun
    DATA : BEGIN OF t_zjpv_torihiki OCCURS 0,
           kubun LIKE zjpv_torihiki-kubun,      " Condition type
           rep_grp LIKE zjpv_torihiki-rep_grp,   " Shikiri Report Group
           rep_grp_name LIKE zjpv_torihiki-rep_grp_name, " Shikiri Report
                                                         " Group NAME
           END OF t_zjpv_torihiki.
    DATA:  l_tpname1(35) TYPE c,                   " trading partner name 1
           l_tpname2(35) TYPE c,                   " trading partner name 2
           l_bdgnm(10) TYPE c,                     " Billing Doc Group Name
           G_FLG(1)    type c,
           G_FLG1(1)    type c.
              Selection screen                                           *
    SELECTION-SCREEN : BEGIN OF BLOCK zjpv WITH FRAME TITLE text-001.
    PARAMETER : p_date LIKE sy-datum OBLIGATORY. " Delivery date
    SELECTION-SCREEN : END OF BLOCK zjpv.
    RANGES : r_bdate  FOR vbrk-fkdat.             " Billing date
           Initialization                                                *
    INITIALIZATION.
      p_date = sy-datum.
               MAIN PROCESSING                                           *
    START-OF-SELECTION.
    This Perform is used for getting Billing date  According to Delivery
    Date(Output date)
      PERFORM f_bill_date_move.
    Selecting the data from tables VBRK,VBRP,KNVV,KNA1,KONV,KONP,LIKP,
    ZJPV_TORIHIKI and ZJPV_REBATE
      PERFORM f_get_data.
    Passing the data from the internal tables (T_VBRK,T_VBRP,T_KNVV,
    T_KNA1,T_KONV,T_KONP,T_LIKP, T_ZJPV_TORIHIKI and T_ZJPV_REBATE)
    to out put Internal table(T_OPUT)
      PERFORM f_process_data.
              END OF SELECTION                                          *
    END-OF-SELECTION.
    Out put formatting
      PERFORM f_output_data.
    *&      Form  F_Bill_DATE_MOVE
    This Perform is used for getting Billing date  According to Delivery *
    Date(Output date)                                                    *
    FORM f_bill_date_move.
      g_datum = p_date + 10.
      g_month = g_datum+4(2).
      g_year = g_datum+0(4).
      IF g_month = 1.
        g_year = g_year - 1.
        g_month = 12.
        g_date = 1.
      ELSE.
        g_month = g_month - 1.
        g_date = 1.
      ENDIF.
    Passing the date to billing date-low
      CONCATENATE  g_year g_month g_date  INTO g_bill_low.
      r_bdate-low = g_bill_low.
      r_bdate-sign = 'I'.
      r_bdate-option = 'BT'.
      g_month1 = g_datum+4(2).
      g_year1 = g_datum+0(4).
      IF g_month1 = 1.
        g_year1 = g_year1 - 1.
        g_month1 = 12.
      ELSE.
        g_month1 = g_month1 - 1.
      ENDIF.
      CASE g_month1.
        WHEN 1.g_date1 = '31'.
        WHEN 3.g_date1 = '31'.
        WHEN 4.g_date1 = '30'.
        WHEN 5.g_date1 =  '31'.
        WHEN 6.g_date1 = '30'.
        WHEN 7.g_date1 = '31'.
        WHEN 8.g_date1 = '31'.
        WHEN 9.g_date1 = '30'.
        WHEN 10.g_date1 = '31'.
        WHEN 11.g_date1 = '30'.
        WHEN 12.g_date1 = '31'.
      ENDCASE.
      g_year2 = g_year1.
      IF g_month1 = 2.
        g_year2 = g_year2 MOD 4 .
        IF g_year2 = 0.
          g_date1 = 29.
        ELSE.
          g_date1 = 28.
        ENDIF.
      ENDIF.
    Passing the date to billing date-high
      CONCATENATE  g_year1  g_month1  g_date1 INTO g_bill_high.
      r_bdate-high = g_bill_high.
      APPEND r_bdate.
    ENDFORM.                    " F_Bill_DATE_MOVE
    *&      Form  f_get_data
    Selecting the data from tables VBRK,VBRP,KNVV,KNA1,KONV,KONP,LIKP,   *
    ZJPV_TORIHIKI and ZJPV_REBATE                                        *
    FORM f_get_data.
    Selecting the data from VBRK into internal table T_VBRK.
      SELECT   vbeln
               vbtyp
               kunag
               vkorg
               vtweg
               kunrg
               fkart_rl
               fkdat
               mwsbk
               netwr
               waerk
               knumv
               FROM vbrk
               INTO TABLE t_vbrk
               WHERE fkdat BETWEEN r_bdate-low and r_bdate-high
                     and RFBSK = C_RFBSK
                     AND  vbtyp IN ('N' , 'S' , 'M' , 'O' , 'P')
                     AND vkorg = c_vkorg
                     AND vtweg = c_vtweg
                     AND netwr <> 0.
      IF sy-subrc Eq 0.
        sort t_vbrk.
      ENDIF.
    Selecting the data from KNVV into internal table T_KNVV.
      SELECT kunnr
             vkorg
             vtweg
             spart
             kvgr2
             vkbur
             FROM knvv
             INTO TABLE t_knvv
             FOR ALL ENTRIES IN t_vbrk WHERE ( kunnr = t_vbrk-kunag
                                       OR    kunnr = t_vbrk-kunrg )
                                       AND   vkorg = t_vbrk-vkorg
                                       AND   vtweg = t_vbrk-vtweg
                                       AND   spart = c_spart
                                       AND   kvgr2 = c_kvgr2.
    Selecting the data from VBRP into internal table T_VBRP.
      SELECT vbeln
             posnr
             zjd_torihikikubn
             vgbel
             vgtyp
             zzjp_remarks
             zjd_kanamei
             fkimg
             netwr
             zjd_touitsumatnr
             FROM vbrp
             INTO TABLE  t_vbrp
             FOR ALL ENTRIES IN t_vbrk
             WHERE vbeln = t_vbrk-vbeln.
    Selecting the data from ZJPV_REBATE into internal table T_ZJPV_REBATE.
      SELECT fkart
             rebate_code
             rebate_name
             FROM zjpv_rebate
             INTO TABLE t_zjpv_rebate
             FOR ALL ENTRIES IN t_vbrk
             WHERE fkart = t_vbrk-fkart_rl.
    Selecting the data from KNA1 into internal table T_KNA1.
      SELECT kunnr
             name1
             name2
             FROM kna1
             INTO TABLE t_kna1
             FOR ALL ENTRIES IN t_knvv
             WHERE kunnr = t_knvv-kunnr.
      IF NOT t_vbrp[] IS INITIAL.
    Selecting the data from LIKP into internal table T_LIKP.
        SELECT vbeln
               kunnr
               FROM likp
               INTO TABLE t_likp
               FOR ALL ENTRIES IN t_vbrp
               WHERE vbeln = t_vbrp-vgbel.
      ENDIF.
    Selecting the data from KONV into internal table T_KONV.
      SELECT knumv
             kposn
             kschl
             knumh
             FROM konv
             INTO TABLE t_konv
             FOR ALL ENTRIES IN t_vbrk
             WHERE knumv = t_vbrk-knumv
             AND   kschl = c_kschl.
    Selecting the data from KONP into internal table T_KONP.
      SELECT knumh
             kbetr
             konwa
             FROM konp
             INTO TABLE t_konp
             FOR ALL ENTRIES IN t_konv
             WHERE knumh = t_konv-knumh.
    Selecting the data from ZJPV_TORIHIKI into internal table
    T_ZJPV_TORIHIKI.
      SELECT kubun
             rep_grp
             rep_grp_name
             FROM zjpv_torihiki
             INTO TABLE t_zjpv_torihiki
             FOR ALL ENTRIES IN t_vbrp
             WHERE kubun = t_vbrp-zjd_torihikikubn.
    ENDFORM.                    " f_get_data
    *&      Form  f_process_data
    Reading The Data from Internal tables (T_VBRK,T_VBRP,T_KNVV,T_KNA1,  *
    T_LIKP,T_KONV,T_KONP,T_ZJPV_REBATE and T_ZJP_TORIHIKI)               *
    FORM f_process_data.
    Sorting the internal table t_kna1, t_vbrk, t_vbrp ,t_knvv,t_kna1,
    t_likp and t_zjpv_rebate
      SORT: t_kna1 BY kunnr,
            t_vbrk BY vbeln,
            t_vbrp BY vbeln,
            t_knvv BY kunnr,
            t_zjpv_rebate BY fkart,
            t_knvv BY kunnr vkorg vtweg spart,
            t_likp BY vbeln.
      LOOP AT t_vbrk.
    Reading the data from internal table t_knvv
        READ TABLE t_knvv WITH KEY kunnr = t_vbrk-kunag
                                     vkorg = t_vbrk-vkorg
                                     vtweg = t_vbrk-vtweg
                                     spart = c_spart
                                     kvgr2 = c_kvgr2.
        IF sy-subrc NE 0.
          g_flg = 'X'.
        ENDIF.
    Reading the data from internal table t_knvv
        READ TABLE t_knvv WITH KEY kunnr = t_vbrk-kunrg
                                    vkorg = t_vbrk-vkorg
                                    vtweg = t_vbrk-vtweg
                                    spart = c_spart
                                    kvgr2 = c_kvgr2.
        IF sy-subrc NE 0.
          G_FLG1 = 'X'.
        ENDIF.
        IF G_FLG = 'X' AND G_FLG1 = 'X'.
          DELETE T_VBRK.
          CLEAR: G_FLG, G_FLG1.
          CONTINUE.
        ENDIF.
      ENDLOOP.
      DATA :  l_sign(1) TYPE c VALUE '-',
              l_ctax(15) TYPE n ,
              l_tamnt(15) TYPE n ,
              l_volume(16) TYPE c,
              l_gtotal(15) TYPE n,
              l_amnt(15) TYPE n.
      SORT t_konv BY knumv kposn kschl.
      SORT t_konp BY knumh.
      LOOP AT t_vbrp.
        READ TABLE t_vbrk WITH KEY vbeln = t_vbrp-vbeln.
        IF sy-subrc <> 0.
          DELETE t_vbrp.
          CONTINUE.
        ENDIF.
    Reading the data from Internal table T_zjpv_rebate(Rebate table)
        READ TABLE t_zjpv_rebate WITH KEY
                            fkart = t_vbrk-fkart_rl
                            BINARY SEARCH.
        IF sy-subrc NE 0 OR t_vbrk-fkart_rl EQ c_fkart.
          MOVE t_vbrk-kunag TO t_oput-tpcode.
        ELSE .
          IF t_vbrk-fkart_rl NE c_fkart.
            MOVE t_vbrk-kunrg TO t_oput-tpcode.
          ENDIF.
        ENDIF.
        READ TABLE t_zjpv_rebate WITH KEY
                            fkart = t_vbrk-fkart_rl
                            BINARY SEARCH.
        IF sy-subrc NE 0.
    Passing the last 6 values of ZJD_TOUITSUMANTR into product code.
          MOVE t_vbrp-zjd_touitsumatnr+3(6) TO t_oput-pcode.
          MOVE t_vbrp-zjd_kanamei TO t_oput-pname.
        ELSE.
          MOVE t_zjpv_rebate-rebate_code+3(6) TO t_oput-pcode.
          MOVE t_zjpv_rebate-rebate_name TO t_oput-pname.
        ENDIF.
    Reading the data from Internal table T_KNA1(Customer Master)
        READ TABLE t_kna1 WITH KEY
                     kunnr = t_oput-tpcode BINARY SEARCH.
        IF sy-subrc = 0.
          MOVE t_kna1-name1 TO t_oput-tpname1.
          MOVE t_kna1-name2 TO t_oput-tpname2.
        ENDIF.
    Reading the data from Internal table T_vbrp(Billing Documnet: Item)
        MOVE t_vbrp-zjd_torihikikubn TO t_oput-zjd_torihikikubn.
    Reading the data from Internal table T_KNVV
        READ TABLE t_knvv WITH KEY kunnr = t_vbrk-kunrg
                                   vkorg = c_vkorg
                                   vtweg = c_vtweg
                                   spart = c_spart
                                   BINARY SEARCH.
        IF sy-subrc EQ 0.
          MOVE t_knvv-vkbur TO t_oput-rbcode.
        ENDIF.
    Reading the data from Internal table T_LIKP (Delivery : Header)
        IF  t_vbrp-vgtyp =  'J' OR t_vbrp-vgtyp = 'T'.
          READ TABLE t_likp WITH KEY
                        vbeln = t_vbrp-vgbel
                        BINARY SEARCH.
          IF sy-subrc = 0.
            MOVE t_likp-kunnr TO t_oput-dcode.
          ENDIF.
        ENDIF.
    Reading the data from Internal table T_KNA1.
        READ TABLE t_kna1 WITH KEY kunnr = t_likp-kunnr BINARY SEARCH.
        IF sy-subrc = 0 AND NOT t_oput-dcode IS INITIAL.
          MOVE t_kna1-name2 TO t_oput-dname.
        ENDIF.
    *Passing the values from internal table t_vbrk and t_vbrp to
    *out put internal table.
        MOVE t_vbrk-fkdat TO t_oput-fkdat.
        CONCATENATE t_oput-fkdat0(4) '.' t_oput-fkdat4(2) '.'
            t_oput-fkdat+6(2) INTO t_oput-fkdat.
        MOVE t_vbrk-vbeln TO t_oput-vbeln.
        MOVE t_vbrp-posnr TO t_oput-posnr.
        MOVE t_vbrp-zzjp_remarks TO t_oput-zzjp_remarks.
    *Checking for billing document category.
        IF t_vbrk-vbtyp = 'M' OR t_vbrk-vbtyp = 'P' OR t_vbrk-vbtyp = 'S'.
          IF t_vbrk-waerk = c_waerk.
            t_oput-ctax = t_vbrk-mwsbk * 100.
            t_oput-tamnt = t_vbrk-netwr * 100.
            t_oput-gtotal = t_oput-ctax + t_oput-tamnt.
          ELSE.
            t_oput-ctax = t_vbrk-mwsbk .
            t_oput-tamnt = t_vbrk-netwr.
            t_oput-gtotal = t_oput-ctax + t_oput-tamnt.
          ENDIF.
        ENDIF.
        IF t_vbrk-vbtyp = 'O' OR  t_vbrk-vbtyp = 'N' .
          IF t_vbrk-waerk = c_waerk.
            l_ctax = ( t_vbrk-mwsbk * 100 ) .
    *The contents of the consumption tax are converted to display format.
            PERFORM F_ALPHA_CONV USING L_CTAX.
            CONCATENATE l_sign l_ctax INTO t_oput-ctax.
            CONDENSE t_oput-ctax.
            l_tamnt  = ( t_vbrk-netwr * 100 ).
    *The contents of the total amount are converted to display format.
            PERFORM F_ALPHA_CONV USING L_TAMNT.
            CONCATENATE l_sign l_tamnt INTO t_oput-tamnt.
            CONDENSE t_oput-tamnt.
            l_gtotal = t_oput-ctax + t_oput-tamnt.
    *The contents of the grand total are converted to display format.
            PERFORM F_ALPHA_CONV USING L_GTOTAL.
            CONCATENATE l_sign l_gtotal INTO t_oput-gtotal.
          ELSE.
            l_ctax = t_vbrk-mwsbk.
    *The contents of the consumption tax are converted to display format.
            PERFORM F_ALPHA_CONV USING L_CTAX.
            CONCATENATE l_sign l_ctax INTO t_oput-ctax.
            l_tamnt = ( t_vbrk-netwr ).
    *The contents of the total amount are converted to display format.
            PERFORM F_ALPHA_CONV USING L_TAMNT.
            CONCATENATE l_sign l_tamnt INTO t_oput-tamnt.
            l_gtotal =  ( t_oput-ctax + t_oput-tamnt ).
    *The contents of the grand total are converted to display format.
            PERFORM F_ALPHA_CONV USING L_GTOTAL.
            CONCATENATE l_sign l_gtotal INTO t_oput-gtotal.
          ENDIF.
        ENDIF.
    Comparing the volume with given conditions.
        IF t_vbrp-fkimg EQ 0.
          t_oput-volume = space.
        ELSEIF t_vbrp-fkimg NE 0.
         IF t_vbrk-vbtyp = 'M' OR  t_vbrk-vbtyp = 'P' OR t_vbrk-vbtyp = 'S'.
            t_oput-volume = t_vbrp-fkimg.
            CALL FUNCTION 'ROUND'
                 EXPORTING
                      DECIMALS      = 3
                      input         = t_oput-volume
                      SIGN          = ' '
                 IMPORTING
                      OUTPUT        = t_oput-volume1
                 EXCEPTIONS
                      INPUT_INVALID = 1
                      OVERFLOW      = 2
                      TYPE_INVALID  = 3
                      OTHERS        = 4.
            IF sy-subrc <> 0.
             MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
            ENDIF.
            move t_oput-volume1 to t_oput-volume2.
            condense t_oput-volume2 no-gaps.
          ELSEIF t_vbrk-vbtyp = 'O' OR  t_vbrk-vbtyp = 'N'.
            t_oput-volume = t_vbrp-fkimg.
            CALL FUNCTION 'ROUND'
                 EXPORTING
                      DECIMALS      = 3
                      input         = t_oput-volume
                      SIGN          = ' '
                 IMPORTING
                      OUTPUT        = t_oput-volume1
                 EXCEPTIONS
                      INPUT_INVALID = 1
                      OVERFLOW      = 2
                      TYPE_INVALID  = 3
                      OTHERS        = 4.
            IF sy-subrc <> 0.
             MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
            ENDIF.
            l_volume = t_oput-volume1.
    *The contents of the volume are converted to display format.
            PERFORM F_ALPHA_CONV USING L_VOLUME.
            CONCATENATE l_sign l_volume INTO t_oput-volume2.
            condense t_oput-volume2 no-gaps.
          ENDIF.
        ENDIF.
    *Unit price
        IF t_vbrp-fkimg EQ 0.
          t_oput-uprice = space.
        ELSE.
    Reading The data from Internal Table T_KONV(Condition :Transactional)
          READ TABLE t_konv WITH KEY   knumv = t_vbrk-knumv
                                       kposn = t_vbrp-posnr
                                       kschl = c_kschl
                                       BINARY SEARCH.
          IF sy-subrc = 0.
    Reading The data from Internal Table T_KONP(Condition : Items)
            READ TABLE t_konp WITH KEY
                    knumh = t_konv-knumh
                    BINARY SEARCH.
            IF sy-subrc = 0.
              IF t_konp-konwa = c_konwa.
                t_oput-uprice = 100 * t_konp-kbetr.
              ELSE.
                t_oput-uprice = t_konp-kbetr.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDIF.
    Caluculating the amount with given conditions
        IF t_zjpv_rebate-fkart = t_vbrk-fkart_rl.
          t_oput-amount = t_vbrk-netwr.
        ELSE.
          t_oput-amount = t_vbrp-netwr.
        ENDIF.
        IF t_vbrk-waerk EQ c_waerk.
          t_oput-amount =  100 * t_oput-amount.
        ENDIF.
        IF t_vbrk-vbtyp ='M' OR t_vbrk-vbtyp = 'P' OR
                               t_vbrk-vbtyp  = 'S'.
        ELSE.
          IF t_vbrk-vbtyp  = 'O' OR t_vbrk-vbtyp = 'N'.
            IF t_oput-amount+15(1) = l_sign.
              l_amnt = t_oput-amount+0(15).
              PERFORM F_ALPHA_CONV USING L_AMNT.
              CONCATENATE l_sign l_amnt INTO t_oput-amount.
            ELSE.
              l_amnt = t_oput-amount.
              PERFORM F_ALPHA_CONV USING L_AMNT.
              CONCATENATE l_sign l_amnt INTO t_oput-amount.
            ENDIF.
          ENDIF.
        ENDIF.
    Reading the data from Internal Table T_ZPV_TORIHIKI
        READ TABLE t_zjpv_torihiki WITH KEY
                   kubun = t_vbrp-zjd_torihikikubn
                   BINARY SEARCH.
        IF sy-subrc = 0.
          t_oput-bdgrp = t_zjpv_torihiki-rep_grp.
          t_oput-bdgnm = t_zjpv_torihiki-rep_grp_name.
        ENDIF.
        APPEND t_oput.
    Clearing the memory of the internal tables.
        CLEAR: t_oput,
               t_vbrp,
               t_vbrk,
               t_kna1,
               t_knvv,
               t_zjpv_rebate,
               t_zjpv_torihiki,
               t_likp,
               t_konv,
               t_konp.
      ENDLOOP.
    ENDFORM.                    " f_process_data
    *&      Form  f_output_data
          Output formatting
    FORM f_output_data.
    SORT t_oput BY rbcode
                    tpcode
                    bdgrp
                    fkdat
                    zjd_torihikikubn
                    vbeln
                    posnr.
      DATA : l_volume(5) TYPE c,
             l_ctax(8) TYPE c.
      MOVE t_oput-volume TO l_volume.
      MOVE t_oput-ctax TO l_ctax.
      DATA : l_ctax1(16) ,
             l_ctax2(16),
             l_vol1(14) ,
             l_vol3(8),
             l_vol2(14),
             l_tamt1(16),
             l_tamt2(16),
             l_gtotal1(16),
             l_gtotal2(16),
             l_uprice1(16),
             l_uprice2(16),
             l_amount1(16) TYPE c,
             l_amount2(16) TYPE c,
             l_fctax1(16) TYPE c,
             l_fctax2(16) TYPE c,
             l_ftamt1(16) TYPE c,
             l_ftamt2(16) TYPE c,
             l_ftotal1(16) TYPE c,
             l_ftotal2(16) TYPE c,
             l_sign(1) TYPE c VALUE '-'.
      CONSTANTS c_minus VALUE '-'.
      SORT t_konv BY knumv kposn kschl.
      SORT t_oput BY zjd_torihikikubn vbeln posnr.
    Printing Final Values.
      LOOP AT t_oput.
    Perform F_FORMAT_SUBTOTAL is used to align the value with the commas
    for display purpose.
        L_CTAX2 = T_OPUT-CTAX.
        G_CTAX2 = T_OPUT-CTAX.
        PERFORM F_FORMAT_SUBTOTAL USING G_CTAX2
                                        C_CONS_8.
        CONDENSE T_OPUT-CTAX.
    Perform F_FORMAT_SUBTOTAL is used to align the value with the commas
    for display purpose.
        L_TAMT2 = T_OPUT-TAMNT.
        G_TAMT2 = T_OPUT-TAMNT.
        PERFORM F_FORMAT_SUBTOTAL USING G_TAMT2
                                        C_CONS_10.
        CONDENSE T_OPUT-TAMNT.
    Perform F_FORMAT_SUBTOTAL is used to align the value with the commas
    for display purpose.
        L_GTOTAL2 = T_OPUT-GTOTAL.
        G_GTOTAL2 = T_OPUT-GTOTAL.
        PERFORM F_FORMAT_SUBTOTAL USING G_GTOTAL2
                                        C_CONS_10.
        CONDENSE T_OPUT-GTOTAL.
    Perform F_FORMAT_SUBTOTAL is used to align the value with the commas
    for display purpose.
    *Volume
        IF t_oput-volume >= 99999 OR t_oput-volume <= -99999.
          t_oput-volume = space.
        ELSE.
          l_vol1 = t_oput-volume.
          l_vol2 = t_oput-volume.
          CONDENSE l_vol1.
          CONDENSE l_vol2.
          IF  l_vol1+0(1) EQ '-'.
            REPLACE '-' WITH space INTO  l_vol1.
          ENDIF.
          CONDENSE l_vol1.
          WRITE l_vol1 TO g_vol RIGHT-JUSTIFIED.
          REPLACE '.' WITH ',' INTO l_vol1.
    write :85 l_vol1.
          IF NOT g_vol+0(2) IS  INITIAL.
            g_vol10(2) = g_vol0(2).
            g_vol1+2(1) = ','.
          ENDIF.
          IF NOT g_vol+2(3) IS  INITIAL.
            g_vol13(3) = g_vol2(3).
          ENDIF.
    replace '.' with ',' into t_oput-volume.
          l_vol2 = t_oput-volume.
          IF  l_vol2+0(1) EQ '-'.
            g_vol2 = g_vol1 .
            CONDENSE g_vol2.
            CONCATENATE c_minus g_vol2 INTO g_vol2.
          ELSE.
            g_vol2 = g_vol1 .
            CONDENSE g_vol2.
          ENDIF.
        ENDIF.
    L_VOL1 = T_OPUT-VOLUME.
    PERFORM F_FORMAT_SUBTOTAL USING L_VOL1
                                     C_CONS_5.
    CONDENSE L_VOL1.
    Unit Price
        IF t_oput-uprice >= 99999999 OR t_oput-uprice <= -99999999.
          t_oput-uprice = space.
        ELSE.
          l_uprice1 = t_oput-uprice .
          l_uprice2 = t_oput-uprice.
          CONDENSE l_uprice1.
          CONDENSE l_uprice2.
          IF  l_uprice1+0(1) EQ '-'.
            REPLACE '-' WITH space INTO  l_uprice1.
          ENDIF.
          CONDENSE l_uprice1.
          WRITE l_uprice1 TO g_uprice RIGHT-JUSTIFIED.
          IF NOT g_uprice+0(2) IS  INITIAL.
            g_uprice10(2) = g_uprice0(2).
            g_uprice1+2(1) = ','.
          ENDIF.
          IF NOT g_uprice+2(3) IS  INITIAL.
            g_uprice13(3) = g_uprice2(3).
            g_uprice1+6(1) = ','.
          ENDIF.
          IF NOT g_uprice+5(3) IS  INITIAL.
            g_uprice17(3) = g_uprice5(3).
          ENDIF.
          IF  l_uprice2+0(1) EQ '-'.
            g_uprice2 = g_uprice1 .
            CONDENSE g_uprice2.
            CONCATENATE c_minus g_uprice2 INTO g_uprice2.
          ELSE.
            g_uprice2 = g_uprice1 .
            CONDENSE g_uprice2.
          ENDIF.
        ENDIF.
    Amount
        IF t_oput-amount >= 99999999 OR t_oput-amount <= -99999999 .
          t_oput-amount = space.
        ELSE.
          l_amount1 = t_oput-amount.
          l_amount2 = t_oput-amount.
          CONDENSE l_amount1.
          CONDENSE l_amount2.
          IF  l_amount1+0(1) EQ '-'.
            REPLACE '-' WITH space INTO  l_amount1.
          ENDIF.
          CONDENSE l_amount1.
          WRITE l_amount1 TO g_amount RIGHT-JUSTIFIED.
          IF NOT g_amount+0(1) IS  INITIAL.
            g_amount0(1) = g_amount0(1).
            g_amount1+1(1) = ','.
          ENDIF.
          IF NOT g_amount+1(3) IS  INITIAL.
            g_amount12(3) = g_amount1(3).
            g_amount1+5(1) = ','.
          ENDIF.
          IF NOT g_amount+4(3) IS  INITIAL.
            g_amount16(3) = g_amount4(3).
            g_amount1+9(1) = ','.
          ENDIF.
          IF NOT g_amount+7(3) IS  INITIAL.
            g_amount110(3) = g_amount7(3).
          ENDIF.
          IF  l_amount2+0(1) EQ '-'.
            g_amount2 = g_amount1 .
            CONDENSE g_amount2.
            CONCATENATE c_minus g_amount2 INTO g_amount2.
          ELSE.
            g_amount2 = g_amount1 .
            CONDENSE g_amount2.
          ENDIF.
        ENDIF.
       NEW-PAGE.
        MOVE t_oput-tpname1 TO l_tpname1.
        MOVE t_oput-tpname2 TO l_tpname2.
        MOVE t_oput-bdgnm   TO l_bdgnm.
        AT NEW bdgrp.
          IF t_oput-rbcode CO '*'.
            t_oput-rbcode = space.
          ENDIF.
          IF t_oput-tpcode CO '*'.
            t_oput-tpcode = space.
          ENDIF.
          IF t_oput-tpname1 CO '*'.
            t_oput-tpname1 = space.
          ENDIF.
          IF t_oput-tpname2 CO '*'.
            t_oput-tpname2 = space.
          ENDIF.
          IF t_oput-bdgnm CO '*'.
            t_oput-bdgnm = space.
          ENDIF.
          PERFORM f_write_heading.
        ENDAT.
        AT NEW vbeln.
          IF sy-linno = 35 OR sy-linno = 1.
            NEW-PAGE.
            PERFORM f_write_heading.
            WRITE:/6 t_oput-fkdat , 18 t_oput-dcode+3(7) ,
                   28 t_oput-vbeln+2(8) ,
                   37 t_oput-dname+0(20) .
          ELSE.
            WRITE:/6 t_oput-fkdat , 18 t_oput-dcode+3(7) ,
                   28 t_oput-vbeln+2(8) ,
                   37 t_oput-dname+0(20) .
          ENDIF.
        ENDAT.
       WRITE:/6 t_oput-fkdat, 18 t_oput-dcode+3(7),
              28 t_oput-vbeln+2(8),
              37 t_oput-dname+0(20).
        IF sy-linno = 35 OR sy-linno = 1.
          NEW-PAGE.
          PERFORM f_write_heading.
             CONDENSE L_VOL1 NO-GAPS.
          MOVE l_vol1 TO l_vol3.
          WRITE:/6 t_oput-fkdat , 18 t_oput-dcode+3(7) ,
                 28 t_oput-vbeln+2(8) ,
                 37 t_oput-dname+0(20) .
          WRITE:/39 t_oput-pcode+3(6) ,
                 50 t_oput-pname+0(25) ,
                 79 t_oput-zjd_torihikikubn ,
                 85 t_oput-volu

  • How to reduce performance time.

    Hi,
    Any body guide me how to reduce performance time for this report.
    It’s taking to much time for execution.
    *& Report  ZEOU_CST_CLAIM_REP                                          *
    REPORT  zeou_cst_claim_rep.
    *& Program Name    : ZEOU_CST_CLAIM_REP                                *
    *& Title           : CST Claim Report                                  *
    *& Module Name     : EOU                                               *
    *& Author          : Chandra Vangoor                                   *
    *& Create Date     : 05.05.2006                                        *
    *& Logical DB      : None                                              *
    *& Program Type    : On-Line.                                          *
    *& SAP Release     : 4.7                                               *
    *& Description     :                                                   *
    *& Log    Date    Author        Reason of change
    TABLES
    TABLES : a363,
             mara,
             marc,
             makt,
             ekko,
             ekpo,
             mkpf,
             mseg,
             konp,
             konh.
    SELECTION-SCREEN
    SELECTION-SCREEN   :   BEGIN OF BLOCK cst WITH FRAME TITLE text-001.
    SELECT-OPTIONS :   s_matnr FOR mara-matnr,                            "Material Number
                       s_lifnr FOR ekko-lifnr,                            "Account Number of the Vendor
                       s_bedat FOR ekko-bedat,                            "Purchasing Document Date
                       s_kschl FOR konh-kschl OBLIGATORY NO INTERVALS,    "Condition type
                       s_bwart FOR mseg-bwart OBLIGATORY NO INTERVALS.    "Movement Type (Inventory Management)
    PARAMETERS     :   p_werks LIKE marc-werks OBLIGATORY.                "Plant
    SELECTION-SCREEN   :   END OF BLOCK cst.
    INCLUDES
    INCLUDE zalv_data.
    DATA - INTERNAL TABLES AND FIELD LISTS
    DATA :  BEGIN    OF     a363_itab  OCCURS 0,
            matnr    LIKE   a363-matnr,                    "Material Number
            lifnr    LIKE   a363-lifnr,                    "Account Number of the Vendor
            werks    LIKE   a363-werks,                    "Plant
            kschl    LIKE   a363-kschl,                    "Condition type
            knumh    LIKE   a363-knumh,                    "Condition record number
            kbetr    LIKE   konp-kbetr,                    "Rate (condition amount or percentage) where no scale exists
            END      OF     a363_itab.
    DATA :  BEGIN    OF     konp_itab  OCCURS 0,
            knumh    LIKE   a363-knumh,                    "Condition record number
            kbetr    LIKE   konp-kbetr,                    "Rate (condition amount or percentage) where no scale exists
            lifnr    LIKE   a363-lifnr,                    "Account Number of the Vendor
            END      OF     konp_itab.
    DATA :  BEGIN    OF     ekko_itab  OCCURS 0,
            ebeln    LIKE   ekko-ebeln,                    "Purchasing Document Number
            lifnr    LIKE   ekko-lifnr,                    "Account Number of the Vendor
            bedat    LIKE   ekko-bedat,                    "Purchasing Document Date
            END      OF     ekko_itab.
    DATA :  BEGIN    OF     ekpo_itab  OCCURS 0,
            ebeln    LIKE   ekpo-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   ekpo-ebelp,                    "Item Number of Purchasing Document
            matnr    LIKE   ekpo-matnr,                    "Material Number
            werks    LIKE   ekpo-werks,                    "Plant
            menge    LIKE   ekpo-menge,                    "Purchase order quantity
            END      OF     ekpo_itab.
    DATA :  BEGIN    OF     v_po_det  OCCURS 0,            "VENDOR + PLANT + PO DEATILS
            lifnr    LIKE   ekko-lifnr,                    "Account Number of the Vendor
            ebeln    LIKE   ekko-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   ekpo-ebelp,                    "Item Number of Purchasing Document
            bedat    LIKE   ekko-bedat,                    "Purchasing Document Date
            matnr    LIKE   ekpo-matnr,                    "Material Number
            werks    LIKE   ekpo-werks,                    "Plant
            menge    LIKE   ekpo-menge,                    "Purchase order quantity
            kbetr    LIKE   konp-kbetr,                    "Rate (condition amount or percentage) where no scale exists
            END      OF     v_po_det.
    DATA :  BEGIN    OF     mseg_itab  OCCURS 0,
            mblnr    LIKE   mseg-mblnr,                    "Number of Material Document
            ebeln    LIKE   mseg-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   mseg-ebelp,                    "Item Number of Purchasing Document
            matnr    LIKE   mseg-matnr,                    "Material Number
            lifnr    LIKE   mseg-lifnr,                    "Account Number of the Vendor
            werks    LIKE   mseg-werks,                    "Plant
            menge    LIKE   mseg-menge,                    "Quantity
            dmbtr    LIKE   mseg-dmbtr,                    "Amount in local currency
            bwart    LIKE   mseg-bwart,                    "Movement Type (Inventory Management)
            END      OF     mseg_itab.
    DATA :  BEGIN    OF     mkpf_itab  OCCURS 0,
            mblnr    LIKE   mkpf-mblnr,                    "Number of Material Document
            bldat    LIKE   mkpf-bldat,                    "Document Date in Document
            END      OF     mkpf_itab.
    DATA :  BEGIN    OF     zeou_pcrdtl_itab  OCCURS 0,
            matnr    LIKE   zeou_pcrdtl-matnr,             "Material Number
            lifnr    LIKE   zeou_pcrdtl-lifnr,             "Account Number of the Vendor
            mblnr    LIKE   zeou_pcrdtl-mblnr,             "Number of Material Document
            whssn    LIKE   zeou_pcrdtl-whssn,             "Warehouse Records Entry Serial No.
            whsdt    LIKE   zeou_pcrdtl-whsdt,             "Warehouse Records Entry date
            END      OF     zeou_pcrdtl_itab.
    DATA :  BEGIN    OF     gr_wh_info  OCCURS 0,          "INFO OF GR & WH BASED ON MVMT TYPE & PO
            mblnr    LIKE   mseg-mblnr,                    "Number of Material Document
            bldat    LIKE   mkpf-bldat,                    "Document Date in Document
            ebeln    LIKE   mseg-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   ekpo-ebelp,                    "Item Number of Purchasing Document
            matnr    LIKE   mseg-matnr,                    "Material Number
            lifnr    LIKE   mseg-lifnr,                    "Account Number of the Vendor
            werks    LIKE   mseg-werks,                    "Plant
            menge    LIKE   mseg-menge,                    "Quantity
            dmbtr    LIKE   mseg-dmbtr,                    "Amount in local currency
            bwart    LIKE   mseg-bwart,                    "Movement Type (Inventory Management)
            whssn    LIKE   zeou_pcrdtl-whssn,             "Warehouse Records Entry Serial No.
            whsdt    LIKE   zeou_pcrdtl-whsdt,             "Warehouse Records Entry date
            END      OF     gr_wh_info.
    DATA :  BEGIN    OF     bseg_itab  OCCURS 0,
            ebeln    LIKE   bseg-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   bseg-ebelp,                    "Item Number of Purchasing Document
            matnr    LIKE   bseg-matnr,                    "Material Number
            lifnr    LIKE   bseg-lifnr,                    "Account Number of the Vendor
            werks    LIKE   bseg-werks,                    "Plant
            buzid    LIKE   bseg-buzid,                    "Identification of the Line Item
            bschl    LIKE   bseg-bschl,                    "Posting Key
            wrbtr    LIKE   bseg-wrbtr,                    "Amount in document currency
            bukrs    LIKE   bseg-bukrs,                    "Company Code
            belnr    LIKE   bseg-belnr,                    "Accounting Document Number
            gjahr    LIKE   bseg-gjahr,                    "Fiscal Year
            END      OF     bseg_itab.
    DATA :  BEGIN    OF     bkpf_itab  OCCURS 0,
            bukrs    LIKE   bkpf-bukrs,                    "Company Code
            belnr    LIKE   bkpf-belnr,                    "Accounting Document Number
            gjahr    LIKE   bkpf-gjahr,                    "Fiscal Year
            xblnr    LIKE   bkpf-xblnr,                    "Reference Document Number
            bldat    LIKE   bkpf-bldat,                    "Document Date in Document
            END      OF     bkpf_itab.
    DATA :  BEGIN    OF     vend_inv  OCCURS 0,            "VENDOR INVOICE DETAILS
            ebeln    LIKE   bseg-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   bseg-ebelp,                    "Item Number of Purchasing Document
            matnr    LIKE   bseg-matnr,                    "Material Number
            lifnr    LIKE   bseg-lifnr,                    "Account Number of the Vendor
            werks    LIKE   bseg-werks,                    "Plant
            buzid    LIKE   bseg-buzid,                    "Identification of the Line Item
            bschl    LIKE   bseg-bschl,                    "Posting Key
            wrbtr    LIKE   bseg-wrbtr,                    "Amount in document currency
            bukrs    LIKE   bseg-bukrs,                    "Company Code
            belnr    LIKE   bseg-belnr,                    "Accounting Document Number
            gjahr    LIKE   bseg-gjahr,                    "Fiscal Year
            xblnr    LIKE   bkpf-xblnr,                    "Reference Document Number
            bldat    LIKE   bkpf-bldat,                    "Document Date in Document
            END      OF     vend_inv.
    DATA :  BEGIN    OF     chckinit  OCCURS 0,            "CHEQUE INIT INFO
            ebeln    LIKE   bseg-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   bseg-ebelp,                    "Item Number of Purchasing Document
            matnr    LIKE   bseg-matnr,                    "Material Number
            lifnr    LIKE   bseg-lifnr,                    "Account Number of the Vendor
            werks    LIKE   bseg-werks,                    "Plant
            buzid    LIKE   bseg-buzid,                    "Identification of the Line Item
            bschl    LIKE   bseg-bschl,                    "Posting Key
            bukrs    LIKE   bkpf-bukrs,                    "Company Code
            belnr    LIKE   bkpf-belnr,                    "Accounting Document Number
            gjahr    LIKE   bkpf-gjahr,                    "Fiscal Year
            koart    LIKE   bseg-koart,                    "Account type
            augbl    LIKE   bseg-augbl,                    "Document Number of the Clearing Document
            END      OF     chckinit.
    DATA :  BEGIN    OF     chckpayer  OCCURS 0,           "CHEQUE BANK DETAILS
            vblnr    LIKE   payr-vblnr,                    "Document Number of the Payment Document
            zbukr    LIKE   payr-zbukr,                    "Paying company code
            gjahr    LIKE   payr-gjahr,                    "Fiscal Year
            chect    LIKE   payr-chect,                    "Check Number
            zaldt    LIKE   payr-zaldt,                    "Probable Payment Date (Cash Discount 1 Due)
            hbkid    LIKE   payr-hbkid,                    "Short key for a house bank
            END      OF     chckpayer.
    DATA :  chckpayer_u LIKE chckpayer OCCURS 0 WITH HEADER LINE.      "UNIQUE CHEQUE DETAILS
    DATA :  BEGIN    OF     chckfinal  OCCURS 0,           "CHEQUE FINAL INFO
            ebeln    LIKE   bseg-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   bseg-ebelp,                    "Item Number of Purchasing Document
            matnr    LIKE   bseg-matnr,                    "Material Number
            lifnr    LIKE   bseg-lifnr,                    "Account Number of the Vendor
            werks    LIKE   bseg-werks,                    "Plant
            buzid    LIKE   bseg-buzid,                    "Identification of the Line Item
            bschl    LIKE   bseg-bschl,                    "Posting Key
            bukrs    LIKE   bkpf-bukrs,                    "Company Code
            belnr    LIKE   bkpf-belnr,                    "Accounting Document Number
            gjahr    LIKE   bkpf-gjahr,                    "Fiscal Year
            koart    LIKE   bseg-koart,                    "Account type
            augbl    LIKE   bseg-augbl,                    "Document Number of the Clearing Document
            vblnr    LIKE   payr-vblnr,                    "Document Number of the Payment Document
            zbukr    LIKE   payr-zbukr,                    "Paying company code
            chect    LIKE   payr-chect,                    "Check Number
            zaldt    LIKE   payr-zaldt,                    "Probable Payment Date (Cash Discount 1 Due)
            hbkid    LIKE   payr-hbkid,                    "Short key for a house bank
            END      OF     chckfinal.
    DATA :  BEGIN    OF     mat_desc OCCURS 0,
            matnr    LIKE   mara-matnr,
            maktx    LIKE   makt-maktx,
            END      OF     mat_desc.
    DATA :  BEGIN      OF     vend_det OCCURS 0,
            lifnr      LIKE   lfa1-lifnr,
            name1      LIKE   lfa1-name1,
            j_1icstno  LIKE   j_1imovend-j_1icstno,
            END        OF     vend_det.
    DATA :  BEGIN    OF     cst_rep  OCCURS 0,             "FINAL CST REPORT
            lifnr    LIKE   a363-lifnr,                    "Account Number of the Vendor
            name1    LIKE   lfa1-name1,                    "Vendor Name
            j_1icstno  LIKE   j_1imovend-j_1icstno,        " Vendor CST No.
            werks    LIKE   a363-werks,                    "Plant
           kschl    LIKE   a363-kschl,                    "Condition type
            ebeln    LIKE   ekko-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   ekpo-ebelp,                    "Item Number of Purchasing Document
            bedat    LIKE   ekko-bedat,                    "Purchasing Document Date
            matnr    LIKE   ekpo-matnr,                    "Material Number
            maktx    LIKE   makt-maktx,                    "Material Description.
            kbetr    LIKE   konp-kbetr,                    "Rate (condition amount or percentage) where no scale exists
            mblnr    LIKE   mseg-mblnr,                    "Number of Material Document
            bldat    LIKE   mkpf-bldat,                    "Document Date in Document
            menge    LIKE   mseg-menge,                    "Quantity
            dmbtr    LIKE   mseg-dmbtr,                    "Amount in local currency
            cst_dmbtr LIKE  mseg-dmbtr,                    "CST Amount in local currency
            bwart    LIKE   mseg-bwart,                    "Movement Type (Inventory Management)
            whssn    LIKE   zeou_pcrdtl-whssn,             "Warehouse Records Entry Serial No.
            whsdt    LIKE   zeou_pcrdtl-whsdt,             "Warehouse Records Entry date
            buzid    LIKE   bseg-buzid,                    "Identification of the Line Item
            bschl    LIKE   bseg-bschl,                    "Posting Key
            wrbtr    LIKE   bseg-wrbtr,                    "Amount in document currency
            cst_wrbtr LIKE  bseg-wrbtr,                    "CST Amount in document currency
            belnr    LIKE   bseg-belnr,                    "Accounting Document Number
            gjahr    LIKE   bseg-gjahr,                    "Fiscal Year
            xblnr    LIKE   bkpf-xblnr,                    "Reference Document Number
            koart    LIKE   bseg-koart,                    "Account type
            augbl    LIKE   bseg-augbl,                    "Document Number of the Clearing Document
            vblnr    LIKE   payr-vblnr,                    "Document Number of the Payment Document
            zbukr    LIKE   payr-zbukr,                    "Paying company code
            chect    LIKE   payr-chect,                    "Check Number
            zaldt    LIKE   payr-zaldt,                    "Probable Payment Date (Cash Discount 1 Due)
            hbkid    LIKE   payr-hbkid,                    "Short key for a house bank
            END      OF     cst_rep.
    DATA :  BEGIN    OF     gt_output  OCCURS 0,              "ALV OUTPUT
            slno     LIKE   sy-tabix,                      "Serial Number
            lifnr    LIKE   a363-lifnr,                    "Account Number of the Vendor
            name1    LIKE   lfa1-name1,                    "Vendor Name
            j_1icstno  LIKE   j_1imovend-j_1icstno,        " Vendor CST No.
            werks    LIKE   a363-werks,                    "Plant
           kschl    LIKE   a363-kschl,                    "Condition type
            ebeln    LIKE   ekko-ebeln,                    "Purchasing Document Number
            ebelp    LIKE   ekpo-ebelp,                    "Item Number of Purchasing Document
            bedat    LIKE   ekko-bedat,                    "Purchasing Document Date
            matnr    LIKE   ekpo-matnr,                    "Material Number
            maktx    LIKE   makt-maktx,                    "Material Description
            mblnr    LIKE   mseg-mblnr,                    "Number of Material Document
            bldat    LIKE   mkpf-bldat,                    "Document Date in Document
            menge    LIKE   mseg-menge,                    "Quantity
            dmbtr    LIKE   mseg-dmbtr,                    "Amount in local currency
            cst_dmbtr LIKE  mseg-dmbtr,                    "CST Amount in local currency
            bwart    LIKE   mseg-bwart,                    "Movement Type (Inventory Management)
            whssn    LIKE   zeou_pcrdtl-whssn,             "Warehouse Records Entry Serial No.
            whsdt    LIKE   zeou_pcrdtl-whsdt,             "Warehouse Records Entry date
            buzid    LIKE   bseg-buzid,                    "Identification of the Line Item
            bschl    LIKE   bseg-bschl,                    "Posting Key
            wrbtr    LIKE   bseg-wrbtr,                    "Amount in document currency
            cst_wrbtr LIKE  bseg-wrbtr,                    "CST Amount in document currency
            belnr    LIKE   bseg-belnr,                    "Accounting Document Number
            gjahr    LIKE   bseg-gjahr,                    "Fiscal Year
            xblnr    LIKE   bkpf-xblnr,                    "Reference Document Number
            koart    LIKE   bseg-koart,                    "Account type
            augbl    LIKE   bseg-augbl,                    "Document Number of the Clearing Document
            vblnr    LIKE   payr-vblnr,                    "Document Number of the Payment Document
            zbukr    LIKE   payr-zbukr,                    "Paying company code
            chect    LIKE   payr-chect,                    "Check Number
            zaldt    LIKE   payr-zaldt,                    "Probable Payment Date (Cash Discount 1 Due)
            hbkid    LIKE   payr-hbkid,                    "Short key for a house bank
            usr_txt1(20) TYPE c,
            usr_txt2(20) TYPE c,
            END      OF     gt_output.
    *Working Variables
    DATA : cst_gr  LIKE  mseg-dmbtr,
           cst_inv LIKE  bseg-wrbtr,
           usr_txt1(20) TYPE c,
           usr_txt2(20) TYPE c.
    START-OF-SELECTION.
    *Retreiving Data from a363 table for the given input
      SELECT  matnr
              lifnr
              werks
              kschl
              knumh
              FROM a363
              INTO TABLE a363_itab
              WHERE matnr IN s_matnr AND lifnr IN s_lifnr AND werks EQ p_werks AND kschl IN s_kschl.
    *rakesh ***************************
    SELECT  *
             FROM konp
             INTO CORRESPONDING FIELDS OF TABLE konp_itab
             FOR ALL ENTRIES IN a363_itab
             WHERE knumh EQ a363_itab-knumh.
      IF  a363_itab[] IS NOT INITIAL.
        SELECT knumh
               kbetr
               lifnr
               FROM konp INTO TABLE konp_itab
               FOR ALL ENTRIES IN a363_itab
               WHERE knumh EQ a363_itab-knumh.
      ENDIF.
      LOOP AT a363_itab.
        READ TABLE konp_itab WITH KEY knumh = a363_itab-knumh.
        IF sy-subrc EQ 0.
          MOVE : konp_itab-kbetr TO a363_itab-kbetr.
          MODIFY a363_itab.
        ENDIF.
        CLEAR : a363_itab, konp_itab.
      ENDLOOP.
    rakesh****************************
    SELECT *
            FROM makt
            INTO CORRESPONDING FIELDS OF TABLE mat_desc
            FOR ALL ENTRIES IN a363_itab
            WHERE matnr EQ a363_itab-matnr.
      SELECT matnr
             maktx
             FROM makt INTO TABLE mat_desc
             FOR ALL ENTRIES IN a363_itab
             WHERE matnr EQ a363_itab-matnr.
      SELECT a~lifnr
             a~name1
             b~j_1icstno
             INTO TABLE vend_det
             FROM lfa1 AS a JOIN j_1imovend AS b
             ON alifnr EQ blifnr
             FOR ALL ENTRIES IN a363_itab
             WHERE a~lifnr EQ a363_itab-lifnr.
    Retreiving Data from EKKO & EKPO table for the given input
    And Populating the V_PO_DETAILS itab
    SELECT  *
             FROM ekko
             INTO CORRESPONDING FIELDS OF TABLE ekko_itab
             FOR ALL ENTRIES IN a363_itab
             WHERE lifnr EQ a363_itab-lifnr AND bedat IN s_bedat.
      IF  a363_itab[] IS NOT INITIAL.
        SELECT ebeln
               lifnr
               bedat
               FROM ekko INTO TABLE ekko_itab
               FOR ALL ENTRIES IN a363_itab
                WHERE lifnr EQ a363_itab-lifnr AND bedat IN s_bedat.
      ENDIF.
    SELECT  *
             FROM ekpo
             INTO CORRESPONDING FIELDS OF TABLE ekpo_itab
             FOR ALL ENTRIES IN a363_itab
             WHERE matnr EQ a363_itab-matnr AND werks EQ a363_itab-werks AND mwskz NE 'V0'.
      IF  a363_itab[] IS NOT INITIAL.
        SELECT ebeln
               ebelp
               matnr
               werks
               menge
               FROM ekpo INTO TABLE ekpo_itab
               FOR ALL ENTRIES IN a363_itab
               WHERE matnr EQ a363_itab-matnr AND werks EQ a363_itab-werks AND mwskz NE 'V0'.
      ENDIF.
      LOOP AT ekpo_itab.
        MOVE :   ekpo_itab-ebelp TO v_po_det-ebelp,
                 ekpo_itab-matnr TO v_po_det-matnr,
                 ekpo_itab-werks TO v_po_det-werks,
                 ekpo_itab-menge TO v_po_det-menge.
        READ TABLE ekko_itab WITH KEY ebeln = ekpo_itab-ebeln.
        IF sy-subrc EQ 0.
          MOVE  :  ekko_itab-lifnr TO v_po_det-lifnr,
                   ekko_itab-ebeln TO v_po_det-ebeln,
                   ekko_itab-bedat TO v_po_det-bedat.
          APPEND : v_po_det.
        ENDIF.
        CLEAR  : ekko_itab, ekpo_itab, v_po_det.
      ENDLOOP.
      LOOP AT v_po_det.
        READ TABLE a363_itab WITH KEY matnr = v_po_det-matnr lifnr = v_po_det-lifnr werks = v_po_det-werks.
        IF sy-subrc EQ 0.
          MOVE : a363_itab-kbetr TO v_po_det-kbetr.
          MODIFY v_po_det.
        ENDIF.
        CLEAR : a363_itab, v_po_det.
      ENDLOOP.
    Retreiving Data from MKPF & MSEG & ZEOU_PCRDTL table for the given input
    And Populating the GR_WH_info itab
    SELECT  *
             FROM mseg
             INTO CORRESPONDING FIELDS OF TABLE mseg_itab
             FOR ALL ENTRIES IN v_po_det
             WHERE ebeln EQ v_po_det-ebeln AND matnr EQ v_po_det-matnr AND bwart IN s_bwart.
      IF v_po_det[] IS NOT INITIAL.
        SELECT mblnr
               ebeln
               ebelp
               matnr
               lifnr
               werks
               menge
               dmbtr
               bwart
               FROM mseg INTO TABLE mseg_itab
               FOR ALL ENTRIES IN v_po_det
               WHERE ebeln EQ v_po_det-ebeln AND matnr EQ v_po_det-matnr AND bwart IN s_bwart.
      ENDIF.
      IF mseg_itab[] IS NOT INITIAL.
    SELECT  *
             FROM mkpf
             INTO CORRESPONDING FIELDS OF TABLE mkpf_itab
             FOR ALL ENTRIES IN mseg_itab
             WHERE mblnr EQ mseg_itab-mblnr.
        SELECT  mblnr
                bldat
                FROM mkpf INTO TABLE mkpf_itab
                FOR ALL ENTRIES IN mseg_itab
                WHERE mblnr EQ mseg_itab-mblnr.
      SELECT  *
             FROM zeou_pcrdtl
             INTO CORRESPONDING FIELDS OF TABLE zeou_pcrdtl_itab
             FOR ALL ENTRIES IN mseg_itab
             WHERE mblnr EQ mseg_itab-mblnr AND matnr EQ mseg_itab-matnr.
        SELECT matnr
               lifnr
               mblnr
               whssn
               whsdt
               FROM zeou_pcrdtl INTO TABLE zeou_pcrdtl_itab
                 FOR ALL ENTRIES IN mseg_itab
                 WHERE mblnr EQ mseg_itab-mblnr AND matnr EQ mseg_itab-matnr.
      ENDIF.
      LOOP AT mseg_itab.
        MOVE  :  mseg_itab-mblnr TO gr_wh_info-mblnr,
                 mseg_itab-ebeln TO gr_wh_info-ebeln,
                 mseg_itab-ebelp TO gr_wh_info-ebelp,
                 mseg_itab-matnr TO gr_wh_info-matnr,
                 mseg_itab-lifnr TO gr_wh_info-lifnr,
                 mseg_itab-werks TO gr_wh_info-werks,
                 mseg_itab-menge TO gr_wh_info-menge,
                 mseg_itab-dmbtr TO gr_wh_info-dmbtr,
                 mseg_itab-bwart TO gr_wh_info-bwart.
        READ TABLE mkpf_itab WITH KEY mblnr = mseg_itab-mblnr.
        IF sy-subrc EQ 0.
          MOVE  :  mkpf_itab-bldat TO gr_wh_info-bldat.
        ENDIF.
        READ TABLE zeou_pcrdtl_itab WITH KEY mblnr = mseg_itab-mblnr.
        IF sy-subrc EQ 0.
          MOVE  :  zeou_pcrdtl_itab-whssn TO gr_wh_info-whssn,
                   zeou_pcrdtl_itab-whsdt TO gr_wh_info-whsdt.
        ENDIF.
        APPEND : gr_wh_info.
        CLEAR : mseg_itab, mkpf_itab, gr_wh_info.
      ENDLOOP.
    Retreiving Data from BSEG & BKPF table
    And Populating the Vendor Invoice Details
      IF v_po_det[] IS NOT INITIAL.
    SELECT  *
             FROM bseg
             INTO CORRESPONDING FIELDS OF TABLE bseg_itab
             FOR ALL ENTRIES IN v_po_det
             WHERE ebeln EQ v_po_det-ebeln AND matnr EQ v_po_det-matnr AND buzid EQ 'W' AND bschl EQ '96'.
        SELECT  ebeln
                ebelp
                matnr
                lifnr
                werks
                buzid
                bschl
                wrbtr
                bukrs
                belnr
                gjahr
                FROM bseg INTO TABLE bseg_itab
                  FOR ALL ENTRIES IN v_po_det
                  WHERE ebeln EQ v_po_det-ebeln AND matnr EQ v_po_det-matnr AND buzid EQ 'W' AND bschl EQ '96'.
      ENDIF.
      IF bseg_itab[] IS NOT INITIAL.
    SELECT  *
             FROM bkpf
             INTO CORRESPONDING FIELDS OF TABLE bkpf_itab
             FOR ALL ENTRIES IN bseg_itab
             WHERE bukrs EQ bseg_itab-bukrs AND belnr EQ bseg_itab-belnr AND gjahr EQ bseg_itab-gjahr.
        SELECT  bukrs
                belnr
                gjahr
                xblnr
                bldat
                FROM bkpf INTO TABLE bkpf_itab
                FOR ALL ENTRIES IN bseg_itab
                WHERE bukrs EQ bseg_itab-bukrs AND belnr EQ bseg_itab-belnr AND gjahr EQ bseg_itab-gjahr.
      ENDIF.
      LOOP AT bseg_itab.
        MOVE  :  bseg_itab-ebeln TO vend_inv-ebeln,
                 bseg_itab-ebelp TO vend_inv-ebelp,
                 bseg_itab-matnr TO vend_inv-matnr,
                 bseg_itab-lifnr TO vend_inv-lifnr,
                 bseg_itab-werks TO vend_inv-werks,
                 bseg_itab-buzid TO vend_inv-buzid,
                 bseg_itab-bschl TO vend_inv-bschl,
                 bseg_itab-wrbtr TO vend_inv-wrbtr,
                 bseg_itab-bukrs TO vend_inv-bukrs,
                 bseg_itab-belnr TO vend_inv-belnr,
                 bseg_itab-gjahr TO vend_inv-gjahr.
        READ TABLE bkpf_itab WITH KEY bukrs = bseg_itab-bukrs belnr = bseg_itab-belnr gjahr = bseg_itab-gjahr.
        IF sy-subrc EQ 0.
          MOVE  :  bkpf_itab-xblnr TO vend_inv-xblnr,
                   bkpf_itab-bldat TO vend_inv-bldat.
          APPEND  :  vend_inv.
        ENDIF.
        CLEAR : vend_inv, bseg_itab, bkpf_itab.
      ENDLOOP.
    Retreiving Data from BSEG & BKPF table
    And Populating the Cheque Info Details
      IF v_po_det[] IS NOT INITIAL.
    SELECT  *
             FROM bseg
             INTO CORRESPONDING FIELDS OF TABLE chckinit
             FOR ALL ENTRIES IN v_po_det
             WHERE ebeln EQ v_po_det-ebeln AND matnr EQ v_po_det-matnr AND buzid EQ 'W' AND bschl EQ '86' AND koart EQ 'K'.
        SELECT  ebeln
                ebelp
                matnr
                lifnr
                werks
                buzid
                bschl
                bukrs
                belnr
                gjahr
                koart
                augbl
                FROM bseg INTO TABLE chckinit
                  FOR ALL ENTRIES IN v_po_det
                  WHERE ebeln EQ v_po_det-ebeln AND matnr EQ v_po_det-matnr AND buzid EQ 'W' AND bschl EQ '86' AND koart EQ 'K'.
      ENDIF.
      IF chckinit[] IS NOT INITIAL.
    SELECT  *
             FROM payr
             INTO CORRESPONDING FIELDS OF TABLE chckpayer
             FOR ALL ENTRIES IN chckinit
             WHERE vblnr EQ chckinit-augbl.
        SELECT  vblnr
                zbukr
                gjahr
                chect
                zaldt
                hbkid
                FROM payr INTO TABLE chckpayer
                FOR ALL ENTRIES IN chckinit
                WHERE vblnr EQ chckinit-augbl.
      ENDIF.
      SORT chckpayer BY vblnr DESCENDING.
      LOOP AT chckpayer.
        ON CHANGE OF chckpayer-vblnr.
          MOVE   : chckpayer TO chckpayer_u.
          APPEND : chckpayer_u.
          CLEAR  : chckpayer_u, chckpayer.
        ENDON.
      ENDLOOP.
      LOOP AT chckinit.
        MOVE  :  chckinit-ebeln TO chckfinal-ebeln,
                 chckinit-ebelp TO chckfinal-ebelp,
                 chckinit-matnr TO chckfinal-matnr,
                 chckinit-lifnr TO chckfinal-lifnr,
                 chckinit-werks TO chckfinal-werks,
                 chckinit-buzid TO chckfinal-buzid,
                 chckinit-bschl TO chckfinal-bschl,
                 chckinit-bukrs TO chckfinal-bukrs,
                 chckinit-gjahr TO chckfinal-gjahr,
                 chckinit-koart TO chckfinal-koart,
                 chckinit-augbl TO chckfinal-augbl.
        READ TABLE chckpayer_u WITH KEY vblnr = chckinit-augbl gjahr = chckinit-gjahr.
        IF sy-subrc EQ 0.
          MOVE  :  chckpayer_u-vblnr TO chckfinal-vblnr,
                   chckpayer_u-zbukr TO chckfinal-zbukr,
                   chckpayer_u-chect TO chckfinal-chect,
                   chckpayer_u-zaldt TO chckfinal-zaldt,
                   chckpayer_u-hbkid TO chckfinal-hbkid.
          APPEND : chckfinal.
        ENDIF.
        CLEAR : chckfinal, chckpayer_u, chckinit.
      ENDLOOP.
    Populating the final CST TABLE
      LOOP AT v_po_det.
        MOVE  :   v_po_det-lifnr TO cst_rep-lifnr,
                  v_po_det-werks TO cst_rep-werks,
                  v_po_det-ebeln TO cst_rep-ebeln,
                  v_po_det-ebelp TO cst_rep-ebelp,
                  v_po_det-bedat TO cst_rep-bedat,
                  v_po_det-matnr TO cst_rep-matnr,
                  v_po_det-kbetr TO cst_rep-kbetr.
        READ TABLE gr_wh_info WITH KEY ebeln = v_po_det-ebeln ebelp = v_po_det-ebelp."matnr = v_po_det-matnr.
        IF sy-subrc EQ 0.
          MOVE :  gr_wh_info-mblnr TO cst_rep-mblnr,
                  gr_wh_info-bldat TO cst_rep-bldat,
                  gr_wh_info-menge TO cst_rep-menge,
                  gr_wh_info-dmbtr TO cst_rep-dmbtr,
                  gr_wh_info-bwart TO cst_rep-bwart,
                  gr_wh_info-whssn TO cst_rep-whssn,
                  gr_wh_info-whsdt TO cst_rep-whsdt.
        ENDIF.
        READ TABLE vend_inv WITH KEY ebeln = v_po_det-ebeln ebelp = v_po_det-ebelp."matnr = v_po_det-matnr.
        IF sy-subrc EQ 0.
          MOVE : vend_inv-buzid TO cst_rep-buzid,
                 vend_inv-bschl TO cst_rep-bschl,
                 vend_inv-wrbtr TO cst_rep-wrbtr,
                 vend_inv-belnr TO cst_rep-belnr,
                 vend_inv-gjahr TO cst_rep-gjahr,
                 vend_inv-xblnr TO cst_rep-xblnr.
        ENDIF.
        READ TABLE chckfinal WITH KEY ebeln = v_po_det-ebeln ebelp = v_po_det-ebelp."matnr = v_po_det-matnr.
        IF sy-subrc EQ 0.
          MOVE : chckfinal-augbl TO cst_rep-augbl,
                 chckfinal-vblnr TO cst_rep-vblnr,
                 chckfinal-zbukr TO cst_rep-zbukr,
                 chckfinal-chect TO cst_rep-chect,
                 chckfinal-zaldt TO cst_rep-zaldt,
                 chckfinal-hbkid TO cst_rep-hbkid.
        ENDIF.
        READ TABLE mat_desc WITH KEY matnr = v_po_det-matnr.
        IF sy-subrc EQ 0.
          MOVE : mat_desc-maktx TO cst_rep-maktx.
        ENDIF.
        READ TABLE vend_det WITH KEY lifnr = v_po_det-lifnr.
        IF sy-subrc EQ 0.
          MOVE : vend_det-name1 TO cst_rep-name1,
                 vend_det-j_1icstno TO cst_rep-j_1icstno.
        ENDIF.
        APPEND : cst_rep.
        CLEAR  : cst_rep, v_po_det, gr_wh_info, vend_inv, chckfinal.
      ENDLOOP.
    Populating GT_output
      LOOP AT cst_rep.
        cst_gr = cst_rep-dmbtr * ( cst_rep-kbetr / 1000 ).
        cst_inv = cst_rep-wrbtr * ( cst_rep-kbetr / 1000 ).
        MOVE : cst_gr  TO cst_rep-cst_dmbtr,
               cst_inv TO cst_rep-cst_wrbtr.
        MODIFY : cst_rep.
        CLEAR : cst_rep, cst_gr, cst_inv.
      ENDLOOP.
      LOOP AT cst_rep.
        MOVE :  sy-tabix TO gt_output-slno,
                cst_rep-lifnr TO gt_output-lifnr,
                cst_rep-name1 TO gt_output-name1,
                cst_rep-j_1icstno TO gt_output-j_1icstno,
                cst_rep-werks TO gt_output-werks,
                cst_rep-matnr TO gt_output-matnr,
                cst_rep-maktx TO gt_output-maktx,
                cst_rep-ebeln TO gt_output-ebeln,
                cst_rep-ebelp TO gt_output-ebelp,
                cst_rep-bedat TO gt_output-bedat,
                cst_rep-mblnr TO gt_output-mblnr,
                cst_rep-bldat TO gt_output-bldat,
                cst_rep-menge TO gt_output-menge,
                cst_rep-dmbtr TO gt_output-dmbtr,
                cst_rep-cst_dmbtr TO gt_output-cst_dmbtr,
                cst_rep-bwart TO gt_output-bwart,
                cst_rep-whssn TO gt_output-whssn,
                cst_rep-whsdt TO gt_output-whsdt,
                cst_rep-buzid TO gt_output-buzid,
                cst_rep-bschl TO gt_output-bschl,
                cst_rep-wrbtr TO gt_output-wrbtr,
                cst_rep-cst_wrbtr TO gt_output-cst_wrbtr,
                cst_rep-belnr TO gt_output-belnr,
                cst_rep-gjahr TO gt_output-gjahr,
                cst_rep-xblnr TO gt_output-xblnr,
                cst_rep-augbl TO gt_output-augbl,
                cst_rep-vblnr TO gt_output-vblnr,
                cst_rep-zbukr TO gt_output-zbukr,
                cst_rep-chect TO gt_output-chect,
                cst_rep-zaldt TO gt_output-zaldt,
                cst_rep-hbkid TO gt_output-hbkid.
        APPEND gt_output.
        CLEAR : cst_rep, gt_output, sy-tabix.
      ENDLOOP.
    END-OF-SELECTION.
    *-ALV Routine
      PERFORM alv_forms.
    *&      Form  alv_forms
    FORM alv_forms.
      PERFORM alv_routines.
      gx_variant = sy-repid.
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save     = g_save
        CHANGING
          cs_variant = gx_variant
        EXCEPTIONS
          not_found  = 2.
      IF sy-subrc = 0.
        vari = gx_variant-variant.
      ENDIF.
      PERFORM comment_build  USING gt_list_top_of_page[].
      PERFORM fieldcat_init  USING gt_fieldcat[].
      PERFORM layout_build USING gs_layout.
      PERFORM print_build  USING gs_print.
      PERFORM alv_output.
    ENDFORM.                    " alv_forms
    *&      Form  alv_routines
    FORM alv_routines.
      PERFORM eventtab_build USING gt_events[].
      PERFORM e06_t_sort_build  USING gt_sort[].
      PERFORM sp_group_build USING gt_sp_group[].
      g_save = 'A'.
      PERFORM variant_init.
    ENDFORM.                    " alv_routines
    *&      Form  eventtab_build
    ----

    Hi Anu,
    These two statements taking to much time for execution what I can do for reducing execution time.
    Regards,
    Rakesh
    SELECT ebeln
    ebelp
    matnr
    lifnr
    werks
    buzid
    bschl
    wrbtr
    bukrs
    belnr
    gjahr
    FROM bseg INTO TABLE bseg_itab
    FOR ALL ENTRIES IN v_po_det
    WHERE ebeln EQ v_po_det-ebeln AND matnr EQ v_po_det-matnr AND buzid EQ 'W' AND bschl EQ '96'.
    ENDIF.
    SELECT ebeln
    ebelp
    matnr
    lifnr
    werks
    buzid
    bschl
    bukrs
    belnr
    gjahr
    koart
    augbl
    FROM bseg INTO TABLE chckinit
    FOR ALL ENTRIES IN v_po_det
    WHERE ebeln EQ v_po_det-ebeln AND matnr EQ v_po_det-matnr AND buzid EQ 'W' AND bschl EQ '86' AND koart EQ 'K'.
    ENDIF.

  • Purchase Order condition isn't calculating the value of refundable tax

    Hello Experts,
                          When i am inputting tax in invoice tab at item level footer in Purchase Order, and after that when i am calculating the taxable and the total amount the condition tab isn't displaying the tax value, the condition type is NAVS of tax in condition tab. Kindly suggest me i want to calculate tax.
    Thanks
    Harmandeep

    Hi flora
    Just get through the sequence .
    see the table fields ...
    1. From EKKO table take an entry which is having pricing conditions.
    Now in the fields list check out for field EKKO-KNUMV(document condition number).
    2.Take this condition number and now goto table KONV.
    Give the document condition number in the field  KONV-KNUMV and execute .
    This will lead to a list of document condition numbers and some other fields .
    3.Now check for field KONV-KNUMH ,KONV-KAWRT(quantity) and note the value KONV-KWERT  .
    (Remember this is at header level).
    This is ur condition record number.
    **comments
    Now from document condition number we got the condition record number (KNUMH).
    4. now since u want the item level tax procedure go to table KONP and give the condition record number and execute .
    This will give u a list of details .
    Now concentrate on KONV-KAWRT (scale quantity) KONP-KBETR(rate) as this table will store “Pricing  per UNIT “ so product of these two will give u the total pricing tax, for a particular condition type say PR00  .
    For that particular condition item .
    Check the pricing procedure .
    See t-code VK13 and check the pricing procedure .
    From me23 check the same PO num select the item and check the pricing conditions applicable .
    Select a particular pricing and goto condition->analysis->analysis pricing  ,
    Better take help of a SD functional consultant in the process.
    regards,
    vijay.

  • Retrieve the Purchase Order Condition Records Table

    Hallo!
    I have found this code right here:
    http://www.sap-basis-abap.com/sapab025.htm
    It is very useful particular for purposes which I need. Please can somebody
    try to fix the error to get it working. There is an internal table missing.
    Regards
    Ilhan
    Retrieve the Purchase Order Condition Records Table
    select * from ekko.
           select * from konv where knumv = ekko-knumv
               "Get all the condition records for the purchase order
           endselect.
    endselect.
    * Get the info record conditions record
    * First declare the record structure for the key
    data: begin of int_konp,
                 txt1(5),
                 lifnr(5),
                 matnr(18),
                 txt2(4),
                 txt3(1),
            end of int_konp.
    clear: konh, konp, int_konp.
    * data for the record key konh-vakey
    int_konp-txt1    = '00000'.
    int_konp-lifnr    = ekko-lifnr+5(5).
    int_konp-matnr = ekpo-matnr(18).
    int_konp-txt2    = 'ALL'.
    int_konp-werks = ekpo-werks.
    int_konp-txt3    = '0'.
    select * from konh where      kschl = 'PB00'            "Conditions (Header)
                                         and datab => p_datum.       "valid from date
          if konh-vakey = int_konp.                                  "Conditions (Item)
                 select single * from konp where knumh = konh-knumh.
                 continue.
          endif.
    endselect.

    Hi flora
    Just get through the sequence .
    see the table fields ...
    1. From EKKO table take an entry which is having pricing conditions.
    Now in the fields list check out for field EKKO-KNUMV(document condition number).
    2.Take this condition number and now goto table KONV.
    Give the document condition number in the field  KONV-KNUMV and execute .
    This will lead to a list of document condition numbers and some other fields .
    3.Now check for field KONV-KNUMH ,KONV-KAWRT(quantity) and note the value KONV-KWERT  .
    (Remember this is at header level).
    This is ur condition record number.
    **comments
    Now from document condition number we got the condition record number (KNUMH).
    4. now since u want the item level tax procedure go to table KONP and give the condition record number and execute .
    This will give u a list of details .
    Now concentrate on KONV-KAWRT (scale quantity) KONP-KBETR(rate) as this table will store “Pricing  per UNIT “ so product of these two will give u the total pricing tax, for a particular condition type say PR00  .
    For that particular condition item .
    Check the pricing procedure .
    See t-code VK13 and check the pricing procedure .
    From me23 check the same PO num select the item and check the pricing conditions applicable .
    Select a particular pricing and goto condition->analysis->analysis pricing  ,
    Better take help of a SD functional consultant in the process.
    regards,
    vijay.

  • Retrieve the Purchase Order *TAX* Condition Records

    Hi,
    Tcode : ME23n
    Area  : Item
    Tab   : Invoice Tab in Item
    On clicking the button <b>taxes</b>  I can see different condition attached in the tax code. These taxes are available in KONH KONP table and the related Axxx table, (in my case A003 table).
    My Question is:
    2) How to find  Cond.record no. ( KONH-KNUMH) on the basis of EBELn that is PO number. I am able to see Cond.record no. from konv table for all the conditions applied on the item directly, but can not see for tax realted conditions, though on debugging I got the KONH-KNUMH and can see the realted data.
    <b>But how to find KONH-KNUMH on the basis of Ebeln</b>
    1) KONP table has KBETR but not kwert, so how can i find the <b>Condition Value</b>
    Let me know if there is any gaps in my problem statement.

    Hi flora
    Just get through the sequence .
    see the table fields ...
    1. From EKKO table take an entry which is having pricing conditions.
    Now in the fields list check out for field EKKO-KNUMV(document condition number).
    2.Take this condition number and now goto table KONV.
    Give the document condition number in the field  KONV-KNUMV and execute .
    This will lead to a list of document condition numbers and some other fields .
    3.Now check for field KONV-KNUMH ,KONV-KAWRT(quantity) and note the value KONV-KWERT  .
    (Remember this is at header level).
    This is ur condition record number.
    **comments
    Now from document condition number we got the condition record number (KNUMH).
    4. now since u want the item level tax procedure go to table KONP and give the condition record number and execute .
    This will give u a list of details .
    Now concentrate on KONV-KAWRT (scale quantity) KONP-KBETR(rate) as this table will store “Pricing  per UNIT “ so product of these two will give u the total pricing tax, for a particular condition type say PR00  .
    For that particular condition item .
    Check the pricing procedure .
    See t-code VK13 and check the pricing procedure .
    From me23 check the same PO num select the item and check the pricing conditions applicable .
    Select a particular pricing and goto condition->analysis->analysis pricing  ,
    Better take help of a SD functional consultant in the process.
    regards,
    vijay.

Maybe you are looking for

  • Cannot install adobe photoshop cs6 extended

    on opening the cd , there...is no    setup exe file on the software.    how do i install this software on my computer ?

  • Bridge/Photoshop hiding buttons

    I have CS4 on Vista and just got a new laptop which has Windows 7 and just got CS5. 7 is a little different than Vista, so bare with me here... I shoot my images in RAW, so when I put them on here, they go into Bridge. Once downloaded, I can click on

  • IPod (5th gen?) keeps crashing iTunes

    Hi there. I'm trying to restore my iPod. At first, it kept crashing iTunes when I connected it to my computer so I couldn't even restore. I rebooted and was able to restore but it crashed iTunes during syncing. Now it keeps crashing iTunes when I res

  • Hide / unhide iviews in page

    Hello, I have successfully created an GP Process and implemented the call of the process by copying the inst application and entering the needed properties. Yet then I wanted to explore some other CE "features" and unfortunately hid the main iview, w

  • Igital Signature in PO

    Hi, We have Digital signature for Form16 in SAP. Same way does SAP supports Digital Sign in PO and if so please provide me a link where i can find info on how to do it. I searched in forums but i couldn't get exact info on this. Please guide me. With