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

Rgarding the insert statement

Former Member
0 Likes
662

Hi

Can any one help me in doing this,

types : BEGIN OF ty_INTABLE ,

ZWERKS_FR type ZITWOTRPLOC-ZWERKS_FR,

ZWERKS_TO type ZITWOTRPLOC-ZWERKS_TO,

ZTRDAYS TYPE ZITWOTRPLOC-ZTRDAYS,

ZTRCOST TYPE ZITWOTRPLOC-ZTRCOST,

ZINDICATOR type ZITWOTRPLOC-ZINDICATOR,

END OF ty_INTABLE.

data : it_intable type table of TY_INTABLE,

wa_intable LIKE LINE OF IT_INTABLE.

data : file_name type string,

w_sucess type i,

w_error type i.

PARAMETERS:

P_PCFN LIKE RLGRAP-FILENAME DEFAULT 'C:\'.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_PCFN.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

IMPORTING

FILE_NAME = P_PCFN

.

start-of-selection.

file_name = P_PCFN.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = file_name

FILETYPE = 'DAT'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = it_intable

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

loop at it_intable into wa_intable.

if sy-subrc eq 0.

insert ZITWOTRPLOC FROM WA_INTABLE.

if sy-subrc eq 0.

w_sucess = w_sucess + 1.

endif.

it is saying that the type of the database table and work area wa_intable are not unicode-convertible,

thanks and regards,

Rajesh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
620

Hi,

Check u r internal table definition once again.

Try with this syntax.

TYPES: BEGIN OF TY_HEADER,

EBELN TYPE EKKO-EBELN,

AEDAT TYPE EKKO-AEDAT,

LIFNR TYPE EKKO-LIFNR,

EKORG TYPE EKKO-EKORG,

KNUMV TYPE EKKO-KNUMV,

END OF TY_HEADER.

DATA: IT_HEADER TYPE STANDARD TABLE OF TY_HEADER,

WAHEADER TYPE TY_HEADER.

If that doesn't workout the problem may be with insert statemetn.

Insert command should be like following.

In the loop u take a variable like sy-index.

INSERT VALUE INTO ITAB INDEX SY-INDEX.

Rewardpoints if useful.

Regards

(YUGANDHAR.P)

5 REPLIES 5
Read only

former_member404244
Active Contributor
0 Likes
620

Hi,

u ahve do like this

data : it_table type table of ZITWOTRPLOC,

wa_table type ZITWOTRPLOC.

LOOP at it_intable into wa_intable.

move : wa_intable-field1 to wa_table-field1,

wa_intable-field2 to wa_table-field2.

append wa_table to it_table.

clear : wa_intable,

wa_table.

endloop.

Now write the statement

insert ZITWOTRPLOC FROM table it_table.

if sy-subrc eq 0.

commit work.

endif.

Regards,

nagaraj

Read only

abdulazeez12
Active Contributor
0 Likes
620

Dont give specific fields in the internal table. Try declaring whole table fields in the interbal tbale declaration..

itab like ZITWOTRPLOC occurs 0 with header line..

and then try with INSERT stmt.

Read only

Former Member
0 Likes
620

Hi

declare the work area as

<b>data: it_intable LIKE ZITWOTRPLOC occurs 0 with header line.</b>

comment these lines

loop at it_intable into wa_intable.

if sy-subrc eq 0.

insert ZITWOTRPLOC FROM WA_INTABLE.

if sy-subrc eq 0.

w_sucess = w_sucess + 1.

endif.

straight away use the single line

<b>insert ZITWOTRPLOC FROM it_INTABLE.</b>

Regards

anji

Read only

Former Member
0 Likes
621

Hi,

Check u r internal table definition once again.

Try with this syntax.

TYPES: BEGIN OF TY_HEADER,

EBELN TYPE EKKO-EBELN,

AEDAT TYPE EKKO-AEDAT,

LIFNR TYPE EKKO-LIFNR,

EKORG TYPE EKKO-EKORG,

KNUMV TYPE EKKO-KNUMV,

END OF TY_HEADER.

DATA: IT_HEADER TYPE STANDARD TABLE OF TY_HEADER,

WAHEADER TYPE TY_HEADER.

If that doesn't workout the problem may be with insert statemetn.

Insert command should be like following.

In the loop u take a variable like sy-index.

INSERT VALUE INTO ITAB INDEX SY-INDEX.

Rewardpoints if useful.

Regards

(YUGANDHAR.P)

Read only

varma_narayana
Active Contributor
0 Likes
620

Hi..

Declare the ITAB like this. With the Same structure as the DB table.

<b>data : it_intable type table of ZITWOTRPLOC.</b>

Then insert the Records into DB table directly from ITAB.

Insert ZITWOTRPLOC FROM table IT_INTABLE ACCEPTING DUPLICATE KEYS.

Write:/ 'No of records inserted =', sy-dbcnt.

<b>REWARD IF HELPFUL.</b>