Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

*&---------------------------------------------------------------------*
*& Report  ZPRICECOND
*  AUTHOR........ Aveek Ghose
*  DATE WRITTEN.. 15/09/2006
*  R/3 RELEASE... 4.6C
*&---------------------------------------------------------------------*

REPORT  ZPRICECOND MESSAGE-ID ZTRV.

CONSTANTS:
c_yes    TYPE c        VALUE 'X',
c_no     TYPE c        VALUE space,
c_screen TYPE sydynnr  VALUE '9000',       "Screen for ALV Report
c_back   TYPE sy-ucomm VALUE '&F03',       "Function Code BACK
c_up     TYPE sy-ucomm VALUE '&F15',       "Function Code ABBA
c_exit   TYPE sy-ucomm VALUE '&F12',       "Function Code BABA
c_session_manager TYPE sy-tcode VALUE 'SESSION_MANAGER',
c_save TYPE c VALUE 'A',                          "Save
c_structure TYPE tabname VALUE 'TY_CONDTN_REP',   "Structure for Report
c_relid     TYPE relid   VALUE 'LT',       "Customer specific variants
c_kappl_v   TYPE kappl VALUE 'V',          "Application
c_kvewe_a   TYPE kvewe VALUE 'A',          "Usage for General Pricing
c_kvewe_n   TYPE kvewe VALUE 'N',          "Usage for Free Goods
c_pricing_a TYPE c     VALUE 'A',          "Pricing Table starting with
c_kote(4)   TYPE c     VALUE 'KOTE',       "Rebate Table starting with
c_kotn(4)   TYPE c     VALUE 'KOTN',       "Free Goods Table starting
c_sign_i    TYPE c     VALUE 'I',          "Sign for Including
c_option_eq(2) TYPE c  VALUE 'EQ',         "Option Equal To
c_option_le(2) TYPE c  VALUE 'LE',         "Option Less than equal to
c_option_ge(2) TYPE c  VALUE 'GE',         "Option Greater than equal to
c_actvt(5)  TYPE c     VALUE 'ACTVT',      "Activity for authorization
c_disp_03(2) TYPE c    VALUE '03',         "Display
c_koaid_c   TYPE koaid VALUE 'C',          "Rebate
* c_sys_type  TYPE /glb/rgtcw_system_type VALUE 'C', "CRM System
c_vbak_vko(10) TYPE c VALUE 'V_VBAK_VKO',  "Authority Object V_VBAK_VKO
c_spart     TYPE fieldname VALUE 'SPART',  "Division
c_and(3)    TYPE c     VALUE 'AND',        "Constant for AND
c_eng       TYPE sylangu VALUE 'E',        "English Language
c_i_condtn_rep TYPE char30 VALUE 'I_CONDTN_REP',
c_gui_status   TYPE char20 VALUE '/EUR/GUI_PRIC_REP',
c_titlebar     TYPE sy-title VALUE '/EUR/TITLE_PRICE_REP',
*** Constants for Selection field names ***
c_vkorg_low(12) TYPE c VALUE 'S_VKORG-LOW',
c_vtweg_low(12) TYPE c VALUE 'S_VTWEG-LOW',
c_vtweg_high(13) TYPE c VALUE 'S_VTWEG-HIGH',
c_kschl_low(12) TYPE c VALUE 'S_KSCHL-LOW',
c_kschl_high(13) TYPE c VALUE 'S_KSCHL-HIGH',
c_campid_low(12) TYPE c VALUE 'S_CAMPID-LOW',
c_campid_high(13) TYPE c VALUE 'S_CAMPID-HIGH',
c_kunnr_low(12) TYPE c VALUE 'S_KUNNR-LOW',
c_kunnr_high(13) TYPE c VALUE 'S_KUNNR-HIGH',
c_hienr_low(12) TYPE c VALUE 'S_HIENR-LOW',
c_hienr_high(13) TYPE c VALUE 'S_HIENR-HIGH',
c_konda_low(12) TYPE c VALUE 'S_KONDA-LOW',
c_konda_high(13) TYPE c VALUE 'S_KONDA-HIGH',
c_matnr_low(12) TYPE c VALUE 'S_MATNR-LOW',
c_matnr_high(13) TYPE c VALUE 'S_MATNR-HIGH',
c_mvgr1_low(12) TYPE c VALUE 'S_MVGR1-LOW',
c_mvgr1_high(13) TYPE c VALUE 'S_MVGR1-HIGH',
c_prodh1_low(12) TYPE c VALUE 'S_PRODH1-LOW',
c_prodh1_high(13) TYPE c VALUE 'S_PRODH1-HIGH',
c_prodh2_low(12) TYPE c VALUE 'S_PRODH2-LOW',
c_prodh2_high(13) TYPE c VALUE 'S_PRODH2-HIGH',
c_prodh3_low(12) TYPE c VALUE 'S_PRODH3-LOW',
c_prodh3_high(13) TYPE c VALUE 'S_PRODH3-HIGH',
c_prodh4_low(12) TYPE c VALUE 'S_PRODH4-LOW',
c_prodh4_high(13) TYPE c VALUE 'S_PRODH4-HIGH',
c_prodh5_low(12) TYPE c VALUE 'S_PRODH5-LOW',
c_prodh5_high(13) TYPE c VALUE 'S_PRODH5-HIGH',
c_loevm_low(12) TYPE c VALUE 'S_LOEVM-LOW',
c_loevm_high(13) TYPE c VALUE 'S_LOEVM-HIGH',
c_bonem_low(12) TYPE c VALUE 'S_BONEM-LOW',
c_bonem_high(13) TYPE c VALUE 'S_BONEM-HIGH',
c_bosta_low(12) TYPE c VALUE 'S_BOSTA-LOW',
c_bosta_high(13) TYPE c VALUE 'S_BOSTA-HIGH',
c_cdatab(8) TYPE c VALUE 'P_CDATAB',
c_cdatbi(8) TYPE c VALUE 'P_CDATBI',
c_crmsys(8) TYPE c VALUE 'P_CRMSYS',
*** Constants for fieldnames ***
c_knumh     TYPE fieldname VALUE 'KNUMH',
c_kschl     TYPE fieldname VALUE 'KSCHL',
c_cvtext    TYPE fieldname VALUE 'CVTEXT',
c_kunnr     TYPE fieldname VALUE 'KUNNR',
c_name1     TYPE fieldname VALUE 'NAME1',
c_hienr     TYPE fieldname VALUE 'HIENR',
c_name1_c   TYPE fieldname VALUE 'NAME1_C',
c_konda     TYPE fieldname VALUE 'KONDA',
c_pvtext    TYPE fieldname VALUE 'PVTEXT',
c_matnr     TYPE fieldname VALUE 'MATNR',
c_maktx     TYPE fieldname VALUE 'MAKTX',
c_mvgr1     TYPE fieldname VALUE 'MVGR1',
c_mbezei    TYPE fieldname VALUE 'MBEZEI',
c_prodh1     TYPE fieldname VALUE 'PRODH1',
c_prodh2     TYPE fieldname VALUE 'PRODH2',
c_prodh3     TYPE fieldname VALUE 'PRODH3',
c_yyprodh4     TYPE fieldname VALUE 'YYPRODH4',
c_yyprodh5     TYPE fieldname VALUE 'YYPRODH5',
c_cmpgn_id  TYPE fieldname VALUE 'CMPGN_ID',
c_external_id TYPE fieldname VALUE 'EXTERNAL_ID',
c_kbetr     TYPE fieldname VALUE 'KBETR',
c_konwa     TYPE fieldname VALUE 'KONWA',
c_kpein     TYPE fieldname VALUE 'KPEIN',
c_kmein     TYPE fieldname VALUE 'KMEIN',
c_datab     TYPE fieldname VALUE 'DATAB',
c_datbi     TYPE fieldname VALUE 'DATBI',
c_kbrue     TYPE fieldname VALUE 'KBRUE',
c_kwaeh     TYPE fieldname VALUE 'KWAEH',
c_loevm_ko     TYPE fieldname VALUE 'LOEVM_KO',
c_kznep     TYPE fieldname VALUE 'KZNEP',
c_knuma     TYPE fieldname VALUE 'KNUMA',
c_boart     TYPE fieldname VALUE 'BOART',
c_rvtext     TYPE fieldname VALUE 'RVTEXT',
c_bon_enh_vakey TYPE fieldname VALUE 'BON_ENH_VAKEY',
c_bon_enh_indirect     TYPE fieldname VALUE 'BON_ENH_INDIRECT',
c_ksape     TYPE fieldname VALUE 'KSPAE',
c_bonem     TYPE fieldname VALUE 'BONEM',
c_waers     TYPE fieldname VALUE 'WAERS',
c_zlsch     TYPE fieldname VALUE 'ZLSCH',
c_abrex     TYPE fieldname VALUE 'ABREX',
c_rdatab     TYPE fieldname VALUE 'RDATAB',
c_rdatbi     TYPE fieldname VALUE 'RDATBI',
c_bosta     TYPE fieldname VALUE 'BOSTA',
c_rrwrt     TYPE fieldname VALUE 'RRWRT',
c_auwrt     TYPE fieldname VALUE 'AUWRT',
c_mpwrt     TYPE fieldname VALUE 'MPWRT',
c_bzwrt     TYPE fieldname VALUE 'BZWRT',
c_vkorg     TYPE fieldname VALUE 'VKORG',
c_vtweg     TYPE fieldname VALUE 'VTWEG',
c_vkbur     TYPE fieldname VALUE 'VKBUR',
c_vkgrp     TYPE fieldname VALUE 'VKGRP',
c_cernam    TYPE fieldname VALUE 'CERNAM',
c_cerdat     TYPE fieldname VALUE 'CERDAT',
c_krech     TYPE fieldname VALUE 'KRECH',
c_kstbw     TYPE fieldname VALUE 'KSTBW',
c_kzbzg     TYPE fieldname VALUE 'KZBZG',
c_stfkz     TYPE fieldname VALUE 'STFKZ',
c_kstbm1    TYPE fieldname VALUE 'KSTBM1',
c_kstbm2    TYPE fieldname VALUE 'KSTBM2',
c_kstbm3    TYPE fieldname VALUE 'KSTBM3',
c_kstbm4    TYPE fieldname VALUE 'KSTBM4',
c_kstbm5    TYPE fieldname VALUE 'KSTBM5',
c_kstbm6    TYPE fieldname VALUE 'KSTBM6',
c_kstbm7    TYPE fieldname VALUE 'KSTBM7',
c_kstbm8    TYPE fieldname VALUE 'KSTBM8',
c_kstbm9    TYPE fieldname VALUE 'KSTBM9',
c_kstbm10    TYPE fieldname VALUE 'KSTBM10',
c_kbetr1    TYPE fieldname VALUE 'KBETR1',
c_kbetr2    TYPE fieldname VALUE 'KBETR2',
c_kbetr3    TYPE fieldname VALUE 'KBETR3',
c_kbetr4    TYPE fieldname VALUE 'KBETR4',
c_kbetr5    TYPE fieldname VALUE 'KBETR5',
c_kbetr6    TYPE fieldname VALUE 'KBETR6',
c_kbetr7    TYPE fieldname VALUE 'KBETR7',
c_kbetr8    TYPE fieldname VALUE 'KBETR8',
c_kbetr9    TYPE fieldname VALUE 'KBETR9',
c_kbetr10    TYPE fieldname VALUE 'KBETR10',
c_mxwrt    TYPE fieldname VALUE 'MXWRT',
c_gkwrt    TYPE fieldname VALUE 'GKWRT',
c_kvewe     TYPE fieldname VALUE 'KVEWE',
c_kappl     TYPE fieldname VALUE 'KAPPL',
c_ernam     TYPE fieldname VALUE 'ERNAM',
c_erdat     TYPE fieldname VALUE 'ERDAT',
c_erzet     TYPE fieldname VALUE 'ERZET',
c_aenam     TYPE fieldname VALUE 'AENAM',
c_aedat     TYPE fieldname VALUE 'AEDAT',
c_aezet     TYPE fieldname VALUE 'AEZET',
c_bomat     TYPE fieldname VALUE 'BOMAT',
c_botext     TYPE fieldname VALUE 'BOTEXT',
c_abspz     TYPE fieldname VALUE 'ABSPZ',
c_kobog    TYPE fieldname VALUE 'KOBOG',
c_knrmm     TYPE fieldname VALUE 'KNRMM',
c_knrnm     TYPE fieldname VALUE 'KNRNM',
c_knrme     TYPE fieldname VALUE 'KNRME',
c_knrzm     TYPE fieldname VALUE 'KNRZM',
c_knrez     TYPE fieldname VALUE 'KNREZ',
c_fgpcr     TYPE fieldname VALUE 'FGPCR',
c_knrrr     TYPE fieldname VALUE 'KNRRR',
c_knrdd     TYPE fieldname VALUE 'KNRDD',
c_lstanr    TYPE fieldname VALUE 'LSTANR',
c_ddtext    TYPE fieldname VALUE 'DDTEXT',
c_knrmat     TYPE fieldname VALUE 'KNRMAT',
c_fmaktx    TYPE fieldname VALUE 'FMAKTX'.

************************************************************************
*                         TYPE DECLARATION                             *
************************************************************************

* Type declaration for the report output
TYPES: BEGIN OF ty_condtn_rep,
kschl TYPE kscha,      "Condition Type
cvtext TYPE vtxtk,     "Condition Type Description
kunnr TYPE kunnr,      "Sold To Number
name1 TYPE name1_gp,   "Sold To Name
hienr TYPE kunnr_kh,   "Customer Hierarchy Number
name1_c TYPE name1_gp, "Customer Hierarchy Name
konda TYPE konda,      "Price Group Name
pvtext TYPE bezei20,   "Price Group Description
matnr TYPE matnr,      "Material Number
maktx TYPE maktx,      "Material Description
mvgr1 TYPE mvgr1,      "Material Group 1
mbezei TYPE bezei40,   "Material Group 1 Description
*prodh1 TYPE /glb/prodh1,    "ProdH 1 - Business
*prodh2 TYPE /glb/prodh2,    "ProdH 2 â€" Business ID
*prodh3 TYPE /glb/prodh3,    "ProdH 3 - Category
*yyprodh4 TYPE /glb/prodh4,  "ProdH 4 â€" Sub-Categ
*yyprodh5 TYPE /glb/prodh5,  "ProdH 5 â€" Seg/Sub Seg
cmpgn_id TYPE cmpgn_id_r3,  "Campaign ID
external_id TYPE cgpl_extid, "Campaign (External ID)
kbetr TYPE kbetr_kond,      "Condition Amount
konwa TYPE konwa,           "Condition Unit
kpein TYPE kpein,           "Condition Pricing Unit
kmein TYPE kmein,      "Condition Unit of Measure
datab TYPE datab,      "Condition Valid On
datbi TYPE datbi,      "Condition Valid To
kbrue TYPE kbrue,      "Condition Accrual Amount - Rebate
kwaeh TYPE kwaeh,      "Condition Accrual Unit - Rebate
loevm_ko TYPE loevm_ko,  "Condition Deletion Indicator
kznep TYPE kznep,        "Condition Exclusive Indicator
knuma TYPE knuma,        "Rebate Agreement Number
boart TYPE boart,        "Rebate Agreement Type
rvtext TYPE vtext,       "Rebate Agreement Type Description
bon_enh_vakey TYPE bon_enh_vakey,  "Enhanced Rebate Indicator
bon_enh_indirect TYPE bon_enh_indirect, "Indir Setlmnt Types Indicator
kspae TYPE kspae,  "Rebate Retroactive Indicator
bonem TYPE bonem,  "Rebate Recipient
waers TYPE waers,  "Rebate Currency
zlsch TYPE dzlsch, "Rebate Payment Method
abrex TYPE abrex,  "Rebate External Description
rdatab TYPE abdatab,  "Rebate Agreement Valid From
rdatbi TYPE abdatbi,  "Rebate Agreement Valid To
bosta TYPE bosta,    "Rebate Agreement Status
ruwrt TYPE mc_rukwt,  "Rebate Accruals
rrwrt TYPE mc_rrkwt,  "Rebate Accruals Reversed
auwrt TYPE mc_auwrt,  "Rebate Payments
mpwrt TYPE mc_mpwrt,  "Rebate: Maximum payable amount
bzwrt TYPE mc_bzwrt,  "Rebate: Amount to be paid
vkorg TYPE vkorg,    "Sales Organization
vtweg TYPE vtweg,    "Distribution Channel
vkbur TYPE vkbur,    "Sales Office
vkgrp TYPE vkgrp,    "Sales Group
cernam TYPE ernam,   "Condition Created By
cerdat TYPE erdat,   "Condition Created on Date
krech TYPE krech,    "Condition Calculation Type
kstbw TYPE kstbw,    "Condition Scales
kzbzg TYPE kzbzg,    "Condition Scale Basis
stfkz TYPE stfkz,    "Condition Scale Type
kstbm1 TYPE kstbm,   "Condition Scale Quantity 1
kstbm2 TYPE kstbm,   "Condition Scale Quantity 2
kstbm3 TYPE kstbm,   "Condition Scale Quantity 3
kstbm4 TYPE kstbm,   "Condition Scale Quantity 4
kstbm5 TYPE kstbm,   "Condition Scale Quantity 5
kstbm6 TYPE kstbm,   "Condition Scale Quantity 6
kstbm7 TYPE kstbm,   "Condition Scale Quantity 7
kstbm8 TYPE kstbm,    "Condition Scale Quantity 8
kstbm9 TYPE kstbm,    "Condition Scale Quantity 9
kstbm10 TYPE kstbm,   "Condition Scale Quantity 10
kbetr1 TYPE kbetr,    "Condition Scale Amount 1
kbetr2 TYPE kbetr,    "Condition Scale Amount 2
kbetr3 TYPE kbetr,    "Condition Scale Amount 3
kbetr4 TYPE kbetr,    "Condition Scale Amount 4
kbetr5 TYPE kbetr,    "Condition Scale Amount 5
kbetr6 TYPE kbetr,    "Condition Scale Amount 6
kbetr7 TYPE kbetr,    "Condition Scale Amount 7
kbetr8 TYPE kbetr,    "Condition Scale Amount 8
kbetr9 TYPE kbetr,    "Condition Scale Amount 9
kbetr10 TYPE kbetr,   "Condition Scale Amount 10
mxwrt TYPE mxwrt,    "Condition Lower Limit
gkwrt TYPE gkwrt,    "Condition Upper Limit
kvewe TYPE kvewe,    "Condition Table Usage
kappl TYPE kappl,    "Condition Application
ernam TYPE ernam,    "Rebate Agreement Created By
erdat TYPE erdat,    "Rebate Agreement Created on Date
erzet TYPE erzet,    "Rebate Agreement Created on Time
aenam TYPE aenam,    "Rebate Agreement Changed By
aedat TYPE aedat,    "Rebate Agreement Changed on Date
aezet TYPE aezet,    "Rebate Agreement Changed on Time
bomat TYPE bomat,    "Rebate: Material for Settlement
botext TYPE botext,  "Rebate Agreement Description
abspz TYPE abspz,    "Rebate Verification Level
kobog TYPE kobog,    "Rebate Condition Type Group
knrmm TYPE knrmm,    "Free goods: Minimum quantity
knrnm TYPE knrnm,    "Free goods: Free goods quantity
*Free goods: Quantity unit for minimum quantity and free goods quantity
knrme TYPE knrme,
knrzm TYPE knrzm,    "Free goods: Additional quantity
*Free goods: Quantity unit for free goods additional quantity
knrez TYPE knrez,
fgpcr TYPE p DECIMALS 2,  "Free goods: Percentage rate
*Free goods: Calculation type for determining free goods quantity
knrrr TYPE knrrr,
knrdd TYPE knrdd,      "Free goods category
lstanr TYPE lstanr,    "Free goods delivery control
*Free goods: Text output for exclusive or inclusive
ddtext TYPE val_text,
knrmat TYPE knrmat,    "Free Goods: Additional Material
fmaktx TYPE maktx,    "Free goods: Additional Material Description

* Begin of MOD-001
aland TYPE land1,     "Departure country
lland TYPE land1,     "Destination country
taxk1 TYPE taxk1,     "Tax classification 1 for customer
taxm1 TYPE taxkm,     "Tax classification material
mwskz TYPE mwskz,     "Tax on sales/purchases code
* End of MOD-001

       END OF ty_condtn_rep.

* Type declaration for data of table T685
TYPES: BEGIN OF ty_t685,
         kvewe TYPE kvewe,  "Usage of the condition table
         kappl TYPE kappl,  "Application
         kschl TYPE kschl,  "Condition type
         kozgf TYPE kozgf,  "Access sequence
       END OF ty_t685.

* Type declaration for data of table T685A
TYPES: BEGIN OF ty_t685a,
         kappl TYPE kappl,  "Application
         kschl TYPE kschl,  "Condition type
         koaid TYPE koaid,  "Condition class
       END OF ty_t685a.

* Type declaration for data of table T682I
TYPES: BEGIN OF ty_t682i,
         kvewe TYPE kvewe,  "Usage of the condition table
         kappl TYPE kappl,  "Application
         kozgf TYPE kozgf,  "Access sequence
         kotabnr TYPE kotabnr,  "Condition table
         kschl TYPE kschl,      "Condition Type
         tabname TYPE tabname, "Condition Table name
         flag TYPE c,        "Flag
       END OF ty_t682i.

* Type declaration for data of table DD03L
TYPES: BEGIN OF ty_dd03l,
         tabname TYPE tabname,   "Table Name
         fieldname TYPE fieldname,  "Field Name
       END OF ty_dd03l.

TYPES: BEGIN OF ty_dd02l,
         tabname TYPE tabname,   "Table Name
       END OF ty_dd02l.

TYPES: ty_clause(72) TYPE c.

TYPES: BEGIN OF ty_cond_rec,
         kschl TYPE kschl,
         knumh TYPE knumh,
       END OF ty_cond_rec.

TYPES: BEGIN OF ty_input_field,
          fieldname TYPE fieldname,  "Fieldname
          selname(39) TYPE c,       "Select Options
          reln    TYPE char2,        "Relation
       END OF ty_input_field.

TYPES: BEGIN OF ty_condtab_data,
         knumh TYPE knumh,       "Condition Record Number
         kvewe TYPE kvewe,       "Condition Table Usage
         kappl TYPE kappl,       "Application
         kschl TYPE kscha,       "Condition Type
         kunnr TYPE kunnr,       "Sold To Number
         hienr TYPE kunnr_kh,    "Customer Hierarchy Number
         konda TYPE konda,       "Price Group Name
         matnr TYPE matnr,       "Material Number
         mvgr1 TYPE mvgr1,       "Material Group 1
*         prodh1 TYPE /glb/prodh1,  "ProdH 1 - Business
*         prodh2 TYPE /glb/prodh2,  "ProdH 2 â€" Business ID
*         prodh3 TYPE /glb/prodh3,  "ProdH 3 - Category
*         yyprodh4 TYPE /glb/prodh4,  "ProdH 4 â€" Sub-Categ
*         yyprodh5 TYPE /glb/prodh5,  "ProdH 5 â€" Seg/Sub Seg
         vkorg TYPE vkorg,        "Sales Organization
         vtweg TYPE vtweg,        "Distribution Channel
         cmpgn_id TYPE cmpgn_id_r3,  "Campaign ID
         external_id TYPE cgpl_extid, "External Campaign ID
         datab TYPE kodatab,    "Validity start date of the cond rec
         datbi TYPE kodatbi,    "Validity end date of the cond rec

* Begin of MOD-001
         aland TYPE land1,     "Departure country
         lland TYPE land1,     "Destination country
         taxk1 TYPE taxk1,     "Tax classification 1 for customer
         taxm1 TYPE taxkm,     "Tax classification material
         mwskz TYPE mwskz,     "Tax on sales/purchases code
* End of MOD-001

       END OF ty_condtab_data.

* Type declaration for Condition Data from Condition Tables
TYPES: BEGIN OF ty_condition_data,
          knumh TYPE knumh,      "Condition record number
          ernam TYPE ernam,      "Name of Person who Created the Object
          erdat TYPE erdat,      "Date on which the record was created
          kvewe TYPE kvewe,      "Usage of the condition table
          datab TYPE datab,      "Valid-From Date
          datbi TYPE datbi,      "Valid To Date
          kappl TYPE kappl,      "Application
          kschl TYPE kscha,      "Condition type
          stfkz TYPE stfkz,      "Scale Type
          kzbzg TYPE kzbzg,      "Scale basis indicator
          kstbw TYPE kstbw,      "Scale value
          krech TYPE krech,      "Calculation type for condition
          kbetr TYPE kbetr_kond, "Rate (condition amount or percentage)
          kpein TYPE kpein,      "Condition pricing unit
          kmein TYPE kmein,      "Condition unit
          meins TYPE meins,      "Base Unit of Measure
          kznep TYPE kznep,      "Condition exclusion indicator
          loevm_ko TYPE loevm_ko, "Deletion Indicator for Condition Item
          bomat TYPE bomat,      "Material for rebate settlement
          kbrue TYPE kbrue,      "Accrual Amount
          kspae TYPE kspae,      "Rebate was set up retroactively
          bosta TYPE bosta_cr,   "Condition Record Status (Rebate)
       END OF ty_condition_data.

* Type declaration for Agreement data from KONA
TYPES: BEGIN OF ty_kona,
         knuma TYPE knuma,        "Agreement
         vkbur TYPE vkbur,        "Sales office
         vkgrp TYPE vkgrp,        "Sales group
         boart TYPE boart,        "Agreement type
         ernam TYPE ernam,        "Name of Person who Created the Object
         erdat TYPE erdat,        "Date on which the record was created
         erzet TYPE erzet,        "Entry time
         aenam TYPE aenam,        "Name of person who changed object
         aedat TYPE aedat,        "Date of Last Change
         aezet TYPE aezet,        "Time last change was made
         bonem TYPE bonem,        "Rebate recipient
         waers TYPE waers,        "Currency Key
         abrex TYPE abrex,        "External description for agreement
         abspz TYPE abspz,        "Scope of verification level of rebate
         bosta TYPE bosta,        "Status of the agreement
         datab TYPE datab,        "Agreement valid-from date
         datbi TYPE datbi,        "Agreement valid-to date
         kobog TYPE kobog,        "Condition type/table group for agr
         botext TYPE botext,      "Description of agreement
         zlsch TYPE dzlsch,       "Payment method
         bon_enh_vakey TYPE bon_enh_vakey, "Indicates Enhand Reb Sett
         bon_enh_indirect TYPE bon_enh_indirect, "Ind for Indir Settlmnt
       END OF ty_kona.

* Type declaration for data of table KONDN
TYPES: BEGIN OF ty_kondn,
        knumh TYPE knumh,      "Condition record number
        knrmm TYPE knrmm,      "Minimum quantity
        knrnm TYPE knrnm,      "Free goods quantity
        knrme TYPE knrme,      "Quantity unit for minimum/free quantity
        knrzm TYPE knrzm,      "Additional quantity for free goods
        knrez TYPE knrez,      "Quantity unit for free good additnl qty
        knrrr TYPE knrrr,      "Calculation type for free goods qty
        knrdd TYPE knrdd,      "Free goods category
        lstanr TYPE lstanr,    "Free goods delivery control
        knrmat TYPE knrmat,  "Scale basis indicator
       END OF ty_kondn.

* Type declaration for data of table T685T
TYPES: BEGIN OF ty_t685t,
        kschl TYPE kschl,     "Condition type
        vtext TYPE vtxtk,     "Name
       END OF ty_t685t.

* Type declaration for data of table MAKT
TYPES: BEGIN OF ty_makt,
         matnr TYPE matnr,     "Material Number
         maktx TYPE maktx,     "Material Description
       END OF ty_makt.

* Type declaration for data of table KNA1
TYPES: BEGIN OF ty_kna1,
         kunnr TYPE kunnr,     "Customer Number 1
         name1 TYPE name1_gp,                               "Name 1
       END OF ty_kna1.

* Type declaration for data of table T188T
TYPES: BEGIN OF ty_t188t,
         konda TYPE konda,     "Price group (customer)
         vtext TYPE bezei20,   "Description
       END OF ty_t188t.

* Type declaration for data of table TVM1T
TYPES: BEGIN OF ty_tvm1t,
        mvgr1 TYPE mvgr1,      "Material group 1
        bezei TYPE bezei,      "Description
       END OF ty_tvm1t.

* Type declaration for data of table T6B1T
TYPES: BEGIN OF ty_t6b1t,
        boart TYPE boart,      "Agreement type
        vtext TYPE vtext,      "Description
       END OF ty_t6b1t.

* Type declaration for data of table KONDNS
TYPES: BEGIN OF ty_kondns,
        knumh TYPE knumh,      "Condition record number
        knrmat TYPE knrmat,    "Additional material for free goods
       END OF ty_kondns.

* Type declaration for data of table DD07T
TYPES: BEGIN OF ty_dd07t,
        valpos TYPE valpos,    "Domain value key
        ddtext TYPE val_text,  "Short text for fixed values
       END OF ty_dd07t.

* Type declaration for data of table
TYPES:BEGIN OF ty_check,
        vkorg TYPE vkorg,      "Sales Org
        vtweg TYPE vtweg,      "Distribution Channel
        flag TYPE char1,       "Flag used
      END OF ty_check.

* Type declaration for data of internal table of External ID
TYPES: BEGIN OF ty_ext_cmpgn,
          external_id TYPE cgpl_extid,
       END OF ty_ext_cmpgn.

* Type declaration for data of table CGPL_PROJECT
TYPES: BEGIN OF ty_cgpl_project,
          external_id TYPE cgpl_extid,   "External Identifier of Element
          bwidentifier TYPE cgpl_bwidentifier,  "BW Identification
       END OF ty_cgpl_project.

* Type declaration for data of internal table of Material No
TYPES: BEGIN OF ty_matnr,
          matnr TYPE matnr,    "Material Number
       END OF ty_matnr.

* Type declaration for data of internal table of Customer
TYPES: BEGIN OF ty_kunnr,
          kunnr TYPE kunnr,    "Customer
       END OF ty_kunnr.

***********************************************************************
*                   Table Type Declarations                           *
***********************************************************************
TYPES: ty_i_t682i TYPE STANDARD TABLE OF ty_t682i,
       ty_i_input_field TYPE STANDARD TABLE OF ty_input_field,
       ty_i_condtab_data TYPE STANDARD TABLE OF ty_condtab_data,
       ty_i_knumh TYPE STANDARD TABLE OF cond_knumh,
       ty_i_konhdb TYPE STANDARD TABLE OF konhdb,
       ty_i_konpdb TYPE STANDARD TABLE OF konpdb,
       ty_i_konm TYPE STANDARD TABLE OF cond_konm,
       ty_i_konw TYPE STANDARD TABLE OF cond_konw,
       ty_i_kondn TYPE SORTED TABLE OF ty_kondn
                 WITH NON-UNIQUE KEY knumh,
       ty_i_kondns TYPE SORTED TABLE OF ty_kondns
                 WITH NON-UNIQUE KEY knumh,
       ty_i_kona TYPE SORTED TABLE OF ty_kona
                 WITH NON-UNIQUE KEY knuma.

************************************************************************
*                     INTERNAL TABLE DECLARATION                       *
************************************************************************
DATA: i_condtn_rep TYPE STANDARD TABLE OF ty_condtn_rep.
*-->Begin of Biswarup TPR18842
DATA: i_cgpl_project TYPE STANDARD TABLE OF ty_cgpl_project,
      rec_cgpl_project TYPE ty_cgpl_project.
*<--End of Biswarup TPR18842

* Mod-002 Begins
* ALV related data declaration
 TYPE-POOLS: slis.
* Mod-002 Ends

************************************************************************
*                       VARIABLE DECLARATION                           *
************************************************************************
DATA: v_vkorg TYPE vbak-vkorg,  "Sales Organization
      v_vtweg TYPE vbak-vtweg,  "Distribution Channel
      v_kschl TYPE konp-kschl,  "Condition type
      v_cmpgn_id TYPE cmpgn_id_r3,  "Campaign ID
      v_external_id TYPE cgpl_extid,  "Campaign ID (External)
      v_kunnr TYPE kunnr,  "Sold to Party
      v_hienr TYPE kunnr_kh,    "Customer Hierarchy
      v_konda  TYPE t188-konda,      "Price Group
      v_matnr TYPE matnr,       "Material number
      v_mvgr1  TYPE tvm1-mvgr1,      "Material Group 1
*      v_prodh1 TYPE prodh1,     "ProdH 1 - Business
*      v_prodh2 TYPE prodh2,     "ProdH 2 â€" Business ID
*      v_prodh3 TYPE prodh3,     "ProdH 3 â€" Category
*      v_prodh4 TYPE /glb/prodh4,     "ProdH 4 â€" Segment
*      v_prodh5 TYPE /glb/prodh5,     "ProdH 5 â€" Seg/Sub Seg
      v_loevm_ko TYPE konp-loevm_ko, "Condition Deletion Indicator
      v_cdatab TYPE datab,      "Condition Valid From
      v_cdatbi TYPE datbi,      "Condition Valid To
      v_bonem TYPE kona-bonem,       "Rebate Recipient
      v_bosta TYPE kona-bosta,     "Rebate Agreement Status
      v_boart TYPE kona-boart,     "Agreement Type     MOD-001
      v_aland TYPE t005-land1,     "Departure Country  MOD-001
      v_rdatab TYPE abdatab,    "Rebate Agreement Valid From
      v_rdatbi TYPE abdatbi,    "Rebate Agreeement Valid To
      v_message TYPE cmoresrfc-message.

DATA: r_kvewe TYPE RANGE OF kvewe,
      r_salesorg TYPE RANGE OF vkorg,
      r_distch TYPE RANGE OF vtweg.

 DATA: i_fldcat TYPE lvc_t_fcat.         "table for field catalog " San

 DATA: wa_layout TYPE lvc_s_layo.

* Mod-002 Begins
 data :wa_layout1   TYPE slis_layout_alv,
       i_fldcat1 TYPE slis_t_fieldcat_alv.
* Mod-002 ends
DATA:  v_container TYPE scrfname VALUE 'SCRN_CONTAINER',
                                    "custom control in screen
       wa_variant TYPE disvariant,  "Structure for Variant
       wa_variant1 TYPE disvariant,  "Structure for Variant " Mod-002
       obj_alv_grid TYPE REF TO cl_gui_alv_grid,
                                    "object for displaying the ALV grid
       v_custom_container TYPE REF TO cl_gui_custom_container.
"object for container to grid

*&---------------------------------------------------------------------*
*&  Include           /EUR/OEUCSN_PRICING_COND_CLASS                   *
*&---------------------------------------------------------------------*

CLASS lcl_data_selection DEFINITION.

  PUBLIC SECTION.

    CLASS-METHODS: class_constructor,      "Authority check
                   m_get_layout_variant_f4, "F4 for Layout Variant
                   m_selscreen_output_control,
                   m_selscreen_prodh_f4.

    METHODS:     m_main_processing,         "Main processing
                 m_build_field_catalogue,   "Build Field Catalogue

* Populate the ALV Field Catalogue
              m_populate_fldcat IMPORTING im_fldname  TYPE lvc_fname
                                       im_outlen   TYPE lvc_outlen
                                       im_clpos    TYPE lvc_colpos
                                       im_rwpos    TYPE lvc_rowpos
                                       im_tabname  TYPE lvc_tname
                                       im_coltext  TYPE lvc_txtcol
                                       im_no_out   TYPE lvc_noout
                                       im_rfield   TYPE lvc_rfname
                                       im_rtable   TYPE lvc_rtname
                                                        OPTIONAL
                                       im_lcase    TYPE lowercase
                                                        OPTIONAL,

* Retrieve Data for display in ALV
                 m_retrieve_data CHANGING ch_i_t682i TYPE ty_i_t682i,
* Retrieve the Condition Records from the respective Condition Tables
                m_get_cond_record
                     IMPORTING im_i_t682i TYPE ty_i_t682i
                     CHANGING ch_i_condtab_data TYPE ty_i_condtab_data,

* Validate the database table existence in SAP system
                m_validate_table CHANGING ch_i_t682i TYPE ty_i_t682i,

* Retrieve the Condition data from Condition Header and Item
                m_get_cond_data
                      IMPORTING im_i_condtab_data TYPE ty_i_condtab_data
                      CHANGING ch_i_knumh TYPE ty_i_knumh
                               ch_i_konhdb TYPE ty_i_konhdb
                               ch_i_konpdb TYPE ty_i_konpdb
                               ch_i_konm TYPE ty_i_konm
                               ch_i_konw TYPE ty_i_konw
                               ch_i_kondn TYPE ty_i_kondn
                               ch_i_kondns TYPE ty_i_kondns,

* Get the BWIDENTIFIER from CRM
                m_get_crm_bwidentifier,

* Retrieve the Rebate Agreement data
                m_get_agreement_data
                      IMPORTING im_i_konpdb TYPE ty_i_konpdb
                      CHANGING ch_i_kona TYPE ty_i_kona,

                m_get_rebate_accrual_values,

* Get the descriptive texts
                m_get_texts,
* Process Data before display
                 m_process_data,

* Populate the internal table based on the selection screen
                 m_input_field
                     CHANGING ch_i_input_field TYPE ty_i_input_field.

    DATA:
             i_t682i TYPE STANDARD TABLE OF ty_t682i,
* Internal Table for the Input Field
    i_input_field TYPE STANDARD TABLE OF ty_input_field,
    i_condtab_data TYPE STANDARD TABLE OF ty_condtab_data,
    i_condition_data TYPE STANDARD TABLE OF ty_condition_data,
    i_kona TYPE SORTED TABLE OF ty_kona
            WITH NON-UNIQUE KEY knuma,
* Internal table to store Free Goods detail
    i_kondn TYPE SORTED TABLE OF ty_kondn
            WITH NON-UNIQUE KEY knumh,
    i_kondns TYPE SORTED TABLE OF ty_kondns
            WITH NON-UNIQUE KEY knumh.

    DATA: i_knumh TYPE STANDARD TABLE OF cond_knumh,
          i_konhdb TYPE STANDARD TABLE OF konhdb,
          i_konpdb TYPE STANDARD TABLE OF konpdb,
          i_konm TYPE STANDARD TABLE OF cond_konm,
          i_konw TYPE STANDARD TABLE OF cond_konw,
          i_t685t TYPE SORTED TABLE OF ty_t685t
                  WITH NON-UNIQUE KEY kschl,
          i_makt TYPE STANDARD TABLE OF ty_makt
                  WITH NON-UNIQUE KEY matnr,
          i_kna1 TYPE STANDARD TABLE OF ty_kna1
                  WITH NON-UNIQUE KEY kunnr,
          i_t188t TYPE STANDARD TABLE OF ty_t188t
                  WITH NON-UNIQUE KEY konda,
          i_tvm1t TYPE STANDARD TABLE OF ty_tvm1t
                  WITH NON-UNIQUE KEY mvgr1,
          i_t6b1t TYPE STANDARD TABLE OF ty_t6b1t
                  WITH NON-UNIQUE KEY boart,
          i_dd07t TYPE STANDARD TABLE OF ty_dd07t
                  WITH NON-UNIQUE KEY valpos.

ENDCLASS.                    "lcl_data_selection DEFINITION
*&---------------------------------------------------------------------*
*&       Class (Implementation)  lcl_data_selection
*&---------------------------------------------------------------------*
*        Implementation of the Class LCL_DATA_SELECTION
*----------------------------------------------------------------------*
CLASS lcl_data_selection IMPLEMENTATION.

*&---------------------------------------------------------------------*
*&       METHOD CONSTRUCTOR
*&---------------------------------------------------------------------*
*        Authority Check
*----------------------------------------------------------------------*
  METHOD class_constructor.

* Local internal table for authorisation check
    DATA : l_i_check TYPE STANDARD TABLE OF
                          ty_check INITIAL SIZE 0,
* Local work area for authorisation check
           l_wa_check TYPE ty_check.
    DATA : l_lines  TYPE sytabix ,
             l_lines1 TYPE sytabix .

    DATA : wa_salesorg LIKE LINE OF  r_salesorg ,
           wa_distch LIKE LINE   OF  r_distch.

    CLEAR l_wa_check.
    CLEAR l_i_check.

*    SELECT vkorg            "Sales Org
*           vtweg            "Distr Channel
*    FROM  tvta               "Organizational Unit: Sales Area(s)
*    INTO TABLE l_i_check
*    WHERE vkorg IN  s_vkorg
*      AND vtweg IN  s_vtweg.
*
* Record not found display error msg
*    IF sy-subrc NE 0.
*     Message that the Sales Org & Distr Chnl combination invalid
*      MESSAGE i073.
*      LEAVE LIST-PROCESSING.
*    ENDIF.
*
*    DESCRIBE TABLE l_i_check LINES l_lines .
*
*    CLEAR : r_salesorg,
*            r_distch.
* Collect all Sales organization in a range
*    LOOP AT l_i_check INTO l_wa_check.
*
*      AUTHORITY-CHECK OBJECT c_vbak_vko      "V_VBAK_VKO
*            ID c_vkorg FIELD l_wa_check-vkorg
*            ID c_vtweg FIELD l_wa_check-vtweg
*            ID c_spart DUMMY
*            ID c_actvt FIELD c_disp_03.
*
*      IF sy-subrc IS INITIAL.
*        DELETE l_i_check INDEX sy-tabix.
*      ENDIF.
*
*    ENDLOOP.

    DESCRIBE TABLE l_i_check LINES l_lines1 .

    IF l_lines1 = l_lines .
*     Message that user is not authorized
      MESSAGE i074.
      LEAVE LIST-PROCESSING.
    ENDIF.

  ENDMETHOD.                    "CLASS_CONSTRUCTOR

*&---------------------------------------------------------------------*
*&       METHOD m_get_layout_variant_f4
*&---------------------------------------------------------------------*
*        Search Help on the parameter Layout Variant
*----------------------------------------------------------------------*
  METHOD m_get_layout_variant_f4.

    wa_variant-report = sy-repid.

    CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
      EXPORTING
        is_variant    = wa_variant
        i_save        = c_save       "A
      IMPORTING
        es_variant    = wa_variant
      EXCEPTIONS
        not_found     = 1
        program_error = 2
        OTHERS        = 3.

    IF sy-subrc IS INITIAL.
*     p_vari = wa_variant-variant.
      vari = wa_variant-variant.

    ENDIF.

  ENDMETHOD.                    "M_GET_LAYOUT_VARIANT_F4

*&---------------------------------------------------------------------*
*&       METHOD m_selscreen_output_control
*&---------------------------------------------------------------------*
*        Control the selection screen outout
*----------------------------------------------------------------------*
  METHOD m_selscreen_output_control.

*    IF s_xcamid IS INITIAL.
*      LOOP AT SCREEN.
*        IF screen-name = c_crmsys.
*          screen-input = 0.
*          MODIFY SCREEN.
*        ENDIF.
*      ENDLOOP.
*    ENDIF.

  ENDMETHOD.                    "m_selscreen_output_control

*&---------------------------------------------------------------------*
*&       METHOD m_selscreen_prodh_f4
*&---------------------------------------------------------------------*
*        Search Help on the ProdH values on selection screen
*----------------------------------------------------------------------*
  METHOD m_selscreen_prodh_f4.

    DATA: l_wa_prodhs TYPE prodhs.
    DATA: l_node_picked TYPE prodh_d,
          l_selfield TYPE fieldname,
          l_stufe TYPE prodh_stuf.

    GET CURSOR FIELD l_selfield.

    IF l_selfield = 'S_PRODH2-LOW' OR l_selfield = 'S_PRODH2-HIGH'.
      l_stufe = 2.
    ENDIF.
    IF l_selfield = 'S_PRODH3-LOW' OR l_selfield = 'S_PRODH3-HIGH'.
      l_stufe = 3.
    ENDIF.
    IF l_selfield = 'S_PRODH4-LOW' OR l_selfield = 'S_PRODH4-HIGH'.
      l_stufe = 4.
    ENDIF.

    IF l_selfield = 'S_PRODH5-LOW' OR l_selfield = 'S_PRODH5-HIGH'.
      l_stufe = 5.
    ENDIF.

    CALL FUNCTION 'RV_PRODUKTHIERARCHIE_SHOW'
     EXPORTING
       root                 = ' '
       selmode              = '3'
       stufe                = l_stufe
       refresh              = 'X'
       display              = 'X'
       x1                   = 5
       x2                   = 80
       y1                   = 5
       y2                   = 24
