Dear experts,
I am currently working on an inserting records program.
Before the record is inserted into a table. It will perform a SELECT query to get the latest running number. My problem here is the COUNTER field in the table is designed in CHAR11.
With the SELECT statement showing below, it will hits a problem when the running number increased to 10. The select statement will not getting the latest number - 10. It will always getting number - 9. It is because it is descending order 10 is considering 1.
Here is my program :
SELECT charg counter FROM ztable_test UP TO 1 ROWS INTO (lf_charg, lv_counter) WHERE charg EQ ls_table-charg AND minch EQ ls_table-minch AND ccod1 EQ ls_table-ccod1 ORDER BY counter DESCENDING. ENDSELECT. IF sy-subrc EQ 0. ls_osada-counter = lv_counter + 1. INSERT ztspp_osada2 FROM ls_osada. EXIT. ENDIF.
I remember in either DB2 or Oracle, the select statement can be like this:
SELECT charg, INT(counter) FROM ztable_test WHERE charg = ls_table-charg AND minch = ls_table-minch AND ccod1= ls_table-ccod1 ORDER BY INT(counter) DESCENDING.
How should I do it in ABAP?
I would really appreciate if someone can help me on this.
Sample of code would greatly appreciated.
Thanks in advance.