Skip to Content
0
Jan 27, 2023 at 10:53 AM

Customer exit variable with multiple input conditions

132 Views Last edit Jan 27, 2023 at 10:56 AM 3 rev

Hello, gurus!

I have the following task: when the user starts the query, he fills in the prompt selected date and list of materials. The query should return all of the materials from the filter with their lowest price for the period between the chosen date and 30 days ago from it.

I created two customer exit variables for the dates - one to get the selected date and another to calculate the date 30 days ago. I am using them as parameters in another CE which have to return the right price condition number.

I came with this code, but I am not very good at ABAP and it doesn't work properly. Right now it runs without errors and returns nothing. If I remove the initial check at the end the result is multiple # rows, which makes me think the list of materials is not loading properly into the variables. I tried to debug it but I am even worst in debugging and could understand a thing in the debugger.

I've checked the date CEs and they return correct results. Also I am sure I use valid data when testing (the test materials have price conditions in the selected period).


      WHEN 'ZCE_LOWEST_PRICE_LAST_30_DAYS'.
*"Variable to show the lowest price for 30 days before selected date"*
*" "*

IF i_step = 2.
READ TABLE i_t_var_range INTO l_s_var_range WITH KEY vnam = 'ZCE_SELECTED_DATE'.
date_temp = l_s_var_range-low.
c_year = date_temp(4).
c_month = date_temp+4(2).
c_day = date_temp+6(2).
CONCATENATE p_year c_month c_day INTO date_new.

clear l_s_var_range.

READ TABLE i_t_var_range INTO l_s_var_range WITH KEY vnam = 'ZCE_30_DAYS_FROM_SEL_DATE_2'.
date_temp = l_s_var_range-low.
c_year = date_temp(4).
c_month = date_temp+4(2).
c_day = date_temp+6(2).
CONCATENATE p_year c_month c_day INTO date_new_2.

clear l_s_var_range.

READ TABLE i_t_var_range ASSIGNING FIELD-SYMBOL(<fs_material>) WITH KEY vnam = '0S_MATL'.

SELECT MATERIAL FROM /BIC/AZPMM011100 INTO CORRESPONDING FIELDS OF TABLE it_mat_list
WHERE MATERIAL = <fs_material>-low.

LOOP AT it_mat_list INTO wa_mat_list.
price = 1000000.

SELECT * FROM /BIC/AZPMM011100 INTO CORRESPONDING FIELDS OF TABLE it_last_30_days_conditions
WHERE DATETO GE date_new_2 AND
DATEFROM LE date_new AND
MATERIAL EQ wa_mat_list-material.

LOOP AT it_last_30_days_conditions INTO wa_last_30_days_conditions.
IF price > wa_last_30_days_conditions-AMOUNT.
price = wa_last_30_days_conditions-AMOUNT.
pr_cond = wa_last_30_days_conditions-/BIC/KNUMH.
ENDIF.
ENDLOOP.

IF NOT pr_cond IS INITIAL.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
l_s_range-low = pr_cond.
APPEND l_s_range TO e_t_range.
ENDIF.

ENDLOOP.
ENDIF. SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; }.L0S31 { font-style: italic; color: #808080; }.L0S32 { color: #3399FF; }.L0S33 { color: #4DA619; }.L0S52 { color: #0000FF; }.L0S55 { color: #800080; }.L0S70 { color: #808080; }