Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Code listing for: ZFI30290_CLASSES
- Description: Klase za program ZFI30290
- *&---------------------------------------------------------------------*
- *& Include ZFI30290_CLASSES
- *&---------------------------------------------------------------------*
- class lcl_app definition.
- public section.
- types: begin of t_out,
- bukrs type bukrs,
- butxt type butxt,
- saknr_lact type saknr,
- txt50_lact type txt50_skat,
- saknr_kons type saknr,
- txt50_kons type txt50_skat,
- ktopl type ktopl,
- saknr type saknr,
- txt50 type txt50_skat,
- bklas type bklas,
- bkbez type bkbez,
- mtart type mtart,
- mtbez type mtbez,
- matnr type matnr,
- maktx type maktx,
- dispo type dispo,
- dsnam type dsnam,
- zwtyp type zwtyp,
- meins type meins,
- werks type werks_d,
- name1 type t001w-name1,
- lbkum type mbew-lbkum,
- lbkum_kg type mbew-lbkum,
- salk3 type salk3,
- mgvbr type mgvbr,
- mgvbr_kg type mgvbr,
- wgvbr type wgvbr,
- letztbew type letztbew,
- menge type mdbs-menge,
- end of t_out,
- begin of t_material_valuation,
- bukrs type bukrs,
- ktopl type ktopl,
- matnr type matnr,
- bwkey type bwkey,
- bklas type bklas,
- saknr type saknr,
- lfgja type lfgja,
- lfmon type lfmon,
- lbkum type mbew-lbkum,
- salk3 type salk3,
- end of t_material_valuation,
- begin of t_t030,
- ktopl type ktopl,
- bklas type bklas,
- konts type saknr,
- end of t_t030,
- begin of t_ska1,
- saknr_lact type saknr,
- saknr_grup type saknr,
- saknr_podu type saknr,
- end of t_ska1,
- begin of t_mrp,
- matnr type matnr,
- werks type werks_d,
- dispo type dispo,
- dsnam type dsnam,
- end of t_mrp,
- begin of t_werks,
- werks type werks_d,
- name1 type t001w-name1,
- bukrs type bukrs,
- end of t_werks,
- begin of t_s031,
- lgort type s031-lgort,
- lgobe type t001l-lgobe,
- mgvbr type s031-mgvbr,
- basme type s031-basme,
- wgvbr type s031-wgvbr,
- hwaer type s031-hwaer,
- end of t_s031,
- tt_out type standard table of t_out,
- tt_material_valuation type standard table of t_material_valuation,
- tt_t030 type standard table of t_t030,
- tt_bklas type range of bklas,
- tt_ska1 type hashed table of t_ska1 with unique key saknr_podu,
- tt_mrp type hashed table of t_mrp with unique key matnr werks,
- tt_werks type hashed table of t_werks with unique key werks.
- class-data:
- app type ref to lcl_app.
- class-methods:
- make_it_so,
- f4_saknr_lact,
- f4_saknr,
- authority_check,
- find_layout,
- check_layout.
- data:
- mt_out type tt_out,
- mt_fc type lvc_t_fcat.
- methods:
- constructor,
- main,
- handle_pbo,
- handle_pai importing i_ucomm type syucomm.
- private section.
- data:
- mt_t001 type hashed table of t001 with unique key bukrs,
- mt_ska1 type tt_ska1,
- mt_skat type hashed table of skat with unique key ktopl saknr,
- mt_makt type hashed table of makt with unique key matnr,
- mt_t025t type hashed table of t025t with unique key bklas,
- mt_mara type hashed table of mara with unique key matnr,
- mt_mrp type hashed table of t_mrp with unique key matnr werks,
- mt_t134t type hashed table of t134t with unique key mtart,
- mt_werks type tt_werks,
- mt_ztwtyp type hashed table of ztwtyp with unique key extwg.
- data:
- m_salv type ref to cl_salv_table,
- m_alv type ref to cl_gui_alv_grid,
- m_splitter type ref to cl_gui_splitter_container,
- m_container type ref to cl_gui_container,
- m_html_container type ref to cl_gui_container,
- m_header_document type ref to cl_dd_document.
- methods:
- select_material_valuation changing c_mbew type tt_material_valuation,
- select_mov_for_curr_stocks importing i_mbew type tt_material_valuation
- changing c_out type tt_out,
- select_last_goods_movement importing i_mbew type tt_material_valuation
- changing c_out type tt_out,
- select_order_item importing i_mbew type tt_material_valuation
- changing c_out type tt_out,
- get_t030 changing c_t030 type tt_t030,
- get_bklas importing i_t030 type tt_t030
- changing c_bklas type tt_bklas,
- on_link_click for event hotspot_click of cl_gui_alv_grid importing e_row_id
- es_row_no,
- display_s031_data importing i_row type t_out,
- get_list_header returning value(r_header) type lvc_title,
- build_fc changing c_fc type lvc_t_fcat,
- display_header.
- endclass. "lcl_app DEFINITION
- *----------------------------------------------------------------------*
- * CLASS lcl_app IMPLEMENTATION
- *----------------------------------------------------------------------*
- *
- *----------------------------------------------------------------------*
- class lcl_app implementation.
- method make_it_so.
- if lcl_app=>app is initial.
- create object lcl_app=>app.
- endif.
- lcl_app=>app->main( ).
- endmethod. "make_it_so
- method constructor.
- if s_spmon-high is initial.
- s_spmon-high = s_spmon-low.
- endif.
- me->build_fc( changing c_fc = me->mt_fc ).
- * Daj mi sva konta na svijetu, svaèija...sve mi poveži... to mi treba... to mi radi. aaaaaaa...
- select distinct
- ska1_poduzeca~saknr as saknr_podu
- ska1_grupe~saknr as saknr_grup
- zlkon01~saknr as saknr_lact
- into corresponding fields of table me->mt_ska1
- from
- zlkon01 inner join ska1 as ska1_grupe on
- zlkon01~saknr = ska1_grupe~bilkt
- inner join ska1 as ska1_poduzeca on
- ska1_poduzeca~bilkt = ska1_grupe~saknr
- inner join t001 on
- ska1_poduzeca~ktopl = t001~ktopl
- where
- zlkon01~zstock <> '' and
- ska1_grupe~ktopl = 'KONS' and
- t001~bukrs in s_bukrs and
- zlkon01~saknr in s_saknrl and
- ska1_poduzeca~saknr in s_saknr.
- select * from t001 into table me->mt_t001 where bukrs in s_bukrs.
- select * from skat into table me->mt_skat where spras = sy-langu.
- select * from mara into table me->mt_mara.
- select * from makt into table me->mt_makt where spras = sy-langu.
- select * from t025t into table me->mt_t025t where spras = sy-langu.
- select
- t001w~werks
- t001w~name1
- t001k~bukrs
- from
- t001w inner join t001k on
- t001w~bwkey = t001k~bwkey
- into
- table me->mt_werks
- where
- t001k~bukrs in s_bukrs.
- select
- marc~matnr
- marc~werks
- marc~dispo
- t024d~dsnam
- from
- marc inner join t024d on
- marc~dispo = t024d~dispo and
- marc~werks = t024d~werks
- into
- table me->mt_mrp.
- select * from t134t into table me->mt_t134t where spras = sy-langu.
- select * from ztwtyp into table me->mt_ztwtyp.
- endmethod. "constructor
- method main.
- data:
- lt_mbew type tt_material_valuation,
- ls_mbew type t_material_valuation,
- ls_ska1 type t_ska1,
- ls_skat type skat,
- ls_makt type makt,
- ls_mara type mara,
- ls_t025t type t025t,
- ls_t001 type t001,
- ls_mrp type t_mrp,
- ls_werks type t_werks,
- ls_t134t type t134t,
- ls_ztwtyp type ztwtyp,
- ls_out type t_out.
- field-symbols:
- <out> type t_out.
- me->select_material_valuation( changing c_mbew = lt_mbew ).
- loop at lt_mbew into ls_mbew.
- move-corresponding ls_mbew to ls_out.
- ls_out-werks = ls_mbew-bwkey.
- append ls_out to me->mt_out.
- endloop.
- me->select_mov_for_curr_stocks( exporting i_mbew = lt_mbew
- changing c_out = me->mt_out ).
- me->select_last_goods_movement( exporting i_mbew = lt_mbew
- changing c_out = me->mt_out ).
- me->select_order_item( exporting i_mbew = lt_mbew
- changing c_out = me->mt_out ).
- delete me->mt_out where lbkum = 0 and salk3 = 0 and mgvbr = 0 and wgvbr = 0 and menge <= 0.
- loop at me->mt_out assigning <out>.
- read table me->mt_ska1 with table key saknr_podu = <out>-saknr into ls_ska1.
- if sy-subrc = 0.
- <out>-saknr_lact = ls_ska1-saknr_lact.
- <out>-saknr_kons = ls_ska1-saknr_grup.
- endif.
- read table me->mt_skat with table key ktopl = <out>-ktopl saknr = <out>-saknr into ls_skat.
- if sy-subrc = 0.
- <out>-txt50 = ls_skat-txt50.
- endif.
- read table me->mt_skat with table key ktopl = 'KONS' saknr = <out>-saknr_kons into ls_skat.
- if sy-subrc = 0.
- <out>-txt50_kons = ls_skat-txt50.
- endif.
- read table me->mt_skat with table key ktopl = 'LACT' saknr = <out>-saknr_lact into ls_skat.
- if sy-subrc = 0.
- <out>-txt50_lact = ls_skat-txt50.
- endif.
- read table me->mt_makt with table key matnr = <out>-matnr into ls_makt.
- if sy-subrc = 0.
- <out>-maktx = ls_makt-maktx.
- endif.
- read table me->mt_t025t with table key bklas = <out>-bklas into ls_t025t.
- if sy-subrc = 0.
- <out>-bkbez = ls_t025t-bkbez.
- endif.
- read table me->mt_t001 with table key bukrs = <out>-bukrs into ls_t001.
- if sy-subrc = 0.
- <out>-butxt = ls_t001-butxt.
- endif.
- read table me->mt_mrp with table key matnr = <out>-matnr werks = <out>-werks into ls_mrp.
- if sy-subrc = 0.
- <out>-dispo = ls_mrp-dispo.
- <out>-dsnam = ls_mrp-dsnam.
- endif.
- read table me->mt_mara with table key matnr = <out>-matnr into ls_mara.
- if sy-subrc = 0.
- <out>-meins = ls_mara-meins.
- <out>-mtart = ls_mara-mtart.
- read table me->mt_t134t with table key mtart = ls_mara-mtart into ls_t134t.
- if sy-subrc = 0.
- <out>-mtbez = ls_t134t-mtbez.
- endif.
- read table me->mt_ztwtyp with table key extwg = ls_mara-extwg into ls_ztwtyp.
- if sy-subrc = 0.
- <out>-zwtyp = ls_ztwtyp-zwtyp.
- endif.
- endif.
- read table me->mt_werks with table key werks = <out>-werks into ls_werks.
- if sy-subrc = 0.
- <out>-name1 = ls_werks-name1.
- endif.
- call function 'MATERIAL_UNIT_CONVERSION'
- exporting
- input = <out>-lbkum
- matnr = <out>-matnr
- meinh = 'KG'
- importing
- output = <out>-lbkum_kg
- exceptions
- conversion_not_found = 1
- input_invalid = 2
- material_not_found = 3
- meinh_not_found = 4
- meins_missing = 5
- no_meinh = 6
- output_invalid = 7
- overflow = 8
- others = 9.
- if sy-subrc <> 0.
- * message id sy-msgid type 'I' number sy-msgno
- * with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
- clear <out>-lbkum_kg.
- endif.
- call function 'MATERIAL_UNIT_CONVERSION'
- exporting
- input = <out>-mgvbr
- matnr = <out>-matnr
- meinh = 'KG'
- importing
- output = <out>-mgvbr_kg
- exceptions
- conversion_not_found = 1
- input_invalid = 2
- material_not_found = 3
- meinh_not_found = 4
- meins_missing = 5
- no_meinh = 6
- output_invalid = 7
- overflow = 8
- others = 9.
- if sy-subrc <> 0.
- * message id sy-msgid type 'I' number sy-msgno
- * with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
- clear <out>-mgvbr_kg.
- endif.
- endloop.
- call screen 100.
- endmethod. "main
- method select_material_valuation.
- data: lt_mbew type hashed table of t_material_valuation with unique key matnr bwkey,
- ls_mbew type t_material_valuation,
- lt_mbewh type standard table of t_material_valuation,
- lt_mbewh_t type standard table of t_material_valuation,
- ls_mbewh type t_material_valuation,
- ls_mbewh_t type t_material_valuation,
- lt_t030 type tt_t030,
- ls_t030 type t_t030,
- rt_bklas type tt_bklas,
- l_check type c,
- l_lfmon type mbew-lfmon,
- l_lfgja type mbew-lfgja.
- me->get_t030( changing c_t030 = lt_t030 ).
- check lt_t030 is not initial.
- me->get_bklas( exporting i_t030 = lt_t030
- changing c_bklas = rt_bklas ).
- * Prethodni period od onog zadnjeg (gornjeg) na selekcijskom...
- if s_spmon-high+4(2) = 1.
- l_lfmon = 12.
- l_lfgja = s_spmon-high(4) - 1.
- else.
- l_lfmon = s_spmon-high+4(2) - 1.
- l_lfgja = s_spmon-high(4).
- endif.
- * Prvo kupim trenutne zalihe
- select
- *
- from
- mbew inner join t001k on
- mbew~bwkey = t001k~bwkey
- inner join t001 on
- t001k~bukrs = t001~bukrs
- into corresponding fields of table lt_mbew
- where
- bklas in rt_bklas and
- t001~bukrs in s_bukrs and
- bwtar = '' and
- ( lfgja < s_spmon-high(4) or
- ( lfmon <= s_spmon-high+4(2) and lfgja = s_spmon-high(4) ) ) and
- matnr in s_matnr.
- * Onda kupim povijesne zalihe
- select
- t001~bukrs
- t001~ktopl
- matnr
- mbewh~bwkey
- lbkum
- salk3
- bklas
- lfgja
- lfmon
- into
- corresponding fields of table lt_mbewh
- from
- mbewh inner join t001k on
- mbewh~bwkey = t001k~bwkey
- inner join t001 on
- t001k~bukrs = t001~bukrs
- where
- bklas in rt_bklas and
- t001~bukrs in s_bukrs and
- ( lfgja < s_spmon-high(4) or
- ( lfmon <= s_spmon-high+4(2) and lfgja = s_spmon-high(4) ) ) and
- matnr in s_matnr.
- sort lt_mbewh by matnr bwkey lfgja lfmon.
- loop at lt_mbewh into ls_mbewh where ( lfgja < l_lfgja ) or ( lfmon <= l_lfmon and lfgja = l_lfgja ).
- select
- t001~bukrs
- t001~ktopl
- matnr
- mbewh~bwkey
- lbkum
- salk3
- bklas
- lfgja
- lfmon
- into
- corresponding fields of table lt_mbewh_t
- from
- mbewh inner join t001k on
- mbewh~bwkey = t001k~bwkey
- inner join t001 on
- t001k~bukrs = t001~bukrs
- where
- mbewh~bklas in s_bklas and
- mbewh~bwkey = ls_mbewh-bwkey and
- t001~bukrs in s_bukrs and
- matnr = ls_mbewh-matnr and
- ( lfgja > ls_mbewh-lfgja or
- ( lfmon > ls_mbewh-lfmon and lfgja = ls_mbewh-lfgja ) ) and
- matnr in s_matnr.
- sort lt_mbewh_t by matnr bwkey lfgja lfmon.
- read table lt_mbewh_t into ls_mbewh_t index 1.
- if sy-subrc = 0.
- ls_mbewh-lbkum = ls_mbewh_t-lbkum.
- ls_mbewh-salk3 = ls_mbewh_t-salk3.
- modify lt_mbewh from ls_mbewh.
- endif.
- endloop.
- * Pièi po povijesnim i provjeravaj nedostaje li nam slog u trenutnim zalihama i po potrebi ga upiši u izlaznu internjaèu.
- loop at lt_mbewh into ls_mbewh.
- clear l_check.
- at end of bwkey.
- l_check = 'X'.
- endat.
- if l_check = 'X'.
- read table lt_mbew with table key
- matnr = ls_mbewh-matnr
- bwkey = ls_mbewh-bwkey
- transporting no fields.
- if sy-subrc ne 0.
- read table lt_t030 with key bklas = ls_mbewh-bklas ktopl = ls_mbewh-ktopl into ls_t030.
- if sy-subrc = 0.
- ls_mbewh-saknr = ls_t030-konts.
- endif.
- collect ls_mbewh into c_mbew.
- endif.
- endif.
- endloop.
- * U izlaznu internjaèu nadoštukaj trnutne zalihe (nakon èega bi tranu trebale biti sve potrebne zalihe po klasi vrednovanja).
- loop at lt_mbew into ls_mbew.
- read table lt_t030 with key bklas = ls_mbew-bklas ktopl = ls_mbewh-ktopl into ls_t030.
- if sy-subrc = 0.
- ls_mbew-saknr = ls_t030-konts.
- endif.
- collect ls_mbew into c_mbew.
- endloop.
- endmethod. "select_material_valuation
- method select_mov_for_curr_stocks.
- data: lt_data type tt_out,
- ls_data type t_out.
- field-symbols: <out> type t_out.
- select
- *
- from
- s031
- into
- corresponding fields of table lt_data
- * for
- * all entries in i_mbew
- where
- spmon in s_spmon
- * and matnr = i_mbew-matnr
- .
- loop at lt_data into ls_data.
- read table c_out with key matnr = ls_data-matnr werks = ls_data-werks assigning <out>.
- if sy-subrc <> 0.
- continue.
- endif.
- <out>-mgvbr = <out>-mgvbr + ls_data-mgvbr.
- <out>-wgvbr = <out>-wgvbr + ls_data-wgvbr.
- endloop.
- endmethod. "select_mov_for_curr_stocks
- method select_last_goods_movement.
- data:
- lt_s032 type standard table of s032,
- ls_s032 type s032.
- field-symbols:
- <out> type t_out.
- select
- *
- from
- s032
- into
- table lt_s032
- for
- all entries in me->mt_werks
- where
- werks = me->mt_werks-werks.
- * Treba mi najnoviji po pogonu i materijalu, bez obzira na skl. lok.
- sort lt_s032 by werks matnr ascending letztbew descending.
- delete adjacent duplicates from lt_s032 comparing werks matnr.
- loop at lt_s032 into ls_s032.
- read table c_out with key matnr = ls_s032-matnr werks = ls_s032-werks assigning <out>.
- if sy-subrc <> 0.
- continue.
- endif.
- <out>-letztbew = ls_s032-letztbew.
- endloop.
- endmethod. "select_last_goods_movement
- method select_order_item.
- data:
- lt_mdbs type standard table of mdbs,
- ls_mdbs type mdbs,
- ls_mara type mara.
- field-symbols:
- <out> type t_out.
- select
- *
- from
- mdbs
- into
- table lt_mdbs
- for
- all entries in i_mbew
- where
- loekz = '' and
- elikz = '' and
- matnr = i_mbew-matnr and
- exists ( select * from ekko where ekko~ebeln = mdbs~ebeln and ekko~lifnr <> '' and ekko~memory = '' ) and
- werks in ( select bwkey from t001k where bukrs in s_bukrs ).
- loop at lt_mdbs into ls_mdbs.
- read table c_out with key matnr = ls_mdbs-matnr werks = ls_mdbs-werks assigning <out>.
- if sy-subrc <> 0.
- continue.
- endif.
- read table me->mt_mara with table key matnr = ls_mdbs-matnr into ls_mara.
- call function 'MATERIAL_UNIT_CONVERSION'
- exporting
- input = ls_mdbs-menge
- matnr = ls_mdbs-matnr
- meinh = ls_mdbs-meins
- importing
- output = ls_mdbs-menge
- exceptions
- conversion_not_found = 1
- input_invalid = 2
- material_not_found = 3
- meinh_not_found = 4
- meins_missing = 5
- no_meinh = 6
- output_invalid = 7
- overflow = 8
- others = 9.
- if sy-subrc <> 0.
- message id sy-msgid type sy-msgty number sy-msgno
- with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
- endif.
- call function 'MATERIAL_UNIT_CONVERSION'
- exporting
- input = ls_mdbs-wemng
- matnr = ls_mdbs-matnr
- meinh = ls_mdbs-meins
- importing
- output = ls_mdbs-wemng
- exceptions
- conversion_not_found = 1
- input_invalid = 2
- material_not_found = 3
- meinh_not_found = 4
- meins_missing = 5
- no_meinh = 6
- output_invalid = 7
- overflow = 8
- others = 9.
- if sy-subrc <> 0.
- message id sy-msgid type sy-msgty number sy-msgno
- with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
- endif.
- <out>-menge = <out>-menge + ls_mdbs-menge - ls_mdbs-wemng.
- endloop.
- endmethod. "select_order_item
- method get_t030.
- data: rt_saknr_poduzeca type range of saknr,
- rs_saknr_poduzeca like line of rt_saknr_poduzeca,
- ls_ska1 type t_ska1,
- lt_t001k type standard table of t001k,
- ls_t001 type t001,
- rt_ktopl_poduzeca type range of ktopl,
- rs_ktopl_poduzeca like line of rt_ktopl_poduzeca...
- rs_ktopl_poduzeca-sign = 'I'.
- rs_ktopl_poduzeca-option = 'EQ'.
- loop at me->mt_t001 into ls_t001.
- rs_ktopl_poduzeca-low = ls_t001-ktopl.
- append rs_ktopl_poduzeca to rt_ktopl_poduzeca.
- endloop.
- * Napuni range tablicu sa kontima kontnog plana poduzeæa
- loop at me->mt_ska1 into ls_ska1.
- rs_saknr_poduzeca-low = ls_ska1-saknr_podu.
- rs_saknr_poduzeca-sign = 'I'.
- rs_saknr_poduzeca-option = 'EQ'.
- append rs_saknr_poduzeca to rt_saknr_poduzeca.
- endloop.
- select * from t001k into table lt_t001k where bukrs in s_bukrs.
- check lt_t001k is not initial.
- * I napokon mi naði klase vrednovanja i pripadajuæa konta poduzeæa koje mi trebaju
- select
- ktopl
- bklas
- konts
- into corresponding fields of table c_t030
- from
- t030
- for all entries in lt_t001k
- where
- ktosl = 'BSX' and
- ktopl in rt_ktopl_poduzeca and
- t030~bwmod = lt_t001k-bwmod and
- konts in rt_saknr_poduzeca and
- bklas in s_bklas.
- endmethod. "get_t030_data
- method get_bklas.
- data:
- ls_t030 type t_t030,
- ls_bklas like line of c_bklas.
- ls_bklas-sign = 'I'.
- ls_bklas-option = 'EQ'.
- loop at i_t030 into ls_t030.
- ls_bklas-low = ls_t030-bklas.
- append ls_bklas to c_bklas.
- endloop.
- endmethod. "set_bklas
- method on_link_click.
- data: ls_out type t_out.
- read table me->mt_out index e_row_id into ls_out.
- me->display_s031_data( ls_out ).
- endmethod. "on_link_click
- method display_s031_data.
- data:
- lt_data type standard table of t_s031,
- lo_popup type ref to cl_salv_table,
- lo_functions type ref to cl_salv_functions,
- lo_display type ref to cl_salv_display_settings,
- lo_cols type ref to cl_salv_columns.
- select *
- from s031 left outer join t001l on
- s031~werks = t001l~werks and
- s031~lgort = t001l~lgort
- into corresponding fields of table lt_data
- where s031~werks = i_row-werks and
- matnr = i_row-matnr and
- spmon in s_spmon and
- ( s031~mgvbr <> 0 or s031~wgvbr <> 0 ).
- try.
- cl_salv_table=>factory( importing r_salv_table = lo_popup changing t_table = lt_data ).
- lo_functions = lo_popup->get_functions( ).
- lo_functions->set_all( abap_true ).
- lo_cols = lo_popup->get_columns( ).
- lo_cols->set_optimize( abap_true ).
- lo_display = lo_popup->get_display_settings( ).
- lo_display->set_striped_pattern( cl_salv_display_settings=>true ).
- * lo_display->set_list_header( 'Pregled zaliha po pogonima' ).
- catch cx_salv_msg.
- message 'Nešto strašno se dogodilo.' type 'E'.
- endtry.
- lo_popup->set_screen_popup( start_column = 5
- end_column = 80
- start_line = 5
- end_line = 20 ).
- lo_popup->display( ).
- endmethod. "display_s031_data
- method get_list_header.
- data:
- ls_t001 type t001,
- l_bukrs_cnt type i.
- describe table me->mt_t001 lines l_bukrs_cnt.
- if l_bukrs_cnt = 1.
- loop at me->mt_t001 into ls_t001.
- r_header = ls_t001-bukrs.
- concatenate 'Pregled zaliha po pogonima za poduzeæe' r_header into r_header separated by space.
- exit.
- endloop.
- else.
- loop at me->mt_t001 into ls_t001.
- if r_header is initial.
- r_header = ls_t001-bukrs.
- else.
- concatenate r_header ',' into r_header.
- concatenate r_header ls_t001-bukrs into r_header separated by space.
- endif.
- endloop.
- concatenate 'Pregled zaliha po pogonima za poduzeæa' r_header into r_header separated by space.
- endif.
- concatenate r_header 'za priod od' s_spmon-low 'do' s_spmon-high into r_header separated by space.
- endmethod. "get_list_header
- method handle_pbo.
- data: ls_layo type lvc_s_layo,
- variant type disvariant.
- set pf-status 'PF100'.
- set titlebar 'TB100'.
- if me->m_splitter is initial.
- create object me->m_splitter
- exporting
- parent = cl_gui_container=>default_screen
- rows = 2
- columns = 1.
- me->m_splitter->set_row_height( exporting height = 70
- id = 1 ).
- me->m_html_container = me->m_splitter->get_container( row = 1
- column = 1 ).
- endif.
- me->m_splitter->set_row_mode( mode = cl_gui_splitter_container=>mode_absolute ).
- if me->m_alv is initial.
- me->m_container = me->m_splitter->get_container( row = 2
- column = 1 ).
- create object me->m_alv
- exporting
- i_parent = me->m_container.
- ls_layo-cwidth_opt = 'X'.
- ls_layo-grid_title = ''.
- variant-report = sy-repid.
- variant-username = sy-uname.
- variant-variant = p_layout.
- me->m_alv->set_table_for_first_display( exporting is_layout = ls_layo
- i_save = 'A'
- i_default = 'X'
- is_variant = variant
- changing it_outtab = me->mt_out
- it_fieldcatalog = me->mt_fc ).
- set handler on_link_click for me->m_alv.
- me->display_header( ).
- endif.
- me->m_alv->refresh_table_display( i_soft_refresh = 'X' ).
- endmethod. "handle_pbo
- method handle_pai.
- case i_ucomm.
- when 'BACK' or 'CANCEL'.
- set screen 0.
- when 'EXIT'.
- leave program.
- endcase.
- endmethod. "handle_pai
- method display_header.
- data:
- l_text(255) type c,
- l_dummy(255) type c,
- right type ref to cl_dd_area,
- ls_t001 type t001.
- create object me->m_header_document.
- me->m_header_document->vertical_split(
- exporting split_area = me->m_header_document
- split_width = '160'
- importing
- right_area = right ).
- l_text = 'Poduzeæe:'.
- me->m_header_document->add_text( text = l_text sap_emphasis = 'STRONG' ).
- loop at me->mt_t001 into ls_t001.
- write ls_t001-bukrs to l_text.
- right->add_text( text = l_text sap_color = cl_dd_document=>list_key ).
- l_text = ls_t001-butxt.
- right->add_text( text = l_text ).
- endloop.
- me->m_header_document->new_line( ).
- right->new_line( ).
- l_text = 'Period:'.
- me->m_header_document->add_text( text = l_text sap_emphasis = 'STRONG' ).
- write s_spmon-low to l_text.
- right->add_text( text = l_text sap_color = cl_dd_document=>list_key ).
- if s_spmon-low <> s_spmon-high.
- l_text = ' do '.
- right->add_text( text = l_text ).
- write s_spmon-high to l_text.
- right->add_text( text = l_text sap_color = cl_dd_document=>list_key ).
- endif.
- me->m_header_document->set_document_background( 'Z_PATTERN_PAPER' ).
- * Prikaži zaglavlje
- me->m_header_document->merge_document( ).
- me->m_header_document->display_document( parent = me->m_html_container ).
- endmethod. "display_header
- method build_fc.
- data:
- ls_fc type lvc_s_fcat,
- l_coltext type lvc_txtcol,
- l_fieldname type lvc_fname.
- define add_field.
- ls_fc-fieldname = &1.
- ls_fc-ref_field = &2.
- ls_fc-ref_table = &3.
- if &4 is not initial.
- ls_fc-coltext = &4.
- endif.
- ls_fc-hotspot = &5.
- append ls_fc to c_fc.
- clear ls_fc.
- end-of-definition.
- add_field:
- 'BUKRS' 'BUKRS' 'T001' '' '',
- 'BUTXT' 'BUTXT' 'T001' '' '',
- 'SAKNR_LACT' 'SAKNR' 'ZLKON01' 'Lactalis konto' '',
- 'TXT50_LACT' 'TXT50' 'SKAT' 'Naziv Lactalis konta' '',
- 'SAKNR_KONS' 'SAKNR' 'SKA1' 'Konto KONS' '',
- 'TXT50_KONS' 'TXT50' 'SKAT' 'Naziv konta KONS' '',
- 'SAKNR' 'SAKNR' 'SKA1' '' '',
- 'TXT50' 'TXT50' 'SKAT' '' '',
- 'BKLAS' 'BKLAS' 'MBEW' '' '',
- 'BKBEZ' 'BKBEZ' 'T025T' '' '',
- 'MTART' 'MTART' 'MARA' '' '',
- 'MTBEZ' 'MTBEZ' 'T134T' '' '',
- 'MATNR' 'MATNR' 'MARA' '' '',
- 'MAKTX' 'MAKTX' 'MAKT' '' '',
- 'DISPO' 'DISPO' 'MARC' '' '',
- 'DSNAM' 'DSNAM' 'T024D' '' '',
- 'ZWTYP' 'ZWTYP' 'ZTWTYP' '' '',
- 'MEINS' 'MEINS' 'MARA' '' '',
- 'WERKS' 'WERKS' 'T001W' '' '',
- 'NAME1' 'NAME1' 'T001W' '' '',
- 'LBKUM' 'LBKUM' 'MBEW' '' '',
- 'LBKUM_KG' 'LBKUM' 'MBEW' 'Ukupna zaliha KG' '',
- 'SALK3' 'SALK3' 'MBEW' '' '',
- 'MGVBR' 'MGVBR' 'S031' '' 'X',
- 'MGVBR_KG' 'MGVBR' 'S031' 'Potrošnja KG' 'X',
- 'WGVBR' 'WGVBR' 'S031' '' 'X',
- 'LETZTBEW' 'LETZTBEW' 'S032' '' '',
- 'MENGE' 'MENGE' 'MDBS' 'Naruèeno/neisporuèeno' ''
- .
- endmethod. "build_fc
- method f4_saknr_lact.
- types: begin of t_lact_saknr,
- saknr type ska1-saknr,
- txt50 type skat-txt50,
- end of t_lact_saknr.
- data: lt_lact_saknr type standard table of t_lact_saknr,
- lt_return type standard table of ddshretval.
- select distinct
- zlkon01~saknr
- skat~txt50
- into corresponding fields of table lt_lact_saknr
- from
- zlkon01 inner join ska1 as ska1_grupe on
- zlkon01~saknr = ska1_grupe~bilkt
- inner join ska1 as ska1_poduzeca on
- ska1_poduzeca~bilkt = ska1_grupe~saknr
- left outer join skat on
- zlkon01~saknr = skat~saknr and
- skat~ktopl = 'LACT' and
- skat~spras = sy-langu
- where
- zlkon01~zstock <> '' and
- ska1_grupe~ktopl = 'KONS'.
- call function 'F4IF_INT_TABLE_VALUE_REQUEST'
- exporting
- retfield = 'SAKNR'
- dynpprog = sy-repid
- dynpnr = sy-dynnr
- dynprofield = 'S_SAKNRL'
- window_title = 'Lactalis konto'
- value_org = 'S'
- tables
- value_tab = lt_lact_saknr
- return_tab = lt_return
- exceptions
- parameter_error = 1
- no_values_found = 2
- others = 3.
- if sy-subrc <> 0.
- message id sy-msgid type sy-msgty number sy-msgno
- with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
- endif.
- endmethod. "f4_saknr_lact
- method f4_saknr.
- types: begin of t_saknr,
- saknr type ska1-saknr,
- txt50 type skat-txt50,
- end of t_saknr.
- data: lt_saknr type standard table of t_saknr,
- lt_return type standard table of ddshretval.
- select distinct
- ska1_poduzeca~saknr
- skat~txt50
- into corresponding fields of table lt_saknr
- from
- zlkon01 inner join ska1 as ska1_grupe on
- zlkon01~saknr = ska1_grupe~bilkt
- inner join ska1 as ska1_poduzeca on
- ska1_poduzeca~bilkt = ska1_grupe~saknr
- inner join t001 on
- ska1_poduzeca~ktopl = t001~ktopl
- left outer join skat on
- skat~saknr = ska1_poduzeca~saknr and
- skat~ktopl = ska1_poduzeca~ktopl and
- skat~spras = sy-langu
- where
- zlkon01~zstock <> '' and
- ska1_grupe~ktopl = 'KONS' and
- t001~bukrs in s_bukrs and
- zlkon01~saknr in s_saknrl.
- call function 'F4IF_INT_TABLE_VALUE_REQUEST'
- exporting
- retfield = 'SAKNR'
- dynpprog = sy-repid
- dynpnr = sy-dynnr
- dynprofield = 'S_SAKNR'
- value_org = 'S'
- tables
- value_tab = lt_saknr
- return_tab = lt_return
- exceptions
- parameter_error = 1
- no_values_found = 2
- others = 3.
- if sy-subrc <> 0.
- message id sy-msgid type sy-msgty number sy-msgno
- with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
- endif.
- endmethod. "f4_saknr
- method authority_check.
- data:
- l_message type string,
- lt_t001 type standard table of t001,
- ls_t001 type t001.
- select * from t001 into table lt_t001 where bukrs in s_bukrs.
- loop at lt_t001 into ls_t001.
- authority-check object 'F_BKPF_BUK'
- id 'BUKRS' field ls_t001-bukrs
- id 'ACTVT' field '03'.
- if sy-subrc ne 0.
- concatenate 'Nemate autorizaciju za poduzeæe' ls_t001-bukrs into l_message separated by space.
- message l_message type 'E'.
- endif.
- endloop.
- endmethod. "authority_check
- method find_layout.
- data:
- l_exit,
- ls_variant type disvariant.
- ls_variant-report = sy-repid.
- call function 'LVC_VARIANT_F4'
- exporting
- is_variant = ls_variant
- i_save = 'X'
- importing
- e_exit = l_exit
- es_variant = ls_variant
- exceptions
- not_found = 1
- others = 2.
- if sy-subrc ne 0.
- message id sy-msgid type sy-msgty number sy-msgno
- with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
- elseif l_exit ne 'X'.
- p_layout = ls_variant-variant.
- endif.
- endmethod. "find_variant
- method check_layout.
- data: ls_variant type disvariant.
- if not p_layout is initial.
- move p_layout to ls_variant-variant.
- move sy-repid to ls_variant-report.
- call function 'LVC_VARIANT_EXISTENCE_CHECK'
- exporting
- i_save = 'X'
- changing
- cs_variant = ls_variant
- exceptions
- wrong_input = 1
- not_found = 2
- program_error = 3
- others = 4.
- if sy-subrc <> 0.
- message id sy-msgid type sy-msgty number sy-msgno
- with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
- else.
- endif.
- endif.
- endmethod. "check_layout
- endclass. "lcl_app IMPLEMENTATION
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement