2007 May 15 5:09 AM
Hi all,
senario is : I have a screen where my screen input fields are linked to dictionary fields ,i'm takin the data from screen to two itabs by following statements:
WHEN 'SAVE'.
move zmm_truck_txn to itab1.
move zmm_po_alloc to itab2.
and then inserting the records by following statements:
INSERT zmm_truck_txn
FROM TABLE itab1
ACCEPTING DUPLICATE KEYS.
if sy-subrc = 0.
commit work.
endif.
INSERT zmm_po_alloc
FROM TABLE itab2
ACCEPTING DUPLICATE KEYS.
if sy-subrc = 0.
commit work.
endif.
endcase.
AND MY RECORDS ARE NOT GETTING INSERTED.
ANY IDEA ANY ONE???
thanks and regards,
sachin soni
2007 May 15 6:09 AM
your insert statement is expecting the source to be in TABLES but you have only moved the values to the table headers, not the tables themselves.
Either change your insert to be from the varaibles rather than tables,
eg,
INSERT zmm_truck_txn
FROM itab1
.
or change the population so that you are adding entries to the tables:
move zmm_truck_txn to itab1.
append itab1.
move zmm_po_alloc to itab2.
append itab2.
Hi all,
senario is : I have a screen where my screen input fields are linked to dictionary fields ,i'm takin the data from screen to two itabs by following statements:
WHEN 'SAVE'.
move zmm_truck_txn to itab1.
move zmm_po_alloc to itab2.
and then inserting the records by following statements:
INSERT zmm_truck_txn
FROM TABLE itab1
ACCEPTING DUPLICATE KEYS.
if sy-subrc = 0.
commit work.
endif.
INSERT zmm_po_alloc
FROM TABLE itab2
ACCEPTING DUPLICATE KEYS.
if sy-subrc = 0.
commit work.
endif.
endcase.
AND MY RECORDS ARE NOT GETTING INSERTED.
ANY IDEA ANY ONE???
thanks and regards,
sachin soni
2007 May 15 5:20 AM
What's the structure and definition of itab1 and itab2?
What is the reason for using ACCEPTING DUPLICATE KEYS addition? Do you know the implication of this?
What's the return code (sy-subrc) after the INSERT statements?
2007 May 15 5:58 AM
itab1 is like a ztable zmm_truck_txn
and itab2 is like zmm_po_alloc
the reason for using ACCEPTING DUPLICATE KEYS addition :
so that it accepts duplicate keys.
return code after insert = 0
regards,
sachin
2007 May 15 6:15 AM
hi user,
you can use
MODIFY in place of INSERT.
i.e.
MODIFY ITAB FROM WA.
CLEAR WA.
2007 May 15 6:43 AM
2007 May 15 6:51 AM
hI sACHIN,
PLS SHOW US THE CURRENT CODE AND THE DECLARATIONS OF THE VARIABLES YOU ARE USING.
2007 May 15 6:53 AM
first check whether your itab contains any value or not?
then i check whether you are trying to insert duplicate key value or not ? if it is so then you can not do that ACCEPTING DUPLICATE KEYS is only to avoid the errors if you are trying to insert duplicate keys but it will not update the records in the database...
regards
shiba dutta
2007 May 15 7:19 AM
hi ,
here is the declaration :
&----
*& Include ZSSTOP Module pool ZSS_SAMPLE1
*&
&----
PROGRAM ZSS_SAMPLE1 MESSAGE-ID ZSS_MSG.
TABLES: zmm_truck_txn,zmm_po_alloc.
*DATA Begin of itab occurs 0.
*DATA include structure zmm_truck_txn.
*DATA include structure zmm_po_alloc.
*DATA End of itab.
DATA itab1 like zmm_truck_txn.
DATA itab2 like zmm_po_alloc.
data : okcode like sy-ucomm.
WHEN 'SAVE'.
move zmm_truck_txn to itab1.
move zmm_po_alloc to itab2.
If itab1 is not initial.
INSERT zmm_truck_txn
FROM itab1.
endif.
If itab2 is not initial.
INSERT zmm_po_alloc
FROM itab2.
endif.
if sy-subrc = 0.
commit work.
message s002.
endif.
2007 May 15 7:24 AM
depending on what the key values are the INSERT will not work if an entry with the same key fields already exists.
Somebody else already suggested you change the INSERT to a MODIFY. This does an INSERT or an UPDATE depending on if the record already exists.
If itab1 is not initial.
MODIFY zmm_truck_txn
FROM itab1.
endif.
If itab2 is not initial.
MODIFY zmm_po_alloc
FROM itab2.
endif.
2007 May 15 7:55 AM
the seen is now the records are gettin inserted in zmm_truck_txn but not in zmm_po_alloc.
regards
sachin soni
2007 May 16 12:22 AM
IN DEBUG CAN YOU SEE IF ITAB2 HAS ANY VALUES BEFORE IT INSERTS TO zmm_po_alloc?
If it does have values and gives 0 sy-subrc after the modify I can't think what the problem is.
2007 May 15 5:22 AM
hi soni,
u can use like this
insert statement can insert record from workarea to internal table and in our query no destination is mentioned [target place for inserting the record]
INSERT zmm_truck_txn
FROM TABLE itab1
ACCEPTING DUPLICATE KEYS.
into [destination table]
if sy-subrc = 0.
commit work.
endif.
INSERT zmm_po_alloc
FROM TABLE itab2
ACCEPTING DUPLICATE KEYS
into [destination table].
if sy-subrc = 0.
commit work.
endif.
reward points if helpful.
with regards,
suresh babu aluri.
2007 May 15 6:02 AM
and suresh !,i think your query is not correct because target is in the begining.
thx
2007 May 15 5:57 AM
hi Sachin ..
I have sample code which may solve your problem. Here it is.
In report code is like this.
<b>controls:
c_spfli type tableview using screen '1400',
c_sflight type tableview using screen '1400'.
data:
w_ucomm type sy-ucomm.
data:
begin of fs_spfli.
include structure spfli.
data end of fs_spfli.
data:
begin of fs_sflight.
include structure sflight.
data end of fs_sflight.
data:
t_spfli like
standard table
of fs_spfli.
data:
t_sflight like
standard table
of fs_sflight.
call screen 1400.
&----
*& Module STATUS_1400 OUTPUT
&----
text
----
module STATUS_1400 output.
SET PF-STATUS 'YH634_STATUS'.
SET TITLEBAR 'xxx'.
endmodule. " STATUS_1400 OUTPUT
&----
*& Module exit_1400 INPUT
&----
text
----
module exit_1400 input.
leave program.
endmodule. " exit_1400 INPUT
&----
*& Module USER_COMMAND_1400 INPUT
&----
text
----
module USER_COMMAND_1400 input.
case w_ucomm.
when 'SAVE'.
INSERT yh634_spfli
FROM TABLE t_spfli
ACCEPTING DUPLICATE KEYS.
INSERT yh634_sflight
FROM TABLE t_sflight
ACCEPTING DUPLICATE KEYS.
endcase.
endmodule. " USER_COMMAND_1400 INPUT
&----
*& Module sflight_1400 INPUT
&----
text
----
module sflight_1400 input.
append fs_sflight to t_sflight.
endmodule. " sflight_1400 INPUT
&----
*& Module spfli_1400 INPUT
&----
text
----
module spfli_1400 input.
append fs_spfli to t_spfli.
endmodule. " spfli_1400 INPUT</b>
And in dialog screen i have following code
<b>MODULE STATUS_1400.
loop at t_spfli into fs_spfli with control c_spfli.
endloop.
loop at t_sflight into fs_sflight with control c_sflight.
endloop.
*
PROCESS AFTER INPUT.
loop at t_spfli.
module spfli_1400.
endloop.
loop at t_sflight.
module sflight_1400.
endloop.
module exit_1400 at exit-command.
MODULE USER_COMMAND_1400.</b>
i have defined two table controls for the t_spfli and t_sflight.
It is working fine.
give a Push button for save and function code <b>'SAVE'</b>.
REGARDS,
VEERESH
2007 May 15 6:04 AM
hi sachin,
just try this code,
first of all your ztable structure and itab structure should be same,
then u can fill your itabs accordingley,
then your code should be as follows,
IF <itab> IS NOT INITIAL.
INSERT <ztable> FROM TABLE <itab>.
ENDIF.
IF <itab1>IS NOT INITIAL.
INSERT <ztable1>FROM TABLE <itab1>.
ENDIF.
if sy-subrc eq 0.
MESSAGE s002(Records are inserted into <ztable>) WITH lv_po.
regards...
seshu.
2007 May 15 6:09 AM
your insert statement is expecting the source to be in TABLES but you have only moved the values to the table headers, not the tables themselves.
Either change your insert to be from the varaibles rather than tables,
eg,
INSERT zmm_truck_txn
FROM itab1
.
or change the population so that you are adding entries to the tables:
move zmm_truck_txn to itab1.
append itab1.
move zmm_po_alloc to itab2.
append itab2.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |