on 05-31-2007 5:10 AM
Hi Gurus,
We have completed Result Recording using QE51N transaction and Usage decision using QA11. It has posted a stock from QI to Unrestricted use. Now I want to take it back from Unrestricted use to QI. This needs reversal of usage decision (What I think).
Can you suggest me the proper way of performing the said transaction?
I will really appreciate your concern.
Thanks
Shiv
Hi Shiv,
1)Activate inspection type '08'-Stock transfer inspection in quality management view of material master.
2)Then use t.code. 'MB1B' &use moment type 322.
New inspection lot will be created&material will again to quality inspection.
Try,if queries revert&award points if helpful
Regards,
Shailendra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shailendra,
When I am doing MB31 with 102 mvt and order number it says "Changes only possible in QM". Same message I was getting while doing MB1B with 322 mvt. But after adding inspection type 08 that was alright. Now I don't know what to do? Is there any possible inspection type which can solve this problem?
Please reply.....
Thanks
Shiv
hi,
can u check this thread, may this may help you.
http://www.sapfans.com/forums/viewtopic.php?t=5510&highlight=given++reversal
Cheers
Alfred
Hai,
Please find the solution with out any programming
Since the stock has been posted to unrestricted stock for the inspection lot, You need to follw the following process .
Condition: If invoice verification done by accounts personnel for the material , Please reverse the incvoice verification (inclusive of excise process) then proceed the below steps
Solution : First u need to move the unrestricted stock to blocked stock(344) and then reverse the GR with movement type (102)
Select the inspection lot with change history for the material and do the cancel for the lot
Now all the stock has been reversed and again do the fresh GR and do the inspection
STEPS:
1. Go To select the transaction code MB1B then press enter
2. Select the Movement type : 344 (material unrestricted to blocked stock) and select the plant and storage location then press enter
3. Select the material code and entre the qty and batch the press save button
4. Then check the stock whether the stock has been moved from unbrestricted stock to Blocked stock using transaction code MMBE
5. Go to menu SAP menu Choose Logistics --> Materials Management ---> Inventory Management ---> Goods Movement --> Goods receipt -->
For purchase order --> PO number known.(MIGO)
The initial screen for creating a goods receipt for a purchase order appears.
6. In the field for the movement type, enter 102 (goods receipt for a purchase order into warehouse - reversal).
7. In the field for the purchase order, enter the purchase order number for the original goods receipt.
You can copy the purchase order number from the inspection lot.
8. Choose Enter to display the selection screen for the purchase order items.
9. Select the purchase order item for which you want to create the goods receipt and set the Stock type indicator as blocked stock).
10. Save the goods receipt and exit the Materials Management component.
11 Choose Logistics --> Quality management ---> Quality inspection ---> Inspection lot -
>Usage decision -
>Change with history.(QA12)
The initial screen for changing a usage decision appears.
12. Enter the number of the inspection lot for which you previously made the usage decision and choose Usage decision (UD).
13. To cancel the inspection lot, choose Usage decision -
> Functions -
> Cancel lot in the usage decision screen.
14. Now stock has been reveresed and do the fresh GR against the purchase order
15. Finally Once again u need do the Inspection for the new lot
Please reward me if you have solved the problem or revert back
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I did exactly what you proposed.
In my case I wanted finally to cancel the material document (102) after the UD was done.
I moved material to blocked, cancelled the Inspection Lot, then moved the material back to unrestricted and wanted to do the 102 - cancellation movement. I got the communicate: "Deficit of BA Stck.in qual.insp".
Why?
The same communicate appears when I did not all the prior steps - just wanted to cancel document in MIGO.
I do not want to make a return delivery but cancellation of the GR (with Inspection type active).
Thanks
R/3 note no. 175842 14.12.2001 Page 1
________________________________________________________________________
Number 0175842
Version 0021 from 29.11.2001
Status Released for customer
Set by SAP AG on 03.12.2001
Language EN
Short text Inspection lot: Reversal of goods movements from UD
Administrator SAP AG
Component QM-IM-UD Inspection Lot Completion
________________________________________________________________________
Long text
Symptom
Goods movements, which were created from the transactions of the usage
decision, can no longer be reversed.
Additional key words
QA11, QA12, QA14, MBST, MF41
Inspection lot, usage decision, goods movements, reversal, material
document
Cause and preconditions
Presently, the function is not provided in the standard system.
Solution
The function is not provided in the standard system up to and including
Release 4.6C.
When you do this bear the following in mind:
1. Using the attached program corrections, stock transfer postings can
be reset for the usage decision.If it is possible to post this
document in the stock management, the inspection lot is also
corrected and the Quality Management Information System is if
necessary updated.After the reset has been successfully carried out,
the inspection lot, related to the stocks, has the status before the
first stock credit entry.The usage decision is not reset.If, after
the usage decision, further transfer postings are carried out in the
stock management which lead to the usage decision transfer postings
not being able to be reset due to missing availability, these
postings must be reversed first.
2. The goods movement is carried out in each case with the reversal
movement type (document neutral reversal).The original documents are
not reversed related to the document.This may lead to deviations in
the accounting caused by valuation.
3. Resetting postings for materials requiring serial numbers is not
supported.
4. With this correction program, you cannot reverse goods movements for
inpection lots for handling units (HU).
5. Batch status changes which have possibly been carried out are not
cancelled.
6. Batches which have been created in the usage decision during a
transfer posting are not deleted.The classification of these batches
is not changed either.
Page 2
7. Within the adjustment posting, in Release 4.x, the reference records
are also adjusted between the material document and inspection
lot.This can possibly lead to an incorrect description of the
reference type when displaying material documents for the inspection
lot.In Release 3.x, the reference records are deleted in order to
make sure that individual documents cannot be cancelled several
times.
8. The program does not contain any own authorization checks and should
be used with utmost care and ONLY after a successful test. The
program should ONLY be applied in exceptions and should not be part
of the standard procedure.
9. The logic implemented in the program for the generation of material
documents or for the update of inspection lot quantities and
inspection lot status should under no circumstances be be changed as
this might lead to inconsistent data. Since this is a program that is
not contained in the standard system, problems that are created as a
result of the program application can be dealt with as problems that
have arisen as a result of a customer modification.
To implement the program, proceed as follows:
1. Create an executable program and copy the attached source code.Then
maintain the text for selection parameter PRUEFLOS by transferring
the Dictionary text.
2. If you a use a Release < 4.6, you must create the function group
ZQMB. In this function group, you must create function module
'ZQMB_QAMB_CANCEL'. Flag the function module as an update function
module (Start immediately) and include table interface parameter
'I_QAMB_TAB' (type specification LIKE, reference structure QAMB).
Afterwards you must include exception 'ERROR_DURING_UPDATE' and
implement the attached source code.
3. Use Transaction OMJJ to enter further entries in level 'Allowed
transactions' (table T158B) for transaction code 'QA11' (Record Usage
Decision).The movement types for which these entries must be created
are derived from the system settings for the goods movements for the
usage decision (table TQ07M):The reversal movement type must be
determined for every movement type that is entered in table TQ07M
with the key VMENGE01 - VMENGE09 and the corresponding entry must be
included in the above-mentioned table.You can use table T156N for
determining the reversal movement type:You can determine the reversal
movement type by entering the movement type (BWART) and function code
(FCODE) ST (BWART_NEXT).For missing entries, the system generates
error M7096 'Goods movement not possible with mvmt type &'.
Source code corrections
________________________________________________________________________
Page 3
Valid releases
R/3 Standard 46C - 46D
46A - 46B
45A - 45B
40A - 40B
30F - 31I
Other components
QM-IM Quality Inspection
________________________________________________________________________
Reference to related notes
Number Short text
____________________________________________________________
0033924 Cancelling usage decisions
0048815 Checking possible inconsistencies between MM and QM
________________________________________________________________________
Page 4
Assigned correction instructions
________________________________________________________________________
$$----
-
$$
$ Correction Instr. : 0120024545 0000111772 $
$ Software Component : SAP_APPL SAP Application $
*$----
$*
$ Validity : 40A SAPKH40A01 - SAPKH40A25 $
$ : 40B All Patches $
$ : 45A All Patches $
$ : 45B All Patches $
*$----
$*
$ Changes/Objects Not Contained in Standard SAP System $
$$----
-
$$
*&----
*
*& Object FUNC ZQMB_QAMB_CANCEL
*& Object Header FUGR ZQMB
*&----
*
*& FUNCTION ZQMB_QAMB_CANCEL
*&----
*
*>>>> START OF INSERTION <<<<
UPDATE QAMB FROM TABLE I_QAMB_TAB.
IF NOT SY-SUBRC IS INITIAL.
RAISE ERROR_DURING_UPDATE.
ENDIF.
*>>>> END OF INSERTION <<<<<<
...
*&----
*
*&----
*
*& Object REPS RQEVAC50
*& Object Header PROG RQEVAC50
*&----
*
*& REPORT RQEVAC50
*&----
*
*>>>> START OF INSERTION <<<<
REPORT RQEVAC50 MESSAGE-ID QA.
TYPES:
T_QAMB_TAB LIKE QAMB OCCURS 0,
T_MKPF_TAB LIKE MKPF OCCURS 0,
T_MSEG_TAB LIKE MSEG OCCURS 0.
PARAMETERS:
PRUEFLOS LIKE QALS-PRUEFLOS OBLIGATORY MEMORY ID QLS.
DATA:
G_MSGV1 LIKE SY-MSGV1,
G_QALS LIKE QALS,
G_QALS_LEISTE LIKE QALS,
G_QAMB_TAB TYPE T_QAMB_TAB,
G_QAMB_VB_TAB TYPE T_QAMB_TAB,
G_MKPF_TAB TYPE T_MKPF_TAB,
G_MSEG_TAB TYPE T_MSEG_TAB,
G_SUBRC LIKE SY-SUBRC.
START-OF-SELECTION.
Page 5
PERFORM ENQUEUE_QALS USING PRUEFLOS
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM READ_QALS USING PRUEFLOS
G_QALS
G_QALS_LEISTE
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID 'QA' TYPE 'S' NUMBER '102'
WITH PRUEFLOS.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM CHECK_LOT USING G_QALS
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
CASE G_SUBRC.
WHEN 128.
G_MSGV1 = 'Material & is serialized'.
REPLACE '&' WITH G_QALS-MATNR INTO G_MSGV1.
WHEN 64.
G_MSGV1 = 'Lot & is not stock relevant'.
WHEN 32.
G_MSGV1 = 'Lot &: No stock transferred'.
WHEN 16.
G_MSGV1 = 'Lot & is cancelled'.
WHEN 8.
G_MSGV1 = 'Lot & is archived'.
WHEN 4.
G_MSGV1 = 'Lot & is blocked'.
WHEN 2.
G_MSGV1 = 'Lot & is HU managed'.
ENDCASE.
REPLACE '&' WITH PRUEFLOS INTO G_MSGV1.
MESSAGE ID '00' TYPE 'S' NUMBER '208'
WITH G_MSGV1.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM READ_QAMB USING G_QALS
G_QAMB_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID 'QA' TYPE 'S' NUMBER '068'
WITH PRUEFLOS.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM READ_MKPF USING G_QAMB_TAB
G_MKPF_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
Page 6
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM CHECK_MKPF USING G_MKPF_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID 'QA' TYPE 'S' NUMBER '068'
WITH PRUEFLOS.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM READ_MSEG USING G_MKPF_TAB
G_MSEG_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM CHECK_MSEG USING G_MSEG_TAB
G_QAMB_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID 'QA' TYPE 'S' NUMBER '068'
WITH PRUEFLOS.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM CREATE_GOODS_MOVEMENT USING G_QALS
G_MSEG_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID 'QA' TYPE 'S' NUMBER '068'
WITH PRUEFLOS.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM POST_GOODS_MOVEMENT.
PERFORM POST_DATA USING G_QALS
G_QALS_LEISTE
G_QAMB_TAB
G_QAMB_VB_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ELSE.
COMMIT WORK AND WAIT.
G_MSGV1 = 'inspection lot &'.
REPLACE '&' WITH PRUEFLOS INTO G_MSGV1.
MESSAGE ID '00' TYPE 'S' NUMBER '368'
Page 7
WITH 'Stock posting reversed for ' G_MSGV1.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
*----
*
Form ENQUEUE_QALS *
*----
*
Los sperren *
*----
*
FORM ENQUEUE_QALS USING P_PRUEFLOS LIKE QALS-PRUEFLOS
P_SUBRC LIKE SY-SUBRC.
CLEAR: P_SUBRC.
CALL FUNCTION 'ENQUEUE_EQQALS1'
EXPORTING
PRUEFLOS = P_PRUEFLOS
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
P_SUBRC = SY-SUBRC.
ENDFORM. " ENQUEUE_QALS
*----
*
Form READ_QALS *
*----
*
Prüflos lesen *
*----
*
FORM READ_QALS USING P_PRUEFLOS LIKE QALS-PRUEFLOS
P_QALS LIKE QALS
P_QALS_LEISTE LIKE QALS
P_SUBRC LIKE SY-SUBRC.
CLEAR: P_SUBRC.
CALL FUNCTION 'QPSE_LOT_READ'
EXPORTING
I_PRUEFLOS = P_PRUEFLOS
I_RESET_LOT = 'X'
IMPORTING
E_QALS = P_QALS
EXCEPTIONS
NO_LOT = 1.
P_SUBRC = SY-SUBRC.
IF P_SUBRC IS INITIAL.
P_QALS_LEISTE = P_QALS.
ELSE.
CLEAR: P_QALS,
P_QALS_LEISTE.
ENDIF.
ENDFORM. " READ_QALS
*----
*
Form CHECK_LOT *
Page 8
*----
*
Prüflos prüfen *
*----
*
FORM CHECK_LOT USING P_QALS LIKE QALS
P_SUBRC LIKE SY-SUBRC.
DATA:
L_STAT LIKE JSTAT,
L_STAT_TAB LIKE JSTAT OCCURS 0 WITH HEADER LINE.
P_SUBRC = 128.
*/Serialized Material
IF NOT P_QALS-SERNP IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 64.
ENDIF.
*/BERF
CALL FUNCTION 'STATUS_CHECK'
EXPORTING
OBJNR = P_QALS-OBJNR
STATUS = 'I0203'
EXCEPTIONS
STATUS_NOT_ACTIVE = 2.
IF NOT SY-SUBRC IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 32.
ENDIF.
*/BTEI & BEND
CLEAR L_STAT. CLEAR L_STAT_TAB. REFRESH L_STAT_TAB.
L_STAT-STAT = 'I0219'. APPEND L_STAT TO L_STAT_TAB. "BTEI
L_STAT-STAT = 'I0220'. APPEND L_STAT TO L_STAT_TAB. "BEND
CALL FUNCTION 'STATUS_OBJECT_CHECK_MULTI'
EXPORTING
OBJNR = P_QALS-OBJNR
TABLES
STATUS_CHECK = L_STAT_TAB.
IF L_STAT_TAB[] IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 16.
ENDIF.
*/LSTO & LSTV
CLEAR L_STAT. CLEAR L_STAT_TAB. REFRESH L_STAT_TAB.
L_STAT-STAT = 'I0224'. APPEND L_STAT TO L_STAT_TAB. "LSTO
L_STAT-STAT = 'I0232'. APPEND L_STAT TO L_STAT_TAB. "LSTV
CALL FUNCTION 'STATUS_OBJECT_CHECK_MULTI'
EXPORTING
Page 9
OBJNR = P_QALS-OBJNR
TABLES
STATUS_CHECK = L_STAT_TAB.
IF NOT L_STAT_TAB[] IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 8.
ENDIF.
*/ARSP & ARCH & REO1 & REO2 & REO3
CLEAR L_STAT. CLEAR L_STAT_TAB. REFRESH L_STAT_TAB.
L_STAT-STAT = 'I0225'. APPEND L_STAT TO L_STAT_TAB. "ARSP
L_STAT-STAT = 'I0226'. APPEND L_STAT TO L_STAT_TAB. "ARCH
L_STAT-STAT = 'I0227'. APPEND L_STAT TO L_STAT_TAB. "REO3
L_STAT-STAT = 'I0228'. APPEND L_STAT TO L_STAT_TAB. "REO2
L_STAT-STAT = 'I0229'. APPEND L_STAT TO L_STAT_TAB. "REO1
CALL FUNCTION 'STATUS_OBJECT_CHECK_MULTI'
EXPORTING
OBJNR = P_QALS-OBJNR
TABLES
STATUS_CHECK = L_STAT_TAB.
IF NOT L_STAT_TAB[] IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 4.
ENDIF.
*/SPER
CALL FUNCTION 'STATUS_CHECK'
EXPORTING
OBJNR = P_QALS-OBJNR
STATUS = 'I0043'
EXCEPTIONS
STATUS_NOT_ACTIVE = 2.
IF SY-SUBRC IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 2.
ENDIF.
*/HUM
CALL FUNCTION 'STATUS_CHECK'
EXPORTING
OBJNR = P_QALS-OBJNR
STATUS = 'I0443'
EXCEPTIONS
STATUS_NOT_ACTIVE = 2.
IF SY-SUBRC IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 0.
ENDIF.
Page 10
ENDFORM. " CHECK_LOT
*----
*
Form READ_QAMB *
*----
*
QAMBs lesen *
*----
*
FORM READ_QAMB USING P_QALS LIKE QALS
P_QAMB_TAB TYPE T_QAMB_TAB
P_SUBRC LIKE SY-SUBRC.
CLEAR: P_SUBRC.
SELECT * FROM QAMB INTO TABLE P_QAMB_TAB
WHERE PRUEFLOS = P_QALS-PRUEFLOS
AND TYP = '3'.
P_SUBRC = SY-SUBRC.
ENDFORM. " READ_QAMB
*----
*
Form READ_MKPF *
*----
*
Read material document header *
*----
*
FORM READ_MKPF USING P_QAMB_TAB TYPE T_QAMB_TAB
P_MKPF_TAB TYPE T_MKPF_TAB
P_SUBRC LIKE SY-SUBRC.
DATA:
BEGIN OF L_MKPF_KEY_TAB OCCURS 0,
MBLNR LIKE MKPF-MBLNR,
MJAHR LIKE MKPF-MJAHR,
END OF L_MKPF_KEY_TAB.
DATA:
L_QAMB LIKE QAMB,
L_MKPF LIKE MKPF,
L_TRTYP LIKE T158-TRTYP VALUE 'A',
L_VGART LIKE T158-VGART VALUE 'WQ',
L_XEXIT LIKE QM00-QKZ.
P_SUBRC = 4.
LOOP AT P_QAMB_TAB INTO L_QAMB.
L_MKPF_KEY_TAB-MBLNR = L_QAMB-MBLNR.
L_MKPF_KEY_TAB-MJAHR = L_QAMB-MJAHR.
COLLECT L_MKPF_KEY_TAB.
ENDLOOP.
LOOP AT L_MKPF_KEY_TAB.
CALL FUNCTION 'ENQUEUE_EMMKPF'
EXPORTING
MBLNR = L_MKPF_KEY_TAB-MBLNR
MJAHR = L_MKPF_KEY_TAB-MJAHR
EXCEPTIONS
FOREIGN_LOCK = 1
Page 11
SYSTEM_FAILURE = 2
OTHERS = 3.
IF NOT SY-SUBRC IS INITIAL.
L_XEXIT = 'X'.
EXIT.
ENDIF.
CLEAR: L_MKPF.
CALL FUNCTION 'MB_READ_MATERIAL_HEADER'
EXPORTING
MBLNR = L_MKPF_KEY_TAB-MBLNR
MJAHR = L_MKPF_KEY_TAB-MJAHR
TRTYP = L_TRTYP
VGART = L_VGART
IMPORTING
KOPF = L_MKPF
EXCEPTIONS
ERROR_MESSAGE = 1.
IF NOT SY-SUBRC IS INITIAL.
L_XEXIT = 'X'.
EXIT.
ELSE.
APPEND L_MKPF TO P_MKPF_TAB.
ENDIF.
ENDLOOP.
IF NOT L_XEXIT IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 0.
ENDIF.
ENDFORM. " READ_MKPF
*----
*
Form READ_MSEG *
*----
*
MSEGs lesen *
*----
*
FORM READ_MSEG USING P_MKPF_TAB TYPE T_MKPF_TAB
P_MSEG_TAB TYPE T_MSEG_TAB
P_SUBRC LIKE SY-SUBRC.
DATA:
L_MKPF LIKE MKPF,
L_MSEG_TAB LIKE MSEG OCCURS 0 WITH HEADER LINE,
L_TRTYP LIKE T158-TRTYP VALUE 'A',
L_XEXIT LIKE QM00-QKZ.
P_SUBRC = 4.
LOOP AT P_MKPF_TAB INTO L_MKPF.
CLEAR: L_MSEG_TAB. REFRESH: L_MSEG_TAB.
CALL FUNCTION 'MB_READ_MATERIAL_POSITION'
EXPORTING
Page 12
MBLNR = L_MKPF-MBLNR
MJAHR = L_MKPF-MJAHR
TRTYP = L_TRTYP
*/ ZEILB = P_ZEILE
*/ ZEILE = P_ZEILE
TABLES
SEQTAB = L_MSEG_TAB
EXCEPTIONS
ERROR_MESSAGE = 1.
IF NOT SY-SUBRC IS INITIAL.
L_XEXIT = 'X'.
EXIT.
ELSE.
APPEND LINES OF L_MSEG_TAB TO P_MSEG_TAB.
ENDIF.
ENDLOOP.
IF NOT L_XEXIT IS INITIAL.
EXIT.
ELSE.
*/ XAuto-Zeilen und Chargenzustandsänderung werden gelöscht
DELETE P_MSEG_TAB WHERE XAUTO NE SPACE
OR BWART EQ '341'
OR BWART EQ '342'.
P_SUBRC = 0.
ENDIF.
ENDFORM. " READ_MSEG
*----
*
Form CREATE_GOODS_MOVEMENT *
*----
*
Warenbewegung anlegen *
*----
*
FORM CREATE_GOODS_MOVEMENT USING P_QALS LIKE QALS
P_MSEG_TAB TYPE T_MSEG_TAB
P_SUBRC LIKE SY-SUBRC.
DATA:
L_LMENGEZUB LIKE QALS-LMENGEZUB,
L_LMENGEGEB LIKE QALS-LMENGEZUB,
L_MBQSS LIKE MBQSS,
L_IMKPF LIKE IMKPF,
L_IMSEG LIKE IMSEG,
L_IMSEG_TAB LIKE IMSEG OCCURS 1,
L_EMKPF LIKE EMKPF,
L_EMSEG LIKE EMSEG,
L_EMSEG_TAB LIKE EMSEG OCCURS 1,
L_MSEG LIKE MSEG,
L_MSEG_TAB LIKE MSEG OCCURS 1,
L_TCODE LIKE SY-TCODE VALUE 'QA11',
L_TABIX LIKE SY-TABIX VALUE 1,
L_XSTBW LIKE T156-XSTBW.
CLEAR: P_SUBRC.
Page 13
*/QAMB initialisieren
CALL FUNCTION 'QAMB_REFRESH_DATA'.
*/Kopf füllen
L_IMKPF-BLDAT = SY-DATLO.
L_IMKPF-BUDAT = SY-DATLO.
L_IMKPF-BKTXT = 'Cancellation of QM UD postings'.
*/Ursprüngliche zu buchende Menge merken + inkrementieren
L_LMENGEZUB = P_QALS-LMENGEZUB.
L_LMENGEGEB = P_QALS-LMENGE01
+ P_QALS-LMENGE02
+ P_QALS-LMENGE03
+ P_QALS-LMENGE04
+ P_QALS-LMENGE05
+ P_QALS-LMENGE06
+ P_QALS-LMENGE07
+ P_QALS-LMENGE08
+ P_QALS-LMENGE09.
*/Zeilen aufbauen
L_MSEG_TAB[] = P_MSEG_TAB[].
LOOP AT L_MSEG_TAB INTO L_MSEG.
MOVE-CORRESPONDING L_MSEG TO L_MBQSS.
MOVE-CORRESPONDING L_MBQSS TO L_IMSEG.
*/ Referenzbeleg übergeben, falls Bestellnummer gefüllt
IF NOT L_MSEG-EBELN IS INITIAL.
MOVE: L_MSEG-LFBNR TO L_IMSEG-LFBNR,
L_MSEG-LFBJA TO L_IMSEG-LFBJA,
L_MSEG-LFPOS TO L_IMSEG-LFPOS.
ENDIF.
MOVE L_MSEG-KDAUF TO L_IMSEG-KDAUF.
MOVE L_MSEG-KDPOS TO L_IMSEG-KDPOS.
MOVE L_MSEG-PS_PSP_PNR TO L_IMSEG-PS_PSP_PNR.
*/ Umlagerungsfelder setzen
MOVE:
L_MSEG-UMMAT TO L_IMSEG-UMMAT,
L_MSEG-UMWRK TO L_IMSEG-UMWRK,
L_MSEG-UMLGO TO L_IMSEG-UMLGO,
L_MSEG-UMCHA TO L_IMSEG-UMCHA.
*/ Storno-Beleg setzen
MOVE: L_MSEG-MJAHR TO L_IMSEG-SJAHR,
L_MSEG-MBLNR TO L_IMSEG-SMBLN,
L_MSEG-ZEILE TO L_IMSEG-SMBLP.
*/ Falsch gefüllte Felder initialisieren
CLEAR: L_IMSEG-MBLNR,
L_IMSEG-MENGE,
L_IMSEG-MEINS.
*/ Bewegungsart lesen
SELECT SINGLE XSTBW FROM T156 INTO L_XSTBW
WHERE BWART = L_IMSEG-BWART.
Page 14
IF NOT SY-SUBRC IS INITIAL.
P_SUBRC = 4.
EXIT.
ENDIF.
*/ Werk/Lagerort füllen
IF P_QALS-STAT11 IS INITIAL.
IF L_XSTBW IS INITIAL.
MOVE P_QALS-LAGORTVORG TO L_IMSEG-LGORT.
ELSE.
MOVE P_QALS-LAGORTVORG TO L_IMSEG-UMLGO.
ENDIF.
ENDIF.
IF L_XSTBW IS INITIAL.
MOVE P_QALS-WERKVORG TO L_IMSEG-WERKS.
ELSE.
MOVE P_QALS-WERKVORG TO L_IMSEG-UMWRK.
ENDIF.
*/ Zusätzliche Felder
MOVE P_QALS-MENGENEINH TO L_IMSEG-ERFME.
"MOVE P_GRUND TO L_IMSEG-GRUND.
"MOVE P_ELIKZ TO L_IMSEG-ELIKZ.
*/ Kennzeichen Storno-Buchung setzen
MOVE 'X' TO L_IMSEG-XSTOB.
MOVE P_QALS-PRUEFLOS TO L_IMSEG-QPLOS.
APPEND L_IMSEG TO L_IMSEG_TAB.
IF P_QALS-STAT11 IS INITIAL.
ADD L_IMSEG-ERFMG TO L_LMENGEZUB.
SUBTRACT L_IMSEG-ERFMG FROM L_LMENGEGEB.
ELSE.
IF L_IMSEG-KZBEW EQ SPACE
AND L_IMSEG-WERKS NE SPACE
AND L_IMSEG-LGORT NE SPACE
AND L_IMSEG-UMWRK NE SPACE
AND L_IMSEG-UMLGO NE SPACE
AND L_IMSEG-WERKS EQ L_IMSEG-UMWRK
AND L_IMSEG-UMLGO EQ L_IMSEG-UMLGO.
*/ Dummy Buchung bei WE-Sperrbestand & Stichprobe
ELSE.
ADD L_IMSEG-ERFMG TO L_LMENGEZUB.
SUBTRACT L_IMSEG-ERFMG FROM L_LMENGEGEB.
ENDIF.
ENDIF.
ENDLOOP.
IF NOT P_QALS-STAT11 IS INITIAL.
*/ Bei WE-Sperrbestand und Stichprobenbuchung Zeilen tauschen
DO.
READ TABLE L_IMSEG_TAB INDEX SY-INDEX INTO L_IMSEG.
IF SY-SUBRC IS INITIAL
AND L_IMSEG-KZBEW EQ SPACE
AND L_IMSEG-WERKS NE SPACE
AND L_IMSEG-LGORT NE SPACE
AND L_IMSEG-UMWRK NE SPACE
AND L_IMSEG-UMLGO NE SPACE
Page 15
AND L_IMSEG-WERKS EQ L_IMSEG-UMWRK
AND L_IMSEG-UMLGO EQ L_IMSEG-UMLGO.
IF SY-TABIX NE L_TABIX.
DELETE L_IMSEG_TAB INDEX SY-TABIX.
INSERT L_IMSEG INTO L_IMSEG_TAB INDEX L_TABIX.
L_TABIX = L_TABIX + 1.
ELSE.
L_TABIX = L_TABIX + 1.
CONTINUE.
ENDIF.
ELSEIF SY-SUBRC IS INITIAL.
CONTINUE.
ELSE.
EXIT. "from do
ENDIF.
ENDDO.
ENDIF.
*/QM deaktivieren
CALL FUNCTION 'QAAT_QM_ACTIVE_INACTIVE'
EXPORTING
AKTIV = SPACE.
*/Buchen
CALL FUNCTION 'MB_CREATE_GOODS_MOVEMENT'
EXPORTING
IMKPF = L_IMKPF
XALLP = 'X'
XALLR = 'X'
CTCOD = L_TCODE
XQMCL = ' '
IMPORTING
EMKPF = L_EMKPF
TABLES
IMSEG = L_IMSEG_TAB
EMSEG = L_EMSEG_TAB.
*/QM wieder aktivieren
CALL FUNCTION 'QAAT_QM_ACTIVE_INACTIVE'
EXPORTING
AKTIV = 'X'.
*/Buchung auswerten
IF L_EMKPF-SUBRC GT 1.
IF L_EMKPF-MSGID NE SPACE.
*/ Fehler auf Kopfebene
MESSAGE ID L_EMKPF-MSGID TYPE 'S'
NUMBER L_EMKPF-MSGNO
WITH L_EMKPF-MSGV1 L_EMKPF-MSGV2
L_EMKPF-MSGV3 L_EMKPF-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ELSE.
*/ Fehler auf Zeilenebene (Ausgabe des ersten Fehlers)
LOOP AT L_EMSEG_TAB INTO L_EMSEG.
IF L_EMSEG-MSGID NE SPACE.
MESSAGE ID L_EMSEG-MSGID TYPE 'S'
NUMBER L_EMSEG-MSGNO
WITH L_EMSEG-MSGV1 L_EMSEG-MSGV2
L_EMSEG-MSGV3 L_EMSEG-MSGV4.
Page 16
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
LOOP AT L_EMSEG_TAB INTO L_EMSEG.
CALL FUNCTION 'QAMB_COLLECT_RECORD'
EXPORTING
LOTNUMBER = P_QALS-PRUEFLOS
DOCYEAR = L_EMKPF-MJAHR
DOCNUMBER = L_EMKPF-MBLNR
DOCPOSITION = L_EMSEG-MBLPO
TYPE = '7'.
ENDLOOP.
*/Sonderkorrektur für Frei-An-Frei & WE-Sperr-An-We-Sperr
IF NOT P_QALS-STAT11 IS INITIAL.
IF P_QALS-LMENGE04 EQ L_LMENGEGEB.
ADD P_QALS-LMENGE04 TO L_LMENGEZUB.
SUBTRACT P_QALS-LMENGE04 FROM L_LMENGEGEB.
ENDIF.
ELSEIF P_QALS-INSMK IS INITIAL.
IF P_QALS-LMENGE01 GE L_LMENGEGEB
AND NOT P_QALS-LMENGE01 IS INITIAL.
ADD L_LMENGEGEB TO L_LMENGEZUB.
SUBTRACT L_LMENGEGEB FROM L_LMENGEGEB.
ENDIF.
ENDIF.
CLEAR: P_QALS-STAT34,
P_QALS-MATNRNEU,
P_QALS-CHARGNEU,
P_QALS-LMENGE01,
P_QALS-LMENGE02,
P_QALS-LMENGE03,
P_QALS-LMENGE04,
P_QALS-LMENGE05,
P_QALS-LMENGE06,
P_QALS-LMENGE07,
P_QALS-LMENGE08,
P_QALS-LMENGE09.
P_QALS-LMENGEZUB = L_LMENGEZUB.
IF NOT L_LMENGEGEB IS INITIAL.
P_SUBRC = 4.
ENDIF.
ENDFORM. " CREATE_GOODS_MOVEMENT
*----
*
Form POST_GOODS_MOVEMENT *
*----
*
Warenbewegung buchen *
*----
*
FORM POST_GOODS_MOVEMENT.
CALL FUNCTION 'MB_POST_GOODS_MOVEMENT'.
Page 17
ENDFORM. " POST_GOODS_MOVEMENT
*----
*
Form POST_DATA *
*----
*
QM-Daten verbuchen *
*----
*
FORM POST_DATA USING P_QALS LIKE QALS
P_QALS_LEISTE LIKE QALS
P_QAMB_TAB TYPE T_QAMB_TAB
P_QAMB_VB_TAB TYPE T_QAMB_TAB
P_SUBRC LIKE SY-SUBRC.
DATA:
L_STAT LIKE JSTAT,
L_STAT_TAB LIKE JSTAT OCCURS 0,
L_QAMB LIKE QAMB,
L_UPDKZ LIKE QALSVB-UPSL VALUE 'U'.
*/QAMBs umsetzen (7 = VE-Buchung storniert)
LOOP AT P_QAMB_TAB INTO L_QAMB.
L_QAMB-TYP = '7'.
APPEND L_QAMB TO P_QAMB_VB_TAB.
ENDLOOP.
*/BERF & BTEI zurücknehmen
CLEAR L_STAT. CLEAR L_STAT_TAB.
L_STAT-INACT = 'X'.
L_STAT-STAT = 'I0219'. APPEND L_STAT TO L_STAT_TAB. "BTEI
L_STAT-STAT = 'I0220'. APPEND L_STAT TO L_STAT_TAB. "BEND
CALL FUNCTION 'STATUS_CHANGE_INTERN'
EXPORTING
OBJNR = P_QALS-OBJNR
TABLES
STATUS = L_STAT_TAB
EXCEPTIONS
ERROR_MESSAGE = 1.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
*/Prüflos aktualisieren
CALL FUNCTION 'QPL1_UPDATE_MEMORY'
EXPORTING
I_QALS = P_QALS
I_UPDKZ = L_UPDKZ.
CALL FUNCTION 'QPL1_INSPECTION_LOTS_POSTING'.
CALL FUNCTION 'STATUS_UPDATE_ON_COMMIT'.
*/QAMB initialisieren
CALL FUNCTION 'QAMB_REFRESH_DATA'.
Page 18
PERFORM UPDATE_QAMB ON COMMIT.
P_SUBRC = 0.
ENDFORM. " POST_DATA
*----
*
Form UPDATE_QAMB *
*----
*
Update auf QAMB *
*----
*
FORM UPDATE_QAMB.
CALL FUNCTION 'ZQMB_QAMB_CANCEL' IN UPDATE TASK
TABLES
I_QAMB_TAB = G_QAMB_VB_TAB.
ENDFORM. " UPDATE_QAMB
*----
*
Form CHECK_MSEG *
*----
*
MSEGs prüfen *
*----
*
FORM CHECK_MSEG USING P_MSEG_TAB TYPE T_MSEG_TAB
P_QAMB_TAB TYPE T_QAMB_TAB
P_SUBRC LIKE SY-SUBRC.
DATA:
L_MSEG_STOR_TAB LIKE MSEG OCCURS 0 WITH HEADER LINE.
CLEAR: P_SUBRC.
*/Zeilen bereits storniert?
SELECT MBLNR MJAHR ZEILE SMBLN SJAHR SMBLP
FROM MSEG INTO CORRESPONDING FIELDS OF TABLE L_MSEG_STOR_TAB
FOR ALL ENTRIES IN P_MSEG_TAB
WHERE SMBLN EQ P_MSEG_TAB-MBLNR
AND SJAHR EQ P_MSEG_TAB-MJAHR
AND SMBLP EQ P_MSEG_TAB-ZEILE.
IF SY-SUBRC IS INITIAL.
LOOP AT L_MSEG_STOR_TAB.
DELETE P_MSEG_TAB WHERE MBLNR = L_MSEG_STOR_TAB-SMBLN
AND MJAHR = L_MSEG_STOR_TAB-SJAHR
AND ZEILE = L_MSEG_STOR_TAB-SMBLP.
DELETE P_QAMB_TAB WHERE MBLNR = L_MSEG_STOR_TAB-SMBLN
AND MJAHR = L_MSEG_STOR_TAB-SJAHR
AND ZEILE = L_MSEG_STOR_TAB-SMBLP.
ENDLOOP.
IF P_MSEG_TAB[] IS INITIAL.
P_SUBRC = 4.
EXIT.
ENDIF.
ENDIF.
ENDFORM. " CHECK_MSEG
Page 19
*----
*
Form CHECK_MKPF *
*----
*
Materialbelege prüfen (Wurde durch VE-Buchung Prüfllos erzeugt?*
*----
*
FORM CHECK_MKPF USING P_MKPF_TAB TYPE T_MKPF_TAB
P_SUBRC LIKE SY-SUBRC.
DATA:
L_MKPF_TAB TYPE T_MKPF_TAB.
CLEAR: P_SUBRC.
SELECT MBLNR FROM QAMB INTO CORRESPONDING FIELDS OF TABLE L_MKPF_TAB
FOR ALL ENTRIES IN P_MKPF_TAB
WHERE MBLNR EQ P_MKPF_TAB-MBLNR
AND MJAHR EQ P_MKPF_TAB-MJAHR
AND TYP = '1'.
IF SY-SUBRC IS INITIAL.
P_SUBRC = 4.
ENDIF.
ENDFORM. " CHECK_MKPF
*>>>> END OF INSERTION <<<<<<
...
*&----
*
Page 20
$$----
-
$$
$ Correction Instr. : 0120024545 0000153366 $
$ Software Component : SAP_APPL SAP Application $
*$----
$*
$ Validity : 30F All Patches $
$ : 31G SAPKH31G01 - SAPKH31G13 $
$ : 31H All Patches $
$ : 31I All Patches $
*$----
$*
$ Changes/Objects Not Contained in Standard SAP System $
$$----
-
$$
*&----
*
*& Object FUNC ZQMB_QAMB_CANCEL
*& Object Header FUGR ZQMB
*&----
*
*& FUNCTION ZQMB_QAMB_CANCEL
*&----
*
*>>>> START OF INSERTION <<<<
DELETE QAMB FROM TABLE I_QAMB_TAB.
IF NOT SY-SUBRC IS INITIAL.
RAISE ERROR_DURING_UPDATE.
ENDIF.
*>>>> END OF INSERTION <<<<<<
...
*&----
*
*&----
*
*& Object REPS RQEVAC50
*& Object Header PROG RQEVAC50
*&----
*
*& REPORT RQEVAC50
*&----
*
*>>>> START OF INSERTION <<<<
REPORT RQEVAC50 MESSAGE-ID QA.
TYPES:
T_QAMB_TAB LIKE QAMB OCCURS 0,
T_MKPF_TAB LIKE MKPF OCCURS 0,
T_MSEG_TAB LIKE MSEG OCCURS 0.
PARAMETERS:
PRUEFLOS LIKE QALS-PRUEFLOS OBLIGATORY MEMORY ID QLS.
DATA:
G_MSGV1 LIKE SY-MSGV1,
G_QALS LIKE QALS,
G_QALS_LEISTE LIKE QALS,
G_QAMB_TAB TYPE T_QAMB_TAB,
G_QAMB_VB_TAB TYPE T_QAMB_TAB,
G_MKPF_TAB TYPE T_MKPF_TAB,
G_MSEG_TAB TYPE T_MSEG_TAB,
G_SUBRC LIKE SY-SUBRC.
TABLES:
MSEG,
T156,
QALS,
QAMB,
QAVE.
Page 21
START-OF-SELECTION.
PERFORM ENQUEUE_QALS USING PRUEFLOS
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM READ_QALS USING PRUEFLOS
G_QALS
G_QALS_LEISTE
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID 'QA' TYPE 'S' NUMBER '102'
WITH PRUEFLOS.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM CHECK_LOT USING G_QALS
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
CASE G_SUBRC.
WHEN 128.
G_MSGV1 = 'Material & is serialized'.
REPLACE '&' WITH G_QALS-MATNR INTO G_MSGV1.
WHEN 64.
G_MSGV1 = 'Lot & is not stock relevant'.
WHEN 32.
G_MSGV1 = 'Lot &: No stock transferred'.
WHEN 16.
G_MSGV1 = 'Lot & is cancelled'.
WHEN 8.
G_MSGV1 = 'Lot & is archived'.
WHEN 4.
G_MSGV1 = 'Lot & is blocked'.
ENDCASE.
REPLACE '&' WITH PRUEFLOS INTO G_MSGV1.
MESSAGE ID '00' TYPE 'S' NUMBER '208'
WITH G_MSGV1.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM READ_QAMB USING G_QALS
G_QAMB_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
G_MSGV1 = 'Stock posting for lot & not supported'.
REPLACE '&' WITH PRUEFLOS INTO G_MSGV1.
MESSAGE ID '00' TYPE 'S' NUMBER '208'
WITH G_MSGV1.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM READ_MKPF USING G_QAMB_TAB
G_MKPF_TAB
Page 22
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM CHECK_MKPF USING G_MKPF_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
G_MSGV1 = 'Stock posting for lot & not supported'.
REPLACE '&' WITH PRUEFLOS INTO G_MSGV1.
MESSAGE ID '00' TYPE 'S' NUMBER '208'
WITH G_MSGV1.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM READ_MSEG USING G_MKPF_TAB
G_MSEG_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM CHECK_MSEG USING G_MSEG_TAB
G_QAMB_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
G_MSGV1 = 'Stock posting for lot & not supported'.
REPLACE '&' WITH PRUEFLOS INTO G_MSGV1.
MESSAGE ID '00' TYPE 'S' NUMBER '208'
WITH G_MSGV1.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM CREATE_GOODS_MOVEMENT USING G_QALS
G_MSEG_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
G_MSGV1 = 'Stock posting for lot & not supported'.
REPLACE '&' WITH PRUEFLOS INTO G_MSGV1.
MESSAGE ID '00' TYPE 'S' NUMBER '208'
WITH G_MSGV1.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM POST_DATA USING G_QALS
G_QALS_LEISTE
G_QAMB_TAB
G_QAMB_VB_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
Page 23
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ELSE.
COMMIT WORK AND WAIT.
G_MSGV1 = 'inspection lot &'.
REPLACE '&' WITH PRUEFLOS INTO G_MSGV1.
MESSAGE ID '00' TYPE 'S' NUMBER '368'
WITH 'Stock posting reversed for ' G_MSGV1.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
*----
*
Form ENQUEUE_QALS *
*----
*
Los sperren *
*----
*
FORM ENQUEUE_QALS USING P_PRUEFLOS LIKE QALS-PRUEFLOS
P_SUBRC LIKE SY-SUBRC.
CLEAR: P_SUBRC.
CALL FUNCTION 'ENQUEUE_EQQALS1'
EXPORTING
PRUEFLOS = P_PRUEFLOS
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
P_SUBRC = SY-SUBRC.
ENDFORM. " ENQUEUE_QALS
*----
*
Form READ_QALS *
*----
*
Prüflos lesen *
*----
*
FORM READ_QALS USING P_PRUEFLOS LIKE QALS-PRUEFLOS
P_QALS LIKE QALS
P_QALS_LEISTE LIKE QALS
P_SUBRC LIKE SY-SUBRC.
CLEAR: P_SUBRC.
SELECT SINGLE * FROM QALS INTO P_QALS
WHERE PRUEFLOS EQ P_PRUEFLOS.
P_SUBRC = SY-SUBRC.
IF P_SUBRC IS INITIAL.
P_QALS_LEISTE = P_QALS.
ELSE.
CLEAR: P_QALS,
P_QALS_LEISTE.
ENDIF.
ENDFORM. " READ_QALS
*----
*
Form CHECK_LOT *
Page 24
*----
*
Prüflos prüfen *
*----
*
FORM CHECK_LOT USING P_QALS LIKE QALS
P_SUBRC LIKE SY-SUBRC.
DATA:
L_STAT LIKE JSTAT,
L_STAT_TAB LIKE JSTAT OCCURS 0 WITH HEADER LINE.
P_SUBRC = 128.
*/Serialized Material
IF NOT P_QALS-SERNP IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 64.
ENDIF.
*/BERF
CALL FUNCTION 'STATUS_CHECK'
EXPORTING
OBJNR = P_QALS-OBJNR
STATUS = 'I0203'
EXCEPTIONS
STATUS_NOT_ACTIVE = 2.
IF NOT SY-SUBRC IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 32.
ENDIF.
*/BTEI & BEND
CLEAR L_STAT. CLEAR L_STAT_TAB. REFRESH L_STAT_TAB.
L_STAT-STAT = 'I0219'. APPEND L_STAT TO L_STAT_TAB. "BTEI
L_STAT-STAT = 'I0220'. APPEND L_STAT TO L_STAT_TAB. "BEND
CALL FUNCTION 'STATUS_OBJECT_CHECK_MULTI'
EXPORTING
OBJNR = P_QALS-OBJNR
TABLES
STATUS_CHECK = L_STAT_TAB.
IF L_STAT_TAB[] IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 16.
ENDIF.
*/LSTO & LSTV
CLEAR L_STAT. CLEAR L_STAT_TAB. REFRESH L_STAT_TAB.
L_STAT-STAT = 'I0224'. APPEND L_STAT TO L_STAT_TAB. "LSTO
L_STAT-STAT = 'I0232'. APPEND L_STAT TO L_STAT_TAB. "LSTV
CALL FUNCTION 'STATUS_OBJECT_CHECK_MULTI'
EXPORTING
Page 25
OBJNR = P_QALS-OBJNR
TABLES
STATUS_CHECK = L_STAT_TAB.
IF NOT L_STAT_TAB[] IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 8.
ENDIF.
*/ARSP & ARCH & REO1 & REO2 & REO3
CLEAR L_STAT. CLEAR L_STAT_TAB. REFRESH L_STAT_TAB.
L_STAT-STAT = 'I0225'. APPEND L_STAT TO L_STAT_TAB. "ARSP
L_STAT-STAT = 'I0226'. APPEND L_STAT TO L_STAT_TAB. "ARCH
L_STAT-STAT = 'I0227'. APPEND L_STAT TO L_STAT_TAB. "REO3
L_STAT-STAT = 'I0228'. APPEND L_STAT TO L_STAT_TAB. "REO2
L_STAT-STAT = 'I0229'. APPEND L_STAT TO L_STAT_TAB. "REO1
CALL FUNCTION 'STATUS_OBJECT_CHECK_MULTI'
EXPORTING
OBJNR = P_QALS-OBJNR
TABLES
STATUS_CHECK = L_STAT_TAB.
IF NOT L_STAT_TAB[] IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 4.
ENDIF.
*/SPER
CALL FUNCTION 'STATUS_CHECK'
EXPORTING
OBJNR = P_QALS-OBJNR
STATUS = 'I0043'
EXCEPTIONS
STATUS_NOT_ACTIVE = 2.
IF SY-SUBRC IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 0.
ENDIF.
ENDFORM. " CHECK_LOT
*----
*
Form READ_QAMB *
*----
*
QAMBs lesen *
*----
*
FORM READ_QAMB USING P_QALS LIKE QALS
P_QAMB_TAB TYPE T_QAMB_TAB
P_SUBRC LIKE SY-SUBRC.
CLEAR: P_SUBRC.
SELECT * FROM QAMB INTO TABLE P_QAMB_TAB
Page 26
WHERE PRUEFLOS = P_QALS-PRUEFLOS.
P_SUBRC = SY-SUBRC.
ENDFORM. " READ_QAMB
*----
*
Form READ_MKPF *
*----
*
Read material document header *
*----
*
FORM READ_MKPF USING P_QAMB_TAB TYPE T_QAMB_TAB
P_MKPF_TAB TYPE T_MKPF_TAB
P_SUBRC LIKE SY-SUBRC.
DATA:
BEGIN OF L_MKPF_KEY_TAB OCCURS 0,
MBLNR LIKE MKPF-MBLNR,
MJAHR LIKE MKPF-MJAHR,
END OF L_MKPF_KEY_TAB.
DATA:
L_QAMB LIKE QAMB,
L_MKPF LIKE MKPF,
L_TRTYP LIKE T158-TRTYP VALUE 'A',
L_VGART LIKE T158-VGART VALUE 'WQ',
L_XEXIT LIKE QM00-QKZ.
P_SUBRC = 4.
LOOP AT P_QAMB_TAB INTO L_QAMB.
L_MKPF_KEY_TAB-MBLNR = L_QAMB-MBLNR.
L_MKPF_KEY_TAB-MJAHR = L_QAMB-MJAHR.
COLLECT L_MKPF_KEY_TAB.
ENDLOOP.
LOOP AT L_MKPF_KEY_TAB.
CALL FUNCTION 'ENQUEUE_EMMKPF'
EXPORTING
MBLNR = L_MKPF_KEY_TAB-MBLNR
MJAHR = L_MKPF_KEY_TAB-MJAHR
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
IF NOT SY-SUBRC IS INITIAL.
L_XEXIT = 'X'.
EXIT.
ENDIF.
CLEAR: L_MKPF.
CALL FUNCTION 'MB_READ_MATERIAL_HEADER'
EXPORTING
MBLNR = L_MKPF_KEY_TAB-MBLNR
MJAHR = L_MKPF_KEY_TAB-MJAHR
TRTYP = L_TRTYP
VGART = L_VGART
IMPORTING
KOPF = L_MKPF
Page 27
EXCEPTIONS
ERROR_MESSAGE = 1.
IF NOT SY-SUBRC IS INITIAL.
L_XEXIT = 'X'.
EXIT.
ELSE.
APPEND L_MKPF TO P_MKPF_TAB.
ENDIF.
ENDLOOP.
IF NOT L_XEXIT IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 0.
ENDIF.
ENDFORM. " READ_MKPF
*----
*
Form READ_MSEG *
*----
*
MSEGs lesen *
*----
*
FORM READ_MSEG USING P_MKPF_TAB TYPE T_MKPF_TAB
P_MSEG_TAB TYPE T_MSEG_TAB
P_SUBRC LIKE SY-SUBRC.
DATA:
L_MKPF LIKE MKPF,
L_MSEG_TAB LIKE MSEG OCCURS 0 WITH HEADER LINE,
L_TRTYP LIKE T158-TRTYP VALUE 'A',
L_XEXIT LIKE QM00-QKZ.
P_SUBRC = 4.
LOOP AT P_MKPF_TAB INTO L_MKPF.
CLEAR: L_MSEG_TAB. REFRESH: L_MSEG_TAB.
CALL FUNCTION 'MB_READ_MATERIAL_POSITION'
EXPORTING
MBLNR = L_MKPF-MBLNR
MJAHR = L_MKPF-MJAHR
TRTYP = L_TRTYP
*/ ZEILB = P_ZEILE
*/ ZEILE = P_ZEILE
TABLES
SEQTAB = L_MSEG_TAB
EXCEPTIONS
ERROR_MESSAGE = 1.
IF NOT SY-SUBRC IS INITIAL.
L_XEXIT = 'X'.
EXIT.
ELSE.
APPEND LINES OF L_MSEG_TAB TO P_MSEG_TAB.
ENDIF.
Page 28
ENDLOOP.
IF NOT L_XEXIT IS INITIAL.
EXIT.
ELSE.
*/ XAuto-Zeilen und Chargenzustandsänderung werden gelöscht
DELETE P_MSEG_TAB WHERE XAUTO NE SPACE
OR BWART EQ '341'
OR BWART EQ '342'.
P_SUBRC = 0.
ENDIF.
ENDFORM. " READ_MSEG
*----
*
Form CREATE_GOODS_MOVEMENT *
*----
*
Warenbewegung anlegen *
*----
*
FORM CREATE_GOODS_MOVEMENT USING P_QALS LIKE QALS
P_MSEG_TAB TYPE T_MSEG_TAB
P_SUBRC LIKE SY-SUBRC.
DATA:
L_LMENGEZUB LIKE QALS-LMENGEZUB,
L_LMENGEGEB LIKE QALS-LMENGEZUB,
L_MBQSS LIKE MBQSS,
L_IMKPF LIKE IMKPF,
L_IMSEG LIKE IMSEG,
L_IMSEG_TAB LIKE IMSEG OCCURS 1,
L_EMKPF LIKE EMKPF,
L_EMSEG LIKE EMSEG,
L_EMSEG_TAB LIKE EMSEG OCCURS 1,
L_MSEG LIKE MSEG,
L_MSEG_TAB LIKE MSEG OCCURS 1,
L_TCODE LIKE SY-TCODE VALUE 'QA11',
L_TABIX LIKE SY-TABIX VALUE 1,
L_XSTBW LIKE T156-XSTBW.
CLEAR: P_SUBRC.
*/Kopf füllen
L_IMKPF-BLDAT = SY-DATLO.
L_IMKPF-BUDAT = SY-DATLO.
L_IMKPF-BKTXT = 'Cancellation of QM UD postings'.
*/Ursprüngliche zu buchende Menge merken + inkrementieren
L_LMENGEZUB = P_QALS-LMENGEZUB.
L_LMENGEGEB = P_QALS-LMENGE01
+ P_QALS-LMENGE02
+ P_QALS-LMENGE03
+ P_QALS-LMENGE04
+ P_QALS-LMENGE05
+ P_QALS-LMENGE06
+ P_QALS-LMENGE07
+ P_QALS-LMENGE08
Page 29
+ P_QALS-LMENGE09.
*/Zeilen aufbauen
L_MSEG_TAB[] = P_MSEG_TAB[].
LOOP AT L_MSEG_TAB INTO L_MSEG.
MOVE-CORRESPONDING L_MSEG TO L_MBQSS.
MOVE-CORRESPONDING L_MBQSS TO L_IMSEG.
*/ Referenzbeleg übergeben, falls Bestellnummer gefüllt
IF NOT L_MSEG-EBELN IS INITIAL.
MOVE: L_MSEG-LFBNR TO L_IMSEG-LFBNR,
L_MSEG-LFBJA TO L_IMSEG-LFBJA,
L_MSEG-LFPOS TO L_IMSEG-LFPOS.
ENDIF.
MOVE L_MSEG-KDAUF TO L_IMSEG-KDAUF.
MOVE L_MSEG-KDPOS TO L_IMSEG-KDPOS.
MOVE L_MSEG-PS_PSP_PNR TO L_IMSEG-PS_PSP_PNR.
*/ Umlagerungsfelder setzen
MOVE:
L_MSEG-UMMAT TO L_IMSEG-UMMAT,
L_MSEG-UMWRK TO L_IMSEG-UMWRK,
L_MSEG-UMLGO TO L_IMSEG-UMLGO,
L_MSEG-UMCHA TO L_IMSEG-UMCHA.
*/ Storno-Beleg setzen
MOVE: L_MSEG-MJAHR TO L_IMSEG-SJAHR,
L_MSEG-MBLNR TO L_IMSEG-SMBLN,
L_MSEG-ZEILE TO L_IMSEG-SMBLP.
*/ Falsch gefüllte Felder initialisieren
CLEAR: "L_IMSEG-MBLNR,
L_IMSEG-MENGE,
L_IMSEG-MEINS.
*/ Bewegungsart lesen
SELECT SINGLE XSTBW FROM T156 INTO L_XSTBW
WHERE BWART = L_IMSEG-BWART.
IF NOT SY-SUBRC IS INITIAL.
P_SUBRC = 4.
EXIT.
ENDIF.
*/ Werk/Lagerort füllen
IF L_XSTBW IS INITIAL.
MOVE P_QALS-WERKVORG TO L_IMSEG-WERKS.
MOVE P_QALS-LAGORTVORG TO L_IMSEG-LGORT.
ELSE.
MOVE P_QALS-WERKVORG TO L_IMSEG-UMWRK.
MOVE P_QALS-LAGORTVORG TO L_IMSEG-UMLGO.
ENDIF.
*/ Zusätzliche Felder
MOVE P_QALS-MENGENEINH TO L_IMSEG-ERFME.
"MOVE P_GRUND TO L_IMSEG-GRUND.
"MOVE P_ELIKZ TO L_IMSEG-ELIKZ.
*/ Kennzeichen Storno-Buchung setzen
Page 30
MOVE 'X' TO L_IMSEG-XSTOB.
MOVE P_QALS-PRUEFLOS TO L_IMSEG-QPLOS.
APPEND L_IMSEG TO L_IMSEG_TAB.
ADD L_IMSEG-ERFMG TO L_LMENGEZUB.
SUBTRACT L_IMSEG-ERFMG FROM L_LMENGEGEB.
ENDLOOP.
*/QM deaktivieren
CALL FUNCTION 'QAAT_QM_ACTIVE_INACTIVE'
EXPORTING
AKTIV = SPACE.
*/Buchen
CALL FUNCTION 'MB_CREATE_GOODS_MOVEMENT'
EXPORTING
IMKPF = L_IMKPF
XALLP = 'X'
XALLR = 'X'
CTCOD = L_TCODE
XQMCL = ' '
IMPORTING
EMKPF = L_EMKPF
TABLES
IMSEG = L_IMSEG_TAB
EMSEG = L_EMSEG_TAB.
*/QM wieder aktivieren
CALL FUNCTION 'QAAT_QM_ACTIVE_INACTIVE'
EXPORTING
AKTIV = 'X'.
*/Buchung auswerten
IF NOT L_EMKPF-SUBRC IS INITIAL.
IF L_EMKPF-MSGID NE SPACE.
*/ Fehler auf Kopfebene
MESSAGE ID L_EMKPF-MSGID TYPE 'S'
NUMBER L_EMKPF-MSGNO
WITH L_EMKPF-MSGV1 L_EMKPF-MSGV2
L_EMKPF-MSGV3 L_EMKPF-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ELSE.
*/ Fehler auf Zeilenebene (Ausgabe des ersten Fehlers)
LOOP AT L_EMSEG_TAB INTO L_EMSEG.
IF L_EMSEG-MSGID NE SPACE.
MESSAGE ID L_EMSEG-MSGID TYPE 'S'
NUMBER L_EMSEG-MSGNO
WITH L_EMSEG-MSGV1 L_EMSEG-MSGV2
L_EMSEG-MSGV3 L_EMSEG-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
*/Sonderkorrektur für Frei-An-Frei & WE-Sperr-An-We-Sperr
IF P_QALS-INSMK IS INITIAL.
IF P_QALS-LMENGE01 GE L_LMENGEGEB
AND NOT P_QALS-LMENGE01 IS INITIAL.
ADD L_LMENGEGEB TO L_LMENGEZUB.
Page 31
SUBTRACT L_LMENGEGEB FROM L_LMENGEGEB.
ENDIF.
ENDIF.
CLEAR: P_QALS-STAT34,
P_QALS-MATNRNEU,
P_QALS-CHARGNEU,
P_QALS-LMENGE01,
P_QALS-LMENGE02,
P_QALS-LMENGE03,
P_QALS-LMENGE04,
P_QALS-LMENGE05,
P_QALS-LMENGE06,
P_QALS-LMENGE07,
P_QALS-LMENGE08,
P_QALS-LMENGE09.
P_QALS-LMENGEZUB = L_LMENGEZUB.
IF NOT L_LMENGEGEB IS INITIAL.
P_SUBRC = 4.
ENDIF.
ENDFORM. " CREATE_GOODS_MOVEMENT
*----
*
Form POST_DATA *
*----
*
QM-Daten verbuchen *
*----
*
FORM POST_DATA USING P_QALS LIKE QALS
P_QALS_LEISTE LIKE QALS
P_QAMB_TAB TYPE T_QAMB_TAB
P_QAMB_VB_TAB TYPE T_QAMB_TAB
P_SUBRC LIKE SY-SUBRC.
DATA:
L_QAVE LIKE QAVE,
L_QAVE_LEISTE LIKE QAVE,
L_STAT LIKE JSTAT,
L_STAT_TAB LIKE JSTAT OCCURS 0,
L_QAMB LIKE QAMB,
L_UPDKZ LIKE QALSVB-UPSL VALUE 'U'.
*/QAMBs zum Löschen vormerken
LOOP AT P_QAMB_TAB INTO L_QAMB.
APPEND L_QAMB TO P_QAMB_VB_TAB.
ENDLOOP.
*/BERF & BTEI zurücknehmen
CLEAR L_STAT. CLEAR L_STAT_TAB.
L_STAT-INACT = 'X'.
L_STAT-STAT = 'I0219'. APPEND L_STAT TO L_STAT_TAB. "BTEI
L_STAT-STAT = 'I0220'. APPEND L_STAT TO L_STAT_TAB. "BEND
CALL FUNCTION 'STATUS_CHANGE_INTERN'
EXPORTING
OBJNR = P_QALS-OBJNR
TABLES
Page 32
STATUS = L_STAT_TAB
EXCEPTIONS
ERROR_MESSAGE = 1.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
*/Prüflos aktualisieren
CALL FUNCTION 'QPL1_UPDATE_MEMORY'
EXPORTING
I_QALS = P_QALS
I_UPDKZ = L_UPDKZ.
*/QMIS korrigieren
IF NOT P_QALS-STAT35 IS INITIAL.
SELECT SINGLE * FROM QAVE INTO L_QAVE
WHERE PRUEFLOS = P_QALS-PRUEFLOS
AND KZART = 'L'
AND ZAEHLER = SPACE.
IF NOT SY-SUBRC IS INITIAL.
MESSAGE X248 WITH SPACE.
ELSE.
L_QAVE_LEISTE = L_QAVE.
*/ Änderungsfall
CALL FUNCTION 'MCQ_STATISTICS_USAGEDEC'
EXPORTING
I_XQALS = P_QALS
I_XQAVE = L_QAVE
I_YQALS = P_QALS_LEISTE
I_YQAVE = L_QAVE_LEISTE
EXCEPTIONS
NO_CHANGES = 0
NO_UPDATE = 0
UPDATE_NOT_ACTIVATED = 0
ERROR_MESSAGE = 0.
ENDIF.
ENDIF.
CALL FUNCTION 'QPL1_INSPECTION_LOTS_POSTING'.
PERFORM DELETE_QAMB ON COMMIT.
P_SUBRC = 0.
ENDFORM. " POST_DATA
*----
*
Form DELETE_QAMB *
*----
*
Update auf QAMB - ST *
*----
*
FORM DELETE_QAMB.
CALL FUNCTION 'ZQMB_QAMB_CANCEL' IN UPDATE TASK
TABLES
Page 33
I_QAMB_TAB = G_QAMB_VB_TAB.
ENDFORM. " DELETE_QAMB
*----
*
Form CHECK_MSEG *
*----
*
MSEGs prüfen *
*----
*
FORM CHECK_MSEG USING P_MSEG_TAB TYPE T_MSEG_TAB
P_QAMB_TAB TYPE T_QAMB_TAB
P_SUBRC LIKE SY-SUBRC.
DATA:
L_MSEG_STOR_TAB LIKE MSEG OCCURS 0 WITH HEADER LINE.
CLEAR: P_SUBRC.
*/Zeilen bereits storniert?
SELECT MBLNR MJAHR ZEILE SMBLN SJAHR SMBLP
FROM MSEG INTO CORRESPONDING FIELDS OF TABLE L_MSEG_STOR_TAB
FOR ALL ENTRIES IN P_MSEG_TAB
WHERE SMBLN EQ P_MSEG_TAB-MBLNR
AND SJAHR EQ P_MSEG_TAB-MJAHR
AND SMBLP EQ P_MSEG_TAB-ZEILE.
IF SY-SUBRC IS INITIAL.
LOOP AT L_MSEG_STOR_TAB.
DELETE P_MSEG_TAB WHERE MBLNR = L_MSEG_STOR_TAB-SMBLN
AND MJAHR = L_MSEG_STOR_TAB-SJAHR
AND ZEILE = L_MSEG_STOR_TAB-SMBLP.
DELETE P_QAMB_TAB WHERE MBLNR = L_MSEG_STOR_TAB-SMBLN
AND MJAHR = L_MSEG_STOR_TAB-SJAHR
AND ZEILE = L_MSEG_STOR_TAB-SMBLP.
ENDLOOP.
IF P_MSEG_TAB[] IS INITIAL.
P_SUBRC = 4.
EXIT.
ENDIF.
ENDIF.
ENDFORM. " CHECK_MSEG
*----
*
Form CHECK_MKPF *
*----
*
Materialbelege prüfen (Wurde durch VE-Buchung Prüflos erzeugt? *
*----
*
FORM CHECK_MKPF USING P_MKPF_TAB TYPE T_MKPF_TAB
P_SUBRC LIKE SY-SUBRC.
DATA:
L_MKPF_TAB TYPE T_MKPF_TAB.
CLEAR: P_SUBRC.
SELECT MBLNR FROM QALS INTO CORRESPONDING FIELDS OF TABLE L_MKPF_TAB
FOR ALL ENTRIES IN P_MKPF_TAB
WHERE MBLNR EQ P_MKPF_TAB-MBLNR
Page 34
AND MJAHR EQ P_MKPF_TAB-MJAHR.
IF SY-SUBRC IS INITIAL.
P_SUBRC = 4.
ENDIF.
ENDFORM. " CHECK_MKPF
*>>>> END OF INSERTION <<<<<<
...
*&----
*
Page 35
$$----
-
$$
$ Correction Instr. : 0120061532 0000298389 $
$ Software Component : SAP_APPL SAP Application $
*$----
$*
$ Validity : 46A SAPKH46A01 - SAPKH46A34 $
$ : 46B All Patches $
$ : 46C All Patches $
*$----
$*
$ Changes/Objects Not Contained in Standard SAP System $
$$----
-
$$
*&----
*
*& Object REPS RQEVAC50
*& Object Header PROG RQEVAC50
*&----
*
*& REPORT RQEVAC50
*&----
*
*>>>> START OF INSERTION <<<<
REPORT RQEVAC50 MESSAGE-ID QA.
TYPES:
T_QAMB_TAB LIKE QAMB OCCURS 0,
T_MKPF_TAB LIKE MKPF OCCURS 0,
T_MSEG_TAB LIKE MSEG OCCURS 0.
PARAMETERS:
PRUEFLOS LIKE QALS-PRUEFLOS OBLIGATORY MEMORY ID QLS.
DATA:
G_MSGV1 LIKE SY-MSGV1,
G_QALS LIKE QALS,
G_QALS_LEISTE LIKE QALS,
G_QAMB_TAB TYPE T_QAMB_TAB,
G_QAMB_VB_TAB TYPE T_QAMB_TAB,
G_MKPF_TAB TYPE T_MKPF_TAB,
G_MSEG_TAB TYPE T_MSEG_TAB,
G_SUBRC LIKE SY-SUBRC.
START-OF-SELECTION.
PERFORM ENQUEUE_QALS USING PRUEFLOS
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM READ_QALS USING PRUEFLOS
G_QALS
G_QALS_LEISTE
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID 'QA' TYPE 'S' NUMBER '102'
WITH PRUEFLOS.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
Page 36
PERFORM CHECK_LOT USING G_QALS
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
CASE G_SUBRC.
WHEN 256.
G_MSGV1 = 'Lot & does not refer to a material doc'.
WHEN 128.
G_MSGV1 = 'Material & is serialized'.
REPLACE '&' WITH G_QALS-MATNR INTO G_MSGV1.
WHEN 64.
G_MSGV1 = 'Lot & is not stock relevant'.
WHEN 32.
G_MSGV1 = 'Lot &: No stock transferred'.
WHEN 16.
G_MSGV1 = 'Lot & is cancelled'.
WHEN 8.
G_MSGV1 = 'Lot & is archived'.
WHEN 4.
G_MSGV1 = 'Lot & is blocked'.
WHEN 2.
G_MSGV1 = 'Lot & is HU managed'.
ENDCASE.
REPLACE '&' WITH PRUEFLOS INTO G_MSGV1.
MESSAGE ID '00' TYPE 'S' NUMBER '208'
WITH G_MSGV1.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM READ_QAMB USING G_QALS
G_QAMB_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID 'QA' TYPE 'S' NUMBER '068'
WITH PRUEFLOS.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM READ_MKPF USING G_QAMB_TAB
G_MKPF_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM CHECK_MKPF USING G_MKPF_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID 'QA' TYPE 'S' NUMBER '068'
WITH PRUEFLOS.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM READ_MSEG USING G_MKPF_TAB
G_MSEG_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
Page 37
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM CHECK_MSEG USING G_MSEG_TAB
G_QAMB_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID 'QA' TYPE 'S' NUMBER '068'
WITH PRUEFLOS.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM CREATE_GOODS_MOVEMENT USING G_QALS
G_MSEG_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID 'QA' TYPE 'S' NUMBER '068'
WITH PRUEFLOS.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
PERFORM POST_GOODS_MOVEMENT.
PERFORM POST_DATA USING G_QALS
G_QALS_LEISTE
G_QAMB_TAB
G_QAMB_VB_TAB
G_SUBRC.
IF NOT G_SUBRC IS INITIAL.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ELSE.
COMMIT WORK AND WAIT.
G_MSGV1 = 'inspection lot &'.
REPLACE '&' WITH PRUEFLOS INTO G_MSGV1.
MESSAGE ID '00' TYPE 'S' NUMBER '368'
WITH 'Stock posting reversed for ' G_MSGV1.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
*----
*
Form ENQUEUE_QALS *
*----
*
Los sperren *
*----
*
FORM ENQUEUE_QALS USING P_PRUEFLOS LIKE QALS-PRUEFLOS
P_SUBRC LIKE SY-SUBRC.
CLEAR: P_SUBRC.
CALL FUNCTION 'ENQUEUE_EQQALS1'
EXPORTING
PRUEFLOS = P_PRUEFLOS
EXCEPTIONS
Page 38
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
P_SUBRC = SY-SUBRC.
ENDFORM. " ENQUEUE_QALS
*----
*
Form READ_QALS *
*----
*
Prüflos lesen *
*----
*
FORM READ_QALS USING P_PRUEFLOS LIKE QALS-PRUEFLOS
P_QALS LIKE QALS
P_QALS_LEISTE LIKE QALS
P_SUBRC LIKE SY-SUBRC.
CLEAR: P_SUBRC.
CALL FUNCTION 'QPSE_LOT_READ'
EXPORTING
I_PRUEFLOS = P_PRUEFLOS
I_RESET_LOT = 'X'
IMPORTING
E_QALS = P_QALS
EXCEPTIONS
NO_LOT = 1.
P_SUBRC = SY-SUBRC.
IF P_SUBRC IS INITIAL.
P_QALS_LEISTE = P_QALS.
ELSE.
CLEAR: P_QALS,
P_QALS_LEISTE.
ENDIF.
ENDFORM. " READ_QALS
*----
*
Form CHECK_LOT *
*----
*
Prüflos prüfen *
*----
*
FORM CHECK_LOT USING P_QALS LIKE QALS
P_SUBRC LIKE SY-SUBRC.
DATA:
L_STAT LIKE JSTAT,
L_STAT_TAB LIKE JSTAT OCCURS 0 WITH HEADER LINE.
P_SUBRC = 256.
*/No reference to material document
IF P_QALS-ZEILE IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 128.
Page 39
ENDIF.
*/Serialized Material
IF NOT P_QALS-SERNP IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 64.
ENDIF.
*/BERF
CALL FUNCTION 'STATUS_CHECK'
EXPORTING
OBJNR = P_QALS-OBJNR
STATUS = 'I0203'
EXCEPTIONS
STATUS_NOT_ACTIVE = 2.
IF NOT SY-SUBRC IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 32.
ENDIF.
*/BTEI & BEND
CLEAR L_STAT. CLEAR L_STAT_TAB. REFRESH L_STAT_TAB.
L_STAT-STAT = 'I0219'. APPEND L_STAT TO L_STAT_TAB. "BTEI
L_STAT-STAT = 'I0220'. APPEND L_STAT TO L_STAT_TAB. "BEND
CALL FUNCTION 'STATUS_OBJECT_CHECK_MULTI'
EXPORTING
OBJNR = P_QALS-OBJNR
TABLES
STATUS_CHECK = L_STAT_TAB.
IF L_STAT_TAB[] IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 16.
ENDIF.
*/LSTO & LSTV
CLEAR L_STAT. CLEAR L_STAT_TAB. REFRESH L_STAT_TAB.
L_STAT-STAT = 'I0224'. APPEND L_STAT TO L_STAT_TAB. "LSTO
L_STAT-STAT = 'I0232'. APPEND L_STAT TO L_STAT_TAB. "LSTV
CALL FUNCTION 'STATUS_OBJECT_CHECK_MULTI'
EXPORTING
OBJNR = P_QALS-OBJNR
TABLES
STATUS_CHECK = L_STAT_TAB.
IF NOT L_STAT_TAB[] IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 8.
ENDIF.
Page 40
*/ARSP & ARCH & REO1 & REO2 & REO3
CLEAR L_STAT. CLEAR L_STAT_TAB. REFRESH L_STAT_TAB.
L_STAT-STAT = 'I0225'. APPEND L_STAT TO L_STAT_TAB. "ARSP
L_STAT-STAT = 'I0226'. APPEND L_STAT TO L_STAT_TAB. "ARCH
L_STAT-STAT = 'I0227'. APPEND L_STAT TO L_STAT_TAB. "REO3
L_STAT-STAT = 'I0228'. APPEND L_STAT TO L_STAT_TAB. "REO2
L_STAT-STAT = 'I0229'. APPEND L_STAT TO L_STAT_TAB. "REO1
CALL FUNCTION 'STATUS_OBJECT_CHECK_MULTI'
EXPORTING
OBJNR = P_QALS-OBJNR
TABLES
STATUS_CHECK = L_STAT_TAB.
IF NOT L_STAT_TAB[] IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 4.
ENDIF.
*/SPER
CALL FUNCTION 'STATUS_CHECK'
EXPORTING
OBJNR = P_QALS-OBJNR
STATUS = 'I0043'
EXCEPTIONS
STATUS_NOT_ACTIVE = 2.
IF SY-SUBRC IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 2.
ENDIF.
*/HUM
CALL FUNCTION 'STATUS_CHECK'
EXPORTING
OBJNR = P_QALS-OBJNR
STATUS = 'I0443'
EXCEPTIONS
STATUS_NOT_ACTIVE = 2.
IF SY-SUBRC IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 0.
ENDIF.
ENDFORM. " CHECK_LOT
*----
*
Form READ_QAMB *
*----
*
QAMBs lesen *
*----
*
FORM READ_QAMB USING P_QALS LIKE QALS
P_QAMB_TAB TYPE T_QAMB_TAB
Page 41
P_SUBRC LIKE SY-SUBRC.
CLEAR: P_SUBRC.
SELECT * FROM QAMB INTO TABLE P_QAMB_TAB
WHERE PRUEFLOS = P_QALS-PRUEFLOS
AND TYP = '3'.
P_SUBRC = SY-SUBRC.
ENDFORM. " READ_QAMB
*----
*
Form READ_MKPF *
*----
*
Read material document header *
*----
*
FORM READ_MKPF USING P_QAMB_TAB TYPE T_QAMB_TAB
P_MKPF_TAB TYPE T_MKPF_TAB
P_SUBRC LIKE SY-SUBRC.
DATA:
BEGIN OF L_MKPF_KEY_TAB OCCURS 0,
MBLNR LIKE MKPF-MBLNR,
MJAHR LIKE MKPF-MJAHR,
END OF L_MKPF_KEY_TAB.
DATA:
L_QAMB LIKE QAMB,
L_MKPF LIKE MKPF,
L_TRTYP LIKE T158-TRTYP VALUE 'A',
L_VGART LIKE T158-VGART VALUE 'WQ',
L_XEXIT LIKE QM00-QKZ.
P_SUBRC = 4.
LOOP AT P_QAMB_TAB INTO L_QAMB.
L_MKPF_KEY_TAB-MBLNR = L_QAMB-MBLNR.
L_MKPF_KEY_TAB-MJAHR = L_QAMB-MJAHR.
COLLECT L_MKPF_KEY_TAB.
ENDLOOP.
LOOP AT L_MKPF_KEY_TAB.
CALL FUNCTION 'ENQUEUE_EMMKPF'
EXPORTING
MBLNR = L_MKPF_KEY_TAB-MBLNR
MJAHR = L_MKPF_KEY_TAB-MJAHR
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
IF NOT SY-SUBRC IS INITIAL.
L_XEXIT = 'X'.
EXIT.
ENDIF.
CLEAR: L_MKPF.
CALL FUNCTION 'MB_READ_MATERIAL_HEADER'
EXPORTING
Page 42
MBLNR = L_MKPF_KEY_TAB-MBLNR
MJAHR = L_MKPF_KEY_TAB-MJAHR
TRTYP = L_TRTYP
VGART = L_VGART
IMPORTING
KOPF = L_MKPF
EXCEPTIONS
ERROR_MESSAGE = 1.
IF NOT SY-SUBRC IS INITIAL.
L_XEXIT = 'X'.
EXIT.
ELSE.
APPEND L_MKPF TO P_MKPF_TAB.
ENDIF.
ENDLOOP.
IF NOT L_XEXIT IS INITIAL.
EXIT.
ELSE.
P_SUBRC = 0.
ENDIF.
ENDFORM. " READ_MKPF
*----
*
Form READ_MSEG *
*----
*
MSEGs lesen *
*----
*
FORM READ_MSEG USING P_MKPF_TAB TYPE T_MKPF_TAB
P_MSEG_TAB TYPE T_MSEG_TAB
P_SUBRC LIKE SY-SUBRC.
DATA:
L_MKPF LIKE MKPF,
L_MSEG_TAB LIKE MSEG OCCURS 0 WITH HEADER LINE,
L_TRTYP LIKE T158-TRTYP VALUE 'A',
L_XEXIT LIKE QM00-QKZ.
P_SUBRC = 4.
LOOP AT P_MKPF_TAB INTO L_MKPF.
CLEAR: L_MSEG_TAB. REFRESH: L_MSEG_TAB.
CALL FUNCTION 'MB_READ_MATERIAL_POSITION'
EXPORTING
MBLNR = L_MKPF-MBLNR
MJAHR = L_MKPF-MJAHR
TRTYP = L_TRTYP
*/ ZEILB = P_ZEILE
*/ ZEILE = P_ZEILE
TABLES
SEQTAB = L_MSEG_TAB
EXCEPTIONS
ERROR_MESSAGE = 1.
Page 43
IF NOT SY-SUBRC IS INITIAL.
L_XEXIT = 'X'.
EXIT.
ELSE.
APPEND LINES OF L_MSEG_TAB TO P_MSEG_TAB.
ENDIF.
ENDLOOP.
IF NOT L_XEXIT IS INITIAL.
EXIT.
ELSE.
*/ XAuto-Zeilen und Chargenzustandsänderung werden gelöscht
DELETE P_MSEG_TAB WHERE XAUTO NE SPACE
OR BWART EQ '341'
OR BWART EQ '342'.
P_SUBRC = 0.
ENDIF.
ENDFORM. " READ_MSEG
*----
*
Form CREATE_GOODS_MOVEMENT *
*----
*
Warenbewegung anlegen *
*----
*
FORM CREATE_GOODS_MOVEMENT USING P_QALS LIKE QALS
P_MSEG_TAB TYPE T_MSEG_TAB
P_SUBRC LIKE SY-SUBRC.
DATA:
L_LMENGEZUB LIKE QALS-LMENGEZUB,
L_LMENGEGEB LIKE QALS-LMENGEZUB,
L_MBQSS LIKE MBQSS,
L_IMKPF LIKE IMKPF,
L_IMSEG LIKE IMSEG,
L_IMSEG_TAB LIKE IMSEG OCCURS 1,
L_EMKPF LIKE EMKPF,
L_EMSEG LIKE EMSEG,
L_EMSEG_TAB LIKE EMSEG OCCURS 1,
L_MSEG LIKE MSEG,
L_MSEG_TAB LIKE MSEG OCCURS 1,
L_TCODE LIKE SY-TCODE VALUE 'QA11',
L_TABIX LIKE SY-TABIX VALUE 1,
L_XSTBW LIKE T156-XSTBW.
CLEAR: P_SUBRC.
*/QAMB initialisieren
CALL FUNCTION 'QAMB_REFRESH_DATA'.
*/Kopf füllen
L_IMKPF-BLDAT = SY-DATLO.
L_IMKPF-BUDAT = SY-DATLO.
L_IMKPF-BKTXT = 'Cancellation of QM UD postings'.
*/Ursprüngliche zu buchende Menge merken + inkrementieren
Page 44
L_LMENGEZUB = P_QALS-LMENGEZUB.
L_LMENGEGEB = P_QALS-LMENGE01
+ P_QALS-LMENGE02
+ P_QALS-LMENGE03
+ P_QALS-LMENGE04
+ P_QALS-LMENGE05
+ P_QALS-LMENGE06
+ P_QALS-LMENGE07
+ P_QALS-LMENGE08
+ P_QALS-LMENGE09.
*/Zeilen aufbauen
L_MSEG_TAB[] = P_MSEG_TAB[].
LOOP AT L_MSEG_TAB INTO L_MSEG.
MOVE-CORRESPONDING L_MSEG TO L_MBQSS.
MOVE-CORRESPONDING L_MBQSS TO L_IMSEG.
*/ Referenzbeleg übergeben, falls Bestellnummer gefüllt
IF NOT L_MSEG-EBELN IS INITIAL.
MOVE: L_MSEG-LFBNR TO L_IMSEG-LFBNR,
L_MSEG-LFBJA TO L_IMSEG-LFBJA,
L_MSEG-LFPOS TO L_IMSEG-LFPOS.
ENDIF.
MOVE L_MSEG-KDAUF TO L_IMSEG-KDAUF.
MOVE L_MSEG-KDPOS TO L_IMSEG-KDPOS.
MOVE L_MSEG-PS_PSP_PNR TO L_IMSEG-PS_PSP_PNR.
*/ Umlagerungsfelder setzen
MOVE:
L_MSEG-UMMAT TO L_IMSEG-UMMAT,
L_MSEG-UMWRK TO L_IMSEG-UMWRK,
L_MSEG-UMLGO TO L_IMSEG-UMLGO,
L_MSEG-UMCHA TO L_IMSEG-UMCHA.
*/ Storno-Beleg setzen
MOVE: L_MSEG-MJAHR TO L_IMSEG-SJAHR,
L_MSEG-MBLNR TO L_IMSEG-SMBLN,
L_MSEG-ZEILE TO L_IMSEG-SMBLP.
*/ Falsch gefüllte Felder initialisieren
CLEAR: L_IMSEG-MBLNR,
L_IMSEG-MENGE,
L_IMSEG-MEINS.
*/ Bewegungsart lesen
SELECT SINGLE XSTBW FROM T156 INTO L_XSTBW
WHERE BWART = L_IMSEG-BWART.
IF NOT SY-SUBRC IS INITIAL.
P_SUBRC = 4.
EXIT.
ENDIF.
*/ Werk/Lagerort füllen
IF P_QALS-STAT11 IS INITIAL.
IF L_XSTBW IS INITIAL.
MOVE P_QALS-LAGORTVORG TO L_IMSEG-LGORT.
Page 45
ELSE.
MOVE P_QALS-LAGORTVORG TO L_IMSEG-UMLGO.
ENDIF.
ENDIF.
IF L_XSTBW IS INITIAL.
MOVE P_QALS-WERKVORG TO L_IMSEG-WERKS.
ELSE.
MOVE P_QALS-WERKVORG TO L_IMSEG-UMWRK.
ENDIF.
*/ Zusätzliche Felder
MOVE P_QALS-MENGENEINH TO L_IMSEG-ERFME.
"MOVE P_GRUND TO L_IMSEG-GRUND.
"MOVE P_ELIKZ TO L_IMSEG-ELIKZ.
*/ Kennzeichen Storno-Buchung setzen
MOVE 'X' TO L_IMSEG-XSTOB.
MOVE P_QALS-PRUEFLOS TO L_IMSEG-QPLOS.
APPEND L_IMSEG TO L_IMSEG_TAB.
IF P_QALS-STAT11 IS INITIAL.
ADD L_IMSEG-ERFMG TO L_LMENGEZUB.
SUBTRACT L_IMSEG-ERFMG FROM L_LMENGEGEB.
ELSE.
IF L_IMSEG-KZBEW EQ SPACE
AND L_IMSEG-WERKS NE SPACE
AND L_IMSEG-LGORT NE SPACE
AND L_IMSEG-UMWRK NE SPACE
AND L_IMSEG-UMLGO NE SPACE
AND L_IMSEG-WERKS EQ L_IMSEG-UMWRK
AND L_IMSEG-UMLGO EQ L_IMSEG-UMLGO.
*/ Dummy Buchung bei WE-Sperrbestand & Stichprobe
ELSE.
ADD L_IMSEG-ERFMG TO L_LMENGEZUB.
SUBTRACT L_IMSEG-ERFMG FROM L_LMENGEGEB.
ENDIF.
ENDIF.
ENDLOOP.
IF NOT P_QALS-STAT11 IS INITIAL.
*/ Bei WE-Sperrbestand und Stichprobenbuchung Zeilen tauschen
DO.
READ TABLE L_IMSEG_TAB INDEX SY-INDEX INTO L_IMSEG.
IF SY-SUBRC IS INITIAL
AND L_IMSEG-KZBEW EQ SPACE
AND L_IMSEG-WERKS NE SPACE
AND L_IMSEG-LGORT NE SPACE
AND L_IMSEG-UMWRK NE SPACE
AND L_IMSEG-UMLGO NE SPACE
AND L_IMSEG-WERKS EQ L_IMSEG-UMWRK
AND L_IMSEG-UMLGO EQ L_IMSEG-UMLGO.
IF SY-TABIX NE L_TABIX.
DELETE L_IMSEG_TAB INDEX SY-TABIX.
INSERT L_IMSEG INTO L_IMSEG_TAB INDEX L_TABIX.
L_TABIX = L_TABIX + 1.
ELSE.
L_TABIX = L_TABIX + 1.
CONTINUE.
Page 46
ENDIF.
ELSEIF SY-SUBRC IS INITIAL.
CONTINUE.
ELSE.
EXIT. "from do
ENDIF.
ENDDO.
ENDIF.
*/QM deaktivieren
CALL FUNCTION 'QAAT_QM_ACTIVE_INACTIVE'
EXPORTING
AKTIV = SPACE.
*/Buchen
CALL FUNCTION 'MB_CREATE_GOODS_MOVEMENT'
EXPORTING
IMKPF = L_IMKPF
XALLP = 'X'
XALLR = 'X'
CTCOD = L_TCODE
XQMCL = ' '
IMPORTING
EMKPF = L_EMKPF
TABLES
IMSEG = L_IMSEG_TAB
EMSEG = L_EMSEG_TAB.
*/QM wieder aktivieren
CALL FUNCTION 'QAAT_QM_ACTIVE_INACTIVE'
EXPORTING
AKTIV = 'X'.
*/Buchung auswerten
IF L_EMKPF-SUBRC GT 1.
IF L_EMKPF-MSGID NE SPACE.
*/ Fehler auf Kopfebene
MESSAGE ID L_EMKPF-MSGID TYPE 'S'
NUMBER L_EMKPF-MSGNO
WITH L_EMKPF-MSGV1 L_EMKPF-MSGV2
L_EMKPF-MSGV3 L_EMKPF-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ELSE.
*/ Fehler auf Zeilenebene (Ausgabe des ersten Fehlers)
LOOP AT L_EMSEG_TAB INTO L_EMSEG.
IF L_EMSEG-MSGID NE SPACE.
MESSAGE ID L_EMSEG-MSGID TYPE 'S'
NUMBER L_EMSEG-MSGNO
WITH L_EMSEG-MSGV1 L_EMSEG-MSGV2
L_EMSEG-MSGV3 L_EMSEG-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
LOOP AT L_EMSEG_TAB INTO L_EMSEG.
CALL FUNCTION 'QAMB_COLLECT_RECORD'
EXPORTING
LOTNUMBER = P_QALS-PRUEFLOS
Page 47
DOCYEAR = L_EMKPF-MJAHR
DOCNUMBER = L_EMKPF-MBLNR
DOCPOSITION = L_EMSEG-MBLPO
TYPE = '7'.
ENDLOOP.
*/Sonderkorrektur für Frei-An-Frei & WE-Sperr-An-We-Sperr
IF NOT P_QALS-STAT11 IS INITIAL.
IF P_QALS-LMENGE04 EQ L_LMENGEGEB.
ADD P_QALS-LMENGE04 TO L_LMENGEZUB.
SUBTRACT P_QALS-LMENGE04 FROM L_LMENGEGEB.
ENDIF.
ELSEIF P_QALS-INSMK IS INITIAL.
IF P_QALS-LMENGE01 GE L_LMENGEGEB
AND NOT P_QALS-LMENGE01 IS INITIAL.
ADD L_LMENGEGEB TO L_LMENGEZUB.
SUBTRACT L_LMENGEGEB FROM L_LMENGEGEB.
ENDIF.
ENDIF.
CLEAR: P_QALS-STAT34,
P_QALS-MATNRNEU,
P_QALS-CHARGNEU,
P_QALS-LMENGE01,
P_QALS-LMENGE02,
P_QALS-LMENGE03,
P_QALS-LMENGE04,
P_QALS-LMENGE05,
P_QALS-LMENGE06,
P_QALS-LMENGE07,
P_QALS-LMENGE08,
P_QALS-LMENGE09.
P_QALS-LMENGEZUB = L_LMENGEZUB.
IF NOT L_LMENGEGEB IS INITIAL.
P_SUBRC = 4.
ENDIF.
ENDFORM. " CREATE_GOODS_MOVEMENT
*----
*
Form POST_GOODS_MOVEMENT *
*----
*
Warenbewegung buchen *
*----
*
FORM POST_GOODS_MOVEMENT.
CALL FUNCTION 'MB_POST_GOODS_MOVEMENT'.
ENDFORM. " POST_GOODS_MOVEMENT
*----
*
Form POST_DATA *
*----
*
QM-Daten verbuchen *
*----
*
FORM POST_DATA USING P_QALS LIKE QALS
P_QALS_LEISTE LIKE QALS
Page 48
P_QAMB_TAB TYPE T_QAMB_TAB
P_QAMB_VB_TAB TYPE T_QAMB_TAB
P_SUBRC LIKE SY-SUBRC.
DATA:
L_STAT LIKE JSTAT,
L_STAT_TAB LIKE JSTAT OCCURS 0,
L_QAMB LIKE QAMB,
L_UPDKZ LIKE QALSVB-UPSL VALUE 'U'.
*/QAMBs umsetzen (7 = VE-Buchung storniert)
LOOP AT P_QAMB_TAB INTO L_QAMB.
L_QAMB-TYP = '7'.
APPEND L_QAMB TO P_QAMB_VB_TAB.
ENDLOOP.
*/BERF & BTEI zurücknehmen
CLEAR L_STAT. CLEAR L_STAT_TAB.
L_STAT-INACT = 'X'.
L_STAT-STAT = 'I0219'. APPEND L_STAT TO L_STAT_TAB. "BTEI
L_STAT-STAT = 'I0220'. APPEND L_STAT TO L_STAT_TAB. "BEND
CALL FUNCTION 'STATUS_CHANGE_INTERN'
EXPORTING
OBJNR = P_QALS-OBJNR
TABLES
STATUS = L_STAT_TAB
EXCEPTIONS
ERROR_MESSAGE = 1.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
SUBMIT (SY-REPID) VIA SELECTION-SCREEN.
ENDIF.
*/Prüflos aktualisieren
CALL FUNCTION 'QPL1_UPDATE_MEMORY'
EXPORTING
I_QALS = P_QALS
I_UPDKZ = L_UPDKZ.
CALL FUNCTION 'QPL1_INSPECTION_LOTS_POSTING'
EXPORTING
I_MODE = '1'.
CALL FUNCTION 'STATUS_UPDATE_ON_COMMIT'.
*/QAMB initialisieren
CALL FUNCTION 'QAMB_REFRESH_DATA'.
PERFORM UPDATE_QAMB ON COMMIT.
P_SUBRC = 0.
ENDFORM. " POST_DATA
*----
*
Page 49
Form UPDATE_QAMB *
*----
*
Update auf QAMB *
*----
*
FORM UPDATE_QAMB.
CALL FUNCTION 'QEVA_QAMB_CANCEL' IN UPDATE TASK
EXPORTING
T_QAMB_TAB = G_QAMB_VB_TAB.
ENDFORM. " UPDATE_QAMB
*----
*
Form CHECK_MSEG *
*----
*
MSEGs prüfen *
*----
*
FORM CHECK_MSEG USING P_MSEG_TAB TYPE T_MSEG_TAB
P_QAMB_TAB TYPE T_QAMB_TAB
P_SUBRC LIKE SY-SUBRC.
DATA:
L_MSEG_STOR_TAB LIKE MSEG OCCURS 0 WITH HEADER LINE.
CLEAR: P_SUBRC.
*/Zeilen bereits storniert?
SELECT MBLNR MJAHR ZEILE SMBLN SJAHR SMBLP
FROM MSEG INTO CORRESPONDING FIELDS OF TABLE L_MSEG_STOR_TAB
FOR ALL ENTRIES IN P_MSEG_TAB
WHERE SMBLN EQ P_MSEG_TAB-MBLNR
AND SJAHR EQ P_MSEG_TAB-MJAHR
AND SMBLP EQ P_MSEG_TAB-ZEILE.
IF SY-SUBRC IS INITIAL.
LOOP AT L_MSEG_STOR_TAB.
DELETE P_MSEG_TAB WHERE MBLNR = L_MSEG_STOR_TAB-SMBLN
AND MJAHR = L_MSEG_STOR_TAB-SJAHR
AND ZEILE = L_MSEG_STOR_TAB-SMBLP.
DELETE P_QAMB_TAB WHERE MBLNR = L_MSEG_STOR_TAB-SMBLN
AND MJAHR = L_MSEG_STOR_TAB-SJAHR
AND ZEILE = L_MSEG_STOR_TAB-SMBLP.
ENDLOOP.
IF P_MSEG_TAB[] IS INITIAL.
P_SUBRC = 4.
EXIT.
ENDIF.
ENDIF.
ENDFORM. " CHECK_MSEG
*----
*
Form CHECK_MKPF *
*----
*
Materialbelege prüfen (Wurde durch VE-Buchung Prüfllos erzeugt?*
*----
*
FORM CHECK_MKPF USING P_MKPF_TAB TYPE T_MKPF_TAB
P_SUBRC LIKE SY-SUBRC.
Page 50
DATA:
L_MKPF_TAB TYPE T_MKPF_TAB.
CLEAR: P_SUBRC.
SELECT MBLNR FROM QAMB INTO CORRESPONDING FIELDS OF TABLE L_MKPF_TAB
FOR ALL ENTRIES IN P_MKPF_TAB
WHERE MBLNR EQ P_MKPF_TAB-MBLNR
AND MJAHR EQ P_MKPF_TAB-MJAHR
AND TYP = '1'.
IF SY-SUBRC IS INITIAL.
P_SUBRC = 4.
ENDIF.
ENDFORM. " CHECK_MKPF
*>>>> END OF INSERTION <<<<<<
...
*&----
*
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In the case of Purchase Rejection, Our quality person transfered the rejected material in return delivery stock (with the T-Code QA32). Here we are unable to pick this material during the creation of MIGO (As Return Delivery), becoz there are we can pick the material only from Unrestricted / blocked ot In Quality Stock.
Is there any way to transfer the material from Return Delivery Stock to Blocked or Unrestricted or In Quality Stock?
Please help.
Thanx in advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
Reversal of usage decision as such is not possible, what i mean is once the UD is made and stock has been posted we cannot the reverse the UD for the same document.If you do a material stock reversal it will create a new lot and there can be no link for the previous lot.
However if your problem is only to bring back the stock to quality even though a new lot is created then go by the replies what u got,
but if you need the same lot with all the qauntities and documents to be reversed then it is possible to do with a user exit.
Regards
Ananth Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
implemet report RQEVAC50 in OSS note 175842.
Bye,
Matteo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shiv Shankar,
As per my understanding we cannot reverse the UD for the inspection lot.....but you can move the material back through manual goods movement & then create a new insoection lot manually.........
Please reward points if helpful.......
Regards
Kaushik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can create a manual inspection lot using QA01 transaction with an appropriate inspection type like 09-Recurring inspection, 89-Miscelleanous.
First you have to activate these inspection types to the material in material master and then create inspection lot manually.
Hope this helps you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.