Skip to Content
-1
Former Member
Nov 17, 2016 at 06:50 AM

Update/Replace table AGR_1252

211 Views

Hello,

My excel file has below columns.

Role , Org level , Low , High , Replace , New

TEST_GOODS_MVMT_OUT_PROC , $EKORG , D400 , , * , D800

TEST_GOODS_MVMT_OUT_PROC , $EKORG , D300 , , * , D600

Existing value in low field will get replaced with value from New column field when there is *

But my code is replacing and creating new record in AGR_1252

FORM GET_AUTH.

CLEAR t_report.
t_report-agr_name = t_file_itab-role.

LOOP AT t_itab.
LOOP AT T_FILE_ITAB.

IF t_itab-field5 eq '*'.
UPDATE AGR_1252 SET: low = t_itab-field6
WHERE agr_name = t_itab-field1 AND varbl = t_itab-field2 AND low = t_itab-field3.

t_report-text = text-l03.
t_report-lights = '3'. "Green if successful
APPEND t_report.

ELSEIF t_itab-field5 ne '*'.

SELECT * INTO CORRESPONDING FIELDS OF TABLE IT_T_AGR_1252 FROM AGR_1252.

IF NOT IT_T_AGR_1252 IS INITIAL.
IF NOT T_FILE_ITAB IS INITIAL.

READ TABLE IT_T_AGR_1252 INTO WA_T_AGR_1252 WITH KEY AGR_NAME = T_FILE_ITAB-ROLE VARBL = T_FILE_ITAB-ORGLEVEL LOW = T_FILE_ITAB-LOW.
IF sy-subrc eq 0.
DELETE T_FILE_ITAB WHERE ROLE = T_FILE_ITAB-ROLE AND ORGLEVEL = T_FILE_ITAB-ORGLEVEL AND LOW = T_FILE_ITAB-LOW.
t_report-text = text-l05.
t_report-lights = '2'. "Yellow if same
APPEND t_report.
ENDIF.

ENDIF.
ENDIF.
ENDIF.

ENDLOOP.
ENDLOOP.

Please guide me why the elseif condition is not working properly.

Regards,