Skip to Content
0
Former Member
Feb 09, 2009 at 10:16 AM

Update std table

27 Views

Hello Experts,

My req is to upload MC.9 data from excel & update std.table J_2TRG1BAL..

Do i m following correct approach..

REPORT .

TABLES : J_2IRG1BAL .

DATA : BEGIN OF record OCCURS 0,

werks LIKE t001w-werks,

name1 LIKE t001w-name1,

matnr LIKE mara-matnr,

maktx LIKE makt-maktx,

lgort LIKE t001l-lgort,

lgobe LIKE t001l-lgobe,

labst LIKE mard-labst,

meins LIKE mseg-meins,

valstock LIKE mard-labst,

valstockmeins LIKE mseg-meins,

cnstgstock LIKE mard-labst,

cnstgstockmeins LIKE mseg-meins,

END OF record.

DATA : vf_index TYPE i.

DATA : vf_start_col TYPE i VALUE '1', "start column

vf_start_row TYPE i VALUE '2', "start row

vf_end_col TYPE i VALUE '256', "maximum column

vf_end_row TYPE i VALUE '65536', "maximum row

p_text(20). "stores error messages

  • Internal Table

data:it_excel like table of alsmex_tabline with header line.

************************************************************************

*/ Work Area

data: wa_intern like it_excel.

*/ Field symbol

FIELD-SYMBOLS : <fs>.

****************************************************

PARAMETERS: p_file LIKE rlgrap-filename MEMORY ID m01,

noheader AS CHECKBOX.

****************************************************

START-OF-SELECTION.

call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

exporting

filename = p_file

i_begin_col = vf_start_col

i_begin_row = vf_start_row

i_end_col = vf_end_col

i_end_row = vf_end_row

tables

intern = it_excel

exceptions

inconsistent_parameters = 1

upload_ole = 2

others = 3.

IF sy-subrc <> 0.

WRITE: / 'EXCEL UPLOAD FAILED :', p_file, sy-subrc.

ELSE.

SORT it_excel BY row col.

LOOP AT it_excel.

IF noheader = 'X'

AND it_excel-row = 1.

CONTINUE.

ENDIF.

vf_index = it_excel-col.

ASSIGN COMPONENT vf_index OF STRUCTURE record TO <fs>.

MOVE : it_excel-value TO <fs>.

AT END OF row.

APPEND record.

CLEAR record.

ENDAT.

ENDLOOP.

ENDIF.

LOOP AT record.

INSERT INTO J_2IRG1BAL VALUES record.

ENDLOOP.

IF sy-subrc EQ 0.

WRITE: / 'DATA UPLOAD SUCCESSFUL'.

ENDIF.

***************************************************************************

But it is showing error..

The type of the database table and work area (or internal table)

"RECORD" are not Unicode convertible.

Plz suggest solution to update std table