Application Development and Automation 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: 
Read only

Insert data to ZTABLE...How?

Former Member
0 Likes
932

Hi All,

Can someone show me a code on how to insert a data coming from an upload file? i have this code

insert ztbl_cust_no from table it_exel but the problem is, the system gave a an error like

The work are IT_EXEL is not long enough. I dont understand it.

Here's my declaration of IT_EXEL.

DATA: BEGIN OF it_exel OCCURS 1000,

lifnr TYPE ztbl_cust_no-lifnr,

lifnrecc6 TYPE ztbl_cust_no-lifnrecc6,

END OF it_exel.

Please help! Thanks so much!

Regards,

Mackoy

7 REPLIES 7
Read only

Former Member
0 Likes
833

Hi,

Your satructure must be same as z table structure

ie it_excel should be same like Z table structure.

Regards,

siva chalasani.

Read only

Former Member
0 Likes
833

Hi,

I think the field length is not enough

please try like this

DATA: BEGIN OF it_exel OCCURS 1000,

lifnr TYPE string,

lifnrecc6 TYPE string,

END OF it_exel.

if its useful reward points

Read only

Former Member
0 Likes
833

Hi,

first of all one question.

is the lt_excel structure similar to the structure of ztbl_cust_no ?

to insert the table the structures should be similar.

you need to move the field values in the structure of the ztbl_cust_no type and then insert.

The line to be inserted is taken from the work area wa and the data read from left to right according to the line structure of the database table dbtab.

use the same complete structure and that will solve the problem.

reward if usefull

taher

Read only

prasanth_kasturi
Active Contributor
0 Likes
833

DATA: BEGIN OF it_exel OCCURS 0,

lifnr TYPE ztbl_cust_no-lifnr,

lifnrecc6 TYPE ztbl_cust_no-lifnrecc6,

END OF it_exel.

if you are using a excel file to upload data check the example code

the fm 'ALSM_EXCEL_TO_INTERNAL_TABLE' uses a internal table of structure different from that of your flat file. check the strtucture

TYPES: BEGIN OF ty_mara,

matnr LIKE mara-matnr,

mbrsh LIKE mara-mbrsh,

mtart LIKE mara-mtart,

maktx LIKE makt-maktx,

meins LIKE mara-meins,

END OF ty_mara.

**

DATA: it_mara TYPE table of ty_mara WITH HEADER LINE.

parameters : p_file like RLGRAP-FILENAME.

data : itab type table of ALSMEX_TABLINE WITH HEADER LINE.

start-of-selection.

*

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = p_file

i_begin_col = 1

i_begin_row = 1

i_end_col = 5

i_end_row = 4

tables

intern = itab.

loop at itab.

CASE ITAB-COL.

WHEN '1'.

it_mara-matnr = ITAB-VALUE.

WHEN '2'.

it_mara-mbrsh = ITAB-VALUE.

WHEN '3'.

it_mara-mbrsh = ITAB-VALUE.

WHEN '4'.

it_mara-maktx = ITAB-VALUE.

WHEN '5'.

it_mara-meins = ITAB-VALUE.

ENDCASE.

AT END OF ROW.

APPEND it_mara.

CLEAR it_mara.

ENDAT.

endloop.

loop at it_mara.

write 😕 it_mara-matnr.

endloop.

regards

prasanth

Read only

Former Member
0 Likes
833

Hi Mackoy,

DATA: BEGIN OF it_exel OCCURS 0,

lifnr TYPE ztbl_cust_no-lifnr,

lifnrecc6 TYPE ztbl_cust_no-lifnrecc6,

END OF it_exel.

Rewad if useful,

Regards,

S.Suresh.

Read only

Former Member
0 Likes
833

How many records you have in your file??????If your file have more than 1000 records then in that case you have to define it as OCCURS 0

Edited by: phanisreedhar lakamsani on May 22, 2008 7:41 AM

Read only

Former Member
0 Likes
833

data : it_ztable like ztable occurs 0 with header line.

DATA: BEGIN OF it_exel OCCURS 1000,

lifnr TYPE ztbl_cust_no-lifnr,

lifnrecc6 TYPE ztbl_cust_no-lifnrecc6,

END OF it_exel.

loop at it_exel.

it_ztable-field1 = it_exel-field1.

it_ztable-field2 = it_exel-field2.

"

"

"

append it_ztable.

clear it

endloop.

modify ztable from table it_ztable.

Regards,

Madan.