08-28-2009 9:31 AM
Hi ,
Find below the piece of code that I have writtend to update a Z table. This code is inside an inbound function module.
We have an issue that it didn't insert the record in the Ztable but it set the status of idoc as 53(successful) . Anybody have any idea. Appreciate your help.
INSERT ztable FROM wa_table.
IF sy-subrc = 0.
COMMIT WORK.
l_subrc = 0.
ELSE.
ROLLBACK WORK.
l_subrc = 4.
ENDIF.
IF l_subrc = 4.
PERFORM change_idoc_status USING
idoc_contrl-docnum '51' 'E'
'Insertion into table' 'ZTABLE failed' 'Duplicate keys'
CHANGING idoc_status.
APPEND idoc_status.
ELSE.
PERFORM change_idoc_status USING
idoc_contrl-docnum '53' 'I'
'Successfully' 'Inserted into table' 'ZTABLE'
CHANGING idoc_status.
APPEND idoc_status.
ENDIF.
08-28-2009 9:38 AM
Hello Beena,
Try following way:
INSERT INTO ztable VALUES wa_table.
Thanks,
Augustin.
08-28-2009 9:42 AM
Hi Beena,
Are you sure wa_table refers to ztable structure ?
Why do you say it isn't inserted in db : looking in SE16, or testing in abap ?
KR,
Laurent
08-28-2009 9:47 AM
May be due to similar key values .
If values of primary keys are same , Insert will not work .
HOpe it helps you.
08-28-2009 9:47 AM
May be due to similar key values .
If values of primary keys are same , Insert will not work .
HOpe it helps you.
08-28-2009 10:10 AM
Harsh,
If it was due duplicate data recorrd then the iDOC 51 would be tiggered !
08-28-2009 10:18 AM
Hi,
To insert an entry into a ZTABLE, you cannot make use of INSERT statement. INSERT statements can be used only in case of internal tables used within a program.
Your problem will definitely be resolved by the Usage of MODIFY statements.
Eg: MODIFY zca0_constant FROM wa_constant.
Thanks,
Asha
08-28-2009 10:39 AM
Aha,
You are WRONG !!!
You can use MODIFY if you want to get rid of a SELECT FOR UPDATE, but INSERT is the correct statement to INSERT a record in a database.
08-28-2009 10:45 AM
Thanks Dier, i checked the same now.
But Beena, Just try using Modify statement. I have used the same many times and it worked. Hope it works for u too.
Thanks,
Asha
08-28-2009 11:39 AM
Hi,
here is the piece of code just check this out....
IF NOT it_hrsemp[] IS INITIAL.
DESCRIBE TABLE it_hrsemp LINES v_line1 .
**inserting records in ztable
INSERT zhr_eq_oasis_act FROM TABLE it_hrsemp.
COMMIT WORK.
Thanks
Ashu
08-28-2009 11:39 AM
Hi,
here is the piece of code just check this out....
IF NOT it_hrsemp[] IS INITIAL.
DESCRIBE TABLE it_hrsemp LINES v_line1 .
**inserting records in ztable
INSERT zhr_eq_oasis_act FROM TABLE it_hrsemp.
COMMIT WORK.
Thanks
Ashu
08-28-2009 12:33 PM
Ashu> we do NOT deal with a MULTIPLE insert !
Everybody> please stop copy/pasting your piece of code, without any eplanation. Give explanation and/or solution.
08-28-2009 12:56 PM
Hi Praveen,
Instead of Insert stmt, you can use Modify Stmt
*Insert values into Database table Ztable
MODIFY Ztable FROM WA_area.
COMMIT WORK AND WAIT.
It may helpfull, In one of my developments, I face same problem with Insert Stmt. then I used Modify stmt, it worked.
Thanks
Sai
08-28-2009 12:57 PM
Hi Praveen,
Instead of Insert stmt, you can use Modify Stmt
*Insert values into Database table Ztable
MODIFY Ztable FROM WA_area.
COMMIT WORK AND WAIT.
It may helpfull, In one of my developments, I face same problem with Insert Stmt. then I used Modify stmt, it worked.
Thanks
Sai
08-28-2009 5:09 PM
U can use a DELETE statement. I use it in a development of mine, and it works.
😕