09-02-2015 1:57 PM
Hello,
I having a problem getting a BDC to work correctly. I am writing a program that will delete bank details based on data from an input file. the data will several lines of data with each line containing the customer number and the bank details that are to be deleted. my program will loop thru the data and create the BDCDATA file to be used in the BDC. below is the recording that I did and the code that I have in my program. what is happening is the first record is processed correctly an then the BDC ends. the remaining records are not processed. I have looked at the recording and the code and I cannot figure out what I need to code to get this to process the entire file.
I would appreciate any help that you have
thanks
program screen start id field name field value
T XD02 BS AA X F
SAPMF02D 0101 X
BDC_CURSOR USE_SAV
BDC_OKCODE /00
RF02D-KUNNR 1010078
RF02D-D0130 X
USE_ZAV X
SAPMF02D 0130 X
BDC_CURSOR KNBK-BANKL(03)
BDC_OKCODE =BDEL
SAPMF02D 0130 X
BDC_CURSOR KNBK-BANKL(03)
BDC_OKCODE =UPDA
PERFORM bdc_load_dynpro USING 'SAPMF02D' '0101'.
PERFORM bdc_load_field USING 'RF02D-KUNNR' ws_bankdetl-kunnr.
PERFORM bdc_load_field USING 'RF02D-D0130' 'X'.
PERFORM bdc_load_field USING 'USE_ZAV' 'X'.
DO.
WHILE ws_tabix > 10.
PERFORM bdc_load_field USING 'BDC_OKCODE' '=P+'.
ws_tabix = ws_tabix - 10.
ENDWHILE.
ENDDO.
CONCATENATE: 'KNBK-BANKS(' ws_bankdetl-record_no ')' INTO l_char1, "DE1K938146
'KNBK-BANKL(' ws_bankdetl-record_no ')' INTO l_char2, "DE1K938146
'KNBK-BANKN(' ws_bankdetl-record_no ')' INTO l_char3. "DE1K938146
CONDENSE: l_char1, l_char2, l_char3. "DE1K938146
PERFORM bdc_load_field USING 'BDC_OKCODE' '/00'.
PERFORM bdc_load_dynpro USING 'SAPMF02D' '0130'.
PERFORM bdc_load_field USING 'BDC_CURSOR' l_char1.
PERFORM bdc_load_field USING l_char1 ws_bankdetl-ctry.
PERFORM bdc_load_field USING l_char2 ws_bankdetl-bankkey.
PERFORM bdc_load_field USING l_char3 ws_bankdetl-bankacct.
PERFORM bdc_load_field USING 'BDC_OKCODE' '=BDEL'.
PERFORM bdc_load_dynpro USING 'SAPMF02D' '0130'.
PERFORM bdc_load_field USING 'BDC_OKCODE' '=UPDA'.
this is the BDCDATA file that was created
row program dynpro dynbegin f nam fval
1 SAPMF02D 0101 X
2 0000 RF02D-KUNNR 0001010078
3 0000 RF02D-D0130 X
4 0000 USE_ZAV X
5 0000 BDC_OKCODE /00
6 SAPMF02D 0130 X
7 0000 BDC_CURSOR KNBK-BANKS(000005)
8 0000 KNBK-BANKS(000005) US
9 0000 KNBK-BANKL(000005) 103000855
10 0000 KNBK-BANKN(000005) 98765432
11 0000 BDC_OKCODE =BDEL
12 SAPMF02D 0130 X
13 0000 BDC_OKCODE =UPDA
14 SAPMF02D 0101 X
15 0000 RF02D-KUNNR 0001010078
16 0000 RF02D-D0130 X
17 0000 USE_ZAV X
18 0000 BDC_OKCODE /00
19 SAPMF02D 0130 X
20 0000 BDC_CURSOR KNBK-BANKS(000003)
21 0000 KNBK-BANKS(000003) US
22 0000 KNBK-BANKL(000003) 103000855
23 0000 KNBK-BANKN(000003) 1235
24 0000 BDC_OKCODE =BDEL
25 SAPMF02D 0130 X
26 0000 BDC_OKCODE =UPDA
09-02-2015 2:21 PM
BDC_OKCODE = UPDA
This will trigger a commit and so close the current transaction, following data in BDC are discarded,
So either remove it or break into multiple transaction call.
Hint: have you considered to make the switch and use method CMD_EI_AP => MAINTAIN_BAPI?
Regards,
Raymond
09-02-2015 2:21 PM
BDC_OKCODE = UPDA
This will trigger a commit and so close the current transaction, following data in BDC are discarded,
So either remove it or break into multiple transaction call.
Hint: have you considered to make the switch and use method CMD_EI_AP => MAINTAIN_BAPI?
Regards,
Raymond
09-02-2015 2:53 PM
thanks Raymond,
I did not know about CMD_EI_AP => MAINTAIN_BAPI. I will look to see how to code for the bank details.
09-02-2015 3:14 PM
In CMD_EI_API=>MAINTAIN_BAPI, fill IS_MASTER_DATA-CUSTOMERS-CENTRAL_DATA-BANKDETAIL-BANKDETAILS (TASK = 'D' for delete)
Hint: Use CMD_EI_API_EXTRACT=>GET_DATA to prepare IS/ES_MASTER_DATA from current values.
Regards,
Raymond
09-02-2015 3:34 PM
Raymond,
I added the following code to my program based on what I could find on the web. I checked the customer after I ran the program and I did not delete the bank detail line. not sure if I have to use the CMD_EI_API_EXTRACT=>GET_DATA to prepare IS/ES_MASTER_DATA from current values as you suggested.
FORM del_bankdetls1.
data: wa_header type cmds_ei_header,
wa_central_data type cmds_ei_vmd_central_data,
wa_central_datax type cmds_ei_vmd_central_data_xflag,
wa_address type bapiad1vl,
wa_addressx type bapiad1vlx,
wa_tax_ind_st type cmds_ei_tax_ind,
wa_tax_ind type cmds_ei_cmd_tax_ind,
wa_bankdetail_st type cvis_ei_cvi_bankdetail,
wa_bankdetail type cvis_ei_bankdetail,
wa_bank_t type CVIS_EI_BANKDETAIL_T,
wa_bank type CVIS_EI_BANKDETAIL_KEY,
wa_company_code_st type cmds_ei_company,
wa_company_code type cmds_ei_cmd_company,
wa_functions_st type cmds_ei_functions,
wa_functions_t type CMDS_EI_FUNCTIONS_T,
wa_functions type cmds_ei_cmd_functions,
wa_sales_data_st type cmds_ei_sales,
wa_sales_data type cmds_ei_cmd_sales,
wa_customer type cmds_ei_extern,
wa_customers type cmds_ei_main,
wa_correct type cmds_ei_main,
wa_defective type cmds_ei_main,
wa_mes_correct type cvis_message,
wa_mes_error type cvis_message.
constants: c_update type c value 'M',
c_delete type c value 'D',
c_insert type c value 'I'.
wa_bankdetail_st-task = c_delete.
wa_bankdetail_st-DATA_KEY-BANKS = ws_bankdetl-ctry.
wa_bankdetail_st-DATA_KEY-BANKL = ws_bankdetl-bankkey.
wa_bankdetail_st-DATA_KEY-BANKN = ws_bankdetl-bankacct.
* wa_bankdetail_st-DATA-BKONT = .
* wa_bankdetail_st-DATA-KOINH = .
append wa_bankdetail_st to wa_bank_t.
wa_bankdetail-BANKDETAILS = wa_bank_t.
wa_customer-header-object_instance-kunnr = ws_bankdetl-kunnr.
* wa_customer-header-object_instance-kunnr = ''.
wa_customer-header-object_task = c_update.
* wa_customer-company_data = wa_company_code.
* wa_customer-sales_data = wa_sales_data.
append wa_customer to wa_customers-customers.
CALL METHOD cmd_ei_api=>maintain_bapi
EXPORTING
is_master_data = wa_customers
IMPORTING
ES_MASTER_DATA_CORRECT = wa_correct
ES_MESSAGE_CORRECT = wa_mes_correct
ES_MASTER_DATA_DEFECTIVE = wa_defective
ES_MESSAGE_DEFECTIVE = wa_mes_error.
if wa_mes_error-is_error is initial.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .
endif.
09-02-2015 3:41 PM
I only use the GET DATA method when many informations are required (e.g. some mass copy) here you can build it yourself.
But you could test this method and then analyze the data structure, deep structures are not always easy to manage.
Regards,
Raymond
09-02-2015 4:32 PM
Raymond,
I was able to get it to work. the code is below.
thank you so much for helping me with this in such a quick manner. it has been a long time since I used this forum. do we still award points for this? if so, is marking the answer correct automatically award the points? if not and we still award points, can you let me know how to do this.
thanks again for the quick response and the alternate process for working with customer banking details
FORM del_bankdetls1.
DATA: wa_bankdetail_st TYPE cvis_ei_cvi_bankdetail,
wa_bankdetail TYPE cvis_ei_bankdetail,
wa_bank_t TYPE CVIS_EI_BANKDETAIL_T,
wa_bank TYPE CVIS_EI_BANKDETAIL_KEY,
wa_customer TYPE cmds_ei_extern,
wa_customers TYPE cmds_ei_main,
wa_correct TYPE cmds_ei_main,
wa_defective TYPE cmds_ei_main,
wa_mes_correct TYPE cvis_message,
wa_mes_error TYPE cvis_message.
CONSTANTS: c_update TYPE c VALUE 'M',
c_delete TYPE c VALUE 'D',
c_insert TYPE c VALUE 'I'.
wa_bankdetail_st-task = c_delete.
wa_bankdetail_st-data_key-banks = ws_bankdetl-ctry.
wa_bankdetail_st-data_key-bankl = ws_bankdetl-bankkey.
wa_bankdetail_st-data_key-bankn = ws_bankdetl-bankacct.
APPEND wa_bankdetail_st TO wa_bank_t.
wa_bankdetail-bankdetails = wa_bank_t.
wa_customer-header-object_instance-kunnr = ws_bankdetl-kunnr.
wa_customer-header-object_task = c_update.
wa_customer-central_data-bankdetail = wa_bankdetail.
APPEND wa_customer to wa_customers-customers.
CALL METHOD cmd_ei_api=>maintain_bapi
EXPORTING
is_master_data = wa_customers
IMPORTING
es_master_data_correct = wa_correct
es_message_correct = wa_mes_correct
es_master_data_defective = wa_defective
es_message_defective = wa_mes_error.
IF wa_mes_error-is_error IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .
ENDIF.
ENDFORM.