Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Validating BDC data

Former Member
0 Likes
1,093

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

5 REPLIES 5
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
910

Hi Mahidhar

You have made a BDC for which tcode...? Migh be some simulation BAPI already available

Nabheet

Read only

former_member187748
Active Contributor
0 Likes
910

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(100TYPE c.

DATA  END   OF it_error.

DATA  BEGIN OF it_success OCCURS 1.

DATAtext(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.

Read only

Arun_Prabhu_K
Active Contributor
0 Likes
910

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.

Read only

Former Member
0 Likes
910

hi Mahidhar

why you don`t want excute 'SAVE' command? thanks.

archer

Read only

vishal_sharda2
Participant
0 Likes
910

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