*   VKORG                =
*   VTWEG                =
       spras                = sy-langu
       show_only            = ' '
     IMPORTING
       node_picked          = l_node_picked
* TABLES
*   DISP_T179            =
*   XM_MAT1P             =
     EXCEPTIONS
       root_not_exist       = 1
       too_many_level       = 2
       OTHERS               = 3
              .
    IF sy-subrc = 0.
      MOVE l_node_picked TO l_wa_prodhs.
      CASE l_selfield.
        WHEN 'S_PRODH2-LOW'.
          s_prodh2-low = l_wa_prodhs-prodh2.
        WHEN 'S_PRODH2-HIGH'.
          s_prodh2-high = l_wa_prodhs-prodh2.
        WHEN 'S_PRODH3-LOW'.
          s_prodh3-low = l_wa_prodhs-prodh3.
        WHEN 'S_PRODH3-HIGH'.
          s_prodh3-high = l_wa_prodhs-prodh3.
        WHEN 'S_PRODH4-LOW'.
          s_prodh4-low = l_wa_prodhs-yyprodh4.
        WHEN 'S_PRODH4-HIGH'.
          s_prodh4-high = l_wa_prodhs-yyprodh4.
        WHEN 'S_PRODH5-LOW'.
          s_prodh5-low = l_wa_prodhs-yyprodh5.
        WHEN 'S_PRODH5-HIGH'.
          s_prodh5-high = l_wa_prodhs-yyprodh5.
      ENDCASE.
    ENDIF.
  ENDMETHOD.                    "m_selscreen_prodh_f4
*&---------------------------------------------------------------------*
*&       METHOD m_retrieve_data
*&---------------------------------------------------------------------*
*        Retrieve data from the Database Tables
*----------------------------------------------------------------------*
  METHOD m_retrieve_data.

    FIELD-SYMBOLS: <l_fs_t682i> TYPE ty_t682i,
                   <l_fs_t685>  TYPE ty_t685,
                   <l_fs_t685a> TYPE ty_t685a.

*   Structure for range tables
    DATA: BEGIN OF rec_kvewe,
           sign TYPE tvarv_sign,
           option TYPE tvarv_opti,
           low TYPE kvewe,
           high TYPE kvewe,
          END OF rec_kvewe.

    DATA:
* internal table for DATA in table t685
      l_i_t685 TYPE SORTED TABLE OF ty_t685
                WITH NON-UNIQUE KEY kvewe kappl kozgf,
      l_i_t685_a TYPE SORTED TABLE OF ty_t685
                 WITH NON-UNIQUE KEY kvewe kappl kschl kozgf,
      l_i_t685a TYPE SORTED TABLE OF ty_t685a
                 WITH NON-UNIQUE KEY kappl kschl koaid,
* Internal Table for data in table T682I
      l_i_t682i_temp TYPE SORTED TABLE OF ty_t682i
                WITH NON-UNIQUE KEY kvewe kappl kschl kozgf,
      l_i_t682i_a TYPE STANDARD TABLE OF ty_t682i,
      l_i_t682i_n TYPE STANDARD TABLE OF ty_t682i.

* Populate the Range Table for Usage(T685-KVEWE) because we want only
* General Pricing, Free Goods and Rebate
    rec_kvewe-sign = c_sign_i.           "I
    rec_kvewe-option = c_option_eq.      "EQ

    IF p_price = c_yes OR p_rebate = c_yes.
      rec_kvewe-low = c_kvewe_a.  "A
      APPEND rec_kvewe TO r_kvewe.
    ENDIF.

    IF p_freegd = c_yes.
      rec_kvewe-low = c_kvewe_n.  "N
      APPEND rec_kvewe TO r_kvewe.
    ENDIF.

    IF r_kvewe IS INITIAL.
      MESSAGE i072.
* Promt an Info Message to check at least one box
      LEAVE LIST-PROCESSING.
    ENDIF.

* For each Condition Type in the selection screen get the Access
* Sequence from the database table T685.
    SELECT kvewe  "Usage of the condition table
           kappl  "Application
           kschl  "Condition type
           kozgf  "Access sequence
    FROM t685     "Conditions: Types
    INTO TABLE l_i_t685
    WHERE kvewe IN r_kvewe
    AND   kappl = c_kappl_v   "V
    AND   kschl IN s_kschl
    AND   kozgf <> c_no.

    IF NOT sy-subrc IS INITIAL.

* Information Message that no data is selected
      MESSAGE i030.
      LEAVE LIST-PROCESSING.
    ENDIF.

    l_i_t685_a = l_i_t685.
    DELETE l_i_t685_a WHERE kvewe <> c_kvewe_a.    "A

    IF NOT l_i_t685_a IS INITIAL.
      SELECT kappl
             kschl
             koaid
      FROM t685a
      INTO TABLE l_i_t685a
      FOR ALL ENTRIES IN l_i_t685_a
      WHERE kappl = c_kappl_v
      AND kschl = l_i_t685_a-kschl
      AND koaid = c_koaid_c.    "C

      IF NOT sy-subrc IS INITIAL.
* No condition types for rebate exists for the selection criteria.
        MESSAGE i075.
      ENDIF.
    ENDIF.

* The following is the way to distinguish different conditions:
* If the Usage (T685-KVEWE) is:
* --> 'A' then the condition type is 'Pricing' or 'Rebate'
* --> 'N' then the condition type is 'Free Goods'

* Keep the distinct Access Sequence only
    DELETE ADJACENT DUPLICATES FROM l_i_t685
                              COMPARING kvewe kappl kschl.

* For each Access Sequence get the Tables (T682I-KOTABNR)from the
* database table T682I
    SELECT kvewe  "Usage of the condition table
           kappl  "Application
           kozgf  "Access sequence
           kotabnr "Condition table
    FROM t682i     "Conditions: Access Sequences (Generated Form)
    INTO TABLE l_i_t682i_temp
    FOR ALL ENTRIES IN l_i_t685
    WHERE kvewe = l_i_t685-kvewe
    AND   kappl = c_kappl_v   "V
    AND   kozgf = l_i_t685-kozgf.

    IF NOT sy-subrc IS INITIAL.
* Information Message that no data is selected
      MESSAGE i030.
      LEAVE LIST-PROCESSING.
    ENDIF.

* For Pricing the Access Tables will be obtained by the following logic:
* Pricing - Concatenate 'A' to the tables (T682I-KOTABNR)
* Rebate - Concatenate 'KOTE' to the tables (T682I-KOTABNR)
* Free Goods - Concatenate 'KOTN' to all the tables (T682I-KOTABNR)

    l_i_t682i_a = l_i_t682i_temp.
    l_i_t682i_n = l_i_t682i_temp.

*   Table for Usage related for General Pricing
    DELETE l_i_t682i_a WHERE NOT kvewe = c_kvewe_a.  "A
*   Table for Usage related for Free Goods
    DELETE l_i_t682i_n WHERE NOT kvewe = c_kvewe_n.  "N

*   Get the names of the database tables from where
*   the Condition Records for Pricing will be retrieved
    LOOP AT l_i_t682i_a ASSIGNING <l_fs_t682i>.

      READ TABLE l_i_t685 ASSIGNING <l_fs_t685> WITH KEY
                        kvewe = <l_fs_t682i>-kvewe "Usage
                        kappl = <l_fs_t682i>-kappl "Application
                        kozgf = <l_fs_t682i>-kozgf "Access sequence
                        BINARY SEARCH.

      IF sy-subrc IS INITIAL.

        <l_fs_t682i>-kschl = <l_fs_t685>-kschl.

        READ TABLE l_i_t685a ASSIGNING <l_fs_t685a> WITH KEY
                           kappl = c_kappl_v
                           kschl = <l_fs_t685>-kschl
                           koaid = c_koaid_c           "C
                           BINARY SEARCH.

        IF sy-subrc IS INITIAL.
          IF p_rebate = c_yes.
            CONCATENATE c_kote                        "KOTE
                        <l_fs_t682i>-kotabnr
                        INTO <l_fs_t682i>-tabname.
          ENDIF.

        ELSE.

          IF p_price = c_yes.
            CONCATENATE c_pricing_a                   "A
                        <l_fs_t682i>-kotabnr
                        INTO <l_fs_t682i>-tabname.

          ENDIF.

        ENDIF.
      ENDIF.

    ENDLOOP.

*   Get the names of the database tables from where
*   the Condition Records for Free Goods will be retrieved
    LOOP AT l_i_t682i_n ASSIGNING <l_fs_t682i>.

      CONCATENATE c_kotn                                "KOTN
                  <l_fs_t682i>-kotabnr
                  INTO <l_fs_t682i>-tabname.

      READ TABLE l_i_t685 ASSIGNING <l_fs_t685> WITH KEY
                              kvewe = <l_fs_t682i>-kvewe "Usage
                              kappl = <l_fs_t682i>-kappl "Application
                              kozgf = <l_fs_t682i>-kozgf
                              BINARY SEARCH.
      "Access sequence

      IF sy-subrc IS INITIAL.

        <l_fs_t682i>-kschl = <l_fs_t685>-kschl.

      ENDIF.
    ENDLOOP.

* The resultant tables will give the name of the tables from where
* the Condition Record can be retrieved.

    IF p_price = c_yes
      OR p_rebate = c_yes.
      ch_i_t682i = l_i_t682i_a.
    ENDIF.

    IF p_freegd = c_yes.
      IF ch_i_t682i IS INITIAL.
        ch_i_t682i = l_i_t682i_n.
      ELSE.
        APPEND LINES OF l_i_t682i_n TO ch_i_t682i.
      ENDIF.
    ENDIF.

    DELETE ch_i_t682i WHERE tabname = space.

    IF ch_i_t682i IS INITIAL.

* Info message that no Condition Table
      MESSAGE i066.
      LEAVE LIST-PROCESSING.

    ENDIF.

*   Retain the distinct table names in the internal table.
    SORT ch_i_t682i BY tabname.
    DELETE ADJACENT DUPLICATES FROM ch_i_t682i
                               COMPARING tabname.

  ENDMETHOD.            "M_RETRIEVE_DATA
*&---------------------------------------------------------------------*
*&       METHOD m_validate_table
*&---------------------------------------------------------------------*
*        Validate that the Condition Tables that were determined
*        actually exists in SAP
*----------------------------------------------------------------------*
  METHOD m_validate_table.

    DATA: l_i_dd02l TYPE SORTED TABLE OF ty_dd02l
                WITH NON-UNIQUE KEY tabname.

    FIELD-SYMBOLS: <l_fs_t682i> TYPE ty_t682i,
                   <l_fs_dd02l> TYPE ty_dd02l.

    SELECT tabname
    FROM dd02l
    INTO TABLE l_i_dd02l
    FOR ALL ENTRIES IN ch_i_t682i
    WHERE tabname = ch_i_t682i-tabname.

    IF NOT sy-subrc IS INITIAL.
* No Condition Tables could be determined for the selection criteria
      MESSAGE i066.
      LEAVE LIST-PROCESSING.
    ENDIF.

    LOOP AT ch_i_t682i ASSIGNING <l_fs_t682i>.

      READ TABLE l_i_dd02l ASSIGNING <l_fs_dd02l>
                          WITH KEY tabname = <l_fs_t682i>-tabname
                          BINARY SEARCH.

      IF NOT sy-subrc IS INITIAL.
        <l_fs_t682i>-flag = c_yes.
      ENDIF.
    ENDLOOP.

    DELETE ch_i_t682i WHERE flag = c_yes.

    IF ch_i_t682i IS INITIAL.

* Info message that no Condition Table
      MESSAGE i066.
      LEAVE LIST-PROCESSING.

    ENDIF.

  ENDMETHOD.            "M_VALIDATE_TABLE
*&---------------------------------------------------------------------*
*&       METHOD m_input_field
*&---------------------------------------------------------------------*
*        Populating all the Input Values in the Selection Screen
*        into an internal table
*----------------------------------------------------------------------*
  METHOD m_input_field.

*   Work area of the internal table i_input_field
    DATA: l_wa_input_field TYPE ty_input_field.

*   Sales Organization
    l_wa_input_field-fieldname = c_vkorg.    "VKORG
    l_wa_input_field-selname = c_vkorg_low.  "S_VKORG-LOW
    l_wa_input_field-reln  = c_option_eq.        "EQ
    APPEND l_wa_input_field TO ch_i_input_field.
    CLEAR l_wa_input_field.

*   Distribution Channel
    IF ( NOT s_vtweg-low IS INITIAL    AND
           NOT s_vtweg-high IS INITIAL ) OR
         ( s_vtweg-low IS INITIAL        AND
           NOT s_vtweg-high IS INITIAL ).

      l_wa_input_field-fieldname = c_vtweg.      "VTWEG
      l_wa_input_field-selname = c_vtweg_low.    "S_VTWEG-LOW
      l_wa_input_field-reln  = c_option_ge.      "GE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

      l_wa_input_field-fieldname = c_vtweg.      "VTWEG
      l_wa_input_field-selname = c_vtweg_high.   "S_VTWEG-HIGH
      l_wa_input_field-reln  = c_option_le.      "LE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

    ELSEIF NOT s_vtweg-low IS INITIAL AND
               s_vtweg-high IS INITIAL.

      l_wa_input_field-fieldname = c_vtweg.      "VTWEG
      l_wa_input_field-selname = c_vtweg_low.    "S_VTWEG-LOW
      l_wa_input_field-reln  = c_option_eq.        "EQ
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.
    ENDIF.

*   Condition Type
    IF ( NOT s_kschl-low IS INITIAL    AND
       NOT s_kschl-high IS INITIAL ) OR
     ( s_kschl-low IS INITIAL        AND
       NOT s_kschl-high IS INITIAL ).

      l_wa_input_field-fieldname = c_kschl.        "KSCHL
      l_wa_input_field-selname = c_kschl_low.      "S_KSCHL-LOW
      l_wa_input_field-reln  = c_option_ge.        "GE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

      l_wa_input_field-fieldname = c_kschl.  "KSCHL
      l_wa_input_field-selname = c_kschl_high. "S_KSCHL-HIGH
      l_wa_input_field-reln  = c_option_le.       "LE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

    ELSEIF NOT s_kschl-low IS INITIAL AND
               s_kschl-high IS INITIAL.

      l_wa_input_field-fieldname = c_kschl.  "KSCHL
      l_wa_input_field-selname = c_kschl_low. "S_KSCHL-LOW
      l_wa_input_field-reln  = c_option_eq.          "EQ
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.
    ENDIF.

* Campaign ID
    IF ( NOT s_campid-low IS INITIAL    AND
        NOT s_campid-high IS INITIAL ) OR
      ( s_campid-low IS INITIAL        AND
        NOT s_campid-high IS INITIAL ).

      l_wa_input_field-fieldname = c_cmpgn_id.  "CMPGN_ID
      l_wa_input_field-selname = c_campid_low.  "S_CAMPID-LOW
      l_wa_input_field-reln  = c_option_ge.     "GE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

      l_wa_input_field-fieldname = c_cmpgn_id.  "CMPGN_ID
      l_wa_input_field-selname = c_campid_high.  "S_CAMPID-HIGH
      l_wa_input_field-reln  = c_option_le.     "LE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

    ELSEIF NOT s_campid-low IS INITIAL AND
               s_campid-high IS INITIAL.

      l_wa_input_field-fieldname = c_cmpgn_id.  "CMPGN_ID
      l_wa_input_field-selname = c_campid_low.  "S_CAMPID-LOW
      l_wa_input_field-reln  = c_option_eq.     "EQ
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.
    ENDIF.

* External Campaign ID
    IF ( NOT s_xcamid-low IS INITIAL    AND
        NOT s_xcamid-high IS INITIAL ) OR
      ( s_xcamid-low IS INITIAL        AND
        NOT s_xcamid-high IS INITIAL ).

*     An RFC to the destination CRM system will be done by which the
*     BWIDENTIFIER will be retrived from CGPL_PROJECT for all the
*     values of the External Campaign ID.
      CALL METHOD m_get_crm_bwidentifier.

*-->Begin of TPR18842 Biswarup 20.04.2005 comment
*      IF s_campid IS INITIAL.
*<--End of TPR18842 Biswarup 20.04.2005 comment
*-->Begin of TPR18842 Biswarup 20.04.2005
      IF NOT s_campid[] IS INITIAL.
*<--End of TPR18842 Biswarup 20.04.2005

        l_wa_input_field-fieldname = c_cmpgn_id.  "CMPGN_ID
        l_wa_input_field-selname = c_campid_low.  "S_CAMPID-LOW
        l_wa_input_field-reln  = c_option_ge.     "GE
        APPEND l_wa_input_field TO ch_i_input_field.
        CLEAR l_wa_input_field.

        l_wa_input_field-fieldname = c_cmpgn_id.  "CMPGN_ID
        l_wa_input_field-selname = c_campid_high. "S_CAMPID-HIGH
        l_wa_input_field-reln  = c_option_le.     "LE
        APPEND l_wa_input_field TO ch_i_input_field.
        CLEAR l_wa_input_field.

      ENDIF.
    ELSEIF NOT s_xcamid-low IS INITIAL AND
               s_xcamid-high IS INITIAL.

*     An RFC to the destination CRM system will be done by which the
*     BWIDENTIFIER will be retrived from CGPL_PROJECT for all the
*     values of the External Campaign ID.
      CALL METHOD m_get_crm_bwidentifier.

*-->Begin of TPR18842 Biswarup 20.04.2005 comment
*      IF s_campid IS INITIAL.
*<--End of TPR18842 Biswarup 20.04.2005 comment
*-->Begin of TPR18842 Biswarup 20.04.2005
      IF NOT s_campid[] IS INITIAL.
*<--End of TPR18842 Biswarup 20.04.2005

        l_wa_input_field-fieldname = c_cmpgn_id.  "CMPGN_ID
        l_wa_input_field-selname = c_campid_low.  "S_CAMPID-LOW
        l_wa_input_field-reln  = c_option_eq.     "EQ
        APPEND l_wa_input_field TO ch_i_input_field.
        CLEAR l_wa_input_field.

      ENDIF.
    ENDIF.

*   Sold to Party
    IF ( NOT s_kunnr-low IS INITIAL    AND
           NOT s_kunnr-high IS INITIAL ) OR
         ( s_kunnr-low IS INITIAL        AND
           NOT s_kunnr-high IS INITIAL ).

      l_wa_input_field-fieldname = c_kunnr.    "KUNNR
      l_wa_input_field-selname = c_kunnr_low.  "S_KUNNR-LOW
      l_wa_input_field-reln  = c_option_ge.    "GE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

      l_wa_input_field-fieldname = c_kunnr.    "KUNNR
      l_wa_input_field-selname = c_kunnr_high. "S_KUNNR-HIGH
      l_wa_input_field-reln  = c_option_le.    "LE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

    ELSEIF NOT s_kunnr-low IS INITIAL AND
               s_kunnr-high IS INITIAL.

      l_wa_input_field-fieldname = c_kunnr.    "KUNNR
      l_wa_input_field-selname = c_kunnr_low.  "S_KUNNR-LOW
      l_wa_input_field-reln  = c_option_eq.    "EQ'.
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.
    ENDIF.

*   Customer Hierarchy
    IF ( NOT s_hienr-low IS INITIAL    AND
           NOT s_hienr-high IS INITIAL ) OR
         ( s_hienr-low IS INITIAL        AND
           NOT s_hienr-high IS INITIAL ).

      l_wa_input_field-fieldname = c_hienr.    "HIENR
      l_wa_input_field-selname = c_hienr_low.  "S_HIENR-LOW
      l_wa_input_field-reln  = c_option_ge.    "GE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

      l_wa_input_field-fieldname = c_hienr.    "HIENR
      l_wa_input_field-selname = c_hienr_high. "S_HIENR-HIGH
      l_wa_input_field-reln  = c_option_le.    "LE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

    ELSEIF NOT s_hienr-low IS INITIAL AND
               s_hienr-high IS INITIAL.

      l_wa_input_field-fieldname = c_hienr.    "HIENR
      l_wa_input_field-selname = c_hienr_low.  "S_HIENR-LOW
      l_wa_input_field-reln  = c_option_eq.    "EQ
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.
    ENDIF.

*   Price Group
    IF ( NOT s_konda-low IS INITIAL    AND
           NOT s_konda-high IS INITIAL ) OR
         ( s_konda-low IS INITIAL        AND
           NOT s_konda-high IS INITIAL ).

      l_wa_input_field-fieldname = c_konda.    "KONDA
      l_wa_input_field-selname = c_konda_low.  "S_KONDA-LOW
      l_wa_input_field-reln  = c_option_ge.    "GE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

      l_wa_input_field-fieldname = c_konda.    "KONDA
      l_wa_input_field-selname = c_konda_high. "S_KONDA-HIGH
      l_wa_input_field-reln  = c_option_le.    "LE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

    ELSEIF NOT s_konda-low IS INITIAL AND
               s_konda-high IS INITIAL.

      l_wa_input_field-fieldname = c_konda.    "KONDA
      l_wa_input_field-selname = c_konda_low.  "S_KONDA-LOW
      l_wa_input_field-reln  = c_option_eq.    "EQ
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.
    ENDIF.

*   Material
    IF ( NOT s_matnr-low IS INITIAL    AND
           NOT s_matnr-high IS INITIAL ) OR
         ( s_matnr-low IS INITIAL        AND
           NOT s_matnr-high IS INITIAL ).

      l_wa_input_field-fieldname = c_matnr.    "MATNR
      l_wa_input_field-selname = c_matnr_low.  "S_MATNR-LOW
      l_wa_input_field-reln  = c_option_ge.    "GE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

      l_wa_input_field-fieldname = c_matnr.    "MATNR
      l_wa_input_field-selname = c_matnr_high. "S_MATNR-HIGH
      l_wa_input_field-reln  = c_option_le.    "LE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

    ELSEIF NOT s_matnr-low IS INITIAL AND
               s_matnr-high IS INITIAL.

      l_wa_input_field-fieldname = c_matnr.    "MATNR
      l_wa_input_field-selname = c_matnr_low.  "S_MATNR-LOW
      l_wa_input_field-reln  = c_option_eq.    "EQ
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.
    ENDIF.

