‎2008 Mar 17 4:47 PM
Hi,
We are running the transaction KKPAN via BDC as a background job. This is failing and creating raise execption dumps. In the foreground it is fine.
Has anyone else come across this issue.
‎2009 Jul 20 3:43 PM
Hello Martin,
Have you solved this problem? Even I wanted to create the BDC for KKPAN in Background/
Could you please give the sample BDC code for KKPAN?
Your help will be appreciated. Thanks in advance.
Regards,
Mahesh
‎2013 Jun 12 4:42 PM
See program template: RCKUNITCOSTING
My example (manage creation and modification
REPORT ztest_creer_ccravv .
TYPE-POOLS: kkpi.
DATA:
table_control_line TYPE rk70l, "line of a unit costing
input_data TYPE kkpi_transfer_data_line, "unitcosting
t_input_data TYPE kkpi_transfer_data. "table of unitcostings
PARAMETER session TYPE c.
* ----------------------------------------------------------------------
* first costing
* ----------------------------------------------------------------------
input_data-klvar = 'PPC1'. "costing variant
input_data-matnr = 'TEST_CCRAVV_04'. "material number
input_data-werks = '1100'. "plant
input_data-losgr = 1. "lot size
input_data-tvers = 01. "costing version
input_data-kadat = '20130612'. "costing date from
input_data-bidat = '99991231'. "costing date to
* input_data-raw_material = 'X'. "raw material
input_data-raw_material = ' '. "non raw material
* 1st cost element
CLEAR table_control_line.
table_control_line-posnr = 1. "number of table_control_line
table_control_line-typps = 'E'. "Unit costing item category
table_control_line-herk2 = 'C0113204'. "Origin field: cost center
table_control_line-herk3 = 'AMO'. "Origin field: plant/activity type
table_control_line-menge = 2390 . "Quantity
table_control_line-meeht = 'H'. "unit
* TABLE_CONTROL_LINE-LTXT = ''. "description
table_control_line-lpreis = '5.90'. "total price
table_control_line-lpeinh = 1. "base price
table_control_line-kstar = '943050'. "G/L acc.
APPEND table_control_line TO input_data-position.
* 2nd cost element
CLEAR table_control_line.
table_control_line-posnr = 2.
table_control_line-typps = 'M'. "article
table_control_line-herk2 = 'PA8653'.
table_control_line-herk3 = '1100'.
table_control_line-menge = '137.207'.
table_control_line-meeht = 'KG'.
* TABLE_CONTROL_LINE-LTXT = ''.
table_control_line-lpreis = '2089.98 '.
table_control_line-lpeinh = 1000.
table_control_line-kstar = '603110'.
APPEND table_control_line TO input_data-position.
* 3rd cost element
CLEAR table_control_line.
table_control_line-posnr = 2.
DO 50 TIMES.
table_control_line-posnr = table_control_line-posnr + 1.
table_control_line-typps = 'V'. "poste variable
* TABLE_CONTROL_LINE-HERK2 = 'PA8653'.
* TABLE_CONTROL_LINE-HERK3 = '1100'.
table_control_line-menge = 2.
table_control_line-meeht = 'PC'.
table_control_line-ltext = 'frais demarrage'.
table_control_line-lpreis = 155.
table_control_line-lpeinh = 1.
table_control_line-kstar = '603260'.
APPEND table_control_line TO input_data-position.
ENDDO.
* append whole unit costing
APPEND input_data TO t_input_data.
** ----------------------------------------------------------------------
** second costing
** ----------------------------------------------------------------------
* CLEAR INPUT_DATA.
* INPUT_DATA-KLVAR = 'PPC1'. "costing variant
* INPUT_DATA-MATNR = 'P-100'. "material number
* INPUT_DATA-WERKS = '0001'. "plant
* INPUT_DATA-LOSGR = 100. "lot size
* INPUT_DATA-TVERS = 88. "costing version
* INPUT_DATA-KADAT = '19980801'. "costing date from
* INPUT_DATA-BIDAT = '19980831'. "costing date to
* INPUT_DATA-RAW_MATERIAL = 'X'. "raw material
** input_data-raw_material = ' '. "non raw material
*
* CLEAR TABLE_CONTROL_LINE.
* TABLE_CONTROL_LINE-POSNR = 1. "number of table_control_line
* TABLE_CONTROL_LINE-TYPPS = 'E'. "Unit costing item category
* TABLE_CONTROL_LINE-HERK2 = 'COST01'. "Origin field: cost center
* TABLE_CONTROL_LINE-HERK3 = 'P01'. "Origin field: activity type
* TABLE_CONTROL_LINE-MENGE = 10. "Quantity
* APPEND TABLE_CONTROL_LINE TO INPUT_DATA-POSITION.
*
* CLEAR TABLE_CONTROL_LINE.
* TABLE_CONTROL_LINE-POSNR = 2. "number of table_control_line
* TABLE_CONTROL_LINE-TYPPS = 'V'. "Unit costing item category
* TABLE_CONTROL_LINE-LPREIS = 2000. "Price
* TABLE_CONTROL_LINE-KSTAR = 415000. "cost element
* TABLE_CONTROL_LINE-MENGE = 2. "Quantity
* APPEND TABLE_CONTROL_LINE TO INPUT_DATA-POSITION.
** append whole unit costing
* APPEND INPUT_DATA TO T_INPUT_DATA.
IF session IS INITIAL.
* direct batch input
CALL FUNCTION 'KKPI_BDC_COSTING_CREATE'
EXPORTING
client = sy-mandt
user = sy-uname
* MODE = 'A' "avant plan
mode = 'N' "arrière plan
* UPDATE = 'A' "asynchrone
UPDATE = 'S' "synchrone
it_transfer_data = t_input_data
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
* CCR à date existe déjÃ
IF sy-msgid = 'K3' AND sy-msgno = '023'.
CALL FUNCTION 'KKPI_BDC_COSTING_CHANGE'
EXPORTING
client = sy-mandt
user = sy-uname
* MODE = 'A' "avant plan
mode = 'N' "arrière plan
* UPDATE = 'A' "asynchrone
UPDATE = 'S' "synchrone
it_transfer_data = t_input_data
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ELSE.
* create batch input session
CALL FUNCTION 'KKPI_SESSION_COSTING_CREATE'
EXPORTING
client = sy-mandt
user = sy-uname
group = 'BATCHMAP'
keep = ' '
holddate = sy-datum
it_transfer_data = t_input_data
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
WRITE 'Fertig!'(001).