Application Development 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: 

INSERT statement not inserting into Ztable

Bema
Active Participant
0 Kudos

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.

14 REPLIES 14

former_member218674
Contributor
0 Kudos

Hello Beena,

Try following way:



INSERT INTO ztable VALUES wa_table.

Thanks,

Augustin.

Former Member
0 Kudos

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

Former Member
0 Kudos

May be due to similar key values .

If values of primary keys are same , Insert will not work .

HOpe it helps you.

Former Member
0 Kudos

May be due to similar key values .

If values of primary keys are same , Insert will not work .

HOpe it helps you.

0 Kudos

Harsh,

If it was due duplicate data recorrd then the iDOC 51 would be tiggered !

Former Member
0 Kudos

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

0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

U can use a DELETE statement. I use it in a development of mine, and it works.

😕