Skip to Content
0
Former Member
Mar 30, 2008 at 03:30 AM

Inserting records into Custom table

470 Views

Hi Friends,

I have created a custom table without table maintainence. I need to insert records into this custom table using abap coding only. When a run a download program an excel file is generated. from that excel file i have to summarise the data and upload the summary to Ztable.

Problem is am getting 3 records in summary but only one record is updated into Ztable. Some times total 3 records updated. i dont understand this strange behaviour.

FORM f_update_report_log.

  • Report log: sum of Document currency Amt & local currency Amt

  • for all document currency keys

SORT it_data BY waers.

LOOP AT it_data.

ON CHANGE OF it_data-waers.

IF sy-tabix NE 1.

zdmaplog-dmdate = sy-datum.

zdmaplog-dmtime = sy-uzeit.

zdmaplog-dmtyp = 'D'.

zdmaplog-sbukrs = p_bukrs.

zdmaplog-tbukrs = p_bukrst.

zdmaplog-items = v_lines.

zdmaplog-wrbtr = v_wrbtr.

zdmaplog-dwaers = v_waers.

zdmaplog-dmbtr = v_dmbtr.

zdmaplog-lwaers = 'SGD'.

zdmaplog-userid = sy-uname.

  • update db table zdmaplog

INSERT zdmaplog.

v_subrc = sy-subrc.

COMMIT WORK AND WAIT.

IF v_subrc NE 0.

WRITE: / v_waers, 'Zdmaplog not updated'.

ENDIF.

CLEAR: v_lines, v_wrbtr, v_dmbtr, v_subrc.

ENDIF.

ENDON.

v_waers = it_data-waers.

v_lines = v_lines + 1.

IF it_data-shkzg = 'H'. "credit

v_wrbtr = v_wrbtr - it_data-wrbtr.

v_dmbtr = v_dmbtr - it_data-dmbtr.

ELSEIF it_data-shkzg = 'S'. "Debit

v_wrbtr = v_wrbtr + it_data-wrbtr.

v_dmbtr = v_dmbtr + it_data-dmbtr.

ENDIF.

ENDLOOP.

  • update DB table zdmaplog

zdmaplog-dmdate = sy-datum.

zdmaplog-dmtime = sy-uzeit.

zdmaplog-dmtyp = 'D'.

zdmaplog-sbukrs = p_bukrs.

zdmaplog-tbukrs = p_bukrst.

zdmaplog-items = v_lines.

zdmaplog-wrbtr = v_wrbtr.

zdmaplog-dwaers = v_waers.

zdmaplog-dmbtr = v_dmbtr.

zdmaplog-lwaers = 'SGD'.

zdmaplog-userid = sy-uname.

INSERT zdmaplog.

v_subrc = sy-subrc.

COMMIT WORK AND WAIT.

IF v_subrc NE 0.

WRITE: / v_waers, 'Zdmaplog not updated'.

ENDIF.

ENDFORM. " f_report_log

Its urgent, please help me. i wil reward good points.