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

INSERT statement not inserting into Ztable

Bema
Active Participant
0 Likes
4,154

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
Read only

Former Member
0 Likes
2,340

Hello Beena,

Try following way:



INSERT INTO ztable VALUES wa_table.

Thanks,

Augustin.

Read only

Former Member
0 Likes
2,340

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

Read only

Former Member
0 Likes
2,340

May be due to similar key values .

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

HOpe it helps you.

Read only

Former Member
0 Likes
2,340

May be due to similar key values .

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

HOpe it helps you.

Read only

0 Likes
2,340

Harsh,

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

Read only

Former Member
0 Likes
2,340

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

Read only

0 Likes
2,340

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.

Read only

Former Member
0 Likes
2,340

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

Read only

Former Member
0 Likes
2,340

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

Read only

Former Member
0 Likes
2,340

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

Read only

0 Likes
2,340

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.

Read only

Former Member
0 Likes
2,340

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

Read only

Former Member
0 Likes
2,340

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

Read only

0 Likes
2,340

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

😕