Documente Academic
Documente Profesional
Documente Cultură
w_off = w_off + 1.
enddo.
* Move Factory Calendar for use later
t_cals-ident = p_ident.
append t_cals.
clear t_cals.
* Get month information from T247 for use in translating column headers
select *
into table w_t247
from t247
where spras = sy-langu.
* Upload the Excel file using the inputs from the user and the known
* layout of the file template.
p_fend = p_fend + 1.
*
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename
= p_file
i_begin_col
= 1
i_begin_row
= 1
i_end_col
= w_cend
i_end_row
= p_fend
tables
intern
= w_excel_tab
exceptions
inconsistent_parameters
= 1
upload_ole
= 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.
* Re-format input file in order to use it effectively.
sort w_excel_tab by row col.
colpos = 5.
* Read headers and translate them into months.
loop at w_excel_tab where row = 1.
check w_excel_tab-col eq colpos.
split w_excel_tab-value at '/'
into col_months-mnr col_months-gjahr.
col_months-colpos = colpos.
read table w_t247 with key mnr = col_months-mnr.
if sy-subrc eq 0.
append col_months.
endif.
colpos = colpos + 1.
endloop.
*
delete w_excel_tab where row = 1.
*
loop at w_excel_tab.
case w_excel_tab-col.
when 1.
clear w_input_tab.
move w_excel_tab-value to w_input_tab-prctr.
when 2.
move w_excel_tab-value to w_input_tab-matnr.
when 3.
* Do nothing - this is the description field
when 4.
else.
w_mode = 'CREATE'.
endif.
clear return.
refresh return.
endat.
* Process line volumes
w_date(4) = w_work_tab-gjahr.
w_date+4(2) = w_work_tab-monat.
w_date+6(2) = '01'.
*
call function 'RE_ADD_MONTH_TO_DATE'
exporting
months
= 1
olddate = w_date
importing
newdate = w_date.
*
w_date = w_date - 1.
*
call function 'DATE_CONVERT_TO_WORKINGDAY'
exporting
date
= w_date
direction
= '-'
importing
workingday
= w_date
tables
factory_calendars
= t_cals.
*
requirements_schedule_in-date_type = '1'.
requirements_schedule_in-req_date = w_date.
requirements_schedule_in-req_qty = w_work_tab-volum.
requirements_schedule_in-unit = p_uom.
append requirements_schedule_in.
clear requirements_schedule_in.
* Process Material completely
at end of matnr.
if w_mode = 'CHANGE'.
call function 'BAPI_REQUIREMENTS_CHANGE'
exporting
material
= w_bapi_item-material
plant
= w_bapi_item-plant
requirementstype
= w_bapi_item-requ_type
version
= w_bapi_item-version
reqmtsplannumber
= w_bapi_item-req_number
vers_activ
= w_bapi_item-vers_activ
*
REQUIREMENT_PARAM
=
*
MRP_AREA
=
*
IMPORTING
*
REQUIREMENT_ITEM_OUT
=
tables
requirements_schedule_in
= requirements_schedule_in
*
REQUIREMENTS_CHAR_IN
=
return
= return
.
if not return[] is initial.
loop at return where type = 'E'.
endloop.
if sy-subrc eq 0.
wa_rejections-matnr = w_bapi_item-material.
*&---------------------------------------------------------------------*
*&
Form CALC_WORKING_DAYS
*&---------------------------------------------------------------------*
form calc_working_days.
data: w_date like sy-datum,
w_no_days type i,
w_days like t009b-butag,
w_rc like sy-subrc.
*
call function 'NUMBER_OF_DAYS_PER_MONTH_GET'
exporting
par_month
= w_work_tab-monat
par_year
= w_work_tab-gjahr
importing
par_days
= w_days.
.
*
w_date(4) = w_work_tab-gjahr.
w_date+4(2) = w_work_tab-monat.
w_date+6(2) = '01'.
*W_DAYS = W_DAYS - 1.
*
do w_days times.
call function 'Z_IS_WORKDAY_2'
exporting
datin
= w_date
facal
= p_ident
importing
rc
= w_rc
.
if w_rc = 0.
w_no_days = w_no_days + 1.
endif.
w_date = w_date + 1.
enddo.
*
w_work_tab-volum = w_work_tab-volum * w_no_days.
*
endform.
" CALC_WORKING_DAYS