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

Validate the file values BEFORE preforming bdc

Former Member
0 Likes
2,335

Hi,

How can I validate data from input file(flat file) before performing BDC. Suppose I have a flat file which has 1000's of records.Is there any way to validate the values BEFORE preforming bdc. So if there are some wrong input in file, then we can send a list to client. I am doing this for ME21n.

Thanks..

Edited by: Julius Bussche on Feb 23, 2009 1:29 PM

Please use meaningfull subject titles

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,600

Hi,

Try this code....

First write the select stmt....

*VALIDATING THE G/L ACCOUNT

SELECT bukrs

saknr

INTO TABLE int_skb1

FROM skb1

FOR ALL ENTRIES IN int_file

WHERE saknr = int_file-hkont.

IF sy-subrc = 0.

SORT int_skb1 BY bukrs saknr.

ENDIF.

then before calling the BDC use the folowing stmt...and catch the error in one internal table and display it in the form of report or download those eror records to an excel at the end of report execution.

example to validate the G/L account.

**CHECK G/L ACCOUNT IS OK OR NOT

READ TABLE int_skb1 INTO fs_skb1 WITH KEY bukrs = fs_file-bukrs

saknr = fs_file-hkont

BINARY SEARCH.

IF sy-subrc <> 0.

PERFORM f_error_log USING text-005. "Invalid G/L Account

CONTINUE.

ENDIF.

FORM f_error_log USING l_message TYPE string.

CLEAR : fs_final.

fs_final-bukrs = fs_file-bukrs.

fs_final-kunnr = fs_file-accnt.

fs_final-xblnr = fs_file-xblnr.

fs_final-zuonr = fs_file-zuonr.

fs_final-shkzg = fs_file-shkzg.

fs_final-status = text-014. "Error

fs_final-message = l_message.

APPEND fs_final TO int_final.

endform.

Hope this will help.

Regards,

Rohan.

Hi,

How can I validate data from input file(flat file) before performing BDC. Suppose I have a flat file which has 1000's of records.Is there any way to validate the values BEFORE preforming bdc. So if there are some wrong input in file, then we can send a list to client. I am doing this for ME21n.

Thanks..

Edited by: Julius Bussche on Feb 23, 2009 1:29 PM

Please use meaningfull subject titles

9 REPLIES 9
Read only

Former Member
0 Likes
1,600

Hi Gaurav,

To validate or to know where your error is you can capture you messages.

That you can do using bdcmsgcoll table and then capture the messages in the fields msgv1 , msgv2 , msgv3 and msgv4.

You ll know where your making the mistake and can correct it.

Much Regards,

Amuktha.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,600
  • Not without programming the check yourself, or you may execute [CALL TRANSACTION|http://help.sap.com/erp2005_ehp_04/helpdata/EN/fa/09715a543b11d1898e0000e8322d00/frameset.htm] and store error messages to send to user (create the BDC for errored records only)

  • The transaction ME21N is an enjoy transaction, not compatible with BDC ([Note 217437 - ME21N/ME51N: Batch input and CATT not possible|https://service.sap.com/sap/support/notes/217437]) (or are you lucky ?)

To create orders, you can use BAPI BAPI_PO_CREATE (as of Release 4.6C, BAPIs BAPI_PO_CREATE1 and BAPI_PO_CHANGE are also available, but not officially released

Regards

Read only

Former Member
0 Likes
1,601

Hi,

Try this code....

First write the select stmt....

*VALIDATING THE G/L ACCOUNT

SELECT bukrs

saknr

INTO TABLE int_skb1

FROM skb1

FOR ALL ENTRIES IN int_file

WHERE saknr = int_file-hkont.

IF sy-subrc = 0.

SORT int_skb1 BY bukrs saknr.

ENDIF.

then before calling the BDC use the folowing stmt...and catch the error in one internal table and display it in the form of report or download those eror records to an excel at the end of report execution.

example to validate the G/L account.

**CHECK G/L ACCOUNT IS OK OR NOT

READ TABLE int_skb1 INTO fs_skb1 WITH KEY bukrs = fs_file-bukrs

saknr = fs_file-hkont

BINARY SEARCH.

IF sy-subrc <> 0.

PERFORM f_error_log USING text-005. "Invalid G/L Account

CONTINUE.

ENDIF.

FORM f_error_log USING l_message TYPE string.

CLEAR : fs_final.

fs_final-bukrs = fs_file-bukrs.

fs_final-kunnr = fs_file-accnt.

fs_final-xblnr = fs_file-xblnr.

fs_final-zuonr = fs_file-zuonr.

fs_final-shkzg = fs_file-shkzg.

fs_final-status = text-014. "Error

fs_final-message = l_message.

APPEND fs_final TO int_final.

endform.

Hope this will help.

Regards,

Rohan.

Read only

Former Member
0 Likes
1,600

hi,

1. Record ME21N tcode normally but instead of clicking save button in the end, u click 'check (ctrl + shift + F3)' button and put in perform say 'check_items'.

2. Record ME21N tcode again and this time by clicking save button in the end and put in a perform say 'post_items'.

3. Now u pass the original internal to perform 'check items' . This will give u list of warning and error (if any) which will be captured using BDC error handing. Mark those internal table line item which gives error say using some indicator 'X'.

4. Now Pass the internal table line items (without indicator mark 'X' ) to perform ' post_items'.

5. And give list of line items with indicator 'X' to the user with corresponding error which we found in 'check_items'.

hope this will help.

aswin.

Read only

Former Member
0 Likes
1,600

While excuting BDC,

After Uploading flat file your all records are stored into one internal table.

you can validate each record and each field value.

Read only

Former Member
0 Likes
1,600

Hi Gaurav,

Please follow following steps:

1. Upload the data from desktop / application server.

2. Get the master data for all data. e.g. If you have material no as one of the field, then get master data for materials from MARA table.

3. After getting all master data, loop into the uploaded data and validate it with master data selected. Also apply business validations also if any. Mark invalid data.

4. Delete invalid data.

5. If u r doing BDC, then try to upload data using BDC with CALL TRANSACTION. But do not save data. If you can reach last screen successfully that means data is correct. It is like simulation which is provided in some of the SAP standard transactions or you can say test mode.

6. Once get through all these steps, you can upload the good data.

Hope this will help you.

Regards,

Anil

Read only

Former Member
0 Likes
1,600

Thank you all..

ur answers are very informative and they solved my problem..

Thanks you so much..

Regards,

Gaurav

Edited by: Gaurav Kumawat on Feb 23, 2009 12:25 PM

Read only

Former Member
0 Likes
1,600

THANK YOU so much