*   Material Group 1
    IF ( NOT s_mvgr1-low IS INITIAL    AND
           NOT s_mvgr1-high IS INITIAL ) OR
         ( s_mvgr1-low IS INITIAL        AND
           NOT s_mvgr1-high IS INITIAL ).

      l_wa_input_field-fieldname = c_mvgr1.                 "MVGR1
      l_wa_input_field-selname = c_mvgr1_low.      "S_MVGR1-LOW
      l_wa_input_field-reln  = c_option_ge.        "GE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

      l_wa_input_field-fieldname = c_mvgr1.                 "MVGR1
      l_wa_input_field-selname = c_mvgr1_high.     "S_MVGR1-HIGH
      l_wa_input_field-reln  = c_option_le.        "LE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

    ELSEIF NOT s_mvgr1-low IS INITIAL AND
               s_mvgr1-high IS INITIAL.

      l_wa_input_field-fieldname = c_mvgr1.                 "MVGR1
      l_wa_input_field-selname = c_mvgr1_low.        "S_MVGR1-LOW
      l_wa_input_field-reln  = c_option_eq.                 "EQ
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.
    ENDIF.

*   Prodh1
    IF ( NOT s_prodh1-low IS INITIAL    AND
           NOT s_prodh1-high IS INITIAL ) OR
         ( s_prodh1-low IS INITIAL        AND
           NOT s_prodh1-high IS INITIAL ).

      l_wa_input_field-fieldname = c_prodh1.                "PRODH1
      l_wa_input_field-selname = c_prodh1_low.        "S_PRODH1-LOW
      l_wa_input_field-reln  = c_option_ge.                "GE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

      l_wa_input_field-fieldname = c_prodh1.                "PRODH1
      l_wa_input_field-selname = c_prodh1_high.      "S_PRODH1-HIGH
      l_wa_input_field-reln  = c_option_le.                 "LE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

    ELSEIF NOT s_prodh1-low IS INITIAL AND
               s_prodh1-high IS INITIAL.

      l_wa_input_field-fieldname = c_prodh1.                "PRODH1
      l_wa_input_field-selname = c_prodh1_low.        "S_PRODH1-LOW
      l_wa_input_field-reln  = c_option_eq.                 "EQ
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.
    ENDIF.

*   Prodh2
    IF ( NOT s_prodh2-low IS INITIAL    AND
       NOT s_prodh2-high IS INITIAL ) OR
     ( s_prodh2-low IS INITIAL        AND
       NOT s_prodh2-high IS INITIAL ).

      l_wa_input_field-fieldname = c_prodh2.                "PRODH2
      l_wa_input_field-selname = c_prodh2_low.         "S_PRODH2-LOW
      l_wa_input_field-reln  = c_option_ge.                 "GE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

      l_wa_input_field-fieldname = c_prodh2.                "PRODH2
      l_wa_input_field-selname = c_prodh2_high.        "S_PRODH2-HIGH
      l_wa_input_field-reln  = c_option_le.                 "LE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

    ELSEIF NOT s_prodh2-low IS INITIAL AND
               s_prodh2-high IS INITIAL.

      l_wa_input_field-fieldname = c_prodh2.                "PRODH2
      l_wa_input_field-selname = c_prodh2_low.        "S_PRODH2-LOW
      l_wa_input_field-reln  = c_option_eq.                 "EQ
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.
    ENDIF.

*   Prodh3
    IF ( NOT s_prodh3-low IS INITIAL    AND
       NOT s_prodh3-high IS INITIAL ) OR
     ( s_prodh3-low IS INITIAL        AND
       NOT s_prodh3-high IS INITIAL ).

      l_wa_input_field-fieldname = c_prodh3.                "PRODH3
      l_wa_input_field-selname = c_prodh3_low.    "S_PRODH3-LOW
      l_wa_input_field-reln  = c_option_ge.                 "GE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

      l_wa_input_field-fieldname = c_prodh3.                "PRODH3
      l_wa_input_field-selname = c_prodh3_high.   "S_PRODH3-HIGH
      l_wa_input_field-reln  = c_option_le.                 "LE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

    ELSEIF NOT s_prodh3-low IS INITIAL AND
               s_prodh3-high IS INITIAL.

      l_wa_input_field-fieldname = c_prodh3.                "PRODH3
      l_wa_input_field-selname = c_prodh3_low.      "S_PRODH3-LOW
      l_wa_input_field-reln  = c_option_eq.                 "EQ
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.
    ENDIF.

*   Prodh4
    IF ( NOT s_prodh4-low IS INITIAL    AND
       NOT s_prodh4-high IS INITIAL ) OR
     ( s_prodh4-low IS INITIAL        AND
       NOT s_prodh4-high IS INITIAL ).

      l_wa_input_field-fieldname = c_yyprodh4.              "YYPRODH4
      l_wa_input_field-selname = c_prodh4_low.         "S_PRODH4-LOW
      l_wa_input_field-reln  = c_option_ge.                 "GE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

      l_wa_input_field-fieldname = c_yyprodh4.              "YYPRODH4
      l_wa_input_field-selname = c_prodh4_high.      "S_PRODH4-HIGH
      l_wa_input_field-reln  = c_option_le.                 "LE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

    ELSEIF NOT s_prodh4-low IS INITIAL AND
               s_prodh4-high IS INITIAL.

      l_wa_input_field-fieldname = c_yyprodh4.              "YYPRODH4
      l_wa_input_field-selname = c_prodh4_low.         "S_PRODH4-LOW
      l_wa_input_field-reln  = c_option_eq.                 "EQ
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.
    ENDIF.

*   Prodh5
    IF ( NOT s_prodh5-low IS INITIAL    AND
       NOT s_prodh5-high IS INITIAL ) OR
     ( s_prodh5-low IS INITIAL        AND
       NOT s_prodh5-high IS INITIAL ).

      l_wa_input_field-fieldname = c_yyprodh5.              "YYPRODH5
      l_wa_input_field-selname = c_prodh5_low.          "S_PRODH5-LOW
      l_wa_input_field-reln  = c_option_ge.                 "GE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

      l_wa_input_field-fieldname = c_yyprodh5.              "YYPRODH5
      l_wa_input_field-selname = c_prodh5_high.       "S_PRODH5-HIGH
      l_wa_input_field-reln  = c_option_le.                 "LE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

    ELSEIF NOT s_prodh5-low IS INITIAL AND
               s_prodh5-high IS INITIAL.

      l_wa_input_field-fieldname = c_yyprodh5.              "YYPRODH5
      l_wa_input_field-selname = c_prodh5_low.         "S_PRODH5-LOW
      l_wa_input_field-reln  = c_option_eq.                 "EQ
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.
    ENDIF.

*   Condition Deletion Indicator
    IF ( NOT s_loevm-low IS INITIAL    AND
       NOT s_loevm-high IS INITIAL ) OR
     ( s_loevm-low IS INITIAL        AND
       NOT s_loevm-high IS INITIAL ).

      l_wa_input_field-fieldname = c_loevm_ko.              "LOEVM_KO
      l_wa_input_field-selname = c_loevm_low.         "S_LOEVM-LOW
      l_wa_input_field-reln  = c_option_ge.                 "GE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

      l_wa_input_field-fieldname = c_loevm_ko.              "LOEVM_KO
      l_wa_input_field-selname = c_loevm_high.         "S_LOEVM-HIGH
      l_wa_input_field-reln  = c_option_le.                 "LE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

    ELSEIF NOT s_loevm-low IS INITIAL AND
               s_loevm-high IS INITIAL.

      l_wa_input_field-fieldname = c_loevm_ko.              "LOEVM_KO
      l_wa_input_field-selname = c_loevm_low.           "S_LOEVM-LOW
      l_wa_input_field-reln  = c_option_eq.                 "EQ
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.
    ENDIF.

*   Rebate Recipient
    IF ( NOT s_bonem-low IS INITIAL    AND
       NOT s_bonem-high IS INITIAL ) OR
     ( s_bonem-low IS INITIAL        AND
       NOT s_bonem-high IS INITIAL ).

      l_wa_input_field-fieldname = c_bonem.                  "BONEM
      l_wa_input_field-selname = c_bonem_low.            "S_BONEM-LOW
      l_wa_input_field-reln  = c_option_ge.                  "GE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

      l_wa_input_field-fieldname = c_bonem.             "BONEM
      l_wa_input_field-selname = c_bonem_high.          "S_BONEM-HIGH'.
      l_wa_input_field-reln  = c_option_le.             "LE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

    ELSEIF NOT s_bonem-low IS INITIAL AND
               s_bonem-high IS INITIAL.

      l_wa_input_field-fieldname = c_bonem.            "BONEM
      l_wa_input_field-selname = c_bonem_low.          "S_BONEM-LOW
      l_wa_input_field-reln  = c_option_eq.            "EQ
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.
    ENDIF.

*   Rebate Agreement Status
    IF ( NOT s_bosta-low IS INITIAL    AND
       NOT s_bosta-high IS INITIAL ) OR
     ( s_bosta-low IS INITIAL        AND
       NOT s_bosta-high IS INITIAL ).

      l_wa_input_field-fieldname = c_bosta.                  "BOSTA
      l_wa_input_field-selname = c_bosta_low.           "S_BOSTA-LOW
      l_wa_input_field-reln  = c_option_ge.                  "GE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

      l_wa_input_field-fieldname = c_bosta.    "BOSTA
      l_wa_input_field-selname = c_bosta_high. "S_BOSTA-HIGH
      l_wa_input_field-reln  = c_option_le.                  "LE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

    ELSEIF NOT s_bosta-low IS INITIAL AND
               s_bosta-high IS INITIAL.

      l_wa_input_field-fieldname = c_bosta.    "BOSTA
      l_wa_input_field-selname = c_bosta_low.  "S_BOSTA-LOW
      l_wa_input_field-reln  = c_option_eq.    "EQ
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.
    ENDIF.

* Begin of MOD-001

*   Departure Country
    IF ( NOT s_aland-low IS INITIAL    AND
       NOT s_aland-high IS INITIAL ) OR
     ( s_aland-low IS INITIAL        AND
       NOT s_aland-high IS INITIAL ).

      l_wa_input_field-fieldname = 'ALAND'.
      l_wa_input_field-selname = 'S_ALAND-LOW'.
      l_wa_input_field-reln  = c_option_ge.                  "GE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

      l_wa_input_field-fieldname = 'ALAND'.
      l_wa_input_field-selname = 'S_ALAND-HIGH'.
      l_wa_input_field-reln  = c_option_le.                  "LE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

    ELSEIF NOT s_aland-low IS INITIAL AND
               s_aland-high IS INITIAL.

      l_wa_input_field-fieldname = 'ALAND'.
      l_wa_input_field-selname = 'S_ALAND-LOW'.
      l_wa_input_field-reln  = c_option_eq.    "EQ
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.
    ENDIF.

*   Rebate Agreement Type
    IF ( NOT s_boart-low IS INITIAL    AND
       NOT s_boart-high IS INITIAL ) OR
     ( s_boart-low IS INITIAL        AND
       NOT s_boart-high IS INITIAL ).

      l_wa_input_field-fieldname = 'BOART'.
      l_wa_input_field-selname = 'S_BOART-LOW'.
      l_wa_input_field-reln  = c_option_ge.                  "GE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

      l_wa_input_field-fieldname = 'BOART'.
      l_wa_input_field-selname = 'S_BOART-HIGH'.
      l_wa_input_field-reln  = c_option_le.                  "LE
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.

    ELSEIF NOT s_boart-low IS INITIAL AND
               s_boart-high IS INITIAL.

      l_wa_input_field-fieldname = 'BOART'.
      l_wa_input_field-selname = 'S_BOART-LOW'.
      l_wa_input_field-reln  = c_option_eq.    "EQ
      APPEND l_wa_input_field TO ch_i_input_field.
      CLEAR l_wa_input_field.
    ENDIF.

* End of MOD-001

  ENDMETHOD.            "M_INPUT_FIELD

*&---------------------------------------------------------------------*
*&       METHOD m_get_cond_record
*&---------------------------------------------------------------------*
*        Retrieve the Condition Records from the respective Condition  *
*        Tables
*----------------------------------------------------------------------*
  METHOD m_get_cond_record.

    FIELD-SYMBOLS: <fs_t682i> TYPE ty_t682i,
                   <fs_dd03l> TYPE ty_dd03l,
                   <fs_input_field> TYPE ty_input_field,
                   <fs_i_cond_tab_data> TYPE STANDARD TABLE,
                   <fs_wa_cond_tab_data> TYPE ANY,
                   <fs_field> TYPE ANY.

*   Local internal table declaration
    DATA: i_dd03l TYPE SORTED TABLE OF ty_dd03l
                  WITH NON-UNIQUE KEY tabname,
          i_clause TYPE STANDARD TABLE OF ty_clause.

*   Internal table of data
    DATA: i_cond_tab_data TYPE REF TO data.

*   Work area declarations
    DATA: l_wa_clause TYPE ty_clause,
          l_wa_condtab_data TYPE ty_condtab_data.

*   Local variable declaration
    DATA: l_cnt_first TYPE sytabix,  "Counter for where clause
          l_tabname TYPE tabname.    "Table name

*   For each table the primary key fields needs to be retrieved
*   from the database table DD03L
    SELECT tabname    "Table Name
           fieldname  "Field Name
    FROM dd03l        "Table Fields
    INTO TABLE i_dd03l
    FOR ALL ENTRIES IN im_i_t682i
    WHERE tabname = im_i_t682i-tabname.

    IF NOT sy-subrc IS INITIAL.
*     Message
      MESSAGE i030.
      LEAVE LIST-PROCESSING.
    ENDIF.

*   For each table, the fields will be determined. Each field then
*   will be checked whether it exists in the selection screen.
    LOOP AT im_i_t682i ASSIGNING <fs_t682i>.

*     Initialize the counter to count the number of where clause.
      CLEAR : l_cnt_first.

      MOVE <fs_t682i>-tabname TO l_tabname.

*     Creating the Internal table with the structure of the
*     current table.
      CREATE DATA i_cond_tab_data
                            TYPE STANDARD TABLE OF (l_tabname).

      ASSIGN i_cond_tab_data->* TO <fs_i_cond_tab_data>.

      LOOP AT i_dd03l ASSIGNING <fs_dd03l>
                                     WHERE tabname = <fs_t682i>-tabname.

*       If the field in the database table is there in the selection
*       screen then that field could be in the where clause.
        LOOP AT i_input_field ASSIGNING <fs_input_field>
                                 WHERE fieldname = <fs_dd03l>-fieldname.

          IF l_cnt_first GE 1.

*           From the second and subsequent where clause, the following
*           logic will be implemented
            CONCATENATE c_and                        "AND
                        <fs_input_field>-fieldname   "Field name
                        <fs_input_field>-reln        "Relation
                        <fs_input_field>-selname     "Sel screen field
            INTO l_wa_clause SEPARATED BY space.

            APPEND l_wa_clause TO i_clause.
            CLEAR l_wa_clause.

          ELSE.

*           For the first where clause of the table the following
*           logic will be implemented
            CONCATENATE space
                        <fs_input_field>-fieldname
                        <fs_input_field>-reln
                        <fs_input_field>-selname
            INTO l_wa_clause SEPARATED BY space.
            APPEND l_wa_clause TO i_clause.
            CLEAR l_wa_clause.

          ENDIF.

*         Increment the value of the counter
          ADD 1 TO l_cnt_first.

        ENDLOOP.

      ENDLOOP.

*     If the where clause is initial, then the selection from the
*     tables would not be done.
*     This is done do prevent the huge data volume that may be retrived.
*     Due to the following statement, no retrieval will be made from the
*     database where at least one filtering condition is not there in
*     the selection screen.
      IF i_clause IS INITIAL.
        CONTINUE.
      ENDIF.

* BEGIN OF MOD-004

* If the first four charachters of the table name is 'KOTE', then, the
* table is a rebate table. Restrict the selection of conditions in
* rebate table by using value from selection screen.

      IF <fs_dd03l>-tabname(c_pref_len) EQ c_rebtab_prefix.

*     Retrieve all the fields of the particular database table
*     into the internal table that is formed for that particular case
*     based on the where condition of that particular case.
*     Each loop pass will retrieve from a distinct database table.
        SELECT *
        FROM (<fs_dd03l>-tabname)
        INTO TABLE <fs_i_cond_tab_data>
        WHERE (i_clause)
          AND knuma IN s_knuma.

      ELSE.

* END OF MOD-004

*     Retrieve all the fields of the particular database table
*     into the internal table that is formed for that particular case
*     based on the where condition of that particular case.
*     Each loop pass will retrieve from a distinct database table.
        SELECT *
        FROM (<fs_dd03l>-tabname)
        INTO TABLE <fs_i_cond_tab_data>
        WHERE (i_clause).

      ENDIF.                                                "MOD-004

      IF sy-subrc IS INITIAL.

*       If data is found in the database table then the desired fields
*       if found will be taken in one internal table.
        LOOP AT <fs_i_cond_tab_data> ASSIGNING <fs_wa_cond_tab_data>.

*         Usage
          ASSIGN COMPONENT c_kvewe OF STRUCTURE    "KVEWE
                        <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-kvewe = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         Application
          ASSIGN COMPONENT c_kappl OF STRUCTURE    "KAPPL
                        <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-kappl = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         Condition Type
          ASSIGN COMPONENT c_kschl OF STRUCTURE    "KSCHL
              <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-kschl = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         Sold-to Party
          ASSIGN COMPONENT c_kunnr OF STRUCTURE    "KUNNR
              <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-kunnr = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         Customer Hierarchy
          ASSIGN COMPONENT c_hienr OF STRUCTURE    "HIENR
                        <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-hienr = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         Price Group
          ASSIGN COMPONENT c_konda OF STRUCTURE    "KONDA
                        <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-konda = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         Material
          ASSIGN COMPONENT c_matnr OF STRUCTURE    "MATNR
                        <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-matnr = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         Material Group 1
          ASSIGN COMPONENT c_mvgr1 OF STRUCTURE             "MVGR1
                        <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-mvgr1 = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         ProdH1
          ASSIGN COMPONENT c_prodh1 OF STRUCTURE            "PRODH1
                        <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-prodh1 = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         ProdH2
          ASSIGN COMPONENT c_prodh2 OF STRUCTURE            "PRODH2
                        <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-prodh2 = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         ProdH3
          ASSIGN COMPONENT c_prodh3 OF STRUCTURE            "PRODH3
                        <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-prodh3 = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         ProdH4
          ASSIGN COMPONENT c_yyprodh4 OF STRUCTURE          "YYPRODH4
                        <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-yyprodh4 = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         ProdH5
          ASSIGN COMPONENT c_yyprodh5 OF STRUCTURE          "YYPRODH5
                        <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-yyprodh5 = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         Condition Record Number
          ASSIGN COMPONENT c_knumh OF STRUCTURE    "KNUMH
                        <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-knumh = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         Sales Organization
          ASSIGN COMPONENT c_vkorg OF STRUCTURE    "VKORG
                                  <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-vkorg = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         Distribution Channel
          ASSIGN COMPONENT c_vtweg OF STRUCTURE    "VTWEG
                                  <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-vtweg = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         Campaign ID
          ASSIGN COMPONENT c_cmpgn_id OF STRUCTURE    "CMPGN_ID
                                  <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-cmpgn_id = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         Campaign ID (External)
*-->Begin of Biswarup TPR18842 25.04.2005 comment
*          ASSIGN COMPONENT c_external_id OF STRUCTURE  "EXTERNAL_ID
*                                  <fs_wa_cond_tab_data>  TO <fs_field>.
*
*          IF <fs_field> IS ASSIGNED.
*            l_wa_condtab_data-external_id = <fs_field>.
*            UNASSIGN <fs_field>.
*          ENDIF.
*<--End of Biswarup TPR18842 25.04.2005 comment
*-->Begin of Biswarup TPR18842 25.04.2005
          READ TABLE i_cgpl_project INTO rec_cgpl_project
            WITH KEY bwidentifier = l_wa_condtab_data-cmpgn_id
            BINARY SEARCH.
          IF sy-subrc = 0.
            l_wa_condtab_data-external_id
                            = rec_cgpl_project-external_id.
          ENDIF.
*<--End of Biswarup TPR18842 25.04.2005

*         Condition Valid On
          ASSIGN COMPONENT c_datab OF STRUCTURE  "DATAB
                                  <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-datab = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         Condition Valid To
          ASSIGN COMPONENT c_datbi OF STRUCTURE  "DATBI
                                   <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-datbi = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

* Begin of MOD-001

*         Departure Country
          ASSIGN COMPONENT 'ALAND' OF STRUCTURE
                                   <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-aland = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         Destination Country
          ASSIGN COMPONENT 'LLAND' OF STRUCTURE
                                   <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-lland = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         Tax classification 1 for customer
          ASSIGN COMPONENT 'TAXK1' OF STRUCTURE
                                   <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-taxk1 = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         Tax classification material
          ASSIGN COMPONENT 'TAXM1' OF STRUCTURE
                                   <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-taxm1 = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

*         Tax on sales/purchases code
          ASSIGN COMPONENT 'MWSKZ' OF STRUCTURE
                                   <fs_wa_cond_tab_data>  TO <fs_field>.

          IF <fs_field> IS ASSIGNED.
            l_wa_condtab_data-mwskz = <fs_field>.
            UNASSIGN <fs_field>.
          ENDIF.

**         Rebate Agreement Type
*          ASSIGN COMPONENT 'BOART' OF STRUCTURE
*                                   <fs_wa_cond_tab_data>  TO <fs_field>
          .
*
*          IF <fs_field> IS ASSIGNED.
*            l_wa_condtab_data-datbi = <fs_field>.
*            UNASSIGN <fs_field>.
*          ENDIF.

* End of MOD-001

          APPEND l_wa_condtab_data TO ch_i_condtab_data.
          CLEAR l_wa_condtab_data.

        ENDLOOP.

      ENDIF.

      REFRESH i_clause.

    ENDLOOP.

*   Retain those records where the Application is
*   related only to Sales & Distribution
    DELETE ch_i_condtab_data WHERE kappl <> c_kappl_v.

**Begin of MOD-003 --------------------------------------------------*
*   Retain only those records that belong to a
*   particular Sales org and distribution channel
    DELETE ch_i_condtab_data WHERE vkorg = c_no AND vtweg = c_no.
**Begin of MOD-003 --------------------------------------------------*

    IF NOT p_cdatab IS INITIAL.
      DELETE ch_i_condtab_data WHERE datab < p_cdatab.
    ENDIF.

    IF NOT p_cdatbi IS INITIAL.
      DELETE ch_i_condtab_data WHERE datbi > p_cdatbi.
    ENDIF.

