02-09-2009 10:16 AM
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
02-09-2009 10:25 AM
Hi,
Plesae replace the loop from
LOOP AT record.
INSERT INTO J_2IRG1BAL VALUES record.
ENDLOOP.
********************
to
*****************
LOOP AT record.
move-corresponding record to J_2IRG1BAL.
INSERT J_2IRG1BAL.
ENDLOOP.
this works as i have ran a test program with the same...
hope this helps you as well
Regards,
Siddarth
02-09-2009 10:19 AM
hi...
use internal table of line type of that standard table
or
uncheck unicode attribute of the program
regards
Edited by: Mohit Kumar on Feb 9, 2009 11:19 AM
02-09-2009 10:19 AM
Hi,
Just check structure of an internal table and u r standard table..
declare work area like this..
data:
wa_intern type standard table of record.
Regards
Kiran
Edited by: Kiran Saka on Feb 9, 2009 11:23 AM
02-09-2009 10:20 AM
Hi.
plz define ur work area just like the table which u are going to update.
meanz change it according to table to which u are updating through ur work area
02-09-2009 10:24 AM
Hi,
May the following Sample Code help you out.
TYPES: kna1.
DATA: it_kna1 LIKE STANDARD TABLE OF kna1 WITH HEADER LINE,
wa_it_kna1 LIKE kna1.
SELECT * FROM kna1
INTO CORRESPONDING FIELDS OF TABLE it_kna1.
LOOP AT it_kna1 INTO wa_it_kna1.
" Do Change here in the any Field of WorkArea
MODIFY kna1 FROM wa_it_kna1.
ENDLOOP.
Kind Regards,
Faisal
02-09-2009 10:25 AM
Hi,
Plesae replace the loop from
LOOP AT record.
INSERT INTO J_2IRG1BAL VALUES record.
ENDLOOP.
********************
to
*****************
LOOP AT record.
move-corresponding record to J_2IRG1BAL.
INSERT J_2IRG1BAL.
ENDLOOP.
this works as i have ran a test program with the same...
hope this helps you as well
Regards,
Siddarth