文章目录
1 Instruction
In the PM, we need modify asset property and we will use FM ‘I_CHANGE_STATUS’ for it .
2 Demo
DATA : LT_INTAB TYPE ZTEQSTATUS ,
LW_INTAB TYPE ZSEQSTATUS .
DATA : LT_INTAB1 TYPE ZTEQSTATUS ,
LW_INTAB1 TYPE ZSEQSTATUS .
DATA : LT_ZTPMEAMLOG LIKE STANDARD TABLE OF ZTPMEAMLOG,
LW_ZTPMEAMLOG LIKE LINE OF LT_ZTPMEAMLOG .
TYPES: BEGIN OF TY_JEST ,
EQUNR TYPE EQUI-EQUNR ,
OBJNR TYPE JEST-OBJNR ,
STAT TYPE JEST-STAT ,
END OF TY_JEST .
DATA :
LW_JEST TYPE TY_JEST ,
LT_JEST TYPE STANDARD TABLE OF TY_JEST.
IF IN_TAB[] IS NOT INITIAL.
LT_INTAB[] = IN_TAB[].
ELSE .
MSGTY = 'E'.
MSGTX = '请输入设备号和输入更新状态'.
EXIT .
ENDIF.
CLEAR :LT_ZTPMEAMLOG[] , LW_ZTPMEAMLOG .
LOOP AT LT_INTAB INTO LW_INTAB .
IF LW_INTAB-EQUNR IS INITIAL.
MSGTY = 'E'.
MSGTX = '请输入设备号'.
EXIT.
ENDIF.
IF LW_INTAB-ESTAT_ACTIVE IS INITIAL.
MSGTY = 'E'.
MSGTX = '请输入更新状态'.
EXIT.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = LW_INTAB-EQUNR
IMPORTING
OUTPUT = LW_INTAB-EQUNR .
MOVE-CORRESPONDING LW_INTAB to LW_ZTPMEAMLOG .
MOVE-CORRESPONDING LW_INTAB to LW_INTAB1 .
APPEND LW_ZTPMEAMLOG TO LT_ZTPMEAMLOG .
APPEND LW_INTAB1 TO LT_INTAB1.
SELECT JEST~OBJNR JEST~STAT EQUI~EQUNR
INTO CORRESPONDING FIELDS OF TABLE LT_JEST
FROM JEST
INNER JOIN EQUI ON JEST~OBJNR = EQUI~OBJNR
WHERE EQUI~EQUNR = LW_INTAB-EQUNR AND JEST~INACT = '' .
CLEAR: LW_INTAB,LW_ZTPMEAMLOG.
ENDLOOP.
DELETE LT_JEST WHERE STAT(1) = 'I' .
CLEAR :LW_JEST , LW_INTAB1 .
LOOP AT LT_JEST[] INTO LW_JEST.
READ TABLE LT_INTAB1 INTO LW_INTAB1 WITH KEY EQUNR = LW_JEST-EQUNR .
IF SY-SUBRC = 0.
IF LW_JEST-STAT = LW_INTAB1-ESTAT_ACTIVE .
MSGTY = 'E'.
MSGTX = '更新的状态于现在的状态一样,请检查'.
EXIT.
ENDIF.
CALL FUNCTION 'I_CHANGE_STATUS'
EXPORTING
OBJNR = LW_JEST-OBJNR
ESTAT_INACTIVE = LW_JEST-STAT
ESTAT_ACTIVE = LW_INTAB1-ESTAT_ACTIVE
.
IF SY-SUBRC = 0.
LW_ZTPMEAMLOG-EQUNR = LW_JEST-EQUNR.
LW_ZTPMEAMLOG-ZMARK = 'S' .
MSGTY = 'S'.
CONCATENATE LW_JEST-EQUNR '状态已经更新为'LW_INTAB1-ESTAT_ACTIVE INTO MSGTX .
CONCATENATE LW_JEST-EQUNR '状态已经更新为'LW_INTAB1-ESTAT_ACTIVE INTO LW_ZTPMEAMLOG-ZMESSAGE .
LW_ZTPMEAMLOG-DATUM = SY-DATUM.
LW_ZTPMEAMLOG-ZSYUZEIT = SY-UZEIT.
APPEND LW_ZTPMEAMLOG TO LT_ZTPMEAMLOG .
ELSE.
LW_ZTPMEAMLOG-EQUNR = LW_JEST-EQUNR.
LW_ZTPMEAMLOG-ZMARK = 'E' .
MSGTY = 'E'.
CONCATENATE LW_JEST-EQUNR '状态更新失败为'LW_INTAB1-ESTAT_ACTIVE '请检查' INTO MSGTX .
LW_ZTPMEAMLOG-DATUM = SY-DATUM.
CONCATENATE LW_JEST-EQUNR '状态更新失败为'LW_INTAB1-ESTAT_ACTIVE '请检查' INTO LW_ZTPMEAMLOG-ZMESSAGE .
LW_ZTPMEAMLOG-ZSYUZEIT = SY-UZEIT.
APPEND LW_ZTPMEAMLOG TO LT_ZTPMEAMLOG .
ENDIF.
ENDIF .
ENDLOOP.
IF LT_ZTPMEAMLOG IS NOT INITIAL .
MODIFY ZTPMEAMLOG FROM TABLE LT_ZTPMEAMLOG[].
IF SY-SUBRC = 0.
COMMIT WORK .
ENDIF.
ENDIF.
CLEAR : LT_ZTPMEAMLOG[] .