*   If the internal table is empty then no data has been selected
*   for the given set of selection criteria.
    IF ch_i_condtab_data IS INITIAL.
      MESSAGE i030.
      LEAVE LIST-PROCESSING.
    ENDIF.

  ENDMETHOD.            "M_GET_COND_RECORD
*&---------------------------------------------------------------------*
*&       METHOD m_get_cond_data
*&---------------------------------------------------------------------*
*        Retrieve the Condition data from the Condition Header KONH    *
*        and the Condition Item KONP.                                  *
*----------------------------------------------------------------------*
  METHOD m_get_cond_data.

*   Local internal table for free goods conditions
    DATA: l_i_kondn TYPE STANDARD TABLE OF ty_kondn.
*   Work area declarations    .
    DATA: l_wa_condtab_data TYPE ty_condtab_data,
          l_wa_cond_knumh TYPE cond_knumh.

*   Accumulate all the Condition Records (KNUMH) into one
*   Internal table.
    LOOP AT im_i_condtab_data INTO l_wa_condtab_data.
      l_wa_cond_knumh-knumh = l_wa_condtab_data-knumh.
      APPEND l_wa_cond_knumh TO ch_i_knumh.
      CLEAR l_wa_cond_knumh.
    ENDLOOP.

***********************************************************************
*   Retrieval of Condition and related scales data from the SAP       *
*   database tables for General Pricing and Rebate.                   *
***********************************************************************
*   Retrieve the Condition detail from the database tables
*   KONH & KONP only for General Pricing and Free Goods
    IF p_price = c_yes OR p_rebate = c_yes.

      CALL FUNCTION 'SELECT_PRICES_DETAILS'
        TABLES
          t_knumh = ch_i_knumh      "Table containing Condition Records
          t_konh  = ch_i_konhdb     "Table containing Condition Header
          t_konp  = ch_i_konpdb     "Table containing Condition Detail
          t_konm  = ch_i_konm       "Table containing Scales
          t_konw  = ch_i_konw.      "Table containing Scales
    ENDIF.

***********************************************************************
*   Retrieval of Condition and related scales data from the SAP       *
*   database tables for Free Goods.                                   *
***********************************************************************
    IF p_freegd = c_yes.

*     For the detail of Free Goods condition retrieve data
*     from the database table KONDN
      SELECT knumh      "Condition record number
             knrmm      "Minimum quantity
             knrnm      "Free goods quantity
             knrme      "Quantity unit for minimum/free quantity
             knrzm      "Additional quantity for free goods
             knrez      "Quantity unit for free good additnl qty
             knrrr      "Calculation type for free goods qty
             knrdd      "Free goods category
             lstanr     "Free goods delivery control
             knrmat  "Scale basis indicator
      FROM kondn        "Conditions: Free goods - Data section
      INTO TABLE ch_i_kondn
      FOR ALL ENTRIES IN ch_i_knumh
      WHERE knumh = ch_i_knumh-knumh.

      IF NOT sy-subrc IS INITIAL.
        MESSAGE i064.
      ELSE.

      ENDIF.

    ENDIF.

  ENDMETHOD.            "M_GET_COND_DATA
*&---------------------------------------------------------------------*
*&       METHOD m_get_crm_bwidentifier
*&---------------------------------------------------------------------*
*        Retrieve the BWIDENTIFIER from the table CGPL_PROJECT in CRM  *
*                                                                      *
*----------------------------------------------------------------------*
  METHOD m_get_crm_bwidentifier.

    FIELD-SYMBOLS: <l_fs_cgpl_project> TYPE ty_cgpl_project.

*   Local internal table declaration
    DATA: l_i_cgpl_project TYPE STANDARD TABLE OF ty_cgpl_project.
*   Variable for storing RFC destination
    DATA: l_rfcdest TYPE rfcdest.
    DATA: l_rec_scampid LIKE LINE OF s_campid.
    DATA: l_v_lines TYPE i.

    DATA: BEGIN OF rec_selopt,
           sign TYPE tvarv_sign,
           option TYPE tvarv_opti,
           low TYPE tvarv_val,
           high TYPE tvarv_val,
          END OF rec_selopt.

    CALL FUNCTION '/GLB/RGT_RFC_DESTINATION'
      EXPORTING
        destsysttype                 = c_sys_type    "C
      IMPORTING
        rfcdest                      = l_rfcdest
      EXCEPTIONS
        no_destination_found         = 1
        own_logical_system_not_found = 2
        OTHERS                       = 3.

    IF sy-subrc IS INITIAL.

* If the CRM system entered by the user does not match with the
* CRM system that has been determined then RFC will be done
* to the determined CRM destination following an information message.
      IF NOT p_crmsys IS INITIAL.
        IF l_rfcdest <> p_crmsys.

          MESSAGE i076 WITH l_rfcdest.

        ENDIF.
      ENDIF.

*-->Begin of TPR18842 Biswarup 20.04.2005
      DATA:
        l_i_external_id  TYPE rsparams_tt,
        l_wa_external_id TYPE rsparams,
        l_wa_xcamid LIKE LINE OF s_xcamid.

      REFRESH l_i_external_id.
      LOOP AT s_xcamid INTO l_wa_xcamid.
        CLEAR l_wa_external_id.
        l_wa_external_id-sign = l_wa_xcamid-sign.
        l_wa_external_id-option = l_wa_xcamid-option.
        l_wa_external_id-low = l_wa_xcamid-low.
        l_wa_external_id-high = l_wa_xcamid-high.
        APPEND l_wa_external_id TO l_i_external_id.
      ENDLOOP.
*<--End of TPR18842 Biswarup 20.04.2005

      CALL FUNCTION '/EUR/CEUCS_GET_CMPGN_ID' DESTINATION l_rfcdest
        EXPORTING
*-->Begin of TPR18842 Biswarup 20.04.2005 comment
*          im_i_external_id      = s_xcamid
*<--End of TPR18842 Biswarup 20.04.2005 comment
*-->Begin of TPR18842 Biswarup 20.04.2005
           im_i_external_id      =  l_i_external_id
*<--End of TPR18842 Biswarup 20.04.2005

        IMPORTING
          ex_i_cgpl_project     = l_i_cgpl_project
        EXCEPTIONS
          no_data_retrieved     = 1
          communication_failure = 2  MESSAGE v_message
          system_failure        = 3  MESSAGE v_message.

*-->Begin of Biswarup TPR18842 25.04.2005
      REFRESH i_cgpl_project.
      i_cgpl_project = l_i_cgpl_project.
      SORT i_cgpl_project BY bwidentifier.
*<--End of Biswarup TPR18842 25.04.2005

      IF sy-subrc IS INITIAL.

        LOOP AT l_i_cgpl_project ASSIGNING <l_fs_cgpl_project>.

          rec_selopt-sign = c_sign_i.        "I
          rec_selopt-option = c_option_eq.   "EQ
          rec_selopt-low = <l_fs_cgpl_project>-bwidentifier.

          APPEND rec_selopt TO s_campid.
          CLEAR rec_selopt.

        ENDLOOP.
*-->Begin of TPR18842 Biswarup 20.04.2005
        READ TABLE s_campid INTO l_rec_scampid INDEX 1.
        s_campid = l_rec_scampid.
        DESCRIBE TABLE s_campid LINES l_v_lines.
        IF l_v_lines > 1.
          READ TABLE s_campid INTO l_rec_scampid INDEX l_v_lines.
          s_campid-high = l_rec_scampid-low.
        ENDIF.
*<--End of TPR18842 Biswarup 20.04.2005

      ENDIF.
    ENDIF.

  ENDMETHOD.            "M_GET_CRM_BWIDENTIFIER
*&---------------------------------------------------------------------*
*&       METHOD m_get_agreement_data
*&---------------------------------------------------------------------*
*        Retrieve the Agreement data from the database table KONA      *
*                                                                      *
*----------------------------------------------------------------------*
  METHOD m_get_agreement_data.

*   Local internal table of Condition details
    DATA: l_i_konpdb TYPE STANDARD TABLE OF konpdb.

*   Retrieve the Rebate data only for the rebate conditions
    IF NOT p_rebate = c_yes.
      EXIT.
    ENDIF.

    l_i_konpdb = im_i_konpdb.

    DELETE l_i_konpdb WHERE knuma_bo = space.

    IF l_i_konpdb IS INITIAL.
      MESSAGE i065.
      EXIT.
    ENDIF.

*   Retrieve Agreement related data from the SAP database table KONA
    SELECT   knuma         "Agreement
             vkbur         "Sales office
             vkgrp         "Sales group
             boart         "Agreement type
             ernam         "Name of Person who Created the Object
             erdat         "Date on which the record was created
             erzet         "Entry time
             aenam         "Name of person who changed object
             aedat         "Date of Last Change
             aezet         "Time last change was made
             bonem         "Rebate recipient
             waers         "Currency Key
             abrex         "External description for agreement
             abspz         "Scope of verification level of rebate
             bosta         "Status of the agreement
             datab         "Agreement valid-from date
             datbi         "Agreement valid-to date
             kobog         "Condition type/table group for agr
             botext        "Description of agreement
             zlsch         "Payment method
             bon_enh_vakey  "Indicates Enhand Reb Sett
             bon_enh_indirect  "Ind for Indir Settlmnt
    FROM kona              "Rebate Agreements
    INTO TABLE ch_i_kona
    FOR ALL ENTRIES IN l_i_konpdb
    WHERE knuma = l_i_konpdb-knuma_bo
    AND vkorg IN s_vkorg                                    "MOD-003
    AND vtweg IN s_vtweg                                    "MOD-003
    AND bonem IN s_bonem
    AND bosta IN s_bosta.

    IF NOT sy-subrc IS INITIAL.
      MESSAGE i065.
    ELSE.
      IF NOT p_rdatab IS INITIAL.
        DELETE ch_i_kona WHERE datab < p_rdatab.
      ENDIF.

      IF NOT ch_i_kona IS INITIAL.
        IF NOT p_rdatbi IS INITIAL.
          DELETE ch_i_kona WHERE datbi > p_rdatbi.
        ENDIF.
      ENDIF.

      IF NOT ch_i_kona IS INITIAL.
        CALL METHOD m_get_rebate_accrual_values.
      ENDIF.

    ENDIF.

  ENDMETHOD.            "M_GET_AGREEMENT_DATA

*&---------------------------------------------------------------------*
*&       METHOD m_get_rebate_accrual_values
*&---------------------------------------------------------------------*
*        Retrieve the Rebate Accrusl Values
*----------------------------------------------------------------------*
  METHOD m_get_rebate_accrual_values.

    FIELD-SYMBOLS: <l_fs_kona> TYPE ty_kona,
                   <l_fs_t6b1> TYPE t6b1,
                   <l_fs_konp> TYPE konpdb,
                   <l_fs_cond_itm> TYPE konpdb.

    DATA: l_i_t6b1 TYPE STANDARD TABLE OF t6b1,
          l_i_cond_itm TYPE STANDARD TABLE OF konpdb,
          l_i_cond_scl TYPE STANDARD TABLE OF condscale,
          l_i_cond_key TYPE STANDARD TABLE OF vakevb.

    DATA: l_wa_kona_tab TYPE kona,
          l_wa_t6b1 TYPE t6b1.

    l_i_cond_itm = i_konpdb.

    SELECT *
    FROM t6b1
    INTO TABLE l_i_t6b1
    FOR ALL ENTRIES IN i_kona
    WHERE boart = i_kona-boart.

    IF sy-subrc IS INITIAL.

      SORT l_i_t6b1 BY boart.

      LOOP AT i_kona ASSIGNING <l_fs_kona>.

***********************************
* Populate the work area for KONA *
***********************************
*       Agreement
        l_wa_kona_tab-knuma = <l_fs_kona>-knuma.
*       Sales office
        l_wa_kona_tab-vkbur = <l_fs_kona>-vkbur.
*       Sales group
        l_wa_kona_tab-vkgrp = <l_fs_kona>-vkgrp.
*       Agreement type
        l_wa_kona_tab-boart = <l_fs_kona>-boart.
*       Name of Person who Created the Object
        l_wa_kona_tab-ernam = <l_fs_kona>-ernam.
*       Date on which the record was created
        l_wa_kona_tab-erdat = <l_fs_kona>-erdat.
*       Entry time
        l_wa_kona_tab-erzet = <l_fs_kona>-erzet.
*       Name of person who changed object
        l_wa_kona_tab-aenam = <l_fs_kona>-aenam.
*       Date of Last Change
        l_wa_kona_tab-aedat = <l_fs_kona>-aedat.
*       Time last change was made
        l_wa_kona_tab-aezet = <l_fs_kona>-aezet.
*       Rebate recipient
        l_wa_kona_tab-bonem = <l_fs_kona>-bonem.
*       Currency Key
        l_wa_kona_tab-waers = <l_fs_kona>-waers.
*       External description for agreement
        l_wa_kona_tab-abrex = <l_fs_kona>-abrex.
*       Scope of verification level of rebate
        l_wa_kona_tab-abspz = <l_fs_kona>-abspz.
*       Status of the agreement
        l_wa_kona_tab-bosta = <l_fs_kona>-bosta.
*       Agreement valid-from date
        l_wa_kona_tab-datab = <l_fs_kona>-datab.
*       Agreement valid-to date
        l_wa_kona_tab-datbi = <l_fs_kona>-datbi.
*       Condition type/table group for agr
        l_wa_kona_tab-kobog = <l_fs_kona>-kobog.
*       Description of agreement
        l_wa_kona_tab-botext = <l_fs_kona>-botext.
*       Payment method
        l_wa_kona_tab-zlsch = <l_fs_kona>-zlsch.
*       Indicates Enhand Reb Sett
        l_wa_kona_tab-bon_enh_vakey = <l_fs_kona>-bon_enh_vakey.
*       Ind for Indir Settlmnt
        l_wa_kona_tab-bon_enh_indirect = <l_fs_kona>-bon_enh_indirect.

        READ TABLE l_i_t6b1 INTO l_wa_t6b1
                            WITH KEY boart = <l_fs_kona>-boart
                            BINARY SEARCH.

        IF sy-subrc IS INITIAL.

          CALL FUNCTION 'SD_BONUS_KONPD_FILL'
            EXPORTING
              rebate_agreement      = l_wa_kona_tab
              rebate_agreement_type = l_wa_t6b1
              period_datab          = l_wa_kona_tab-datab
              period_datbi          = l_wa_kona_tab-datbi
            TABLES
              cond_item             = l_i_cond_itm
              cond_scales           = l_i_cond_scl
              cond_keys             = l_i_cond_key
            EXCEPTIONS
              invalid_bonus_type    = 1
              OTHERS                = 2.

          IF sy-subrc IS INITIAL.

            SORT l_i_cond_itm BY knumh kopos.

            LOOP AT i_konpdb ASSIGNING <l_fs_konp>.

              READ TABLE l_i_cond_itm ASSIGNING <l_fs_cond_itm>
                             WITH KEY knumh = <l_fs_konp>-knumh
                                      kopos = <l_fs_konp>-kopos
                                      knuma_bo = <l_fs_konp>-knuma_bo
                                      BINARY SEARCH.

              IF sy-subrc IS INITIAL.

*               Rebate Accruals
                <l_fs_konp>-ruwrt = <l_fs_cond_itm>-ruwrt.
*               Rebate Accruals Reversed
                <l_fs_konp>-rrwrt = <l_fs_cond_itm>-rrwrt.
*               Rebate Payments
                <l_fs_konp>-auwrt = <l_fs_cond_itm>-auwrt.
*               Rebate: Maximum payable amount
                <l_fs_konp>-mpwrt = <l_fs_cond_itm>-mpwrt.
*               Rebate: Amount to be paid
                <l_fs_konp>-bzwrt = <l_fs_cond_itm>-bzwrt.

              ENDIF.
            ENDLOOP.

          ENDIF.

        ENDIF.

        REFRESH: l_i_cond_itm,
                 l_i_cond_scl,
                 l_i_cond_key.

        CLEAR: l_wa_kona_tab,
               l_wa_t6b1.

      ENDLOOP.

    ENDIF.
  ENDMETHOD.                    "m_get_rebate_accrual_values
*&---------------------------------------------------------------------*
*&       METHOD m_get_texts
*&---------------------------------------------------------------------*
*        Retrieve the descriptive texts
*----------------------------------------------------------------------*
  METHOD m_get_texts.

    FIELD-SYMBOLS: <l_fs_condtab_data> TYPE ty_condtab_data,
                   <l_fs_kondns> TYPE ty_kondns.

*   Declaration of local internal tables for temporary use
    DATA: l_i_condtab_data TYPE STANDARD TABLE OF ty_condtab_data,
          l_i_kondns TYPE STANDARD TABLE OF ty_kondns,
          l_i_kona TYPE STANDARD TABLE OF ty_kona,
*   Internal table to collect all condition & free goods material
          l_i_matnr TYPE STANDARD TABLE OF ty_matnr,
*   Internal table to collect all Customer & Customer Hierarchy
          l_i_kunnr TYPE STANDARD TABLE OF ty_kunnr.

*   Work area for the internal table for Material
    DATA: l_wa_matnr TYPE ty_matnr,
*   Work area for the internal table of Customer
          l_wa_kunnr TYPE ty_kunnr.

* Retrieve the Condition Type descriptions
    l_i_condtab_data = i_condtab_data.

    SORT l_i_condtab_data BY kschl.

    DELETE ADJACENT DUPLICATES FROM l_i_condtab_data COMPARING kschl.

    SELECT kschl
           vtext
    FROM t685t
    INTO TABLE i_t685t
    FOR ALL ENTRIES IN l_i_condtab_data
    WHERE spras = sy-langu
    AND kschl = l_i_condtab_data-kschl.

    IF NOT sy-subrc IS INITIAL.

      SELECT kschl
             vtext
      FROM t685t
      INTO TABLE i_t685t
      FOR ALL ENTRIES IN l_i_condtab_data
      WHERE spras = c_eng                   "E
      AND kschl = l_i_condtab_data-kschl.

    ENDIF.

* Retrieve the Material description
    REFRESH l_i_condtab_data.

    l_i_condtab_data = i_condtab_data.
    l_i_kondns = i_kondns.

    SORT l_i_condtab_data BY matnr.
    SORT l_i_kondns BY knrmat.

    DELETE ADJACENT DUPLICATES FROM l_i_condtab_data COMPARING matnr.
    DELETE ADJACENT DUPLICATES FROM l_i_kondns COMPARING knrmat.

    LOOP AT l_i_condtab_data ASSIGNING <l_fs_condtab_data>.

      l_wa_matnr-matnr = <l_fs_condtab_data>-matnr.
      APPEND l_wa_matnr TO l_i_matnr.
      CLEAR l_wa_matnr.

    ENDLOOP.

    LOOP AT l_i_kondns ASSIGNING <l_fs_kondns>.

      l_wa_matnr-matnr = <l_fs_kondns>-knrmat.
      APPEND l_wa_matnr TO l_i_matnr.
      CLEAR l_wa_matnr.

    ENDLOOP.

    SORT l_i_matnr BY matnr.
    DELETE ADJACENT DUPLICATES FROM l_i_matnr COMPARING matnr.

    SELECT matnr
           maktx
    FROM makt
    INTO TABLE i_makt
    FOR ALL ENTRIES IN l_i_matnr
    WHERE matnr = l_i_matnr-matnr
    AND spras = sy-langu.

    IF NOT sy-subrc IS INITIAL.
      SELECT matnr
             maktx
      FROM makt
      INTO TABLE i_makt
      FOR ALL ENTRIES IN l_i_matnr
      WHERE matnr = l_i_matnr-matnr
      AND spras = c_eng.                   "E

    ENDIF.

* Retrieve the Name of the Customer
    l_i_condtab_data = i_condtab_data.

    SORT l_i_condtab_data BY kunnr.

    DELETE ADJACENT DUPLICATES FROM l_i_condtab_data COMPARING kunnr.

    LOOP AT l_i_condtab_data ASSIGNING <l_fs_condtab_data>.

      l_wa_kunnr-kunnr = <l_fs_condtab_data>-kunnr.
      APPEND l_wa_kunnr TO l_i_kunnr.
      CLEAR l_wa_kunnr.

    ENDLOOP.

    REFRESH l_i_condtab_data.

    l_i_condtab_data = i_condtab_data.

    SORT l_i_condtab_data BY hienr.

    DELETE ADJACENT DUPLICATES FROM l_i_condtab_data COMPARING hienr.

    LOOP AT l_i_condtab_data ASSIGNING <l_fs_condtab_data>.

      l_wa_kunnr-kunnr = <l_fs_condtab_data>-hienr.
      APPEND l_wa_kunnr TO l_i_kunnr.
      CLEAR l_wa_kunnr.

    ENDLOOP.

    SORT l_i_kunnr BY kunnr.
    DELETE ADJACENT DUPLICATES FROM l_i_kunnr COMPARING kunnr.

    SELECT kunnr
           name1
    FROM kna1
    INTO TABLE i_kna1
    FOR ALL ENTRIES IN l_i_kunnr
    WHERE kunnr = l_i_kunnr-kunnr.

* Retrieve the Price Group description
    REFRESH l_i_condtab_data.

    l_i_condtab_data = i_condtab_data.

    SORT l_i_condtab_data BY konda.

    DELETE ADJACENT DUPLICATES FROM l_i_condtab_data COMPARING konda.

    SELECT konda
           vtext
    FROM t188t
    INTO TABLE i_t188t
    FOR ALL ENTRIES IN l_i_condtab_data
    WHERE spras = sy-langu
    AND konda = l_i_condtab_data-konda.

    IF NOT sy-subrc IS INITIAL.
      SELECT konda
             vtext
      FROM t188t
      INTO TABLE i_t188t
      FOR ALL ENTRIES IN l_i_condtab_data
      WHERE spras = c_eng                  "E
      AND konda = l_i_condtab_data-konda.

    ENDIF.

* Retrieve the Material Group 1 description
    REFRESH l_i_condtab_data.

    l_i_condtab_data = i_condtab_data.

    SORT l_i_condtab_data BY mvgr1.

    DELETE ADJACENT DUPLICATES FROM l_i_condtab_data COMPARING mvgr1.

    SELECT mvgr1
           bezei
    FROM tvm1t
    INTO TABLE i_tvm1t
    FOR ALL ENTRIES IN l_i_condtab_data
    WHERE spras = sy-langu
    AND mvgr1 = l_i_condtab_data-mvgr1.

    IF NOT sy-subrc IS INITIAL.

      SELECT mvgr1
             bezei
      FROM tvm1t
      INTO TABLE i_tvm1t
      FOR ALL ENTRIES IN l_i_condtab_data
      WHERE spras = c_eng                  "E
      AND mvgr1 = l_i_condtab_data-mvgr1.

    ENDIF.

