728x90
반응형
BAPI_SALESORDER_CHANGE
FORM DELETE_SALES_ORDER .
DATA: LV_ANSWER,
LV_ERROR.
DATA: LS_HEADER TYPE BAPISDH1,
LS_HEADERX TYPE BAPISDH1X,
LT_ITEMS TYPE TABLE OF BAPISDITM WITH HEADER LINE,
LT_ITEMSX TYPE TABLE OF BAPISDITMX WITH HEADER LINE,
LT_RETURN TYPE TABLE OF BAPIRET2 WITH HEADER LINE.
DATA: LT_RETURN2 TYPE TABLE OF BAPIRET2 WITH HEADER LINE.
DATA: BEGIN OF LT_SO_KEY OCCURS 0,
VBELN TYPE VBAK-VBELN,
END OF LT_SO_KEY.
DATA: LT_ROWS TYPE LVC_T_ROW,
LS_ROW TYPE LVC_S_ROW.
"선택된 ROW ID를 추출한다.
CALL METHOD GR_GRID->GET_SELECTED_ROWS
IMPORTING
ET_INDEX_ROWS = LT_ROWS.
IF LT_ROWS[] IS INITIAL.
MESSAGE S001 WITH TEXT-E04 DISPLAY LIKE 'E'.
" 선택된 라인이 없습니다.
EXIT.
ENDIF.
LOOP AT LT_ROWS INTO LS_ROW.
READ TABLE GT_ITAB INDEX LS_ROW-INDEX.
CHECK SY-SUBRC = 0.
CLEAR LT_SO_KEY.
LT_SO_KEY-VBELN = GT_ITAB-VBELN.
COLLECT LT_SO_KEY.
ENDLOOP.
LOOP AT LT_SO_KEY.
CLEAR LS_HEADERX.
LS_HEADERX-UPDATEFLAG ='D'.
CLEAR: LT_RETURN[].
CLEAR: LT_ITEMS[], LT_ITEMSX[].
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = LT_SO_KEY-VBELN
ORDER_HEADER_IN = LS_HEADER
ORDER_HEADER_INX = LS_HEADERX
TABLES
RETURN = LT_RETURN
ORDER_ITEM_IN = LT_ITEMS
ORDER_ITEM_INX = LT_ITEMSX.
CLEAR: LT_RETURN2, LV_ERROR.
LOOP AT LT_RETURN.
CASE LT_RETURN-TYPE.
WHEN 'E' OR 'A' OR 'X'.
LV_ERROR = GC_TRUE.
MOVE-CORRESPONDING LT_RETURN TO LT_RETURN2. "result msg collect
LT_RETURN2-MESSAGE_V2 = LT_SO_KEY-VBELN.
APPEND LT_RETURN2.
WHEN OTHERS.
ENDCASE.
ENDLOOP.
IF LV_ERROR = SPACE.
DELETE GT_ITAB WHERE VBELN = LT_SO_KEY-VBELN.
ENDIF.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
ENDLOOP.
LOOP AT GT_ITAB.
READ TABLE LT_RETURN2 WITH KEY MESSAGE_V2 = GT_ITAB-VBELN.
IF SY-SUBRC = 0.
GT_ITAB-ZTEXT = LT_RETURN2-MESSAGE.
GT_ITAB-UPDKZ = '@0A@'.
MODIFY GT_ITAB.
ENDIF.
ENDLOOP.
728x90
반응형
'ABAP' 카테고리의 다른 글
Text editor object (0) | 2023.03.02 |
---|---|
[ALV] ALV + Hotspot Event (0) | 2023.03.02 |
Pop-up Message (POPUP_TO_CONFIRM) (0) | 2023.03.01 |
[Smartform] (0) | 2023.03.01 |
데이터 갱신시 특수문자 제거 (0) | 2023.03.01 |
댓글