Application Development 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: 

Validation in BDC

Former Member
0 Kudos

Hi All,

I am facing a problem in BDC. I have to upload bulk data from flat file into SAP, for that i have put some conditions. Is there any method by which i can filter those records which don't fullfill those conditions from bulk using that bdc.

With this, it shuldn't allow any of the record to upload into SAP, unless & untill all the records of flat file are correct.

Regards,

Vinita Sharma

4 REPLIES 4

Former Member
0 Kudos

Hi,

Validation's you have to do by your own.......BDC is not meant for that and should not be used for that.....

Former Member
0 Kudos

Hello,

One way to do it is to Run a LOOP for the first time and check for the Condition that you want. Move all those records into a Separate Internal Table and delete the same records from the Orignial Internal Table which has to be passed to BDC. Once the Records are filtered, then you can go ahead and upload all the Valid Records into SAP.

Hope it helps.

Thanks and Regards,

Venkat Phani Prasad Konduri

Former Member
0 Kudos

t_mat --- internal table holding flat file data

wa --- work area

IF t_MAT IS NOT INITIAL.

*first screen data

SELECT MATNR FROM MARA INTO TABLE t_MN " ETXRACTING MATNR DATA FROM MARA TO VALIDATE THE FIELD

FOR ALL ENTRIES IN t_MAT WHERE MATNR = t_MAT-MATNR.

IF sy-subrc NE 0.

MESSAGE i000 WITH 'MATNR IS NOT VALID FOR THIS RECORD'.

ENDIF.

.......................................

.......................................

.......................................

.......................................

endif.

SORT T_MN BY MATNR .

LOOP AT t_MAT INTO wa_MAT.

IF sy-tabix IS NOT INITIAL. "to check next row of internal table filled with data

  • validate field MATERIAL NO of flat file with field in check table

read table t_MN with TABLE key MATNR = wa_MAT-MATNR transporting no fields.

IF sy-subrc = 0. "checking for validation of the MATERIAL NO

wa_valid-matnr = wa_MAT-matnr. "moving MATERIAL NO from internal table to valid internal table

ELSE.

wa_INvalid-matnr = wa_MAT-matnr. "moving MAT NO from internal table to INvalid internal table

CONCATENATE 'MATERIAL NO-' wa_invalid-matnr

wa_invalid-error INTO wa_invalid-error SEPARATED BY ' ' .

ENDIF.

.......................................

.......................................

.......................................

.......................................

endif.

endloop.

manoj

Mohamed_Mukhtar
Active Contributor
0 Kudos

Hi Vineeta ,

To handle error records,

prepare an error internal table of same type as record internal table with an extra field for error text.

Loop at <internal table> into <work Area>

" do validations for your field. 
" for example :
 PERFORM err_h_matnr.
'
'
'
do validations for ever field
IF w_hflag is intial.

" write here the code generated through recording
else.
" collect all error records here.
" clear w_hflag
endif.
endloop.
*&---------------------------------------------------------------------*
*&      Form  ERR_MATNR
*&---------------------------------------------------------------------*
FORM err_h_matnr .

  IF wa_record-matnr_001 IS NOT INITIAL.

    SELECT SINGLE matnr FROM mara
                            INTO w_matnr
                            WHERE matnr = wa_record-matnr_001.

    IF sy-dbcnt = 0.
      wa_tmp_table = wa_record.
      wa_tmp_table-ertxt = 'MATERIAL DOES NOT EXIST'.
      w_hflag = 'X'.  " set a flag if an error record is found
    ENDIF.
    IF sy-dbcnt <> 0.
      wa_tmp_table = wa_record.
    ENDIF.
  ENDIF.

ENDFORM.                    " ERR_MATNR

Thanks & Regards