Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Update/Replace table AGR_1252

Former Member
0 Kudos

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,

3 REPLIES 3

Former Member
0 Kudos

Hello,

Please guide for this query ?

Regards,

Sandra_Rossi
Active Contributor
0 Kudos

What are you asking exactly?

IF t_itab-field5 eq '*'.
...
ELSEIF t_itab-field5 ne '*'.

is the same as

IF t_itab-field5 eq '*'.
...
ELSE

Why shouldn't it work?

Former Member
0 Kudos

hello,

My IF t_itab-field5 eq '*'. part is for replacing AGR_1252 table for ORGLEVEL low value.

and

Elseif

will update(add) new value

But in my above code when I upload the excel with * and low value to be replaced, it replaces the current role for orglevel low value with new value and then it also adds the new record.

Meaning in one go if and elseif condition us being executing.

Regards,