Hello SDNers,
I am uploading valuation class using BAPI_MATERIAL_SAVEDATA.
In my excel file I had 25 material of different types.
Out of 25 records 13 were uploaded to DB for remaining I got these kinds of errors.
1) The field MBEW-BKLAS/ BAPI_MBEW-VAL_CLASS is defined as a required field; it does not contain an entry.
2) No description transferred
What could be the reason for the following error.
* Declaration of tables internal tables and bapi structure. tables : mbew. " Material valuation data : begin of t_matvclass occurs 0, material type matnr, " Material ind_sec type mbrsh, " Industry sector mat_typ type mtart, " Material type val_class type BKLAS, " Valuation class end of t_matvclass. data : wa like line of t_matvclass. data :bapi_head like bapimathead, " Header Segment with Control Info bapi_valclass like BAPI_MBEW, " Valuation class bapi_valclassx like BAPI_MBEWx, " Checkbox Structure for BAPI_MBEW bapi_return like bapiret2, " Bapi return structrue returnm type table of bapi_matreturn2 with header line. data : it_excel type alsmex_tabline occurs 0 with header line. data: begin of it_ret occurs 0. include structure bapiret2. data end of it_ret. * Data objects for exception handling. data : lv_converr type ref to CX_SY_CONVERSION_ERROR, lv_dynerr type ref to CX_SY_DYN_CALL_ERROR. data : txt_converr type string, txt_converr_l type string, txt_dynerr type string, txt_dynerr_l type string. * Declaring selection screen for selecting a data file * for uploading valuation class selection-screen begin of block b1 with frame title text-001. parameter : file_nam type rlgrap-filename obligatory default 'C:\master data UPDATED_test.xls'. parameter : p_begcol type i default 1 no-display, p_begrow type i default 2 no-display, p_endcol type i default 4 no-display, p_endrow type i default 26 no-display. parameters: p_valare type mbew-bwkey obligatory. " Valuation area selection-screen end of block b1. at selection-screen on value-request for file_nam. perform F_get_file using file_nam. start-of-selection. perform F_xls_itab using file_nam changing it_excel. perform F_move_data. perform F_get_data. form F_xls_itab using p_file_nam changing p_it_excel. CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE' EXPORTING filename = file_nam i_begin_col = p_begcol i_begin_row = p_begrow i_end_col = p_endcol i_end_row = p_endrow tables intern = it_excel EXCEPTIONS INCONSISTENT_PARAMETERS = 1 UPLOAD_OLE = 2 OTHERS = 3. endform. " F_xls_itab form F_get_file using p_file_nam. CALL FUNCTION 'KD_GET_FILENAME_ON_F4' EXPORTING PROGRAM_NAME = SYST-REPID DYNPRO_NUMBER = SYST-DYNNR * FIELD_NAME = ' ' * STATIC = ' ' * MASK = ' ' CHANGING file_name = file_nam EXCEPTIONS MASK_TOO_LONG = 1 OTHERS = 2. endform. " F_get_file form F_move_data . data : lv_index type i. field-symbols <fs>. * Sorting the internal table sort it_excel by row col. clear it_excel. loop at it_excel. move it_excel-col to lv_index. * Assigning each record to the internal table row. assign component lv_index of structure wa to <fs>. * Assigning the field value to a field symbol move it_excel-value to <fs>. at end of row. append wa to t_matvclass. clear wa. endat. endloop. endform. " F_move_data form F_get_data . loop at t_matvclass into wa. try. * BAPIHEAD --- > Header Segment with Control Information bapi_head-material = wa-material. bapi_head-ind_sector = wa-ind_sec. bapi_head-matl_type = wa-mat_typ. bapi_head-account_view = 'X'. * For Valuation Class. bapi_valclass-val_area = p_valare. bapi_valclass-val_class = wa-val_class. bapi_valclassx-val_area = p_valare. bapi_valclassx-std_price = 'X'. catch CX_SY_CONVERSION_ERROR into lv_converr. txt_converr = lv_converr->get_text( ). txt_converr_l = lv_converr->get_longtext( ). write:/ 'Error:', txt_converr color 5. write:/ 'Error:', txt_converr_l color 3. endtry. perform F_call_bapi. read table it_ret with key type = 'S'. " Success if sy-subrc eq 0. perform F_bapi_commit. write:/10 'Valuation Class created or updated successfully' color 4. else. *loop at it_ret. write:/1 it_ret-type, 8 it_ret-id, 30 it_ret-number, 38 it_ret-message, 190 it_ret-parameter, 210 it_ret-row, 220 it_ret-field. *endloop. endif. endloop. endform. " F_get_data form F_bapi_commit. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' * EXPORTING * WAIT = * IMPORTING * RETURN = . endform. " F_bapi_commit form F_call_bapi . CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA' EXPORTING headdata = bapi_head VALUATIONDATA = bapi_valclass VALUATIONDATAX = bapi_valclassx IMPORTING RETURN = it_ret TABLES RETURNMESSAGES = returnm. endform. " F_call_bapi
Please help me out SDNers.
Regards,
Ranjith N