‎2013 Dec 23 7:18 AM
Hi,
I have a BDC requirement. We have a 'Test' check box in the selection screen where if the 'Test' check box is checked, we only need to check for the errors for the given data (or record). We have 2 options for this:
1) Manually validate the data in the file
2) Run the BDC with out saving the transaction. I.E don't execute the 'SAVE' command in the BDC by putting some condition like 'If the checkbox is checked, that 'SAVE' command should not be executed.
Both the cases, we can get the errors, if any. Now, my question is can you please tell me which one is the best option and can we go for the 2nd option?
Thanks
Mahidhar
‎2013 Dec 23 7:21 AM
Hi Mahidhar
You have made a BDC for which tcode...? Migh be some simulation BAPI already available
Nabheet
‎2013 Dec 23 7:24 AM
Hi Mahi,
please see this example, through you can get error messages for those data, where there is any
wrong data appears, i always use this bapi, to take error log, you can modify this code according to your needs, it will give you error log
DATA : BEGIN OF options.
INCLUDE STRUCTURE ctu_params.
DATA : END OF options.
DATA: i_messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE,
l_message LIKE bapiret2-message.
DATA: p_mode TYPE c.
DATA BEGIN OF it_error OCCURS 1.
DATA : text(100) TYPE c.
DATA END OF it_error.
DATA BEGIN OF it_success OCCURS 1.
DATA: text(100) TYPE c.
DATA END OF it_success.
CALL TRANSACTION 'FB01' USING bdcdata
OPTIONS FROM options
MESSAGES INTO i_messtab.
IF SY-SUBRC NE 0.
CALL FUNCTION 'BAPI_MESSAGE_GETDETAIL'
EXPORTING
id = sy-msgid
number = sy-msgno
language = sy-langu
textformat = 'ASC'
message_v1 = sy-msgv1
message_v2 = sy-msgv2
message_v3 = sy-msgv3
message_v4 = sy-msgv4
IMPORTING
message = l_message.
.
CONCATENATE l_message '-' wa_input-newko wa_input-wrbtr wa_input-budat INTO it_error-text
SEPARATED BY ' '.
APPEND it_error.
ELSE.
CONCATENATE 'DATA UPLOADED SUCCESSFULLY :' wa_input-newko wa_input-wrbtr wa_input-budat
INTO it_success-text SEPARATED BY ' '.
APPEND it_success.
ENDIF.
REFRESH bdcdata.
CLEAR: wa_input,l_message.
ENDLOOP.
‎2013 Dec 23 7:46 AM
Hello Mahidhar.
I would suggest for first option of yours mainly because it improves readability of the program code.
And go for BDC only if you don't have any BAPI/FM for that functionality.
Regards.
‎2013 Dec 23 8:07 AM
hi Mahidhar
why you don`t want excute 'SAVE' command? thanks.
archer
‎2013 Dec 24 5:06 AM
Hi,
Firstly check if there is any BAPI available for the updates you are trying to make via BDC. Secondly, go for first option. Get rid of erroneous data in the file, and then probably you can decide if clean data should be processed or nothing should be processed.
Thanks!
-Vishal