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

ANY hint ..why this code is not working? insert is not working

Former Member
0 Likes
807

REPORT ZBDCDIRECTIP .

DATA ITAB LIKE KNA1 OCCURS 0 WITH HEADER LINE.

DATA : BEGIN OF ITAB1 OCCURS 0,

STR(255),

END OF ITAB1.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\Documents and Settings\micro\Desktop\KNA1.TXT'

FILETYPE = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = ITAB1

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 ITAB1.

SPLIT ITAB1 AT ',' INTO ITAB-KUNNR ITAB-NAME1 ITAB-LAND1.

APPEND ITAB.

ENDLOOP.

INSERT KNA1 FROM table ITAB.

LOOP AT ITAB.

WRITE : / ITAB-KUNNR, ITAB-NAME1, ITAB-LAND1.

ENDLOOP.

any clues ????

Message was edited by:

balaji velpuri

REPORT ZBDCDIRECTIP .

DATA ITAB LIKE KNA1 OCCURS 0 WITH HEADER LINE.

DATA : BEGIN OF ITAB1 OCCURS 0,

STR(255),

END OF ITAB1.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\Documents and Settings\micro\Desktop\KNA1.TXT'

FILETYPE = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = ITAB1

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 ITAB1.

SPLIT ITAB1 AT ',' INTO ITAB-KUNNR ITAB-NAME1 ITAB-LAND1.

APPEND ITAB.

ENDLOOP.

INSERT KNA1 FROM table ITAB.

LOOP AT ITAB.

WRITE : / ITAB-KUNNR, ITAB-NAME1, ITAB-LAND1.

ENDLOOP.

any clues ????

Message was edited by:

balaji velpuri

6 REPLIES 6
Read only

Former Member
0 Likes
782

Hi,

what doesn't work? the upload or insert?

Regards, Dieter

Read only

Former Member
0 Likes
782

HI,

the definition message-id is missing at report.

REPORT BDCDIRECTIP MESSAGE-ID SY.

regards

Nicole

Read only

Former Member
0 Likes
782

Hi,

Try to debug this program.

Check whether<b> itab1</b> and <b>itab</b> is getting values or not?

Regards,

Amit

Read only

Former Member
0 Likes
782

Hi Balaji,

Try This.

REPORT ZBDCDIRECTIP .

DATA ITAB LIKE KNA1 OCCURS 0 WITH HEADER LINE.

DATA : BEGIN OF ITAB1 OCCURS 0,

STR(255),

END OF ITAB1.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\Documents and Settings\micro\Desktop\KNA1.TXT'

FILETYPE = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = ITAB1

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 ITAB1.

SPLIT ITAB1 AT ',' INTO ITAB-KUNNR ITAB-NAME1 ITAB-LAND1.

APPEND ITAB.

ENDLOOP.

<b>INSERT lines of Itab into KNA1.</b>

LOOP AT ITAB.

WRITE : / ITAB-KUNNR, ITAB-NAME1, ITAB-LAND1.

ENDLOOP.

Reward if useful.

Regards,

Chitra.

Message was edited by:

Chitra Parameswaran

Read only

Former Member
0 Likes
782

Hi

there is no error in your coding its working fine

I have checked that coding in both latest( ECC 6) and old versions( 4.7) also

So u can execute ur code freely

Regards

Pavan

Read only

Former Member
0 Likes
782

hi

good

your INSERT statement is wrong,go through this link which ll give you idea about the INSERT statement.

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/insert_d.htm

thanks

mrutyun^