2008 Jun 27 6:18 AM
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.
2008 Jun 27 6:21 AM
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.
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.
2008 Jun 27 6:21 AM
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.
2008 Jun 27 6:22 AM
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
2008 Jun 27 6:23 AM
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
2008 Jun 27 6:24 AM
2008 Jun 27 6:24 AM
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.
2008 Jun 27 6:28 AM
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.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |