2007 Aug 29 9:24 PM
1) Query LQUA for the EDATU ( Todays date) Time (EZEIT) for the last 20 minutes from the current time.
2) Extract all the LQUA-MATNR for the warshe ( 754) plant 0054 sloc - LGORT. Also, extract SUID ( LENUM) and available quantity (VERME) , Storage bin - LGPLA. Store them in the internal table ( Only the confirmed TO). The -LEIN-STATU should be blank . or LQUA-VERME should not be blank.
3) In the previous step the REMAN data was extracted for the use in the next steps.
4) Compare the LQUA-MATNR with the REMAN material no ( From Custom table ZCORE_1 Relation ship matrix)
5) Extract the records which are matching and also add the Dummy finish part from the custom table ZCORE_1 in the internal table
6) Call BAPI- BAPI_GOODSMVT_CREATE ( movement type- 919) to process material to material transfer. Receiving material is Dummy finish part no , rcvng sloc and rcvng plant are the same as REMAN. ( plant 0054)
7) Get the material document created from the previous step and store it
8) Query table LUBU by LUBU-MBLNR ( mat doc no from previous step), LUBU-BDATU ( Todays date), LUBU-BWART ( 919) and extract the posting change no ( LUBU-UBNUM).
9) Use the function module - L_TO_Create_Posting_Change with the (LUBU-UBNUM) created in the previous step. Use 922 (TR-ZONE) for the source bin to process the posting change ( use the information of the SUID, Source bin, SUT type etc from step 1)
10) Populate the table ZCORE_2 with the processed items. REMAN no, Qty, SU ID, Dummy finish part, CAM serial no. The CAM serial no is extracted form the BCS interface table ZY310 ( by querying against the REMAN / SU Id no)
Note: The Vrgn Bld flag is maintained for the vrgn bld process ( Refere functional spec Mat to mat transfer_Rework and Vrgn.doc)
11) Collect the Record information form the previous step, Change the BCS table fields MATNR and ZBARCODE = concatenate BCS|MATNR|EXIDV02 with the dummy part no in for the following tables - ZYBKP, ZY310 , ZYBCS_LOT
FOR THE ABOVE TASK, I WRITTEN THE BELOW PROGRAM, IT IS SYNTATICALL CORRECT, BUT I'M NOT GETTING THE RESULT, CAN ANY CORRECT THIS PROGRAM
REPORT ZMVMOOPI LINE-SIZE 132
LINE-COUNT 60
NO STANDARD PAGE HEADING.
************************************************************************
T A B L E S *
************************************************************************
Tables: LQUA,
ZCORE_2,
ZCORE_ITEM,
ZCORE_HEADER,
LUBU,
ZY310,
ZYBKP,
ZYBCS_LOT.
DATA : lv_time TYPE sy-uzeit.
----
Input Parameters P A R A M E T E R S *
----
SELECTION-SCREEN begin of block b001 with frame title text-001.
PARAMETERS: MATNR LIKE LQUA-MATNR.
PARAMETERS: EDATU LIKE SY-DATUM default sy-datum.
PARAMETERS: PLANT LIKE LQUA-WERKS.
PARAMETERS: SUID like LQUA-LENUM.
PARAMETERS: SLOC LIKE LQUA-LGORT.
selection-screen end of block b001.
************************************************************************
D A T A D E F I N I T I O N *
************************************************************************
DATA: BEGIN OF ITAB OCCURS 0,
MANDT LIKE LQUA-MANDT,
MATNR LIKE LQUA-MATNR,
LENUM LIKE LQUA-LENUM,
VERME LIKE LQUA-VERME,
LGPLA LIKE LQUA-LGPLA,
LQNUM LIKE LQUA-LQNUM,
LGTYP LIKE LQUA-LGTYP,
PLPOS LIKE LQUA-PLPOS,
END OF ITAB.
DATA: ZADUMMY LIKE ZCORE_HEADER-ADUMMY,
ZUBNUM LIKE LUBU-UBNUM.
data: VAR1(3) TYPE C,
VAR2(18) TYPE C,
VAR3(17) TYPE C.
data: GOODSMVT_HEADER type bapi2017_gm_head_01.
data: GOODSMVT_CODE type bapi2017_gm_code.
data: GOODSMVT_HEADRET type bapi2017_gm_head_ret.
data: GOODSMVT_ITEM type table of
bapi2017_gm_item_create with header line.
data: RETURN type bapiret2 occurs 0.
data: MATERIALDOCUMENT type bapi2017_gm_head_ret-mat_doc.
DATA: I_UBNUM LIKE LTAK-UBNUM,
T_LUBQU LIKE LUBQU OCCURS 0 WITH HEADER LINE,
L_TANUM LIKE LTAK-TANUM.
data: t_zcore like ZCORE_2 occurs 0 with header line.
************************************************************************
S T A R T - O F - S E L E C T I O N *
************************************************************************
START-OF-SELECTION.
lv_time = sy-uzeit - 1200.
SELECT MANDT MATNR LENUM VERME LGPLA LQNUM LGTYP PLPOS FROM LQUA INTO
TABLE ITAB WHERE LGNUM = 754 AND
WERKS = 0054 and EDATU = SY-DATUM AND EZEIT >= lv_time AND VERME <> ''.
select SINGLE ADUMMY from ZCORE_HEADER INTO ZADUMMY WHERE RMATNR = ITAB-MATNR.
DATA: XX_MVT_CODE(3).
REFRESH: GOODSMVT_ITEM, RETURN.
CLEAR: GOODSMVT_ITEM, GOODSMVT_HEADER, RETURN,
MATERIALDOCUMENT, GOODSMVT_HEADRET.
XX_MVT_CODE = '919'.
MOVE '04' TO GOODSMVT_CODE.
MOVE SY-DATUM TO GOODSMVT_HEADER-PSTNG_DATE.
MOVE SY-DATUM TO GOODSMVT_HEADER-DOC_DATE.
GOODSMVT_ITEM-MATERIAL = ITAB-MATNR.
GOODSMVT_ITEM-PLANT = '0054'.
GOODSMVT_ITEM-STGE_LOC = LQUA-LGORT.
GOODSMVT_ITEM-ENTRY_UOM = LQUA-MEINS.
GOODSMVT_ITEM-MOVE_TYPE = XX_MVT_CODE.
GOODSMVT_ITEM-MOVE_MAT = ZADUMMY.
GOODSMVT_ITEM-MOVE_PLANT = '0054'.
GOODSMVT_ITEM-MOVE_STLOC = LQUA-LGORT.
GOODSMVT_ITEM-MOVE_REAS = ' '.
GOODSMVT_ITEM-MVT_IND = ' '.
APPEND GOODSMVT_ITEM.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
GOODSMVT_HEADER = GOODSMVT_HEADER
GOODSMVT_CODE = GOODSMVT_CODE
TESTRUN = ' '
IMPORTING
GOODSMVT_HEADRET = GOODSMVT_HEADRET
MATERIALDOCUMENT = MATERIALDOCUMENT
TABLES
GOODSMVT_ITEM = GOODSMVT_ITEM
GOODSMVT_SERIALNUMBER = GOODSMVT_SERIALNUMBER
RETURN = RETURN
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN =
.
CALL FUNCTION 'DEQUEUE_ALL'
EXPORTING
_SYNCHRON = ' '
.
SELECT SINGLE UBNUM FROM LUBU INTO ZUBNUM WHERE MBLNR = MATERIALDOCUMENT
AND BDATU = SY-DATUM AND BWART = '919'.
T_LUBQU-LQNUM = ITAB-LQNUM.
T_LUBQU-NLTYP = ITAB-LGTYP.
T_LUBQU-NLPLA = ITAB-LGPLA.
T_LUBQU-NLENR = ITAB-LENUM.
T_LUBQU-NPPOS = ITAB-PLPOS.
T_LUBQU-SQUIT = 'X'.
APPEND T_LUBQU.
CALL FUNCTION 'L_TO_CREATE_POSTING_CHANGE'
EXPORTING
I_LGNUM = '754'
I_UBNUM = ZUBNUM
I_LUBUI = ' '
I_SQUIT = 'X'
I_NIDRU = ' '
I_DRUKZ = ' '
I_LDEST = ' '
I_UPDATE_TASK = ' '
I_COMMIT_WORK = 'X'
I_BNAME = SY-UNAME
I_SOLEX = 0
I_PERNR = 0
IMPORTING
E_TANUM = L_TANUM
TABLES
T_LUBQU = T_LUBQU
T_LTAP_VB =
T_LTAK =
EXCEPTIONS
FOREIGN_LOCK = 1
TP_COMPLETED = 2
XFELD_WRONG = 3
LDEST_WRONG = 4
DRUKZ_WRONG = 5
TP_WRONG = 6
SQUIT_FORBIDDEN = 7
NO_TO_CREATED = 8
UPDATE_WITHOUT_COMMIT = 9
NO_AUTHORITY = 10
I_UBNUM_OR_I_LUBU = 11
BWLVS_WRONG = 12
MATERIAL_NOT_FOUND = 13
MANUAL_TO_FORBIDDEN = 14
BESTQ_WRONG = 15
SOBKZ_MISSING = 16
SOBKZ_WRONG = 17
MEINS_WRONG = 18
CONVERSION_NOT_FOUND = 19
NO_QUANTS = 20
T_LUBQU_REQUIRED = 21
LE_BULK_QUANT_NOT_SELECTABLE = 22
QUANT_NOT_SELECTABLE = 23
QUANTNUMBER_INITIAL = 24
KZUAP_OR_BIN_LOCATION = 25
DATE_WRONG = 26
NLTYP_MISSING = 27
NLPLA_MISSING = 28
LGBER_WRONG = 29
LENUM_WRONG = 30
MENGE_WRONG = 31
MENGE_TO_BIG = 32
OPEN_TR_KZUAP = 33
LOCK_EXISTS = 34
DOUBLE_QUANT = 35
QUANTITY_WRONG = 36
OTHERS = 37
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
move itab-mandt to t_zcore-MANDT.
move ZADUMMY to t_zcore-ZDUMMY.
move itab-MATNR to t_zcore-zrmatnr.
SPLIT ZY310-ZBARCODE at '|' into VAR1 VAR2 VAR3.
move VAR3 to t_zcore-ZCAM.
move T_LUBQU-NLENR to t_zcore-ZSUID.
move itab-verme to t_zcore-ZQTY.
move ' ' to t_zcore-zvrgn.
move sy-datum to t_zcore-ZDATE.
APPEND t_zcore.
update ZCORE_2 FROM table t_zcore.
update ZYBKP set MATNR = zcore_2-ZDUMMY where matnr = zcore_2-ZDUMMY.
update ZY310 set MATNR = zcore_2-ZDUMMY where matnr = zcore_2-ZDUMMY.
update ZYBCS_LOT set MATNR = zcore_2-ZDUMMY where matnr = zcore_2-ZDUMMY.
THANKS FOR YOUR HELP
2007 Aug 29 9:47 PM
I don't think that it's reasonable to ask on this forum to review the whole program. People get paid by an hour for that, you know. I'd suggest to run it in Debugger and identify the step where it's failing and, if you still have questions after that, feel free to ask, but be more specific.
Something that just caught my attention - in your opinion, what exactly does this code do:
update ZYBKP set MATNR = zcore_2-ZDUMMY where matnr = zcore_2-ZDUMMY.
1) Query LQUA for the EDATU ( Todays date) Time (EZEIT) for the last 20 minutes from the current time.
2) Extract all the LQUA-MATNR for the warshe ( 754) plant 0054 sloc - LGORT. Also, extract SUID ( LENUM) and available quantity (VERME) , Storage bin - LGPLA. Store them in the internal table ( Only the confirmed TO). The -LEIN-STATU should be blank . or LQUA-VERME should not be blank.
3) In the previous step the REMAN data was extracted for the use in the next steps.
4) Compare the LQUA-MATNR with the REMAN material no ( From Custom table ZCORE_1 Relation ship matrix)
5) Extract the records which are matching and also add the Dummy finish part from the custom table ZCORE_1 in the internal table
6) Call BAPI- BAPI_GOODSMVT_CREATE ( movement type- 919) to process material to material transfer. Receiving material is Dummy finish part no , rcvng sloc and rcvng plant are the same as REMAN. ( plant 0054)
7) Get the material document created from the previous step and store it
8) Query table LUBU by LUBU-MBLNR ( mat doc no from previous step), LUBU-BDATU ( Todays date), LUBU-BWART ( 919) and extract the posting change no ( LUBU-UBNUM).
9) Use the function module - L_TO_Create_Posting_Change with the (LUBU-UBNUM) created in the previous step. Use 922 (TR-ZONE) for the source bin to process the posting change ( use the information of the SUID, Source bin, SUT type etc from step 1)
10) Populate the table ZCORE_2 with the processed items. REMAN no, Qty, SU ID, Dummy finish part, CAM serial no. The CAM serial no is extracted form the BCS interface table ZY310 ( by querying against the REMAN / SU Id no)
Note: The Vrgn Bld flag is maintained for the vrgn bld process ( Refere functional spec Mat to mat transfer_Rework and Vrgn.doc)
11) Collect the Record information form the previous step, Change the BCS table fields MATNR and ZBARCODE = concatenate BCS|MATNR|EXIDV02 with the dummy part no in for the following tables - ZYBKP, ZY310 , ZYBCS_LOT
FOR THE ABOVE TASK, I WRITTEN THE BELOW PROGRAM, IT IS SYNTATICALL CORRECT, BUT I'M NOT GETTING THE RESULT, CAN ANY CORRECT THIS PROGRAM
REPORT ZMVMOOPI LINE-SIZE 132
LINE-COUNT 60
NO STANDARD PAGE HEADING.
************************************************************************
T A B L E S *
************************************************************************
Tables: LQUA,
ZCORE_2,
ZCORE_ITEM,
ZCORE_HEADER,
LUBU,
ZY310,
ZYBKP,
ZYBCS_LOT.
DATA : lv_time TYPE sy-uzeit.
----
Input Parameters P A R A M E T E R S *
----
SELECTION-SCREEN begin of block b001 with frame title text-001.
PARAMETERS: MATNR LIKE LQUA-MATNR.
PARAMETERS: EDATU LIKE SY-DATUM default sy-datum.
PARAMETERS: PLANT LIKE LQUA-WERKS.
PARAMETERS: SUID like LQUA-LENUM.
PARAMETERS: SLOC LIKE LQUA-LGORT.
selection-screen end of block b001.
************************************************************************
D A T A D E F I N I T I O N *
************************************************************************
DATA: BEGIN OF ITAB OCCURS 0,
MANDT LIKE LQUA-MANDT,
MATNR LIKE LQUA-MATNR,
LENUM LIKE LQUA-LENUM,
VERME LIKE LQUA-VERME,
LGPLA LIKE LQUA-LGPLA,
LQNUM LIKE LQUA-LQNUM,
LGTYP LIKE LQUA-LGTYP,
PLPOS LIKE LQUA-PLPOS,
END OF ITAB.
DATA: ZADUMMY LIKE ZCORE_HEADER-ADUMMY,
ZUBNUM LIKE LUBU-UBNUM.
data: VAR1(3) TYPE C,
VAR2(18) TYPE C,
VAR3(17) TYPE C.
data: GOODSMVT_HEADER type bapi2017_gm_head_01.
data: GOODSMVT_CODE type bapi2017_gm_code.
data: GOODSMVT_HEADRET type bapi2017_gm_head_ret.
data: GOODSMVT_ITEM type table of
bapi2017_gm_item_create with header line.
data: RETURN type bapiret2 occurs 0.
data: MATERIALDOCUMENT type bapi2017_gm_head_ret-mat_doc.
DATA: I_UBNUM LIKE LTAK-UBNUM,
T_LUBQU LIKE LUBQU OCCURS 0 WITH HEADER LINE,
L_TANUM LIKE LTAK-TANUM.
data: t_zcore like ZCORE_2 occurs 0 with header line.
************************************************************************
S T A R T - O F - S E L E C T I O N *
************************************************************************
START-OF-SELECTION.
lv_time = sy-uzeit - 1200.
SELECT MANDT MATNR LENUM VERME LGPLA LQNUM LGTYP PLPOS FROM LQUA INTO
TABLE ITAB WHERE LGNUM = 754 AND
WERKS = 0054 and EDATU = SY-DATUM AND EZEIT >= lv_time AND VERME <> ''.
select SINGLE ADUMMY from ZCORE_HEADER INTO ZADUMMY WHERE RMATNR = ITAB-MATNR.
DATA: XX_MVT_CODE(3).
REFRESH: GOODSMVT_ITEM, RETURN.
CLEAR: GOODSMVT_ITEM, GOODSMVT_HEADER, RETURN,
MATERIALDOCUMENT, GOODSMVT_HEADRET.
XX_MVT_CODE = '919'.
MOVE '04' TO GOODSMVT_CODE.
MOVE SY-DATUM TO GOODSMVT_HEADER-PSTNG_DATE.
MOVE SY-DATUM TO GOODSMVT_HEADER-DOC_DATE.
GOODSMVT_ITEM-MATERIAL = ITAB-MATNR.
GOODSMVT_ITEM-PLANT = '0054'.
GOODSMVT_ITEM-STGE_LOC = LQUA-LGORT.
GOODSMVT_ITEM-ENTRY_UOM = LQUA-MEINS.
GOODSMVT_ITEM-MOVE_TYPE = XX_MVT_CODE.
GOODSMVT_ITEM-MOVE_MAT = ZADUMMY.
GOODSMVT_ITEM-MOVE_PLANT = '0054'.
GOODSMVT_ITEM-MOVE_STLOC = LQUA-LGORT.
GOODSMVT_ITEM-MOVE_REAS = ' '.
GOODSMVT_ITEM-MVT_IND = ' '.
APPEND GOODSMVT_ITEM.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
GOODSMVT_HEADER = GOODSMVT_HEADER
GOODSMVT_CODE = GOODSMVT_CODE
TESTRUN = ' '
IMPORTING
GOODSMVT_HEADRET = GOODSMVT_HEADRET
MATERIALDOCUMENT = MATERIALDOCUMENT
TABLES
GOODSMVT_ITEM = GOODSMVT_ITEM
GOODSMVT_SERIALNUMBER = GOODSMVT_SERIALNUMBER
RETURN = RETURN
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN =
.
CALL FUNCTION 'DEQUEUE_ALL'
EXPORTING
_SYNCHRON = ' '
.
SELECT SINGLE UBNUM FROM LUBU INTO ZUBNUM WHERE MBLNR = MATERIALDOCUMENT
AND BDATU = SY-DATUM AND BWART = '919'.
T_LUBQU-LQNUM = ITAB-LQNUM.
T_LUBQU-NLTYP = ITAB-LGTYP.
T_LUBQU-NLPLA = ITAB-LGPLA.
T_LUBQU-NLENR = ITAB-LENUM.
T_LUBQU-NPPOS = ITAB-PLPOS.
T_LUBQU-SQUIT = 'X'.
APPEND T_LUBQU.
CALL FUNCTION 'L_TO_CREATE_POSTING_CHANGE'
EXPORTING
I_LGNUM = '754'
I_UBNUM = ZUBNUM
I_LUBUI = ' '
I_SQUIT = 'X'
I_NIDRU = ' '
I_DRUKZ = ' '
I_LDEST = ' '
I_UPDATE_TASK = ' '
I_COMMIT_WORK = 'X'
I_BNAME = SY-UNAME
I_SOLEX = 0
I_PERNR = 0
IMPORTING
E_TANUM = L_TANUM
TABLES
T_LUBQU = T_LUBQU
T_LTAP_VB =
T_LTAK =
EXCEPTIONS
FOREIGN_LOCK = 1
TP_COMPLETED = 2
XFELD_WRONG = 3
LDEST_WRONG = 4
DRUKZ_WRONG = 5
TP_WRONG = 6
SQUIT_FORBIDDEN = 7
NO_TO_CREATED = 8
UPDATE_WITHOUT_COMMIT = 9
NO_AUTHORITY = 10
I_UBNUM_OR_I_LUBU = 11
BWLVS_WRONG = 12
MATERIAL_NOT_FOUND = 13
MANUAL_TO_FORBIDDEN = 14
BESTQ_WRONG = 15
SOBKZ_MISSING = 16
SOBKZ_WRONG = 17
MEINS_WRONG = 18
CONVERSION_NOT_FOUND = 19
NO_QUANTS = 20
T_LUBQU_REQUIRED = 21
LE_BULK_QUANT_NOT_SELECTABLE = 22
QUANT_NOT_SELECTABLE = 23
QUANTNUMBER_INITIAL = 24
KZUAP_OR_BIN_LOCATION = 25
DATE_WRONG = 26
NLTYP_MISSING = 27
NLPLA_MISSING = 28
LGBER_WRONG = 29
LENUM_WRONG = 30
MENGE_WRONG = 31
MENGE_TO_BIG = 32
OPEN_TR_KZUAP = 33
LOCK_EXISTS = 34
DOUBLE_QUANT = 35
QUANTITY_WRONG = 36
OTHERS = 37
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
move itab-mandt to t_zcore-MANDT.
move ZADUMMY to t_zcore-ZDUMMY.
move itab-MATNR to t_zcore-zrmatnr.
SPLIT ZY310-ZBARCODE at '|' into VAR1 VAR2 VAR3.
move VAR3 to t_zcore-ZCAM.
move T_LUBQU-NLENR to t_zcore-ZSUID.
move itab-verme to t_zcore-ZQTY.
move ' ' to t_zcore-zvrgn.
move sy-datum to t_zcore-ZDATE.
APPEND t_zcore.
update ZCORE_2 FROM table t_zcore.
update ZYBKP set MATNR = zcore_2-ZDUMMY where matnr = zcore_2-ZDUMMY.
update ZY310 set MATNR = zcore_2-ZDUMMY where matnr = zcore_2-ZDUMMY.
update ZYBCS_LOT set MATNR = zcore_2-ZDUMMY where matnr = zcore_2-ZDUMMY.
THANKS FOR YOUR HELP
2007 Aug 29 9:47 PM
I don't think that it's reasonable to ask on this forum to review the whole program. People get paid by an hour for that, you know. I'd suggest to run it in Debugger and identify the step where it's failing and, if you still have questions after that, feel free to ask, but be more specific.
Something that just caught my attention - in your opinion, what exactly does this code do:
update ZYBKP set MATNR = zcore_2-ZDUMMY where matnr = zcore_2-ZDUMMY.
2007 Aug 29 10:00 PM
hi thank you, i did debug the program, but i couldnt find and that logic is to update the field matnr in all the three database tables
2007 Aug 29 10:05 PM
HI,
update ZYBKP set MATNR = <b>zcore_2-ZDUMMY</b> where matnr = <b>zcore_2-ZDUMMY</b>.
update ZY310 set MATNR = zcore_2-ZDUMMY where matnr = zcore_2-ZDUMMY.
update ZYBCS_LOT set MATNR = zcore_2-ZDUMMY where matnr = zcore_2-ZDUMMY.
<b>YOU ARE COMPARING SAME MATERIAL AND UPDATING WITH THE SAME..</b> AND ALSO ZCORE_2 IS A DATABASE TABLE AND MAY NOT CONTAIN ANY VALUE AT THAT POINT...
in these statments you say that
update table set matnr = 'MATNR' WHERE MATNR = 'MATNR'.
EVEN THOUGH THIS STATMENT IS EXECUTED THERE WILL NOT BE ANY CHANGE IN THE TABLE...
Thanks,
Mahesh
2007 Aug 29 10:07 PM
But don't you see that it makes no sense whatsoever? It will not make any changes because you are looking for entries with value X and then are trying to update the same field with the same value. It's like IF X = X THEN X = X.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |