Skip to Content
-1

Update/Replace table AGR_1252

Nov 17, 2016 at 06:50 AM

64

avatar image
Former Member

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,

10 |10000 characters needed characters left characters exceeded
Former Member

Hello,

Please guide for this query ?

Regards,

0

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?

0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

avatar image
Former Member Nov 18, 2016 at 08:57 AM
0

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,

Share
10 |10000 characters needed characters left characters exceeded