2006 Sep 20 2:34 PM
hello friends i have written this piece of code, it dose not have any error but when ececuted it gives a dump.
tables : zash.
DATA : BEGIN OF it_table OCCURS 0,
vbeln LIKE zash-vbeln,
posnr LIKE zash-posnr,
uepos LIKE zash-uepos,
netwr LIKE zash-netwr,
matnr LIKE zash-matnr,
END OF it_table.
TYPE-POOLS: slis.
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa>,
<dyn_field>.
DATA: it_fldcat TYPE lvc_t_fcat,
wa_it_fldcat TYPE lvc_s_fcat.
TYPE-POOLS : abap.
DATA: new_table TYPE REF TO data,
new_line TYPE REF TO data.
DATA: xcel TYPE TABLE OF alsmex_tabline WITH HEADER LINE.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text .
PARAMETERS: p_file TYPE rlgrap-filename DEFAULT
'C:\Test.csv'.
PARAMETERS: p_flds TYPE i.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
Add X number of fields to the dynamic itab cataelog
DO p_flds TIMES.
CLEAR wa_it_fldcat.
wa_it_fldcat-fieldname = sy-index.
wa_it_fldcat-datatype = 'C'.
wa_it_fldcat-inttype = 'C'.
wa_it_fldcat-intlen = 10.
APPEND wa_it_fldcat TO it_fldcat .
ENDDO.
.
Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fldcat
IMPORTING
ep_table = new_table.
ASSIGN new_table->* TO <dyn_table>.
Create dynamic work area and assign to FS
CREATE DATA new_line LIKE LINE OF <dyn_table>.
ASSIGN new_line->* TO <dyn_wa>.
Upload the excel
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '200'
i_end_row = '5000'
TABLES
intern = xcel
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
Reformt to dynamic internal table
LOOP AT xcel.
ASSIGN COMPONENT xcel-col OF STRUCTURE <dyn_wa> TO <dyn_field>.
IF sy-subrc = 0.
<dyn_field> = xcel-value.
ENDIF.
AT END OF row.
APPEND <dyn_wa> TO it_table.
CLEAR <dyn_wa>.
ENDAT.
ENDLOOP.
the dump occurs at the append statement into the internal atble it_table.
any advice,
Shejal Shetty.
2006 Sep 20 2:44 PM
2006 Sep 20 2:44 PM
2006 Sep 20 2:47 PM
It is giving me dump Error at the append statement where i am appending data from <dyn_wa> to the internal table it_table.
Shejal Shetty.
2006 Sep 20 2:50 PM
hi shejjal,
chekc my code.
i am updating a data base from excel value.
its working fine. this may hlp u
DATA : int_excel LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
data : record like db_name_age occurs 0 with header line.
DATA : v_start_col TYPE i VALUE '1', "starting col
v_start_row TYPE i VALUE '1', " starting row
v_end_col TYPE i VALUE '2', " total columns
v_end_row TYPE i VALUE '10'. "total no of record
FORM f_upload .
CLEAR : int_excel, int_excel[].
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = wf_filename
i_begin_col = v_start_col
i_begin_row = v_start_row
i_end_col = v_end_col
i_end_row = v_end_row
TABLES
intern = int_excel
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
*Message is 'Unable to upload data from ' wf_filename.
MESSAGE e169(zm050) WITH wf_filename.
ELSE.
SORT int_excel BY row col.
REFRESH : record.
CLEAR : record.
LOOP AT int_excel.
CASE int_excel-col. "go thru each column.
WHEN 1.
record-name = int_excel-value.
WHEN 2.
record-age = int_excel-value.
ENDCASE.
AT END OF row.
APPEND record.
CLEAR record.
ENDAT.
ENDLOOP.
*inserting into table
modfiy db_name_age from table record.
ENDIF.
if this helped pld rewrd points,
rgrds
anver
2006 Sep 20 3:14 PM
Thanks everyone for the code.
I am able to get the data into an internal table from an excel sheet,
But when i am inserting this data from internal table to data base i am having an error,
code i am using to insert,
LOOP AT it_table.
INSERT INTO zvbrp_1 VALUES it_table.
ENDLOOP.
error i am getting,
The type of the database table and work area (or internal table)
"IT1_TABLE" are not Unicode convertible.
(the data base has some data in it and i want to insert new data into the data base)
Shejal.
2006 Sep 20 3:15 PM
the error message is
The type of the database table and work area (or internal table)
"IT_TABLE" are not Unicode convertible.
Shejal.
2006 Sep 20 3:29 PM
obviously it will show as the 2 structures are different
change ur internal table declaration like this
data : begin of it_table occurs 0.
include structure zvbrp_1.
data : end of it_table.
2006 Sep 20 3:39 PM
Thanks everyone for all your help and suggestions.
Shejal Shetty.
2006 Sep 20 2:45 PM
Hi Shejal
it may give dump if file is opened while executing this program.
Best Regards
Naresh
2006 Sep 20 2:46 PM
HI shejal,
In your program, you are trying
to create a dynamic internal table,
using some list of fields.
1.
For this purpose,
in my program,
<b> there is an INDEPENDENT FORM</b>
whose inputs are
<b> LIST OF FIELDS, (just as u require)</b>
and from those, it consructs dynamic table.
2. Here is the program.
the dynamic table name will be
<DYNTABLE>.
3. U can use this program (FORM in this program)
to generate any kind of internal table
by specifying list of fields.
4.
REPORT abc.
*----
COMPULSORY
FIELD-SYMBOLS: <dyntable> TYPE ANY TABLE.
FIELD-SYMBOLS: <dynline> TYPE ANY.
DATA: lt TYPE lvc_t_fcat.
DATA: ls TYPE lvc_s_fcat.
FIELD-SYMBOLS: <fld> TYPE ANY.
DATA : fldname(50) TYPE c.
DATA : ddfields LIKE ddfield OCCURS 0 WITH HEADER LINE.
*----
START-OF-SELECTION.
*----
field list
ddfields-fieldname = 'BUKRS'.
APPEND DDFIELDS.
ddfields-fieldname = 'MATNR'.
APPEND DDFIELDS.
*----
PERFORM mydyntable .
*----
see <DYNTABLE> in debug mode.
BREAK-POINT.
*----
INDEPENDENT FORM
*----
FORM mydyntable .
*----
Create Dyn Table From FC
FIELD-SYMBOLS: <fs_data> TYPE REF TO data.
FIELD-SYMBOLS: <fs_1>.
FIELD-SYMBOLS: <fs_2> TYPE ANY TABLE.
DATA: lt_data TYPE REF TO data.
data : lt TYPE lvc_t_fcat .
*----
CONSTRUCT FIELD LIST
LOOP AT ddfields.
ls-fieldname = ddfields-fieldname.
APPEND ls TO lt.
ENDLOOP.
ASSIGN lt_data TO <fs_data>.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt
IMPORTING
ep_table = <fs_data>
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
*----
Assign Dyn Table To Field Sumbol
ASSIGN <fs_data>->* TO <fs_1>.
ASSIGN <fs_1> TO <fs_2>.
ASSIGN <fs_1> TO <dyntable>.
ENDFORM. "MYDYNTABLE
regards,
amit m.
2006 Sep 20 3:01 PM
chk this logic
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = p_file
i_begin_col = 1
i_begin_row = 4
i_end_col = 15
i_end_row = 65000
tables
intern = it_rows
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
if not it_rows[] is initial.
sort it_rows by row col.
loop at it_rows.
move : it_rows-col to v_index.
assign component v_index of structure it_output to <fs>.
move : it_rows-value to <fs>.
at end of row.
append it_output.
clear it_output.
endat.
endloop.
endif.