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

*======================================================================
*DESCRIPTION          : THE PURPOSE OF THIS PROGRAM IS TO PROVIDE
*                       USERS WITH INFORMATION ABOUT THE PRICING
*                       SYSTEM.THIS ALLOWS USER TO CHECK UP IF PRICING
*                       CONDITIONS HAVE BEEN SET UP, AND TO CHECK
*                       THE DETAIL OF THOSE CONDITIONS.
*======================================================================
*COPIED FROM         : (CLONED PROGRAM)
*TITLE               : (PROGRAM TITLE)
*OTHER RELATED OBJ   : (OBJECT NAMES)
*======================================================================
*CHANGE HISTORY LOG
*----------------------------------------------------------------------
*MOD. NO.|  DATE    | NAME    | CORRECTION NUMBER | CHANGE REFERENCE #
*----------------------------------------------------------------------
*MOD-001 |DD/MM/YYYY| XXXXXXX | XXXXXXXXXX        | XXXXXXXXXX
*DESCRIPTION:
*
***********************************************************************


 REPORT  zpricingrept                      MESSAGE-ID zdev
                                          LINE-SIZE 80
                                          LINE-COUNT 62
                                          NO STANDARD PAGE HEADING    .

*----------------------------------------------------------------------
*                 Include for Global Data Declaration
*----------------------------------------------------------------------
* This Include contains all Global Data and Type declaration

* INCLUDE zpricing_top.

*&---------------------------------------------------------------------
*&  Include           ZPRICING_TOP
*&---------------------------------------------------------------------

**=====================================================================
*CHANGE REQUEST (CTS) : RD2K923937
*DESCRIPTION          : THE PURPOSE OF THIS INCLUDE IS TO PROVIDE
*                       WITH INFORMATION ABOUT  DECLARATIONS
*                       USED IN THE ENTIRE REPORT
*======================================================================
*COPIED FROM         : (CLONED PROGRAM)
*TITLE               : (PROGRAM TITLE)
*OTHER RELATED OBJ   : (OBJECT NAMES)
*======================================================================
*CHANGE HISTORY LOG
*---------------------------------------------------------------------
*MOD. NO.|  DATE    | NAME           | CORRECTION NUMBER  | CHANGE
*REFERENCE #    *
*---------------------------------------------------------------------
*MOD-001 |DD/MM/YYYY| XXXXXXXXXXXXXX | XXXXXXXXXX         | XXXXXXXXXX
*DESCRIPTION:
*----------------------------------------------------------------------
*MOD-002 |DD/MM/YYYY| XXXXXXXXXXXXXX | XXXXXXXXXX         | XXXXXXXXXX
*DESCRIPTION:
***********************************************************************

TYPE-POOLS : slis.

***********************************************************************
*                       CONSTANT DECLARATION
***********************************************************************
CONSTANTS:
c_scrgr_sc1 TYPE char3  VALUE 'SC1',  "Screen Group SC1
c_scrgr_sc2 TYPE char3  VALUE 'SC2',  "Screen Group SC2
c_yes       TYPE flag   VALUE 'X',   "Check Character for Mark
c_formname_at_user_command TYPE slis_formname VALUE
                                          'USER_COMMAND',
c_ic1       TYPE char4  VALUE '&IC1',  " functon code for hotspot
c_order     TYPE char14 VALUE 'I_FINAL-VBELNO', " sales doc
c_bill      TYPE char14 VALUE 'I_FINAL-VBELNB',  " billing doc
c_aun       TYPE char3  VALUE  'AUN', " parameter id sales doc
c_vf        TYPE char2  VALUE 'VF',   " parameter id billing doc
c_va03      TYPE char4  VALUE 'VA03', " sales order display
c_vf03      TYPE char4  VALUE 'VF03',  " biling order display
c_finaltable TYPE sval-tabname VALUE 'I_FINAL',  " internal table
c_space      TYPE char1 VALUE '',     " constant O,
c_3          TYPE char1 VALUE '3',    " Constant value for 3
c_a         TYPE char1  VALUE  'A',   " constant A
c_vbelno    TYPE char6  VALUE 'VBELNO',   " sales doc num
c_auarto    TYPE char6  VALUE 'AUARTO',   " sales doc type
c_bezei     TYPE char5  VALUE 'BEZEI',    " sales doc tpe desc
c_audato    TYPE char6  VALUE 'AUDATO',   " sales doc date
c_kunnro    TYPE char6  VALUE 'KUNNRO',   " sld-to-party
c_name1o    TYPE char6  VALUE 'NAME1O',   " name of customer
c_bstkd_v   TYPE char7  VALUE 'BSTKD_V',  " Customer purchase
c_augruo    TYPE char6  VALUE 'AUGRUO',   " Order reason
c_prsdt_v   TYPE char7  VALUE 'PRSDT_V',  " Date for pricing
c_netwro    TYPE char6  VALUE 'NETWRO',    " net value
c_waerko    TYPE char6  VALUE  'WAERKO',   " currency
c_valdt_v   TYPE char7  VALUE  'VALDT_V',  " fixed value
c_valtg_v   TYPE char7  VALUE  'VALTG_V',  " addl. days
c_zterm_v   TYPE char7  VALUE  'ZTERM_V',  " condition counter
c_vbelnb    TYPE char6  VALUE  'VBELNB',   " billing doc number
c_fkartb    TYPE char6  VALUE  'FKARTB',   " billing doc type
c_vtext     TYPE char5  VALUE  'VTEXT',    " billing doc desc
c_fkdatb    TYPE char6  VALUE  'FKDATB',    " billing doc date
c_fkstk     TYPE char5  VALUE 'FKSTK',      " billing doc status
c_fkstob    TYPE char6  VALUE  'FKSTOB',    " billing  cancelled
c_kunrg     TYPE char5  VALUE  'KUNRG',     " payer
c_name1b    TYPE  char6  VALUE  'NAME1B',   " name of the payer
c_netwrb    TYPE  char6  VALUE  'NETWRB',   " net value
c_waerkb    TYPE  char6  VALUE  'WAERKB',   " currency
c_rfbskb    TYPE  char6  VALUE  'RFBSKB',   " status to the transfer
c_xblnrb    TYPE  char6  VALUE  'XBLNRB',   " reference document
c_ztermb    TYPE  char6  VALUE  'ZTERMB',   " terms of document key
c_gbsta    TYPE    char5  VALUE  'GBSTA',    " sales overall status
c_ernamo    TYPE  char6  VALUE  'ERNAMO',    " sales order person
c_erdato    TYPE  char6  VALUE  'ERDATO',    " sales doc created on
c_vkorgo    TYPE  char6  VALUE  'VKORGO',    " sales org
c_sparto    TYPE  char6  VALUE  'SPARTO',    " division
c_mwsbpo    TYPE  char6  VALUE  'MWSBPO',    " Tax document currency
c_vbtypo    TYPE  char6  VALUE  'VBTYPO',    " sales doc category
c_faksko    TYPE  char6  VALUE  'FAKSKO',    " billing block in sd
c_lifsko    TYPE  char6  VALUE  'LIFSKO',    " delivery block
c_fkdat_v   TYPE  char7  VALUE  'FKDAT_V',   " billing date for index
c_vkburo    TYPE  char6  VALUE 'VKBURO',     " sales office
c_vkgrpo    TYPE  char6  VALUE 'VKGRPO',     " sales group
c_konda_v   TYPE  char7   VALUE 'KONDA_V',     " PRICE GROUP
c_inco1_v   TYPE  char7  VALUE  'INCO1_V',   " inco terms
c_bsark_v   TYPE  char7  VALUE  'BSARK_V',   " cust pur order type
c_taxk1o    TYPE  char6  VALUE  'TAXK1O',    " tax classification
c_kalsmo    TYPE  char6  VALUE  'KALSMO',    " pricing procedure
c_posnro    TYPE  char6  VALUE  'POSNRO',    " item
c_matnro    TYPE  char6  VALUE  'MATNRO',    " material number
c_kwmengo   TYPE  char7  VALUE  'KWMENGO',   " order quantity
c_vrkmeo    TYPE  char6  VALUE  'VRKMEO',    " sales unit
c_werkso    TYPE  char6  VALUE  'WERKSO',    " plant
c_prodho    TYPE  char6  VALUE  'PRODHO',    " product hirearchy
c_mvgr1o    TYPE  char6  VALUE  'MVGR1O',    " material group1
c_vkauso    TYPE  char6  VALUE  'VKAUSO',    " Usage indicator
c_mvgr4o    TYPE  char6  VALUE  'MVGR4O',    " material group 4
c_mwsbpb    TYPE  char6  VALUE  'MWSBPB',    " Tax document currency
c_kschl     TYPE  char5  VALUE  'KSCHL',     " conditon type
c_kdatu     TYPE  char5  VALUE  'KDATU',     " condition date
c_kbetr     TYPE  char5  VALUE  'KBETR',     " rate
c_waers     TYPE  char5  VALUE  'WAERS',     " currency
c_kpein     TYPE  char5  VALUE  'KPEIN',     " condition unit
c_kmein     TYPE  char5  VALUE  'KMEIN',     " cond. doc . unit
c_kwert_k   TYPE  char7  VALUE  'KWERT_K',   " condition value
c_kolnr     TYPE  char5  VALUE  'KOLNR',     " accesssequence number
c_kposn     TYPE  char5  VALUE  'KPOSN',     " condition item
c_stunr     TYPE  char5  VALUE  'STUNR',     " step number
c_zaehk     TYPE  char5  VALUE  'ZAEHK',     " condition counter
c_krech     TYPE  char5  VALUE  'KRECH',     " calculation type
c_kawrt     TYPE  char5  VALUE  'KAWRT',     " condition base value
c_kkurs     TYPE  char5  VALUE  'KKURS',     " condition exchange rate
c_kntyp     TYPE  char5  VALUE  'KNTYP',     " condition category
c_knprs     TYPE  char5  VALUE  'KNPRS',     " scale type
c_kstat     TYPE  char5  VALUE  'KSTAT',     " condition statistics
c_kruek     TYPE  char5  VALUE  'KRUEK',     " condition accuals
c_kherk     TYPE  char5  VALUE  'KHERK',     " origin of condition
c_kgrpe     TYPE  char5  VALUE  'KGRPE',     " condition group
c_kvsl1     TYPE  char5  VALUE  'KVSL1',     " account key
c_sakn1     TYPE  char5  VALUE  'SAKN1',     " G/L account number
c_mwsk1     TYPE  char5  VALUE  'MWSK1',     " tax on sales/purchase
c_kvsl2     TYPE  char5  VALUE  'KVSL2',     " account key accurals
c_kwert     TYPE  char5  VALUE  'KWERT',     " condition value
c_kinak     TYPE  char5  VALUE  'KINAK',     " condition is inactive
c_ksteu     TYPE  char5  VALUE  'KSTEU',     " Condition control
c_koaid     TYPE  char5  VALUE  'KOAID',     " Condition class
c_ernamb    TYPE  char6  VALUE  'ERNAMB',    " billing created by name
c_erdatb    TYPE  char6  VALUE  'ERDATB',    " billing created on date
c_erzetb    TYPE  char6  VALUE  'ERZETB',    " billing created on time
c_vkorgb    TYPE  char6  VALUE  'VKORGB',    " sales organization
c_vtwegb    TYPE  char6  VALUE  'VTWEGB',    " distribution channel
c_fktypb    TYPE  char6  VALUE  'FKTYPB',    " billing category
c_kondab    TYPE  char6  VALUE  'KONDAB',    " price group
c_inco1b    TYPE  char6  VALUE  'INCO1B',    " inco terms
c_taxk1b    TYPE  char6  VALUE  'TAXK1B',    " tax classification
c_kalsmb    TYPE  char6  VALUE  'KALSMB',    " pricing procedure
c_posnrb    TYPE  char6  VALUE  'POSNRB',    " billing item number
c_matnrb    TYPE  char6  VALUE  'MATNRB',    " material number
c_fkimgb    TYPE  char6  VALUE  'FKIMGB',    " actual inviced quantity
c_vrkmeb    TYPE  char6  VALUE  'VRKMEB',    " sales unit
c_werksb    TYPE  char6  VALUE  'WERKSB',    " plant
c_prodhb    TYPE  char6  VALUE  'PRODHB',    " product hirearchy
c_mvgr1b    TYPE  char6  VALUE  'MVGR1B',    " material group1
c_abrvwb    TYPE  char6  VALUE  'ABRVWB',    " usage indicator
c_sktofb    TYPE  char6  VALUE  'SKTOFB',    " cash discount indicator
c_augru_auftb  TYPE  char11  VALUE  'AUGRU_AUFTB',
c_kschlb    TYPE  char6  VALUE  'KSCHLB',    "  condition type
c_kdatub    TYPE  char6  VALUE  'KDATUB',    "  condition date
c_kbetrb    TYPE  char6  VALUE  'KBETRB',    " rate
c_waersb    TYPE  char6  VALUE  'WAERSB',    " currency
c_kpeinb    TYPE  char6  VALUE  'KPEINB',    " condition pricing unit
c_kmeinb    TYPE  char6  VALUE  'KMEINB',    " condition unit document
c_kwert_kb  TYPE  char8  VALUE  'KWERT_KB',  " condition value
c_kolnrb    TYPE  char6  VALUE  'KOLNRB',    " access sequence number
c_kposnb    TYPE  char6  VALUE  'KPOSNB',    " condition item number
c_stunrb    TYPE  char6  VALUE  'STUNRB',    " step number
c_zaehkb    TYPE  char6  VALUE  'ZAEHKB',    " condition counter
c_krechb    TYPE  char6  VALUE  'KRECHB',    " calculation type
c_kawrtb    TYPE  char6  VALUE  'KAWRTB',    " condition base value
c_kkursb    TYPE  char6  VALUE  'KKURSB',    " condition exchange rate
c_kntypb    TYPE  char6  VALUE  'KNTYPB',    " condition category
c_knprsb    TYPE  char6  VALUE  'KNPRSB',    " scale type
c_kstatb    TYPE  char6  VALUE  'KSTATB',    " condition statistics
c_kruekb    TYPE  char6  VALUE  'KRUEKB',    " condition accuals
c_kherkb    TYPE  char6  VALUE  'KHERKB',    " origin of condition
c_kgrpeb    TYPE  char6  VALUE  'KGRPEB',    " condition group
c_kvsl1b    TYPE  char6  VALUE  'KVSL1B',    " account key
c_sakn1b    TYPE  char6  VALUE  'SAKN1B',    " G/L account number
c_mwsk1b    TYPE  char6  VALUE  'MWSK1B',    " tax sales/purchase code
c_kvsl2b    TYPE  char6  VALUE  'KVSL2B',    " account key accurals
c_kwertb    TYPE  char6  VALUE  'KWERTB',    " condition value
c_kinakb    TYPE  char6  VALUE  'KINAKB',    " condition is inactive
c_ksteub    TYPE  char6  VALUE  'KSTEUB',    " Condition control
c_koaidb    TYPE  char6  VALUE  'KOAIDB',    " Condition class
c_vbelv     TYPE  char5  VALUE  'VBELV',     " preceeding document
c_vbeln     TYPE  char5  VALUE  'VBELN',     " subsequent document
c_faksp     TYPE  char5  VALUE  'FAKSP',
c_lifsp     TYPE  char5  VALUE  'LIFSP',
c_maktxo    TYPE  char6  VALUE  'MAKTXO',    " material description
c_maktxb    TYPE  char6  VALUE  'MAKTXB',    " material description
c_yy_psp_pnro TYPE char11 VALUE 'YY_PSP_PNRO', " order campign id
c_yy_psp_pnrb TYPE char11 VALUE 'YY_PSP_PNRB', " billing campign id
c_bezei_augru TYPE  char11 VALUE  'BEZEI_AUGRU', " order reasondesc
c_vtext_kschl TYPE char11 VALUE  'VTEXT_KSCHL', " cond type desc
c_vtext_kschlb TYPE char12 VALUE  'VTEXT_KSCHLB', " billcond type desc
c_vtext_konda  TYPE char11 VALUE  'VTEXT_KONDA', " biil price grp desc
c_vtext_kondao  TYPE char12 VALUE  'VTEXT_KONDAO', " order price grp
c_waerk_tax    TYPE char9    VALUE 'WAERK_TAX',   " tax currency
c_waerkb_tax    TYPE char10    VALUE 'WAERKB_TAX',  " tax currency
c_vkgrpb    TYPE  char6  VALUE 'VKGRPB',     " sales group
c_vkburb    TYPE  char6  VALUE 'VKBURB',     " sales office
c_mvgr4b    TYPE  char6  VALUE  'MVGR4B',    " material group 4
c_auth TYPE char10 VALUE 'V_VBAK_VKO',  " sales Authority check
c_authb TYPE char10 VALUE 'V_VBRK_VKO',  " sales Authority check
c_disp  TYPE char2 VALUE '03',
c_kind TYPE char1 VALUE 'I',
c_dummy  TYPE char5 VALUE 'DUMMY',
*c_ordnumber  type char21 value 'Order Document Number',
c_option TYPE char2 VALUE 'EQ'.

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

*----type for the final internal table to display the details
TYPES : BEGIN OF ty_final,
  dummy(20) TYPE c,
  vbelno  TYPE vbeln_va,   "  Sales Document number
  auarto  TYPE auart,      "  Sales Document Type
  bezei   TYPE bezei20,    "  Sales Document Type Description
  audato  TYPE audat,      "  Document date
  gbsta   TYPE gbsta,      " order document overall status
  kunnro  TYPE kunnr,      "  Sold-to party
  name1o TYPE name1_gp,    "  Name
  bstkd_v TYPE bstkd,      "  Customer purchase order number
  augruo  TYPE augru,      "  Order reason
  prsdt_v TYPE prsdt,      "  Date for pricing and exchange rate
  netwro  TYPE netwr_ak,   "  Net Value of the Sales Order
  waerko  TYPE waerk,      " order currency
  mwsbpo  TYPE  mwsbp,     "  Tax amount in document currency
  waerk_tax TYPE waerk,    " TAX CURRENCY
  valdt_v TYPE valdt,      "  fixed value data
  valtg_v TYPE valtg,      "  additional value days
  zterm_v TYPE dzterm,     " condition counter
  vbelnb  TYPE vbeln_vf,   " billing document number
  fkartb  TYPE fkart,      "  Sales Document Type
  vtext   TYPE bezei20,    "  Sales Document Type Description
  fkdatb  TYPE fkdat,      " billing document date
  fkstk   TYPE fkstk,      " billing stataus
  fkstob  TYPE fksto,      " billing document is cancelled
  kunrg   TYPE kunrg,      " payer
  name1b  TYPE name1_gp,    "  payer Name
  netwrb  TYPE  netwr,      " netvalue of the billingorder
  waerkb  TYPE waerk,        " billing currecy
  rfbskb  TYPE rfbsk,        " status to the transfer
  xblnrb  TYPE xblnr_v1,    "   reference document number
  ztermb  TYPE dzterm,      " terms of document key
  ernamo  TYPE ernam,        " name of person who created
  erdato  TYPE erdat,        " sales documnet created date
  erzeto  TYPE erzet,        " document created time
  vkorgo  TYPE vkorg,        " sales organization
  sparto  TYPE  spart,      " division
  vtwego  TYPE vtweg,        " distribution channel
  vbtypo  TYPE vbtyp,        " document category
  faksko  TYPE  faksk,      " billing block in sd document
  faksp  TYPE  faksp,       " billing blk desc
  lifsko  TYPE  lifsk,      " delivery block
  lifsp  TYPE  lifsp,       " deliver block desc
  fkdat_v TYPE  fkdat,      " billing date for billinig index
  vkburo  TYPE  vkbur,      " sales office
  vkgrpo  TYPE  vkgrp,      " sales group
  konda_v TYPE  konda,      " price group
  vtext_kondao TYPE bezei20, " price grp desc
  inco1_v TYPE  inco1,      " inco terms
  bsark_v TYPE  bsark,      " customer purchase order type
  taxk1o  TYPE  taxk1_ak,   " tax classification
  kalsmo  TYPE  kalsmasd,    " pricing procedure
  posnro  TYPE  posnr_va,    " sales item number
  matnro  TYPE  matnr,      " material number
  maktxo  TYPE  maktx,      " material description
  kwmengo TYPE kwmeng,      " order quantity
  vrkmeo  TYPE  vrkme,      " sales unit
  werkso  TYPE  werks,      " plant
  prodho  TYPE  prodh_d,    " product hirearchy
  mvgr1o  TYPE  mvgr1,      " material group 1
  yy_psp_pnro TYPE ps_psp_pnr, " campign ID
  vkauso  TYPE  abrvw,    " Usage indicator
  mvgr4o  TYPE  mvgr4,      " material group 4
  mwsbpb  TYPE  mwsbp,     "  Tax amount in document currency
  waerkb_tax  TYPE waerk,  " tax currency
  kschl   TYPE  kscha,    " condition type
  vtext_kschl TYPE vtxtk, " condition type desc
  kdatu   TYPE  kdatu,    " condition date
  kbetr   TYPE  kbetr,    " rate
  waers   TYPE  waers,    " currency
  kpein   TYPE  kpein,    " condition pricing unit
  kmein   TYPE  kmein,    " condition unit in the document
  kwert_k TYPE  kwert,    " condition value
  kolnr   TYPE  kolnr,    " access sequence number
  kposn   TYPE  kposn,    " condition item number
  stunr   TYPE  stunr,    " step number
  zaehk   TYPE  dzaehk,    " condition counter
  krech   TYPE  krech,    " calculation type
  kawrt   TYPE  kawrt,    " condition base value
  kkurs   TYPE  kkurs,    " condition exchange rate
  kntyp   TYPE  kntyp,    " condition category
  knprs   TYPE  knprs,    " scale type
  kstat   TYPE  kstat,    " condition statistics
  kruek   TYPE  kruek,    " condition accuals
  kherk   TYPE  kherk,    " origin of condition
  kgrpe   TYPE  kgrpe,    " condition group
  kvsl1   TYPE  kvsl1,    " account key
  sakn1   TYPE  saknr,    " G/L account number
  mwsk1   TYPE  mwskz,    " tax on sales/purchase code
  kvsl2   TYPE  kvsl2,    " account key accurals
  kwert   TYPE  kwert,    " condition value
  kinak   TYPE  kinak,    " condition is inactive
  ksteu   TYPE  ksteu,    " Condition control
  koaid   TYPE  koaid,    " Condition class
  ernamb  TYPE  ernam,    " billing document created by name
  erdatb  TYPE  erdat,    " billing document created on date
  erzetb  TYPE  erzet,    " billing document created on time
  vkorgb  TYPE  vkorg,    " sales organization
  spartb  TYPE  spart,    " division
  vtwegb  TYPE  vtweg,    " distribution channel
  fktypb  TYPE  fktyp,    " billing category
  VKGRPb  type  VKGRP,    " Billing Sales group
  VKBURb  type  VKBUR,    " Billing Sales office
  kondab  TYPE  konda,    " price group
  vtext_konda TYPE bezei20, " price grp desc
  inco1b  TYPE  inco1,    " inco terms
  taxk1b  TYPE  taxk1,    " tax classification
  kalsmb  TYPE  kalsmasd,  " pricing procedure
  posnrb  TYPE  posnr_vf,  " billing item number
  matnrb  TYPE  matnr,      " material number
  maktxb  TYPE  maktx,    " material description
  fkimgb  TYPE  fkimg,    "   actual inviced quantity
  vrkmeb  TYPE  vrkme,    " sales unit
  werksb  TYPE  werks_d,   " plant
  prodhb  TYPE  prodh_d,  " product hirearchy
  mvgr1b  TYPE  mvgr1,    " material group 1
  mvgr4b  type  mvgr4,    " material group 4
  yy_psp_pnrb  TYPE  ps_psp_pnr, " work breakdown
  abrvwb  TYPE  abrvw,    " usage indicator
  sktofb  TYPE  sktof,    " cash discount indicator
  augru_auftb  TYPE  augru,  " Billing item order reason
  bezei_augru TYPE augru, " Billing item order reason desc
  kschlb  TYPE  kscha,    " condition type
  vtext_kschlb TYPE vtxtk, " condition type desc
  kdatub  TYPE  kdatu,    " condition date
  kbetrb  TYPE  kbetr,    " rate
  waersb  TYPE  waers,    " currency
  kpeinb  TYPE  kpein,    " condition pricing unit
  kmeinb  TYPE  kmein,    " condition unit in the document
  kwert_kb TYPE  kwert,    " condition value
  kolnrb   TYPE  kolnr,    " access sequence number
  kposnb   TYPE  kposn,    " condition item number
  stunrb   TYPE  stunr,    " step number
  zaehkb   TYPE  dzaehk,    " condition counter
  krechb   TYPE  krech,    " calculation type
  kawrtb   TYPE  kawrt,    " condition base value
  kkursb   TYPE  kkurs,    " condition exchange rate
  kntypb   TYPE  kntyp,    " condition category
  knprsb   TYPE  knprs,    " scale type
  kstatb   TYPE  kstat,    " condition statistics
  kruekb   TYPE  kruek,    " condition accuals
  kherkb   TYPE  kherk,    " origin of condition
  kgrpeb   TYPE  kgrpe,    " condition group
  kvsl1b  TYPE  kvsl1,    " account key
  sakn1b   TYPE  saknr,    " G/L account number
  mwsk1b   TYPE  mwskz,    " tax on sales/purchase code
  kvsl2b   TYPE  kvsl2,    " account key accurals
  kwertb   TYPE  kwert,    " condition value
  kinakb   TYPE  kinak,    " condition is inactive
  ksteub   TYPE  ksteu,    " Condition control
  koaidb  TYPE  koaid,    " Condition class
  vbelv TYPE vbeln_von,    " preceeding document
  vbeln TYPE vbeln_nach,   " subsequent document
END OF ty_final.

*------type for sales order data
TYPES : BEGIN OF ty_vbak_vbap,
  vbeln  TYPE vbeln_va,   "  Sales Document number
  erdat  TYPE erdat,      "  Date on which the record was created
  erzet  TYPE erzet,      "  Entry time
  ernam  TYPE ernam,      "  Name of Person who Created the Object
  audat  TYPE audat,      "  Document date
  vbtyp  TYPE vbtyp,      "  SD document category
  auart  TYPE auart,      "  Sales Document Type
  augru  TYPE augru,      "  Order reason
  lifsk  TYPE lifsk,      "  Delivery block
  faksk  TYPE faksk,      "  Billing block in SD document
  netwr  TYPE netwr_ak,   "  Net Value of the Sales Order
  waerk  TYPE waerk,      "  SD document currency
  vkorg  TYPE vkorg,      "  Sales Organization
  vtweg  TYPE vtweg,      "  Distribution Channel
  spart  TYPE spart,      "  Division
  vkgrp  TYPE vkgrp,      "  Sales group
  vkbur  TYPE vkbur,      "  Sales office
  knumv  TYPE knumv,      "  Number of the document condition
  kalsm  TYPE kalsmasd,   "  Sales and Distribution:Pricing Procedure
  kunnr  TYPE kunnr,      "  Sold-to party
  taxk1  TYPE taxk1_ak,   "  Alternative tax classification

  posnr  TYPE posnr_va,   "  Sales Document Item
  matnr  TYPE matnr,      "  Material Number
  prodh  TYPE prodh_d,    "  Product hierarchy
  vkaus  TYPE  abrvw,
  kwmeng TYPE kwmeng,     "  Cumulative order quantity in sales units
  vrkme  TYPE vrkme,      "  Sales unit
  werks  TYPE werks,      "  Plant
  mvgr1  TYPE mvgr1,      "  Material group 1
  mvgr4  TYPE mvgr4,      "  Material group 4
  mwsbp  TYPE  mwsbp,     "  Tax amount in document currency

  END OF ty_vbak_vbap.

* type Sales order Business data.
TYPES : BEGIN OF ty_vbak_vbkd,
  vbeln TYPE vbeln,      "  Sales and Distribution Document Number
  posnr TYPE posnr,      "  Item number of the SD document
  konda TYPE konda,      "  Price group (customer)
  inco1 TYPE inco1,      "  Incoterms (part 1)
  valtg TYPE valtg,      "  Additional value days
  valdt TYPE valdt,      "  Fixed value date
  zterm TYPE dzterm,     "  Terms of payment key
  prsdt TYPE prsdt,      "  Date for pricing and exchange rate
  fkdat TYPE fkdat,      "  Billing date for billing index andprintout
  bstkd TYPE bstkd,      "  Customer purchase order number
  bsark TYPE bsark,      "  Customer purchase order type
END OF ty_vbak_vbkd.

*---------type for documnt flow
TYPES : BEGIN OF ty_vbfa,
  vbelv TYPE vbeln_von,   " preceeding document
  posnv TYPE posnr_von,   " preceeding item
  vbeln TYPE vbeln_nach,  " subsequent document
  posnn TYPE posnr_nach,  " subsequent item
  vbtyp_n TYPE vbtyp_n,   " subsequent type
  vbtyp_v TYPE vbtyp_v,   " preceeding type
END OF ty_vbfa.


*type Billing header data VBRK.
TYPES : BEGIN OF ty_vbrk_vbrp,
  vbeln  TYPE  vbeln_vf,  "  Billing Document
  fkart  TYPE  fkart,     "  Billing Type
  fktyp  TYPE  fktyp,     "  Billing category
  vbtyp  TYPE  vbtyp,     "  SD document category
  waerk  TYPE  waerk,     "  Currency
  vkorg  TYPE  vkorg,     "  Sales Organization
  vtweg  TYPE  vtweg,     "  Distribution channel
  kalsm  TYPE  kalsmasd,  "  Sales and Distribution:Pricing Procedure
  knumv  TYPE  knumv,     "  Number of the document condition
  fkdat  TYPE  fkdat,     "  Billing date for billing indexandprintout
  konda  TYPE  konda,     "  Price group (customer)
  inco1  TYPE  inco1,     "  Incoterms (part 1)
  rfbsk  TYPE  rfbsk,     "  Status for transfer to accounting
  zterm  TYPE  dzterm,    "  Terms of payment key
  taxk1  TYPE  taxk1,     "  Tax classification 1 for customer
  netwr  TYPE  netwr,     "  Net value in document currency
  ernam  TYPE  ernam,     "  Name of Person who Created the Object
  erzet  TYPE  erzet,     "  Entry time
  erdat  TYPE  erdat,     "  Date on which the record was created
  kunrg  TYPE  kunrg,     "  Payer
  kunag  TYPE  kunag,     "  Sold-to party
  spart  TYPE  spart,     "  Division
  xblnr  TYPE  xblnr_v1,  "  Reference Document Number
  fksto  TYPE  fksto,     "  Billing document is cancelled


  posnr  TYPE  posnr_vf,  "  Billing item
  fkimg  TYPE  fkimg,     "  Actual Invoiced Quantity
  vrkme  TYPE  vrkme,     "  Sales unit
  vbelv  TYPE  vbelv,     "  Originating document
  vgbel  TYPE  vgbel,     "  Document number of the reference document
  vgpos  TYPE  vgpos,     "  Item number of the reference item
  aubel  TYPE  vbeln_va,  "  Sales Document
  aupos  TYPE  posnr_va,  "  Sales Document Item
  matnr  TYPE  matnr,     "  Material Number
  prodh  TYPE  prodh_d,   "  Product hierarchy
  werks  TYPE  werks_d,   "  plant
  sktof  TYPE  sktof,     "  Cash discount indicator
  vkgrp  type  vkgrp,     "  Sales Group
  vkbur  type  vkbur,     "  sales office
  mvgr1  TYPE  mvgr1,     "  Material group 1
  mvgr4  type  mvgr4,     "  Material group 4
  abrvw  TYPE  abrvw,     "  Usage indicator
  mwsbp  TYPE  mwsbp,     "  Tax amount in document currency
  augru_auft  TYPE  augru,
END OF ty_vbrk_vbrp.

*type for    Pricing Conditions.
TYPES : BEGIN OF ty_konv,
  knumv   TYPE  knumv,     "  Number of the document condition
  kposn   TYPE  kposn,     "  Condition item number
  stunr   TYPE  stunr,     "  Step number
  zaehk   TYPE  dzaehk,    "  Condition counter
  kschl   TYPE  kscha,     "  Condition type
  kdatu   TYPE  kdatu,     "  Condition pricing date
  krech   TYPE  krech,     "  Calculation type for condition
  kawrt   TYPE  kawrt,     "  Condition base value
  kbetr   TYPE  kbetr,     "  Rate (condition amount or percentage)
  waers   TYPE  waers,     "  Currency
  kkurs   TYPE  kkurs,     "  Condition exchange rate for conversion
  kpein   TYPE  kpein,     "  Condition pricing unit
  kmein   TYPE  kmein,     "  Condition unit in the document
  kntyp   TYPE  kntyp,     "  Condition category
  kstat   TYPE  kstat,     "  Condition is used for statistics
  knprs   TYPE  knprs,     "  Scale Type
  kruek   TYPE  kruek,     "  Condition is Relevant for Accrual
  kherk   TYPE  kherk,     "  Origin of the condition
  kgrpe   TYPE  kgrpe,     "  Group condition
  kolnr   TYPE  kolnr,     "  Access sequence - Access number
  knumh   TYPE  knumh,     "  Condition record number
  kvsl1   TYPE  kvsl1,     "  Account key
  sakn1   TYPE  saknr,     "  G/L Account Number
  mwsk1   TYPE  mwskz,     "  Tax on sales/purchases code
  kvsl2   TYPE  kvsl2,     "  Account key - accruals / provisions
  kwert   TYPE  kwert,     "  Condition value
  ksteu   TYPE  ksteu,     "  Condition control
  kinak   TYPE  kinak,     "  Condition is inactive
  koaid   TYPE  koaid,     "  Condition class
  kwert_k TYPE  kwert,     "  Condition base value
END OF ty_konv.

*--- type for valid dates of pricing records
TYPES : BEGIN OF ty_konh,
  knumh   TYPE  knumh,     "  Condition record number
  datab   TYPE  datab,     "  Valid-From Date
  datbi   TYPE  datbi,     "  Valid to Date
END OF ty_konh.

*---------type for sales doc.type description
TYPES : BEGIN OF ty_tvakt,
        auart TYPE auart,  " sales document type
        bezei TYPE bezei20,  " sales document type description
        END OF ty_tvakt.
*---------type for billing doc.type description
TYPES : BEGIN OF ty_tvfkt,
        fkart TYPE fkart,  " billing document type
        vtext TYPE bezei20, " billing document type description
        END OF ty_tvfkt.

*---------type for sold to party name
TYPES : BEGIN OF ty_kna1,
        kunnr TYPE kunnr,  " customer number(sold to party)
        name1 TYPE name1_gp,  " name
        END OF ty_kna1.

*------type for billing status
TYPES : BEGIN OF ty_vbuk,
        vbeln TYPE vbeln,  " sales document nuber
        fkstk TYPE fkstk,  " billing status
        END OF ty_vbuk.

*-----type for doc. overall status
TYPES : BEGIN OF ty_vbup,
        vbeln TYPE vbeln,   " sales doc number
        posnr TYPE posnr,   " item
        gbsta TYPE gbsta,   " sales doc overall status
        END OF ty_vbup.
* type for the billing type description
TYPES : BEGIN OF ty_tvfst,
        faksp TYPE faksp,
        vtext TYPE bezei_faksp,
        END OF ty_tvfst.
* type for the billing type description
TYPES : BEGIN OF ty_tvlst,
        lifsp TYPE lifsp,
        vtext TYPE bezei_lifsp,
        END OF ty_tvlst.
* type for the billing price group description
TYPES : BEGIN OF ty_t188t,
        konda TYPE konda,
        vtext TYPE bezei20,
        END OF ty_t188t.
* type for the material description
TYPES : BEGIN OF ty_makt,
        matnr TYPE matnr,
        maktx TYPE maktx,
        END OF ty_makt.

* type for the billing item reason description
TYPES : BEGIN OF ty_tvaut,
        augru TYPE augru,
        bezei TYPE bezei40,
        END OF ty_tvaut.

* type for the condition type description
TYPES : BEGIN OF ty_t685t,
        kschl TYPE kschl,
        vtext TYPE vtxtk,
        END OF ty_t685t.
TYPES:BEGIN OF ty_check,
      vkorg TYPE vkorg,             "organisational Number
      vtweg TYPE vtweg,             "Distribution Channel
      flag TYPE char1,              "Flag used
END OF ty_check.

*---------------------------------------------------------------------
*   Table Types
*---------------------------------------------------------------------

TYPES :
*----table type for ty_vbak_vbap
   t_ty_vbak_vbap TYPE STANDARD TABLE OF ty_vbak_vbap,
*-----table type for ty_vbrk_vbrp
   t_ty_vbrk_vbrp TYPE STANDARD TABLE OF ty_vbrk_vbrp,
*-----table type for ty_konv
   t_ty_konv TYPE STANDARD TABLE OF ty_konv,
*-----table type for ty_konh
   t_ty_konh TYPE STANDARD TABLE OF ty_konh,
*----table type for ty_vbfa
   t_ty_vbfa TYPE STANDARD TABLE OF ty_vbfa,
*------table type for ty_vbuk
   t_ty_vbuk TYPE STANDARD TABLE OF ty_vbuk,
*------table type for ty_vbak_vbkd
   t_ty_vbak_vbkd TYPE STANDARD TABLE OF ty_vbak_vbkd,
*-------table type for ty_tvakt
   t_ty_tvakt TYPE  STANDARD TABLE OF ty_tvakt,
*------table type for ty_tvfkt
   t_ty_tvfkt TYPE  STANDARD TABLE OF ty_tvfkt,
*------table type for ty_kna1
   t_ty_kna1  TYPE  STANDARD TABLE OF ty_kna1,
*-----table type for ty_vbup
   t_ty_vbup  TYPE STANDARD TABLE OF ty_vbup,
*-------table type for ty_final
   t_ty_final TYPE STANDARD TABLE OF ty_final,
*------table type for ty_tvfst
   t_ty_tvfst TYPE STANDARD TABLE OF ty_tvfst,
*------table type for ty_tvlst
   t_ty_tvlst TYPE STANDARD TABLE OF ty_tvlst,
*------table type for ty_makt
   t_ty_makt TYPE STANDARD TABLE OF ty_makt,
*------table type for ty_tvaut
   t_ty_tvaut TYPE STANDARD TABLE OF ty_tvaut,
*------table type for ty_t685t
   t_ty_t685t TYPE STANDARD TABLE OF ty_t685t,
*------table type for ty_t188t
   t_ty_t188t TYPE STANDARD TABLE OF ty_t188t.

**********************************************************************
*                     INTERNAL TABLE DECLARATION
**********************************************************************

*------final internal table
DATA : i_final TYPE STANDARD TABLE OF ty_final.
*------internal table for sales order details
DATA : i_vbak_vbap TYPE STANDARD TABLE OF ty_vbak_vbap.
*------internal table for billing details
DATA : i_vbrk_vbrp TYPE STANDARD TABLE OF ty_vbrk_vbrp.
*-------internal table for business data
DATA : i_vbak_vbkd TYPE STANDARD TABLE OF ty_vbak_vbkd.
*-------internal table for condition records
DATA : i_konv TYPE STANDARD TABLE OF ty_konv.
*-------internal table for condition data valid dates
DATA : i_konh TYPE  STANDARD TABLE OF ty_konh.
*-------internal table for condition records
DATA : i_konv_b TYPE STANDARD TABLE OF ty_konv.
*-------internal table for condition data valid dates
DATA : i_konh_b TYPE  STANDARD TABLE OF ty_konh.
*-------internal table for document flow
DATA : i_vbfa TYPE  STANDARD TABLE OF ty_vbfa.
*-------internal table for
DATA : i_tvakt TYPE STANDARD TABLE OF ty_tvakt.
*-------internal table for
DATA : i_tvfkt TYPE STANDARD TABLE OF ty_tvfkt.
*-------internal table for sold-to party name
DATA : i_kna1 TYPE STANDARD TABLE OF ty_kna1.
*-------internal table for payer name
DATA : i_kna1_b TYPE STANDARD TABLE OF ty_kna1.
*-------internal table for billing status
DATA : i_vbuk TYPE STANDARD TABLE OF ty_vbuk.
*-------internal table for over all sales doc. status
DATA : i_vbup TYPE STANDARD TABLE OF ty_vbup.
*-------internal table for order type description
DATA : i_tvfst TYPE STANDARD TABLE OF ty_tvfst.
*-------internal table for billing type description
DATA : i_tvlst TYPE STANDARD TABLE OF ty_tvlst.
*-------internal table for billing reason description
DATA : i_tvaut TYPE STANDARD TABLE OF ty_tvaut.
*-------internal table for sales material description
DATA : i_makt TYPE STANDARD TABLE OF ty_makt.
*-------internal table for billing material description
DATA : i_makt_b TYPE STANDARD TABLE OF ty_makt.
*-------internal table for order price grp description
DATA : i_t188t_o TYPE STANDARD TABLE OF ty_t188t.
*-------internal table for billng price grp description
DATA : i_t188t TYPE STANDARD TABLE OF ty_t188t.
*-------internal table for conditin type description
DATA : i_t685t TYPE STANDARD TABLE OF ty_t685t.
*-------internal table for conditin type description
DATA : i_t685t_b TYPE STANDARD TABLE OF ty_t685t.



**********************************************************************
*                       VARIABLE DECLARATION
**********************************************************************
DATA: v_vkorg TYPE VBAK-vkorg,  "Sales Organization
      v_vtweg TYPE vbak-vtweg,  "Distribution Channel
      v_matnr TYPE matnr,  "Material Number
      v_kschl TYPE konp-kschl,  "Condition type
      v_datab TYPE datab,  "valid from
      v_datbi TYPE datbi,  "valid to
      v_vbeln_va TYPE vbeln_va, "Sales Document
      v_auart TYPE auart,  "Sales Document Type
      v_erdat TYPE erdat,  "Date on which the record was created
      v_kunnr TYPE kunag,  "Sold-to party
      v_vbeln_vf TYPE vbeln_vf,  "Billing Document
      v_fkart TYPE fkart,  "Billing Type
      v_kunrg TYPE kunrg.  "Payer

*Define ranges
DATA : r_salesorg TYPE RANGE OF vkorg,
       r_distch TYPE RANGE OF vtweg.


**********************************************************************
*                  WORK AREA DECLARATION FOR ALV GRID DISPLAY
**********************************************************************

DATA :  i_fieldcat TYPE slis_t_fieldcat_alv, " field catalog
        v_save TYPE char1,   " to save the variant
        v_exit TYPE char1,   " exit
        v_repid TYPE sy-repid,  " report name
        v_variant TYPE disvariant,  " variant
        layout   TYPE slis_layout_alv,  " layout variant
        vx_variant TYPE disvariant.    " variant

***********************************************************************
*                  WORK AREA DECLARATION                              *
***********************************************************************

DATA : wa_final TYPE ty_final. " work area for i_final
DATA : wa_vbak_vbap TYPE ty_vbak_vbap. " work area for i_vbak_vbap
DATA : wa_vbrk_vbrp TYPE ty_vbrk_vbrp. " work area for i_vbrk_vbrp
DATA : wa_vbkd TYPE ty_vbak_vbkd.      " work area for i_vbak_vbkd
DATA : wa_konv TYPE ty_konv.           " work area for i_konv
DATA : wa_konv_b TYPE ty_konv.         " work area for i_konv_b
DATA : wa_vbfa TYPE ty_vbfa.           " work area for i_vbfa
DATA : wa_tvakt TYPE ty_tvakt.         " work area for i_tvakt
DATA : wa_tvfkt TYPE ty_tvfkt.         " work area for i_tvfkt
DATA : wa_kna1 TYPE ty_kna1.           " work area for i_kna1
DATA : wa_kna1_b TYPE ty_kna1.         " work area for i_kna1_b
DATA : wa_vbuk TYPE ty_vbuk.           " work area for i_vbuk
DATA : wa_vbup TYPE ty_vbup.           " work area for i_vbup
DATA : wa_tvfst TYPE ty_tvfst.         " work area for i_tvfst
DATA : wa_tvlst TYPE ty_tvlst.         " work area for i_tvlst
DATA : wa_tvaut TYPE ty_tvaut.         " work area for i_tvaut
DATA : wa_makt TYPE ty_makt.           " work area for i_makt
DATA : wa_makt_b TYPE ty_makt.         " work area for i_makt_b
DATA : wa_t188t TYPE ty_t188t.         " work area for i_t188t
DATA : wa_t685t TYPE ty_t685t.         " work area for i_t685t
DATA : wa_t685t_b TYPE ty_t685t.       " work area for i_t685t_b
DATA : wa_t188t_o TYPE ty_t188t.       " work area for i_t188t_o

***********************************************************************
*          WORK AREA DECLARATION FOR RANGES                           *
***********************************************************************

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


*----------------------------------------------------------------------
*                 Include for Selection Screen Design
*----------------------------------------------------------------------
* This Include contains the design of Selection Screen

*INCLUDE zpricing_seln.
*&---------------------------------------------------------------------
*&  Include           ZPRICING_SELN
*&---------------------------------------------------------------------
*======================================================================
*DEVELOPMENT ID       : GDEVWR0005370
*CHANGE REQUEST (CTS) : RD2K923937
*DESCRIPTION          : THE PURPOSE OF THIS INCLUDE IS TO PROVIDE
*                       SELECTION SCREEN
*======================================================================
*COPIED FROM         : (CLONED PROGRAM)
*TITLE               : (PROGRAM TITLE)
*OTHER RELATED OBJ   : (OBJECT NAMES)
*======================================================================
*CHANGE HISTORY LOG
*----------------------------------------------------------------------
*MOD. NO.|  DATE    | NAME    | CORRECTION NUMBER | CHANGE REFERENCE #
*----------------------------------------------------------------------
*MOD-001 |DD/MM/YYYY| XXXXXXX | XXXXXXXXXX        | XXXXXXXXXX
*DESCRIPTION:
*
***********************************************************************

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
*           Order Documents
PARAMETERS: rb_order RADIOBUTTON GROUP gr1 DEFAULT 'X'
                                   USER-COMMAND ucomm,
*           Billing Documents
            rb_bill  RADIOBUTTON GROUP gr1.

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.

SELECT-OPTIONS:
* Sales Organization
  s_vkorg FOR v_vkorg NO INTERVALS OBLIGATORY DEFAULT 'GB11',
* Distribution Channel
  s_vtweg FOR v_vtweg OBLIGATORY DEFAULT '01',
* Material
  s_matnr FOR v_matnr MATCHCODE OBJECT MAT1,
* Condition Type
  s_kschl FOR v_kschl MATCHCODE OBJECT H_T685,
*/eur/oeucse_condition_type,
* Condition Type Valid from
  s_datab FOR v_datab NO-EXTENSION NO INTERVALS,
* Condition type Valid to
  s_datbi FOR v_datbi NO-EXTENSION NO INTERVALS.

SELECTION-SCREEN END OF BLOCK b2.

SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME.

SELECT-OPTIONS:
* Order Document Number
  s_vbelno FOR v_vbeln_va MODIF ID sc1,
          "MATCHCODE OBJECT /eur/oeucse_sales_doc_num
* Order Document Type
  s_auart FOR v_auart  MATCHCODE OBJECT H_TVAK
                       MODIF ID sc1,
* Order Document Created on
* s_erdato FOR v_erdat MODIF ID sc1 OBLIGATORY DEFAULT SY-DATUM,
  s_erdato FOR v_erdat MODIF ID sc1, " OBLIGATORY DEFAULT SY-DATUM,

* Order Sold-to Party
  s_kunag FOR v_kunnr MATCHCODE OBJECT C_KUNNR
                       MODIF ID sc1.

SELECTION-SCREEN END OF BLOCK b3.

SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME.

SELECT-OPTIONS:
* Billing Document Number
  s_vbelnb FOR v_vbeln_vf MATCHCODE OBJECT F4_VBRK
                        MODIF ID sc2,
* Billing Document Type
  s_fkart FOR v_fkart  MATCHCODE OBJECT H_TVFK
                       MODIF ID sc2,
* Billing Document Created On
  s_erdatb FOR v_erdat MODIF ID sc2 OBLIGATORY DEFAULT SY-DATUM,
* Billing Document Payer
  s_kunrg FOR v_kunrg MATCHCODE OBJECT DEBI
                       MODIF ID sc2.

SELECTION-SCREEN END OF BLOCK b4.

SELECTION-SCREEN BEGIN OF BLOCK b5 WITH FRAME.

* Layout Variant
PARAMETERS: p_disvar type disvariant-variant.  "Layout Variant

SELECTION-SCREEN END OF BLOCK b5.

*----------------------------------------------------------------------
*                 Include for Subroutines
*----------------------------------------------------------------------

*This Include contains all the Subroutines.

* INCLUDE zpricing_rtns.

***********************************************************************
*          INITIALIZATION
***********************************************************************

INITIALIZATION.
*--initializing the global variables
  PERFORM init_prog CHANGING v_variant
                             vx_variant
                             p_disvar
                             v_repid
                             v_save.
  PERFORM build_layout USING layout.

***********************************************************************
*                         AT SELECTION-SCREEN EVENT
***********************************************************************

AT SELECTION-SCREEN OUTPUT.
*-----This is to change the slection screen as per the radiobittons
  PERFORM at_selection_screen.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_disvar.

* This get the ALV predined varients when pressing F4 button
  PERFORM get_alv_variant USING    v_variant
                                   v_save
                          CHANGING vx_variant
                                   p_disvar
                                   v_exit.

* AT SELECTION-SCREEN on field

AT SELECTION-SCREEN ON s_vkorg.
*----validation of sales organization
  PERFORM sub_validate_salesorg.

AT SELECTION-SCREEN ON s_vtweg.
*-----validation of distribution channel
  PERFORM sub_validate_distchanl.

AT SELECTION-SCREEN ON s_matnr.
*-----validation of material number
  PERFORM sub_validate_material.

AT SELECTION-SCREEN ON s_kschl.
*-----validation of condition type
  PERFORM sub_validate_conditiontype.

AT SELECTION-SCREEN ON s_vbelno.
*------validation of document number
  PERFORM sub_validate_salesdoc.

AT SELECTION-SCREEN ON s_auart.
*-----validation of document type
  PERFORM sub_validate_doctype.
*
AT SELECTION-SCREEN ON s_kunag.
*-----validation of sold-to party
  PERFORM sub_validate_soldtoparty.

AT SELECTION-SCREEN ON s_vbelnb.
*-----validation of billing document number
  PERFORM sub_validate_billdoc.

AT SELECTION-SCREEN ON s_fkart.
*-------validation fo billing document type
  PERFORM sub_validate_billingtype.

AT SELECTION-SCREEN ON s_kunrg.
*------validation of payer
  PERFORM sub_validate_payer.

* AT SELECTION-SCREEN EVENT
  AT SELECTION-SCREEN.

* This reuse of the existence variant for the ALV List
  PERFORM pai_of_selection_screen USING v_save
                                        v_repid
                              CHANGING  p_disvar
                                        v_variant
                                        vx_variant.


**********************************************************************
*                         START OF SELECTION
**********************************************************************

START-OF-SELECTION.
  IF rb_order = c_yes.     " Order Documents is Selected
* Authorization check for Sales organization
  PERFORM check_auhtorization.

* Retrives the Order details from the sales Tables Based on
* Selection Scren Entries.
  PERFORM get_sales CHANGING i_vbak_vbap.
* Retrives the Business data.
  PERFORM get_busdata USING    i_vbak_vbap
                        CHANGING i_vbak_vbkd.
* Displays the overall status of the sales document item
  PERFORM doc_status USING i_vbak_vbap
                        CHANGING i_vbup.

* Retrives the billing satus
  PERFORM   get_billing_status USING i_vbak_vbap
                                 CHANGING i_vbuk.
* Retrives the Order Conditions data.
  PERFORM get_konv USING    i_vbak_vbap
                     CHANGING i_konv.
* To Validate The Dates of the Conditions
  PERFORM get_konh USING    i_konv
                     CHANGING i_konh.
* retrives the Document Flow data.
  PERFORM get_vbfa USING i_vbak_vbap
                     CHANGING i_vbfa.
* Retrives the Billing Data
  PERFORM get_billing USING i_vbfa
                        CHANGING i_vbrk_vbrp.
* To retrive the order type description data.
  PERFORM get_typdec USING i_vbak_vbap
                       CHANGING i_tvakt.
* To retrive the billing document type description.
  PERFORM get_typdec_b  USING i_vbrk_vbrp
                          CHANGING i_tvfkt.
* To retrive the name of sold-to-party.
  PERFORM get_soldtoparty USING i_vbak_vbap
                            CHANGING  i_kna1.
* to retrive the name of the payer.
  PERFORM get_payer USING i_vbrk_vbrp
                      CHANGING i_kna1_b.
* Retrives the Billing Conditions data.
  PERFORM get_konv_s USING i_vbrk_vbrp
                       CHANGING i_konv_b.

* To Validate The Dates of the Conditions
  PERFORM get_konh_s USING    i_konv_b
                       CHANGING i_konh_b.

* to retrive the description of billingblock
  PERFORM desc_billblock USING i_vbak_vbap
                       CHANGING i_tvfst.

* to retrive the description of delivery block
  PERFORM desc_delivblock USING i_vbak_vbap
                CHANGING i_tvlst.

* to retrive the order material description
  PERFORM desc_material  USING i_vbak_vbap
               CHANGING i_makt.

* to retrive the billing material description
  PERFORM desc_material_b  USING i_vbrk_vbrp
               CHANGING i_makt_b.
* to retrive the billing order reason description
  PERFORM desc_reason_b using i_vbrk_vbrp
                          changing i_tvaut.
* to retrive the order price group description
  PERFORM desc_pricegrp_o using i_vbAk_vbkd
                          changing i_t188t_o.
* to retrive the billing price group description
  PERFORM desc_pricegrp using i_vbrk_vbrp
                          changing i_t188t.
* to retrive the condition type description
  PERFORM desc_condtype_o using i_konv
                          changing i_t685t.
* to retrive the condition type description
  PERFORM desc_condtype_b using i_konv_b
                          changing i_t685t_b.
* Populates the Final Internal table for Orders
  PERFORM get_data_or CHANGING i_final.

  ELSEIF rb_bill = c_yes.  " Billing Documents is Selected
* Authorization check for Sales organization
  PERFORM check_auhtorization_B.

* Retrives the Billing Details from Billing Tables Based on
* Selection Screen Entries.
  PERFORM get_billing_data CHANGING i_vbrk_vbrp.
* Retrives the Billing Conditions data.
  PERFORM get_konv_b  USING   i_vbrk_vbrp
                     CHANGING i_konv_B.
* to retrive the condition type description
  PERFORM desc_condtype_b using i_konv_b
                          changing i_t685t_b.
* To Validate The Dates of the Conditions
  PERFORM get_konh_b USING    i_konv_B
                       CHANGING i_konh_B.
* Retrives the Sales Data
  PERFORM get_sales_b USING i_vbrk_vbrp
                        CHANGING i_vbak_vbap.
* Displays the overall status of the sales document item
  PERFORM doc_status USING i_vbak_vbap
                        CHANGING i_vbup.
* Retrives the billing satus
  PERFORM   get_billing_status USING i_vbak_vbap
                                 CHANGING i_vbuk.
* To retrive the description data.
  PERFORM get_typdec USING i_vbak_vbap
                       CHANGING i_tvakt.
* To retrive the billing document type description.
  PERFORM get_typdec_b  USING i_vbrk_vbrp
                          CHANGING i_tvfkt.
* To retrive the name of sold-to-party.
  PERFORM get_soldtoparty USING i_vbak_vbap
                            CHANGING  i_kna1.
* to retrive the name of the payer.
  PERFORM get_payer USING i_vbrk_vbrp
                   CHANGING i_kna1_b.
* Retrives the business data
  PERFORM get_busdata_b USING  i_vbak_vbap
                      CHANGING i_vbak_vbkd.
* to retrive the order price group description
  PERFORM desc_pricegrp_o using i_vbAk_vbkd
                        changing i_t188t_o.
* Retrives the Order Conditions data.
  PERFORM get_konv_sc USING i_vbak_vbap
                      CHANGING  i_konv.
* to retrive the condition type description
  PERFORM desc_condtype_o using i_konv
                      changing i_t685t.

* To Validate The Dates of the Conditions
  PERFORM get_konh_sc USING i_konv
                   CHANGING i_konh.
* to retrive the description of billingblock
  PERFORM desc_billblock USING i_vbak_vbap
                     CHANGING i_tvfst.
* to retrive the description of delivery block
  PERFORM desc_delivblock USING i_vbak_vbap
              CHANGING i_tvlst.
* to retrive the order material description
  PERFORM desc_material  USING i_vbak_vbap
                 CHANGING i_makt.
* to retrive the billing material description
  PERFORM desc_material_b  USING i_vbrk_vbrp
                   CHANGING i_makt_b.
* Populates the Final Internal table for Billing
  PERFORM get_data_bl CHANGING i_final.
  ENDIF.

***********************************************************************
*                         END OF SELECTION
***********************************************************************
*END-OF-SELECTION.
* INITIALISING THE FIELD CATALOGUE
  PERFORM initialize_fieldcat CHANGING i_fieldcat.
* Displays the Data in The ALV GRID
  PERFORM  write_output.

*&---------------------------------------------------------------------
*&  Include           ZPRICING_RTN
*&---------------------------------------------------------------------
*======================================================================
*CHANGE REQUEST (CTS) : RD2K923937
*DESCRIPTION          : THE PURPOSE OF THIS INCLUDE IS TO PROVIDE
*                       ALL THE SUBROUTINES USED IN THE REPORT
*======================================================================
*COPIED FROM         : (CLONED PROGRAM)
*TITLE               : (PROGRAM TITLE)
*OTHER RELATED OBJ   : (OBJECT NAMES)
*======================================================================
*CHANGE HISTORY LOG
*----------------------------------------------------------------------
*MOD. NO.|  DATE    | NAME           | CORRECTION NUMBER  | CHANGE
*REFERENCE #    *
*----------------------------------------------------------------------
*MOD-001 |DD/MM/YYYY| XXXXXXXXXXXXXX | XXXXXXXXXX         | XXXXXXXXXX
*DESCRIPTION:
*----------------------------------------------------------------------
*MOD-002 |DD/MM/YYYY| XXXXXXXXXXXXXX | XXXXXXXXXX         | XXXXXXXXXX
*DESCRIPTION:
***********************************************************************
*&---------------------------------------------------------------------
*&      Form  get_sales
*&---------------------------------------------------------------------
*       sub routine to Retrive the sales data as per selection screen
*----------------------------------------------------------------------

FORM get_sales CHANGING fp_i_vbak_vbap TYPE t_ty_vbak_vbap.
  SELECT   a~vbeln    "  Sales Document number
           a~erdat    "  Date on which the record was created
           a~erzet    "  Entry time
           a~ernam    "  Name of Person who Created the Object
           a~audat    "  Document date
           a~vbtyp    "  SD document category
           a~auart    "  Sales Document Type
           a~augru    "  Order reason
           a~lifsk    "  Delivery block
           a~faksk    "  Billing block in SD document
           a~netwr    "  Net Value of the Sales Order in Document
           a~waerk    "  SD document currency
           a~vkorg    "  Sales Organization
           a~vtweg    "  Distribution Channel
           a~spart    "  Division
           a~vkgrp    "  Sales group
           a~vkbur    "  Sales office
           a~knumv    "  Number of the document condition
           a~kalsm    "  Sales and Distribution: Pricing Procedure
           a~kunnr    "  Sold-to party
           a~taxk1    "  Alternative tax classification

           b~posnr    "  Sales Document Item
           b~matnr    "  Material Number
           b~prodh    "  Product hierarchy
           b~vkaus
           b~kwmeng   "  Cumulative order quantity in sales units
           b~vrkme    "  Sales unit
           b~werks    "  Plant
           b~mvgr1    "  Material group 1
           b~mvgr4    "  Material group 4
           b~mwsbp    "  Tax amount in document currency
       INTO TABLE fp_i_vbak_vbap FROM vbak AS a
       INNER JOIN vbap AS b ON
       a~vbeln = b~vbeln
       WHERE a~vbeln IN s_vbelno AND
             a~erdat IN s_erdato AND
             a~auart IN s_auart  AND
             a~kunnr IN s_kunag AND
             a~vkorg IN s_vkorg AND
             a~vtweg IN s_vtweg AND
             b~matnr IN s_matnr.

  IF sy-subrc %LT%GT 0.
*-----no sales order data found
    MESSAGE i055.
    LEAVE LIST-PROCESSING.
  ENDIF.
ENDFORM.                    "get_sales

*&---------------------------------------------------------------------
*&      Form  get_busdata
*&---------------------------------------------------------------------
*       subroutine to retrive the business data
*----------------------------------------------------------------------
*  --%GT  p1        fp_i_vbak_vbap
*  %LT--  p2        fp_i_vbak_vbkd
*----------------------------------------------------------------------

FORM get_busdata  USING    fp_i_vbak_vbap TYPE t_ty_vbak_vbap
                  CHANGING fp_i_vbak_vbkd TYPE t_ty_vbak_vbkd.

  DATA : l_i_vbak_vbap_tmp TYPE t_ty_vbak_vbap.

  l_i_vbak_vbap_tmp[] = fp_i_vbak_vbap[].
  SORT l_i_vbak_vbap_tmp BY vbeln.
  DELETE ADJACENT DUPLICATES FROM l_i_vbak_vbap_tmp COMPARING vbeln.
  IF NOT l_i_vbak_vbap_tmp IS INITIAL.
    SELECT
    vbeln    "  Sales and Distribution Document Number
    posnr    "  Item number of the SD document
    konda    "  Price group (customer)
    inco1    "  Incoterms (part 1)
    valtg    "  Additional value days
    valdt    "  Fixed value date
    zterm    "  Terms of payment key
    prsdt    "  Date for pricing and exchange rate
    fkdat    "  Billing date for billing index and printout
    bstkd    "  Customer purchase order number
    bsark    "  Customer purchase order type
    FROM vbkd
    INTO TABLE fp_i_vbak_vbkd
    FOR ALL ENTRIES IN l_i_vbak_vbap_tmp
    WHERE vbeln = l_i_vbak_vbap_tmp-vbeln.
  ENDIF.
  IF sy-subrc NE 0.
*-----no business data found
    MESSAGE i057.
  ENDIF.


ENDFORM.                    " get_busdata

*&---------------------------------------------------------------------
*&      Form  get_konv
*&---------------------------------------------------------------------
*       subroutine to retrive the order conditions dat
*----------------------------------------------------------------------
*  --%GT  p1        FP_i_vbak_vbap
*  %LT--  p2        FP_i_konv
*----------------------------------------------------------------------

FORM get_konv  USING     fp_i_vbak_vbap TYPE t_ty_vbak_vbap
               CHANGING  fp_i_konv TYPE  t_ty_konv.

  DATA : l_i_vbak_vbap_tmp TYPE t_ty_vbak_vbap.

  l_i_vbak_vbap_tmp[] = fp_i_vbak_vbap[].
  SORT l_i_vbak_vbap_tmp BY vbeln posnr.
  DELETE ADJACENT DUPLICATES FROM l_i_vbak_vbap_tmp COMPARING vbeln
                                                              posnr.
  IF NOT l_i_vbak_vbap_tmp IS INITIAL.
    SELECT knumv    "  Number of the document condition
        kposn    "  Condition item number
        stunr    "  Step number
        zaehk    "  Condition counter
        kschl    "  Condition type
        kdatu    "  Condition pricing date
        krech    "  Calculation type for condition
        kawrt    "  Condition base value
        kbetr    "  Rate (condition amount or percentage)
        waers    "  Currency
        kkurs    "  Condition exchange rate for conversion
        kpein    "  Condition pricing unit
        kmein    "  Condition unit in the document
        kntyp    "  Condition category
        kstat    "  Condition is used for statistics
        knprs    "  Scale Type
        kruek    "  Condition is Relevant for Accrual
        kherk    "  Origin of the condition
        kgrpe    "  Group condition
        kolnr    "  Access sequence - Access number
        knumh    "  Condition record number
        kvsl1    "  Account key
        sakn1    "  G/L Account Number
        mwsk1    "  Tax on sales/purchases code
        kvsl2    "  Account key - accruals / provisions
        kwert    "  Condition value
        ksteu    "  Condition control
        kinak    "  Condition is inactive
        koaid    "  Condition class
        kwert_k  "  Condition base value
        FROM konv INTO TABLE fp_i_konv
        FOR ALL ENTRIES IN  l_i_vbak_vbap_tmp
        WHERE knumv = l_i_vbak_vbap_tmp-knumv AND
              kposn = l_i_vbak_vbap_tmp-posnr AND
              kschl IN s_kschl.
  ENDIF.
  IF sy-subrc %LT%GT 0.
*-----no sales conditions records found
    MESSAGE i058.
  ENDIF.
ENDFORM.                    " get_konv

*&---------------------------------------------------------------------
*&      Form  get_konh
*&---------------------------------------------------------------------
*      subroutine to retrive the condition records data for valid dates
*----------------------------------------------------------------------
*  --%GT  p1        fp_i_konv
*  %LT--  p2        fp_i_konh
*----------------------------------------------------------------------

FORM get_konh USING fp_i_konv TYPE  t_ty_konv
              CHANGING fp_i_konh    TYPE t_ty_konh.

  DATA : l_i_konv TYPE  t_ty_konv.

  l_i_konv[] = fp_i_konv[].
  SORT l_i_konv BY knumv.
  DELETE ADJACENT DUPLICATES FROM l_i_konv COMPARING knumv.
  IF NOT l_i_konv IS INITIAL.
    SELECT
    knumh    "  Condition record number
    datab    "  Valid-From Date
    datbi    "  Valid to Date
    FROM konh INTO TABLE fp_i_konh
    FOR ALL ENTRIES IN l_i_konv
    WHERE knumh = l_i_konv-knumh AND
          datab IN s_datab AND
          datbi IN s_datbi.
  ENDIF.
  IF sy-subrc %LT%GT 0.
*  -------NO SY-SUBRC REQUIRED.
  ENDIF.

ENDFORM.                    " get_konh


*&---------------------------------------------------------------------
*&      Form  get_vbfa
*&---------------------------------------------------------------------
*     subroutine to retrive document flow data
*----------------------------------------------------------------------
*  --%GT  p1        fp_i_vbak_vbap
*  %LT--  p2        fp_i_vbfa
*----------------------------------------------------------------------

FORM get_vbfa USING     fp_i_vbak_vbap TYPE t_ty_vbak_vbap
              CHANGING  fp_i_vbfa  TYPE t_ty_vbfa.

  IF NOT fp_i_vbak_vbap IS INITIAL.
    SELECT  vbelv    "  Preceding sales and distribution document
            posnv    "  Preceding item of an SD document
            vbeln    "  Subsequent sales and distribution document
            posnn    "  Subsequent item of an SD document
            vbtyp_n  "  Document category of subsequent document
            vbtyp_v  "  Document category of preceding SD document
            FROM vbfa INTO TABLE fp_i_vbfa
            FOR ALL ENTRIES IN fp_i_vbak_vbap
            WHERE vbelv = fp_i_vbak_vbap-vbeln AND
                  posnv = fp_i_vbak_vbap-posnr.
  ENDIF.
  IF sy-subrc %LT%GT 0.
*------------NO SY-SUBRC REQUIRED.
  ENDIF.
ENDFORM.                    " get_vbfa
*&---------------------------------------------------------------------
*&      Form  get_billing
*&---------------------------------------------------------------------
*  sub routine to retrive the billing order data related to sales
*----------------------------------------------------------------------
*  --%GT  p1        fp_i_vbfa
*  %LT--  p2        fp_i_vbrk_vbrk
*----------------------------------------------------------------------

FORM get_billing USING fp_i_vbfa  TYPE t_ty_vbfa
                 CHANGING fp_i_vbrk_vbrp TYPE t_ty_vbrk_vbrp.

  IF NOT fp_i_vbfa IS INITIAL.
    SELECT  a~vbeln    "  Billing Document
            a~fkart    "  Billing Type
            a~fktyp    "  Billing category
            a~vbtyp    "  SD document category
            a~waerk    "  Currency
            a~vkorg    "  Sales Organization
            a~vtweg    "  Distribution channel
            a~kalsm    "  Sales and Distribution: Pricing Procedure
            a~knumv    "  Number of the document condition
            a~fkdat    "  Billing date for billing index and printout
            a~konda    "  Price group (customer)
            a~inco1    "  Incoterms (part 1)
            a~rfbsk    "  Status for transfer to accounting
            a~zterm    "  Terms of payment key
            a~taxk1    "  Tax classification 1 for customer
            a~netwr    "  Net value in document currency
            a~ernam    "  Name of Person who Created the Object
            a~erzet    "  Entry time
            a~erdat    "  Date on which the record was created
            a~kunrg    "  Payer
            a~kunag    "  Sold-to party
            a~spart    "  Division
            a~xblnr    "  Reference Document Number
            a~fksto    "  Billing document is cancelled

            b~posnr    "  Billing item
            b~fkimg    "  Actual Invoiced Quantity
            b~vrkme    "  Sales unit
            b~vbelv    "  Originating document
            b~vgbel    "  Document number of the reference document
            b~vgpos    "  Item number of the reference item
            b~aubel    "  Sales Document
            b~aupos    "  Sales Document Item
            b~matnr    "  Material Number
            b~prodh    "  Product hierarchy
            b~werks    "  plant
            b~sktof    "  Cash discount indicator
            b~vkgrp
            b~vkbur
            b~mvgr1    "  Material group 1
            b~mvgr4
            b~abrvw    "  Usage indicator
            b~mwsbp      "  Tax amount in document currency
            b~augru_auft

        INTO TABLE fp_i_vbrk_vbrp
        FROM vbrk AS a INNER JOIN vbrp AS b ON
        a~vbeln = b~vbeln
        FOR ALL ENTRIES IN fp_i_vbfa
        WHERE a~vbeln = fp_i_vbfa-vbeln AND
              b~posnr = fp_i_vbfa-posnn AND
              a~vbtyp = fp_i_vbfa-vbtyp_n.

    IF sy-subrc NE 0.
*------no billing order data found
      MESSAGE i056.
    ENDIF.
  ENDIF.
ENDFORM.                    " get_billing

*&---------------------------------------------------------------------
*&      Form  get_konv_b
*&---------------------------------------------------------------------
*       subroutine to retrive the billing conditions data
*----------------------------------------------------------------------
*  --%GT  p1        fp_i_vbrk_vbrp
*  %LT--  p2        fp_i_kon_b
*----------------------------------------------------------------------

FORM get_konv_s  USING     fp_i_vbrk_vbrp TYPE t_ty_vbrk_vbrp
               CHANGING    fp_i_konv_b TYPE  t_ty_konv.

  DATA : l_i_vbrk_vbrp_tmp TYPE t_ty_vbrk_vbrp.

  l_i_vbrk_vbrp_tmp[] = fp_i_vbrk_vbrp[].
  SORT l_i_vbrk_vbrp_tmp BY vbeln posnr.
  DELETE ADJACENT DUPLICATES FROM l_i_vbrk_vbrp_tmp
  COMPARING vbeln posnr.
  IF NOT l_i_vbrk_vbrp_tmp IS INITIAL.
    SELECT
    knumv    "  Number of the document condition
    kposn    "  Condition item number
    stunr    "  Step number
    zaehk    "  Condition counter
    kschl    "  Condition type
    kdatu    "  Condition pricing date
    krech    "  Calculation type for condition
    kawrt    "  Condition base value
    kbetr    "  Rate (condition amount or percentage)
    waers    "  Currency
    kkurs    "  Condition exchange rate for conversion to local curren
    kpein    "  Condition pricing unit
    kmein    "  Condition unit in the document
    kntyp    "  Condition category
    kstat    "  Condition is used for statistics
    knprs    "  Scale Type
    kruek    "  Condition is Relevant for Accrual
    kherk    "  Origin of the condition
    kgrpe    "  Group condition
    kolnr    "  Access sequence - Access number
    knumh    "  Condition record number
    kvsl1    "  Account key
    sakn1    "  G/L Account Number
    mwsk1    "  Tax on sales/purchases code
    kvsl2    "  Account key - accruals / provisions
    kwert    "  Condition value
    ksteu    "  Condition control
    kinak    "  Condition is inactive
    koaid    "  Condition class
    kwert_k  "  Condition base value

    FROM konv INTO TABLE fp_i_konv_b
    FOR ALL ENTRIES IN  l_i_vbrk_vbrp_tmp
    WHERE knumv = l_i_vbrk_vbrp_tmp-knumv AND
          kposn = l_i_vbrk_vbrp_tmp-posnr AND
              kschl IN s_kschl.
  ENDIF.
  IF sy-subrc NE 0.
*------no billing condition records found
    MESSAGE i059.
  ENDIF.
ENDFORM.                    " get_konv_b

*&--------------------------------------------------------------------
*&      Form  get_konh_b
*&--------------------------------------------------------------------
* Subroutine to retrive the biiling condition records for valid date
*---------------------------------------------------------------------

FORM get_konh_s USING fp_i_konv TYPE  t_ty_konv
                CHANGING fp_i_konh    TYPE t_ty_konh.

  DATA : l_i_ty_konv TYPE t_ty_konv.

*-- Move to temp internal table
  l_i_ty_konv[] = fp_i_konv[].
*-- Sort Internal table by Cond. Doc. Number
  SORT l_i_ty_konv BY knumv.
*-- Delete duplicates
  DELETE ADJACENT DUPLICATES FROM l_i_ty_konv COMPARING knumv.
*-- Get condition details from the table konh
  IF NOT l_i_ty_konv IS INITIAL.
    SELECT
    knumh    "  Condition record number
    datab    "  Valid-From Date
    datbi    "  Valid to Date
    FROM konh
    INTO TABLE fp_i_konh
    FOR ALL ENTRIES IN l_i_ty_konv
    WHERE knumh = l_i_ty_konv-knumh AND
          datab IN s_datab AND
          datbi IN s_datbi.
  ENDIF.
  IF sy-subrc %LT%GT 0.
*----- Sy subrc not required
  ENDIF.
ENDFORM.                    " get_konh

*&---------------------------------------------------------------------
*&      Form  get_billing_data
*&---------------------------------------------------------------------
* subroutine to retrive the Billling data as per the selection screen
*----------------------------------------------------------------------

FORM get_billing_data CHANGING fp_i_vbrk_vbrp TYPE t_ty_vbrk_vbrp.

  SELECT    a~vbeln    "  Billing Document
            a~fkart    "  Billing Type
            a~fktyp    "  Billing category
            a~vbtyp    "  SD document category
            a~waerk    "  Currency
            a~vkorg    "  Sales Organization
            a~vtweg    "  Distribution channel
            a~kalsm    "  Sales and Distribution: Pricing Procedure
            a~knumv    "  Number of the document condition
            a~fkdat    "  Billing date for billing index and printout
            a~konda    "  Price group (customer)
            a~inco1    "  Incoterms (part 1)
            a~rfbsk    "  Status for transfer to accounting
            a~zterm    "  Terms of payment key
            a~taxk1    "  Tax classification 1 for customer
            a~netwr    "  Net value in document currency
            a~ernam    "  Name of Person who Created the Object
            a~erzet    "  Entry time
            a~erdat    "  Date on which the record was created
            a~kunrg    "  Payer
            a~kunag    "  Sold-to party
            a~spart    "  Division
            a~xblnr    "  Reference Document Number
            a~fksto    "  Billing document is cancelled

            b~posnr    "  Billing item
            b~fkimg    "  Actual Invoiced Quantity
            b~vrkme    "  Sales unit
            b~vbelv    "  Originating document
            b~vgbel    "  Document number of the reference document
            b~vgpos    "  Item number of the reference item
            b~aubel    "  Sales Document
            b~aupos    "  Sales Document Item
            b~matnr    "  Material Number
            b~prodh    "  Product hierarchy
            b~werks    "  plant
            b~sktof    "  Cash discount indicator
            b~vkgrp    "  Sales group
            b~vkbur    "  sales office
            b~mvgr1    "  Material group 1
            b~mvgr4    "  Material group 4
            b~abrvw    "  Usage indicator
            b~mwsbp      "  Tax amount in document currency
            b~augru_auft

        INTO TABLE fp_i_vbrk_vbrp
        FROM vbrk AS a INNER JOIN vbrp AS b ON
        a~vbeln = b~vbeln
        WHERE a~vbeln IN s_vbelnb AND
              a~fkart IN s_fkart AND
              a~erdat IN s_erdatb AND
              a~kunrg IN s_kunrg AND
              a~vkorg IN s_vkorg AND
              a~vtweg IN s_vtweg AND
              b~matnr IN s_matnr.
  IF sy-subrc NE 0.
    MESSAGE i056.
*-----no billing order data found
    LEAVE LIST-PROCESSING.
  ENDIF.
ENDFORM.                    " get_billing_data

*&--------------------------------------------------------------------*
*&      Form  get_konv_b
*&--------------------------------------------------------------------*
*       to retrive the billing condition data
*---------------------------------------------------------------------*

FORM get_konv_b USING     fp_i_vbrk_vbrp TYPE t_ty_vbrk_vbrp
               CHANGING   fp_i_konv_b TYPE  t_ty_konv.

  DATA : l_i_vbrk_vbrp_tmp TYPE t_ty_vbrk_vbrp.

  SORT l_i_vbrk_vbrp_tmp BY vbeln posnr.
  l_i_vbrk_vbrp_tmp[] = fp_i_vbrk_vbrp[].
  DELETE ADJACENT DUPLICATES FROM l_i_vbrk_vbrp_tmp
  COMPARING vbeln posnr.
  IF NOT l_i_vbrk_vbrp_tmp IS INITIAL.
    SELECT
    knumv    "  Number of the document condition
    kposn    "  Condition item number
    stunr    "  Step number
    zaehk    "  Condition counter
    kschl    "  Condition type
    kdatu    "  Condition pricing date
    krech    "  Calculation type for condition
    kawrt    "  Condition base value
    kbetr    "  Rate (condition amount or percentage)
    waers    "  Currency
    kkurs    "  Condition exchange rate
    kpein    "  Condition pricing unit
    kmein    "  Condition unit in the document
    kntyp    "  Condition category
    kstat    "  Condition is used for statistics
    knprs    "  Scale Type
    kruek    "  Condition is Relevant for Accrual
    kherk    "  Origin of the condition
    kgrpe    "  Group condition
    kolnr    "  Access sequence - Access number
    knumh    "  Condition record number
    kvsl1   "  Account key
    sakn1    "  G/L Account Number
    mwsk1    "  Tax on sales/purchases code
    kvsl2    "  Account key - accruals / provisions
    kwert    "  Condition value
    ksteu    "  Condition control
    kinak    "  Condition is inactive
    koaid    "  Condition class
    kwert_k  "  Condition base value

    FROM konv INTO TABLE fp_i_konv_b
    FOR ALL ENTRIES IN  l_i_vbrk_vbrp_tmp
    WHERE knumv = l_i_vbrk_vbrp_tmp-knumv AND
            kposn = l_i_vbrk_vbrp_tmp-posnr AND
          kschl IN s_kschl.
  ENDIF.
  IF sy-subrc NE 0.
*-----no billing condition records found
    MESSAGE i059.
  ENDIF.

ENDFORM.                    " GET_KNOV

*&--------------------------------------------------------------------*
*&      Form  get_konh_b
*&--------------------------------------------------------------------*
*   To retrive the billing conditions records as per the valid dates
*---------------------------------------------------------------------*
FORM get_konh_b USING fp_i_konv_b TYPE  t_ty_konv
                CHANGING fp_i_konh_b    TYPE t_ty_konh.

  DATA : l_i_konv_b TYPE  t_ty_konv.
  l_i_konv_b[] = fp_i_konv_b[].
  SORT l_i_konv_b BY knumv.
  DELETE ADJACENT DUPLICATES FROM l_i_konv_b COMPARING knumv.
  IF NOT l_i_konv_b IS INITIAL.
    SELECT
    knumh    "  Condition record number
    datab    "  Valid-From Date
    datbi    "  Valid to Date
    FROM konh INTO TABLE fp_i_konh_b
    FOR ALL ENTRIES IN l_i_konv_b
    WHERE knumh = l_i_konv_b-knumh AND
          datab IN s_datab AND
          datbi IN s_datbi.
  ENDIF.
  IF sy-subrc %LT%GT 0.
*---- NO SY-SUBRC REQUIRED
  ENDIF.
ENDFORM.                    "GET_KONH
*&---------------------------------------------------------------------
*&      Form  get_sales_b
*&---------------------------------------------------------------------
*      To retrive the sale order data of the billing document
*----------------------------------------------------------------------
*  --%GT  p1        fp_i_vbrk_vbrp
*  %LT--  p2        fp_i_vbak_vbap
*----------------------------------------------------------------------
FORM get_sales_b USING fp_i_vbrk_vbrp TYPE t_ty_vbrk_vbrp
                 CHANGING  fp_i_vbak_vbap TYPE t_ty_vbak_vbap.
  DATA : l_i_vbrk_vbrp_tmp TYPE t_ty_vbrk_vbrp.
  l_i_vbrk_vbrp_tmp[] = fp_i_vbrk_vbrp[].
  SORT l_i_vbrk_vbrp_tmp BY aubel.

  IF NOT l_i_vbrk_vbrp_tmp IS INITIAL.

    SELECT   a~vbeln    "  Sales Document number
             a~erdat    "  Date on which the record was created
             a~erzet    "  Entry time
             a~ernam    "  Name of Person who Created the Object
             a~audat    "  Document date
             a~vbtyp    "  SD document category
             a~auart    "  Sales Document Type
             a~augru    "  Order reason
             a~lifsk    "  Delivery block
             a~faksk    "  Billing block in SD document
             a~netwr    "  Net Value of the Sales Order in Document
             a~waerk    "  SD document currency
             a~vkorg    "  Sales Organization
             a~vtweg    "  Distribution Channel
             a~spart    "  Division
             a~vkgrp    "  Sales group
             a~vkbur    "  Sales office
             a~knumv    "  Number of the document condition
             a~kalsm    "  Sales and Distribution: Pricing Procedure
             a~kunnr    "  Sold-to party
             a~taxk1    "  Alternative tax classification

             b~posnr    "  Sales Document Item
             b~matnr    "  Material Number
             b~prodh    "  Product hierarchy
             b~vkaus
             b~kwmeng   "  Cumulative order quantity in sales units
             b~vrkme    "  Sales unit
             b~werks    "  Plant
             b~mvgr1    "  Material group 1
             b~mvgr4    "  Material group 4
             b~mwsbp    "  Tax amount in document currency

         INTO TABLE fp_i_vbak_vbap
         FROM vbak AS a INNER JOIN vbap AS b
         ON a~vbeln = b~vbeln FOR ALL ENTRIES IN fp_i_vbrk_vbrp
         WHERE a~vbeln = fp_i_vbrk_vbrp-aubel AND
               b~posnr = fp_i_vbrk_vbrp-aupos.
  ENDIF.

  IF sy-subrc NE 0.
*-----no sales order data found
    MESSAGE i055.
  ENDIF.
ENDFORM.                    " get_sales_b
*&---------------------------------------------------------------------
*&      Form  get_konv_sc
*&---------------------------------------------------------------------
*      to retrive the order condition data
*----------------------------------------------------------------------
*  --%GT  p1        i_vbak_vbap
*  %LT--  p2        i_konv_b
*----------------------------------------------------------------------
FORM get_konv_sc USING  fp_i_vbak_vbap TYPE t_ty_vbak_vbap
                 CHANGING fp_i_konv  TYPE  t_ty_konv.
  DATA  : l_i_vbak_vbap_tmp TYPE t_ty_vbak_vbap.
  MOVE fp_i_vbak_vbap TO l_i_vbak_vbap_tmp.
  SORT l_i_vbak_vbap_tmp BY vbeln.
  DELETE ADJACENT DUPLICATES FROM l_i_vbak_vbap_tmp COMPARING vbeln.

  IF NOT l_i_vbak_vbap_tmp IS INITIAL.
    SELECT
    knumv    "  Number of the document condition
    kposn    "  Condition item number
    stunr    "  Step number
    zaehk    "  Condition counter
    kschl    "  Condition type
    kdatu    "  Condition pricing date
    krech    "  Calculation type for condition
    kawrt    "  Condition base value
    kbetr    "  Rate (condition amount or percentage)
    waers    "  Currency
    kkurs    "  Condition exchange rate
    kpein    "  Condition pricing unit
    kmein    "  Condition unit in the document
    kntyp    "  Condition category
    kstat    "  Condition is used for statistics
    knprs    "  Scale Type
    kruek    "  Condition is Relevant for Accrual
    kherk    "  Origin of the condition
    kgrpe    "  Group condition
    kolnr    "  Access sequence - Access number
    knumh    "  Condition record number
    kvsl1    "  Account key
    sakn1    "  G/L Account Number
    mwsk1    "  Tax on sales/purchases code
    kvsl2    "  Account key - accruals / provisions
    kwert    "  Condition value
    ksteu    "  Condition control
    kinak    "  Condition is inactive
    koaid    "  Condition class
    kwert_k  "  Condition base value

    FROM konv INTO TABLE fp_i_konv
    FOR ALL ENTRIES IN  l_i_vbak_vbap_tmp
    WHERE knumv = l_i_vbak_vbap_tmp-knumv AND
          kposn = l_i_vbak_vbap_tmp-posnr AND
          kschl IN s_kschl.
  ENDIF.
  IF sy-subrc %LT%GT 0.
*------no sales conditions records found
    MESSAGE i058.
  ENDIF.
ENDFORM.                    " get_konv_sc

*&---------------------------------------------------------------------
*&      Form  get_konh_sc
*&---------------------------------------------------------------------
*   to retrive the order condition records as per the valid dates
*----------------------------------------------------------------------
*  --%GT  p1        fp_i_konv
*  %LT--  p2        fp_i_konh
*----------------------------------------------------------------------
FORM get_konh_sc USING fp_i_konv TYPE t_ty_konv
                 CHANGING fp_i_konh TYPE t_ty_konh.

  DATA : l_i_konv_tmp TYPE t_ty_konv.
  l_i_konv_tmp[] = fp_i_konv[].
  SORT l_i_konv_tmp BY knumv.
  DELETE ADJACENT DUPLICATES FROM l_i_konv_tmp COMPARING knumv.
  IF NOT l_i_konv_tmp IS INITIAL.
    SELECT
    knumh    "  Condition record number
    datab    "  Valid-From Date
    datbi    "  Valid to Date
    FROM konh INTO TABLE fp_i_konh
    FOR ALL ENTRIES IN l_i_konv_tmp
    WHERE knumh = l_i_konv_tmp-knumh AND
          datab IN s_datab AND
          datbi IN s_datbi.
  ENDIF.
  IF sy-subrc %LT%GT 0.
*-----NO SY-SUBRC REQUIRED.
  ENDIF.
ENDFORM.                    " get_konh_sc

*&--------------------------------------------------------------------
*& Form  get_data_or
*&--------------------------------------------------------------------
*       to populate the final internal table for order radio button
*---------------------------------------------------------------------
FORM get_data_or CHANGING fp_i_final TYPE t_ty_final.
*-------sorting the internal tables.
  SORT i_vbak_vbap BY vbeln posnr.
  SORT i_vbup BY vbeln posnr.
  SORT i_tvakt BY auart.
  SORT i_vbuk BY vbeln.
  SORT i_kna1 BY kunnr.
  SORT i_vbak_vbkd BY vbeln.
  SORT i_vbrk_vbrp BY vbeln posnr vbtyp.
  SORT i_kna1_b BY kunnr.
  SORT i_tvfkt BY fkart.
  SORT i_konv_b BY knumv  kposn.
  SORT i_tvfst BY faksp.
  SORT i_tvlst BY lifsp.
  SORT i_makt  BY matnr.
  SORT i_makt_b BY matnr.
  SORT i_tvaut BY augru.
  SORT i_t188t BY konda.
  SORT i_t685t BY kschl.
*----Populating the final internal table
  LOOP AT i_vbfa INTO wa_vbfa.

    wa_final-vbelv = wa_vbfa-vbelv.
    wa_final-vbeln = wa_vbfa-vbeln.

    READ TABLE i_vbak_vbap INTO wa_vbak_vbap WITH KEY
                           vbeln = wa_vbfa-vbelv
                           posnr = wa_vbfa-posnv BINARY SEARCH.

    IF sy-subrc = 0.
      CALL FUNCTION 'CONVERSION_EXIT_AUART_OUTPUT'
        EXPORTING
          input         = wa_vbak_vbap-auart
       IMPORTING
         OUTPUT        = wa_vbak_vbap-auart.

      wa_final-vbelno  = wa_vbak_vbap-vbeln.
      wa_final-erdato  = wa_vbak_vbap-erdat.
      wa_final-erzeto  = wa_vbak_vbap-erzet.
      wa_final-ernamo  = wa_vbak_vbap-ernam.
      wa_final-audato  = wa_vbak_vbap-audat.
      wa_final-vbtypo  = wa_vbak_vbap-vbtyp.
      wa_final-auarto  = wa_vbak_vbap-auart.
      wa_final-augruo  = wa_vbak_vbap-augru.
      wa_final-lifsko  = wa_vbak_vbap-lifsk.
      wa_final-faksko  = wa_vbak_vbap-faksk.
      wa_final-netwro  = wa_vbak_vbap-netwr.
      wa_final-waerko  = wa_vbak_vbap-waerk.
      wa_final-vkorgo  = wa_vbak_vbap-vkorg.
      wa_final-vtwego  = wa_vbak_vbap-vtweg.
      wa_final-sparto  = wa_vbak_vbap-spart.
      wa_final-vkgrpo  = wa_vbak_vbap-vkgrp.
      wa_final-vkburo  = wa_vbak_vbap-vkbur.
      wa_final-kalsmo  = wa_vbak_vbap-kalsm.
      wa_final-kunnro  = wa_vbak_vbap-kunnr.
      wa_final-taxk1o  = wa_vbak_vbap-taxk1.
      wa_final-posnro  = wa_vbak_vbap-posnr.
      wa_final-matnro  = wa_vbak_vbap-matnr.
      wa_final-prodho  = wa_vbak_vbap-prodh.
      wa_final-kwmengo = wa_vbak_vbap-kwmeng.
      wa_final-vrkmeo  = wa_vbak_vbap-vrkme.
      wa_final-werkso  = wa_vbak_vbap-werks.
      wa_final-mvgr1o  = wa_vbak_vbap-mvgr1.
      wa_final-mvgr4o  = wa_vbak_vbap-mvgr4.
      wa_final-mwsbpo  = wa_vbak_vbap-mwsbp.
*      wa_final-yy_psp_pnro = wa_vbak_vbap-yy_psp_pnr.
      wa_final-waerk_tax = wa_vbak_vbap-waerk.
    ENDIF.

    READ TABLE i_tvfst INTO wa_tvfst
           WITH KEY faksp = wa_vbak_vbap-faksk BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-faksp = wa_tvfst-faksp.
    ENDIF.
    READ TABLE i_tvlst INTO wa_tvlst
           WITH KEY lifsp = wa_vbak_vbap-lifsk BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-lifsp = wa_tvlst-lifsp.
    ENDIF.
*-----to get the sales material description
    READ TABLE i_makt INTO wa_makt
           WITH KEY matnr = wa_vbak_vbap-matnr BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-maktxo = wa_makt-maktx.
    ENDIF.

*-----to get the sales doc overall status

    READ TABLE i_vbup INTO wa_vbup WITH KEY
          vbeln = wa_vbak_vbap-vbeln
          posnr = wa_vbak_vbap-posnr BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-gbsta = wa_vbup-gbsta.
    ENDIF.
*------to get the order type description

CALL FUNCTION 'CONVERSION_EXIT_AUART_INPUT'
  EXPORTING
    input         = wa_vbak_vbap-auart
 IMPORTING
   OUTPUT        = wa_vbak_vbap-auart.



    READ TABLE i_tvakt INTO wa_tvakt WITH KEY
          auart = wa_vbak_vbap-auart BINARY SEARCH.
*         auart = wa_final-auarto BINARY SEARCH.

    IF sy-subrc = 0.
      wa_final-bezei = wa_tvakt-bezei.
    ENDIF.
*---to get the billing status of the document

    READ TABLE i_vbuk INTO wa_vbuk WITH KEY
           vbeln = wa_vbak_vbap-vbeln BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-fkstk = wa_vbuk-fkstk.
    ENDIF.
*-----to get the name of the sold-to-party

    READ TABLE i_kna1 INTO wa_kna1 WITH KEY
           kunnr = wa_vbak_vbap-kunnr BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-name1o = wa_kna1-name1.
    ENDIF.
*----to get the business data

    READ TABLE i_vbak_vbkd INTO wa_vbkd WITH KEY
            vbeln = wa_vbak_vbap-vbeln BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-konda_v  = wa_vbkd-konda.
      wa_final-inco1_v  = wa_vbkd-inco1.
      wa_final-valtg_v  = wa_vbkd-valtg.
      wa_final-valdt_v  = wa_vbkd-valdt.
      wa_final-zterm_v  = wa_vbkd-zterm.
      wa_final-prsdt_v  = wa_vbkd-prsdt.
      wa_final-fkdat_v  = wa_vbkd-fkdat.
      wa_final-bstkd_v  = wa_vbkd-bstkd.
      wa_final-bsark_v  = wa_vbkd-bsark.
    ENDIF.

*----to get the order price group description

    READ TABLE i_t188t_o INTO wa_t188t_o WITH KEY
                   konda = wa_vbkd-konda BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-vtext_kondao = wa_t188t-vtext.
      CLEAR wa_vbkd-konda.
    ENDIF.

*--to retrive the condition type description
    READ TABLE i_t685t INTO wa_t685t WITH KEY
                          kschl = wa_konv-kschl.
    IF sy-subrc = 0.
      wa_final-vtext_kschl = wa_t685t-vtext.
    ENDIF.

*---to retrive the billing details of sales order
    READ TABLE i_vbrk_vbrp INTO wa_vbrk_vbrp WITH KEY
                        vbeln = wa_vbfa-vbeln
                        posnr = wa_vbfa-posnv
                        vbtyp = wa_vbfa-vbtyp_n BINARY SEARCH.

    IF sy-subrc = 0.
      wa_final-vbelnb  = wa_vbrk_vbrp-vbeln.
      wa_final-fkartb  = wa_vbrk_vbrp-fkart.
      wa_final-fktypb  = wa_vbrk_vbrp-fktyp.
      wa_final-waerkb  = wa_vbrk_vbrp-waerk.
      wa_final-vkorgb  = wa_vbrk_vbrp-vkorg.
      wa_final-vtwegb  = wa_vbrk_vbrp-vtweg.
      wa_final-kalsmb  = wa_vbrk_vbrp-kalsm.
      wa_final-fkdatb  = wa_vbrk_vbrp-fkdat.
      wa_final-kondab  = wa_vbrk_vbrp-konda.
      wa_final-inco1b  = wa_vbrk_vbrp-inco1.
      wa_final-rfbskb  = wa_vbrk_vbrp-rfbsk.
      wa_final-ztermb  = wa_vbrk_vbrp-zterm.
      wa_final-taxk1b  = wa_vbrk_vbrp-taxk1.
      wa_final-netwrb  = wa_vbrk_vbrp-netwr.
      wa_final-ernamb  = wa_vbrk_vbrp-ernam.
      wa_final-erzetb  = wa_vbrk_vbrp-erzet.
      wa_final-erdatb  = wa_vbrk_vbrp-erdat.
      wa_final-kunrg   = wa_vbrk_vbrp-kunrg.
      wa_final-spartb  = wa_vbrk_vbrp-spart.
      wa_final-xblnrb  = wa_vbrk_vbrp-xblnr.
      wa_final-fkstob  = wa_vbrk_vbrp-fksto.
      wa_final-posnrb  = wa_vbrk_vbrp-posnr.
      wa_final-fkimgb  = wa_vbrk_vbrp-fkimg.
      wa_final-vrkmeb  = wa_vbrk_vbrp-vrkme.
      wa_final-matnrb  = wa_vbrk_vbrp-matnr.
      wa_final-prodhb  = wa_vbrk_vbrp-prodh.
      wa_final-werksb  = wa_vbrk_vbrp-werks.
      wa_final-sktofb  = wa_vbrk_vbrp-sktof.
      wa_final-mvgr1b  = wa_vbrk_vbrp-mvgr1.
      wa_final-abrvwb  = wa_vbrk_vbrp-abrvw.
      wa_final-mwsbpb  = wa_vbrk_vbrp-mwsbp.
      wa_final-augru_auftb = wa_vbrk_vbrp-augru_auft.
*      wa_final-yy_psp_pnrb = wa_vbrk_vbrp-yy_psp_pnr.
      wa_final-waerkb_tax = wa_vbrk_vbrp-waerk.

    ENDIF.

*------to get the billing item order reason description
    READ TABLE i_tvaut INTO wa_tvaut WITH KEY
              augru = wa_vbrk_vbrp-augru_auft BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-bezei_augru = wa_tvaut-bezei.
      CLEAR wa_vbrk_vbrp-augru_auft.

    ENDIF.

*----to get the billing price group description

    READ TABLE i_t188t INTO wa_t188t WITH KEY
                   konda = wa_vbrk_vbrp-konda BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-vtext_konda = wa_t188t-vtext.
      CLEAR wa_vbrk_vbrp-konda.
    ENDIF.

*---------to get the material description

    READ TABLE i_makt_b INTO wa_makt_b
         WITH KEY matnr = wa_vbrk_vbrp-matnr BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-maktxb = wa_makt_b-maktx.
      CLEAR wa_makt_b.
      CLEAR wa_vbrk_vbrp-matnr.
    ENDIF.

*-----to get the name of the payer

    READ TABLE i_kna1_b INTO wa_kna1_b WITH KEY
                   kunnr = wa_vbrk_vbrp-kunrg BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-name1b = wa_kna1_b-name1.
      CLEAR wa_vbrk_vbrp-kunrg.
    ENDIF.
*---to get the biling doc type description

    READ TABLE i_tvfkt INTO wa_tvfkt WITH KEY
                     fkart = wa_vbrk_vbrp-fkart BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-vtext = wa_tvfkt-vtext.
      CLEAR  wa_vbrk_vbrp-fkart.
    ENDIF.
*-----to get the billing condition records

    READ TABLE i_konv_b INTO wa_konv_b WITH KEY
                    knumv = wa_vbrk_vbrp-knumv
                    kposn = wa_vbrk_vbrp-posnr BINARY SEARCH.
    IF sy-subrc EQ 0.
      wa_final-kposnb  = wa_konv_b-kposn.
      wa_final-stunrb  = wa_konv_b-stunr.
      wa_final-zaehkb  = wa_konv_b-zaehk.
      wa_final-kschlb  = wa_konv_b-kschl.
      wa_final-kdatub  = wa_konv_b-kdatu.
      wa_final-krechb  = wa_konv_b-krech.
      wa_final-kawrtb  = wa_konv_b-kawrt / 10.
      wa_final-kbetrb  = wa_konv_b-kbetr.
      wa_final-waersb  = wa_konv_b-waers.
      wa_final-kkursb  = wa_konv_b-kkurs.
      wa_final-kpeinb  = wa_konv_b-kpein.
      wa_final-kmeinb  = wa_konv_b-kmein.
      wa_final-kntypb  = wa_konv_b-kntyp.
      wa_final-kstatb  = wa_konv_b-kstat.
      wa_final-knprsb  = wa_konv_b-knprs.
      wa_final-kruekb  = wa_konv_b-kruek.
      wa_final-kherkb  = wa_konv_b-kherk.
      wa_final-kgrpeb  = wa_konv_b-kgrpe.
      wa_final-kolnrb  = wa_konv_b-kolnr.
      wa_final-kvsl1b  = wa_konv_b-kvsl1.
      wa_final-sakn1b  = wa_konv_b-sakn1.
      wa_final-mwsk1b  = wa_konv_b-mwsk1.
      wa_final-kvsl2b  = wa_konv_b-kvsl2.
      wa_final-kwertb  = wa_konv_b-kwert.
      wa_final-ksteub  = wa_konv_b-ksteu.
      wa_final-kinakb  = wa_konv_b-kinak.
      wa_final-koaidb  = wa_konv_b-koaid.
      wa_final-kwert_kb  = wa_konv_b-kwert.
      CLEAR  wa_vbrk_vbrp-knumv.
    ENDIF.

    READ TABLE i_t685t_b INTO wa_t685t_b WITH KEY
                          kschl = wa_konv_b-kschl.
    IF sy-subrc = 0.
      wa_final-vtext_kschlb = wa_t685t_b-vtext.
      CLEAR wa_konv_b-kschl.
    ENDIF.

    LOOP AT i_konv INTO wa_konv  WHERE
                 knumv = wa_vbak_vbap-knumv AND
                 kposn = wa_vbak_vbap-posnr.

      wa_final-kposn  = wa_konv-kposn.
      wa_final-stunr  = wa_konv-stunr.
      wa_final-zaehk  = wa_konv-zaehk.
      wa_final-kschl  = wa_konv-kschl.
      wa_final-kdatu  = wa_konv-kdatu.
      wa_final-krech  = wa_konv-krech.
      wa_final-kawrt  = wa_konv-kawrt / 10.
      wa_final-kbetr  = wa_konv-kbetr.
      wa_final-waers  = wa_konv-waers.
      wa_final-kkurs  = wa_konv-kkurs.
      wa_final-kpein  = wa_konv-kpein.
      wa_final-kmein  = wa_konv-kmein.
      wa_final-kntyp  = wa_konv-kntyp.
      wa_final-kstat  = wa_konv-kstat.
      wa_final-knprs  = wa_konv-knprs.
      wa_final-kruek  = wa_konv-kruek.
      wa_final-kherk  = wa_konv-kherk.
      wa_final-kgrpe  = wa_konv-kgrpe.
      wa_final-kolnr  = wa_konv-kolnr.
      wa_final-kvsl1  = wa_konv-kvsl1.
      wa_final-sakn1  = wa_konv-sakn1.
      wa_final-mwsk1  = wa_konv-mwsk1.
      wa_final-kvsl2  = wa_konv-kvsl2.
      wa_final-kwert  = wa_konv-kwert.
      wa_final-ksteu  = wa_konv-ksteu.
      wa_final-kinak  = wa_konv-kinak.
      wa_final-koaid  = wa_konv-koaid.
      wa_final-kwert_k = wa_konv-kwert.
      READ TABLE i_t685t INTO wa_t685t WITH KEY
                              kschl = wa_konv-kschl.
      IF sy-subrc = 0.
        wa_final-vtext_kschl = wa_t685t-vtext.
      ENDIF.
      APPEND wa_final TO fp_i_final.

    ENDLOOP.
    IF wa_konv-knumv NE wa_vbak_vbap-knumv AND
       wa_konv-kposn NE wa_vbak_vbap-posnr.
      APPEND wa_final TO fp_i_final.
    ENDIF.
    CLEAR wa_final.
  ENDLOOP.
ENDFORM.                    "get_output



*&--------------------------------------------------------------------
*&  Form get_data_bl
*&--------------------------------------------------------------------
*    to populate the final internal table for the billing radio button
*---------------------------------------------------------------------
FORM get_data_bl CHANGING fp_i_final TYPE t_ty_final.
*-----sorting the internal tables.
      SORT i_kna1_b BY kunnr.
      SORT i_tvfkt BY fkart.
      SORT i_konv BY knumv kposn.
      SORT i_vbak_vbap BY vbeln posnr.
      SORT i_vbup BY vbeln posnr.
      SORT i_kna1 BY kunnr.
      SORT i_vbuk BY vbeln.
      SORT i_tvakt BY auart.
      SORT i_vbak_vbkd BY vbeln.
      SORT i_tvfst BY faksp.
      SORT i_tvlst BY lifsp.
      SORT i_makt  BY matnr.
      SORT i_makt_b BY matnr.
      SORT i_vbfa BY vbelv vbeln.
*----populating the internal table for billing radio button
  LOOP AT i_vbrk_vbrp INTO wa_vbrk_vbrp.
    wa_final-vbelnb  = wa_vbrk_vbrp-vbeln.
    wa_final-fkartb  = wa_vbrk_vbrp-fkart.
    wa_final-fktypb  = wa_vbrk_vbrp-fktyp.
    wa_final-waerkb  = wa_vbrk_vbrp-waerk.
    wa_final-vkorgb  = wa_vbrk_vbrp-vkorg.
    wa_final-vtwegb  = wa_vbrk_vbrp-vtweg.
    wa_final-kalsmb  = wa_vbrk_vbrp-kalsm.
    wa_final-fkdatb  = wa_vbrk_vbrp-fkdat.
    wa_final-kondab  = wa_vbrk_vbrp-konda.
    wa_final-inco1b  = wa_vbrk_vbrp-inco1.
    wa_final-rfbskb  = wa_vbrk_vbrp-rfbsk.
    wa_final-ztermb  = wa_vbrk_vbrp-zterm.
    wa_final-taxk1b  = wa_vbrk_vbrp-taxk1.
    wa_final-netwrb  = wa_vbrk_vbrp-netwr.
    wa_final-ernamb  = wa_vbrk_vbrp-ernam.
    wa_final-erzetb  = wa_vbrk_vbrp-erzet.
    wa_final-erdatb  = wa_vbrk_vbrp-erdat.
    wa_final-kunrg   = wa_vbrk_vbrp-kunrg.
    wa_final-spartb  = wa_vbrk_vbrp-spart.
    wa_final-xblnrb  = wa_vbrk_vbrp-xblnr.
    wa_final-fkstob  = wa_vbrk_vbrp-fksto.
    wa_final-posnrb  = wa_vbrk_vbrp-posnr.
    wa_final-fkimgb  = wa_vbrk_vbrp-fkimg.
    wa_final-vrkmeb  = wa_vbrk_vbrp-vrkme.
    wa_final-matnrb  = wa_vbrk_vbrp-matnr.
    wa_final-prodhb  = wa_vbrk_vbrp-prodh.
    wa_final-werksb  = wa_vbrk_vbrp-werks.
    wa_final-vkgrpb  = wa_vbrk_vbrp-vkgrp.
    wa_final-vkburb  = wa_vbrk_vbrp-vkbur.
    wa_final-sktofb  = wa_vbrk_vbrp-sktof.
    wa_final-mvgr1b  = wa_vbrk_vbrp-mvgr1.
    wa_final-mvgr4b  = wa_vbrk_vbrp-mvgr4.
    wa_final-abrvwb  = wa_vbrk_vbrp-abrvw.
    wa_final-mwsbpb  = wa_vbrk_vbrp-mwsbp.
    wa_final-augru_auftb = wa_vbrk_vbrp-augru_auft.
*    wa_final-yy_psp_pnrb = wa_vbrk_vbrp-yy_psp_pnr.
    wa_final-waerkb_tax = wa_vbrk_vbrp-waerk.

*----to get the billing status of the document
     READ TABLE i_makt_b INTO wa_makt_b
          WITH KEY matnr = wa_vbrk_vbrp-matnr BINARY SEARCH.
    IF sy-subrc = 0.
       wa_final-maktxb = wa_makt_b-maktx.
    ENDIF.
*------to get the billing item order reason description
    READ TABLE i_tvaut INTO wa_tvaut WITH KEY
               augru = wa_vbrk_vbrp-augru_auft.
    IF sy-subrc = 0.
      wa_final-bezei_augru = wa_tvaut-bezei.
    ENDIF.
*----to get the billing price group description
    READ TABLE i_t188t INTO wa_t188t WITH KEY
                     konda = wa_vbrk_vbrp-konda.
    IF sy-subrc = 0.
       wa_final-vtext_konda = wa_t188t-vtext.
    ENDIF.
*-------
    READ TABLE i_vbuk INTO wa_vbuk WITH KEY
                     vbeln = wa_vbrk_vbrp-vbeln BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-fkstk = wa_vbuk-fkstk.
    ENDIF.
*-----to get the name of the payer

    READ TABLE i_kna1_b INTO wa_kna1_b WITH KEY
                    kunnr = wa_vbrk_vbrp-kunrg BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-name1b = wa_kna1_b-name1.
    ENDIF.
*-----to get the billing doc type description
    READ TABLE i_tvfkt INTO wa_tvfkt WITH KEY
                   fkart = wa_vbrk_vbrp-fkart BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-vtext = wa_tvfkt-vtext.
    ENDIF.
*---to get the sales documnet details of the billing doc
    READ  TABLE i_vbak_vbap INTO wa_vbak_vbap WITH KEY
                 vbeln = wa_vbrk_vbrp-aubel
                 posnr = wa_vbrk_vbrp-aupos BINARY SEARCH.

    IF sy-subrc = 0.

    CALL FUNCTION 'CONVERSION_EXIT_AUART_OUTPUT'
        EXPORTING
          input         = wa_vbak_vbap-auart
       IMPORTING
         OUTPUT        = wa_vbak_vbap-auart.


       wa_final-vbelno  = wa_vbak_vbap-vbeln.
       wa_final-erdato  = wa_vbak_vbap-erdat.
       wa_final-erzeto  = wa_vbak_vbap-erzet.
       wa_final-ernamo  = wa_vbak_vbap-ernam.
       wa_final-audato  = wa_vbak_vbap-audat.
       wa_final-vbtypo  = wa_vbak_vbap-vbtyp.
       wa_final-auarto  = wa_vbak_vbap-auart.
       wa_final-augruo  = wa_vbak_vbap-augru.
       wa_final-lifsko  = wa_vbak_vbap-lifsk.
       wa_final-faksko  = wa_vbak_vbap-faksk.
       wa_final-netwro  = wa_vbak_vbap-netwr.
       wa_final-waerko  = wa_vbak_vbap-waerk.
       wa_final-vkorgo  = wa_vbak_vbap-vkorg.
       wa_final-vtwego  = wa_vbak_vbap-vtweg.
       wa_final-vkgrpo  = wa_vbak_vbap-vkgrp.
       wa_final-vkburo  = wa_vbak_vbap-vkbur.
       wa_final-kalsmo  = wa_vbak_vbap-kalsm.
       wa_final-kunnro  = wa_vbak_vbap-kunnr.
       wa_final-taxk1o  = wa_vbak_vbap-taxk1.
       wa_final-posnro  = wa_vbak_vbap-posnr.
       wa_final-matnro  = wa_vbak_vbap-matnr.
       wa_final-prodho  = wa_vbak_vbap-prodh.
       wa_final-kwmengo = wa_vbak_vbap-kwmeng.
       wa_final-vrkmeo  = wa_vbak_vbap-vrkme.
       wa_final-werkso  = wa_vbak_vbap-werks.
       wa_final-mvgr1o  = wa_vbak_vbap-mvgr1.
       wa_final-mvgr4o  = wa_vbak_vbap-mvgr4.
*       wa_final-yy_psp_pnro = wa_vbak_vbap-yy_psp_pnr.
       wa_final-waerk_tax = wa_vbak_vbap-waerk.

    ENDIF.

    READ TABLE i_t685t INTO wa_t685t WITH KEY
                 kschl = wa_konv-kschl BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-vtext_kschl = wa_t685t-vtext.
      CLEAR wa_konv-kschl.
    ENDIF.

    READ TABLE i_tvfst INTO wa_tvfst
           WITH KEY faksp = wa_vbak_vbap-faksk BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-faksp = wa_tvfst-faksp.
      CLEAR wa_vbak_vbap-faksk.
    ENDIF.
    READ TABLE i_tvlst INTO wa_tvlst
           WITH KEY lifsp = wa_vbak_vbap-lifsk BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-lifsp = wa_tvlst-lifsp.
      CLEAR wa_vbak_vbap-lifsk.
    ENDIF.
    READ TABLE i_makt INTO wa_makt
           WITH KEY matnr = wa_vbak_vbap-matnr BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-maktxo = wa_makt-maktx.
      CLEAR wa_vbak_vbap-matnr.
    ENDIF.

*---to get the sales doc.overall status

    READ TABLE i_vbup INTO wa_vbup WITH KEY
          vbeln = wa_vbak_vbap-vbeln
          posnr = wa_vbak_vbap-posnr BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-gbsta = wa_vbup-gbsta.
    ENDIF.
*----to get the sold-to-party name

    READ TABLE i_kna1 INTO wa_kna1 WITH KEY
          kunnr = wa_vbak_vbap-kunnr BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-name1o = wa_kna1-name1.
      CLEAR wa_vbak_vbap-kunnr.
    ENDIF.
*---to get the billing status

    READ TABLE i_vbuk INTO wa_vbuk WITH KEY
          vbeln = wa_vbak_vbap-vbeln BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-fkstk = wa_vbuk-fkstk.
*      CLEAR wa_vbak_vbap-vbeln.
    ENDIF.
*------to get the sales doc. type description

    READ TABLE i_tvakt INTO wa_tvakt WITH KEY
          auart = wa_vbak_vbap-auart BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-bezei = wa_tvakt-bezei.
      CLEAR wa_vbak_vbap-auart.
    ENDIF.
*---to get the business data

    READ TABLE i_vbak_vbkd INTO wa_vbkd WITH KEY
          vbeln = wa_vbak_vbap-vbeln BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-konda_v  = wa_vbkd-konda.
      wa_final-inco1_v  = wa_vbkd-inco1.
      wa_final-valtg_v  = wa_vbkd-valtg.
      wa_final-valdt_v  = wa_vbkd-valdt.
      wa_final-zterm_v  = wa_vbkd-zterm.
      wa_final-prsdt_v  = wa_vbkd-prsdt.
      wa_final-fkdat_v  = wa_vbkd-fkdat.
      wa_final-bstkd_v  = wa_vbkd-bstkd.
      wa_final-bsark_v  = wa_vbkd-bsark.
    ENDIF.


    READ TABLE i_t188t_o INTO wa_t188t_o WITH KEY
                   konda = wa_vbkd-konda BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-vtext_kondao = wa_t188t-vtext.
      CLEAR wa_vbkd-konda.
    ENDIF.

*---to get the sales condition records

    READ TABLE i_konv INTO wa_konv WITH KEY
               knumv = wa_vbak_vbap-knumv
               kposn = wa_vbak_vbap-posnr BINARY SEARCH.

    IF sy-subrc = 0.
      wa_final-kposn  = wa_konv-kposn.
      wa_final-stunr  = wa_konv-stunr.
      wa_final-zaehk  = wa_konv-zaehk.
      wa_final-kschl  = wa_konv-kschl.
      wa_final-kdatu  = wa_konv-kdatu.
      wa_final-krech  = wa_konv-krech.
      wa_final-kawrt  = wa_konv-kawrt / 10 .
      wa_final-kbetr  = wa_konv-kbetr.
      wa_final-waers  = wa_konv-waers.
      wa_final-kkurs  = wa_konv-kkurs.
      wa_final-kpein  = wa_konv-kpein.
      wa_final-kmein  = wa_konv-kmein.
      wa_final-kntyp  = wa_konv-kntyp.
      wa_final-kstat  = wa_konv-kstat.
      wa_final-knprs  = wa_konv-knprs.
      wa_final-kruek  = wa_konv-kruek.
      wa_final-kherk  = wa_konv-kherk.
      wa_final-kgrpe  = wa_konv-kgrpe.
      wa_final-kolnr  = wa_konv-kolnr.
      wa_final-kvsl1  = wa_konv-kvsl1.
      wa_final-sakn1  = wa_konv-sakn1.
      wa_final-mwsk1  = wa_konv-mwsk1.
      wa_final-kvsl2  = wa_konv-kvsl2.
      wa_final-kwert  = wa_konv-kwert.
      wa_final-ksteu  = wa_konv-ksteu.
      wa_final-kinak  = wa_konv-kinak.
      wa_final-koaid  = wa_konv-koaid.
      wa_final-kwert_k = wa_konv-kwert.
    ENDIF.
    READ TABLE i_t685t INTO wa_t685t WITH KEY
               kschl = wa_konv-kschl BINARY SEARCH.
    IF sy-subrc = 0.
      wa_final-vtext_kschl = wa_t685t-vtext.
      CLEAR wa_konv-kschl.
    ENDIF.


    LOOP AT i_konv_b INTO wa_konv_b WHERE
                 knumv = wa_vbrk_vbrp-knumv AND
                 kposn = wa_vbrk_vbrp-posnr.

      wa_final-kposnb  = wa_konv_b-kposn.
      wa_final-stunrb  = wa_konv_b-stunr.
      wa_final-zaehkb  = wa_konv_b-zaehk.
      wa_final-kschlb  = wa_konv_b-kschl.
      wa_final-kdatub  = wa_konv_b-kdatu.
      wa_final-krechb  = wa_konv_b-krech.
      wa_final-kawrtb  = wa_konv_b-kawrt / 10.
      wa_final-kbetrb  = wa_konv_b-kbetr.
      wa_final-waersb  = wa_konv_b-waers.
      wa_final-kkursb  = wa_konv_b-kkurs.
      wa_final-kpeinb  = wa_konv_b-kpein.
      wa_final-kmeinb  = wa_konv_b-kmein.
      wa_final-kntypb  = wa_konv_b-kntyp.
      wa_final-kstatb  = wa_konv_b-kstat.
      wa_final-knprsb  = wa_konv_b-knprs.
      wa_final-kruekb  = wa_konv_b-kruek.
      wa_final-kherkb  = wa_konv_b-kherk.
      wa_final-kgrpeb  = wa_konv_b-kgrpe.
      wa_final-kolnrb  = wa_konv_b-kolnr.
      wa_final-kvsl1b  = wa_konv_b-kvsl1.
      wa_final-sakn1b  = wa_konv_b-sakn1.
      wa_final-mwsk1b  = wa_konv_b-mwsk1.
      wa_final-kvsl2b  = wa_konv_b-kvsl2.
      wa_final-kwertb  = wa_konv_b-kwert.
      wa_final-ksteub  = wa_konv_b-ksteu.
      wa_final-kinakb  = wa_konv_b-kinak.
      wa_final-koaidb  = wa_konv_b-koaid.
      wa_final-kwert_kb  = wa_konv_b-kwert.

      READ TABLE i_t685t_b INTO wa_t685t_b WITH KEY
                            kschl = wa_konv_b-kschl.
      IF sy-subrc = 0.
        wa_final-vtext_kschlb = wa_t685t_b-vtext.
      ENDIF.
      APPEND wa_final TO fp_i_final.
    ENDLOOP.
    IF wa_konv_b-knumv NE wa_vbrk_vbrp-knumv AND
       wa_konv_b-kposn NE wa_vbrk_vbrp-posnr.
      APPEND wa_final TO fp_i_final.
    ENDIF.
    CLEAR wa_final.
  ENDLOOP.
ENDFORM.                    "billing_data


*&--------------------------------------------------------------------
*&      Form  INITIALIZE_FIELDCAT
*&--------------------------------------------------------------------
*       initializing the field catalog
*---------------------------------------------------------------------
FORM initialize_fieldcat CHANGING fp_fieldtab
                                    TYPE slis_t_fieldcat_alv.

  DATA: l_fieldcat TYPE slis_fieldcat_alv.

  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_vbelno.
  l_fieldcat-seltext_l  = text-001.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-REF_TABNAME   = 'VBAK'.
  l_fieldcat-REF_FIELDNAME = 'VBELN'.
  l_fieldcat-Ddictxt = 'L'.
*  l_fieldcat-DDIC_OUTPUTLEN   = '10'.
*  l_fieldcat-LOWERCASE = 'X'.
*  l_fieldcat-NO_ZERO = 'X'.
  l_fieldcat-outputlen  = 21.
  l_fieldcat-hotspot    = c_yes.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*---Order Documnet type

  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_auarto.
  l_fieldcat-seltext_l  = text-002.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-DDIC_OUTPUTLEN   = '4'.
  l_fieldcat-LOWERCASE = 'X'.
  l_fieldcat-outputlen  = 19.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*---order document description
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_bezei.
  l_fieldcat-seltext_l = text-003.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-DDIC_OUTPUTLEN   = '25'.
  l_fieldcat-LOWERCASE = 'X'.
  l_fieldcat-outputlen     = 29.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*----order documnet created on
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_audato.
  l_fieldcat-seltext_l = text-004.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-outputlen     = 19.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----order document status
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_gbsta.
  l_fieldcat-seltext_l = text-032.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-DDIC_OUTPUTLEN   = '1'.
  l_fieldcat-LOWERCASE = 'X'.
  l_fieldcat-outputlen     = 29.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*----order sold to party
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_kunnro.
  l_fieldcat-seltext_l = text-005.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-REF_TABNAME   = 'KNA1'.
  l_fieldcat-REF_FIELDNAME = 'KUNNR'.
  l_fieldcat-Ddictxt = 'L'.
  l_fieldcat-outputlen     = 26.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----order sold to party name
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_name1o.
  l_fieldcat-seltext_l = text-006.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-DDIC_OUTPUTLEN   = '30'.
  l_fieldcat-LOWERCASE = 'X'.
  l_fieldcat-outputlen     = 18.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----order purchase order number
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_bstkd_v.
  l_fieldcat-seltext_l = text-007.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-DDIC_OUTPUTLEN   = '35'.
  l_fieldcat-LOWERCASE = 'X'.
  l_fieldcat-outputlen     = 27.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*----order reason
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_augruo.
  l_fieldcat-seltext_l = text-008.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-DDIC_OUTPUTLEN   = '3'.
  l_fieldcat-LOWERCASE = 'X'.
  l_fieldcat-outputlen     = 12.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----order pricing date
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_prsdt_v.
  l_fieldcat-seltext_l = text-009.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-outputlen     = 18.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*------order document net value
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_netwro.
  l_fieldcat-seltext_l = text-010.
  l_fieldcat-no_out     = c_space.
* l_fieldcat-col_pos    = 11.
  l_fieldcat-outputlen     = 15.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*------order currency
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_waerko.
  l_fieldcat-seltext_l = text-011.
  l_fieldcat-no_out     = c_space.
*  l_fieldcat-col_pos    = 12.
  l_fieldcat-outputlen     = 14.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-------order tax amount
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_mwsbpo.
  l_fieldcat-seltext_l = text-012.
  l_fieldcat-no_out     = c_space.
*  l_fieldcat-col_pos    = 13.
  l_fieldcat-outputlen     = 16.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-------order currency
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_waerk_tax.
  l_fieldcat-seltext_l = text-013.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-outputlen     = 14.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-------order fixed value date
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_valdt_v.
  l_fieldcat-seltext_l = text-014.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-outputlen     = 22.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----order additional value days
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_valtg_v.
  l_fieldcat-seltext_l = text-015.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-outputlen     = 27.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*------order payment terms
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_zterm_v.
  l_fieldcat-seltext_l = text-016.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-outputlen     = 19.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.


*-------Billing document number
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_vbelnb.
  l_fieldcat-seltext_l = text-017.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-REF_TABNAME   = 'VBUK'.
  l_fieldcat-REF_FIELDNAME = 'VBELN'.
  l_fieldcat-Ddictxt = 'L'.
  l_fieldcat-hotspot    = c_yes.
  l_fieldcat-outputlen     = 23.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*--------billing document type
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_fkartb.
  l_fieldcat-seltext_l = text-018.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-outputlen     = 21.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-------billing document type description
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_vtext.
  l_fieldcat-seltext_l = text-019.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-DDIC_OUTPUTLEN   = '20'.
  l_fieldcat-LOWERCASE = 'X'.
  l_fieldcat-outputlen     = 33.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*------billing document date
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_fkdatb.
  l_fieldcat-seltext_l = text-020.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-outputlen     = 21.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*------Billing document status
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_fkstk.
  l_fieldcat-seltext_l = text-021.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-outputlen     = 14.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----billing document cancelled
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_fkstob.
  l_fieldcat-seltext_l = text-022.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-outputlen     = 26.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----billing payer number
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_kunrg.
  l_fieldcat-seltext_l = text-023.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-REF_TABNAME   = 'KNA1'.
  l_fieldcat-REF_FIELDNAME = 'KUNNR'.
  l_fieldcat-Ddictxt = 'L'.
  l_fieldcat-outputlen     = 20.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*------billing payer name
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_name1b.
  l_fieldcat-seltext_l = text-024.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-DDIC_OUTPUTLEN   = '30'.
  l_fieldcat-LOWERCASE = 'X'.
  l_fieldcat-outputlen     = 19.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*------billing documnet net value
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_netwrb.
  l_fieldcat-seltext_l = text-025.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-outputlen     = 26.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*------billing currency
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_waerkb.
  l_fieldcat-seltext_l = text-026.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-outputlen     = 16.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----billing tax amount
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_mwsbpb.
  l_fieldcat-seltext_l = text-027.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-outputlen     = 18.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*------billing currency
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_waerkb_tax.
  l_fieldcat-seltext_l = text-028.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-outputlen     = 16.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*------billing document posting status
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_rfbskb.
  l_fieldcat-seltext_l = text-029.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-outputlen     = 31.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----billing reference
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_xblnrb.
  l_fieldcat-seltext_l = text-030.
  l_fieldcat-no_out     = c_space.
  l_fieldcat-outputlen     = 17.
  l_fieldcat-DDIC_OUTPUTLEN   = '10'.
  l_fieldcat-LOWERCASE = 'X'.
  l_fieldcat-REF_TABNAME   = 'VBRK'.
  l_fieldcat-REF_FIELDNAME = 'XBLNR'.
  l_fieldcat-Ddictxt = 'L'.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----billing payment terms
  l_fieldcat-tabname    = c_finaltable.
  l_fieldcat-fieldname  = c_ztermb.
  l_fieldcat-seltext_l = text-031.
  l_fieldcat-outputlen     = 21.
  l_fieldcat-no_out     = c_space.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*--To hide the Fields

*-----order sales orgonization
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname  = c_vkorgo.
  l_fieldcat-seltext_l = text-033.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 24.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*---order division
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname  = c_sparto.
  l_fieldcat-seltext_l = text-034.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 14.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*----order category
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_vbtypo.
  l_fieldcat-seltext_l = text-035.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 23.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*----order document created by
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname  = c_ernamo.
  l_fieldcat-seltext_l = text-036.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 25.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----order document created on
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname  = c_erdato.
  l_fieldcat-seltext_l = text-037.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 25.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------order billing block
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_faksko.
  l_fieldcat-seltext_l = text-038.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 19.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*------order billing block DESCRIPTION
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_faksp.
  l_fieldcat-seltext_l = text-136.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 31.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*------order delivery block
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_lifsko.
  l_fieldcat-seltext_l = text-039.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 20.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*------order delivery block DESCRIPTION
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_lifsp.
  l_fieldcat-seltext_l = text-137.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 32.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-------ordr billing date
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_fkdat_v.
  l_fieldcat-seltext_l = text-040.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 18.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------order sales office
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_vkburo.
  l_fieldcat-seltext_l = text-041.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 18.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*----order sales group
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_vkgrpo.
  l_fieldcat-seltext_l = text-042.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 17.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*----order price group
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_konda_v.
  l_fieldcat-seltext_l = text-147.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 17.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*----order price group desc
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_vtext_kondao.
  l_fieldcat-seltext_l = text-148.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 29.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.


*-----ordrer inco terms
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_inco1_v.
  l_fieldcat-seltext_l = text-043.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 16.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-------order puchase order type
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_bsark_v.
  l_fieldcat-seltext_l = text-044.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 25.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*----Order Alternative Tax Classification
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_taxk1o.
  l_fieldcat-seltext_l = text-045.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 36.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Order Pricing Procedure
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kalsmo.
  l_fieldcat-seltext_l = text-046.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 23.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Order Item Number
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_posnro.
  l_fieldcat-seltext_l = text-047.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 17.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Order Material Number
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_matnro.
  l_fieldcat-seltext_l = text-048.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 21.
  l_fieldcat-REF_TABNAME   = 'VBAP'.
  l_fieldcat-REF_FIELDNAME = 'MATNR'.
  l_fieldcat-Ddictxt = 'L'.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----Order Material Number DESCRIPTION
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_maktxo.
  l_fieldcat-seltext_l = text-139.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-DDIC_OUTPUTLEN   = '40'.
  l_fieldcat-LOWERCASE = 'X'.
  l_fieldcat-outputlen     = 26.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*----Order Material Quantity
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kwmengo.
  l_fieldcat-seltext_l = text-049.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 23.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Order Material UOM
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_vrkmeo.
  l_fieldcat-seltext_l = text-050.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 18.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*----Order Item Plant
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_werkso.
  l_fieldcat-seltext_l = text-051.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-REF_TABNAME   = 'VBRK'.
  l_fieldcat-REF_FIELDNAME = 'WERKS'.
  l_fieldcat-Ddictxt = 'L'.
*  l_fieldcat-DDIC_OUTPUTLEN   = '4'.
*  l_fieldcat-LOWERCASE = 'X'.
  l_fieldcat-outputlen     = 16.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Order Item Product Hierarchy
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_prodho.
  l_fieldcat-seltext_l = text-052.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 28.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Order Item Material Group 1
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_mvgr1o.
  l_fieldcat-seltext_l = text-053.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 27.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----Order campaign id
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_yy_psp_pnro.
  l_fieldcat-seltext_l = text-140.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 22.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----Order Item Usage
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_vkauso.
  l_fieldcat-seltext_l = text-054.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen   = 16.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*----Order Item material group 4
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_mvgr4o.
  l_fieldcat-seltext_l = text-055.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 27.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-------Order Condition Type
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kschl.
  l_fieldcat-seltext_l = text-056.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 20.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-------Order Condition Type desc
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_vtext_kschl.
  l_fieldcat-seltext_l = text-141.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-DDIC_OUTPUTLEN   = '20'.
  l_fieldcat-LOWERCASE = 'X'.
  l_fieldcat-outputlen     = 32.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Order Condition Pricing Date
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kdatu.
  l_fieldcat-seltext_l = text-057.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 28.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-------Order Amount / Rate
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kbetr.
  l_fieldcat-seltext_l = text-058.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 19.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-------Order Condition Currency
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_waers.
  l_fieldcat-seltext_l = text-059.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 24.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Order Condition Pricing Unit
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kpein.
  l_fieldcat-seltext_l = text-060.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 28.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Order Condition unit in the document
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kmein.
  l_fieldcat-seltext_l = text-061.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 36.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-------Order Condition Value
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kwert_k.
  l_fieldcat-seltext_l = text-062.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 21.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Order Access sequence - Access number
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kolnr.
  l_fieldcat-seltext_l = text-063.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 37.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-------Order Condition item number
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kposn.
  l_fieldcat-seltext_l = text-064.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 27.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Order Step Number
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_stunr.
  l_fieldcat-seltext_l = text-065.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 17.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Order Condition Counter
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_zaehk.
  l_fieldcat-seltext_l = text-066.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 23.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Order Calculation Type
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_krech.
  l_fieldcat-seltext_l = text-067.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 22.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Order Condition Base Value
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-DECIMALS_OUT = c_3.
 l_fieldcat-CURRENCY  = 'X'.
  l_fieldcat-fieldname = c_kawrt.
  l_fieldcat-seltext_l = text-068.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 26.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Order Condition Exchange Rate
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kkurs.
  l_fieldcat-seltext_l = text-069.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 29.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Order Condition Category
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kntyp.
  l_fieldcat-seltext_l = text-070.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 24.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Order Scale Type
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_knprs.
  l_fieldcat-seltext_l = text-071.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 16.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Order Statistical Condition
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kstat.
  l_fieldcat-seltext_l = text-072.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 27.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Order Accural Condition
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kruek.
  l_fieldcat-seltext_l = text-073.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 23.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Order Condition Origin
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kherk.
  l_fieldcat-seltext_l = text-074.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 22.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Order Group Condition
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kgrpe.
  l_fieldcat-seltext_l = text-075.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 21.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Order Account Key
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kvsl1.
  l_fieldcat-seltext_l = text-076.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 17.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Order G/L Account
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_sakn1.
  l_fieldcat-seltext_l = text-077.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 17.
  l_fieldcat-REF_TABNAME   = 'KONV'.
  l_fieldcat-REF_FIELDNAME = 'SAKN1'.
  l_fieldcat-Ddictxt = 'L'.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-------Order Tax Code
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_mwsk1.
  l_fieldcat-seltext_l = text-078.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 14.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Order Accurals Key
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kvsl2.
  l_fieldcat-seltext_l = text-079.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 18.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Order Document Currency
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kwert.
  l_fieldcat-seltext_l = text-080.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 23.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Order Inactive Condition
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kinak.
  l_fieldcat-seltext_l = text-081.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 24.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-------Order Condition Control
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_ksteu.
  l_fieldcat-seltext_l = text-082.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 23.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*--------Order Conditon Class
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_koaid.
  l_fieldcat-seltext_l = text-083.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 20.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-------Billing Document Created By
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_ernamb.
  l_fieldcat-seltext_l = text-084.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 27.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Document Created On Date
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_erdatb.
  l_fieldcat-seltext_l = text-085.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 32.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Document Created On Time
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_erzetb.
  l_fieldcat-seltext_l = text-086.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 32.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Sales Organisation
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_vkorgb.
  l_fieldcat-seltext_l = text-087.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 26.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-------Billing Distribution Channel
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_vtwegb.
  l_fieldcat-seltext_l = text-088.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 28.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Document Category
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_fktypb.
  l_fieldcat-seltext_l = text-089.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 25.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*------Billing sales group
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_vkgrpb.
  l_fieldcat-seltext_l = text-150.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 19.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*------Billing sales office
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_vkburb.
  l_fieldcat-seltext_l = text-149.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 20.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.



*------Billing Price Group
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kondab.
  l_fieldcat-seltext_l = text-091.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 19.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Price Group DESC
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_vtext_konda.
  l_fieldcat-seltext_l = text-142.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 31.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----Billing Inco Terms
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_inco1b.
  l_fieldcat-seltext_l = text-092.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 18.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Document Tax Classification
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_taxk1b.
  l_fieldcat-seltext_l = text-093.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 35.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------BIlling Procedure
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kalsmb.
  l_fieldcat-seltext_l = text-094.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 17.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Item Number
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_posnrb.
  l_fieldcat-seltext_l = text-095.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 19.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Material Number
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_matnrb.
  l_fieldcat-seltext_l = text-096.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 23.
  l_fieldcat-REF_TABNAME   = 'VBRP'.
  l_fieldcat-REF_FIELDNAME = 'MATNR'.
  l_fieldcat-Ddictxt = 'L'.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----BILLING Material Number DESCRIPTION
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_maktxb.
  l_fieldcat-seltext_l = text-143.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-DDIC_OUTPUTLEN   = '40'.
  l_fieldcat-LOWERCASE = 'X'.
  l_fieldcat-outputlen     = 28.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*--------Billing Material Quantity
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_fkimgb.
  l_fieldcat-seltext_l = text-097.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 25.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Material UOM
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_vrkmeb.
  l_fieldcat-seltext_l = text-098.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 20.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Billing Item Plant
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_werksb.
  l_fieldcat-seltext_l = text-099.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 18.
  l_fieldcat-REF_TABNAME   = 'VBRP'.
  l_fieldcat-REF_FIELDNAME = 'WERKS'.
  l_fieldcat-Ddictxt = 'L'.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Item Product Hierarchy
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_prodhb.
  l_fieldcat-seltext_l = text-100.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 30.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*----Billing Item Material Group 1
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_mvgr1b.
  l_fieldcat-seltext_l = text-101.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 29.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*----Billing Item campaign id
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_yy_psp_pnrb.
  l_fieldcat-seltext_l = text-145.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 25.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*------Billing Item Usage
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_abrvwb.
  l_fieldcat-seltext_l = text-102.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 18.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*----Billing Item Material Group 4
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_mvgr4b.
  l_fieldcat-seltext_l = text-151.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 29.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----Billing Item Cash Discount
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_sktofb.
  l_fieldcat-seltext_l = text-103.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 26.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----Billing Item Order Reason
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_augru_auftb.
  l_fieldcat-seltext_l = text-105.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 25.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----Billing Item Order Reason desc
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_bezei_augru.
  l_fieldcat-seltext_l = text-146.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 37.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-----Billing Condition Type
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kschlb.
  l_fieldcat-seltext_l = text-106.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 22.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*-------Billing Condition Type desc
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_vtext_kschlb.
  l_fieldcat-seltext_l = text-144.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-DDIC_OUTPUTLEN   = '20'.
  l_fieldcat-LOWERCASE = 'X'.
  l_fieldcat-outputlen     = 34.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*----Billing Condition Pricing date
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kdatub.
  l_fieldcat-seltext_l = text-107.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 30.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Billing Amount/Rate
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kbetrb.
  l_fieldcat-seltext_l = text-108.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 19.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Billing Currency
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_waersb.
  l_fieldcat-seltext_l = text-109.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 16.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Currency Pricing Unit
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kpeinb.
  l_fieldcat-seltext_l = text-110.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 29.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Condition Unit in the Document
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kmeinb.
  l_fieldcat-seltext_l = text-111.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 38.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Condition Value
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kwert_kb.
  l_fieldcat-seltext_l = text-112.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 23.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Access Sequence
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kolnrb.
  l_fieldcat-seltext_l = text-113.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 23.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.

*------Billing Conditon item Number
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kposnb.
  l_fieldcat-seltext_l = text-114.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 28.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Billing Step Number
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_stunrb.
  l_fieldcat-seltext_l = text-115.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 19.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Condition Counter
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_zaehkb.
  l_fieldcat-seltext_l = text-116.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 25.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Calulation Type
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_krechb.
  l_fieldcat-seltext_l = text-117.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 23.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*----Billing Condition Base Value
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kawrtb.
  l_fieldcat-seltext_l = text-118.
  l_fieldcat-DECIMALS_OUT = c_3.
  l_fieldcat-CURRENCY  = 'X'.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 28.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Billing Condition Exchange Rate
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kkursb.
  l_fieldcat-seltext_l = text-119.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 31.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Billing Condition Category
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kntypb.
  l_fieldcat-seltext_l = text-120.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 26.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Scale Type
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_knprsb.
  l_fieldcat-seltext_l = text-121.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 18.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Statistical Condition
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kstatb.
  l_fieldcat-seltext_l = text-122.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 29.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Billing Accural Condition
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kruekb.
  l_fieldcat-seltext_l = text-123.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 25.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Condition Origin
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kherkb.
  l_fieldcat-seltext_l = text-124.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 24.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-------Billing Group Condition
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kgrpeb.
  l_fieldcat-seltext_l = text-125.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 23.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Billing Account Key
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kvsl1b.
  l_fieldcat-seltext_l = text-126.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 19.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing G/L Account
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_sakn1b.
  l_fieldcat-seltext_l = text-127.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 19.
  l_fieldcat-REF_TABNAME   = 'KONV'.
  l_fieldcat-REF_FIELDNAME = 'SAKN1'.
  l_fieldcat-Ddictxt = 'L'.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Tax Code
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_mwsk1b.
  l_fieldcat-seltext_l = text-128.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 16.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Billing Accurals Key
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kvsl2b.
  l_fieldcat-seltext_l = text-129.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 20.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Billing Document Currency
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kwertb.
  l_fieldcat-seltext_l = text-130.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 25.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Billing Inactive Condition
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_kinakb.
  l_fieldcat-seltext_l = text-131.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 26.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-------Billing Condition Control
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_ksteub.
  l_fieldcat-seltext_l = text-132.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 25.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-----Billing Condition Class
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_koaidb.
  l_fieldcat-seltext_l = text-133.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 23.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*-------Preceeding Document
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_vbelv.
  l_fieldcat-seltext_l = text-134.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 19.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
*------Subsequent Document
  l_fieldcat-tabname   = c_finaltable.
  l_fieldcat-sp_group  = c_a.
  l_fieldcat-fieldname = c_vbeln.
  l_fieldcat-seltext_l = text-135.
  l_fieldcat-no_out    = c_yes.
  l_fieldcat-outputlen     = 19.
  APPEND l_fieldcat TO fp_fieldtab.
  CLEAR l_fieldcat.
ENDFORM.                    "initialize_fieldcat


*&---------------------------------------------------------------------
*&      Form  write_output
*&---------------------------------------------------------------------
*       To display in the ALV GRID
*----------------------------------------------------------------------
FORM write_output.

**-for passing the field catalog which are to display
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_program_name     = v_repid
      i_internal_tabname = c_finaltable " internal table
      i_inclname         = v_repid      " program name
    CHANGING
      ct_fieldcat        = i_fieldcat.  " fild catalog

*--displays in the Grid with ALV functions
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program      = v_repid  " sy-repid
      i_callback_user_command = c_formname_at_user_command
      i_structure_name        = c_finaltable  "internal table
      is_layout               = layout
      it_fieldcat             = i_fieldcat
      i_default               = c_a
      i_save                  = v_save
      is_variant              = v_variant
    TABLES
      t_outtab                = i_final.
ENDFORM.                    " field_catalog
*&---------------------------------------------------------------------
*&      Form  get_alv_variant
*&---------------------------------------------------------------------
*       to get the variant
*----------------------------------------------------------------------
FORM get_alv_variant USING   fp_v_variant TYPE disvariant
                             fp_save TYPE char1
                    CHANGING fp_vx_variant TYPE disvariant
                             fp_p_disvar TYPE disvariant-variant
                             fp_exit TYPE char1.


* F4 help for the existing variants
  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
    EXPORTING
      is_variant = fp_v_variant
      i_save     = fp_save
    IMPORTING
      e_exit     = fp_exit
      es_variant = fp_vx_variant.

  IF fp_exit = space.

*     assigning the variant to the selection para
    fp_p_disvar = fp_vx_variant-variant.
*    ENDIF.

  ENDIF.

ENDFORM.                    " get_alv_variant

*&---------------------------------------------------------------------
*&      Form  pai_of_selection_screen
*&---------------------------------------------------------------------
*       for making the variant
*----------------------------------------------------------------------
*   %LT--  p2       p_disvar
*----------------------------------------------------------------------
FORM pai_of_selection_screen
              USING    fp_save TYPE char1
                       fp_repid TYPE sy-repid
              CHANGING fp_p_disvar TYPE disvariant-variant
                       fp_v_variant TYPE disvariant
                       fp_vx_variant TYPE disvariant.


* checking the variant have the value
  IF NOT fp_p_disvar IS INITIAL.

*   Populating the values
    MOVE fp_v_variant TO fp_vx_variant.
    MOVE fp_p_disvar TO fp_vx_variant-variant.

*   Reuse the existing variant
    CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
      EXPORTING
        i_save     = fp_save
      CHANGING
        cs_variant = fp_vx_variant.

    fp_v_variant = fp_vx_variant.
  ELSE.

*  clear the variant
    CLEAR fp_v_variant.

*  assigning the report name to variant report
    fp_v_variant-report = fp_repid.

  ENDIF.

ENDFORM.                    " pai_of_selection_screen
*&---------------------------------------------------------------------
*&      Form  init_prog
*&---------------------------------------------------------------------
*       initializes the variables
*----------------------------------------------------------------------
*   %LT--  p2        p_disvar
*----------------------------------------------------------------------
FORM init_prog CHANGING fp_v_variant TYPE disvariant
                        fp_vx_variant TYPE disvariant
                        fp_p_disvar TYPE disvariant-variant
                        fp_repid TYPE sy-repid
                        fp_save TYPE char1.


* assigning the report id to variable
  fp_repid = sy-repid.
  fp_save = c_a.

* cleat the variant
  CLEAR fp_v_variant.

* assigning report name to variant's report name
  fp_v_variant-report = fp_repid.

* Get default variant
  fp_vx_variant = fp_v_variant.

* Reuse of the defauls variant for output
  CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
    EXPORTING
      i_save     = fp_save
    CHANGING
      cs_variant = fp_vx_variant
    EXCEPTIONS
      not_found  = 2.

* Checking of success for function
  IF sy-subrc = 0.
    fp_p_disvar = fp_vx_variant-variant.
  ENDIF.

ENDFORM.                    " init_prog


*----------------------------------------------------------------------
*       FORM USER_COMMAND
*----------------------------------------------------------------------
*       Call the transaction when click on list
*----------------------------------------------------------------------
FORM user_command USING r_ucomm LIKE sy-ucomm
                  rs_selfield TYPE slis_selfield.           "#EC CALLED

  IF r_ucomm = c_ic1.

    IF rs_selfield-sel_tab_field = c_order.
      IF rs_selfield-value IS NOT INITIAL.
*---sets the parameter id of the sales document
        SET PARAMETER ID c_aun FIELD rs_selfield-value.
*---calls the display sales order detals transaction
*       CALL TRANSACTION c_va03 AND SKIP FIRST SCREEN.
        CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.


      ENDIF.
    ENDIF.

    IF rs_selfield-sel_tab_field = c_bill.
      IF rs_selfield-value IS NOT INITIAL.
*---sets the parameter id of the billing document
        SET PARAMETER ID c_vf FIELD rs_selfield-value.
*---calls the display invoice detais transaction
*       CALL TRANSACTION c_vf03 AND SKIP FIRST SCREEN.
        CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN.

      ENDIF.
    ENDIF.

  ENDIF.
ENDFORM.                    "user_command
*&---------------------------------------------------------------------
*&      Form  at_selection_screen
*&---------------------------------------------------------------------
*       to change the selection-screen as per the radio button
*----------------------------------------------------------------------
FORM at_selection_screen.
  IF rb_order = c_yes. "X
    LOOP AT SCREEN.
      IF screen-group1 = c_scrgr_sc2.   "SC2
        screen-input = 0.
        MODIFY SCREEN.

      ENDIF.
    ENDLOOP.
  ELSEIF rb_bill = c_yes.
    LOOP AT SCREEN.
      IF screen-group1 = c_scrgr_sc1.   "SC1
        screen-input = 0.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.

ENDFORM.                    " at_selection_screen
*&---------------------------------------------------------------------
*&      Form  get_busdata_b
*&---------------------------------------------------------------------
*       to get the business data
*----------------------------------------------------------------------
*  --%GT  p1        fp_i_vbak_vbap
*  %LT--  p2        fp_i_vbak_vbkd
*----------------------------------------------------------------------
FORM get_busdata_b USING    fp_i_vbak_vbap TYPE t_ty_vbak_vbap
                  CHANGING fp_i_vbak_vbkd TYPE t_ty_vbak_vbkd.

  DATA : l_i_vbak_vbap_tmp TYPE t_ty_vbak_vbap.
*-----copies the contents of the internal table to temperory table
  MOVE fp_i_vbak_vbap TO l_i_vbak_vbap_tmp.
*------sorts the temperory table by sales doc number
  SORT l_i_vbak_vbap_tmp BY vbeln.
*-----deletes the duplicate entries
  DELETE ADJACENT DUPLICATES FROM l_i_vbak_vbap_tmp COMPARING vbeln.
*-- retives the data from the business table
  IF NOT l_i_vbak_vbap_tmp IS INITIAL.
    SELECT
    vbeln    "  Sales and Distribution Document Number
    posnr    "  Item number of the SD document
    konda    "  Price group (customer)
    inco1    "  Incoterms (part 1)
    valtg    "  Additional value days
    valdt    "  Fixed value date
    zterm    "  Terms of payment key
    prsdt    "  Date for pricing and exchange rate
    fkdat    "  Billing date for billing index and printout
    bstkd    "  Customer purchase order number
    bsark    "  Customer purchase order type
    FROM vbkd
    INTO TABLE fp_i_vbak_vbkd
    FOR ALL ENTRIES IN l_i_vbak_vbap_tmp
    WHERE vbeln = l_i_vbak_vbap_tmp-vbeln.
  ENDIF.
  IF sy-subrc NE 0.
* ..... message for no business data
    MESSAGE i057.
  ENDIF.


ENDFORM.                    " get_busdata_b
*&---------------------------------------------------------------------
*&      Form  get_typdec
*&---------------------------------------------------------------------
*       order document type description
*----------------------------------------------------------------------
*  --%GT  p1        fp_i_vbak_vbap
*  %LT--  p2        fp_i_tvakt
*----------------------------------------------------------------------
FORM get_typdec USING fp_i_vbak_vbap TYPE t_ty_vbak_vbap
                CHANGING fp_i_tvakt TYPE t_ty_tvakt.

*---formal parameter
  DATA : l_vbak_vbap_tmp TYPE t_ty_vbak_vbap.
*----copies the data from l_vbak_vbap into temprory internaltable
  l_vbak_vbap_tmp[] = fp_i_vbak_vbap[].
  SORT l_vbak_vbap_tmp BY auart.

*---- deletes the adjacent duplicate entries comparing doc. type
  DELETE ADJACENT DUPLICATES FROM l_vbak_vbap_tmp COMPARING auart.
  IF NOT l_vbak_vbap_tmp IS INITIAL.
    SELECT auart bezei FROM tvakt
                 INTO TABLE fp_i_tvakt
                 FOR ALL ENTRIES IN l_vbak_vbap_tmp
                 WHERE spras = sy-langu AND
                 auart = l_vbak_vbap_tmp-auart.
  ENDIF.
*-----sy-subrc not required.

ENDFORM.                    " get_typdec
*&---------------------------------------------------------------------
*&      Form  get_billing_status
*&---------------------------------------------------------------------
*       to get the billing status of the sales documen
*----------------------------------------------------------------------
*  --%GT  p1        fp_i_vbak_vbap
*  %LT--  p2        fp_i_vbuk
*----------------------------------------------------------------------
FORM get_billing_status USING fp_i_vbak_vbap TYPE t_ty_vbak_vbap
                        CHANGING  fp_i_vbuk TYPE t_ty_vbuk.
* temporory internal table declaration locally
  DATA : l_i_vbak_vbap_tmp TYPE t_ty_vbak_vbap.
* copies the actual contents into tem. table
  l_i_vbak_vbap_tmp[] = fp_i_vbak_vbap[].
*---sorts the temp. table by doc. number
  SORT l_i_vbak_vbap_tmp BY vbeln.
*---deletes the duplicate entries in the temp. table
  DELETE ADJACENT DUPLICATES FROM l_i_vbak_vbap_tmp COMPARING vbeln.
  IF NOT l_i_vbak_vbap_tmp IS INITIAL.
    SELECT vbeln
    fkstk  FROM vbuk
                 INTO TABLE fp_i_vbuk
                 FOR ALL ENTRIES IN l_i_vbak_vbap_tmp
                 WHERE vbeln = l_i_vbak_vbap_tmp-vbeln.
  ENDIF.
*-----sy-subrc not required.
ENDFORM.                    " get_billing_status
*&---------------------------------------------------------------------
*&      Form  SUB_VALIDATE_SALESOR
*&---------------------------------------------------------------------
*       validation for sales organization
FORM sub_validate_salesorg .

  DATA : l_vkorg TYPE vkorg.

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

  IF sy-subrc %LT%GT 0.
    MESSAGE e001.
  ENDIF.


ENDFORM.                    " SUB_VALIDATE_SALESORG
*&---------------------------------------------------------------------
*&      Form  SUB_VALIDATE_DISTCHANL
*&---------------------------------------------------------------------
*       validation for distribution channel
*----------------------------------------------------------------------
FORM sub_validate_distchanl .
  DATA : l_vtweg TYPE vtweg.

  IF NOT s_vtweg IS INITIAL.
*  To validate distribution channel.
    SELECT  vtweg
            FROM tvtw
            INTO (l_vtweg)
            UP TO 1 ROWS
            WHERE vtweg IN s_vtweg.
    ENDSELECT.

    IF sy-subrc %LT%GT 0.
      MESSAGE e023.
    ENDIF.

    CLEAR l_vtweg.

* To check the distribution channel against the sales org.
    SELECT  vtweg
            FROM tvkov
            INTO (l_vtweg)
            UP TO 1 ROWS
            WHERE vtweg IN s_vtweg
            AND   vkorg IN s_vkorg.
    ENDSELECT.
* if Invalid combination of Sales Organization
* and Distribution Channel found raise error message.
    IF sy-subrc %LT%GT 0.
      MESSAGE e073.
    ENDIF.
  ENDIF.
ENDFORM.                    " SUB_VALIDATE_DISTCHANL
*&---------------------------------------------------------------------
*&      Form  SUB_VALIDATE_CONDITIONTYPE
*&---------------------------------------------------------------------
*       validation for condition type
*----------------------------------------------------------------------
FORM sub_validate_conditiontype .
  DATA : l_kschl TYPE kscha.
  IF s_kschl IS NOT INITIAL.
    SELECT  kschl
    FROM t685
    INTO (l_kschl)
    UP TO 1 ROWS
    WHERE kschl IN s_kschl.
    ENDSELECT.
    IF sy-subrc %LT%GT 0.
      MESSAGE e527.
    ENDIF.
  ENDIF.

ENDFORM.                    " SUB_VALIDATE_CONDITIONTYPE
*&---------------------------------------------------------------------
*&      Form  SUB_VALIDATE_SALESDOC
*&---------------------------------------------------------------------
*       validation for sales document number
*----------------------------------------------------------------------
FORM sub_validate_salesdoc .
  DATA : l_vbeln TYPE vbeln.
  IF NOT s_vbelno IS INITIAL.
    SELECT  vbeln
    FROM  vbuk
    INTO (l_vbeln)
    UP TO 1 ROWS
    WHERE vbeln IN s_vbelno.
    ENDSELECT.
    IF sy-subrc %LT%GT 0.
      MESSAGE e054.
    ENDIF.
  ENDIF.
ENDFORM.                    " SUB_VALIDATE_SALESDOC
*&---------------------------------------------------------------------
*&      Form  SUB_VALIDATE_SALESDOC
*&---------------------------------------------------------------------
*       validation for billing document number
*----------------------------------------------------------------------

FORM sub_validate_billdoc .
  DATA : l_vbeln TYPE vbeln.
  IF NOT s_vbelnb IS INITIAL.
    SELECT vbeln
    FROM  vbuk
    INTO (l_vbeln)
    UP TO 1 ROWS
    WHERE vbeln IN s_vbelnb.
    ENDSELECT.
    IF sy-subrc %LT%GT 0.
      MESSAGE e426.
    ENDIF.
  ENDIF.
ENDFORM.                    " SUB_VALIDATE_SALESDOC
*&---------------------------------------------------------------------
*&      Form  SUB_VALIDATE_MATERIAL
*&---------------------------------------------------------------------
*       validatin the material number
*----------------------------------------------------------------------
FORM sub_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 sy-subrc %LT%GT 0.
    MESSAGE e409.
  ENDIF.
ENDFORM.                    " SUB_VALIDATE_MATERIAL
*&---------------------------------------------------------------------
*&      Form  SUB_VALIDATE_DOCTYPE
*&---------------------------------------------------------------------
*      validation for document type
*----------------------------------------------------------------------
FORM sub_validate_doctype .
  DATA : l_auart TYPE auart.
  IF NOT s_auart IS INITIAL.
    SELECT auart
    FROM  tvak
    INTO (l_auart)
    UP TO 1 ROWS
    WHERE auart IN s_auart.
    ENDSELECT.
    IF sy-subrc %LT%GT 0.
      MESSAGE e016.
    ENDIF.
  ENDIF.
ENDFORM.                    " SUB_VALIDATE_DOCTYPE
*&---------------------------------------------------------------------
*&      Form  SUB_VALIDATE_BILLINGTYPE
*&---------------------------------------------------------------------
*       validation for billing type
*----------------------------------------------------------------------
FORM sub_validate_billingtype .
  DATA : l_fkart TYPE fkart.
  IF NOT s_fkart IS INITIAL.
    SELECT fkart
    FROM  tvfk
    INTO (l_fkart)
    UP TO 1 ROWS
    WHERE fkart IN s_fkart.
    ENDSELECT.
    IF sy-subrc %LT%GT 0.
      MESSAGE e024.
    ENDIF.
  ENDIF.

ENDFORM.                    " SUB_VALIDATE_BILLINGTYPE
*&---------------------------------------------------------------------
*&      Form  SUB_VALIDATE_SOLDTOPARTY
*&---------------------------------------------------------------------
*       validation for the sold-to-party
*----------------------------------------------------------------------
FORM sub_validate_soldtoparty .
  DATA : l_kunnr TYPE kunnr.
  IF NOT s_kunag IS INITIAL.
    SELECT kunnr
    FROM  kna1
    INTO (l_kunnr)
    UP TO 1 ROWS
    WHERE kunnr IN s_kunag.
    ENDSELECT.
    IF sy-subrc %LT%GT 0.
      MESSAGE e517.
    ENDIF.
  ENDIF.
ENDFORM.                    " SUB_VALIDATE_SOLDTOPARTY
*&---------------------------------------------------------------------
*&      Form  SUB_VALIDATE_PAYER
*&---------------------------------------------------------------------
*       validation for the payer
*----------------------------------------------------------------------

FORM sub_validate_payer .
  DATA : l_kunrg TYPE kunrg.
  IF NOT s_kunrg IS INITIAL.
    SELECT kunnr
    FROM  kna1
    INTO (l_kunrg)
    UP TO 1 ROWS
    WHERE kunnr IN s_kunrg.
    ENDSELECT.
    IF sy-subrc %LT%GT 0.
      MESSAGE e031.
    ENDIF.
  ENDIF.
ENDFORM.                    " SUB_VALIDATE_SOLDTOPARTY
*&---------------------------------------------------------------------
*&      Form  get_typdec_b
*&---------------------------------------------------------------------
*       Retrives the billing document type description
*----------------------------------------------------------------------
FORM get_typdec_b USING fp_i_vbrk_vbrp TYPE t_ty_vbrk_vbrp
                  CHANGING fp_i_tvfkt TYPE t_ty_tvfkt .
  DATA : l_vbrk_vbrp_tmp TYPE t_ty_vbrk_vbrp.
  l_vbrk_vbrp_tmp[] = fp_i_vbrk_vbrp[].
  SORT l_vbrk_vbrp_tmp BY vbeln fkart.
  DELETE ADJACENT DUPLICATES FROM l_vbrk_vbrp_tmp COMPARING vbeln fkart.
  IF NOT l_vbrk_vbrp_tmp IS INITIAL.
    SELECT fkart vtext FROM tvfkt
                 INTO TABLE fp_i_tvfkt
                 FOR ALL ENTRIES IN l_vbrk_vbrp_tmp
                 WHERE spras = sy-langu AND
                 fkart = l_vbrk_vbrp_tmp-fkart.
  ENDIF.
  IF sy-subrc %LT%GT 0.
*--------doing nothing.
  ENDIF.

ENDFORM.                    " get_typdec_b
*&---------------------------------------------------------------------
*&      Form  get_soldtoparty
*&---------------------------------------------------------------------
*       Rerives the name of the sold to party
*----------------------------------------------------------------------
FORM get_soldtoparty USING fp_i_vbak_vbap TYPE t_ty_vbak_vbap
                     CHANGING fp_i_kna1 TYPE t_ty_kna1.

  DATA : l_vbak_vbap_tmp TYPE t_ty_vbak_vbap.
  l_vbak_vbap_tmp[] = fp_i_vbak_vbap[].
  SORT l_vbak_vbap_tmp BY kunnr.
  DELETE ADJACENT DUPLICATES FROM l_vbak_vbap_tmp COMPARING kunnr.
  IF NOT l_vbak_vbap_tmp IS INITIAL.
    SELECT kunnr name1 FROM kna1
                 INTO TABLE fp_i_kna1
                 FOR ALL ENTRIES IN l_vbak_vbap_tmp
                 WHERE kunnr = l_vbak_vbap_tmp-kunnr.
  ENDIF.
  IF sy-subrc %LT%GT 0.
*-------doing nothing.
  ENDIF.

ENDFORM.                    " get_soldtoparty
*&---------------------------------------------------------------------
*&      Form  get_payer
*&---------------------------------------------------------------------
*       to retrive the name of payer.
*----------------------------------------------------------------------
FORM get_payer USING fp_i_vbrk_vbrp TYPE t_ty_vbrk_vbrp
                     CHANGING fp_i_kna1_b TYPE t_ty_kna1.

  DATA : l_vbrk_vbrp_tmp TYPE t_ty_vbrk_vbrp.
  l_vbrk_vbrp_tmp[] = fp_i_vbrk_vbrp[].
  SORT l_vbrk_vbrp_tmp BY kunrg.
  DELETE ADJACENT DUPLICATES FROM l_vbrk_vbrp_tmp COMPARING kunrg.
  IF NOT l_vbrk_vbrp_tmp IS INITIAL.
    SELECT kunnr name1 FROM kna1
                 INTO TABLE fp_i_kna1_b
                 FOR ALL ENTRIES IN l_vbrk_vbrp_tmp
                 WHERE kunnr = l_vbrk_vbrp_tmp-kunrg.
  ENDIF.
  IF sy-subrc %LT%GT 0.
*------doing nothing.
  ENDIF.
ENDFORM.                    " get_payer
*&---------------------------------------------------------------------
*&      Form  build_layout
*&---------------------------------------------------------------------
*       to get the check boxes in the ALV layout
*----------------------------------------------------------------------
FORM build_layout USING fp_layout TYPE slis_layout_alv.

  fp_layout-box_fieldname = C_DUMMY.
  fp_layout-zebra = c_yes.
  fp_layout-colwidth_optimize = c_yes.

ENDFORM.                               " BUILD_LAYOUT
*&---------------------------------------------------------------------
*&      Form  doc_status
*&---------------------------------------------------------------------
*   to get the document status
*----------------------------------------------------------------------
FORM doc_status  USING    fp_i_vbak_vbap TYPE t_ty_vbak_vbap
                 CHANGING fp_i_vbup TYPE t_ty_vbup.

  DATA : l_vbak_vbap_tmp TYPE  t_ty_vbak_vbap.
  MOVE fp_i_vbak_vbap TO l_vbak_vbap_tmp.
  SORT l_vbak_vbap_tmp BY vbeln.

  IF NOT l_vbak_vbap_tmp  IS INITIAL.
    SELECT
    vbeln
    posnr
    gbsta FROM vbup INTO TABLE fp_i_vbup
    FOR ALL ENTRIES IN l_vbak_vbap_tmp
    WHERE vbeln = l_vbak_vbap_tmp-vbeln AND
    posnr = l_vbak_vbap_tmp-posnr.
  ENDIF.

  IF sy-subrc %LT%GT 0.
*-----doing nothing.
  ENDIF.
ENDFORM.                    " doc_status
*&---------------------------------------------------------------------
*&      Form  desc_billblock
*&---------------------------------------------------------------------
*       text
*----------------------------------------------------------------------
*      --%GTP_I_VBAK_VBAP  text
*      %LT--P_I_TVFST  text
*----------------------------------------------------------------------
FORM desc_billblock USING fp_i_vbak_vbap TYPE t_ty_vbak_vbap
      CHANGING fp_i_tvfst TYPE t_ty_tvfst.

  DATA : l_i_vbak_vbap_tmp TYPE t_ty_vbak_vbap.

  MOVE fp_i_vbak_vbap TO l_i_vbak_vbap_tmp.

  SORT l_i_vbak_vbap_tmp BY faksk .
  DELETE ADJACENT DUPLICATES FROM l_i_vbak_vbap_tmp
  COMPARING faksk.

  SELECT faksp vtext FROM tvfst INTO TABLE fp_i_tvfst
  FOR ALL ENTRIES IN l_i_vbak_vbap_tmp
  WHERE spras = sy-langu AND
        faksp = l_i_vbak_vbap_tmp-faksk.


ENDFORM.                    " desc_billblock
*&---------------------------------------------------------------------
*&      Form  desc_delivblock
*&---------------------------------------------------------------------
*       text
*----------------------------------------------------------------------
*      --%GTP_I_VBAK_VBAP  text
*      %LT--P_I_TVLST  text
*----------------------------------------------------------------------
FORM desc_delivblock  USING fp_i_vbak_vbap TYPE t_ty_vbak_vbap
      CHANGING fp_i_tvlst TYPE t_ty_tvlst.

  DATA : l_i_vbak_vbap_tmp TYPE t_ty_vbak_vbap.

  MOVE fp_i_vbak_vbap TO l_i_vbak_vbap_tmp.

  SORT l_i_vbak_vbap_tmp BY lifsk .
  DELETE ADJACENT DUPLICATES FROM l_i_vbak_vbap_tmp
  COMPARING lifsk.

  SELECT lifsp vtext FROM tvlst INTO TABLE fp_i_tvlst
  FOR ALL ENTRIES IN l_i_vbak_vbap_tmp
  WHERE spras = sy-langu AND
        lifsp = l_i_vbak_vbap_tmp-lifsk.


ENDFORM.                    " desc_billblock
*&---------------------------------------------------------------------
*&      Form  desc_material
*&---------------------------------------------------------------------
*       text
*----------------------------------------------------------------------
*      --%GTP_I_VBAK_VBAP  text
*      %LT--P_I_MAKT  text
*----------------------------------------------------------------------
FORM desc_material USING fp_i_vbak_vbap TYPE t_ty_vbak_vbap
         CHANGING fp_i_makt TYPE t_ty_makt.

DATA : l_i_vbak_vbap_tmp TYPE t_ty_vbak_vbap.

  MOVE fp_i_vbak_vbap TO l_i_vbak_vbap_tmp.
  SORT l_i_vbak_vbap_tmp BY matnr.
  DELETE ADJACENT DUPLICATES FROM l_i_vbak_vbap_tmp COMPARING matnr.

  SELECT matnr maktx FROM makt INTO TABLE fp_i_makt
  FOR ALL ENTRIES IN l_i_vbak_vbap_tmp
  WHERE spras = sy-langu AND
        matnr = l_i_vbak_vbap_tmp-matnr.
ENDFORM.                    "desc_material
*&---------------------------------------------------------------------
*&      Form  desc_material_b
*&---------------------------------------------------------------------
*       text
*----------------------------------------------------------------------
*      --%GTP_I_VBRK_VBRP_TMP  text
*      %LT--P_I_MAKT  text
*----------------------------------------------------------------------

FORM desc_material_b USING fp_i_vbrk_vbrp TYPE t_ty_vbrk_vbrp
         CHANGING fp_i_makt_b TYPE t_ty_makt.

DATA : l_i_vbrk_vbrp_tmp TYPE t_ty_vbrk_vbrp.

  MOVE fp_i_vbrk_vbrp TO l_i_vbrk_vbrp_tmp.
  SORT l_i_vbrk_vbrp_tmp BY matnr.
  DELETE ADJACENT DUPLICATES FROM l_i_vbrk_vbrp_tmp COMPARING matnr.

  SELECT matnr maktx FROM makt INTO TABLE fp_i_makt_b
  FOR ALL ENTRIES IN l_i_vbrk_vbrp_tmp
  WHERE spras = sy-langu AND
        matnr = l_i_vbrk_vbrp_tmp-matnr.
ENDFORM.                    " desc_material_b
*&---------------------------------------------------------------------
*&      Form  desc_reason_b
*&---------------------------------------------------------------------
*       subroutine for the billing or reason desc
*----------------------------------------------------------------------
FORM desc_reason_b  USING    fp_i_vbrk_vbrp TYPE t_ty_vbrk_vbrp
                    CHANGING fp_i_tvaut TYPE t_ty_tvaut.

  DATA :  l_i_vbrk_vbrp TYPE  t_ty_vbrk_vbrp.
  l_i_vbrk_vbrp[] = fp_i_vbrk_vbrp.
  SORT l_i_vbrk_vbrp BY augru_auft .
  DELETE ADJACENT DUPLICATES FROM l_i_vbrk_vbrp
  COMPARING augru_auft.
  SELECT augru bezei FROM tvaut INTO TABLE fp_i_tvaut
  FOR ALL ENTRIES IN l_i_vbrk_vbrp
  WHERE spras = sy-langu AND
        augru = l_i_vbrk_vbrp-augru_auft.
ENDFORM.                    " desc_reason_b
*&---------------------------------------------------------------------
*&      Form  desc_condtype_o
*&---------------------------------------------------------------------
*       order condition type description
*----------------------------------------------------------------------
FORM desc_condtype_o  USING    fp_i_konv TYPE t_ty_konv
                    CHANGING fp_i_t685t TYPE t_ty_t685t.

  DATA :  l_i_konv TYPE  t_ty_konv.
  l_i_konv[] = fp_i_konv[].
  SORT l_i_konv BY kschl .
  DELETE ADJACENT DUPLICATES FROM l_i_konv
  COMPARING kschl.
  SELECT kschl vtext FROM t685t INTO TABLE fp_i_t685t
  FOR ALL ENTRIES IN l_i_konv
  WHERE spras = sy-langu AND
        kschl = l_i_konv-kschl.

ENDFORM.                    " desc_condtype_o
*&---------------------------------------------------------------------
*&      Form  desc_pricegrp
*&---------------------------------------------------------------------
*       text
*----------------------------------------------------------------------
*      --%GTP_I_VBRK_VBRP  text
*      %LT--P_I_T188T  text
*----------------------------------------------------------------------
FORM desc_pricegrp  USING    fp_i_vbrk_vbrp TYPE t_ty_vbrk_vbrp
                    CHANGING fp_i_t188t TYPE t_ty_t188t.

  DATA : l_i_vbrk_vbrp TYPE  t_ty_vbrk_vbrp.
  l_i_vbrk_vbrp[] = fp_i_vbrk_vbrp.
  SORT l_i_vbrk_vbrp BY konda.
  DELETE ADJACENT DUPLICATES FROM l_i_vbrk_vbrp
  COMPARING konda.
  SELECT konda vtext FROM t188t INTO TABLE fp_i_t188t
  FOR ALL ENTRIES IN l_i_vbrk_vbrp
  WHERE spras = sy-langu AND
        konda = l_i_vbrk_vbrp-konda.

ENDFORM.                    " desc_pricegrp
*&---------------------------------------------------------------------
*&      Form  desc_condtype_b
*&---------------------------------------------------------------------
*       billinig cond. type description
*----------------------------------------------------------------------
FORM desc_condtype_b  USING    fp_i_konv_b TYPE t_ty_konv
                    CHANGING fp_i_t685t_b TYPE t_ty_t685t.

  DATA :  l_i_konv_b TYPE  t_ty_konv.
  l_i_konv_b[] = fp_i_konv_b[].
  SORT l_i_konv_b BY kschl .
  DELETE ADJACENT DUPLICATES FROM l_i_konv_b
  COMPARING kschl.
  SELECT kschl vtext FROM t685t INTO TABLE fp_i_t685t_b
  FOR ALL ENTRIES IN l_i_konv_b
  WHERE spras = sy-langu AND
        kschl = l_i_konv_b-kschl.

ENDFORM.                    " desc_condtype_b
*&---------------------------------------------------------------------
*&      Form  desc_pricegrp_o
*&---------------------------------------------------------------------
*       text
*----------------------------------------------------------------------
*      --%GTP_I_VBAK_VBKD  text
*      %LT--P_I_T188T_O  text
*----------------------------------------------------------------------
FORM desc_pricegrp_o  USING    fp_i_vbak_vbkd TYPE t_ty_vbak_vbkd
                      CHANGING fp_i_t188t_o TYPE t_ty_t188t.

  DATA : l_i_vbak_vbkd TYPE  t_ty_vbak_vbkd.
  l_i_vbak_vbkd[] = fp_i_vbak_vbkd.
  SORT l_i_vbak_vbkd BY konda.
  DELETE ADJACENT DUPLICATES FROM l_i_vbak_vbkd
  COMPARING konda.
  SELECT konda vtext FROM t188t INTO TABLE fp_i_t188t_o
  FOR ALL ENTRIES IN l_i_vbak_vbkd
  WHERE spras = sy-langu AND
        konda = l_i_vbak_vbkd-konda.

ENDFORM.                    " desc_pricegrp_o
*&---------------------------------------------------------------------
*&      Form  check_auhtorization
*&---------------------------------------------------------------------
*       AUTHORITY CHEC
*----------------------------------------------------------------------
FORM check_auhtorization .

  CONSTANTS: l_c_vkorg TYPE char5 VALUE 'VKORG',
             l_c_vtweg TYPE char5 VALUE 'VTWEG',
             l_c_actvt TYPE char5 VALUE 'ACTVT'.

* 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.

  CLEAR l_wa_check.
  CLEAR l_i_check.

  SELECT vkorg
         vtweg
  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 i230  .
*   Choose valid Sales organization
    LEAVE LIST-PROCESSING.
  ENDIF.

  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_auth
*          ID l_c_vkorg FIELD l_wa_check-vkorg
*          ID l_c_vtweg FIELD l_wa_check-vtweg
*          ID l_c_actvt FIELD c_disp.
*
    IF sy-subrc %LT%GT 0.
      MESSAGE i231 WITH l_wa_check-vkorg .
*     Activity-Change is not allowed for you for sales organisation:&
      LEAVE LIST-PROCESSING.
    ELSE.

      wa_salesorg-sign = c_kind.
      wa_salesorg-option = c_option.
      wa_salesorg-low =  l_wa_check-vkorg.
      APPEND wa_salesorg TO r_salesorg.
      CLEAR wa_salesorg.

      wa_distch-sign = c_kind.
      wa_distch-option = c_option.
      wa_distch-low =  l_wa_check-vtweg.
      APPEND wa_distch TO r_distch.
      CLEAR wa_distch.

      CLEAR l_wa_check.
    ENDIF.
  ENDLOOP.


ENDFORM.                    " check_auhtorization
*&---------------------------------------------------------------------
*&      Form  check_auhtorization_B
*&---------------------------------------------------------------------
*       AUTHORITY CHECK
*----------------------------------------------------------------------
FORM check_auhtorization_b .
  CONSTANTS: l_c_vkorg TYPE char5 VALUE 'VKORG',
             l_c_actvt TYPE char5 VALUE 'ACTVT'.

* 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.

  CLEAR l_wa_check.
  CLEAR l_i_check.

  SELECT vkorg
  FROM  tvko               "Organizational Unit: Sales Area(s)
  INTO TABLE l_i_check
  WHERE vkorg IN  s_vkorg.

* Record not found display error msg
  IF sy-subrc NE 0.
    MESSAGE i230.
*   Choose valid Sales organization
    LEAVE LIST-PROCESSING.
  ENDIF.

  CLEAR : r_salesorg.
* Collect all Sales organization in a range
  LOOP AT l_i_check INTO l_wa_check.

    AUTHORITY-CHECK OBJECT c_authb
          ID l_c_vkorg FIELD l_wa_check-vkorg
          ID l_c_actvt FIELD c_disp.

    IF sy-subrc %LT%GT 0.
      MESSAGE i231 WITH l_wa_check-vkorg .
*     Activity-Change is not allowed for you for sales organisation:&
      LEAVE LIST-PROCESSING.
    ELSE.

      wa_salesorg-sign = c_kind.
      wa_salesorg-option = c_option.
      wa_salesorg-low =  l_wa_check-vkorg.
      APPEND wa_salesorg TO r_salesorg.
      CLEAR wa_salesorg.
      CLEAR l_wa_check.
    ENDIF.
  ENDLOOP.


ENDFORM.                    " check_auhtorization_B



*Text elements
*----------------------------------------------------------
* 001 Order Document Number
* 002 Order Document Type
* 003 Ord Document Type Description
* 004 Order Document Date
* 005 Order Sold-to Party Number
* 006 Sold to party Name
* 007 Order Purchase Order Number
* 008 Order Reason
* 009 Order Pricing Date
* 010 Order Net Value
* 011 Order Currency
* 012 Order Tax Amount
* 013 Order Currency
* 014 Order Fixed Value Date
* 015 Order Additional Value Days
* 016 Order Payment Terms
* 017 Billing Document Number
* 018 Billing Document Type
* 019 Billing Document Type Description
* 020 Billing Document Date
* 021 Billing Document Status
* 022 Billing Document Cancelled
* 023 Billing Payer Number
* 024 Billing Payer Name
* 025 Billing Document Net Value
* 026 Billing Currency
* 027 Billing Tax Amount
* 028 Billing Currency
* 029 Billing Document Posting Status
* 030 Billing Reference
* 031 Billing Payment Terms
* 032 Order Document Overall Status
* 033 Order Sales Organisation
* 034 Order Division
* 035 Order Document Category
* 036 Order Document Created By
* 037 Order Document Created On
* 038 Order Billing Block
* 039 Order Delivery Block
* 040 Order Billing Date
* 041 Order Sales Office
* 042 Order Sales Group
* 043 Order Inco Terms
* 044 Order Purchase Order Type
* 045 Order Alternative Tax Classification
* 046 Order Pricing Procedure
* 047 Order Item Number
* 048 Order Material Number
* 049 Order Material Quantity
* 050 Order Material UOM
* 051 Order Item Plant
* 052 Order Item Product Hierarchy
* 053 Order Item Material Group 1
* 054 Order Item Usage
* 055 Order Item Material Group 4
* 056 Order Condition Type
* 057 Order Condition Pricing Date
* 058 Order Amount / Rate
* 059 Order Condition Currency
* 060 Order Condition Pricing Unit
* 061 Order Condition unit in the document
* 062 Order Condition Value
* 063 Order Access sequence - Access number
* 064 Order Condition item number
* 065 Order Step Number
* 066 Order Condition Counter
* 067 Order Calculation Type
* 068 Order Condition Base Value
* 069 Order Condition Exchange Rate
* 070 Order Condition Category
* 071 Order Scale Type
* 072 Order Statistical Condition
* 073 Order Accural Condition
* 074 Order Condition Origin
* 075 Order Group Condition
* 076 Order Account Key
* 077 Order G/L Account
* 078 Order Tax Code
* 079 Order Accurals Key
* 080 Order Document Currency
* 081 Order Inactive Condition
* 082 Order Condition Control
* 083 Order Conditon Class
* 084 Billing Document Created By
* 085 Billing Document Created On Date
* 086 Billing Document Created On Time
* 087 Billing Sales Organisation
* 088 Billing Distribution Channel
* 089 Billing Document Category
* 090 Billing Docment Billing Date
* 091 Billing Price Group
* 092 Billing Inco Terms
* 093 Billing Document Tax Classification
* 094 BIlling Procedure
* 095 Billing Item Number
* 096 Billing Material Number
* 097 Billing Material Quantity
* 098 Billing Material UOM
* 099 Billing Item Plant
* 100 Billing Item Product Hierarchy
* 101 Billing Item Material Group 1
* 102 Billing Item Usage
* 103 Billing Item Cash Discount
* 104 Billing Purchase Order Type
* 105 Billing Item Order Reason
* 106 Billing Condition Type
* 107 Billing Condition Pricing date
* 108 Billing Amount/Rate
* 109 Billing Currency
* 110 Billing Currency Pricing Unit
* 111 Billing Condition Unit in the Document
* 112 Billing Condition Value
* 113 Billing Access Sequence
* 114 Billing Conditon item Number
* 115 Billing Step Number
* 116 Billing Condition Counter
* 117 Billing Calulation Type
* 118 Billing Condition Base Value
* 119 Billing Condition Exchange Rate
* 120 Billing Condition Category
* 121 Billing Scale Type
* 122 Billing Statistical Condition
* 123 Billing Accural Condition
* 124 Billing Condition Origin
* 125 Billing Group Condition
* 126 Billing Account Key
* 127 Billing G/L Account
* 128 Billing Tax Code
* 129 Billing Accurals Key
* 130 Billing Document Currency
* 131 Billing Inactive Condition
* 132 Billing Condition Control
* 133 Billing Condition Class
* 134 Preceeding Document
* 135 Subsequent Document
* 136 Order Billing Block Description
* 137 Order Delivery Block Description
* 138 Order Price Group Description
* 139 Order Material Description
* 140 Order Item Campaign ID
* 141 Order Condition Type Description
* 142 Billing Price Group Description
* 143 Billing Material Description
* 144 Billing Condition Type Description
* 145 Billing Item Campaign ID
* 146 Billing Item Order Reason Description
* 147 Order Price Group
* 148 Order Price Group Description
* 149 Billing Sales Office
* 150 Billing Sales Group
* 151 Billing Item Material Group 4


*Selection texts
*----------------------------------------------------------
* P_DISVAR         Layout Variant
* RB_BILL         Billing Documents
* RB_ORDER         Order Documents
* S_AUART         Order Document Type
* S_DATAB         Condition Type Valid From
* S_DATBI         Condition Type Valid To
* S_ERDATB         Billing Document Created On
* S_ERDATO         Order Document Created On
* S_FKART         Billing Document Type
* S_KSCHL         Condition Type
* S_KUNAG         Order Sold-to Party
* S_KUNRG         Billing Document Payer
* S_MATNR         Material
* S_VBELNB         Billing Document Number
* S_VBELNO         Order Document Number
* S_VKORG         Sales Organization
* S_VTWEG         Distribution Channel


*Messages
*----------------------------------------------------------
*
* Message class: ZDEV

*001   Please enter a correct Sales Organization !!
*016   Please enter a correct sales document type !!
*023   Please enter valid Distribution Channel
*024   Please enter valid Billing Document Type
*031   Invalid Payer
*054   Please enter a correct sales document number
*055   no sales order data found
*056   no billing order data found
*057   no business data found
*058   no sales conditions records found
*059   no billing condition records found
*073   Invalid combination of Sales Organization and Distribution
*230   Choose valid Sales organization
*231   Activity-Change is not allowed for sales organisation & Dist
*409   Please Choose valid Material Number
*426   Please enter the correct Billing Document Number
*517   Choose valid customer (Sold to Party)
*527   Please enter the valid condition type

*Text elements
*----------------------------------------------------------
* 001 Order Document Number
* 002 Order Document Type
* 003 Ord Document Type Description
* 004 Order Document Date
* 005 Order Sold-to Party Number
* 006 Sold to party Name
* 007 Order Purchase Order Number
* 008 Order Reason
* 009 Order Pricing Date
* 010 Order Net Value
* 011 Order Currency
* 012 Order Tax Amount
* 013 Order Currency
* 014 Order Fixed Value Date
* 015 Order Additional Value Days
* 016 Order Payment Terms
* 017 Billing Document Number
* 018 Billing Document Type
* 019 Billing Document Type Description
* 020 Billing Document Date
* 021 Billing Document Status
* 022 Billing Document Cancelled
* 023 Billing Payer Number
* 024 Billing Payer Name
* 025 Billing Document Net Value
* 026 Billing Currency
* 027 Billing Tax Amount
* 028 Billing Currency
* 029 Billing Document Posting Status
* 030 Billing Reference
* 031 Billing Payment Terms
* 032 Order Document Overall Status
* 033 Order Sales Organisation
* 034 Order Division
* 035 Order Document Category
* 036 Order Document Created By
* 037 Order Document Created On
* 038 Order Billing Block
* 039 Order Delivery Block
* 040 Order Billing Date
* 041 Order Sales Office
* 042 Order Sales Group
* 043 Order Inco Terms
* 044 Order Purchase Order Type
* 045 Order Alternative Tax Classification
* 046 Order Pricing Procedure
* 047 Order Item Number
* 048 Order Material Number
* 049 Order Material Quantity
* 050 Order Material UOM
* 051 Order Item Plant
* 052 Order Item Product Hierarchy
* 053 Order Item Material Group 1
* 054 Order Item Usage
* 055 Order Item Material Group 4
* 056 Order Condition Type
* 057 Order Condition Pricing Date
* 058 Order Amount / Rate
* 059 Order Condition Currency
* 060 Order Condition Pricing Unit
* 061 Order Condition unit in the document
* 062 Order Condition Value
* 063 Order Access sequence - Access number
* 064 Order Condition item number
* 065 Order Material Number
* 066 Order Material Quantity
* 067 Order Material UOM
* 068 Order Item Plant
* 069 Order Item Product Hierarchy
* 070 Order Item Material Group 1
* 071 Order Item Usage
* 072 Order Item Material Group 4
* 073 Order Condition Type
* 074 Order Condition Pricing Date
* 075 Order Amount / Rate
* 076 Order Condition Currency
* 077 Order Condition Pricing Unit
* 078 Order Condition unit in the document
* 079 Order Condition Value
* 080 Order Access sequence - Access number
* 081 Order Condition item number
* 082 Order Step Number
* 083 Order Condition Counter
* 084 Order Calculation Type
* 085 Order Condition Base Value
* 086 Order Condition Exchange Rate
* 087 Order Condition Category
* 088 Order Scale Type
* 089 Order Statistical Condition
* 090 Order Accural Condition
* 091 Order Condition Origin
* 092 Order Group Condition
* 093 Order Account Key
* 094 Order G/L Account
* 095 Order Tax Code
* 096 Order Accurals Key
* 097 Order Document Currency
* 098 Order Inactive Condition
* 099 Order Condition Control
* 100 Order Conditon Class
* 101 Billing Document Created By
* 102 Billing Document Created On Date
* 103 Billing Document Created On Time
* 104 Billing Sales Organisation
* 105 Billing Distribution Channel
* 106 Billing Document Category
* 107 Billing Docment Billing Date
* 108 Billing Price Group
* 109 Billing Inco Terms
* 110 Billing Document Tax Classification
* 111 BIlling Procedure
* 112 Billing Item Number
* 113 Billing Material Number
* 114 Billing Material Quantity
* 115 Billing Material UOM
* 116 Billing Item Plant
* 117 Billing Item Product Hierarchy
* 118 Billing Item Material Group 1
* 119 Billing Item Usage
* 120 Billing Item Cash Discount
* 121 Billing Purchase Order Type
* 122 Billing Item Order Reason
* 123 Billing Condition Type
* 124 Billing Condition Pricing date
* 125 Billing Amount/Rate
* 126 Billing Currency
* 127 Billing Currency Pricing Unit
* 128 Billing Condition Unit in the Document
* 129 Billing Condition Value
* 130 Billing Access Sequence
* 131 Billing Conditon item Number
* 132 Billing Step Number
* 133 Billing Condition Counter
* 134 Billing Calulation Type
* 135 Billing Condition Base Value
* 136 Billing Condition Exchange Rate
* 137 Billing Condition Category
* 138 Billing Scale Type
* 139 Billing Statistical Condition
* 140 Billing Accural Condition
* 141 Billing Condition Origin
* 142 Billing Group Condition
* 143 Billing Account Key
* 144 Billing G/L Account
* 145 Billing Tax Code
* 146 Billing Accurals Key
* 147 Billing Document Currency
* 148 Billing Inactive Condition
* 149 Billing Condition Control
* 150 Billing Condition Class
* 151 Preceeding Document
* 152 Subsequent Document
* 153 Order Billing Block Description
* 154 Order Delivery Block Description
* 155 Order Price Group Description
* 156 Order Material Description
* 157 Order Item Campaign ID
* 158 Order Condition Type Description
* 159 Billing Price Group Description
* 160 Billing Material Description
* 161 Billing Condition Type Description
* 162 Billing Item Campaign ID
* 163 Billing Item Order Reason Description
* 164 Order Price Group
* 165 Order Price Group Description
* 166 Billing Sales Office
* 167 Billing Sales Group
* 168 Billing Item Material Group 4


*Selection texts
*----------------------------------------------------------
* P_DISVAR         Layout Variant
* RB_BILL         Billing
* RB_ORDER         Order Documents
* S_AUART         Order Document Type
* S_DATAB         Condition Type Valid From
* S_DATBI         Condition Type Valid To
* S_ERDATB         Billing Document Created On
* S_ERDATO         Order Document Created On
* S_FKART         Billing Document Type
* S_KSCHL         Condition Type
* S_KUNAG         Order Sold-to Party
* S_KUNRG         Billing Document Payer
* S_MATNR         Material
* S_VBELNB         Billing Document Number
* S_VBELNO         Order Document Number
* S_VKORG         Sales Organization
* S_VTWEG         Distribution Channel


*Messages
*----------------------------------------------------------
*
* Message class: ZDEV
*001   Please enter a correct Sales Organization !!
*016   Please enter a correct sales document type !!
*023   Please enter valid Distribution Channel
*024   Please enter valid Billing Document Type
*031   Invalid Payer
*054   Please enter a correct sales document number
*055   No sales order data found
*056   No billing order data found
*057   no business data found
*058   no sales conditions records found
*059   no billing condition records found
*073   Invalid combination of Sales Organization and Distribution
*      Channel
*230   Choose valid Sales organization
*231   Activity-Change is not allowed for sales organisation & Dist
*      channel
*409   Please Choose valid Material Number
*426   Please enter the correct Billing Document Number
*517   Choose valid customer (Sold to Party)
*527   Please enter the valid condition type


*Selection texts
*----------------------------------------------------------
* P_DISVAR         Layout Variant
* RB_BILL         Billing
* RB_ORDER         Order Documents
* S_AUART         Order Document Type
* S_DATAB         Condition Type Valid From
* S_DATBI         Condition Type Valid To
* S_ERDATB         Billing Document Created On
* S_ERDATO         Order Document Created On
* S_FKART         Billing Document Type
* S_KSCHL         Condition Type
* S_KUNAG         Order Sold-to Party
* S_KUNRG         Billing Document Payer
* S_MATNR         Material
* S_VBELNB         Billing Document Number
* S_VBELNO         Order Document Number
* S_VKORG         Sales Organization
* S_VTWEG         Distribution Channel


*Messages
*----------------------------------------------------------
*
* Message class: ZDEV
*001
*016
*023
*024
*031
*054
*055
*056
*057
*058
*059
*073
*230
*231
*409
*426
*517
*527


*Selection texts
*----------------------------------------------------------
* P_DISVAR         Layout Variant
* RB_BILL         Billing
* RB_ORDER         Order Documents
* S_AUART         Order Document Type
* S_DATAB         Condition Type Valid From
* S_DATBI         Condition Type Valid To
* S_ERDATB         Billing Document Created On
* S_ERDATO         Order Document Created On
* S_FKART         Billing Document Type
* S_KSCHL         Condition Type
* S_KUNAG         Order Sold-to Party
* S_KUNRG         Billing Document Payer
* S_MATNR         Material
* S_VBELNB         Billing Document Number
* S_VBELNO         Order Document Number
* S_VKORG         Sales Organization
* S_VTWEG         Distribution Channel


*Messages
*----------------------------------------------------------
*
* Message class: ZDEV
*001
*016
*023
*024
*031
*054
*055
*056
*057
*058
*059
*073
*230
*231
*409
*426
*517
*527

*Text elements
*----------------------------------------------------------
* 001 Order Document Number
* 002 Order Document Type
* 003 Ord Document Type Description
* 004 Order Document Date
* 005 Order Sold-to Party Number
* 006 Sold to party Name
* 007 Order Purchase Order Number
* 008 Order Reason
* 009 Order Pricing Date
* 010 Order Net Value
* 011 Order Currency
* 012 Order Tax Amount
* 013 Order Currency
* 014 Order Fixed Value Date
* 015 Order Additional Value Days
* 016 Order Payment Terms
* 017 Billing Document Number
* 018 Billing Document Type
* 019 Billing Document Type Description
* 020 Billing Document Date
* 021 Billing Document Status
* 022 Billing Document Cancelled
* 023  Billing Payer Number
* 024 Billing Payer Name
* 025 Billing Document Net Value
* 026 Billing Currency
* 027 Billing Tax Amount
* 028 Billing Currency
* 029 Billing Document Posting Status
* 030 Billing Reference
* 031 Billing Payment Terms
* 032 Order Document Overall Status
* 033 Order Sales Organisation
* 034 Order Division
* 035 Order Document Category
* 036 Order Document Created By
* 037 Order Document Created On
* 038 Order Billing Block
* 039 Order Delivery Block
* 040 Order Billing Date
* 041 Order Sales Office
* 042 Order Sales Group
* 043 Order Inco Terms
* 044 Order Purchase Order Type
* 045 Order Alternative Tax Classification
* 046 Order Pricing Procedure
* 047 Order Item Number
* 048 Order Material Number
* 049 Order Material Quantity
* 050 Order Material UOM
* 051 Order Item Plant
* 052 Order Item Product Hierarchy
* 053 Order Item Material Group 1
* 054 Order Item Usage
* 055 Order Item Material Group 4
* 056 Order Condition Type
* 057 Order Condition Pricing Date
* 058 Order Amount / Rate
* 059 Order Condition Currency
* 060 Order Condition Pricing Unit
* 061 Order Condition unit in the document
* 062 Order Condition Value
* 063 Order Access sequence - Access number
* 064 Order Condition item number
* 065 Order Material Number
* 066 Order Material Quantity
* 067 Order Material UOM
* 068 Order Item Plant
* 069 Order Item Product Hierarchy
* 070 Order Item Material Group 1
* 071 Order Item Usage
* 072 Order Item Material Group 4
* 073 Order Condition Type
* 074 Order Condition Pricing Date
* 075 Order Amount / Rate
* 076 Order Condition Currency
* 077 Order Condition Pricing Unit
* 078 Order Condition unit in the document
* 079 Order Condition Value
* 080 Order Access sequence - Access number
* 081 Order Condition item number
* 082 Order Step Number
* 083 Order Condition Counter
* 084 Order Calculation Type
* 085 Order Condition Base Value
* 086 Order Condition Exchange Rate
* 087 Order Condition Category
* 088 Order Scale Type
* 089 Order Statistical Condition
* 090 Order Accural Condition
* 091 Order Condition Origin
* 092 Order Group Condition
* 093 Order Account Key
* 094 Order G/L Account
* 095 Order Tax Code
* 096 Order Accurals Key
* 097 Order Document Currency
* 098 Order Inactive Condition
* 099 Order Condition Control
* 100 Order Conditon Class
* 101 Billing Document Created By
* 102 Billing Document Created On Date
* 103 Billing Document Created On Time
* 104 Billing Sales Organisation
* 105 Billing Distribution Channel
* 106 Billing Document Category
* 107 Billing Docment Billing Date
* 108 Billing Price Group
* 109 Billing Inco Terms
* 110 Billing Document Tax Classification
* 111 BIlling Procedure
* 112 Billing Item Number
* 113 Billing Material Number
* 114 Billing Material Quantity
* 115 Billing Material UOM
* 116 Billing Item Plant
* 117 Billing Item Product Hierarchy
* 118 Billing Item Material Group 1
* 119 Billing Item Usage
* 120 Billing Item Cash Discount
* 121 Billing Purchase Order Type
* 122 Billing Item Order Reason
* 123 Billing Condition Type
* 124 Billing Condition Pricing date
* 125 Billing Amount/Rate
* 126 Billing Currency
* 127 Billing Currency Pricing Unit
* 128 Billing Condition Unit in the Document
* 129 Billing Condition Value
* 130 Billing Access Sequence
* 131 Billing Conditon item Number
* 132 Billing Step Number
* 133 Billing Condition Counter
* 134 Billing Calulation Type
* 135 Billing Condition Base Value
* 136 Billing Condition Exchange Rate
* 137 Billing Condition Category
* 138 Billing Scale Type
* 139 Billing Statistical Condition
* 140 Billing Accural Condition
* 141 Billing Condition Origin
* 142 Billing Group Condition
* 143 Billing Account Key
* 144 Billing G/L Account
* 145 Billing Tax Code
* 146 Billing Accurals Key
* 147 Billing Document Currency
* 148 Billing Inactive Condition
* 149 Billing Condition Control
* 150 Billing Condition Class
* 151 Preceeding Document
* 152 Subsequent Document
* 153 Order Billing Block Description
* 154 Order Delivery Block Description
* 155 Order Price Group Description
* 156 Order Material Description
* 157 Order Item Campaign ID
* 158 Order Condition Type Description
* 159 Billing Price Group Description
* 160 Billing Material Description
* 161 Billing Condition Type Description
* 162 Billing Item Campaign ID
* 163 Billing Item Order Reason Description
* 164 Order Price Group
* 165 Order Price Group Description
* 166 Billing Sales Office
* 167 Billing Sales Group
* 168 Billing Item Material Group 4


*Selection texts
*----------------------------------------------------------
* P_DISVAR         Layout Variant
* RB_BILL         Billing
* RB_ORDER         Order Documents
* S_AUART         Order Document Type
* S_DATAB         Condition Type Valid From
* S_DATBI         Condition Type Valid To
* S_ERDATB         Billing Document Created On
* S_ERDATO         Order Document Created On
* S_FKART         Billing Document Type
* S_KSCHL         Condition Type
* S_KUNAG         Order Sold-to Party
* S_KUNRG         Billing Document Payer
* S_MATNR         Material
* S_VBELNB         Billing Document Number
* S_VBELNO         Order Document Number
* S_VKORG         Sales Organization
* S_VTWEG         Distribution Channel


*Messages
*----------------------------------------------------------
*
* Message class: ZDEV
*001
*016
*023
*024
*031
*054
*055
*056
*057
*058
*059
*073
*230
*231
*409
*426
*517
*527

----
  • No labels