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

Check successful entry table

Former Member
0 Likes
1,887

Good day!

Part of my assignment is to create a program that would transfer the values of a text file to a table in the database. So far, what I did was to first transfer it to an internal table which I will then transfer to a table in the database. I am almost done with this project but part of my assignment is not only insert the data into the respective fields of the table, but to also show the number of records successfully inserted and count those that were not successfully inserted. Is there any way to check this? Sorry for the noob question.

This is part of my code where I insert it to the table.

LOOP AT zpdpld_itab.

INSERT (p_tab) FROM zpdpld_itab.

ENDLOOP.

ptab containes the table name

while zpdpld_itab is my internal table containing the values.

1 ACCEPTED SOLUTION
Read only

former_member195383
Active Contributor
0 Likes
1,313

Declare a counter

data: wf_cnt type i.

clear : wf_cnt.

LOOP AT zpdpld_itab.

INSERT (p_tab) FROM zpdpld_itab.

if sy-subrc eq 0.

wf_cnt = wf_cnt + 1.

endif.

ENDLOOP.

at the end of loop wf_cnt will give u number of records successfully inserted...

Reward points if the above helps.

Declare a counter

data: wf_cnt type i.

clear : wf_cnt.

LOOP AT zpdpld_itab.

INSERT (p_tab) FROM zpdpld_itab.

if sy-subrc eq 0.

wf_cnt = wf_cnt + 1.

endif.

ENDLOOP.

at the end of loop wf_cnt will give u number of records successfully inserted...

Reward points if the above helps.

6 REPLIES 6
Read only

former_member195383
Active Contributor
0 Likes
1,314

Declare a counter

data: wf_cnt type i.

clear : wf_cnt.

LOOP AT zpdpld_itab.

INSERT (p_tab) FROM zpdpld_itab.

if sy-subrc eq 0.

wf_cnt = wf_cnt + 1.

endif.

ENDLOOP.

at the end of loop wf_cnt will give u number of records successfully inserted...

Reward points if the above helps.

Read only

Former Member
0 Likes
1,313

Hi,

NO need for Loop...endloop...

INSERT (p_tab) FROM table zpdpld_itab.

if sy-subrc = 0.

write:/ sy-dbcnt, 'records inserted'.

endif.

Sy-dbcnt contains the no. of records inserted.

Regards,

Subramanian

Read only

nikhil_chitre
Active Participant
0 Likes
1,313

Hi,

After your Insert comand.

Check

If sy-subrc = 0.

L_count = L_count + 1.

you'll have the number of records inserted in varible l_count.

Regards,

Nikhil

Read only

Former Member
0 Likes
1,313

Thank you for the quick reply!

Points awarded.

Read only

Former Member
0 Likes
1,313

Try this:

LOOP AT zpdpld_itab.

INSERT (p_tab) FROM zpdpld_itab.

if sy-subrc = 0.

move-corresponding records to table it_messages.

else.

move-corresponding records to table it_messages.

ENDLOOP.

Loop at messages.

write:........

endloop.

In it_messages collect all entries.For the entries which are successfully inserted i.e. SY-subrc is 0 show green traffic light and for failed entries show red light.You can find the lights in table ICON.

Reward if useful.

Read only

Former Member
0 Likes
1,313

Hi Katrina,

You can define a variable of type i , Which will hold the count of records inserted into the Ztable.

data: V_COUNT TYPE I value '0'.

LOOP AT zpdpld_itab.

INSERT (p_tab) FROM zpdpld_itab.

if sy-subrc = 0.

V_COUNT = V_COUNT + 1.

endif.

ENDLOOP.

I hope this will help you.