* Retrieve the Rebate Agreement Type description
    IF NOT i_kona IS INITIAL.

      l_i_kona = i_kona.

      SORT l_i_kona BY boart.

      DELETE ADJACENT DUPLICATES FROM l_i_kona COMPARING boart.

      SELECT boart      "Agreement type
             vtext      "Description
      FROM t6b1t
      INTO TABLE i_t6b1t
      FOR ALL ENTRIES IN l_i_kona
      WHERE spras = sy-langu
      AND boart = l_i_kona-boart.

      IF NOT sy-subrc IS INITIAL.

        SELECT boart      "Agreement type
               vtext      "Description
        FROM t6b1t
        INTO TABLE i_t6b1t
        FOR ALL ENTRIES IN l_i_kona
        WHERE spras = c_eng            "E
        AND boart = l_i_kona-boart.

      ENDIF.
    ENDIF.

* Free goods: Text output for exclusive or inclusive
    SELECT valpos      "Domain value key
           ddtext      "Short text for fixed values
    FROM dd07t
    INTO TABLE i_dd07t
    WHERE domname = c_knrdd      "KNRDD
    AND ddlanguage = sy-langu.

    IF NOT sy-subrc IS INITIAL.

      SELECT valpos      "Domain value key
             ddtext      "Short text for fixed values
      FROM dd07t
      INTO TABLE i_dd07t
      WHERE domname = c_knrdd    "KNRDD
      AND ddlanguage = c_eng.    "E

    ENDIF.

  ENDMETHOD.            "M_GET_TEXTS.
*&---------------------------------------------------------------------*
*&       METHOD m_process_data
*&---------------------------------------------------------------------*
*        Process the retrieved data to build the final Internal Table
*----------------------------------------------------------------------*
  METHOD m_process_data.

    FIELD-SYMBOLS: <l_fs_knumh> TYPE cond_knumh,
                   <l_fs_konpdb> TYPE konpdb,
                   <l_fs_konhdb> TYPE konhdb,
                   <l_fs_condtab_data> TYPE ty_condtab_data,
                   <l_fs_kona> TYPE ty_kona,
                   <l_fs_kondn> TYPE ty_kondn,
                   <l_fs_t685t> TYPE ty_t685t,
                   <l_fs_makt> TYPE ty_makt,
                   <l_fs_kna1> TYPE ty_kna1,
                   <l_fs_t188t> TYPE ty_t188t,
                   <l_fs_tvm1t> TYPE ty_tvm1t,
                   <l_fs_konm> TYPE cond_konm,
                   <l_fs_t6b1t> TYPE ty_t6b1t,
                   <l_fs_kondns> TYPE ty_kondns,
                   <l_fs_dd07t> TYPE ty_dd07t.

*   Work area of the final internal table
    DATA: l_wa_condtn_rep TYPE ty_condtn_rep.
*   Counter for loop passes
    DATA: l_cnt TYPE sytabix.

*   Get the descriptive texts of the desired fields
    CALL METHOD m_get_texts.

    SORT i_condtab_data BY knumh.
    SORT i_konpdb BY knumh.
    SORT i_konhdb BY knumh.
    SORT i_konm BY knumh.
    SORT i_konw BY knumh.

    LOOP AT i_knumh ASSIGNING <l_fs_knumh>.

*     General Condition data
      READ TABLE i_condtab_data ASSIGNING <l_fs_condtab_data>
                          WITH KEY knumh = <l_fs_knumh>-knumh
                          BINARY SEARCH.

      IF sy-subrc IS INITIAL.

*       Condition Type
        l_wa_condtn_rep-kschl = <l_fs_condtab_data>-kschl.
*       Sold To Number
        l_wa_condtn_rep-kunnr = <l_fs_condtab_data>-kunnr.
*       Customer Hierarchy Number
        l_wa_condtn_rep-hienr = <l_fs_condtab_data>-hienr.
*       Price Group Name
        l_wa_condtn_rep-konda = <l_fs_condtab_data>-konda.
*       Material Number
        l_wa_condtn_rep-matnr = <l_fs_condtab_data>-matnr.
*       Material Group 1
        l_wa_condtn_rep-mvgr1 = <l_fs_condtab_data>-mvgr1.
*       ProdH 1 - Business
        l_wa_condtn_rep-prodh1 = <l_fs_condtab_data>-prodh1.
*       ProdH 2 â€" Business ID
        l_wa_condtn_rep-prodh2 = <l_fs_condtab_data>-prodh2.
*       ProdH 3 - Category
        l_wa_condtn_rep-prodh3 = <l_fs_condtab_data>-prodh3.
*       ProdH 4 â€" Sub-Categ
        l_wa_condtn_rep-yyprodh4 = <l_fs_condtab_data>-yyprodh4.
*       ProdH 5 â€" Seg/Sub Seg
        l_wa_condtn_rep-yyprodh5 = <l_fs_condtab_data>-yyprodh5.
*       Campaign ID
        l_wa_condtn_rep-cmpgn_id = <l_fs_condtab_data>-cmpgn_id.
*       Campaign (External ID)
        l_wa_condtn_rep-external_id = <l_fs_condtab_data>-external_id.
*       Sales Organization
        l_wa_condtn_rep-vkorg = <l_fs_condtab_data>-vkorg.
*       Distribution Channel
        l_wa_condtn_rep-vtweg = <l_fs_condtab_data>-vtweg.

* Begin of MOD-001

*       Departure Country
        l_wa_condtn_rep-aland = <l_fs_condtab_data>-aland.
*       Destination Country
        l_wa_condtn_rep-lland = <l_fs_condtab_data>-lland.
*       Tax classification 1 for customer
        l_wa_condtn_rep-taxk1 = <l_fs_condtab_data>-taxk1.
*       Tax classification material
        l_wa_condtn_rep-taxm1 = <l_fs_condtab_data>-taxm1.
*       Tax on sales/purchases code
        l_wa_condtn_rep-mwskz = <l_fs_condtab_data>-mwskz.

* End of MOD-001

        READ TABLE i_t685t ASSIGNING <l_fs_t685t>
                  WITH KEY kschl = <l_fs_condtab_data>-kschl
                  BINARY SEARCH.

        IF sy-subrc IS INITIAL.
*         Condition Type Description
          l_wa_condtn_rep-cvtext = <l_fs_t685t>-vtext.
        ENDIF.

        READ TABLE i_makt ASSIGNING <l_fs_makt>
                  WITH KEY matnr = <l_fs_condtab_data>-matnr
                  BINARY SEARCH.

        IF sy-subrc IS INITIAL.
*         Material Description
          l_wa_condtn_rep-maktx = <l_fs_makt>-maktx.
        ENDIF.

        READ TABLE i_kna1 ASSIGNING <l_fs_kna1>
                          WITH KEY kunnr = <l_fs_condtab_data>-kunnr
                          BINARY SEARCH.

        IF sy-subrc IS INITIAL.
*         Sold To Name
          l_wa_condtn_rep-name1 = <l_fs_kna1>-name1.
        ENDIF.

        READ TABLE i_kna1 ASSIGNING <l_fs_kna1>
                          WITH KEY kunnr = <l_fs_condtab_data>-hienr
                          BINARY SEARCH.

        IF sy-subrc IS INITIAL.
*         Customer Hierarchy Name
          l_wa_condtn_rep-name1_c = <l_fs_kna1>-name1.
        ENDIF.

        READ TABLE i_t188t ASSIGNING <l_fs_t188t>
                               WITH KEY konda =
                               <l_fs_condtab_data>-konda
                               BINARY SEARCH.

        IF sy-subrc IS INITIAL.
*         Price Group Description
          l_wa_condtn_rep-pvtext = <l_fs_t188t>-vtext.
        ENDIF.

        READ TABLE i_tvm1t ASSIGNING <l_fs_tvm1t>
                               WITH KEY mvgr1 =
                               <l_fs_condtab_data>-mvgr1
                               BINARY SEARCH.

        IF sy-subrc IS INITIAL.
*         Material Group 1 Description
          l_wa_condtn_rep-mbezei = <l_fs_tvm1t>-bezei.
        ENDIF.

      ENDIF.

      IF p_price = c_yes OR p_rebate = c_yes.

*     Get the Condition Detail data
        READ TABLE i_konpdb ASSIGNING <l_fs_konpdb>
                            WITH KEY knumh = <l_fs_knumh>-knumh
                            BINARY SEARCH.

        IF sy-subrc IS INITIAL.

*       Condition Amount
          IF <l_fs_konpdb>-konwa = '%'.
            l_wa_condtn_rep-kbetr = <l_fs_konpdb>-kbetr / 10.
          ELSE.
            l_wa_condtn_rep-kbetr = <l_fs_konpdb>-kbetr.
          ENDIF.
*       Condition Unit
          l_wa_condtn_rep-konwa = <l_fs_konpdb>-konwa.
*       Condition Pricing Unit
          l_wa_condtn_rep-kpein = <l_fs_konpdb>-kpein.
*       Condition Unit of Measure
          l_wa_condtn_rep-kmein = <l_fs_konpdb>-kmein.
*       Condition Accrual Amount - Rebate
          l_wa_condtn_rep-kbrue = <l_fs_konpdb>-kbrue.
*       Condition Accrual Unit - Rebate
          l_wa_condtn_rep-kwaeh = <l_fs_konpdb>-kwaeh.
*       Condition Deletion Indicator
          l_wa_condtn_rep-loevm_ko = <l_fs_konpdb>-loevm_ko.
*       Condition Exclusive Indicator
          l_wa_condtn_rep-kznep = <l_fs_konpdb>-kznep.
*       Rebate Retroactive Indicator
          l_wa_condtn_rep-kspae = <l_fs_konpdb>-kspae.
*       Rebate Accruals
          l_wa_condtn_rep-ruwrt = <l_fs_konpdb>-ruwrt.
*       Rebate Accruals Reversed
          l_wa_condtn_rep-rrwrt = <l_fs_konpdb>-rrwrt.
*       Rebate Payments
          l_wa_condtn_rep-auwrt = <l_fs_konpdb>-auwrt.
*       Rebate: Maximum payable amount
          l_wa_condtn_rep-mpwrt = <l_fs_konpdb>-mpwrt.

*       BEGIN OF MOD-004

*       Delta: Payment vs. Settlement of Accruals
          l_wa_condtn_rep-pymt_vs_stmt = l_wa_condtn_rep-auwrt
                                         + l_wa_condtn_rep-rrwrt.
*       Delta: Accruals vs. Settlement of Accruals
          l_wa_condtn_rep-accrl_vs_stmt_accrl
                           = l_wa_condtn_rep-ruwrt
                           + l_wa_condtn_rep-rrwrt.
*       Still Payable
*       If Delta: Payment vs. Settlement of Accruals >= 0.
          IF l_wa_condtn_rep-pymt_vs_stmt GE c_zero.
            l_wa_condtn_rep-st_pybl
                             = l_wa_condtn_rep-auwrt
                             - l_wa_condtn_rep-ruwrt
                             - l_wa_condtn_rep-pymt_vs_stmt.
          ELSE.
            l_wa_condtn_rep-st_pybl
                              = l_wa_condtn_rep-auwrt
                              - l_wa_condtn_rep-ruwrt.
          ENDIF.

*       END OF MOD-004

*       Rebate: Amount to be paid
          l_wa_condtn_rep-bzwrt = <l_fs_konpdb>-bzwrt.
*       Condition Calculation Type
          l_wa_condtn_rep-krech = <l_fs_konpdb>-krech.
*       Condition Scales
          l_wa_condtn_rep-kstbw = <l_fs_konpdb>-kstbw.
*       Condition Scale Basis
          l_wa_condtn_rep-kzbzg = <l_fs_konpdb>-kzbzg.
*       Condition Scale Type
          l_wa_condtn_rep-stfkz = <l_fs_konpdb>-stfkz.
*       Condition Lower Limit
          l_wa_condtn_rep-mxwrt = <l_fs_konpdb>-mxwrt.
*       Condition Upper Limit
          l_wa_condtn_rep-gkwrt = <l_fs_konpdb>-gkwrt.
*       Condition Application
          l_wa_condtn_rep-kappl = <l_fs_konpdb>-kappl.
*       Rebate: Material for Settlement
          l_wa_condtn_rep-bomat = <l_fs_konpdb>-bomat.

* Begin of MOD-001

*       Tax on sales/purchases code
          l_wa_condtn_rep-mwskz = <l_fs_konpdb>-mwsk1.

* End of MOD-001
        ENDIF.

*     Get the Condition Header data
        READ TABLE i_konhdb ASSIGNING <l_fs_konhdb>
                            WITH KEY knumh = <l_fs_knumh>-knumh
                            BINARY SEARCH.

        IF sy-subrc IS INITIAL.

*       Condition Valid On
          l_wa_condtn_rep-datbi = <l_fs_konhdb>-datbi.
*       Condition Valid To
          l_wa_condtn_rep-datab = <l_fs_konhdb>-datab.
*       Condition Created By
          l_wa_condtn_rep-ernam = <l_fs_konhdb>-ernam.
*       Condition Created on Date
          l_wa_condtn_rep-erdat = <l_fs_konhdb>-erdat.
*       Condition Table Usage
          l_wa_condtn_rep-kvewe = <l_fs_konhdb>-kvewe.

        ENDIF.

        READ TABLE i_kona ASSIGNING <l_fs_kona>
                            WITH KEY knuma = <l_fs_konpdb>-knuma_bo
                            BINARY SEARCH.

        IF sy-subrc IS INITIAL.

*       Rebate Agreement Number
          l_wa_condtn_rep-knuma = <l_fs_kona>-knuma.
*       Rebate Agreement Type
          l_wa_condtn_rep-boart = <l_fs_kona>-boart.
*       Enhanced Rebate Indicator
          l_wa_condtn_rep-bon_enh_vakey = <l_fs_kona>-bon_enh_vakey.
*       Indirect Settlement Types Indicator
          l_wa_condtn_rep-bon_enh_indirect = <l_fs_kona>-bon_enh_indirect.
*       Rebate Recipient
          l_wa_condtn_rep-bonem = <l_fs_kona>-bonem.
*       Rebate Currency
          l_wa_condtn_rep-waers = <l_fs_kona>-waers.
*       Rebate Payment Method
          l_wa_condtn_rep-zlsch = <l_fs_kona>-zlsch.
*       Rebate External Description
          l_wa_condtn_rep-abrex = <l_fs_kona>-abrex.
*       Rebate Agreement Valid From
          l_wa_condtn_rep-rdatab = <l_fs_kona>-datab.
*       Rebate Agreement Valid To
          l_wa_condtn_rep-rdatbi = <l_fs_kona>-datbi.
*       Rebate Agreement Status
          l_wa_condtn_rep-bosta = <l_fs_kona>-bosta.
*       Sales Office
          l_wa_condtn_rep-vkbur = <l_fs_kona>-vkbur.
*       Sales Group
          l_wa_condtn_rep-vkgrp = <l_fs_kona>-vkgrp.
*       Rebate Agreement Created By
          l_wa_condtn_rep-ernam = <l_fs_kona>-ernam.
*       Rebate Agreement Created on Date
          l_wa_condtn_rep-erdat = <l_fs_kona>-erdat.
*       Rebate Agreement Created on Time
          l_wa_condtn_rep-erzet = <l_fs_kona>-erzet.
*       Rebate Agreement Changed By
          l_wa_condtn_rep-aenam = <l_fs_kona>-aenam.
*       Rebate Agreement Changed on Date
          l_wa_condtn_rep-aedat = <l_fs_kona>-aedat.
*       Rebate Agreement Changed on Time
          l_wa_condtn_rep-aezet = <l_fs_kona>-aezet.
*       Rebate Agreement Description
          l_wa_condtn_rep-botext = <l_fs_kona>-botext.
*       Rebate Verification Level
          l_wa_condtn_rep-abspz = <l_fs_kona>-abspz.
*       Rebate Condition Type Group
          l_wa_condtn_rep-kobog = <l_fs_kona>-kobog.

          READ TABLE i_t6b1t ASSIGNING <l_fs_t6b1t>
                            WITH KEY boart = <l_fs_kona>-boart
                            BINARY SEARCH.

          IF sy-subrc IS INITIAL.
*         Rebate Agreement Type Description
            l_wa_condtn_rep-rvtext = <l_fs_t6b1t>-vtext.
          ENDIF.

        ENDIF.

        LOOP AT i_konm ASSIGNING <l_fs_konm>
                         WHERE knumh = <l_fs_knumh>-knumh.

          IF l_cnt > 10.
            EXIT.
          ENDIF.

          ADD 1 TO l_cnt.

          CASE l_cnt.
            WHEN 1.
*           Condition Scale Quantity 1
              l_wa_condtn_rep-kstbm1 = <l_fs_konm>-kstbm.
*           Condition Scale Amount 1
              l_wa_condtn_rep-kbetr1 = <l_fs_konm>-kbetr.
            WHEN 2.
*           Condition Scale Quantity 2
              l_wa_condtn_rep-kstbm2 = <l_fs_konm>-kstbm.
*           Condition Scale Amount 2
              l_wa_condtn_rep-kbetr2 = <l_fs_konm>-kbetr.
            WHEN 3.
*           Condition Scale Quantity 3
              l_wa_condtn_rep-kstbm3 = <l_fs_konm>-kstbm.
*           Condition Scale Amount 3
              l_wa_condtn_rep-kbetr3 = <l_fs_konm>-kbetr.
            WHEN 4.
*           Condition Scale Quantity 4
              l_wa_condtn_rep-kstbm4 = <l_fs_konm>-kstbm.
*           Condition Scale Amount 4
              l_wa_condtn_rep-kbetr4 = <l_fs_konm>-kbetr.
            WHEN 5.
*           Condition Scale Quantity 5
              l_wa_condtn_rep-kstbm5 = <l_fs_konm>-kstbm.
*           Condition Scale Amount 5
              l_wa_condtn_rep-kbetr5 = <l_fs_konm>-kbetr.
            WHEN 6.
*           Condition Scale Quantity 6
              l_wa_condtn_rep-kstbm6 = <l_fs_konm>-kstbm.
*           Condition Scale Amount 6
              l_wa_condtn_rep-kbetr6 = <l_fs_konm>-kbetr.
            WHEN 7.
*           Condition Scale Quantity 7
              l_wa_condtn_rep-kstbm7 = <l_fs_konm>-kstbm.
*           Condition Scale Amount 7
              l_wa_condtn_rep-kbetr7 = <l_fs_konm>-kbetr.
            WHEN 8.
*           Condition Scale Quantity 8
              l_wa_condtn_rep-kstbm8 = <l_fs_konm>-kstbm.
*           Condition Scale Amount 8
              l_wa_condtn_rep-kbetr8 = <l_fs_konm>-kbetr.
            WHEN 9.
*           Condition Scale Quantity 9
              l_wa_condtn_rep-kstbm9 = <l_fs_konm>-kstbm.
*           Condition Scale Amount 9
              l_wa_condtn_rep-kbetr9 = <l_fs_konm>-kbetr.
            WHEN 10.
*           Condition Scale Quantity 10
              l_wa_condtn_rep-kstbm10 = <l_fs_konm>-kstbm.
*           Condition Scale Amount 10
              l_wa_condtn_rep-kbetr10 = <l_fs_konm>-kbetr.
          ENDCASE.
        ENDLOOP.
      ENDIF.

      IF p_freegd = c_yes.

        READ TABLE i_kondn ASSIGNING <l_fs_kondn>
                                  WITH KEY knumh = <l_fs_knumh>-knumh
                                  BINARY SEARCH.

        IF sy-subrc IS INITIAL.

*       Free goods: Minimum quantity
          l_wa_condtn_rep-knrmm = <l_fs_kondn>-knrmm.
*       Free goods: Free goods quantity
          l_wa_condtn_rep-knrnm = <l_fs_kondn>-knrnm.
*       Free goods: Quantity unit for minimum quantity
*       and free goods quantity
          l_wa_condtn_rep-knrme = <l_fs_kondn>-knrme.
*       Free goods: Additional quantity
          l_wa_condtn_rep-knrzm = <l_fs_kondn>-knrzm.
*       Free goods: Quantity unit for free goods additional quantity
          l_wa_condtn_rep-knrez = <l_fs_kondn>-knrez.
*       Free goods: Calculation type for determining free goods quantity
          l_wa_condtn_rep-knrrr = <l_fs_kondn>-knrrr.
*       Free goods category
          l_wa_condtn_rep-knrdd = <l_fs_kondn>-knrdd.
*       Free goods delivery control
          l_wa_condtn_rep-lstanr = <l_fs_kondn>-lstanr.
*       Free Goods: Additional Material
          l_wa_condtn_rep-knrmat = <l_fs_kondn>-knrmat.

*       Free goods: Percentage rate
          IF <l_fs_kondn>-knrdd = 1
          OR <l_fs_kondn>-knrdd = 3.
            l_wa_condtn_rep-fgpcr
                = ( <l_fs_kondn>-knrzm * 100 ) / <l_fs_kondn>-knrnm.
          ENDIF.

          IF <l_fs_kondn>-knrdd = 2.
            l_wa_condtn_rep-fgpcr
                      = ( <l_fs_kondn>-knrzm * 100 ) / (
                      <l_fs_kondn>-knrnm +
                                                 <l_fs_kondn>-knrzm )
                                                      .

          ENDIF.

*         The length of the VALPOS and KNRDD is different
*         but there is no chance of data loss.
          READ TABLE i_dd07t ASSIGNING <l_fs_dd07t>
                                WITH KEY valpos = <l_fs_kondn>-knrdd
                                BINARY SEARCH.

          IF sy-subrc IS INITIAL.
*         Free goods: Text output for exclusive or inclusive
            l_wa_condtn_rep-ddtext = <l_fs_dd07t>-ddtext.
          ENDIF.

          READ TABLE i_makt ASSIGNING <l_fs_makt>
                          WITH KEY matnr = <l_fs_kondn>-knrmat
                          BINARY SEARCH.

          IF sy-subrc IS INITIAL.
