Mobile Code
MB01--
MB31--
MB1A--
--Mb1b
--MB1C
--MB11
--MB04 , receipt (101)
Description: Purchase order, production order receipt
[Plain] View Plain copy form recvfromord tables pt_tran structure zwttran. Move Library definition data: goodsmvt_header type bapi2017_gm_head_01, goodsmvt_code type bapi2017_gm_code, goodsmvt_headret type bapi2017_gm_head_ret, materialdocument type bapi2017_gm_head_ret-mat_doc, matdocumentyear type bapi2017_gm_ head_ret-doc_year, goodsmvt_item type standard table of /afs/bapi2017_gm_item_create, return type standard table of bapiret2, w_ creturn type bapiret2, w_goodsmvt_item type /afs/bapi2017_gm_item_ create, w_return type bapiret2. data:lt_retmsg like table of bapiret2 with header line, lt_return like table of bapiret2 with header line. data:l_tran_nbr like zwttran-tran_nbr, l_tranpo like zwttran-tranpo, l_matdoc like zwttran-matdoc, l_flag like zwttran-flag, l_line_id type i. data:l_asn_nbr type ze_ref_field, "ASN l_po type ze_ref_field, "Po No. l_po_line (5) type n, "PO line number l_matnr type matnr. " SKU   DATA:L_TYPE TYPE CHAR1, "type  L_AFPO TYPE AFPO, "Production orders l_j_3absSi type j_3abssi, "Production order planning line l_eket Type eket, "Purchase order plan lines l_ekpo type ekpo." Purchase order line items data:lt_bom like table of zwmbom with header line. refresh:t_tran_nbr. loop at pt_tran. clear :t_tran_nbr.     T_TRAN_NBR-TRAN_NBR = pt_tran-tran_nbr. if pt_tran-tran_type = ' 603 ' and pt_tran-tran_code = ' the ' and pt_tran-proc_stat_code = ' and pt_tran-ref_field_6 = ' P ' . t_tran_ nbr-po = pt_tran-ref_field_3. endif. append t_tran_nbr. endloop.   SORT T_TRAN_NBR BY TRAN_NBR po. delete adjacent duplicates from t_tran_nbr. loop at t_tran_nbr. clear:l_tran_nbr,l_ Matdoc,l_matnr,l_asn_nbr,l_po,l_matnr,l_type,l_afpo,l_j_3abssi,l_eket,l_ekpo,l_tranpo,lt_retmsg,lt_return,pt_ tran. refresh:lt_return. Clear:goodsmvt_header,goodsmvt_code,goodsmvt_headret,materialdocument,matdocumentyear, goodsmvt_item ,return,w_return. refresh:goodsmvt_item ,return. "Head goodsmvt_header-pstng_date = sy-datum. goodsmvt_header-doc_date = sy-datum. "Detail loop at pt_tran where tran_type = ' 603 ' and tran_code = ' and units_rcvd ' and proc_stat_code = ' ten ' > 0 and tran_nbr = t_tran_nbr-tran_nbr and ref_field_3 = t_tran_nbr-po. if pt_ tran-ref_field_6 = ' P ' . l_tran_nbr = pt_tran-tran_nbr. Get the ASN number l_asn_nbr = pt_tran-ref_field_1. l_po = pt_tran-ref_field_3. concatenate l_tran_nbr l_po into l_tranpo. if pt_tran-ref_field_4 is not initial. l_po_line = pt_tran-ref_field_4. else. clear l_po_line. endif. l_matnr = pt_tran-matnr. clear:lt_retmsg.