11-09-2007 3:10 PM
Hi experts,
I tried this pgm i got the success msg but the data never get uploaded..i paste my pgm...help me please.....
tables:zkna1.
data:begin of itab occurs 0,
kunnr like kna1-kunnr,
ktokd like kna1-ktokd,
brsch like kna1-brsch,
kukla like kna1-kukla,
end of itab.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\Documents and Settings\User\Desktop\cust_master.txt'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = itab
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 itab.
insert zkna1.
modify zkna1.
if sy-subrc = 0.
message 'data uploaded successfully' type 'S'.
else.
message 'data is not uploaded' type 'W'.
endif.
endloop.
11-09-2007 7:00 PM
Hi Manjula,
your problem is in below statements.
insert zkna1.
modify zkna1.
do like this.
insert zkna1 from itab.
modify zkna1 from itab.
Hope your problem will get resolved.
Reward points if it helps,
Satish
11-09-2007 3:19 PM
Use COMMIT WORK.
Like:
loop at itab.
insert zkna1.
modify zkna1.
if sy-subrc <> 0.
l_error = 'X'. "<< set the flag
endif.
endloop.
if l_error is initial. "<< check the flag
commit work. " << commit work
message 'data uploaded successfully' type 'S'.
else.
rollback work.
message 'data is not uploaded' type 'W'.
endif.
Regards,
Naimesh Patel
11-09-2007 3:23 PM
What exactly do yo want to do
- Create records in ZKNA1 / Update records existing
- Are all fields provided in uploaded file
If all fields are provided, try something like
MOVE-CORRESPONDING itab TO zkna1.
MODIFY ZKNA1.
or if structure are identical
MODIFY ZKNA1 FROM TABLE ITAB.
If some records already exist and the file uploaded doesn't provide all fields of the table you have to read the data already existing before MODIFY the database
SELECT * FROM ZKNA1 INTO TABLE T_ZKNA1 FOR ALL ENTRIES IN ITAB WHERE...
Then update of insert into T_ZKNA1 with the data uploaded and at end update the database.
Use COMMIT WORK if you want tbe database to be updated before the end of the transaction.
Regards
<i>PS: MODIFY UPDATE or INSERT the records so if INSERT is successful, don't MODIFY just after.</i>
11-09-2007 5:36 PM
I think you should define i_tab as
data:begin of itab occurs 0,
kunnr(10) type c,
ktokd(4) type c,
brsch(4) type c,
kukla(2) type c,
end of itab.
INSTEAD OF
kunnr like kna1-kunnr,
ktokd like kna1-ktokd,
brsch like kna1-brsch,
kukla like kna1-kukla,
11-09-2007 7:00 PM
Hi Manjula,
your problem is in below statements.
insert zkna1.
modify zkna1.
do like this.
insert zkna1 from itab.
modify zkna1 from itab.
Hope your problem will get resolved.
Reward points if it helps,
Satish
11-12-2007 9:37 AM
hi satish,
Thank u so much.i used ur answer.it is worked now.thank u.
11-10-2007 5:36 AM
Hi
use that table to be modified by useing internal table
that statement will be like this
MODIFY <b>TABLE</b> FROM TABLE <b>ITAB</b>
because 1st ur storing the data in ITAB then u r passing that to table
use like this