*& 计划参数文件相关MDPH,更改与特性相关标记
*&---------------------------------------------------------------------*
report zppe0113
message-id zfd-002.
*&---------------------------------------------------------------------*
*& INCLUDE
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& TABLES
*&---------------------------------------------------------------------*
tables:marc.
*&---------------------------------------------------------------------*
*& TYPES
*&---------------------------------------------------------------------*
* TYPES:
*&---------------------------------------------------------------------*
*& CONSTANTS
*&---------------------------------------------------------------------*
* CONSTANTS:
*&---------------------------------------------------------------------*
*& PROGRAM VARIABLES
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& FIELD-SYMBOLS
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& STRUCTURES
*&---------------------------------------------------------------------*
* DATA:
*&---------------------------------------------------------------------*
*& INTERNAL TABLES
*&---------------------------------------------------------------------*
data:begin of it_config occurs 0,
matnr like mara-matnr,
end of it_config.
data:begin of it_tphvp occurs 0,
matnr like tphvp-objekt,
profilid like tphvp-profilid,
end of it_tphvp,
begin of it_tplvp occurs 0,
profilid like tplvp-profilid,
clint like tplvp-clint,
lnpos like tpsvp-lnpos,
pl_rel like tpsvp-pl_rel,
atinn(10) type n,
valc(3) type n,
end of it_tplvp,
begin of it_modify occurs 0,
matnr like tphvp-objekt,
atinn(13) type n,
end of it_modify .
*&---------------------------------------------------------------------*
*& RANGES
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& SELECT SCREEN
*&---------------------------------------------------------------------*
selection-screen: begin of block b1 with frame title text-001.
select-options:s_matnr for marc-matnr obligatory.
selection-screen:skip 1.
parameters: p_add radiobutton group g1,
p_cancel radiobutton group g1.
selection-screen: end of block b1.
************************************************************************
* INITIALIZATION
************************************************************************
* INITIALIZATION.
************************************************************************
* AT SELECTION-SCREEN
************************************************************************
************************************************************************
* TOP-OF-PAGE
************************************************************************
* TOP-OF-PAGE.
************************************************************************
* START-OF-SELECTION
************************************************************************
start-of-selection.
if p_add = 'X'.
*& 读取计划参数文件
perform read_plan_para_file.
*& 保存现有配置文件到本地
perform save_config_file_to_local.
*& 把所有的标记勾上
perform update_pl_rel_flag.
else.
call function 'ZWS_UPLOAD'
exporting
filename = 'c:/pzwj.txt'
filetype = 'DAT'
tables
data_tab = it_tplvp
exceptions
conversion_error = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
gui_refuse_filetransfer = 6
others = 7.
if sy-subrc <> 0.
message '原始文件上传出错,请检查c:/pzwj.txt文件是否存在!'
type 'E'.
else.
loop at it_tplvp.
update tpsvp set pl_rel = it_tplvp-pl_rel
where profilid = it_tplvp-profilid and
clint = it_tplvp-clint and
lnpos = it_tplvp-lnpos.
endloop.
commit work and wait.
if sy-subrc = 0.
message '特性值调整完成!' type 'S'.
endif.
endif.
endif.
************************************************************************
* END-OF-SELECTION
************************************************************************
end-of-selection.
*&---------------------------------------------------------------------*
*& Form READ_PLAN_PARA_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form read_plan_para_file .
data:begin of it_cuvtab_valc occurs 0,
slnid like cuvtab_valc-slnid,
atinn like cuvtab_valc-atinn,
valc like cuvtab_valc-valc,
end of it_cuvtab_valc,
l_atnam(10).
field-symbols:<fs_tplvp> like line of it_tplvp.
select objekt as matnr profilid
into table it_tphvp
from tphvp
where objekt in s_matnr.
if not it_tphvp[] is initial.
select profilid clint lnpos pl_rel
into table it_tplvp
from tpsvp
for all entries in it_tphvp
where profilid = it_tphvp-profilid.
endif.
sort it_tplvp by profilid clint.
loop at it_tplvp assigning <fs_tplvp>.
at new clint.
*& 内部表号对应的特性,特性值
refresh:it_cuvtab_valc.
select slnid atinn valc
into table it_cuvtab_valc
from cuvtab_valc
where vtint = <fs_tplvp>-clint.
endat.
read table it_cuvtab_valc with key slnid = <fs_tplvp>-lnpos.
if sy-subrc = 0.
<fs_tplvp>-atinn = it_cuvtab_valc-atinn.
<fs_tplvp>-valc = it_cuvtab_valc-valc.
endif.
if <fs_tplvp>-pl_rel is initial.
clear:l_atnam.
perform convert_into_output_format using <fs_tplvp>-atinn
changing l_atnam.
clear:it_modify.
concatenate l_atnam <fs_tplvp>-valc into it_modify-atinn.
read table it_tphvp with key profilid = <fs_tplvp>-profilid.
if sy-subrc = 0.
it_modify-matnr = it_tphvp-matnr.
collect it_modify.
endif.
endif.
endloop.
endform. " READ_PLAN_PARA_FILE
*&---------------------------------------------------------------------*
*& Form convert_into_output_format
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ATINN text
* -->RET_ATNAM text
*----------------------------------------------------------------------*
form convert_into_output_format using p_atinn
changing ret_atnam.
call function 'CONVERSION_EXIT_ATINN_OUTPUT'
exporting
input = p_atinn
importing
output = ret_atnam.
endform. " CONVERT_INTO_OUTPUT_FORMAT
*&---------------------------------------------------------------------*
*& Form SAVE_CONFIG_FILE_TO_LOCAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form save_config_file_to_local .
call function 'ZWS_DOWNLOAD'
exporting
filename = 'c:/pzwj.txt'
filetype = 'DAT'
tables
data_tab = it_tplvp
exceptions
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
no_authority = 10
others = 11.
if sy-subrc <> 0.
message '原有计划参数文件保存错误,请联系相关负责人!' type 'E'.
endif.
endform. " SAVE_CONFIG_FILE_TO_LOCAL
*&---------------------------------------------------------------------*
*& Form UPDATE_PL_REL_FLAG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form update_pl_rel_flag .
loop at it_tplvp.
*&更新所有的标记,分更新计划参署文件行,mrp相关的DBVM,DBVL
at new profilid.
update tpsvp set pl_rel = 'X'
where profilid = it_tplvp-profilid.
perform update_mrp_parameters using it_tplvp-profilid.
endat.
endloop.
commit work and wait.
if not it_tplvp[] is initial.
write:at /2 '车 型',20 '特 性'.
loop at it_modify.
write:at /2 it_modify-matnr,20 it_modify-atinn.
endloop.
endif.
endform. " UPDATE_PL_REL_FLAG
*&---------------------------------------------------------------------*
*& Form update_mrp_parameters
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_PROFILID text
*----------------------------------------------------------------------*
form update_mrp_parameters using p_profilid .
data:l_ustmp(15) type n.
concatenate sy-datum sy-uzeit into l_ustmp.
read table it_tphvp with key profilid = p_profilid.
if sy-subrc = 0.
update dbvm set gsaen = 'X'
akken = 'X'
resal = 'X'
mpskz = 'X'
erdat = sy-datum
ustmp = l_ustmp
where matnr = it_tphvp-matnr and
berid = '1000' and
( gsaen <> 'X' or
akken <> 'X' or
resal <> 'X' or
mpskz <> 'X' ).
update dbvl set gsaen = 'X'
akken = 'X'
resal = 'X'
mpskz = 'X'
erdat = sy-datum
ustmp = l_ustmp
where matnr = it_tphvp-matnr and
berid = '1000' and
( gsaen <> 'X' or
akken <> 'X' or
resal <> 'X' or
mpskz <> 'X' ) .
endif.
endform. " UPDATE_MRP_PARAMETERS