*             Free goods: Additional Material Description
            l_wa_condtn_rep-fmaktx = <l_fs_makt>-maktx.
          ENDIF.

        ENDIF.

      ENDIF.

      APPEND l_wa_condtn_rep TO i_condtn_rep.
      CLEAR l_wa_condtn_rep.

    ENDLOOP.

    SORT i_condtn_rep BY kschl.

  ENDMETHOD.            "M_PROCESS_DATA

*&---------------------------------------------------------------------*
*&       METHOD m_main_processing
*&---------------------------------------------------------------------*
*        Main Method which in turn will call the different methods
*        to achieve the functionality of the program.
*----------------------------------------------------------------------*
  METHOD m_main_processing.

*   Retrieve the data from the Condition Tables for the different
*   Condition Types and get the corresponding table names from where
*   the Condition Records to be retrieved.
    CALL METHOD m_retrieve_data
      CHANGING
        ch_i_t682i = i_t682i.

*   Validate whether the tables determined from the previous method
*   actually exists in the SAP database.
    CALL METHOD m_validate_table
      CHANGING
        ch_i_t682i = i_t682i.

*   Populate the internal table with the contents of the selection
*   screen.
    CALL METHOD m_input_field
      CHANGING
        ch_i_input_field = i_input_field.

*   Get the Condition Records for all the condition type and for the
*   set of criteria in the selection screen.
    CALL METHOD m_get_cond_record
      EXPORTING
        im_i_t682i        = i_t682i
      CHANGING
        ch_i_condtab_data = i_condtab_data.

*   Get the detail of the Condition Type from the SAP database tables
*   and then the corresponding scales if they exist.
    CALL METHOD m_get_cond_data
      EXPORTING
        im_i_condtab_data = i_condtab_data
      CHANGING
        ch_i_knumh        = i_knumh
        ch_i_konhdb       = i_konhdb
        ch_i_konpdb       = i_konpdb
        ch_i_konm         = i_konm
        ch_i_konw         = i_konw
        ch_i_kondn        = i_kondn
        ch_i_kondns       = i_kondns.

*   Get the detail of the Rebate Agreement data from the SAP database
*   table KONA.
    CALL METHOD m_get_agreement_data
      EXPORTING
        im_i_konpdb = i_konpdb
      CHANGING
        ch_i_kona   = i_kona.

*   The retrieved data will be processed into the desired internal table
*   which will finally displayed in the report.
    CALL METHOD m_process_data.

* Mod-Begins Sangeetha
    IF sy-batch EQ 'X'.
      PERFORM alv_report_display.
    ELSE.
      TRY.
*   Calling the Screen that has the container.
*   The ALV report will be shown on the container
          CALL SCREEN c_screen.                             "9000
        CATCH cx_sy_program_not_found.
        CATCH cx_root.
      ENDTRY.
*   Work area of the final internal table
    ENDIF.

  ENDMETHOD.            "M_MAIN_PROCESSING
*&---------------------------------------------------------------------*
*&       METHOD m_populate_fldcat
*&---------------------------------------------------------------------*
*        Process to populate the Field Catalogue for ALV Grid Display
*----------------------------------------------------------------------*
  METHOD m_populate_fldcat.

    DATA:l_rec_fldcat TYPE  lvc_s_fcat.
    DATA:  l_fldcat TYPE slis_fieldcat_alv.                 " Mod-002

    l_rec_fldcat-fieldname   = im_fldname.
    l_rec_fldcat-outputlen   = im_outlen.
    l_rec_fldcat-col_pos     = im_clpos.
    l_rec_fldcat-row_pos     = im_rwpos .
    l_rec_fldcat-tabname     = im_tabname.
    l_rec_fldcat-coltext     = im_coltext.
    l_rec_fldcat-no_out      = im_no_out.
    l_rec_fldcat-ref_field   = im_rfield.
    l_rec_fldcat-ref_table   = im_rtable.
    l_rec_fldcat-lowercase = im_lcase.
    APPEND l_rec_fldcat TO i_fldcat.
    CLEAR l_rec_fldcat.

    CLEAR  l_fldcat .
    l_fldcat-tabname = im_tabname.
    l_fldcat-fieldname = im_fldname.
    l_fldcat-key = 'X'.
    l_fldcat-seltext_l = im_coltext.
    l_fldcat-no_out = space.
    APPEND l_fldcat  TO i_fldcat1.

  ENDMETHOD.            "M_POPULATE_FLDCAT
*&---------------------------------------------------------------------*
*&       METHOD m_build_field_catalogue
*&---------------------------------------------------------------------*
*        Populating the ALV Fieldcatalogue with proper attributes
*----------------------------------------------------------------------*

  METHOD m_build_field_catalogue.
* Populate Condition Type
    CALL METHOD m_populate_fldcat(
      im_fldname = c_kschl         "Fieldname
      im_outlen = 14               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-003        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_kschl      "Reference Field
      ).

* Populate Condition Type Description
    CALL METHOD m_populate_fldcat(
      im_fldname = c_cvtext         "Fieldname
      im_outlen = 26               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-004        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_cvtext      "Reference Field
      ).

* Populate Sold To Number
    CALL METHOD m_populate_fldcat(
      im_fldname = c_kunnr         "Fieldname
      im_outlen = 14               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-005        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_kunnr      "Reference Field
      im_rtable = 'KNA1'
      ).

** Populate Sold To Name
    CALL METHOD m_populate_fldcat(
      im_fldname = c_name1         "Fieldname
      im_outlen = 12               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-006        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_name1      "Reference Field
      im_rtable = 'KNA1'
      im_lcase = c_yes
      ).

* Populate Customer Hierarchy Number
    CALL METHOD m_populate_fldcat(
      im_fldname = c_hienr         "Fieldname
      im_outlen = 25               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-007        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_kunnr      "Reference Field
      im_rtable = 'KNA1'
      ).

* Populate Customer Hierarchy Name
    CALL METHOD m_populate_fldcat(
      im_fldname = c_name1_c       "Fieldname
*      im_outlen = 23               "Output Length
      im_outlen = 20               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-008        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_name1      "Reference Field
      im_rtable = 'KNA1'
      im_lcase = c_yes
      ).

* Populate Price Group Name
    CALL METHOD m_populate_fldcat(
      im_fldname = c_konda         "Fieldname
      im_outlen = 16               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-009        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_konda      "Reference Field
      ).

* Populate Price Group Description
    CALL METHOD m_populate_fldcat(
      im_fldname = c_pvtext        "Fieldname
      im_outlen = 23               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-010        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_pvtext      "Reference Field
      ).

* Populate Material Number
    CALL METHOD m_populate_fldcat(
      im_fldname = c_matnr         "Fieldname
      im_outlen = 18               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-011        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_matnr      "Reference Field
      im_rtable = 'MARA'
      im_lcase = c_yes
      ).

* Populate Material Description
    CALL METHOD m_populate_fldcat(
      im_fldname = c_maktx         "Fieldname
      im_outlen = 40               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-012        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_maktx      "Reference Field
      ).

* Populate Material Group 1
    CALL METHOD m_populate_fldcat(
      im_fldname = c_mvgr1         "Fieldname
      im_outlen = 16               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-013        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_mvgr1      "Reference Field
      ).

* Populate Material Group 1 Description
    CALL METHOD m_populate_fldcat(
      im_fldname = c_mbezei         "Fieldname
      im_outlen = 28               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-014        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_mbezei      "Reference Field
      ).

* Populate ProdH 1 - Business
    CALL METHOD m_populate_fldcat(
      im_fldname = c_prodh1         "Fieldname
      im_outlen = 18               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-015        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_prodh1      "Reference Field
      ).

* Populate ProdH 2 â€" Business ID
    CALL METHOD m_populate_fldcat(
      im_fldname = c_prodh2         "Fieldname
      im_outlen = 19               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-016        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_prodh2      "Reference Field
      ).

* Populate ProdH 3 - Category
    CALL METHOD m_populate_fldcat(
      im_fldname = c_prodh3         "Fieldname
      im_outlen = 18               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-017        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_prodh3      "Reference Field
      ).

* Populate ProdH 4 â€" Sub-Categ
    CALL METHOD m_populate_fldcat(
      im_fldname = c_yyprodh4         "Fieldname
      im_outlen = 19               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-018        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_yyprodh4      "Reference Field
      ).

* Populate ProdH 5 â€" Seg/Sub Seg
    CALL METHOD m_populate_fldcat(
      im_fldname = c_yyprodh5         "Fieldname
      im_outlen = 21               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-019        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_yyprodh5      "Reference Field
      ).

* Populate CAMPIGN ID
    CALL METHOD m_populate_fldcat(
      im_fldname = c_cmpgn_id      "Fieldname
      im_outlen = 11               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-020        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_cmpgn_id      "Reference Field
      ).

* Populate Campaign (External ID)
    CALL METHOD m_populate_fldcat(
      im_fldname = c_external_id   "Fieldname
      im_outlen = 22               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-021        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_external_id      "Reference Field
      ).

* Populate Condition Amount
    CALL METHOD m_populate_fldcat(
      im_fldname = c_kbetr         "Fieldname
      im_outlen = 16         "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-022        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_kbetr      "Reference Field
      ).

* Populate Condition Unit
    CALL METHOD m_populate_fldcat(
      im_fldname = c_konwa         "Fieldname
      im_outlen = 14               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-023        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_konwa      "Reference Field
      ).

* Populate Condition Pricing Unit
    CALL METHOD m_populate_fldcat(
      im_fldname = c_kpein         "Fieldname
      im_outlen = 22               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-024        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_kpein      "Reference Field
      ).

* Populate Condition Unit of Measure
    CALL METHOD m_populate_fldcat(
      im_fldname = c_kmein         "Fieldname
      im_outlen = 25               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-025        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_kmein      "Reference Field
      ).

* Populate Condition Valid On
    CALL METHOD m_populate_fldcat(
      im_fldname = c_datab         "Fieldname
      im_outlen = 18               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-026        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_datab      "Reference Field
      ).

* Populate Condition Valid To
    CALL METHOD m_populate_fldcat(
      im_fldname = c_datbi         "Fieldname
      im_outlen = 18               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-027        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_datbi      "Reference Field
      ).

* Populate Condition Accrual Amount - Rebate
    CALL METHOD m_populate_fldcat(
      im_fldname = c_kbrue         "Fieldname
      im_outlen = 33               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-028        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_kbrue      "Reference Field
      ).

* Populate Condition Accrual Unit - Rebate
    CALL METHOD m_populate_fldcat(
      im_fldname = c_kwaeh         "Fieldname
      im_outlen = 31               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-029        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_kwaeh      "Reference Field
      ).

* Populate Condition Deletion Indicator
    CALL METHOD m_populate_fldcat(
      im_fldname = c_loevm_ko         "Fieldname
      im_outlen = 28               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-030        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_loevm_ko      "Reference Field
      ).

* Populate Condition Exclusive Indicator
    CALL METHOD m_populate_fldcat(
      im_fldname = c_kznep         "Fieldname
      im_outlen = 29               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-031        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_kznep      "Reference Field
      ).

* Populate Rebate Agreement Number
    CALL METHOD m_populate_fldcat(
      im_fldname = c_knuma         "Fieldname
      im_outlen = 23               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-032        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_knuma      "Reference Field
      im_rtable = 'KONA'
      ).

* Populate Rebate Agreement Type
    CALL METHOD m_populate_fldcat(
      im_fldname = c_boart         "Fieldname
      im_outlen = 21               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-033        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_boart      "Reference Field
      ).

* Populate Rebate Agreement Type Description
    CALL METHOD m_populate_fldcat(
      im_fldname = c_rvtext         "Fieldname
      im_outlen = 33               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-034        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_rvtext      "Reference Field
      ).

* Populate Enhanced Rebate Indicator
    CALL METHOD m_populate_fldcat(
      im_fldname = c_bon_enh_vakey "Fieldname
      im_outlen = 25               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-035        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_bon_enh_vakey  "Reference Field
      ).

* Populate Indirect Settlement Types Indicator
    CALL METHOD m_populate_fldcat(
      im_fldname = c_bon_enh_indirect  "Fieldname
      im_outlen = 35               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-036        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_bon_enh_indirect  "Reference Field
      ).

* Populate Rebate Retroactive Indicator
    CALL METHOD m_populate_fldcat(
      im_fldname = c_ksape         "Fieldname
      im_outlen = 28               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-037        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_ksape      "Reference Field
      ).

* Populate Rebate Recipient
    CALL METHOD m_populate_fldcat(
      im_fldname = c_bonem         "Fieldname
      im_outlen = 16               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-038        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_bonem      "Reference Field
      ).

* Populate Rebate Currency
    CALL METHOD m_populate_fldcat(
      im_fldname = c_waers         "Fieldname
      im_outlen = 15               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-039        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_waers      "Reference Field
      ).

* Populate Rebate Payment Method
    CALL METHOD m_populate_fldcat(
      im_fldname = c_zlsch         "Fieldname
      im_outlen = 21               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-040        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_zlsch      "Reference Field
      ).

* Populate Rebate External Description
    CALL METHOD m_populate_fldcat(
      im_fldname = c_abrex         "Fieldname
      im_outlen = 27               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-041        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_abrex      "Reference Field
      ).

* Populate Rebate Agreement Valid From
    CALL METHOD m_populate_fldcat(
      im_fldname = c_rdatab         "Fieldname
      im_outlen = 27                "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-042        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_rdatab      "Reference Field
      ).

* Populate Rebate Agreement Valid To
    CALL METHOD m_populate_fldcat(
      im_fldname = c_rdatbi         "Fieldname
      im_outlen = 25               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-043        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_rdatbi      "Reference Field
      ).

* Populate Rebate Agreement Status
    CALL METHOD m_populate_fldcat(
      im_fldname = c_bosta         "Fieldname
      im_outlen = 23               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-044        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_bosta      "Reference Field
      ).

* Populate Rebate Accruals
    CALL METHOD m_populate_fldcat(
      im_fldname = 'RUWRT'         "Fieldname
      im_outlen = 15               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-045        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_bosta      "Reference Field
      ).

* Populate Rebate Accruals Reversed
    CALL METHOD m_populate_fldcat(
      im_fldname = c_rrwrt         "Fieldname
      im_outlen = 24               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-046        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_rrwrt      "Reference Field
      ).

* Populate Rebate Payments
    CALL METHOD m_populate_fldcat(
      im_fldname = c_auwrt         "Fieldname
      im_outlen = 15               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-047        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_auwrt      "Reference Field
      ).

* Populate Rebate: Maximum payable amount
    CALL METHOD m_populate_fldcat(
      im_fldname = c_mpwrt         "Fieldname
      im_outlen = 30               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-048        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_mpwrt      "Reference Field
      ).

* BEGIN OF MOD-004

*   Populate Delta: Payment vs. Settlement of Accruals
    CALL METHOD m_populate_fldcat(
      im_fldname = c_pymt_vs_stmt         "Fieldname
      im_outlen = 26               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-115        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_waers      "Reference Field
      im_rtable = c_kona           "Reference Table
      ).

*   Populate Delta: Accruals vs. Settlement of Accruals
    CALL METHOD m_populate_fldcat(
      im_fldname = c_accrl_vs_stmt_accrl         "Fieldname
      im_outlen = 26               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-116        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_waers      "Reference Field
      im_rtable = c_kona           "Reference Table
      ).

*   Populate Delta: Still Payable
    CALL METHOD m_populate_fldcat(
      im_fldname = c_st_pybl         "Fieldname
      im_outlen = 26               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-117        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_waers      "Reference Field
      im_rtable = c_kona           "Reference Table
      ).

* END OF MOD-004

* Populate Rebate: Amount to be paid
    CALL METHOD m_populate_fldcat(
      im_fldname = c_bzwrt         "Fieldname
      im_outlen = 25               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-049        "Column Text
      im_no_out = space            "Column is not output
      im_rfield = c_bzwrt      "Reference Field
      ).

* Populate Sales Organization
    CALL METHOD m_populate_fldcat(
      im_fldname = c_vkorg         "Fieldname
      im_outlen = 15               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-050        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_vkorg       "Reference Field
      ).

* Populate Distribution Channel
    CALL METHOD m_populate_fldcat(
      im_fldname = c_vtweg         "Fieldname
      im_outlen = 24               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-051        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_vtweg      "Reference Field
      ).

* Populate Sales Office
    CALL METHOD m_populate_fldcat(
      im_fldname = c_vkbur         "Fieldname
      im_outlen = 15               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-052        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_vkbur      "Reference Field
      ).

* Populate Sales Group
    CALL METHOD m_populate_fldcat(
      im_fldname = c_vkgrp         "Fieldname
      im_outlen = 30               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-053        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_vkgrp      "Reference Field
      ).

* Populate Condition Created By
    CALL METHOD m_populate_fldcat(
      im_fldname = c_cernam         "Fieldname
      im_outlen = 25               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-054        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_cernam      "Reference Field
      ).

* Populate Condition Created on Date
    CALL METHOD m_populate_fldcat(
      im_fldname = c_cerdat         "Fieldname
      im_outlen = 18               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-055        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_cerdat      "Reference Field
      ).

* Populate Condition Calculation Type
    CALL METHOD m_populate_fldcat(
      im_fldname = c_krech         "Fieldname
      im_outlen = 26               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-057        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_krech      "Reference Field
      ).

* Populate Condition Scales
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kstbw         "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-058        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kstbw      "Reference Field
          ).

* Populate Condition Scale Basis
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kzbzg         "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-059        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kzbzg      "Reference Field
          ).

* Populate Condition Scale Type
    CALL METHOD m_populate_fldcat(
          im_fldname = c_stfkz         "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-060        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_stfkz      "Reference Field
          ).

* Populate Condition Scale Quantity 1
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kstbm1        "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-061        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kstbm1      "Reference Field
          ).

* Populate Condition Scale Quantity 2
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kstbm2        "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-062        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kstbm2      "Reference Field
          ).

* Populate Condition Scale Quantity 3
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kstbm3        "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-063        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kstbm3      "Reference Field
          ).

* Populate Condition Scale Quantity 4
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kstbm4        "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-064        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kstbm4      "Reference Field
          ).

* Populate Condition Scale Quantity 5
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kstbm5        "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-065        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kstbm5      "Reference Field
          ).

* Populate Condition Scale Quantity 6
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kstbm6        "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-066        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kstbm6      "Reference Field
          ).

* Populate Condition Scale Quantity 7
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kstbm7        "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-067        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kstbm7      "Reference Field
          ).

* Populate Condition Scale Quantity 8
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kstbm8        "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-068        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kstbm8      "Reference Field
          ).

* Populate Condition Scale Quantity 9
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kstbm9        "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-069        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kstbm9      "Reference Field
          ).

* Populate Condition Scale Quantity 10
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kstbm10       "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-070        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kstbm10      "Reference Field
          ).

* Populate Condition Scale Amount 1
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kbetr1        "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-071        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kbetr1      "Reference Field
          ).

* Populate Condition Scale Amount 2
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kbetr2        "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-072        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kbetr2      "Reference Field
          ).

* Populate Condition Scale Amount 3
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kbetr3        "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-073        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kbetr3      "Reference Field
          ).

* Populate Condition Scale Amount 4
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kbetr4        "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-074        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kbetr4      "Reference Field
          ).

* Populate Condition Scale Amount 5
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kbetr5        "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-075        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kbetr5      "Reference Field
          ).

* Populate Condition Scale Amount 6
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kbetr6        "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-076        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kbetr6      "Reference Field
          ).

* Populate Condition Scale Amount 7
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kbetr7        "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-077        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kbetr7      "Reference Field
          ).

* Populate Condition Scale Amount 8
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kbetr8        "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-078        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kbetr8      "Reference Field
          ).

* Populate Condition Scale Amount 9
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kbetr9        "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-079        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kbetr9      "Reference Field
          ).

* Populate Condition Scale Amount 10
    CALL METHOD m_populate_fldcat(
          im_fldname = c_kbetr10       "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-080        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_kbetr10      "Reference Field
          ).

* Populate Condition Lower Limit
    CALL METHOD m_populate_fldcat(
          im_fldname = c_mxwrt         "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-081        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_mxwrt      "Reference Field
          ).

* Populate Condition Upper Limit
    CALL METHOD m_populate_fldcat(
          im_fldname = c_gkwrt         "Fieldname
          im_outlen = 26               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-082        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_gkwrt      "Reference Field
          ).

* Populate Condition Table Usage
    CALL METHOD m_populate_fldcat(
      im_fldname = c_kvewe         "Fieldname
      im_outlen = 21               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-086        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_kvewe      "Reference Field
      ).

* Populate Condition Application
    CALL METHOD m_populate_fldcat(
      im_fldname = c_kappl         "Fieldname
      im_outlen = 21               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-087        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_kappl      "Reference Field
      ).

* Populate Rebate Agreement Created By
    CALL METHOD m_populate_fldcat(
      im_fldname = c_ernam         "Fieldname
      im_outlen = 27               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-088        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_ernam       "Reference Field
      ).

* Populate Rebate Agreement Created on Date
    CALL METHOD m_populate_fldcat(
      im_fldname = c_erdat         "Fieldname
      im_outlen = 32               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-089        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_erdat      "Reference Field
      ).

* Populate Rebate Agreement Created on Time
    CALL METHOD m_populate_fldcat(
      im_fldname = c_erzet         "Fieldname
      im_outlen = 32               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-090        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_erzet      "Reference Field
      ).

* Populate Rebate Agreement Changed By
    CALL METHOD m_populate_fldcat(
      im_fldname = c_aenam         "Fieldname
      im_outlen = 27               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-091        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_aenam      "Reference Field
      ).

* Populate Rebate Agreement Changed on Date
    CALL METHOD m_populate_fldcat(
      im_fldname = c_aedat         "Fieldname
      im_outlen = 32               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-092        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_aedat      "Reference Field
      ).

* Populate Rebate Agreement Changed on Time
    CALL METHOD m_populate_fldcat(
      im_fldname = c_aezet         "Fieldname
      im_outlen = 32               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-093        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_aezet      "Reference Field
      ).

* Populate Material for Rebate Settlement
    CALL METHOD m_populate_fldcat(
          im_fldname = c_bomat         "Fieldname
          im_outlen = 32               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-094        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_bomat      "Reference Field
          ).

* Populate Rebate Agreement Description
    CALL METHOD m_populate_fldcat(
      im_fldname = c_botext         "Fieldname
      im_outlen = 28               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-095        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_botext      "Reference Field
      ).

* Populate Rebate Verification Level
    CALL METHOD m_populate_fldcat(
      im_fldname = c_abspz         "Fieldname
      im_outlen = 25               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-096        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_abspz      "Reference Field
      ).

* Populate Rebate Condition Type Group
    CALL METHOD m_populate_fldcat(
      im_fldname = c_kobog         "Fieldname
      im_outlen = 27               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-097        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_kobog      "Reference Field
      ).

* Populate Free goods: Minimum quantity
    CALL METHOD m_populate_fldcat(
      im_fldname = c_knrmm         "Fieldname
      im_outlen = 28               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-098        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_knrmm      "Reference Field
      ).

* Populate Free goods: Free goods quantity
    CALL METHOD m_populate_fldcat(
      im_fldname = c_knrnm         "Fieldname
      im_outlen = 31               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-099        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_knrnm      "Reference Field
      ).

* Populate Free goods: Quantity unit for minimum quantity
* and free goods quantity
    CALL METHOD m_populate_fldcat(
      im_fldname = c_knrme         "Fieldname
      im_outlen = 35               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-100        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_knrme      "Reference Field
      ).

* Populate Free goods: Additional quantity
    CALL METHOD m_populate_fldcat(
      im_fldname = c_knrzm         "Fieldname
      im_outlen = 31               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-101        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_knrzm      "Reference Field
      ).

* Populate Free goods: Quantity unit for free goods additional quantity
    CALL METHOD m_populate_fldcat(
      im_fldname = c_knrez         "Fieldname
      im_outlen = 36               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-102        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_knrez      "Reference Field
      ).

* Populate Free Goods: Percentage Rate
    CALL METHOD m_populate_fldcat(
          im_fldname = c_fgpcr         "Fieldname
          im_outlen = 36               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep       "Table name
          im_coltext = text-103        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_fgpcr      "Reference Field
          ).

* Populate Free goods: Calculation type for determining
* free goods quantity
    CALL METHOD m_populate_fldcat(
      im_fldname = c_knrrr         "Fieldname
      im_outlen = 33               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-104        "Column Text
      im_no_out = c_yes           "Column is not output
      im_rfield = c_knrrr      "Reference Field
      ).

* Populate Free goods category
    CALL METHOD m_populate_fldcat(
      im_fldname = c_knrdd         "Fieldname
      im_outlen = 19               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-105        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_knrdd      "Reference Field
      ).

* Populate Free goods delivery control
    CALL METHOD m_populate_fldcat(
      im_fldname = c_lstanr         "Fieldname
      im_outlen = 27               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-106        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_lstanr      "Reference Field
      ).

* Populate Free goods: Text output for exclusive or inclusive
    CALL METHOD m_populate_fldcat(
      im_fldname = c_ddtext         "Fieldname
      im_outlen = 27               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep       "Table name
      im_coltext = text-107        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_ddtext      "Reference Field
      ).

* Populate Free Goods: Additional Material
    CALL METHOD m_populate_fldcat(
      im_fldname = c_knrmat         "Fieldname
      im_outlen = 26               "Output Length
      im_clpos = 1                 "Column Position
      im_rwpos = 1                 "Row Position
      im_tabname = c_i_condtn_rep  "Table name
      im_coltext = text-108        "Column Text
      im_no_out = c_yes            "Column is not output
      im_rfield = c_knrmat      "Reference Field
      ).

* Populate Free goods: Additional Material Description
    CALL METHOD m_populate_fldcat(
          im_fldname = c_fmaktx         "Fieldname
          im_outlen = 25               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep  "Table name
          im_coltext = text-109        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = c_fmaktx      "Reference Field
          ).

* Begin of MOD-001

* Populate the Departure Country
    CALL METHOD m_populate_fldcat(
          im_fldname = 'ALAND'         "Fieldname
          im_outlen = 25               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep  "Table name
          im_coltext = text-110        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = 'LAND1'      "Reference Field
          ).

* Populate the Destination Country
    CALL METHOD m_populate_fldcat(
          im_fldname = 'LLAND'         "Fieldname
          im_outlen = 25               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep  "Table name
          im_coltext = text-111        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = 'LAND1'      "Reference Field
          ).

* Populate the Tax classification 1 for Customer
    CALL METHOD m_populate_fldcat(
          im_fldname = 'TAXK1'         "Fieldname
          im_outlen = 25               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep  "Table name
          im_coltext = text-112        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = 'TAXK1'      "Reference Field
          ).

* Populate the Tax classification Material
    CALL METHOD m_populate_fldcat(
          im_fldname = 'TAXM1'         "Fieldname
          im_outlen = 25               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep  "Table name
          im_coltext = text-113        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = 'TAXM1'      "Reference Field
          ).

* Populate the Tax on sales/purchase code
    CALL METHOD m_populate_fldcat(
          im_fldname = 'MWSKZ'         "Fieldname
          im_outlen = 25               "Output Length
          im_clpos = 1                 "Column Position
          im_rwpos = 1                 "Row Position
          im_tabname = c_i_condtn_rep  "Table name
          im_coltext = text-114        "Column Text
          im_no_out = c_yes            "Column is not output
          im_rfield = 'MWSKZ'      "Reference Field
          ).

* End of MOD-001

  ENDMETHOD.            "M_BUILD_FIELD_CATALOGUE

ENDCLASS.               "lcl_data_selection

*---------------------------------------------------------------------*
*       CLASS lcl_input_validation DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_input_validation DEFINITION.

  PUBLIC SECTION.
    CLASS-METHODS: m_validate_sales_org,  "Validate the Sales Org
                   m_validate_distr_chl,  "Validate the Distr Channel
                   m_validate_sales_area, "Validate Sales Area
                   m_validate_cond_type,  "Validate the Condition Type
                   m_validate_customer,   "Validate the Sold to Party
                   m_validate_cus_hier,   "Validate Customer Hierarchy
                   m_validate_price_grp,  "validate the Price Group
                   m_validate_material,   "Validate the Material
                   m_validate_mat_grp1,   "Validate the material Group 1
                   m_validate_reb_recp,   "Validate Rebate recipient
                   m_validate_variant,    "Validate Variant Name
                   m_validate_condel_ind, "Validate Cond Del Indicator
                   m_validate_reb_agg_stat, "Validate Rebate Agg Status
                   m_validate_prodh1,     "Validate ProdH1
                   m_validate_prodh2,     "Validate ProdH2
                   m_validate_prodh3,     "Validate ProdH3
                   m_validate_prodh4,     "Validate ProdH4
                   m_validate_prodh5,     "Validate ProdH5
*                  Begin of MOD-001
                   m_validate_aland,      "Validate Departure Country
                   m_validate_boart,      "Validate Agreement Type
*                  Begin of MOD-001
*                  BEGIN OF MOD-004
                   m_validate_knuma.      "Validate Rebate Agreement
    "Number
*                  END OF MOD-004

ENDCLASS.                    "lcl_input_validation DEFINITION
*&---------------------------------------------------------------------*
*&       Class (Implementation)  lcl_input_validation
*&---------------------------------------------------------------------*
*        Class for Selection Screen Validation
*----------------------------------------------------------------------*
CLASS lcl_input_validation IMPLEMENTATION.

*&---------------------------------------------------------------------*
*&       METHOD m_validate_sales_org
*&---------------------------------------------------------------------*
*        Validation of Sales Organization
*----------------------------------------------------------------------*
  METHOD m_validate_sales_org.

    DATA : l_vkorg TYPE vkorg.

    SELECT  vkorg
            FROM tvko
            INTO (l_vkorg)
            UP TO 1 ROWS
            WHERE vkorg IN s_vkorg.
    ENDSELECT.

    IF NOT sy-subrc IS INITIAL.
*     Message: Please choose valid Sales Organization
      MESSAGE e402.
    ENDIF.

  ENDMETHOD.                    "m_validate_sales_org

*&---------------------------------------------------------------------*
*&       METHOD m_validate_distr_chl
*&---------------------------------------------------------------------*
*        Validation of Distribution Channel
*----------------------------------------------------------------------*
  METHOD m_validate_distr_chl.

    DATA : l_vtweg TYPE vtweg.

    SELECT  vtweg
            FROM tvtw
            INTO (l_vtweg)
            UP TO 1 ROWS
            WHERE vtweg IN s_vtweg.
    ENDSELECT.

    IF NOT sy-subrc IS INITIAL.
*     Message: Please choose valid Distribution Channel
      MESSAGE e403.
    ENDIF.

  ENDMETHOD.                    "m_validate_distr_chl

*&---------------------------------------------------------------------*
*&       METHOD m_validate_distr_chl
*&---------------------------------------------------------------------*
*        Validation of Sales Area
*----------------------------------------------------------------------*
  METHOD m_validate_sales_area.

    DATA: l_vkorg TYPE vkorg,
          l_vtweg TYPE vtweg.

    SELECT vkorg
           vtweg
    FROM tvkov
    INTO (l_vkorg, l_vtweg)
    UP TO 1 ROWS
    WHERE vkorg IN s_vkorg
    AND vtweg IN s_vtweg.
    ENDSELECT.

    IF NOT sy-subrc IS INITIAL.
      MESSAGE e073.
    ENDIF.
  ENDMETHOD.                    "m_validate_sales_area

*&---------------------------------------------------------------------*
*&       METHOD m_validate_cond_type
*&---------------------------------------------------------------------*
*        Validation of Condition Type
*----------------------------------------------------------------------*
  METHOD m_validate_cond_type.

    DATA : l_kschl TYPE kscha.

    SELECT  kschl
            FROM t685
            INTO (l_kschl)
            UP TO 1 ROWS
            WHERE kschl IN s_kschl.
    ENDSELECT.

    IF NOT sy-subrc IS INITIAL.
*     Message: Please enter the valid condition type
      MESSAGE e527.
    ENDIF.

  ENDMETHOD.                    "m_validate_cond_type

*&---------------------------------------------------------------------*
*&       METHOD m_validate_customer
*&---------------------------------------------------------------------*
*        Validation of Customer
*----------------------------------------------------------------------*
  METHOD m_validate_customer.

    DATA : l_kunnr TYPE kunnr.

    SELECT kunnr
           FROM  kna1
           INTO (l_kunnr)
           UP TO 1 ROWS
           WHERE kunnr IN s_kunnr.
    ENDSELECT.

    IF NOT sy-subrc IS INITIAL.
*     Message: Choose valid customer (Sold to Party)
      MESSAGE e517.
    ENDIF.

  ENDMETHOD.                    "m_validate_customer

*&---------------------------------------------------------------------*
*&       METHOD m_validate_cus_hier
*&---------------------------------------------------------------------*
*        Validation of Customer Hierarchy
*----------------------------------------------------------------------*
  METHOD m_validate_cus_hier.

    DATA : l_kunnr TYPE kunnr.

    SELECT kunnr
           FROM  kna1
           INTO (l_kunnr)
           UP TO 1 ROWS
           WHERE kunnr IN s_hienr.
    ENDSELECT.

    IF NOT sy-subrc IS INITIAL.
*     Message: Choose valid customer hierarchy (Node)
      MESSAGE e513.
    ENDIF.

  ENDMETHOD.                    "m_validate_cus_hier

*&---------------------------------------------------------------------*
*&       METHOD m_validate_price_grp
*&---------------------------------------------------------------------*
*        Validation of Price Group
*----------------------------------------------------------------------*
  METHOD m_validate_price_grp.

    DATA: l_konda TYPE konda.

    SELECT konda
           FROM t188
           INTO (l_konda)
           UP TO 1 ROWS
           WHERE konda IN s_konda.
    ENDSELECT.

    IF NOT sy-subrc IS INITIAL.
*   Message:Price group is invalid. Please enter a valid price group.
      MESSAGE e067.
    ENDIF.

  ENDMETHOD.                    "m_validate_price_grp

*&---------------------------------------------------------------------*
*&       METHOD m_validate_material
*&---------------------------------------------------------------------*
*        Validation of Material
*----------------------------------------------------------------------*
  METHOD m_validate_material.

    DATA : l_matnr TYPE matnr.

    SELECT matnr
           FROM  mara
           INTO (l_matnr)
           UP TO 1 ROWS
           WHERE  matnr IN s_matnr.
    ENDSELECT.

    IF NOT sy-subrc IS INITIAL.
*     Message: Invalid material
      MESSAGE e409.
    ENDIF.

  ENDMETHOD.                    "m_validate_material

*&---------------------------------------------------------------------*
*&       METHOD m_validate_mat_grp1
*&---------------------------------------------------------------------*
*        Validation of Material Group 1
*----------------------------------------------------------------------*
  METHOD m_validate_mat_grp1.

    DATA: l_mvgr1 TYPE mvgr1.

    SELECT mvgr1
           FROM tvm1
           INTO (l_mvgr1)
           UP TO 1 ROWS
           WHERE mvgr1 IN s_mvgr1.
    ENDSELECT.

    IF NOT sy-subrc IS INITIAL.
*     Message: Material Group 1 is invalid
      MESSAGE e069.
    ENDIF.

  ENDMETHOD.                    "m_validate_mat_grp1

*&---------------------------------------------------------------------*
*&       METHOD m_validate_reb_recp
*&---------------------------------------------------------------------*
*        Validation of Rebate Recipient
*----------------------------------------------------------------------*
  METHOD m_validate_reb_recp.

    DATA : l_kunnr TYPE kunnr.

    SELECT kunnr
           FROM  kna1
           INTO (l_kunnr)
           UP TO 1 ROWS
           WHERE kunnr IN s_bonem.
    ENDSELECT.

    IF sy-subrc <> 0.
*    Rebate recipient is invalid.Please enter valid rebate recipient
*    (Customer)
      MESSAGE e070.
    ENDIF.

  ENDMETHOD.                    "m_validate_reb_recp

*&---------------------------------------------------------------------*
*&       METHOD m_validate_variant
*&---------------------------------------------------------------------*
*        Validate Variant Name
*----------------------------------------------------------------------*
  METHOD m_validate_variant.

    DATA: l_variant TYPE slis_vari.

    SELECT variant    "Layout
    UP TO 1 ROWS
    FROM ltdx    "Generic storage of layouts
    INTO (l_variant)
    WHERE relid  = c_relid
    AND   report = sy-repid
    AND variant = p_vari.
    ENDSELECT.

    IF sy-subrc <> 0.
*     Error message that Invalid Layout Variant Name
      MESSAGE e068.
    ENDIF.

  ENDMETHOD.               "M_VALIDATE_VARIANT

*&---------------------------------------------------------------------*
*&       METHOD m_validate_condel_ind
*&---------------------------------------------------------------------*
*        Validate Condition Deletion Indicator
*----------------------------------------------------------------------*
  METHOD m_validate_condel_ind.

*    DATA: r_loevm TYPE RANGE OF loevm_ko.
*
*    DATA: BEGIN OF rec_loevm,
*               sign TYPE tvarv_sign,
*               option TYPE tvarv_opti,
*               low TYPE loevm_ko,
*               high TYPE loevm_ko,
*              END OF rec_loevm.
*
*    rec_loevm-sign = c_sign_i.           "I
*    rec_loevm-option = c_option_eq.      "EQ
*
*    rec_loevm-low = space.
*    APPEND rec_loevm TO r_loevm.
*
*    rec_loevm-low = c_yes.
*    APPEND rec_loevm TO r_loevm.
*
*clear rec_loevm.

*read table r_loevm into rec_loevm
*             with key
    IF NOT c_yes IN s_loevm.
*     Error message: Invalid condition deletion indicator.
      MESSAGE e078.
    ENDIF.

  ENDMETHOD.                    "m_validate_condel_ind

*&---------------------------------------------------------------------*
*&       METHOD m_validate_reb_agg_stat
*&---------------------------------------------------------------------*
*        Validate Rebate Agreement Status
*----------------------------------------------------------------------*
  METHOD m_validate_reb_agg_stat.

    DATA: r_bosta TYPE RANGE OF bosta,
          r_bosta_temp TYPE RANGE OF bosta.

    DATA: BEGIN OF rec_bosta,
               sign TYPE tvarv_sign,
               option TYPE tvarv_opti,
               low TYPE bosta,
               high TYPE bosta,
              END OF rec_bosta.

    rec_bosta-sign = c_sign_i.           "I
    rec_bosta-option = c_option_eq.      "EQ

    rec_bosta-low = 'A'.
    APPEND rec_bosta TO r_bosta.

    rec_bosta-low = 'B'.
    APPEND rec_bosta TO r_bosta.

    rec_bosta-low = 'C'.
    APPEND rec_bosta TO r_bosta.

    rec_bosta-low = 'D'.
    APPEND rec_bosta TO r_bosta.

* Mod-002 Begins
    rec_bosta-low = space.
    APPEND rec_bosta TO r_bosta.
* Mod-002 End
    CLEAR rec_bosta.

    r_bosta_temp[] = s_bosta[].

    DELETE r_bosta_temp WHERE NOT low IN r_bosta.

    IF r_bosta_temp IS INITIAL.
      MESSAGE e079.
    ENDIF.

  ENDMETHOD.                    "m_validate_reb_agg_stat

*&---------------------------------------------------------------------*
*&       METHOD m_validate_prodh1
*&---------------------------------------------------------------------*
*        Validate ProdH1
*----------------------------------------------------------------------*
  METHOD m_validate_prodh1.

    DATA: l_prodh TYPE prodh_d.

    SELECT prodh
    UP TO 1 ROWS
    FROM t179
    INTO l_prodh
    WHERE prodh IN s_prodh1.
    ENDSELECT.

    IF NOT sy-subrc IS INITIAL.
      MESSAGE e080.
    ENDIF.

  ENDMETHOD.                    "m_validate_prodh1

*&---------------------------------------------------------------------*
*&       METHOD m_validate_prodh2
*&---------------------------------------------------------------------*
*        Validate ProdH2
*----------------------------------------------------------------------*
  METHOD m_validate_prodh2.

    DATA: l_prodh TYPE prodh_d.

    SELECT prodh
    UP TO 1 ROWS
    FROM t179
    INTO l_prodh
    WHERE prodh IN s_prodh2.
    ENDSELECT.

    IF NOT sy-subrc IS INITIAL.
      MESSAGE e080.
    ENDIF.

  ENDMETHOD.                    "m_validate_prodh2

*&---------------------------------------------------------------------*
*&       METHOD m_validate_prodh3
*&---------------------------------------------------------------------*
*        Validate ProdH3
*----------------------------------------------------------------------*
  METHOD m_validate_prodh3.

    DATA: l_prodh TYPE prodh_d.

    SELECT prodh
    UP TO 1 ROWS
    FROM t179
    INTO l_prodh
    WHERE prodh IN s_prodh3.
    ENDSELECT.

    IF NOT sy-subrc IS INITIAL.
      MESSAGE e080.
    ENDIF.

  ENDMETHOD.                    "m_validate_prodh3

*&---------------------------------------------------------------------*
*&       METHOD m_validate_prodh4
*&---------------------------------------------------------------------*
*        Validate ProdH4
*----------------------------------------------------------------------*
  METHOD m_validate_prodh4.

    DATA: l_prodh TYPE prodh_d.

    SELECT prodh
    UP TO 1 ROWS
    FROM t179
    INTO l_prodh
    WHERE prodh IN s_prodh4.
    ENDSELECT.

    IF NOT sy-subrc IS INITIAL.
      MESSAGE e080.
    ENDIF.

  ENDMETHOD.                    "m_validate_prodh4

*&---------------------------------------------------------------------*
*&       METHOD m_validate_prodh5
*&---------------------------------------------------------------------*
*        Validate ProdH5
*----------------------------------------------------------------------*
  METHOD m_validate_prodh5.

    DATA: l_prodh TYPE prodh_d.

    SELECT prodh
    UP TO 1 ROWS
    FROM t179
    INTO l_prodh
    WHERE prodh IN s_prodh5.
    ENDSELECT.

    IF NOT sy-subrc IS INITIAL.
      MESSAGE e080.
    ENDIF.

  ENDMETHOD.                    "m_validate_prodh5

* Begin of MOD-001
*&---------------------------------------------------------------------*
*&       METHOD m_validate_aland
*&---------------------------------------------------------------------*
*        Validate Country of Departure
*----------------------------------------------------------------------*
  METHOD m_validate_aland.

    DATA: l_land1 TYPE land1.

    SELECT land1
    UP TO 1 ROWS
    FROM t005
    INTO l_land1
    WHERE land1 IN s_aland.
    ENDSELECT.

    IF NOT sy-subrc IS INITIAL.
*     Error Message that the Departure Country is invalid
      MESSAGE e089.
    ENDIF.

  ENDMETHOD.                    "m_validate_aland

*&---------------------------------------------------------------------*
*&       METHOD m_validate_boart
*&---------------------------------------------------------------------*
*        Validate Rebate Agreement Type
*----------------------------------------------------------------------*
  METHOD m_validate_boart.

    DATA: l_boart TYPE boart.

    SELECT boart
    UP TO 1 ROWS
    FROM t6b1
    INTO l_boart
    WHERE boart IN s_boart.
    ENDSELECT.

    IF NOT sy-subrc IS INITIAL.
*     Error Message that the Rebate Agreement Type is invalid
      MESSAGE e090.
    ENDIF.

  ENDMETHOD.                    "m_validate_boart

* End of MOD-001

* BEGIN OF MOD-004
*&---------------------------------------------------------------------*
*&       METHOD m_validate_boart
*&---------------------------------------------------------------------*
*        Validate Rebate Agreement Number
*----------------------------------------------------------------------*
  METHOD m_validate_knuma.

    DATA: l_v_knuma TYPE knuma.    ""#EC NEEDED

    SELECT knuma
      UP TO 1 ROWS
      FROM kona
      INTO l_v_knuma
      WHERE knuma IN s_knuma.
    ENDSELECT.

    IF sy-subrc <> 0.
*     Please enter valid rebate agreement number(s)
      MESSAGE e141.
    ENDIF.

  ENDMETHOD.                    "m_validate_knuma

* END OF MOD-004

ENDCLASS.               "lcl_input_validation

  • No labels

2 Comments

  1. Guest

    Hello Aveek,

    Can this report show values of freight conditons in ALV format?

    I'll test this ... 

    Thanks 

  2. Hi

    I try to run this report , But this report has syntax error  So unable to execute as well as understand it .

    Thanks