Code: Alles auswählen.
FUNCTION Z_FB_MC94_V2.
*"--------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(CTU) LIKE APQI-PUTACTIVE DEFAULT 'X'
*" VALUE(MODE) LIKE APQI-PUTACTIVE DEFAULT 'N'
*" VALUE(UPDATE) LIKE APQI-PUTACTIVE DEFAULT 'L'
*" VALUE(GROUP) LIKE APQI-GROUPID OPTIONAL
*" VALUE(USER) LIKE APQI-USERID OPTIONAL
*" VALUE(KEEP) LIKE APQI-QERASE OPTIONAL
*" VALUE(HOLDDATE) LIKE APQI-STARTDATE OPTIONAL
*" VALUE(NODATA) LIKE APQI-PUTACTIVE DEFAULT '/'
*" VALUE(SCTYP_001) LIKE BDCDATA-FVAL DEFAULT 'ZPP_PLAN_ZM'
*" VALUE(LOW_002) LIKE BDCDATA-FVAL DEFAULT 'P0002'
*" VALUE(FLD001_12_003) LIKE BDCDATA-FVAL DEFAULT ' 111'
*" VALUE(FLD001_12_004) LIKE BDCDATA-FVAL DEFAULT ' 222'
*" VALUE(FLD001_12_005) LIKE BDCDATA-FVAL DEFAULT ' 333'
*" VALUE(FLD001_12_006) LIKE BDCDATA-FVAL DEFAULT ' 444'
*" VALUE(FLD001_12_007) LIKE BDCDATA-FVAL DEFAULT ' 555'
*" VALUE(FLD001_12_008) LIKE BDCDATA-FVAL DEFAULT ' 666'
*" VALUE(FLD001_12_009) LIKE BDCDATA-FVAL DEFAULT ' 777'
*" VALUE(FLD001_12_010) LIKE BDCDATA-FVAL DEFAULT ' 888'
*" VALUE(FLD001_12_011) LIKE BDCDATA-FVAL DEFAULT ' 999'
*" VALUE(FLD001_12_012) LIKE BDCDATA-FVAL DEFAULT ' 1111'
*" VALUE(FLD001_12_013) LIKE BDCDATA-FVAL DEFAULT ' 1122'
*" EXPORTING
*" VALUE(SUBRC) LIKE SYST-SUBRC
*" TABLES
*" MESSTAB STRUCTURE BDCMSGCOLL OPTIONAL
*"--------------------------------------------------------------------
DATA: lv_wrk type werks_d.
SET PARAMETER ID 'WRK' FIELD lv_wrk.
subrc = 0.
perform bdc_nodata using NODATA.
perform open_group using GROUP USER KEEP HOLDDATE CTU.
perform bdc_dynpro using 'SAPMMCP6' '0110'.
perform bdc_field using 'BDC_CURSOR'
'RMCP2-SCTYP'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RMCP2-SCTYP'
SCTYP_001.
perform bdc_dynpro using 'RMCA7779' '1000'.
perform bdc_field using 'BDC_CURSOR'
'SL_0001-LOW'.
perform bdc_field using 'BDC_OKCODE'
'=AKTV'.
perform bdc_field using 'SL_0002-LOW'
LOW_002.
perform bdc_dynpro using 'SAPLMCPA' '0707'.
perform bdc_field using 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
perform bdc_field using 'BDC_OKCODE'
'=S+'.
perform bdc_field using 'RMCP4-FLD001(12)'
FLD001_12_003.
perform bdc_dynpro using 'SAPLMCPA' '0707'.
perform bdc_field using 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
perform bdc_field using 'BDC_OKCODE'
'=S+'.
perform bdc_field using 'RMCP4-FLD001(12)'
FLD001_12_004.
perform bdc_dynpro using 'SAPLMCPA' '0707'.
perform bdc_field using 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
perform bdc_field using 'BDC_OKCODE'
'=S+'.
perform bdc_field using 'RMCP4-FLD001(12)'
FLD001_12_005.
perform bdc_dynpro using 'SAPLMCPA' '0707'.
perform bdc_field using 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
perform bdc_field using 'BDC_OKCODE'
'=S+'.
perform bdc_field using 'RMCP4-FLD001(12)'
FLD001_12_006.
perform bdc_dynpro using 'SAPLMCPA' '0707'.
perform bdc_field using 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
perform bdc_field using 'BDC_OKCODE'
'=S+'.
perform bdc_field using 'RMCP4-FLD001(12)'
FLD001_12_007.
perform bdc_dynpro using 'SAPLMCPA' '0707'.
perform bdc_field using 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
perform bdc_field using 'BDC_OKCODE'
'=S+'.
perform bdc_field using 'RMCP4-FLD001(12)'
FLD001_12_008.
perform bdc_dynpro using 'SAPLMCPA' '0707'.
perform bdc_field using 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
perform bdc_field using 'BDC_OKCODE'
'=S+'.
perform bdc_field using 'RMCP4-FLD001(12)'
FLD001_12_009.
perform bdc_dynpro using 'SAPLMCPA' '0707'.
perform bdc_field using 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
perform bdc_field using 'BDC_OKCODE'
'=S+'.
perform bdc_field using 'RMCP4-FLD001(12)'
FLD001_12_010.
perform bdc_dynpro using 'SAPLMCPA' '0707'.
perform bdc_field using 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
perform bdc_field using 'BDC_OKCODE'
'=S+'.
perform bdc_field using 'RMCP4-FLD001(12)'
FLD001_12_011.
perform bdc_dynpro using 'SAPLMCPA' '0707'.
perform bdc_field using 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
perform bdc_field using 'BDC_OKCODE'
'=S+'.
perform bdc_field using 'RMCP4-FLD001(12)'
FLD001_12_012.
perform bdc_dynpro using 'SAPLMCPA' '0707'.
perform bdc_field using 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RMCP4-FLD001(12)'
FLD001_12_013.
perform bdc_dynpro using 'SAPLMCPA' '0707'.
perform bdc_field using 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
perform bdc_field using 'BDC_OKCODE'
'=SICH'.
**********************************************************************
DATA: lt_myopt type ctu_params.
lt_myopt-DISMODE = 'N'.
lt_myopt-UPDMODE = 'S'.
*lt_myopt-CATTMODE
*lt_myopt-DEFSIZE
lt_myopt-RACOMMIT = 'X'.
*lt_myopt-NOBINPT
*lt_myopt-NOBIEND
FREE MEMORY ID 'WRK'.
CALL TRANSACTION 'MC94' USING BDCDATA
OPTIONS from Lt_MYOPT
MESSAGES INTO MESSTAB.
if sy-subrc <> 0.
subrc = sy-subrc.
exit.
endif.
PERFORM close_group USING ctu.
*perform bdc_transaction tables messtab
*using 'MC94'
* CTU
* MODE
* UPDATE.
*if sy-subrc <> 0.
* subrc = sy-subrc.
* exit.
*endif.
*
*perform close_group using CTU.
ENDFUNCTION.
Code: Alles auswählen.
FUNCTION z_fb_mc94.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(CTU) LIKE APQI-PUTACTIVE DEFAULT 'X'
*" VALUE(MODE) LIKE APQI-PUTACTIVE DEFAULT 'N'
*" VALUE(UPDATE) LIKE APQI-PUTACTIVE DEFAULT 'L'
*" VALUE(GROUP) LIKE APQI-GROUPID OPTIONAL
*" VALUE(USER) LIKE APQI-USERID OPTIONAL
*" VALUE(KEEP) LIKE APQI-QERASE OPTIONAL
*" VALUE(HOLDDATE) LIKE APQI-STARTDATE OPTIONAL
*" VALUE(NODATA) LIKE APQI-PUTACTIVE DEFAULT '/'
*" VALUE(SCTYP_001) LIKE BDCDATA-FVAL DEFAULT 'ZPP_PLAN_ZM'
*" VALUE(LOW_002) LIKE BDCDATA-FVAL DEFAULT 'P0003'
*" VALUE(LOW_003) LIKE BDCDATA-FVAL DEFAULT ''
*" VALUE(FLD001_12_004) LIKE BDCDATA-FVAL DEFAULT ' 4711'
*" VALUE(IV_VARIANTE) TYPE I
*" EXPORTING
*" VALUE(SUBRC) LIKE SYST-SUBRC
*" TABLES
*" MESSTAB STRUCTURE BDCMSGCOLL OPTIONAL
*"----------------------------------------------------------------------
subrc = 0.
PERFORM bdc_nodata USING nodata.
PERFORM open_group USING group user keep holddate ctu.
PERFORM bdc_dynpro USING 'SAPMMCP6' '0110'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RMCP2-SCTYP'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RMCP2-SCTYP'
sctyp_001.
PERFORM bdc_dynpro USING 'RMCA7779' '1000'.
PERFORM bdc_field USING 'BDC_CURSOR'
'SL_0003-LOW'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=AKTV'.
PERFORM bdc_field USING 'SL_0002-LOW'
low_002.
PERFORM bdc_field USING 'SL_0003-LOW'
low_003.
DATA: it_planwerte TYPE STANDARD TABLE OF bdcdata-fval,
lv_planwerte TYPE bdcdata-fval,
lv_tabix type sy-tabix.
lv_planwerte = ' 123456'.
APPEND lv_planwerte TO it_planwerte.
lv_planwerte = ' 123222'.
APPEND lv_planwerte TO it_planwerte.
lv_planwerte = ' 123333'.
APPEND lv_planwerte TO it_planwerte.
lv_planwerte = ' 123444'.
APPEND lv_planwerte TO it_planwerte.
lv_planwerte = ' 123555'.
APPEND lv_planwerte TO it_planwerte.
lv_planwerte = ' 123666'.
APPEND lv_planwerte TO it_planwerte.
lv_planwerte = ' 123777'.
APPEND lv_planwerte TO it_planwerte.
lv_planwerte = ' 123888'.
APPEND lv_planwerte TO it_planwerte.
CASE iv_variante.
WHEN 1.
**********************************************************************
"letzter Wert in 01.2014, erster Wert in 04.2014 - Rest unverändert
LOOP AT it_planwerte INTO lv_planwerte.
lv_tabix = sy-tabix.
PERFORM bdc_dynpro USING 'SAPLMCPA' '0707'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
DO lv_tabix TIMES.
PERFORM bdc_field USING 'BDC_OKCODE'
'=S+'.
ENDDO.
PERFORM bdc_field USING 'RMCP4-FLD001(12)'
lv_planwerte."FLD001_12_004.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
ENDLOOP.
**********************************************************************
**********************************************************************
WHEN 2.
"letzter Wert in 01.2014, erster Wert in 04.2014 - Rest unverändert
LOOP AT it_planwerte INTO lv_planwerte.
lv_tabix = sy-tabix.
PERFORM bdc_dynpro USING 'SAPLMCPA' '0707'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
DO lv_tabix TIMES.
PERFORM bdc_field USING 'BDC_OKCODE'
'=S+'.
ENDDO.
PERFORM bdc_field USING 'RMCP4-FLD001(12)'
lv_planwerte."FLD001_12_004.
ENDLOOP.
**********************************************************************
**********************************************************************
WHEN 3.
"letzter Wert in 01.2014, erster Wert in 04.2014 - Rest unverändert
LOOP AT it_planwerte INTO lv_planwerte.
DO Sy-tabix TIMES.
PERFORM bdc_dynpro USING 'SAPLMCPA' '0707'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=S+'.
ENDDO.
PERFORM bdc_field USING 'RMCP4-FLD001(12)'
lv_planwerte."FLD001_12_004.
ENDLOOP.
**********************************************************************
**********************************************************************
WHEN 4.
"nur der letzte Wert wird in 01.2014 gespeichert
LOOP AT it_planwerte INTO lv_planwerte.
DO Sy-tabix TIMES.
PERFORM bdc_dynpro USING 'SAPLMCPA' '0707'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=S+'.
ENDDO.
PERFORM bdc_dynpro USING 'SAPLMCPA' '0707'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RMCP4-FLD001(12)'
lv_planwerte."FLD001_12_004.
ENDLOOP.
**********************************************************************
**********************************************************************
when 5.
"nur im 01.2014 wird gespeichert
LOOP AT it_planwerte INTO lv_planwerte.
PERFORM bdc_dynpro USING 'SAPLMCPA' '0707'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=S+'.
PERFORM bdc_dynpro USING 'SAPLMCPA' '0707'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RMCP4-FLD001(12)'
lv_planwerte."FLD001_12_004.
ENDLOOP.
**********************************************************************
**********************************************************************
when 6.
"nur der letzte Wert wird in 01.2014 gespeichert
LOOP AT it_planwerte INTO lv_planwerte.
PERFORM bdc_dynpro USING 'SAPLMCPA' '0707'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=S+'.
PERFORM bdc_field USING 'RMCP4-FLD001(12)'
lv_planwerte."FLD001_12_004.
ENDLOOP.
PERFORM bdc_dynpro USING 'SAPLMCPA' '0707'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
**********************************************************************
** break gruhle.
** PERFORM bdc_dynpro USING 'SAPLMCPA' '0707'.
**
** LOOP AT it_planwerte INTO lv_planwerte.
**
** PERFORM bdc_field USING 'BDC_CURSOR'
** 'RMCP4-FLD001(12)'.
** PERFORM bdc_field USING 'BDC_OKCODE'
** '=S+'.
**
** PERFORM bdc_field USING 'BDC_CURSOR'
** 'RMCP4-FLD001(12)'.
** PERFORM bdc_field USING 'BDC_OKCODE'
** '/00'.
** PERFORM bdc_field USING 'RMCP4-FLD001(12)'
** lv_planwerte."FLD001_12_004.
**
** "alles landet in einem Feld, es bleibt nur der letzte Wert im Feld 04.2014
" kann auch net gehen da pro Dynpro nur ein OK-Code!
** ENDLOOP.
* break gruhle.
* PERFORM bdc_dynpro USING 'SAPLMCPA' '0707'.
*
* LOOP AT it_planwerte INTO lv_planwerte.
*
* PERFORM bdc_field USING 'BDC_CURSOR'
* 'RMCP4-FLD001(12)'.
* PERFORM bdc_field USING 'BDC_OKCODE'
* '=S+'.
*
* PERFORM bdc_dynpro USING 'SAPLMCPA' '0707'.
* PERFORM bdc_field USING 'BDC_CURSOR'
* 'RMCP4-FLD001(12)'.
*
* PERFORM bdc_field USING 'RMCP4-FLD001(12)'
* lv_planwerte."FLD001_12_004.
*
* "alles landet in einem Feld, es bleibt nur der letzte Wert im Feld 01.2014
* ENDLOOP.
*perform bdc_dynpro using 'SAPLMCPA' '0707'.
*perform bdc_field using 'BDC_CURSOR'
* 'RMCP4-FLD001(12)'.
*perform bdc_field using 'BDC_OKCODE'
* '=S+'.
*perform bdc_field using 'RMCP4-FLD001(12)'
* FLD001_12_004.
*
*perform bdc_dynpro using 'SAPLMCPA' '0707'.
*perform bdc_field using 'BDC_CURSOR'
* 'RMCP2-KRIT2(01)'.
*perform bdc_field using 'BDC_OKCODE'
* '=S+'.
*
*
*perform bdc_dynpro using 'SAPLMCPA' '0707'.
*perform bdc_field using 'BDC_CURSOR'
* 'RMCP4-FLD001(12)'.
*perform bdc_field using 'BDC_OKCODE'
* '/00'.
*perform bdc_field using 'RMCP4-FLD001(12)'
* FLD001_12_004.
WHEN OTHERS.
ENDCASE.
PERFORM bdc_dynpro USING 'SAPLMCPA' '0707'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RMCP4-FLD001(12)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=SICH'.
DATA: lt_myopt TYPE ctu_params.
lt_myopt-dismode = 'N'.
lt_myopt-updmode = 'S'.
*lt_myopt-CATTMODE
*lt_myopt-DEFSIZE
lt_myopt-racommit = 'X'.
*lt_myopt-NOBINPT
*lt_myopt-NOBIEND
FREE MEMORY ID 'WRK'.
CALL TRANSACTION 'MC94' USING bdcdata
OPTIONS FROM lt_myopt
MESSAGES INTO messtab.
IF sy-subrc <> 0.
subrc = sy-subrc.
EXIT.
ENDIF.
PERFORM close_group USING ctu.
*perform bdc_transaction tables messtab
*using 'MC94'
* CTU
* MODE
* UPDATE.
*if sy-subrc <> 0.
* subrc = sy-subrc.
* exit.
*endif.
*
*perform close_group using CTU.
ENDFUNCTION.