cancel
Showing results for 
Search instead for 
Did you mean: 

User Exit : Auto Release Sub orders

former_member245085
Participant
0 Kudos

Hello Gurus,

I want to automatically Release the sub orders when superior order is Release.

After I wrote to SCN, I came to know that In Standard, There is no provision to auto release or auto TECO or auto Business completion of Sub Orders based on Superior Order business transaction.


Can some one please correct the exit & condition I selected


On exit IWO10009 when saving the superior order


IF sy-tcode = 'IW32'.

SELECT AUFNR

FROM AFKO

WHERE MAUFNR = caufvd_imp-AUFNR

release_order = 'X'.

ENDIF.

If above exit is incorrect,Can I use Exit IWO10002

If above exit is correct,Can I same to auto Business complete the Sub Orders when Superior Order CLSD


Thanks in Advance


Ashok  M

Accepted Solutions (1)

Accepted Solutions (1)

jogeswararao_kavala
Active Contributor
0 Kudos

Ashok,

I feel it is not IWO10002  but we need to try with User Exit for IWO10009 for your task. I'm unable to test the solution for you at present.

Clues are:

You need to use Function Module STATUS_CHANGE_INTERN in the Exit coding. The logic would be, when you release the Main Order and Save, system checks the System Status of Main Order, i.e., field CAUFVD_IMP-IPHAS.   '2' is the value for REL status.


So the code will be like:

*----------------------------------------------------------------------------------


If CAUFVD_IMP-IPHAS = '2' .

CALL FUNCTION 'STATUS_CHANGE_INTERN'

......................

......................

......................

ENDIF.


COMMIT WORK.


*----------------------------------------------------------------------------------

In this FM, you will be passing the OBJNR value of SubOrder no. (get from AUFK table) and target status (perhaps I0002). (verify in TJ02 table).


Best of Luck

KJogeswaraRao







former_member245085
Participant
0 Kudos

Thanks Jogeswara,

I ' ll test this and confirm

jogeswararao_kavala
Active Contributor
0 Kudos

Ashok,


I have successfully tested the code. (There is no need of COMMIT WORK statement in the end as suggested earlier.) . As per this code, when you Release and Save your Order, all the Sub-Orders related to it will automatically turn into REL status.

Here is the code. (to be written in the include ZXWOCU07 of exit IWO10009)


TYPES: BEGIN OF TY_SO,
   AUFNR TYPE AUFK-AUFNR,
   OBJNR TYPE AUFK-OBJNR,
END OF TY_SO.

DATA: IT_SO TYPE TABLE OF TY_SO,
       WA_SO LIKE LINE OF IT_SO.

SELECT AUFNR OBJNR FROM VIAUFKS INTO CORRESPONDING FIELDS

OF TABLE IT_SO WHERE MAUFNR = CAUFVD_IMP-AUFNR.

DATA: IT_STAT TYPE TABLE OF JSTAT,
          WA_STAT TYPE JSTAT.

WA_STAT-STAT =  'I0002'.
WA_STAT-INACT = ' '.

APPEND WA_STAT TO IT_STAT.

IF CAUFVD_IMP-IPHAS = '2'.
   LOOP AT IT_SO INTO WA_SO.
     CALL FUNCTION 'STATUS_CHANGE_INTERN'
       EXPORTING
         OBJNR  = WA_SO-OBJNR
       TABLES
         STATUS = IT_STAT.
   ENDLOOP.
ENDIF.

Best of Luck

KJogeswaraRao

former_member245085
Participant
0 Kudos

Thank you very much Jogeswara,

I ll confirm this once I coded with ABAP

Thank a lot

AM

peter_atkin
Active Contributor
0 Kudos

AM,

Just to confirm, when you are in the superior order (via IW32 ) and release this order, you then want to release all sub orders (without the user entering each sub -order)?

If so, then I'd be a little wary of using the STATUS_CHANGE_INTERN method above as, in my experience, this can lead to status/database inconsistencies. Also you don't always get feedback as to why the status may fail (e.g. locked order). Furthermore - what happens if the superior order save is terminated/cancelled..

I would prefer to update the sub-order statuses via a more conventional route, say using function module BAPI_ALM_ORDER_MAINTAIN after the superior order has been successfully saved..

PeteA

former_member245085
Participant
0 Kudos

Thanks PeteA for the FM

I ' ll  test both scenarios before confirm

Answers (0)