Skip to Content
0
Former Member
Apr 15, 2013 at 06:08 AM

Displaying records which include amounts less than 0.

27 Views

Hi Experts,

I need to fetch records that have amounts less than 0 to be displayed as 0.

Appending is the code which I need your help with.

Urgent guidance would be appreciated.

IF not it_erdk[] is INITIAL.
* SELECT opbel
* faedn
* bldat
* budat
* total_amnt
* vkont
* erdat
* creation_time
* FROM erdk
* INTO CORRESPONDING FIELDS OF TABLE it_erdk
* FOR ALL ENTRIES IN it_vkont
* WHERE vkont = it_vkont-vkont
* AND budat IN s_invdt
* AND stokz = space
* AND intopbel = space
* AND simulated = space
* AND verart NE 'RE'
* AND abrvorg ne '06'. " added by Aditya on 19.10.10

IF sy-subrc = 0.
SORT it_erdk BY vkont ASCENDING
erdat DESCENDING
creation_time DESCENDING.
* SORT it_vkont BY vkont.

LOOP AT it_erdk ASSIGNING <fs_erdk>.
AT NEW vkont.
IF <fs_erdk>-total_amnt LT 0.
* DELETE it_erdk INDEX sy-tabix.
ELSE.
APPEND INITIAL LINE TO it_file ASSIGNING <fs_file>.
IF <fs_file> IS ASSIGNED.
<fs_file>-vkont = <fs_erdk>-vkont.
<fs_file>-opbel = <fs_erdk>-opbel.
<fs_file>-total_amnt = <fs_erdk>-total_amnt * 100.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = <fs_file>-total_amnt
IMPORTING
output = <fs_file>-total_amnt.

* READ TABLE it_vkont ASSIGNING <fs_vkont>
* WITH KEY vkont = <fs_erdk>-vkont
* BINARY SEARCH.
* IF sy-subrc = 0.
* IF <fs_vkont>-vkona IS NOT INITIAL.
* <fs_file>-vkona = <fs_vkont>-vkona.
* CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
* EXPORTING
* input = <fs_file>-vkona
* IMPORTING
* output = <fs_file>-vkona.
* ELSE.
* <fs_file>-vkona = '000000000000'.
* ENDIF.
* ENDIF.

IF <fs_erdk>-vkona IS NOT INITIAL.
<fs_file>-vkona = <fs_erdk>-vkona.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = <fs_file>-vkona
IMPORTING
output = <fs_file>-vkona.
ELSE.
<fs_file>-vkona = '000000000000'.
ENDIF.

CONCATENATE <fs_erdk>-budat+6(2)
<fs_erdk>-budat+4(2)
<fs_erdk>-budat+2(4)
INTO <fs_file>-budat.

CONCATENATE <fs_erdk>-faedn+6(2)
<fs_erdk>-faedn+4(2)
<fs_erdk>-faedn+2(4)
INTO <fs_file>-faedn.
UNASSIGN <fs_file>.
ENDIF.
ENDIF.
CONTINUE.
ENDAT.
DELETE it_erdk INDEX sy-tabix.
ENDLOOP.
DELETE it_erdk WHERE total_amnt LT 0.

rgds

Mazal