FIELD-SYMBOLS
: <FS_PR>
TYPE BAPIMEREQITEM
.
DATA : I_RETURN TYPE TABLE OF BAPIRET2 ,
K_PRITEMX LIKE BAPIMEREQITEM ,
I_PRITEM_GET TYPE TABLE OF BAPIMEREQITEM ,
I_PRITEM_GET_LINE LIKE LINE OF I_PRITEM_GET ,
I_PRITEMX TYPE BAPIMEREQITEMX OCCURS 0 ,
IS_PRITEMX TYPE BAPIMEREQITEMX ,
I_PRITEM TYPE TABLE OF BAPIMEREQITEMIMP ,
I_PRITEM_LINE LIKE LINE OF I_PRITEM ,
I_SERVICES TYPE TABLE OF BAPI_SRV_SERVICE_LINE ,
I_SERVICES_LINE LIKE LINE OF I_SERVICES ,
I_SERVICESX TYPE TABLE OF BAPI_SRV_SERVICE_LINEX ,
I_SERVICESX_LINE LIKE LINE OF I_SERVICESX ,
K_RETURN LIKE LINE OF I_RETURN ,
LV_TABIX LIKE SY -TABIX . "D10K969053
* Get pr details
CALL FUNCTION 'BAPI_PR_GETDETAIL'
EXPORTING
NUMBER = '0020000512'
SERVICES = 'X'
TABLES
RETURN = I_RETURN
PRITEM = I_PRITEM_GET
SERVICELINES = I_SERVICES .
IF SY -SUBRC = 0 .
LOOP AT I_PRITEM_GET INTO I_PRITEM_GET_LINE .
I_PRITEM_GET_LINE -CLOSED = 'X' .
I_PRITEM_GET_LINE -REQ_BLOCKED = '1' .
I_PRITEM_GET_LINE -REASON_BLOCKING = '尾量不需执行' .
* If pr is locked clear deletion indicator to unlock it.
MOVE-CORRESPONDING I_PRITEM_GET_LINE TO I_PRITEM_LINE .
IF I_PRITEM_LINE -DELETE_IND = 'L' .
CLEAR I_PRITEM_LINE -DELETE_IND .
ENDIF .
IS_PRITEMX -PREQ_ITEM = I_PRITEM_LINE -PREQ_ITEM .
* k_pritemx-delete_ind = 'X'.
IS_PRITEMX -PREQ_ITEMX = 'X' .
IS_PRITEMX -CLOSED = 'X' .
IS_PRITEMX -REQ_BLOCKED = 'X' .
IS_PRITEMX -REASON_BLOCKING = 'X' .
APPEND IS_PRITEMX TO I_PRITEMX .
CLEAR K_PRITEMX .
APPEND I_PRITEM_LINE TO I_PRITEM .
CLEAR I_PRITEM_LINE .
ENDLOOP .
CLEAR I_RETURN .
* Unlock pr
LOOP AT I_SERVICES INTO I_SERVICES_LINE WHERE DEL_IND <> 'X' .
LV_TABIX = SY -TABIX .
* i_services_line-GROSS_PRICE = '100'.
I_SERVICES_LINE -QUANTITY = '10' .
I_SERVICESX_LINE -DOC_ITEM = I_SERVICES_LINE -DOC_ITEM .
I_SERVICESX_LINE -OUTLINE = I_SERVICES_LINE -OUTLINE .
I_SERVICESX_LINE -GROSS_PRICE = 'X' .
I_SERVICESX_LINE -QUANTITY = 'X' .
APPEND I_SERVICESX_LINE TO I_SERVICESX .
* modify i_servicesx from i_servicesx_line index sy-tabix.
* In ORDER to set the price the deletion indicator must be cleared.
MODIFY I_SERVICES FROM I_SERVICES_LINE INDEX LV_TABIX .
CLEAR I_SERVICES_LINE -DEL_IND .
ENDLOOP .
CLEAR I_RETURN .
* Call bapi to change the gross price.
CALL FUNCTION 'BAPI_PR_CHANGE'
EXPORTING
NUMBER = '0020000512'
* PRHEADER =
* PRHEADERX =
* TESTRUN =
* IMPORTING
* PRHEADEREXP =
TABLES
RETURN = I_RETURN
PRITEM = I_PRITEM
PRITEMX = I_PRITEMX
SERVICELINES = I_SERVICES
SERVICELINESX = I_SERVICESX .
IF SY -SUBRC = 0 .
* Commit changes to the DB.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X' .
ENDIF .
ENDIF .
DATA : I_RETURN TYPE TABLE OF BAPIRET2 ,
K_PRITEMX LIKE BAPIMEREQITEM ,
I_PRITEM_GET TYPE TABLE OF BAPIMEREQITEM ,
I_PRITEM_GET_LINE LIKE LINE OF I_PRITEM_GET ,
I_PRITEMX TYPE BAPIMEREQITEMX OCCURS 0 ,
IS_PRITEMX TYPE BAPIMEREQITEMX ,
I_PRITEM TYPE TABLE OF BAPIMEREQITEMIMP ,
I_PRITEM_LINE LIKE LINE OF I_PRITEM ,
I_SERVICES TYPE TABLE OF BAPI_SRV_SERVICE_LINE ,
I_SERVICES_LINE LIKE LINE OF I_SERVICES ,
I_SERVICESX TYPE TABLE OF BAPI_SRV_SERVICE_LINEX ,
I_SERVICESX_LINE LIKE LINE OF I_SERVICESX ,
K_RETURN LIKE LINE OF I_RETURN ,
LV_TABIX LIKE SY -TABIX . "D10K969053
* Get pr details
CALL FUNCTION 'BAPI_PR_GETDETAIL'
EXPORTING
NUMBER = '0020000512'
SERVICES = 'X'
TABLES
RETURN = I_RETURN
PRITEM = I_PRITEM_GET
SERVICELINES = I_SERVICES .
IF SY -SUBRC = 0 .
LOOP AT I_PRITEM_GET INTO I_PRITEM_GET_LINE .
I_PRITEM_GET_LINE -CLOSED = 'X' .
I_PRITEM_GET_LINE -REQ_BLOCKED = '1' .
I_PRITEM_GET_LINE -REASON_BLOCKING = '尾量不需执行' .
* If pr is locked clear deletion indicator to unlock it.
MOVE-CORRESPONDING I_PRITEM_GET_LINE TO I_PRITEM_LINE .
IF I_PRITEM_LINE -DELETE_IND = 'L' .
CLEAR I_PRITEM_LINE -DELETE_IND .
ENDIF .
IS_PRITEMX -PREQ_ITEM = I_PRITEM_LINE -PREQ_ITEM .
* k_pritemx-delete_ind = 'X'.
IS_PRITEMX -PREQ_ITEMX = 'X' .
IS_PRITEMX -CLOSED = 'X' .
IS_PRITEMX -REQ_BLOCKED = 'X' .
IS_PRITEMX -REASON_BLOCKING = 'X' .
APPEND IS_PRITEMX TO I_PRITEMX .
CLEAR K_PRITEMX .
APPEND I_PRITEM_LINE TO I_PRITEM .
CLEAR I_PRITEM_LINE .
ENDLOOP .
CLEAR I_RETURN .
* Unlock pr
LOOP AT I_SERVICES INTO I_SERVICES_LINE WHERE DEL_IND <> 'X' .
LV_TABIX = SY -TABIX .
* i_services_line-GROSS_PRICE = '100'.
I_SERVICES_LINE -QUANTITY = '10' .
I_SERVICESX_LINE -DOC_ITEM = I_SERVICES_LINE -DOC_ITEM .
I_SERVICESX_LINE -OUTLINE = I_SERVICES_LINE -OUTLINE .
I_SERVICESX_LINE -GROSS_PRICE = 'X' .
I_SERVICESX_LINE -QUANTITY = 'X' .
APPEND I_SERVICESX_LINE TO I_SERVICESX .
* modify i_servicesx from i_servicesx_line index sy-tabix.
* In ORDER to set the price the deletion indicator must be cleared.
MODIFY I_SERVICES FROM I_SERVICES_LINE INDEX LV_TABIX .
CLEAR I_SERVICES_LINE -DEL_IND .
ENDLOOP .
CLEAR I_RETURN .
* Call bapi to change the gross price.
CALL FUNCTION 'BAPI_PR_CHANGE'
EXPORTING
NUMBER = '0020000512'
* PRHEADER =
* PRHEADERX =
* TESTRUN =
* IMPORTING
* PRHEADEREXP =
TABLES
RETURN = I_RETURN
PRITEM = I_PRITEM
PRITEMX = I_PRITEMX
SERVICELINES = I_SERVICES
SERVICELINESX = I_SERVICESX .
IF SY -SUBRC = 0 .
* Commit changes to the DB.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X' .
ENDIF .
ENDIF .