2013 May 13 6:36 AM
Hi,
I want the current Order Status(Release OR Lock) from Sales Order Header(Object Status) while saving the Order in Exit USEREXIT_SAVE_DOCUMENT.
Is there anyway to get the status.
Developers Plz help,
Thanks,
2013 May 13 7:55 AM
2013 May 13 7:55 AM
2013 May 13 8:02 AM
For example
CALL FUNCTION 'STATUS_READ'
EXPORTING
client = sy-mandt
objnr = iv_objnr "VBAK-OBJNR
only_active = iv_only_active
TABLES
status = lt_stat
EXCEPTIONS
object_not_found = 1
OTHERS = 2.
LOOP AT lt_stat INTO ls_stat.
IF ls_stat-STAT = 'I0002'.
ls_aufnr-released = abap_true.
ENDIF.
IF ls_stat-STAT = 'E0018'.
ls_aufnr-locked = abap_true.
ENDIF.
ENDLOOP.
2013 May 13 8:26 AM
Hi Narendra,
Try like below.
CHECK t180-trtyp EQ 'H' " Only at create
AND t180-trvog = '0'. " Only for sales orders
DATA : ld_stsma TYPE j_stsma.
DATA : ld_estat TYPE j_estat.
DATA : ld_objnr TYPE j_objnr.
DATA : ld_esta(4) TYPE c VALUE 'ESTA'.
DATA: BEGIN OF jest_mem OCCURS 1000. "Einzelstatus-Puffer
INCLUDE STRUCTURE jest_upd.
DATA: mod,
inact_old LIKE jest-inact.
DATA: END OF jest_mem.
IMPORT ld_estat TO ld_estat FROM MEMORY ID 'Z_ESTA'.
CHECK sy-subrc IS INITIAL
AND NOT ld_estat IS INITIAL.
FREE MEMORY ID 'Z_ESTA'.
SELECT SINGLE stsma FROM tvak
INTO ld_stsma
WHERE auart = vbak-auart.
CHECK sy-subrc IS INITIAL. " Disregard order types without status
SELECT SINGLE estat FROM tj30t
INTO ld_estat
WHERE stsma = ld_stsma
AND txt04 = ld_esta
AND spras = 'E'.
CHECK sy-subrc IS INITIAL. " Disregard status profiles without ESTA
CALL FUNCTION 'STATUS_BUFFER_EXPORT_TO_MEMORY'
EXPORTING
i_memory_id = 'Z_BSVA_VBK_STATUS'
EXCEPTIONS
OTHERS = 1.
IMPORT jest_buf TO jest_mem
FROM MEMORY ID 'Z_BSVA_VBK_STATUS'.
FREE MEMORY ID 'Z_BSVA_VBK_STATUS'.
IF NOT jest_mem[] IS INITIAL.
READ TABLE jest_mem
WITH KEY stat = 'E0007'.
CHECK sy-subrc IS INITIAL.
jest_mem-stat = ld_esta.
APPEND jest_mem.
ld_objnr = jest_mem-objnr.
CALL FUNCTION 'STATUS_CHANGE_EXTERN'
EXPORTING
client = sy-mandt
objnr = ld_objnr
user_status = ld_estat
EXCEPTIONS
object_not_found = 1
status_inconsistent = 2
status_not_allowed = 3
OTHERS = 4.
ENDIF.
This is called in MV45AFZZ, USEREXIT_MOVE_FIELD_TO_VBAK.
As I need this only when the sales order is created with reference to a contract, and only if the contract has a specific status, I have more logic in the contract/SO copy routine, which eventually do the memory export. As USEREXIT_MOVE_FIELD_TO_VBAK is called a lot in VA01/VA02, I clear the memory ID to ensure logic is only processed once.
As you see, the real trick is the FM, 'STATUS_BUFFER_EXPORT_TO_MEMORY' which enables me to get a list of the current nonsaved statuses.
2013 May 13 8:33 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |