02 July 2014

Provide

Provide command allows you to perform search overlap between to table
with different date.
Data:
Tab01.
date_from      date_to
01.01.2011     10.01.2011
01.02.2011     10.02.2011
01.03.2011     31.12.9999

Tab02.
05.01.2011     15.01.2011
25.01.2011     31.01.2011
05.02.2011     31.12.9999




Report: ZTEST_ITM_QRY
*&---------------------------------------------------------------------*
*& Report  ZTEST_ITM_QRY
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

report  ztest_itm_qry.

types: begin of vend_ret_type,
       sort_level(2)    type n,
       level(20),
       net_pur_price    like zret_item_query_prices-net_pur_price,
       kbetr            type konp-kbetr,
       net_pr           type konp-kbetr,
       tot_store_credit type konp-kbetr,
       datab            type datab,
       datbi            type datbi.
types: end of vend_ret_type.

data: gt_a867            type table of a867,
      gs_a867            type          a867,
      gt_konp            type table of konp,
      gs_konp            type          konp.

data: gt_prices          type zret_item_query_prices_tt.
data: gs_prices          type zret_item_query_prices.

data : vend_it           type standard table of vend_ret_type,
       vend_wa           type vend_ret_type .

data: gv_lifnr(10)       type n value '0000231125',
      gv_matnr(18)       type n value '000000000021002054',
      gv_cmatnr(18),
      gv_work_date       type sy-datum,
      gv_end_calc_date   type i.
data: flag1(1)           type c,
      flag2(1)           type c.

start-of-selection.
  gs_prices-sort_level       = '01'.
  gs_prices-price_list_level = 'Global1'.
  gs_prices-vendor           = '0000231125'.
  gs_prices-gross_pur_price  = '7.8700'.
  gs_prices-net_pur_price    = '7.8700'.
  gs_prices-sale_price       = '17.9900'.
  gs_prices-profit           = '49.25%'.
  gs_prices-date_from        = '20080201'.
  gs_prices-date_to          = '20081213'.
  append: gs_prices to gt_prices.
  gs_prices-sort_level       = '01'.
  gs_prices-price_list_level = 'Global2'.
  gs_prices-vendor           = '0000231125'.
  gs_prices-gross_pur_price  = '7.0800'.
  gs_prices-net_pur_price    = '7.0800'.
  gs_prices-sale_price       = '17.9900'.
  gs_prices-profit           = '54.35%'.
  gs_prices-date_from        = '20081214'.
  gs_prices-date_to          = '20090110'.
  append: gs_prices to gt_prices.
  gs_prices-sort_level       = '01'.
  gs_prices-price_list_level = 'Global3'.
  gs_prices-vendor           = '0000231125'.
  gs_prices-gross_pur_price  = '7.8700'.
  gs_prices-net_pur_price    = '7.8700'.
  gs_prices-sale_price       = '17.9900'.
  gs_prices-profit           = '49.25%'.
  gs_prices-date_from        = '20090111'.
  gs_prices-date_to          = '20090112'.
  append: gs_prices to gt_prices.
  gs_prices-sort_level       = '01'.
  gs_prices-price_list_level = 'Global4'.
  gs_prices-vendor           = '0000231125'.
  gs_prices-gross_pur_price  = '7.8700'.
  gs_prices-net_pur_price    = '7.8700'.
  gs_prices-sale_price       = '17.9900'.
  gs_prices-profit           = '49.25%'.
  gs_prices-date_from        = '20090113'.
  gs_prices-date_to          = '20090219'.
  append: gs_prices to gt_prices.
  gs_prices-sort_level       = '01'.
  gs_prices-price_list_level = 'Global5'.
  gs_prices-vendor           = '0000231125'.
  gs_prices-gross_pur_price  = '7.8700'.
  gs_prices-net_pur_price    = '7.8700'.
  gs_prices-sale_price       = '17.9900'.
  gs_prices-profit           = '49.25%'.
  gs_prices-date_from        = '20090220'.
  gs_prices-date_to          = '20090228'.
  append: gs_prices to gt_prices.
  gs_prices-sort_level       = '01'.
  gs_prices-price_list_level = 'Global6'.
  gs_prices-vendor           = '0000231125'.
  gs_prices-gross_pur_price  = '7.8700'.
  gs_prices-net_pur_price    = '7.8700'.
  gs_prices-sale_price       = '17.9900'.
  gs_prices-profit           = '49.25%'.
  gs_prices-date_from        = '20090301'.
  gs_prices-date_to          = '20090803'.
  append: gs_prices to gt_prices.
  gs_prices-sort_level       = '01'.
  gs_prices-price_list_level = 'Global7'.
  gs_prices-vendor           = '0000231125'.
  gs_prices-gross_pur_price  = '7.8700'.
  gs_prices-net_pur_price    = '7.8700'.
  gs_prices-sale_price       = '17.9900'.
  gs_prices-profit           = '49.25%'.
  gs_prices-date_from        = '20090804'.
  gs_prices-date_to          = '99991231'.
  append: gs_prices to gt_prices.




  gs_a867-kappl = 'M'.
  gs_a867-kschl = 'ZRIT'.
  gs_a867-ekorg = '0017'.
  gs_a867-lifnr = '0000231125'.
  gs_a867-matnr = '000000000021002054'.
  gs_a867-datbi = '20081228'.
  gs_a867-datab = '20080801'.
  gs_a867-knumh = '0001101748'.
  append: gs_a867 to gt_a867.

  gs_a867-kappl = 'M'.
  gs_a867-kschl = 'ZRIT'.
  gs_a867-ekorg = '0017'.
  gs_a867-lifnr = '0000231125'.
  gs_a867-matnr = '000000000021002054'.
  gs_a867-datbi = '20090704'.
  gs_a867-datab = '20081229'.
  gs_a867-knumh = '0001102088'.
  append: gs_a867 to gt_a867.

  gs_a867-kappl = 'M'.
  gs_a867-kschl = 'ZRIT'.
  gs_a867-ekorg = '0017'.
  gs_a867-lifnr = '0000231125'.
  gs_a867-matnr = '000000000021002054'.
  gs_a867-datbi = '99991231'.
  gs_a867-datab = '20090705'.
  gs_a867-knumh = '0001105547'.
  append: gs_a867 to gt_a867.


  provide fields knumh from gt_a867 into gs_a867
                                    valid flag1
                                    bounds datab and datbi
          fields price_list_level from gt_prices into gs_prices
                                     valid flag2
                                     bounds date_from and date_to

           between '20070101' and '99991231'.

    if gs_a867-datab gt gs_prices-date_from.
      write: / gs_a867-datab.
    else.
      write: / gs_prices-date_from .
    endif.
    if gs_a867-datbi lt gs_prices-date_to.
      write: gs_a867-datbi .
    else.
      write: gs_prices-date_to .
    endif.

    skip.
  endprovide.
*&---------------------------------------------------------------------*
*&      Form  GET_A867
*&---------------------------------------------------------------------*
form get_a867     using vendor
                        matnr
                        date_to
                        date_from
               changing gs_a867.

  loop at gt_a867 into gs_a867 where kappl = 'M'
                               and   kschl = 'ZRIT'
                               and   ekorg = '0017'
                               and   lifnr =  vendor
                               and   matnr =  matnr
                               and   datbi <> '19000101'
                               and   datab <= date_to
                               and   datbi >= date_from.
    exit.
  endloop.

endform.                                                    " GET_A867


Result:





No comments:

Post a Comment