Advertisement
sinke

ZFI30300_CLASSES

Nov 10th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 28.77 KB | None | 0 0
  1.  
  2. Code listing for: ZFI30300_CLASSES
  3. Description: Klase za program ZFI30300
  4. *&---------------------------------------------------------------------*
  5. *&  Include           ZFI30300_CLASSES
  6. *&---------------------------------------------------------------------*
  7. class lcl_app definition.
  8.   public section.
  9.     types:
  10.             t_zpci        type p length 8 decimals 2,
  11.  
  12.             begin of t_ska1,
  13.               saknr_lact type saknr,
  14.               saknr_grup type saknr,
  15.               saknr_podu type saknr,
  16.             end of t_ska1,
  17.  
  18.             begin of t_out,
  19.               bukrs       type  bukrs,
  20.               butxt       type  butxt,
  21.               saknr_lact  type  saknr,
  22.               txt50_lact  type  txt50_skat,
  23.               saknr_kons  type  saknr,
  24.               txt50_kons  type  txt50_skat,
  25.               ktopl       type  ktopl,
  26.               saknr       type  saknr,
  27.               txt50       type  txt50_skat,
  28.               matnr       type  matnr,
  29.               maktx       type  maktx,
  30.               meins       type  meins,
  31.               waers       type  waers,
  32.               werks       type  werks_d,
  33.               name1       type  t001w-name1,
  34.               lbkum_i     type  lbkum,
  35.               salk3_i     type  salk3,
  36.               zpci_i      type  t_zpci,
  37.               salk3pci_i  type  salk3,
  38.               salk3eur_i  type  salk3,
  39.               lbkum_u     type  lbkum,
  40.               salk3_u     type  salk3,
  41.               zpci_u      type  t_zpci,
  42.               salk3pci_u  type  salk3,
  43.               salk3eur_u  type  salk3,
  44.             end of t_out,
  45.  
  46.             begin of t_co_pci,
  47.               kadky       type ckhs-kadky,
  48.               hwges       type ckhs-hwges,
  49.               menge       type ckhs-menge,
  50.             end of t_co_pci,
  51.  
  52.             tt_ska1                   type hashed table of t_ska1 with unique key saknr_podu,
  53.             tt_out                    type standard table of t_out.
  54.  
  55.     class-data:
  56.         app type ref to lcl_app.
  57.  
  58.     class-methods:
  59.       make_it_so,
  60.       f4_saknr_lact,
  61.       f4_saknr,
  62.       authority_check,
  63.       find_layout,
  64.       check_layout.
  65.  
  66.  
  67.     data:
  68.       mt_out                          type tt_out,
  69.       mt_fc                           type lvc_t_fcat.
  70.  
  71.     methods:
  72.       constructor,
  73.       main,
  74.       handle_pbo,
  75.       handle_pai                      importing i_ucomm     type syucomm.
  76.  
  77.   private section.
  78.  
  79.     data:
  80.       mt_t001                         type hashed table of t001 with unique key bukrs,
  81.       mt_ska1                         type tt_ska1,
  82.       mt_skat                         type hashed table of skat with unique key ktopl saknr,
  83.       mt_makt                         type hashed table of makt with unique key matnr,
  84.       mt_t001w                        type hashed table of t001w with unique key werks,
  85.       mt_zbfrpci                      type standard table of zbfrpci,
  86.       mt_zbfrklvar                    type standard table of zbfrklvar,
  87.       m_last_date_report              type d,
  88.       m_last_date_compare             type d.
  89.  
  90.     data:
  91.       m_alv                           type ref to cl_gui_alv_grid,
  92.       m_splitter                      type ref to cl_gui_splitter_container,
  93.       m_container                     type ref to cl_gui_container,
  94.       m_html_container                type ref to cl_gui_container,
  95.       m_header_document               type ref to cl_dd_document.
  96.  
  97.  
  98.     methods:
  99.       select_data,
  100.       get_sd_pci                      importing   i_matnr       type matnr
  101.                                                   i_date        type d
  102.                                       returning   value(r_pci)  type t_zpci
  103.                                       exceptions  not_found,
  104.       get_co_pci                      importing   i_matnr       type matnr
  105.                                                   i_date        type d
  106.                                                   i_werks       type werks_d
  107.                                       returning   value(r_pci)  type t_zpci,
  108.       build_fc                        changing    c_fc          type lvc_t_fcat,
  109.       display_header.
  110.  
  111. endclass. "lcl_app DEFINITION
  112.  
  113.  
  114. *----------------------------------------------------------------------*
  115. *       CLASS lcl_app IMPLEMENTATION
  116. *----------------------------------------------------------------------*
  117. *
  118. *----------------------------------------------------------------------*
  119. class lcl_app implementation.
  120.  
  121.   method make_it_so.
  122.     if lcl_app=>app is initial.
  123.       create object lcl_app=>app.
  124.     endif.
  125.  
  126.     lcl_app=>app->main( ).
  127.   endmethod.                    "make_it_so
  128.  
  129.  
  130.  
  131.   method constructor.
  132.  
  133.  
  134.     concatenate s_spmoni-low '01' into me->m_last_date_report.
  135.     concatenate s_spmonu-low '01' into me->m_last_date_compare.
  136.  
  137.     call function 'RP_LAST_DAY_OF_MONTHS'
  138.       exporting
  139.         day_in            = me->m_last_date_report
  140.       importing
  141.         last_day_of_month = me->m_last_date_report
  142.       exceptions
  143.         day_in_no_date    = 1
  144.         others            = 2.
  145.     if sy-subrc <> 0.
  146.       message id sy-msgid type sy-msgty number sy-msgno
  147.               with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  148.     endif.
  149.  
  150.  
  151.     call function 'RP_LAST_DAY_OF_MONTHS'
  152.       exporting
  153.         day_in            = me->m_last_date_compare
  154.       importing
  155.         last_day_of_month = me->m_last_date_compare
  156.       exceptions
  157.         day_in_no_date    = 1
  158.         others            = 2.
  159.     if sy-subrc <> 0.
  160.       message id sy-msgid type sy-msgty number sy-msgno
  161.               with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  162.     endif.
  163.  
  164.     me->build_fc( changing  c_fc  = me->mt_fc ).
  165.  
  166. *   Daj mi sva konta na svijetu, svaèija...sve mi poveži... to mi treba... to mi radi. aaaaaaa...
  167.     select distinct
  168.       ska1_poduzeca~saknr as saknr_podu
  169.       ska1_grupe~saknr as saknr_grup
  170.       zlkon01~saknr as saknr_lact
  171.     into corresponding fields of table me->mt_ska1
  172.     from
  173.         zlkon01 inner join ska1 as ska1_grupe on
  174.           zlkon01~saknr = ska1_grupe~bilkt
  175.         inner join ska1 as ska1_poduzeca on
  176.           ska1_poduzeca~bilkt = ska1_grupe~saknr
  177.         inner join t001 on
  178.           ska1_poduzeca~ktopl = t001~ktopl
  179.     where
  180.         zlkon01~zstock <> '' and
  181.         ska1_grupe~ktopl = 'KONS' and
  182.         t001~bukrs in s_bukrs and
  183.         zlkon01~saknr in s_saknrl and
  184.         ska1_poduzeca~saknr in s_saknr.
  185.  
  186.  
  187.     select * from t001 into table me->mt_t001 where bukrs in s_bukrs.
  188.  
  189.     select * from skat into table me->mt_skat where spras = sy-langu.
  190.  
  191.     select * from makt into table me->mt_makt where spras = sy-langu.
  192.  
  193.     select * from t001w into table me->mt_t001w.
  194.  
  195.  
  196.   endmethod.                    "constructor
  197.  
  198.  
  199.  
  200.   method main.
  201.  
  202.  
  203.     me->select_data( ).
  204.  
  205.     call screen 100.
  206.   endmethod.                    "main
  207.  
  208.  
  209.  
  210.   method select_data.
  211.     data: lt_zbfrstock_i  type hashed table of zbfrstock with unique key bukrs bwkey zktopo zktogr zktola matnr,
  212.           ls_zbfrstock_i  type zbfrstock,
  213.           lt_zbfrstock_u  type hashed table of zbfrstock with unique key bukrs bwkey zktopo zktogr zktola matnr,
  214.           ls_zbfrstock_u  type zbfrstock,
  215.           ls_out          type t_out,
  216.           ls_skat         type skat,
  217.           ls_makt         type makt,
  218.           ls_t001         type t001,
  219.           ls_t001w        type t001w,
  220.           ls_exch_rate    type bapi1093_0,
  221.           l_sobsk         type marc-sobsk.
  222.  
  223.     field-symbols: <out>    type t_out.
  224.  
  225.  
  226.     select
  227.       bukrs
  228.       bwkey
  229.       zktopo
  230.       zktogr
  231.       zktola
  232.       matnr
  233.       meins
  234.       waers
  235.       sum( lbkum ) as lbkum
  236.       sum( salk3 ) as salk3
  237.     from
  238.       zbfrstock
  239.     into
  240.       corresponding fields of table lt_zbfrstock_i
  241.     where
  242.       bukrs   in  s_bukrs and
  243.       zktopo  in  s_saknr and
  244.       zktola  in  s_saknrl and
  245.       ryear   =   s_spmoni-low(4) and
  246.       zmm     =   s_spmoni-low+4(2) and
  247.       matnr   in s_matnr
  248.      group by
  249.       bukrs
  250.       bwkey
  251.       zktopo
  252.       zktogr
  253.       zktola
  254.       matnr
  255.       meins
  256.       waers.
  257.  
  258.     select
  259.       bukrs
  260.       bwkey
  261.       zktopo
  262.       zktogr
  263.       zktola
  264.       matnr
  265.       meins
  266.       waers
  267.       sum( lbkum ) as lbkum
  268.       sum( salk3 ) as salk3
  269.     from
  270.       zbfrstock
  271.     into
  272.       corresponding fields of table lt_zbfrstock_u
  273.     where
  274.       bukrs   in  s_bukrs and
  275.       zktopo  in  s_saknr and
  276.       zktola  in  s_saknrl and
  277.       ryear   =   s_spmonu-low(4) and
  278.       zmm     =   s_spmonu-low+4(2) and
  279.       matnr   in s_matnr
  280.      group by
  281.       bukrs
  282.       bwkey
  283.       zktopo
  284.       zktogr
  285.       zktola
  286.       matnr
  287.       meins
  288.       waers.
  289.  
  290.     loop at lt_zbfrstock_i into ls_zbfrstock_i.
  291.       clear: ls_out-werks, l_sobsk.
  292.  
  293.       move-corresponding ls_zbfrstock_i to ls_out.
  294.  
  295.       ls_out-saknr_lact = ls_zbfrstock_i-zktola.
  296.       ls_out-saknr_kons = ls_zbfrstock_i-zktogr.
  297.       ls_out-saknr = ls_zbfrstock_i-zktopo.
  298.  
  299.       read table lt_zbfrstock_u
  300.         with table key
  301.           bukrs       = ls_zbfrstock_i-bukrs
  302.           bwkey       = ls_zbfrstock_i-bwkey
  303.           zktopo      = ls_zbfrstock_i-zktopo
  304.           zktogr      = ls_zbfrstock_i-zktogr
  305.           zktola      = ls_zbfrstock_i-zktola
  306.           matnr       = ls_zbfrstock_i-matnr
  307.        into
  308.         ls_zbfrstock_u.
  309.       if sy-subrc <> 0.
  310.         clear ls_zbfrstock_u.
  311.       endif.
  312.  
  313.  
  314.       ls_out-lbkum_i = ls_zbfrstock_i-lbkum.
  315.       ls_out-salk3_i = ls_zbfrstock_i-salk3.
  316.       ls_out-lbkum_u = ls_zbfrstock_u-lbkum.
  317.       ls_out-salk3_u = ls_zbfrstock_u-salk3.
  318.  
  319.       select
  320.         single t460a~wrk02 marc~sobsk
  321.       from
  322.         t460a inner join marc on
  323.           t460a~werks = marc~werks and
  324.           t460a~sobsl = marc~sobsk
  325.       into
  326.         (ls_out-werks, l_sobsk)
  327.       where
  328.         t460a~werks = ls_zbfrstock_i-bwkey and
  329.         marc~matnr = ls_zbfrstock_i-matnr.
  330.  
  331.       if sy-subrc = 0 and l_sobsk = '52'.
  332.         ls_out-werks = ls_zbfrstock_i-bwkey.
  333.       endif.
  334.  
  335.  
  336.       collect ls_out into me->mt_out.
  337.     endloop.
  338.  
  339. *   Sad još moram nadoštukat ove kojih imam u usporednom razdoblju a nemam u izvještajnom...
  340.     loop at lt_zbfrstock_u into ls_zbfrstock_u.
  341.  
  342.       read table lt_zbfrstock_i
  343.         with table key
  344.           bukrs       = ls_zbfrstock_u-bukrs
  345.           bwkey       = ls_zbfrstock_u-bwkey
  346.           zktopo      = ls_zbfrstock_u-zktopo
  347.           zktogr      = ls_zbfrstock_u-zktogr
  348.           zktola      = ls_zbfrstock_u-zktola
  349.           matnr       = ls_zbfrstock_u-matnr
  350.        transporting no fields.
  351.       if sy-subrc = 0.
  352.         continue.
  353.       endif.
  354.  
  355.       clear: ls_out, l_sobsk.
  356.  
  357.       move-corresponding ls_zbfrstock_u to ls_out.
  358.  
  359.       ls_out-saknr_lact = ls_zbfrstock_u-zktola.
  360.       ls_out-saknr_kons = ls_zbfrstock_u-zktogr.
  361.       ls_out-saknr = ls_zbfrstock_u-zktopo.
  362.  
  363.       ls_out-lbkum_u = ls_zbfrstock_u-lbkum.
  364.       ls_out-salk3_u = ls_zbfrstock_u-salk3.
  365.  
  366.       select
  367.         single t460a~wrk02 marc~sobsk
  368.       from
  369.         t460a inner join marc on
  370.           t460a~werks = marc~werks and
  371.           t460a~sobsl = marc~sobsk
  372.       into
  373.         (ls_out-werks, l_sobsk)
  374.       where
  375.         t460a~werks = ls_zbfrstock_u-bwkey and
  376.         marc~matnr = ls_zbfrstock_u-matnr.
  377.  
  378.       if sy-subrc = 0 and l_sobsk = '52'.
  379.         ls_out-werks = ls_zbfrstock_u-bwkey.
  380.       endif.
  381.  
  382.       collect ls_out into me->mt_out.
  383.  
  384.     endloop.
  385.  
  386.  
  387.     loop at me->mt_out assigning <out>.
  388. *     Prvo tražim PCI u SD cijeniku, pa ako ga ne naðem onda tražim u CO
  389.       call method me->get_sd_pci
  390.         exporting
  391.           i_matnr   = <out>-matnr
  392.           i_date    = me->m_last_date_report
  393.         receiving
  394.           r_pci     = <out>-zpci_i
  395.         exceptions
  396.           not_found = 1.
  397.       if sy-subrc = 1.
  398.         <out>-zpci_i = me->get_co_pci( i_matnr = <out>-matnr
  399.                                         i_date = me->m_last_date_report
  400.                                         i_werks = <out>-werks ).
  401.       endif.
  402.  
  403.  
  404.       call method me->get_sd_pci
  405.         exporting
  406.           i_matnr   = <out>-matnr
  407.           i_date    = me->m_last_date_compare
  408.         receiving
  409.           r_pci     = <out>-zpci_u
  410.         exceptions
  411.           not_found = 1.
  412.       if sy-subrc = 1.
  413.         <out>-zpci_u = me->get_co_pci( i_matnr = <out>-matnr
  414.                                         i_date = me->m_last_date_compare
  415.                                         i_werks = <out>-werks ).
  416.       endif.
  417.  
  418.       <out>-salk3pci_i = <out>-lbkum_i * <out>-zpci_i.
  419.       <out>-salk3pci_u = <out>-lbkum_u * <out>-zpci_u.
  420.  
  421.       call function 'BAPI_EXCHANGERATE_GETDETAIL'
  422.         exporting
  423.           rate_type  = p_kurst
  424.           from_curr  = 'EUR'
  425.           to_currncy = <out>-waers
  426.           date       = me->m_last_date_report
  427.         importing
  428.           exch_rate  = ls_exch_rate.
  429.  
  430.       if ls_exch_rate-exch_rate <> 0.
  431.         if <out>-salk3pci_i <> 0.
  432.           <out>-salk3eur_i = <out>-salk3pci_i / ls_exch_rate-exch_rate.
  433.         else.
  434.           <out>-salk3eur_i = <out>-salk3_i / ls_exch_rate-exch_rate.
  435.         endif.
  436.       else.
  437.         clear <out>-salk3eur_i.
  438.       endif.
  439.  
  440.  
  441.       call function 'BAPI_EXCHANGERATE_GETDETAIL'
  442.         exporting
  443.           rate_type  = p_kurst
  444.           from_curr  = 'EUR'
  445.           to_currncy = <out>-waers
  446.           date       = me->m_last_date_compare
  447.         importing
  448.           exch_rate  = ls_exch_rate.
  449.  
  450.       if ls_exch_rate-exch_rate <> 0.
  451.         if <out>-salk3pci_u <> 0.
  452.           <out>-salk3eur_u = <out>-salk3pci_u / ls_exch_rate-exch_rate.
  453.         else.
  454.           <out>-salk3eur_u = <out>-salk3_u / ls_exch_rate-exch_rate.
  455.         endif.
  456.       else.
  457.         clear <out>-salk3eur_u.
  458.       endif.
  459.  
  460. *     Nazivi iz matiènih...
  461.       read table me->mt_t001 with table key bukrs = <out>-bukrs into ls_t001.
  462.       if sy-subrc = 0.
  463.         <out>-butxt = ls_t001-butxt.
  464.         <out>-ktopl = ls_t001-ktopl.
  465.       endif.
  466.  
  467.       read table me->mt_skat with table key ktopl = <out>-ktopl saknr = <out>-saknr into ls_skat.
  468.       if sy-subrc = 0.
  469.         <out>-txt50 = ls_skat-txt50.
  470.       endif.
  471.  
  472.       read table me->mt_skat with table key ktopl = 'KONS' saknr = <out>-saknr_kons into ls_skat.
  473.       if sy-subrc = 0.
  474.         <out>-txt50_kons = ls_skat-txt50.
  475.       endif.
  476.  
  477.       read table me->mt_skat with table key ktopl = 'LACT' saknr = <out>-saknr_lact into ls_skat.
  478.       if sy-subrc = 0.
  479.         <out>-txt50_lact = ls_skat-txt50.
  480.       endif.
  481.  
  482.       read table me->mt_makt with table key matnr = <out>-matnr into ls_makt.
  483.       if sy-subrc = 0.
  484.         <out>-maktx = ls_makt-maktx.
  485.       endif.
  486.  
  487.       read table me->mt_t001w with table key werks = <out>-werks into ls_t001w.
  488.       if sy-subrc = 0.
  489.         <out>-name1 = ls_t001w-name1.
  490.       endif.
  491.  
  492.     endloop.
  493.  
  494.  
  495.   endmethod.                    "select_data
  496.  
  497.  
  498.  
  499.   method get_sd_pci.
  500.     data: l_kbetr type konp-kbetr,
  501.           l_kpein type konp-kpein.
  502.  
  503.     select single
  504.       konp~kbetr konp~kpein
  505.     from a550 inner join konp on
  506.       a550~knumh = konp~knumh
  507.     into
  508.       (l_kbetr, l_kpein)
  509.     where
  510.       a550~kappl = 'V' and
  511.       a550~kschl in s_kschl and
  512.       a550~matnr = i_matnr and
  513.       a550~datab <= i_date and
  514.       a550~datbi >= i_date.
  515.  
  516.     if sy-subrc <> 0.
  517.       raise not_found.
  518.     endif.
  519.  
  520.     r_pci = l_kbetr / l_kpein.
  521.  
  522.   endmethod.                    "get_sd_pci
  523.  
  524.  
  525.   method get_co_pci.
  526.     data: lt_co_pci     type standard table of t_co_pci,
  527.           ls_co_pci     type t_co_pci,
  528.           lt_zbfrklvar  type standard table of zbfrklvar,
  529.           lt_zbfrpci    type standard table of zbfrpci,
  530.           ls_zbfrklvar  type zbfrklvar,
  531.           ls_zbfrpci    type zbfrpci.
  532.  
  533.  
  534.     select single * from zbfrklvar into ls_zbfrklvar where werks = i_werks and begda <= i_date and endda >= i_date.
  535.  
  536.     select single * from zbfrpci into ls_zbfrpci where werks = i_werks and begda <= i_date and endda >= i_date.
  537.  
  538.     select
  539.       ckhs~kadky ckhs~hwges ckhs~menge
  540.     from
  541.       ckhs inner join keko on
  542.         ckhs~bzobj = keko~bzobj and
  543.         ckhs~kalnr = keko~kalnr and
  544.         ckhs~kalka = keko~kalka and
  545.         ckhs~kadky = keko~kadky and
  546.         ckhs~tvers = keko~tvers and
  547.         ckhs~bwvar = keko~bwvar
  548.       inner join tka02 on
  549.         keko~kokrs = tka02~kokrs
  550.     into
  551.       corresponding fields of table lt_co_pci
  552.     where
  553.       ckhs~lednr = '00' and
  554.       ckhs~bzobj = '00' and
  555.       ckhs~bukrs in s_bukrs and
  556.       ckhs~kadky between ls_zbfrklvar-begda and ls_zbfrklvar-endda and
  557.       keko~matnr = i_matnr and
  558.       tka02~bukrs in s_bukrs and
  559.       keko~werks = i_werks and
  560.       keko~sowrk = '' and
  561.       keko~klvar = ls_zbfrklvar-klvar.
  562.  
  563.  
  564.     sort lt_co_pci by kadky ascending.
  565.     read table lt_co_pci into ls_co_pci index 1.
  566.  
  567.     r_pci = ( ls_co_pci-hwges / ls_co_pci-menge ).
  568.     r_pci =  r_pci + ( r_pci * ls_zbfrpci-pcimp / 100 ).
  569.  
  570. *    r_pci * ( 1 + ( ls_zbfrpci-pcimp / 100 ) ) .
  571.  
  572.  
  573.   endmethod.                    "get_co_pci
  574.  
  575.   method handle_pbo.
  576.     data: ls_layo     type lvc_s_layo,
  577.           variant     type disvariant.
  578.  
  579.  
  580.     set pf-status 'PF100'.
  581.     set titlebar 'TB100'.
  582.  
  583.     if me->m_splitter is initial.
  584.       create object me->m_splitter
  585.         exporting
  586.           parent  = cl_gui_container=>default_screen
  587.           rows    = 2
  588.           columns = 1.
  589.  
  590.       me->m_splitter->set_row_height( exporting height = 120
  591.                                                 id     = 1 ).
  592.  
  593.       me->m_html_container = me->m_splitter->get_container( row    = 1
  594.                                                             column = 1 ).
  595.  
  596.     endif.
  597.  
  598.     me->m_splitter->set_row_mode( mode = cl_gui_splitter_container=>mode_absolute ).
  599.  
  600.     if me->m_alv is initial.
  601.  
  602.       me->m_container = me->m_splitter->get_container(  row    = 2
  603.                                                         column = 1 ).
  604.  
  605.  
  606.  
  607.       create object me->m_alv
  608.         exporting
  609.           i_parent = me->m_container.
  610.  
  611.       ls_layo-cwidth_opt  = 'X'.
  612.  
  613.       ls_layo-grid_title = ''.
  614.  
  615.  
  616.       variant-report      = sy-repid.
  617.       variant-username    = sy-uname.
  618.       variant-variant     = p_layout.
  619.  
  620.  
  621.       me->m_alv->set_table_for_first_display(  exporting  is_layout             = ls_layo
  622.                                                           i_save                = 'A'
  623.                                                           i_default             = 'X'
  624.                                                           is_variant            = variant
  625.                                                 changing  it_outtab             = me->mt_out
  626.                                                           it_fieldcatalog       = me->mt_fc ).
  627.  
  628.       me->display_header( ).
  629.     endif.
  630.  
  631.     me->m_alv->refresh_table_display( i_soft_refresh = 'X' ).
  632.  
  633.   endmethod.                    "handle_pbo
  634.  
  635.  
  636.  
  637.   method handle_pai.
  638.     case i_ucomm.
  639.       when 'PCI'.
  640.  
  641.       when 'KLVAR'.
  642.  
  643.       when 'BACK' or 'CANCEL'.
  644.         set screen 0.
  645.       when 'EXIT'.
  646.         leave program.
  647.     endcase.
  648.  
  649.   endmethod.                    "handle_pai
  650.  
  651.  
  652.   method build_fc.
  653.     data:
  654.           ls_fc       type lvc_s_fcat,
  655.           l_coltext   type lvc_txtcol,
  656.           l_fieldname type lvc_fname.
  657.  
  658.  
  659.     define add_field.
  660.       ls_fc-fieldname = &1.
  661.       ls_fc-ref_field = &2.
  662.       ls_fc-ref_table = &3.
  663.       if &4 is not initial.
  664.         ls_fc-coltext = ls_fc-tooltip = &4.
  665.       endif.
  666.       ls_fc-emphasize = &5.
  667.       append ls_fc to c_fc.
  668.       clear ls_fc.
  669.     end-of-definition.
  670.  
  671.     add_field:
  672.        'BUKRS'      'BUKRS'     'T001'      ''                                        'C400',
  673.        'BUTXT'      'BUTXT'     'T001'      ''                                        'C400',
  674.        'SAKNR_LACT' 'SAKNR'     'ZLKON01'   'Lactalis konto'                          'C400',
  675.        'TXT50_LACT' 'TXT50'     'SKAT'      'Naziv Lactalis konta'                    'C400',
  676.        'SAKNR_KONS' 'SAKNR'     'SKA1'      'Konto KONS'                              'C400',
  677.        'TXT50_KONS' 'TXT50'     'SKAT'      'Naziv konta KONS'                        'C400',
  678.        'SAKNR'      'SAKNR'     'SKA1'      ''                                        'C400',
  679.        'TXT50'      'TXT50'     'SKAT'      ''                                        'C400',
  680.        'MATNR'      'MATNR'     'MARA'      ''                                        'C400',
  681.        'MAKTX'      'MAKTX'     'MAKT'      ''                                        'C400',
  682.        'MEINS'      'MEINS'     'MARA'      ''                                        'C400',
  683.        'WERKS'      'WRK02'     'T460A'     ''                                        'C400',
  684.        'NAME1'      'NAME1'     'T001W'     ''                                        'C400',
  685.        'LBKUM_I'    'LBKUM'     'ZBFRSTOCK' 'Ukupna zaliha razd izv.'                 'C500',
  686.        'SALK3_I'    'SALK3'     'ZBFRSTOCK' 'Ukupna vrijednost zalihe razd. izv'      'C500',
  687.        'ZPCI_I'     'KBETR'     'KONP'      'PCI cijena za razd. izv'                 'C500',
  688.        'SALK3PCI_I' 'SALK3'     'ZBFRSTOCK' 'Vrijednost ukupne zalihe  PCI razd. izv' 'C500',
  689.        'SALK3EUR_I' 'SALK3'     'ZBFRSTOCK' 'Vrijednost ukupne zalihe EUR razd. izv'  'C500',
  690.        'LBKUM_U'    'LBKUM'     'ZBFRSTOCK' 'Ukupna zaliha razd usporedbe'            'C700',
  691.        'SALK3_U'    'SALK3'     'ZBFRSTOCK' 'Ukupna vrijednost zalihe razd. usp'      'C700',
  692.        'ZPCI_U'     'KBETR'     'KONP'      'PCI cijena za razd. usp'                 'C700',
  693.        'SALK3PCI_U' 'SALK3'     'ZBFRSTOCK' 'Vrijednost ukupne zalihe  PCI razd. usp' 'C700',
  694.        'SALK3EUR_U' 'SALK3'     'ZBFRSTOCK' 'Vrijednost ukupne zalihe EUR razd. usp'  'C700'.
  695.  
  696.   endmethod.                    "build_fc
  697.  
  698.   method display_header.
  699.     data:
  700.        l_text(255)  type c,
  701.        l_dummy(255) type c,
  702.  
  703.        right        type ref to cl_dd_area,
  704.  
  705.        ls_t001  type t001.
  706.  
  707.     create object me->m_header_document.
  708.  
  709.     me->m_header_document->vertical_split(
  710.           exporting split_area  = me->m_header_document
  711.                     split_width = '200'
  712.           importing
  713.                     right_area  = right ).
  714.  
  715.  
  716.  
  717.     l_text = 'Poduzeæe:'.
  718.     me->m_header_document->add_text( text = l_text sap_emphasis = 'STRONG' ).
  719.  
  720.     loop at me->mt_t001 into ls_t001.
  721.       write ls_t001-bukrs to l_text.
  722.       right->add_text( text = l_text sap_color = cl_dd_document=>list_key ).
  723.  
  724.       l_text = ls_t001-butxt.
  725.       right->add_text( text = l_text ).
  726.     endloop.
  727.  
  728.     me->m_header_document->new_line( ).
  729.     right->new_line( ).
  730.  
  731.     l_text = 'Razdoblje izvješæivanja:'.
  732.     me->m_header_document->add_text( text = l_text sap_emphasis = 'STRONG' ).
  733.  
  734.     write s_spmoni-low to l_text.
  735.     right->add_text( text = l_text sap_color = cl_dd_document=>list_positive ).
  736.  
  737.     me->m_header_document->new_line( ).
  738.     right->new_line( ).
  739.  
  740.     l_text = 'Razdoblje usporedbe:'.
  741.     me->m_header_document->add_text( text = l_text sap_emphasis = 'STRONG' ).
  742.  
  743.     write s_spmonu-low to l_text.
  744.     right->add_text( text = l_text sap_color = cl_dd_document=>list_group ).
  745.  
  746.     me->m_header_document->new_line( ).
  747.     right->new_line( ).
  748.  
  749.     l_text = 'Tip teèaja:'.
  750.     me->m_header_document->add_text( text = l_text sap_emphasis = 'STRONG' ).
  751.  
  752.     write p_kurst to l_text.
  753.     right->add_text( text = l_text sap_color = cl_dd_document=>list_key ).
  754.  
  755.  
  756.     me->m_header_document->set_document_background( 'Z_PATTERN_PAPER' ).
  757.  
  758. *   Prikaži zaglavlje
  759.     me->m_header_document->merge_document( ).
  760.     me->m_header_document->display_document( parent = me->m_html_container ).
  761.  
  762.   endmethod.                    "display_header
  763.  
  764.  
  765.  
  766.   method f4_saknr_lact.
  767.     types: begin of t_lact_saknr,
  768.               saknr type ska1-saknr,
  769.               txt50 type skat-txt50,
  770.             end of t_lact_saknr.
  771.  
  772.     data: lt_lact_saknr type standard table of t_lact_saknr,
  773.           lt_return     type standard table of ddshretval.
  774.  
  775.     select distinct
  776.       zlkon01~saknr
  777.       skat~txt50
  778.     into corresponding fields of table lt_lact_saknr
  779.     from
  780.         zlkon01 inner join ska1 as ska1_grupe on
  781.           zlkon01~saknr = ska1_grupe~bilkt
  782.         inner join ska1 as ska1_poduzeca on
  783.           ska1_poduzeca~bilkt = ska1_grupe~saknr
  784.         left outer join skat on
  785.           zlkon01~saknr = skat~saknr and
  786.           skat~ktopl = 'LACT' and
  787.           skat~spras = sy-langu
  788.     where
  789.         zlkon01~zstock <> '' and
  790.         ska1_grupe~ktopl = 'KONS'.
  791.  
  792.  
  793.     call function 'F4IF_INT_TABLE_VALUE_REQUEST'
  794.       exporting
  795.         retfield        = 'SAKNR'
  796.         dynpprog        = sy-repid
  797.         dynpnr          = sy-dynnr
  798.         dynprofield     = 'S_SAKNRL'
  799.         window_title    = 'Lactalis konto'
  800.         value_org       = 'S'
  801.       tables
  802.         value_tab       = lt_lact_saknr
  803.         return_tab      = lt_return
  804.       exceptions
  805.         parameter_error = 1
  806.         no_values_found = 2
  807.         others          = 3.
  808.     if sy-subrc <> 0.
  809.       message id sy-msgid type sy-msgty number sy-msgno
  810.               with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  811.     endif.
  812.  
  813.  
  814.   endmethod.                    "f4_saknr_lact
  815.  
  816.  
  817.  
  818.   method f4_saknr.
  819.     types: begin of t_saknr,
  820.               saknr type ska1-saknr,
  821.               txt50 type skat-txt50,
  822.             end of t_saknr.
  823.  
  824.     data: lt_saknr  type standard table of t_saknr,
  825.           lt_return type standard table of ddshretval.
  826.  
  827.     select distinct
  828.       ska1_poduzeca~saknr
  829.       skat~txt50
  830.     into corresponding fields of table lt_saknr
  831.     from
  832.         zlkon01 inner join ska1 as ska1_grupe on
  833.           zlkon01~saknr = ska1_grupe~bilkt
  834.         inner join ska1 as ska1_poduzeca on
  835.           ska1_poduzeca~bilkt = ska1_grupe~saknr
  836.         inner join t001 on
  837.           ska1_poduzeca~ktopl = t001~ktopl
  838.         left outer join skat on
  839.           skat~saknr = ska1_poduzeca~saknr and
  840.           skat~ktopl = ska1_poduzeca~ktopl and
  841.           skat~spras = sy-langu
  842.     where
  843.         zlkon01~zstock <> '' and
  844.         ska1_grupe~ktopl = 'KONS' and
  845.         t001~bukrs in s_bukrs and
  846.         zlkon01~saknr in s_saknrl.
  847.  
  848.     call function 'F4IF_INT_TABLE_VALUE_REQUEST'
  849.       exporting
  850.         retfield        = 'SAKNR'
  851.         dynpprog        = sy-repid
  852.         dynpnr          = sy-dynnr
  853.         dynprofield     = 'S_SAKNR'
  854.         value_org       = 'S'
  855.       tables
  856.         value_tab       = lt_saknr
  857.         return_tab      = lt_return
  858.       exceptions
  859.         parameter_error = 1
  860.         no_values_found = 2
  861.         others          = 3.
  862.     if sy-subrc <> 0.
  863.       message id sy-msgid type sy-msgty number sy-msgno
  864.               with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  865.     endif.
  866.  
  867.   endmethod.                    "f4_saknr
  868.  
  869.  
  870.   method authority_check.
  871.     data:
  872.           l_message type string,
  873.           lt_t001   type standard table of t001,
  874.           ls_t001   type t001.
  875.  
  876.     select * from t001 into table lt_t001 where bukrs in s_bukrs.
  877.  
  878.     loop at lt_t001 into ls_t001.
  879.  
  880.       authority-check object 'F_BKPF_BUK'
  881.              id 'BUKRS' field ls_t001-bukrs
  882.              id 'ACTVT' field '03'.
  883.       if sy-subrc ne 0.
  884.         concatenate 'Nemate autorizaciju za poduzeæe' ls_t001-bukrs into l_message separated by space.
  885.         message l_message type 'E'.
  886.       endif.
  887.  
  888.     endloop.
  889.   endmethod.                    "authority_check
  890.  
  891.  
  892.   method find_layout.
  893.  
  894.     data:
  895.           l_exit,
  896.           ls_variant type disvariant.
  897.  
  898.     ls_variant-report = sy-repid.
  899.  
  900.     call function 'LVC_VARIANT_F4'
  901.       exporting
  902.         is_variant = ls_variant
  903.         i_save     = 'X'
  904.       importing
  905.         e_exit     = l_exit
  906.         es_variant = ls_variant
  907.       exceptions
  908.         not_found  = 1
  909.         others     = 2.
  910.  
  911.     if sy-subrc ne 0.
  912.       message id sy-msgid type sy-msgty number sy-msgno
  913.       with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  914.     elseif l_exit ne 'X'.
  915.       p_layout    = ls_variant-variant.
  916.     endif.
  917.  
  918.   endmethod.                    "find_variant
  919.  
  920.  
  921.   method check_layout.
  922.  
  923.     data: ls_variant type disvariant.
  924.  
  925.     if not p_layout is initial.
  926.       move p_layout to ls_variant-variant.
  927.       move sy-repid to ls_variant-report.
  928.  
  929.       call function 'LVC_VARIANT_EXISTENCE_CHECK'
  930.         exporting
  931.           i_save        = 'X'
  932.         changing
  933.           cs_variant    = ls_variant
  934.         exceptions
  935.           wrong_input   = 1
  936.           not_found     = 2
  937.           program_error = 3
  938.           others        = 4.
  939.       if sy-subrc <> 0.
  940.         message id sy-msgid type sy-msgty number sy-msgno
  941.         with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  942.       else.
  943.  
  944.       endif.
  945.     endif.
  946.   endmethod.                    "check_variant
  947.  
  948. endclass. "lcl_app IMPLEMENTATION
  949. Extracted by Mass Download version 1.5.5 - E.G.Mellodew. 1998-2016. Sap Release 700
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement