Professional Documents
Culture Documents
*&---------------------------------------------------------------------*
*& form f_get_f4_chess
*&---------------------------------------------------------------------*
* >>>> f4 help for p_chess
*----------------------------------------------------------------------*
form f_get_f4_chess .
form f_get_f4_visual .
call function '/sapdmc/lsm_f4_server_file'
importing
serverfile = p_visual
exceptions
canceled_by_user = 1
others = 2.
if sy-subrc <> 0.
* message id sy-msgid type sy-msgty number sy-msgno
* with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " f_get_f4_visual
*&---------------------------------------------------------------------*
*& form f_get_f4_error
*&---------------------------------------------------------------------*
* >>>>f4 help for p_error
*----------------------------------------------------------------------*
form f_get_f4_error .
call function '/sapdmc/lsm_f4_server_file'
importing
serverfile = p_error
exceptions
canceled_by_user = 1
others = 2.
if sy-subrc <> 0.
* message id sy-msgid type sy-msgty number sy-msgno
* with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " f_get_f4_error
*&---------------------------------------------------------------------*
*& form f_validate_p_chess
*&---------------------------------------------------------------------*
* >>> chess demand file validation *
*----------------------------------------------------------------------*
form f_validate_p_chess .
if sy-subrc eq 0.
sort i_plaf by plnum ascending.
* selection of records from database table mdsb.
select rsnum
rspos
plnum
matnr
erfmg
from mdsb
into table i_mdsb
for all entries in i_plaf
where plnum eq i_plaf-plnum.
if sy-subrc eq 0.
sort i_mdsb by matnr ascending.
endif.
else.
* text-105 - no planned order numbers are available for the plant 2000
wa_error-message = text-105.
append wa_error to i_error.
clear wa_error.
endif.
if sy-subrc eq 0.
sort i_chess_dmnd by zplnum ascending.
endif.
wa_chess_dmnd-zplanord_del = c_y.
wa_chess_dmnd-zdel_date = sy-datum.
wa_chess_dmnd-zlast_date = sy-datum.
endif.
endloop.
endif.
* sort i_round
sort i_round by matnr ascending.
endloop.
endif.
wa_chess-status = c_1.
wa_chess-plant = c_nc1.
wa_chess-cur = c_cur.
wa_chess-part_number = wa_mdsb-matnr.
wa_chess-stream = c_forecast.
v_date = wa_plaf-psttr+6(2).
v_month = wa_plaf-psttr+4(2).
v_year = wa_plaf-psttr+2(2).
wa_chess-date = v_date1.
wa_chess-blank2 = space.
clear wa_round.
read table i_round into wa_round
with key matnr = wa_mdsb-matnr.
* binary search.
if sy-subrc eq 0.
if wa_round-rflag = c_x.
wa_chess-qty = floor( wa_mdsb-erfmg ).
wa_round-rflag = space.
* modify the internal table i_round from wa_round
modify table i_round from wa_round
transporting rflag.
elseif wa_round-rflag ne c_x.
wa_chess-qty = ceil( wa_mdsb-erfmg ).
wa_round-rflag = c_x.
* modify the internal table i_round from wa_round
modify table i_round from wa_round
transporting rflag.
endif.
else.
* get the nearest value using ceil
wa_chess-qty = ceil( wa_mdsb-erfmg ) .
wa_round-matnr = wa_mdsb-matnr.
wa_round-rflag = c_x.
form f_get_2179_info .
else.
wa_mat_plant-plant = wa_plaf-plwrk.
wa_mat_plant-material = wa_plaf-matnr.
append wa_mat_plant to i_mat_plant.
clear wa_mat_plant.
case v_mts_mto_flag.
when c_mts.
if sy-subrc <> 0.
* message id sy-msgid type sy-msgty number sy-msgno
* with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
wa_mat_plant-plant = wa_plaf-plwrk.
wa_mat_plant-material = v_matwa.
append wa_mat_plant to i_mat_plant.
clear wa_mat_plant.
if sy-subrc <> 0.
* message id sy-msgid type sy-msgty number sy-msgno
* with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endcase.
endif.
form write_new_record .
wa_chess_dmnd2-zplant_code = wa_plaf-plwrk.
if v_mts_mto_flag = c_xr.
wa_chess_dmnd2-zorig_rectyp = c_1.
elseif v_mts_mto_flag <> c_xr and wa_plaf-trmkz <> c_x.
wa_chess_dmnd2-zorig_rectyp = c_2.
elseif v_mts_mto_flag <> c_xr and wa_plaf-trmkz = c_x.
wa_chess_dmnd2-zorig_rectyp = c_3 .
endif.
wa_chess_dmnd2-zmts_mto_flag = v_mts_mto_flag.
wa_chess_dmnd2-zplnum = wa_plaf-plnum.
if v_mts_mto_flag = c_xr.
* read the internal table i_serial into wa_serial with index v_count
clear wa_serial.
read table i_serial into wa_serial
index v_counter.
if sy-subrc eq 0.
wa_chess_dmnd2-zxr_serialno = wa_serial-serial_no.
endif.
endif.
endif.
wa_chess_dmnd2-zorig_partnum = v_matnr.
wa_chess_dmnd2-zcurr_partnum = v_matnr.
wa_chess_dmnd2-zorig_catnum = v_matwa.
wa_chess_dmnd2-zcurr_catnum = v_matwa.
if v_mts_mto_flag = c_xr.
wa_chess_dmnd2-zwonum = wa_chess_dmnd2-zxr_serialno.
else.
if wa_plaf-trmkz = c_x.
* read the table i_wo_cnt into wa_wo_cnt index 1.
clear wa_wo_cnt.
read table i_wo_cnt into wa_wo_cnt
index 1.
if sy-subrc eq 0.
wa_wo_cnt-zwo_counter = wa_wo_cnt-zwo_counter + 1.
wa_chess_dmnd2-zwonum = wa_wo_cnt-zwo_counter.
form f_update_existing_records .
endif.
v_verid = wa_plaf-verid+1(3).
concatenate c_0 v_verid into v_verid.
endif.
endif.
if wa_chess_dmnd-zcurr_qty <> wa_plaf-gsmng.
form f_update_and_insert_records .
if sy-subrc eq 0.
if sy-subrc ne 0.
wa_error-message = text-213.
* append the internal table i_error from wa_error
append wa_error to i_error.
endif.
endif.
if i_chess_dmnd2[] is not initial.
insert z1120_chs_dmnd from table i_chess_dmnd2
accepting duplicate keys.
if sy-subrc <> 0.
wa_error-message = text-214.
* append the internal table i_error from wa_error
append wa_error to i_error.
endif.
endif.
endif.
endif.
case wa_chess_dmnd2-zmts_mto_flag.
when c_xr.
wa_chess-part_number = wa_chess_dmnd2-zxr_serialno.
when c_eto.
wa_chess-part_number = wa_chess_dmnd2-zcurr_catnum.
when c_others.
wa_chess-part_number = wa_chess_dmnd2-zcurr_partnum.
endcase.
if wa_chess_dmnd2-zmts_mto_flag = c_xr.
wa_chess-stream = wa_chess_dmnd2-zxr_serialno.
endif.
if wa_chess_dmnd2-zorig_fdate lt sy-datum.
wa_chess_dmnd2-zorig_fdate = sy-datum + 1.
endif.
v_date = wa_chess_dmnd2-zorig_fdate+6(2).
v_month = wa_chess_dmnd2-zorig_fdate+4(2).
v_year = wa_chess_dmnd2-zorig_fdate+2(2).
concatenate v_date v_month v_year into v_date1.
wa_chess-date = v_date1.
wa_chess-blank2 = space.
if wa_round-rflag = c_x.
endloop.
endif.
form f_write_vf_records .
case wa_chess_dmnd2-zmts_mto_flag.
when c_xr.
wa_visual-bom = wa_chess_dmnd2-zxr_serialno.
when c_eto.
wa_visual-bom = wa_chess_dmnd2-zcurr_catnum.
when c_others.
wa_visual-bom = wa_chess_dmnd2-zcurr_partnum.
endcase.
wa_visual-catalog = wa_chess_dmnd2-zcurr_catnum.
wa_visual-work_order = wa_chess_dmnd2-zwonum.
if wa_chess_dmnd2-zcurr_fdate < sy-datum.
wa_chess_dmnd2-zcurr_fdate = wa_chess_dmnd2-zcurr_fdate + 1.
endif.
v_date = wa_chess_dmnd2-zorig_fdate+6(2).
v_month = wa_chess_dmnd2-zorig_fdate+4(2).
v_year = wa_chess_dmnd2-zorig_fdate+2(2).
concatenate v_date v_month v_year into v_date1.
wa_chess-date = v_date1.
wa_visual-ftime = wa_chess_dmnd2-zcurr_ftime.
if wa_round-rflag = c_x.
wa_visual-production_line = wa_chess_dmnd2-zcurr_prdline.
wa_visual-fiscweek = v_week+4(2).
v_qtr = ceil( wa_plaf-pedtr+4(2) / 3 ).
wa_visual-fiscquart = v_qtr.
endif.
endif.
append wa_visual to i_visual.
endloop.
sort i_visual by fdate ascending.
form f_move_chess_to_file .
exit.
else.
clear: wa_chess ,v_string,v_chess_message.
form f_move_vf_to_file .
endif.
uline.
format color col_heading intensified off.
write:/1 sy-vline,3 text-121,at sy-linsz sy-vline.
format color off.
uline.
write: /1 sy-vline,3 text-116,45 v_chess,
at sy-linsz sy-vline,
/1 sy-vline,3 text-117,45 v_visual,
at sy-linsz sy-vline,
/1 sy-vline,3 text-118,45 v_error,
at sy-linsz sy-vline.
uline.
skip.
if v_chess_msg is not initial or
v_visual_msg is not initial or
v_error_msg is not initial.
uline.
format color col_heading intensified off.
write:/1 sy-vline,3 text-222,at sy-linsz sy-vline.
format color off.
uline.
form f_replace_total_page .
* for displaying line number at every top of page .
move sy-pagno to v_page.
do v_page times.
v_count = v_count + 1.
read line c_line of page v_count.
replace v_temp with v_page into sy-lisel.
modify line c_line of page v_count.
enddo.
endform. " f_replace_total_page
*&---------------------------------------------------------------------*
*& form f_clear_internal_tables
*&---------------------------------------------------------------------*
* >>>clear internal tables
*----------------------------------------------------------------------*
form f_clear_internal_tables .
clear : v_temp,
v_chess,
v_error,
v_visual,
v_chess_message,
v_error_message,
v_visual_message,
wa_round,
wa_plaf,
wa_error,
wa_chess,
wa_visual.
refresh : i_plaf,
i_round,
i_chess,
i_visual,
i_error.