There is no BAPI or FM to update forecase values.
See the below program, it used MD61 transaction.
Code:
************************************************************************
* Report : ZMPPC015
* Type : Data upload
* Author : Seshu Maramreddy
* Description: This ABAP/4 Program to Create Planned Independent
* Requirement for SMI plants using MD61 Transaction.
* It accepts tab-delimited spreadsheet input and
* creates BDC sessions.
*
************************************************************************
report zmppc015 no standard page heading
line-size 120
line-count 55
message-id zz.
* Constants
constants : c_x type c value 'X'," Dynbegin
c_tcode type tstc-tcode value 'MD61'." Transaction Code
* Variables
data : v_lines_in_xcel like sy-tabix,
l_tabix like sy-tabix,
v_trans_in_ssn type i,
v_ssnnr(4) type n," Counter
v_ssnname like apqi-groupid,
v_matnr(18) type c. " Material Number
* Internal Tables
* Internal table for file
data : begin of t_file occurs 0,
matnr(18) type c, " Material Number
berid(10) type c, " MRP Area
PLNMG01(17) type n, " Forecast Month -01
PLNMG02(17) type n, " Forecast Month -02
PLNMG03(17) type n, " Forecast Month -03
PLNMG04(17) type n, " Forecast Month -04
PLNMG05(17) type n, " Forecast Month -05
PLNMG06(17) type n, " Forecast Month -06
PLNMG07(17) type n, " Forecast Month -07
PLNMG08(17) type n, " Forecast Month -08
PLNMG09(17) type n, " Forecast Month -09
PLNMG10(17) type n, " Forecast Month -10
PLNMG11(17) type n, " Forecast Month -11
PLNMG12(17) type n, " Forecast Month -12
WERKS(4) TYPE C, " Plant
end of t_file.
* Internal table for BDCDATA Structure
data : begin of itab_bdc_tab occurs 0.
include structure bdcdata.
data : end of itab_bdc_tab.
* Selection-screen
selection-screen: skip 3.
selection-screen: begin of block id1 with frame.
*
parameters: p_name like rlgrap-filename
default 'C:\My Documents\InputFile.txt'
obligatory,
* bdc session name prefix
p_bdcpfx(6) default 'ZPIRCT'
obligatory,
* number for transction per BDC session
p_trnssn type i
default 2000 obligatory,
* retain the BDC session after successfull execution
p_keep like apqi-qerase
default c_x,
* user who will be executing BDC session
p_uname like apqi-userid
default sy-uname
obligatory.
selection-screen : skip 1.
* Requirement type
parameters : p_bedae like t459u-bedae,
* From Date
p_date like sy-datum default sy-datum obligatory.
selection-screen: end of block id1.
at selection-screen on value-request for p_name.
* F4 value for Input file
perform filename_get.
* main processing
start-of-selection.
* To get the data from file to Internal table
perform getdata_fromfile.
loop at t_file.
* hang on to xcel line num
l_tabix = sy-tabix.
* if num-of-trnas-in-session = 0, create new BDC session
if v_trans_in_ssn is initial.
perform bdc_session_open.
endif.
* begin new bdc script for rtg create trans
* fill in bdc-data for prod.version maintenance screens
perform bdc_build_script.
* insert the bdc script as a BDC transaction
perform bdc_submit_transaction.
* keep track of how many BDC transactions were inserted in the BDC
* session
add 1 to v_trans_in_ssn.
* if the user-specified num of trans in BDC session is reached OR
* if end of input file is reached, close the BDC session
if v_trans_in_ssn = p_trnssn or
l_tabix = v_lines_in_xcel.
perform bdc_session_close.
clear v_trans_in_ssn.
endif.
clear t_file.
endloop.
*&---------------------------------------------------------------------*
*& Form filename_get
*&---------------------------------------------------------------------*
* F4 Value for input file
*----------------------------------------------------------------------*
FORM filename_get.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_PATH = 'C:\Temp\ '
MASK = ',*.*,*.*.'
MODE = 'O'
TITLE = 'Select File '(007)
IMPORTING
FILENAME = p_name
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
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. " filename_get
*&---------------------------------------------------------------------*
*& Form getdata_fromfile
*&---------------------------------------------------------------------*
* Upload the data from file to Internal table
*----------------------------------------------------------------------*
FORM getdata_fromfile.
sort t_file by matnr .
delete t_file where matnr = ''.
clear v_lines_in_xcel.
describe table t_file lines v_lines_in_xcel.
if v_lines_in_xcel is initial.
write: / 'No data in input file'.
stop.
endif.
else.
write:/ 'Error reading input file'.
stop.
endif.
ENDFORM. " getdata_fromfile
*&---------------------------------------------------------------------*
*& Form bdc_session_open
*&---------------------------------------------------------------------*
* BDC_OPEN_GROUP
*----------------------------------------------------------------------*
FORM bdc_session_open.
* create bdc session name = prefix-from-selectn-screen + nnnn
add 1 to v_ssnnr.
concatenate p_bdcpfx v_ssnnr into v_ssnname.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = v_ssnname
KEEP = p_keep
USER = p_uname
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
GROUP_INVALID = 3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
QUEUE_ERROR = 7
RUNNING = 8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11.
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. " bdc_session_open
*&---------------------------------------------------------------------*
*& Form bdc_build_script
*&---------------------------------------------------------------------*
* BDC Script
*----------------------------------------------------------------------*
FORM bdc_build_script.
* Local Variables
DATA : l_frdat(8) type c, " From Date
l_todat(8) type c, " To Date
l_frdat1(4) type c, " Year
l_frdat2(2) type c, " Month
l_frdat3(2) type c, " Day
l_tdate like sy-datum, " Subtract date(1)
l_todat1(4) type c, " Year
l_todat2(2) type c, " Month
l_todat3(3) type c. " Day
* Get the material number from tables ZMSMI_FERR_RAW,
* ZMSMI_SNAP_RAW and ZMSMI_SIMP_RAW
perform get_matnr.
* Screen 0100.
perform bdc_screen using 'SAPMM60X' '0100'.
perform bdc_field using 'BDC_OKCODE' '/EBDPT'.
perform bdc_field using 'AM60X-MATAW' 'X'.
perform bdc_field using 'AM60X-MATNR' T_FILE-MATNR.
perform bdc_field using 'AM60X-PRGRP' SPACE.
perform bdc_field using 'AM60X-PBDNR' SPACE.
perform bdc_field using 'RM60X-BERID' T_FILE-BERID.
perform bdc_field using 'AM60X-WERKS' SPACE.
perform bdc_field using 'RM60X-VERSB' '00'.
* Converted the date as per MD61 Transaction.
* From date
l_frdat1 = p_date+0(4).
l_frdat2 = p_date+4(2).
l_frdat3 = p_date+6(2).
concatenate l_frdat2 l_frdat3 l_frdat1 into l_frdat.
concatenate l_todat2 l_todat3 l_todat1 into l_todat.
perform bdc_field using 'RM60X-DATVE' l_frdat.
perform bdc_field using 'RM60X-DATBE' l_todat.
perform bdc_field using 'RM60X-ENTLU' 'M'.
* Screen 0127
perform bdc_screen using 'SAPMM60X' '0127'.
perform bdc_field using 'BDC_OKCODE' '=WEIT'.
if p_bedae is initial.
perform bdc_field using 'T459U-BEDAE' space.
else.
perform bdc_field using 'T459U-BEDAE' P_BEDAE.
endif.
* Screen 0100.
perform bdc_screen using 'SAPMM60X' '0100'.
perform bdc_field using 'BDC_OKCODE' '/00'.
perform bdc_field using 'AM60X-MATAW' 'X'.
perform bdc_field using 'AM60X-MATNR' T_FILE-MATNR.
perform bdc_field using 'AM60X-PRGRP' SPACE.
perform bdc_field using 'AM60X-PBDNR' SPACE.
perform bdc_field using 'RM60X-BERID' T_FILE-BERID.
perform bdc_field using 'AM60X-WERKS' SPACE.
perform bdc_field using 'RM60X-VERSB' '00'.
perform bdc_field using 'RM60X-DATVE' l_frdat.
perform bdc_field using 'RM60X-DATBE' l_todat.
perform bdc_field using 'RM60X-ENTLU' 'M'.
* Screen 0200
perform bdc_screen using 'SAPLM60E' '0200'.
perform bdc_field using 'BDC_OKCODE' '=S+'.
perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG01.
perform bdc_screen using 'SAPLM60E' '0200'.
perform bdc_field using 'BDC_OKCODE' '=S+'.
perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG02.
perform bdc_screen using 'SAPLM60E' '0200'.
perform bdc_field using 'BDC_OKCODE' '=S+'.
perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG03.
perform bdc_screen using 'SAPLM60E' '0200'.
perform bdc_field using 'BDC_OKCODE' '=S+'.
perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG04.
perform bdc_screen using 'SAPLM60E' '0200'.
perform bdc_field using 'BDC_OKCODE' '=S+'.
perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG05.
perform bdc_screen using 'SAPLM60E' '0200'.
perform bdc_field using 'BDC_OKCODE' '=S+'.
perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG06.
perform bdc_screen using 'SAPLM60E' '0200'.
perform bdc_field using 'BDC_OKCODE' '=S+'.
perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG07.
perform bdc_screen using 'SAPLM60E' '0200'.
perform bdc_field using 'BDC_OKCODE' '=S+'.
perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG08.
perform bdc_screen using 'SAPLM60E' '0200'.
perform bdc_field using 'BDC_OKCODE' '=S+'.
perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG09.
perform bdc_screen using 'SAPLM60E' '0200'.
perform bdc_field using 'BDC_OKCODE' '=S+'.
perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG10.
perform bdc_screen using 'SAPLM60E' '0200'.
perform bdc_field using 'BDC_OKCODE' '=S+'.
perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG11.
perform bdc_screen using 'SAPLM60E' '0200'.
perform bdc_field using 'BDC_OKCODE' '=SICH'.
perform bdc_field using 'RM60X-PLN01(01)' T_FILE-PLNMG12.
ENDFORM. " bdc_build_script
*&---------------------------------------------------------------------*
*& Form get_matnr
*&---------------------------------------------------------------------*
* Get the material number from tables ZMSMI_FERR_RAW,
* ZMSMI_SNAP_RAW and ZMSMI_SIMP_RAW
*----------------------------------------------------------------------*
FORM get_matnr.
clear v_matnr.
case t_file-werks.
when '0101'.
select single cmatnr from zmsmi_simp_raw
into v_matnr where matnr = t_file-matnr.
if sy-subrc eq 0.
clear t_file-matnr.
t_file-matnr = v_matnr.
endif.
when '0103'.
select single cmatnr from zmsmi_ferr_raw
into v_matnr where matnr = t_file-matnr.
if sy-subrc eq 0.
clear t_file-matnr.
t_file-matnr = v_matnr.
endif.
when '0102' or '0110' or '0111' or '0112' or '0113'
or '0114' or '0115' or '0116' or '0117'.
select single cmatnr from zmsmi_snap_raw
into v_matnr where matnr = t_file-matnr.
if sy-subrc eq 0.
clear t_file-matnr.
t_file-matnr = v_matnr.
endif.
endcase.
ENDFORM. " get_matnr
*&---------------------------------------------------------------------*
*& Form bdc_screen
*&---------------------------------------------------------------------*
* BDC Script for Screen fields
*----------------------------------------------------------------------*
* -->P_PROG Program name
* -->P_SCRN Screen Number
*----------------------------------------------------------------------*
FORM bdc_screen USING p_prog
p_scrn.
*&---------------------------------------------------------------------*
*& Form bdc_field
*&---------------------------------------------------------------------*
* BDC Script for Screen fileds
*----------------------------------------------------------------------*
* -->P_NAM Field name
* -->P_VAL Field value
*----------------------------------------------------------------------*
FORM bdc_field USING p_nam
p_val.
clear itab_bdc_tab.
itab_bdc_tab-fnam = p_nam.
itab_bdc_tab-fval = p_val.
append itab_bdc_tab.
ENDFORM. " bdc_screen
*&---------------------------------------------------------------------*
*& Form bdc_submit_transaction
*&---------------------------------------------------------------------*
* BDC_INSERT Function Module
*----------------------------------------------------------------------*
FORM bdc_submit_transaction.
** Load BDC script as a trqansction in BDC session
call function 'BDC_INSERT'
EXPORTING
tcode = c_tcode
TABLES
dynprotab = itab_bdc_tab
EXCEPTIONS
internal_error = 01
not_open = 02
queue_error = 03
tcode_invalid = 04.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
refresh itab_bdc_tab.
ENDFORM. " bdc_submit_transaction
*&---------------------------------------------------------------------*
*& Form bdc_session_close
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM bdc_session_close.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.