*----------------------------------------------------------------------*
* *
* RFITEMAP Line ITEMs Accounts Payable *
* ---- - - *
* *
* This report selects data to be displayed by ALV *
*----------------------------------------------------------------------*
report rfitemap message-id msitem no standard page heading.
*... general data definitions:
include rfitem_def.
*... icons and symbols:
include
- .
tables: lfa1, lfb1, bsik, bsid, admi_files.
tables: kna1.
tables: t001.
tables: t005.
data: it_h_t001 type tpit_t_vt001 with header line,
it_h_lfa1 type tpit_t_vlfa1 with header line,
it_h_lfb1 type tpit_t_vlfb1 with header line.
*... selection screen layout:
* button worklists on/off:
selection-screen function key 1.
* selections for processing of worklists:
selection-screen begin of block vendor with frame title text-w02.
parameters: pa_wllif like rf42b-idntk modif id wkl.
select-options: so_wllif for lfb1-lifnr modif id wkl no database
selection.
selection-screen end of block vendor.
selection-screen begin of block company with frame title text-w03.
parameters: pa_wlbuk like rf42b-idntb modif id wkl.
select-options: so_wlbuk for lfb1-bukrs modif id wkl no database
selection.
selection-screen end of block company.
* outer frame for item selection:
selection-screen begin of block items with frame title text-007.
* inner frame 1:
selection-screen begin of block status with frame title text-002.
* open items:
selection-screen begin of line.
parameters x_opsel like itemset-xopsel radiobutton group rad1.
selection-screen comment 3(20) text-003 for field x_opsel.
selection-screen end of line.
parameters pa_stida like rfpdo-allgstid default sy-datlo.
selection-screen skip.
* cleared items:
selection-screen begin of line.
parameters x_clsel like itemset-xclsel radiobutton group rad1.
selection-screen comment 3(25) text-004 for field x_clsel.
selection-screen end of line.
select-options so_augdt for bsik-augdt no database selection.
parameters pa_stid2 like rfpdo-allgstid.
selection-screen skip.
* all items:
selection-screen begin of line.
parameters x_aisel like itemset-xaisel radiobutton group rad1.
selection-screen comment 3(20) text-005 for field x_aisel.
selection-screen end of line.
select-options so_budat for bsik-budat no database selection.
selection-screen end of block status.
* inner frame 2:
selection-screen begin of block type with frame title text-006.
parameters: x_norm like itemset-xnorm as checkbox default 'X',
x_shbv like itemset-xshbv as checkbox,
x_merk like itemset-xmerk as checkbox,
x_park like itemset-xpark as checkbox,
x_apar like itemset-xapit as checkbox.
selection-screen end of block type.
* end of inner frames.
* net due date selection:
select-options so_faedt for it_pos-faedt no database selection
modif id due.
selection-screen end of block items.
* end of outer frame.
* list layout frame:
selection-screen begin of block list with frame title text-001.
parameters: pa_vari type slis_vari,
pa_nmax like itemset-nmax.
selection-screen end of block list.
*... end of selection screen layout.
*... dark parameters:
* branch: read items posted on central office?
* Values: (Y)es, (N)o, ( ) prompt user, (C) selection cancelled
parameters: pa_cent type c no-display.
* combined fiscal year/posting period
data: ld_yrper like rwcoom-fiscper.
select-options: so_yrper for ld_yrper no-display.
* internet transaction mode?
parameters: pa_inet type c no-display.
* grid control display?
* Values: (Y)es, (N)o, ( ) get parameter
parameters: pa_grid type c no-display.
*... include internal select-options for derived item fields:
include rfitem_sel.
initialization.
g_repid = sy-repid.
kd_noaut = 'X'.
kd_nooap = 'X'.
* expiring currencies:
perform init_expcur.
* deactivate user commands:
perform change_status.
* get due date selection PID value:
perform dd_get_flag.
* initialize worklist button:
perform wl_flag_and_button.
* get T021S and make field administration tables:
perform init_admin_tables.
* make field catalog, exclude all unnecessary fields:
perform make_fieldcatalog.
* prepare KKBER currency lookup table:
perform init_kkcurr_table.
* get parameters:
perform get_general_param.
* set account and company code:
perform set_acct_and_ccode.
* set fields for transfer prices
perform insert_tp_fields.
at selection-screen output.
* check for "suppress dialog":
gd_dynp_fun = 7.
gd_dynp_val = 1.
perform dynp_get_status using gd_dynp_fun
changing gd_dynp_val.
loop at screen.
perform wl_modify_screen.
perform dd_modify_screen.
modify screen.
endloop.
at selection-screen on block vendor.
if not gd_wl_on is initial. " worklists on >
if gd_dynp_val eq 0. " rebuild kd_bukrs and kd_lifnr >
* vendors:
refresh kd_lifnr.
if not pa_wllif is initial. " vendor worklist given >
perform resolve_worklist tables gt_cosel
using pa_wllif
'LIFNR'.
* worklist overrides vendor select-option:
refresh so_wllif.
clear so_wllif.
loop at gt_cosel.
move-corresponding gt_cosel to kd_lifnr.
append kd_lifnr.
endloop.
else.
append lines of so_wllif to kd_lifnr.
endif. " vendor worklist given <
endif. " rebuild kd_bukrs and kd_lifnr <
endif. " worklists on <
at selection-screen on block company.
if not gd_wl_on is initial. " worklists on >
if gd_dynp_val eq 0. " rebuild kd_bukrs and kd_lifnr >
* company codes:
refresh kd_bukrs.
if not pa_wlbuk is initial. " ccode worklist given >
perform resolve_worklist tables gt_cosel
using pa_wlbuk
'BUKRS'.
* worklist overrides company code select-option:
refresh so_wlbuk.
clear so_wlbuk.
loop at gt_cosel.
move-corresponding gt_cosel to kd_bukrs.
append kd_bukrs.
endloop.
else.
append lines of so_wlbuk to kd_bukrs.
endif. " ccode worklist given <
endif. " rebuild kd_bukrs and kd_lifnr <
endif. " worklists on <
at selection-screen.
case sy-ucomm.
*...switch worklist on or off:
when 'FC01'.
perform worklist_on_off.
perform set_acct_and_ccode.
*...process worklists and check selections:
when 'ONLI' or 'PRIN' or 'INIT' or space.
call function 'BUKRS_AUTHORITY_CHECK'
exporting
xdatabase = 'K'
tables
xbukreis = kd_bukrs.
* Belegberechtigung auf Buchungskreisebene
call function 'BUKRS_AUTHORITY_CHECK'
exporting
xdatabase = 'B'
tables
xbukreis = kd_bukrs.
* check input:
perform sel_account_check.
* check date (tpc)
perform check_date tables kd_bukrs
using kd_tpc.
endcase.
at selection-screen on block type.
*... check item type only when action = execute:
if sy-ucomm = 'ONLI'.
perform sel_type_check.
endif.
at selection-screen on value-request for pa_vari.
perform alv_variant_f4 changing pa_vari.
*** start of selection
start-of-selection.
***
clear: x_stop.
* set parameters:
perform set_parameters.
* map selections to LDB logic:
perform map_sel_to_ldb.
* determine company codes which use transfer prices
select * from t001a into table it_tp_auth where bukrs in kd_bukrs.
loop at it_tp_auth.
if it_tp_auth-curtp+1(1) = '1' or it_tp_auth-curtp+1(1) = '2'
or it_tp_auth-curtp2+1(1) = '1' or it_tp_auth-curtp2+1(1) = '2'.
else.
delete it_tp_auth.
endif.
endloop.
* check tp authority and set 'tech'-attribute if authority is missing
perform make_fieldcatalog2.
get lfa1.
* general account master data:
perform lfa1_info_fill.
perform t005_info_fill using 'K'.
get lfb1.
* company master data:
perform t001_info_fill.
* company account master data:
perform lfb1_info_fill.
get lfb1 late.
* customer items requested?
if not x_apar is initial and not lfa1-kunnr is initial.
perform read_customer_items.
endif.
get bsik.
* importing BKPF and BSEG data from archive
perform import_arch_from_memory.
* line items, basic fields:
ld_yrper(4) = bsik-gjahr.
ld_yrper+5 = bsik-monat.
check ld_yrper in so_yrper.
perform pos_table_fill changing x_stop.
end-of-selection.
* any branch accounts? prompt user if necessary:
perform lfb1_check_branch.
* save all selection criteria for refresh:
perform save_all_selections.
* Selection cancelled if choosen at the branch/head popup.
if pa_cent = 'C'.
message s050.
exit.
endif.
* determine list display mode:
perform display_grid_or_classic.
* read items posted on central office:
perform read_central_items.
* set variant:
gs_variant-report = g_repid.
gs_variant-username = sy-uname.
gs_variant-variant = pa_vari.
* read special fields if necessary:
perform special_fields_init using gs_variant.
* number of selected items:
if x_stop = 'X'.
message i023 with pa_nmax.
else.
describe table it_pos lines n_lines.
if n_lines > 0.
message s024 with n_lines.
elseif pa_inet is initial and gd_dynp_val is initial.
message s033.
exit.
else.
message i033.
endif.
endif.
* export general data used in header info:
perform export_filitexts_data.
* authority display or change
perform authority_tcode using 'FB02' subrc.
if subrc eq 0.
x_change = 'X'.
else.
x_change = space.
endif.
* leave to ALV:
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
text = text-009.
call function 'FI_ITEMS_DISPLAY'
exporting
caller_repid = c_repid_ap
acctype = c_koart_ap
x_change = x_change
i_u_save = gd_alvsave
is_u_variant = gs_variant
it_u_fieldcat = gt_fieldcat[]
it_kontab = it_accts[]
it_slbtab = it_comps[]
it_t001 = it_h_t001[]
it_lfa1 = it_h_lfa1[]
it_lfb1 = it_h_lfb1[]
x_grid = x_grid
x_inet = pa_inet
tables
it_items = it_pos.
*----------------------------------------------------------------------*
* FORM SEL_ACCOUNT_CHECK
*----------------------------------------------------------------------*
form sel_account_check.
data: ld_lines like sy-index,
ld_single_account type c,
ld_single_bukrs type c.
read table kd_lifnr index 1.
if sy-subrc ne 0.
read table kd_bukrs index 1.
if sy-subrc ne 0 and pa_nmax = 0.
message w019.
endif.
endif.
read table kd_lifnr index 1.
if sy-subrc eq 0.
loop at kd_lifnr transporting no fields
where option ne 'EQ' or
sign ne 'I'.
exit.
endloop.
subrc = sy-subrc. "Arbeitsvorrat: subrc ne 0
else.
subrc = 0.
endif.
if subrc eq 0.
select single lifnr from lfb1 into lfb1-lifnr
where lifnr in kd_lifnr
and bukrs in kd_bukrs.
else.
select lifnr from lfb1 into lfb1-lifnr
up to 1 rows
for all entries in kd_lifnr
where lifnr eq kd_lifnr-low
and bukrs in kd_bukrs.
endselect.
endif.
if sy-subrc ne 0.
message e030(msitem).
endif.
clear lfb1.
*...write kd_lifnr und kd_bukrs into memory
*...(important later for Dispute-Management).
export kd_lifnr to memory id 'FILITEXTS_LIFNR'.
export kd_bukrs to memory id 'FILITEXTS_BUKRS'.
*...find out, if single accounts and company codes have been selected..*
*...(important for header display).....................................*
clear ld_single_account.
describe table kd_lifnr lines ld_lines.
if ld_lines eq 1.
read table kd_lifnr index 1.
if ( kd_lifnr-sign eq 'I' and kd_lifnr-option eq 'EQ' ) or
( kd_lifnr-sign eq 'I' and kd_lifnr-option eq 'BT' and
kd_lifnr-low eq kd_lifnr-high ).
ld_single_account = 'X'.
endif.
endif.
clear ld_single_bukrs.
describe table kd_bukrs lines ld_lines.
if ld_lines eq 1.
read table kd_bukrs index 1.
if ( kd_bukrs-sign eq 'I' and kd_bukrs-option eq 'EQ' ) or
( kd_bukrs-sign eq 'I' and kd_bukrs-option eq 'BT' and
kd_bukrs-low eq kd_bukrs-high ).
ld_single_bukrs = 'X'.
endif.
endif.
export ld_single_bukrs ld_single_account to memory id
'FILITEXTS_SINGLE'.
endform. "sel_account_check
*----------------------------------------------------------------------*
* FORM SEL_TYPE_CHECK
*----------------------------------------------------------------------*
form sel_type_check.
if x_norm is initial and x_shbv is initial and x_merk is initial
and x_park is initial and x_apar is initial.
message e020.
endif.
endform. "sel_type_check
*----------------------------------------------------------------------*
* Form POS_TABLE_FILL
*----------------------------------------------------------------------*
form pos_table_fill changing p_stop.
data: text_index type i,
okay type c value space.
clear wa_pos.
move-corresponding bsik to wa_pos.
*... check item against selection flags:
perform check_item_ok using x_norm
x_shbv
x_merk
x_park
wa_pos
changing okay.
check okay = 'X'.
*
wa_pos-koart = c_koart_ap.
wa_pos-konto = bsik-lifnr.
wa_pos-dmshb = bsik-dmbtr.
wa_pos-wrshb = bsik-wrbtr.
wa_bsegp-bdiff = bsik-bdiff.
wa_bsegp-bdif2 = bsik-bdif2.
wa_bsegp-bdif3 = bsik-bdif3.
* derive nontrivial item fields:
call function 'ITEM_DERIVE_FIELDS'
exporting
s_t001 = it_h_t001
s_bsegp = wa_bsegp
key_date = p_keydate
* XOPVW = 'X'
i_kalsm = t005-kalsm
changing
s_item = wa_pos
exceptions
bad_input = 1
others = 2
.
if sy-subrc ne 0.
message a022.
endif.
* check and modify text field in internet case:
if not pa_inet is initial.
if wa_pos-sgtxt(1) ne '*'.
* take posting key text:
clear wa_pos-sgtxt.
select single ltext from tbslt into wa_pos-sgtxt
where spras = sy-langu
and bschl = wa_pos-bschl
and umskz = wa_pos-umskz.
else.
* take line item text:
shift wa_pos-sgtxt.
endif.
endif.
* fill currency fields:
perform item_currency_fields.
* check dark select-options and add item to table:
perform item_check_append.
* check max number:
describe table it_pos lines n_lines.
if pa_nmax > 0 and n_lines ge pa_nmax.
p_stop = 'X'.
stop.
endif.
endform. "pos_table_fill
*----------------------------------------------------------------------*
* Form POS_TABLE_FILL_CUSTOMER
*----------------------------------------------------------------------*
form pos_table_fill_customer changing p_stop.
data: text_index type i,
okay type c value space.
clear wa_pos.
move-corresponding bsid to wa_pos.
*... check item against selection flags:
perform check_item_ok using x_norm
x_shbv
x_merk
x_park
wa_pos
changing okay.
check okay = 'X'.
*
wa_pos-koart = 'D'.
wa_pos-konto = lfa1-kunnr.
wa_pos-dmshb = bsid-dmbtr.
wa_pos-wrshb = bsid-wrbtr.
wa_bsegp-bdiff = bsid-bdiff.
wa_bsegp-bdif2 = bsid-bdif2.
wa_bsegp-bdif3 = bsid-bdif3.
* derive nontrivial item fields:
call function 'ITEM_DERIVE_FIELDS'
exporting
s_t001 = it_h_t001
s_bsegp = wa_bsegp
key_date = p_keydate
* XOPVW = 'X'
i_kalsm = t005-kalsm
changing
s_item = wa_pos
exceptions
bad_input = 1
others = 2
.
if sy-subrc ne 0.
message a022.
endif.
* check and modify text field in internet case:
if not pa_inet is initial.
if wa_pos-sgtxt(1) ne '*'.
clear wa_pos-sgtxt.
else.
shift wa_pos-sgtxt.
endif.
endif.
* fill currency fields:
perform item_currency_fields.
* check dark select-options and add item to table:
perform item_check_append.
* check max number:
describe table it_pos lines n_lines.
if pa_nmax > 0 and n_lines ge pa_nmax.
p_stop = 'X'.
stop.
endif.
endform. " POS_TABLE_FILL_VENDOR
*&---------------------------------------------------------------------*
*& Form LFA1_INFO_FILL
*&---------------------------------------------------------------------*
form lfa1_info_fill.
clear it_h_lfa1.
move-corresponding lfa1 to it_h_lfa1.
insert table it_h_lfa1.
endform. " LFA1_INFO_FILL
*&---------------------------------------------------------------------*
*& Form LFB1_INFO_FILL
*&---------------------------------------------------------------------*
form lfb1_info_fill.
clear it_h_lfb1.
move-corresponding lfb1 to it_h_lfb1.
insert table it_h_lfb1.
* table of accounts:
perform fill_acct_table using c_koart_ap
lfb1-lifnr
lfb1-bukrs
lfa1-kunnr
lfa1-name1
space.
endform. " LFB1_INFO_FILL
*&---------------------------------------------------------------------*
*& Form LFB1_CHECK_BRANCH
*&---------------------------------------------------------------------*
form lfb1_check_branch.
data: ls_selection like addr1_sel,
ls_branch_addr like addr1_val,
ls_central_addr like addr1_val,
ls_lfa1 like lfa1,
lb_okay type c.
data: ld_mandt like lfb1-mandt.
data: ld_bukrs like lfb1-bukrs.
data: ld_lnrze like lfb1-lnrze.
data: ld_text(2) type c.
loop at it_h_lfb1 where not lnrze is initial.
if pa_cent ne 'N'.
ld_mandt = it_h_lfb1-mandt.
ld_bukrs = it_h_lfb1-bukrs.
ld_lnrze = it_h_lfb1-lnrze.
read table it_h_lfb1 with key mandt = ld_mandt
lifnr = ld_lnrze
bukrs = ld_bukrs
binary search
transporting no fields.
if sy-subrc = 0.
continue.
else.
clear it_central.
if pa_cent is initial.
* check permanent user setting:
get parameter id 'FIT_BRANCH' field ld_text.
if ld_text+1(1) = 'X'.
* 'never again' case:
lb_okay = ld_text(1).
else.
* get central address record for branch account:
read table it_h_lfa1 with key mandt = it_h_lfb1-mandt
lifnr = it_h_lfb1-lifnr
binary search.
if sy-subrc = 0.
ls_selection-addrnumber = it_h_lfa1-adrnr.
call function 'ADDR_GET'
exporting
address_selection = ls_selection
importing
address_value = ls_branch_addr
exceptions
parameter_error = 1
others = 2.
endif.
* get central address record for central account:
select single name1 adrnr from lfa1
into corresponding fields of ls_lfa1
where lifnr = it_h_lfb1-lnrze.
if sy-subrc = 0.
ls_selection-addrnumber = ls_lfa1-adrnr.
call function 'ADDR_GET'
exporting
address_selection = ls_selection
importing
address_value = ls_central_addr
exceptions
parameter_error = 1
others = 2.
endif.
* show popup:
call function 'FI_ITEMS_BRANCH_CENTRAL'
exporting
id_branch_acct = it_h_lfb1-lifnr
id_branch_name1 = ls_branch_addr-name1
id_central_acct = it_h_lfb1-lnrze
id_central_name1 = ls_central_addr-name1
id_bukrs = it_h_lfb1-bukrs
importing
eb_central_items = lb_okay.
endif.
endif.
* return to selection screen, if selection is cancelled in Branch/Head
* Popup:
if lb_okay = 'C'.
pa_cent = 'C'.
clear it_central.
refresh it_central.
exit.
endif.
* add account to memory, and fill central account, if required:
if pa_cent = 'Y' or lb_okay = 'X'.
it_central-central = it_h_lfb1-lnrze.
endif.
it_central-branch = it_h_lfb1-lifnr.
it_central-bukrs = it_h_lfb1-bukrs.
append it_central.
endif.
endif.
endloop.
endform. "lfb1_check_branch
*&---------------------------------------------------------------------*
*& Form T001_INFO_FILL
*&---------------------------------------------------------------------*
form t001_info_fill.
read table it_h_t001 with key mandt = sy-mandt
bukrs = lfb1-bukrs
binary search.
if sy-subrc ne 0.
clear: it_h_t001.
select single * from t001 into it_h_t001
where bukrs = lfb1-bukrs.
insert table it_h_t001.
* table of companies:
perform fill_comp_table using lfb1-bukrs
it_h_t001-waers
it_h_t001-kkber.
endif.
if wa_x001-bukrs ne lfb1-bukrs.
clear: wa_x001.
call function 'FI_CURRENCY_INFORMATION'
exporting
i_bukrs = lfb1-bukrs
importing
e_x001 = wa_x001
exceptions
currency_2_not_defined = 1
currency_3_not_defined = 2
others = 3.
if sy-subrc = 0.
* ?
endif.
endif.
endform. " T001_INFO_FILL
*&---------------------------------------------------------------------*
*& Form MAP_SEL_TO_LDB
*&---------------------------------------------------------------------*
form map_sel_to_ldb.
data: ld_stida like sy-datum.
clear: kd_opopt, kd_apopt, kd_stida, kd_augdt, kd_budat.
refresh: kd_augdt, kd_budat.
* Determine whether parked (xstav) and/or normal items
* (xstan) must be selected by the log. database
if x_park = 'X'.
b0sg-xstav = 'X'.
else.
clear b0sg-xstav.
endif.
if ( x_norm = 'X' or x_shbv = 'X' or x_merk = 'X' ).
b0sg-xstan = 'X'.
else.
clear b0sg-xstan.
endif.
* Determine relevant keydates for the selection by the log. database
* (kd_stida)
get parameter id 'FI_STIDA' field ld_stida.
if not ld_stida is initial and sy-subrc eq 0.
pa_stida = ld_stida.
set parameter id 'FI_STIDA' field '00000000'.
endif.
case 'X'.
when x_opsel.
if pa_stida is initial.
p_keydate = '99991231'.
kd_stida = '99991231'.
b0sg-xnopl = 'X'.
else.
p_keydate = pa_stida.
kd_stida = pa_stida.
endif.
kd_opopt = 'X'.
when x_clsel.
if pa_stid2 is initial.
p_keydate = '99991231'.
kd_stida = '00010101'.
else.
p_keydate = pa_stid2.
kd_stida = pa_stid2.
kd_budat-sign = 'I'.
kd_budat-option = 'LE'.
kd_budat-low = pa_stid2.
append kd_budat.
endif.
kd_augdt[] = so_augdt[].
when x_aisel.
p_keydate = '99991231'.
kd_stida = '99991231'.
kd_budat[] = so_budat[].
kd_opopt = 'X'.
kd_apopt = 'X'.
endcase.
pa_stida_default = kd_stida.
* For reading from archives:
* number of archived items as i-message:
kd_iarch = 'X'.
kd_memor = 'X'.
endform. "map_sel_to_ldb
*&---------------------------------------------------------------------*
*& Form SET_PARAMETERS
*&---------------------------------------------------------------------*
form set_parameters.
* set general parameters:
perform set_general_param.
* set acc.type specific parameters:
clear: kd_lifnr, kd_bukrs.
clear: so_wllif, so_wlbuk.
if gd_wl_on is initial.
read table kd_lifnr index 1.
if sy-subrc = 0 and kd_lifnr-sign = 'I' and kd_lifnr-option = 'EQ'
and not kd_lifnr-low is initial.
set parameter id 'LIF' field kd_lifnr-low.
endif.
read table kd_bukrs index 1.
if sy-subrc = 0 and kd_bukrs-sign = 'I' and kd_bukrs-option = 'EQ'
and not kd_bukrs-low is initial.
set parameter id 'BUK' field kd_bukrs-low.
endif.
set parameter id 'AVK' field space.
set parameter id 'AVB' field space.
else.
* worklists switched on:
set parameter id 'AVK' field pa_wllif.
set parameter id 'AVB' field pa_wlbuk.
read table so_wllif index 1.
if sy-subrc = 0 and so_wllif-sign = 'I' and so_wllif-option = 'EQ'
and not so_wllif-low is initial.
set parameter id 'LIF' field so_wllif-low.
endif.
read table so_wlbuk index 1.
if sy-subrc = 0 and so_wlbuk-sign = 'I' and so_wlbuk-option = 'EQ'
and not so_wlbuk-low is initial.
set parameter id 'BUK' field so_wlbuk-low.
endif.
endif.
* Set parameters for reading from archiv
gd_usear = kd_usear.
gd_usedb = kd_usedb.
gd_memor = 'X'.
endform. "set_parameters
*&---------------------------------------------------------------------*
*& Form READ_CUSTOMER_ITEMS
*&---------------------------------------------------------------------*
form read_customer_items.
* prepare selection screen table:
perform ddf_selscreen.
if sy-subrc <> 0 .
sy-subrc = 0.
exit.
endif.
* prepare dynamic selections:
perform ddf_dynamics.
* prepare callbacks for ldb_process:
perform fill_ddf_callback.
* export b0sg flags for ldb
export b0sg to memory id 'DDF_B0SG'.
* read ldb DDF:
call function 'LDB_PROCESS'
exporting
ldbname = 'DDF'
expressions = it_dyn_texpr[]
tables
callback = it_callback
selections = it_selscreen
exceptions
ldb_selections_error = 1
ldb_selections_not_accepted = 2
free_selections_error = 3
callback_no_event = 4
callback_no_program = 5
callback_no_cbform = 6
others = 7.
if sy-subrc ne 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
else.
perform import_arch_from_memory.
endif.
endform. " READ_CUSTOMER_ITEMS
*&---------------------------------------------------------------------*
*& Form READ_CENTRAL_ITEMS
*&---------------------------------------------------------------------*
form read_central_items.
* loop over all identified central office accts:
loop at it_central where not central is initial.
* prepare selection screen table:
perform kdf_selscreen.
* prepare dynamic selections:
perform kdf_dynamics.
* prepare callbacks for ldb_process:
perform fill_kdf_callback.
* export b0sg flags for ldb
export b0sg to memory id 'KDF_B0SG'.
* read ldb DDF:
call function 'LDB_PROCESS'
exporting
ldbname = 'KDF'
expressions = it_dyn_texpr[]
* DYN_NODE_TYPES =
tables
callback = it_callback
selections = it_selscreen
exceptions
ldb_not_reentrant = 1
ldb_incorrect = 2
ldb_already_running = 3
ldb_error = 4
ldb_selections_error = 5
ldb_selections_not_accepted = 6
free_selections_error = 10
callback_no_event = 11
callback_node_duplicate = 12
callback_no_program = 13
callback_no_cbform = 14
others = 17.
if sy-subrc = 0 .
perform import_arch_from_memory.
endif.
endloop.
endform. " READ_CENTRAL_ITEMS
*&---------------------------------------------------------------------*
*& Form DDF_SELSCREEN
*&---------------------------------------------------------------------*
form ddf_selscreen.
types: begin of acccoco,
kunnr like lfa1-kunnr,
bukrs like lfb1-bukrs,
end of acccoco.
data: ld_selections_old type acccoco.
statics: st_selections_old type sorted table of acccoco
with unique key kunnr bukrs.
ld_selections_old-kunnr = lfa1-kunnr.
ld_selections_old-bukrs = lfb1-bukrs.
insert ld_selections_old into table st_selections_old.
if sy-subrc <> 0.
exit.
else.
refresh: it_selscreen.
* fill selections: first single values & parameters
it_selscreen-selname = 'DD_KUNNR'.
it_selscreen-kind = 'S'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = lfa1-kunnr.
append it_selscreen.
clear it_selscreen.
it_selscreen-selname = 'DD_BUKRS'.
it_selscreen-kind = 'S'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = lfb1-bukrs.
append it_selscreen.
clear it_selscreen.
it_selscreen-selname = 'DD_OPOPT'.
it_selscreen-kind = 'P'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = kd_opopt.
append it_selscreen.
clear it_selscreen.
it_selscreen-selname = 'DD_APOPT'.
it_selscreen-kind = 'P'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = kd_apopt.
append it_selscreen.
clear it_selscreen.
it_selscreen-selname = 'DD_STIDA'.
it_selscreen-kind = 'P'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = kd_stida.
append it_selscreen.
* now select option tables:
loop at kd_augdt.
clear it_selscreen.
it_selscreen-selname = 'DD_AUGDT'.
it_selscreen-kind = 'S'.
move-corresponding kd_augdt to it_selscreen.
append it_selscreen.
endloop.
loop at kd_budat.
clear it_selscreen.
it_selscreen-selname = 'DD_BUDAT'.
it_selscreen-kind = 'S'.
move-corresponding kd_budat to it_selscreen.
append it_selscreen.
endloop.
if sy-subrc <> 0.
sy-subrc = 0.
endif.
* Parameters and Select Options for Archives
clear it_selscreen.
it_selscreen-selname = 'DD_USEDB'.
it_selscreen-kind = 'P'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = kd_usedb.
append it_selscreen.
clear it_selscreen.
it_selscreen-selname = 'DD_USEAR'.
it_selscreen-kind = 'P'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = kd_usear.
append it_selscreen.
clear it_selscreen.
it_selscreen-selname = 'DD_USEAS'.
it_selscreen-kind = 'P'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = kd_useas.
append it_selscreen.
if not kd_files[] is initial.
loop at kd_files.
clear it_selscreen.
it_selscreen-selname = 'DD_FILES'.
it_selscreen-kind = 'S'.
move-corresponding kd_files to it_selscreen.
append it_selscreen.
endloop.
endif.
clear it_selscreen.
it_selscreen-selname = 'DD_MEMOR'.
it_selscreen-kind = 'P'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = kd_memor.
append it_selscreen.
clear it_selscreen.
it_selscreen-selname = 'DD_IARCH'.
it_selscreen-kind = 'P'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = kd_iarch.
append it_selscreen.
clear it_selscreen.
it_selscreen-selname = 'DD_NOOAP'.
it_selscreen-kind = 'P'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = kd_nooap.
append it_selscreen.
endif.
endform. " DDF_SELSCREEN
*&---------------------------------------------------------------------*
*& Form KDF_SELSCREEN
*&---------------------------------------------------------------------*
form kdf_selscreen.
refresh: it_selscreen.
* fill selections: first single values & parameters
it_selscreen-selname = 'KD_LIFNR'.
it_selscreen-kind = 'S'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = it_central-central.
append it_selscreen.
clear it_selscreen.
it_selscreen-selname = 'KD_BUKRS'.
it_selscreen-kind = 'S'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = it_central-bukrs.
append it_selscreen.
clear it_selscreen.
it_selscreen-selname = 'KD_OPOPT'.
it_selscreen-kind = 'P'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = kd_opopt.
append it_selscreen.
clear it_selscreen.
it_selscreen-selname = 'KD_APOPT'.
it_selscreen-kind = 'P'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = kd_apopt.
append it_selscreen.
clear it_selscreen.
it_selscreen-selname = 'KD_STIDA'.
it_selscreen-kind = 'P'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = kd_stida.
append it_selscreen.
* now select option tables:
loop at kd_augdt.
clear it_selscreen.
it_selscreen-selname = 'KD_AUGDT'.
it_selscreen-kind = 'S'.
move-corresponding kd_augdt to it_selscreen.
append it_selscreen.
endloop.
loop at kd_budat.
clear it_selscreen.
it_selscreen-selname = 'KD_BUDAT'.
it_selscreen-kind = 'S'.
move-corresponding kd_budat to it_selscreen.
append it_selscreen.
endloop.
* Parameters and Select Options for Archives
clear it_selscreen.
it_selscreen-selname = 'KD_USEDB'.
it_selscreen-kind = 'P'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = kd_usedb.
append it_selscreen.
clear it_selscreen.
it_selscreen-selname = 'KD_USEAR'.
it_selscreen-kind = 'P'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = kd_usear.
append it_selscreen.
clear it_selscreen.
it_selscreen-selname = 'KD_USEAS'.
it_selscreen-kind = 'P'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = kd_useas.
append it_selscreen.
if not kd_files[] is initial.
loop at kd_files.
clear it_selscreen.
it_selscreen-selname = 'KD_FILES'.
it_selscreen-kind = 'S'.
move-corresponding kd_files to it_selscreen.
append it_selscreen.
endloop.
endif.
clear it_selscreen.
it_selscreen-selname = 'KD_MEMOR'.
it_selscreen-kind = 'P'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = kd_memor.
append it_selscreen.
clear it_selscreen.
it_selscreen-selname = 'KD_MEMOR'.
it_selscreen-kind = 'P'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = kd_memor.
append it_selscreen.
clear it_selscreen.
it_selscreen-selname = 'KD_NOOAP'.
it_selscreen-kind = 'P'.
it_selscreen-sign = 'I'.
it_selscreen-option = 'EQ'.
it_selscreen-low = kd_nooap.
append it_selscreen.
endform. " KDF_SELSCREEN
*&---------------------------------------------------------------------*
*& Form DDF_DYNAMICS
*&---------------------------------------------------------------------*
form ddf_dynamics.
data: rt_dyn_trange type rsds_trange.
refresh: it_dyn_texpr.
* get report dynamic selections:
call function 'RS_REFRESH_FROM_DYNAMICAL_SEL'
exporting
curr_report = g_repid
mode_write_or_move = 'M'
importing
p_trange = rt_dyn_trange
exceptions
not_found = 1
wrong_type = 2
others = 3.
if sy-subrc ne 0.
exit.
endif.
delete rt_dyn_trange where tablename ne 'BSIK'.
call function 'FREE_SELECTIONS_RANGE_2_EX'
exporting
field_ranges = rt_dyn_trange
importing
expressions = it_dyn_texpr[].
* replace tablenames: vendor -> customer
loop at it_dyn_texpr.
case it_dyn_texpr-tablename.
when 'LFA1'.
it_dyn_texpr-tablename = 'KNA1'.
when 'LFB1'.
it_dyn_texpr-tablename = 'KNB1'.
when 'BSIK'.
it_dyn_texpr-tablename = 'BSID'.
when others.
delete it_dyn_texpr.
continue.
endcase.
modify it_dyn_texpr.
endloop.
* create dummy if it_dyn_texpr is empty, due to technical reasons
* in LDB runtime environment (refresh DYN_SEL)
read table it_dyn_texpr index 1.
if sy-subrc ne 0.
append initial line to it_dyn_texpr.
endif.
endform. " DDF_DYNAMICS
*&---------------------------------------------------------------------*
*& Form KDF_DYNAMICS
*&---------------------------------------------------------------------*
form kdf_dynamics.
data: rt_dyn_trange type rsds_trange,
ls_expr like rsdsexpr.
refresh: it_dyn_texpr,
it_dyn_texpr-expr_tab.
* get report dynamic selections:
call function 'RS_REFRESH_FROM_DYNAMICAL_SEL'
exporting
curr_report = g_repid
mode_write_or_move = 'M'
importing
p_trange = rt_dyn_trange
exceptions
not_found = 1
wrong_type = 2
others = 3.
if sy-subrc > 1.
exit.
endif.
delete rt_dyn_trange where tablename ne 'BSIK'.
call function 'FREE_SELECTIONS_RANGE_2_EX'
exporting
field_ranges = rt_dyn_trange
importing
expressions = it_dyn_texpr[].
* add selection: items belonging to branch
it_dyn_texpr-tablename = 'BSIK'.
ls_expr-fieldname = 'FILKD'.
ls_expr-option = 'EQ'.
ls_expr-low = it_central-branch.
append ls_expr to it_dyn_texpr-expr_tab.
append it_dyn_texpr.
endform. " KDF_DYNAMICS
*&---------------------------------------------------------------------*
*& Form FILL_DDF_CALLBACK
*&---------------------------------------------------------------------*
form fill_ddf_callback.
refresh: it_callback.
it_callback-ldbnode = 'KNA1'.
it_callback-get = 'X'.
it_callback-cb_prog = c_repid_ap.
it_callback-cb_form = 'CB_DDF_GET_KNA1'.
append it_callback.
it_callback-ldbnode = 'BSID'.
it_callback-get = 'X'.
it_callback-cb_prog = c_repid_ap.
it_callback-cb_form = 'CB_DDF_GET_BSID'.
append it_callback.
endform. " FILL_LDB_CALLBACK
*&---------------------------------------------------------------------*
*& Form FILL_KDF_CALLBACK
*&---------------------------------------------------------------------*
form fill_kdf_callback.
refresh: it_callback.
it_callback-ldbnode = 'LFA1'.
it_callback-get = 'X'.
it_callback-cb_prog = c_repid_ap.
it_callback-cb_form = 'CB_KDF_GET_LFA1'.
append it_callback.
it_callback-ldbnode = 'BSIK'.
it_callback-get = 'X'.
it_callback-cb_prog = c_repid_ap.
it_callback-cb_form = 'CB_KDF_GET_BSIK'.
append it_callback.
endform. " FILL_KDF_CALLBACK
*&---------------------------------------------------------------------*
*& Form CB_DDF_GET_BSID
*&---------------------------------------------------------------------*
form cb_ddf_get_bsid using name like ldbn-ldbnode
ls_bsid like bsid
mode type c
selected type c.
bsid = ls_bsid.
perform pos_table_fill_customer changing x_stop.
endform. " CB_DDF_GET_BSID
*&---------------------------------------------------------------------*
*& Form CB_KDF_GET_BSIK
*&---------------------------------------------------------------------*
form cb_kdf_get_bsik using name like ldbn-ldbnode
ls_bsik like bsik
mode type c
selected type c.
bsik = ls_bsik.
* HWAER would be filled incorrect in the case the IT_H_T001
* stands on the wrong entry
IF bsik-bukrs <> it_h_t001-bukrs.
READ TABLE it_h_t001 WITH KEY BUKRS = bsik-bukrs.
ENDIF.
* attention: change account number!!
bsik-lifnr = bsik-filkd.
perform pos_table_fill changing x_stop.
endform. " CB_DDF_GET_BSID
*&---------------------------------------------------------------------*
*& Form SET_ACCT_AND_CCODE
*&---------------------------------------------------------------------*
form set_acct_and_ccode.
refresh: kd_lifnr, kd_bukrs, so_wllif, so_wlbuk.
clear: kd_lifnr, kd_bukrs, so_wllif, so_wlbuk,
pa_wllif, pa_wlbuk.
if gd_wl_on is initial.
get parameter id 'LIF' field kd_lifnr-low.
if sy-subrc = 0 and not kd_lifnr-low is initial.
kd_lifnr-sign = 'I'.
kd_lifnr-option = 'EQ'.
append kd_lifnr.
endif.
get parameter id 'BUK' field kd_bukrs-low.
if sy-subrc = 0 and not kd_bukrs-low is initial.
kd_bukrs-sign = 'I'.
kd_bukrs-option = 'EQ'.
append kd_bukrs.
endif.
else.
* worklists switched on:
get parameter id 'AVK' field pa_wllif.
get parameter id 'AVB' field pa_wlbuk.
if pa_wllif is initial.
get parameter id 'LIF' field so_wllif-low.
if sy-subrc = 0 and not so_wllif-low is initial.
so_wllif-sign = 'I'.
so_wllif-option = 'EQ'.
append so_wllif.
endif.
endif.
if pa_wlbuk is initial.
get parameter id 'BUK' field so_wlbuk-low.
if sy-subrc = 0 and not so_wlbuk-low is initial.
so_wlbuk-sign = 'I'.
so_wlbuk-option = 'EQ'.
append so_wlbuk.
endif.
endif.
endif.
endform. " SET_ACCT_AND_CCODE
*---------------------------------------------------------------------*
* FORM CB_KDF_GET_LFA1 *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> NAME *
* --> LS_LFA1 *
* --> MODE *
* --> SELECTED *
*---------------------------------------------------------------------*
form cb_kdf_get_lfa1 using name like ldbn-ldbnode
ls_lfa1 like lfa1
mode type c
selected type c.
data: ld_koart type koart.
lfa1 = ls_lfa1.
ld_koart = 'K'.
perform t005_info_fill using ld_koart.
endform. "CB_KDF_GET_LFA1
*---------------------------------------------------------------------*
* FORM CB_DDF_GET_KNA1 *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> NAME *
* --> LS_KNA1 *
* --> MODE *
* --> SELECTED *
*---------------------------------------------------------------------*
form cb_ddf_get_kna1 using name like ldbn-ldbnode
ls_kna1 like kna1
mode type c
selected type c.
data: ld_koart type koart.
kna1 = ls_kna1.
ld_koart = 'D'.
perform t005_info_fill using ld_koart.
endform. "CB_DDF_GET_KNA1
*&---------------------------------------------------------------------*
*& Form t005_info_fill
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form t005_info_fill using ld_koart type koart.
if ld_koart = 'D'.
if not kna1-land1 is initial.
select single * from t005 where land1 = kna1-land1.
endif.
elseif ld_koart = 'K' .
if not lfa1-land1 is initial.
select single * from t005 where land1 = lfa1-land1.
endif.
endif.
endform. " t005_info_fill
*&---------------------------------------------------------------------*
*& Include RFITEM_INC
*&---------------------------------------------------------------------*
include rfitem_inc.
*