BAPI--几个有用的BAPI调用样例
2008-01-15 09:29:01
***INCLUDE MMWE0F01 . * 88951 26.11.97 4.0B KB: Preis黚ergabe an ME_CREATE_PO_ITEM * 94702 04.02.98 4.0B KB: Verbuchungsproblem Bestellung/Kundenauftrag *102133 24.04.98 4.0C KB: Preis黚ernahme in Bestellung *106225 09.06.98 4.5A KB: Bestellpreismengeneinheit in Bestellposition *134329 15.01.99 4.5B RB: WE/RE-Kennzeichen *167369 12.08.99 4.6B RB: Positionsreihenfolge in erzeugten Objekten *&---------------------------------------------------------------------* *& Hinzuf黦en neue Position aus dem Katalog in BAN *&---------------------------------------------------------------------* form ban_store_cat. clear ban. ban-preq_item = h_banpos + 1. clear bankey. bankey-preq_item = ban-preq_item. * lesen BAN - merken Indizes read table ban with key bankey binary search. h_index = sy-tabix. h_subrc = sy-subrc. * 黚ernehmen globale Daten in BAN move-corresponding global to ban. if ban-preq_name is initial. ban-preq_name = sy-uname. endif. * 黚ernehmen Katalog-Daten in BAN ban-material = new_item-matnr. ban-pur_mat = new_item-matnr. ban-quantity = new_item-quantity. if new_item-unit is initial. message s064 with new_item-unit. exit. endif. perform unit_of_measure_to_sap using new_item-unit. if exitflag ne space. message s064 with new_item-unit. exit. endif. ban-unit = new_item-unit. ban-short_text = new_item-description. if not new_item-currency is initial and not new_item-price is initial. perform value_to_sap using new_item-currency new_item-price. if exitflag ne space. message s065 with new_item-price new_item-currency. exit. endif. endif. ban-preis = new_item-price. ban-c_amt_bapi = new_item-price. ban-price_unit = new_item-priceunit. if not ban-preis is initial. * BAN-PO_PRICE = '2'. "102133/KB ban-po_price = '1'. "102133/KB endif. if not new_item-currency is initial. perform currency_to_sap using new_item-currency. if exitflag ne space. message s066 with new_item-currency. exit. endif. endif. ban-currency = new_item-currency. ban-waers = ban-currency. ban-deliv_date = sy-datlo + new_item-leadtime. ban-vend_mat = new_item-vendormat. ban-manu_mat = new_item-manufactmat. ban-mfr_no_ext = new_item-manufactcode. if h_catalogs-lifnr ne space. ban-fixed_vend = h_catalogs-lifnr. ban-purch_org = h_catalogs-ekorg. else. ban-fixed_vend = new_item-vendor. if not h_catalogs-ekorg is initial and ban-purch_org is initial. ban-purch_org = h_catalogs-ekorg. endif. endif. * Materialnummer von Katalog 黚ergeben - Pr黤en Mat. und 黚ern. Daten if ban-pur_mat ne space. perform material_get using ban-pur_mat. if no_material ne space or no_status_b ne space. message s050 with ban-pur_mat. clear ban-pur_mat. clear ban-material. else. move-corresponding mat_tab to ban. ban-preis = mat_tab-c_amt_bapi. perform material_availability_check. endif. endif. * Materialnummer 黚er Infosatz suchen, wenn Lieferantenmatnr. sitzt if ban-pur_mat eq space. if ban-vend_mat ne space. perform determine_material_inforecord using new_item-vendormat ban-fixed_vend ban-pur_mat ban-info_rec. * falls Materialnummer gefunden wurde, so weiter, als sei sie eingegeben if ban-pur_mat ne space. perform material_get using ban-pur_mat. if no_material ne space or no_status_b ne space. clear ban-pur_mat. clear ban-material. else. move-corresponding mat_tab to ban. ban-preis = mat_tab-c_amt_bapi. perform material_availability_check. endif. endif. endif. * Materialnummer 黚er Hersteller und Herstellerteilenummer if new_item-manufactmat ne space and new_item-manufactcode ne space. perform determine_material_manufact using new_item-manufactmat new_item-manufactcode ban-pur_mat. * falls Materialnummer gefunden wurde, so weiter, als sei sie eingegeben if ban-pur_mat ne space. perform material_get using ban-pur_mat. if no_material ne space or no_status_b ne space. clear ban-pur_mat. clear ban-material. else. move-corresponding mat_tab to ban. ban-preis = mat_tab-c_amt_bapi. perform material_availability_check. endif. endif. endif. endif. * lesen lieferantenstamm und ermitteln EKORG if ban-fixed_vend ne space and ban-purch_org eq space. endif. * Festwerte if ban-price_unit is initial. ban-price_unit = 1. endif. ban-del_datcat = '1'. ban-item_cat = '0'. ban-update = 'I'. perform check_mandantory_fields. * WE/RE-Kennzeichen setzen "134329/RB select single * from t163 where pstyp = ban-item_cat. "134329/RB select single * from t163k where knttp = ban-acctasscat. "134329/RB "134329/RB ban-gr_ind = t163-wepos. "134329/RB ban-gr_non_val = t163-weunb. "134329/RB ban-ir_ind = t163-repos. "134329/RB "134329/RB if ban-acctasscat ne space. "134329/RB ban-consumpt = t163k-kzvbr. "134329/RB if t163-wepov eq space. "134329/RB ban-gr_ind = t163k-wepos. "134329/RB endif. "134329/RB if t163-weunv eq space. "134329/RB ban-gr_non_val = t163k-weunb. "134329/RB endif. "134329/RB if t163-repov eq space. "134329/RB ban-ir_ind = t163k-repos. "134329/RB endif. "134329/RB endif. "134329/RB * merken redirectURL f黵 SD-scenario ban-katalog = h_catalogs-katalog. ban-sd = sel_sd. if sel_sd ne space. read table redirect with key ban-katalog. if sy-subrc ne 0. redirect-katalog = ban-katalog. field-get 'SD_HOOK_URL' 1 h_redirect h_redirect_length. move h_redirect to redirect-url. append redirect. endif. endif. if h_subrc eq 0. modify ban index h_index. else. insert ban index h_index. endif. h_banpos = ban-preq_item. * erzeugen Kontierungszeile perform init_bsc. * erzeugen Textzeilen perform init_bantx. clear ban. endform. *&---------------------------------------------------------------------* *& 膎dern Position 黚er das Detailbild - Grunddaten *&---------------------------------------------------------------------* form ban_store_core. clear bankey. bankey-preq_item = bapieban-preq_item. read table ban with key bankey binary search. h_index = sy-tabix. h_subrc = sy-subrc. * unerhebliche Felder - einfach 黚ernehmen ban-doc_type = bapieban-doc_type. ban-pur_group = bapieban-pur_group. ban-short_text = bapieban-short_text. ban-store_loc = bapieban-store_loc. ban-preq_name = bapieban-preq_name. ban-trackingno = bapieban-trackingno. ban-preis = eban-preis. ban-price_unit = bapieban-price_unit. ban-currency = bapieban-currency. ban-vend_mat = bapieban-vend_mat. * L鰏chen Bezugsquellendaten bei bestimmten 膎derungen if ban-plant ne bapieban-plant or ban-mat_grp ne bapieban-mat_grp or ban-unit ne bapieban-unit or ban-item_cat ne bapieban-item_cat. clear next. loop at sos where preq_item eq ban-preq_item. delete sos. next = next + 1. endloop. if next > 0. clear next. message s132. clear: ban-fixed_vend, ban-purch_org, ban-agreement, ban-agmt_item, ban-info_rec. endif. endif. * 黚ernehmen Felder, wenn Nichtlagerposition if ban-pur_mat eq space. ban-mat_grp = bapieban-mat_grp. ban-plant = bapieban-plant. ban-unit = bapieban-unit. ban-c_amt_bapi = bapieban-c_amt_bapi. ban-price_unit = bapieban-price_unit. ban-currency = bapieban-currency. if not ban-preis is initial. * BAN-PO_PRICE = '2'. "102133/KB ban-po_price = '1'. "102133/KB endif. else. * IF NOT BAN-PREIS IS INITIAL. "102133/KB * BAN-PO_PRICE = '1'. "102133/KB * ENDIF. "102133/KB endif. * Anstossen Verf黦barkeit bei 膎derung Menge oder Termin if ban-material ne space. if ban-quantity ne bapieban-quantity or ban-deliv_date ne bapieban-deliv_date. ban-quantity = bapieban-quantity. ban-deliv_date = bapieban-deliv_date. perform material_availability_check. message s047. endif. endif. ban-quantity = bapieban-quantity. ban-deliv_date = bapieban-deliv_date. * Festwerte if ban-price_unit is initial. ban-price_unit = 1. endif. ban-del_datcat = '1'. ban-item_cat = '0'. ban-update = 'I'. perform check_mandantory_fields. modify ban index h_index. endform. *&---------------------------------------------------------------------* *& Sichern neue oder ge鋘derte Daten in interner Tabelle BAN *&---------------------------------------------------------------------* form ban_store_loop. clear bankey. bankey-preq_item = banwa-preq_item. read table ban with key bankey binary search. h_index = sy-tabix. if sy-subrc eq 0. * Position ver鋘dert if ban-update ne space. * Daten der Verf黦barkeit haben sich unter Umst鋘den ge鋘dert if ban-quantity ne banwa-quantity or ban-deliv_date ne banwa-deliv_date. ban-quantity = banwa-quantity. ban-deliv_date = banwa-deliv_date. if ban-material ne space. perform material_availability_check. message s047. endif. endif. * L鰏chen Bezugsquellendaten bei bestimmten 膎derungen if ban-unit ne banwa-unit. clear next. loop at sos where preq_item eq ban-preq_item. delete sos. next = next + 1. endloop. if next > 0. clear next. message s132. clear: ban-fixed_vend, ban-purch_org, ban-agreement, ban-agmt_item, ban-info_rec. endif. endif. ban-unit = banwa-unit. ban-short_text = banwa-short_text. perform check_mandantory_fields. modify ban index h_index. * Position ver鋘dert, aber Dummyposition else. move-corresponding global to ban. move-corresponding banwa to ban. if ban-preq_name is initial. ban-preq_name = sy-uname. endif. if ban-pur_mat ne space. perform material_get using ban-pur_mat. if no_material ne space or no_status_b ne space. message s050 with ban-pur_mat. prepare_item = 'X'. delete ban index h_index. exit. else. move-corresponding mat_tab to ban. ban-preis = mat_tab-c_amt_bapi. * IF NOT BAN-PREIS IS INITIAL. "102133/KB * BAN-PO_PRICE = '1'. "102133/KB * ENDIF. "102133/KB perform material_availability_check. endif. else. "102133/KB if not ban-preis is initial. "102133/KB ban-po_price = '1'. "102133/KB endif. "102133/KB endif. if ban-price_unit is initial. ban-price_unit = 1. endif. ban-del_datcat = '1'. ban-item_cat = '0'. ban-update = 'I'. h_banpos = ban-preq_item. perform check_mandantory_fields. * WE/RE-Kennzeichen setzen "134329/RB select single * from t163 where pstyp = ban-item_cat. "134329/RB select single * from t163k where knttp = ban-acctasscat."134329/RB "134329/RB ban-gr_ind = t163-wepos. "134329/RB ban-gr_non_val = t163-weunb. "134329/RB ban-ir_ind = t163-repos. "134329/RB "134329/RB if ban-acctasscat ne space. "134329/RB ban-consumpt = t163k-kzvbr. "134329/RB if t163-wepov eq space. "134329/RB ban-gr_ind = t163k-wepos. "134329/RB endif. "134329/RB if t163-weunv eq space. "134329/RB ban-gr_non_val = t163k-weunb."134329/RB endif. "134329/RB if t163-repov eq space. "134329/RB ban-ir_ind = t163k-repos. "134329/RB endif. "134329/RB endif. "134329/RB modify ban index h_index. * erzeugen Kontierungszeile perform init_bsc. * erzeugen Textzeilen perform init_bantx. endif. * neue Position else. clear ban. move-corresponding global to ban. move-corresponding banwa to ban. if ban-preq_name is initial. ban-preq_name = sy-uname. endif. if ban-pur_mat ne space. perform material_get using ban-pur_mat. if no_material ne space or no_status_b ne space. message s050 with ban-pur_mat. prepare_item = 'X'. delete ban index h_index. exit. else. move-corresponding mat_tab to ban. ban-preis = mat_tab-c_amt_bapi. * IF NOT BAN-PREIS IS INITIAL. "102133/KB * BAN-PO_PRICE = '1'. "102133/KB * ENDIF. "102133/KB perform material_availability_check. endif. else. "102133/KB if not ban-preis is initial. "102133/KB ban-po_price = '1'. "102133/KB endif. "102133/KB endif. if ban-price_unit is initial. ban-price_unit = 1. endif. ban-update = 'I'. perform check_mandantory_fields. ban-item_cat = '0'. ban-del_datcat = '1'. h_banpos = ban-preq_item. * WE/RE-Kennzeichen setzen "134329/RB select single * from t163 where pstyp = ban-item_cat. "134329/RB select single * from t163k where knttp = ban-acctasscat. "134329/RB "134329/RB ban-gr_ind = t163-wepos. "134329/RB ban-gr_non_val = t163-weunb. "134329/RB ban-ir_ind = t163-repos. "134329/RB "134329/RB if ban-acctasscat ne space. "134329/RB ban-consumpt = t163k-kzvbr. "134329/RB if t163-wepov eq space. "134329/RB ban-gr_ind = t163k-wepos. "134329/RB endif. "134329/RB if t163-weunv eq space. "134329/RB ban-gr_non_val = t163k-weunb. "134329/RB endif. "134329/RB if t163-repov eq space. "134329/RB ban-ir_ind = t163k-repos. "134329/RB endif. "134329/RB endif. "134329/RB insert ban index h_index. * erzeugen Kontierungszeile perform init_bsc. * erzeugen Textzeilen perform init_bantx. endif. clear ban. endform. *&---------------------------------------------------------------------* *& 膎dern Position - Kontierungen 黚er das Detailbild *&---------------------------------------------------------------------* form bsc_store_account. clear bankey. bankey-preq_item = bapieban-preq_item. read table ban with key bankey binary search. * bsc lesen und Daten fortschreiben clear bsckey. bsckey-preq_item = bapieban-preq_item. bsckey-serial_no = '01'. read table bsc with key bsckey binary search. h_index1 = sy-tabix. if sy-subrc eq 0. move-corresponding bapiebkn to bapipogna. perform check_account_assignment. check exitflag eq space. move-corresponding bapipogna to bapiebkn. move-corresponding bapiebkn to bsc. move-corresponding bsckey to bsc. modify bsc index h_index1. endif. endform. *&---------------------------------------------------------------------* *& Form CHECK_MANDANTORY_FIELDS *&---------------------------------------------------------------------* form check_mandantory_fields. if ban-quantity is initial. message e094. endif. if ban-deliv_date is initial. message e095. endif. if ban-unit is initial. message e096. endif. endform. " CHECK_MANDANTORY_FIELDS *&---------------------------------------------------------------------* *& Aufruf fremder Katalog *&---------------------------------------------------------------------* form call_catalog. loop at catalogs where katalog eq select_cat. exit. endloop. h_catalogs = catalogs. * merken Katalog-Id und Lieferant in Hilfsfeld sel_sd = catalogs-sd_catalog. sel_vendor = catalogs-lifnr. * im Falle SD, Kundennummer besorgen if sel_sd ne space. perform get_company_code. perform get_customer_number. field-set 'CUSTOMER_NO' 1 customer_no. endif. * Aufruf Katalog * wenn vorher bereits aufgerufen - URL aus interner Tabelle read table redirect with key catalogs-katalog. if sy-subrc eq 0. clear my_hook_url. its-wgateurl my_hook_url. field-set 'MM_HOOK_URL' 1 my_hook_url. field-set '~OkCode' 1 'SHPS'. its-browser_redirect redirect-url. else. * wenn noch nicht aufgerufen - URL 黚er Customizingtabelle aufbauen perform catalog_browser_redirect using catalogs-katalog. endif. endform. *&---------------------------------------------------------------------* *& Form CATALOG_BROWSER_REDIRECT *&---------------------------------------------------------------------* * Aufruf externe Kataloge 黚er Customizingtabelle *----------------------------------------------------------------------* form catalog_browser_redirect using cbr_katalog. data: url like savwctxt-fieldcont, hook like savwctxt-fieldcont, name like savwctxt-fieldname, cont like savwctxt-fieldcont, hook_name like savwctxt-fieldname, hook_index like sy-tabix, sep. refresh: xmw03. clear: xmw03. * Katalog-Parameter besorgen select * from tmw03 into table xmw03 where katalog = cbr_katalog. sort xmw03. * 1. Runde: URL des Katalogs merken loop at xmw03. hook_index = sy-tabix. * Parameter merken bei Parameter-Wechsel if xmw03-fieldnam ne space. if name ne space or cont ne space. field-set name 0 cont. clear: name, cont. endif. * Parameter-Name name = xmw03-fieldnam. endif. * Parameter-Wert analysieren case xmw03-valuetyp. * URL when '0'. concatenate url xmw03-fieldval into url. * Festwert when '2'. concatenate cont xmw03-fieldval into cont. * ABAP-Feld when '1'. write (xmw03-fieldval) to cont. * Hook-Url when '4'. * Ende 1.Runde exit. endcase. endloop. * Fester Teil der R點kgabe-URL vom ITS its-wgateurl hook. * 2. Runde: R點kgabe-URL merken loop at xmw03 from hook_index. * Erster Parameter: Trennzeichen '?' if not hook cs '?'. sep = '?'. * Folgeparameter: Trennzeichen '&' else. sep = '&'. endif. * Parameter-Wert analysieren case xmw03-valuetyp. * Festwert when '2'. concatenate hook sep xmw03-fieldnam '=' xmw03-fieldval into hook. * ABAP-Feld when '1'. write (xmw03-fieldval) to cont. concatenate hook sep xmw03-fieldnam '=' cont into hook. * Hook-Url when '4'. hook_name = xmw03-fieldnam. endcase. endloop. * Komplette R點kgabe-URL als Parameter merken field-set hook_name 0 hook. * URL zusammenbauen, encoden und an ITS 黚ergeben its-browser_redirect url. endform. *&---------------------------------------------------------------------* *& Pr黤en Kontierungsdaten *&---------------------------------------------------------------------* form check_account_assignment. perform fill_bapicobl. refresh return1. clear return1. clear exitflag. * Aufruf Kontierungspr黤ung und -erg鋘zung call function 'BAPI_ACCSERV_CHECKACCASSIGNMT' exporting check_codingblock = bapicobl importing changed_codingblock = bapicobl tables return = return1 exceptions error_message = 1. * keine Fehler if return1[] is initial and sy-subrc eq 0. perform fill_bapipogna. else. * Fehler ausgeben loop at return1 where type eq 'E'. * MESSAGE ID RETURN1-ID TYPE RETURN1-TYPE NUMBER RETURN1-NUMBER message id return1-id type 'S' number return1-number with return1-message_v1 return1-message_v2 return1-message_v3 return1-message_v4. exitflag = 'X'. exit. endloop. loop at return1 where type ne 'E'. message id return1-id type 'S' number return1-number with return1-message_v1 return1-message_v2 return1-message_v3 return1-message_v4. endloop. endif. endform. *&---------------------------------------------------------------------* *& Pr黤en Globale Daten auf Vollst鋘digkeit *&---------------------------------------------------------------------* form check_global_data. clear global_data_missing. if bapipogn-doc_type is initial. global_data_missing = 'X'. endif. if bapipogn-pur_group is initial. global_data_missing = 'X'. endif. if bapipogn-mat_grp is initial. global_data_missing = 'X'. endif. if bapipogn-plant is initial. global_data_missing = 'X'. endif. if bapipogn-acctasscat is initial. global_data_missing = 'X'. endif. if bapipogna-cost_ctr is initial. global_data_missing = 'X'. endif. endform. *&--------------------------------------------------------------------- * Erzeugen Bestellung *---------------------------------------------------------------------- form create_po. data: transaction_id like arfctid, "94702/KB commit_work(15) value 'COMMIT_WORK', "94702/KB status_of_transaction(15). "94702/KB clear return. refresh return. clear transaction_id. "94702/KB * Verbuchung 'normal' wenn SD nicht im Spiel "94702/KB if sd_katalog is initial. "94702/KB * Aufruf BAPI zum Erzeugen der Bestellung call function 'BAPI_PO_CREATE' exporting po_header = po_head importing purchaseorder = h_ebeln tables po_items = po_item po_item_schedules = po_sched po_item_account_assignment = po_acct po_item_text = po_text return = return exceptions others = 0. * Verbuchung mit commit and wait, wenn SD im Spiel "94702/KB else. "94702/KB call function 'TRANSACTION_BEGIN' "94702/KB importing "94702/KB transaction_id = transaction_id "94702/KB exceptions "94702/KB others = 1. "94702/KB call function 'BAPI_PO_CREATE' "94702/KB exporting "94702/KB po_header = po_head "94702/KB importing "94702/KB purchaseorder = h_ebeln "94702/KB tables "94702/KB po_items = po_item "94702/KB po_item_schedules = po_sched "94702/KB po_item_account_assignment = po_acct "94702/KB po_item_text = po_text "94702/KB return = return "94702/KB exceptions "94702/KB others = 0. "94702/KB call function 'TRANSACTION_STATUS' "94702/KB importing "94702/KB status = status_of_transaction "94702/KB exceptions "94702/KB others = 1. "94702/KB if status_of_transaction = commit_work. "94702/KB commit work and wait. "94702/KB endif. "94702/KB call function 'TRANSACTION_END' "94702/KB exporting "94702/KB transaction_id = transaction_id "94702/KB exceptions "94702/KB others = 1. "94702/KB endif. "94702/KB * Auswertung der aufgetretenen Fehler und Fortschreiben Protokoll loop at return. error_po = 'X'. move-corresponding return to prot_po. prot_po-vendor = po_head-vendor. append prot_po. endloop. * Merken SD-Katalog in PO-Tabelle um den erneuten Aufruf zu erm鰃lichen clear object_po. if h_ebeln ne space. po_exist = 'X'. object_po-number = h_ebeln. if not sd_katalog is initial. object_po-katalog = sd_katalog. endif. append object_po. endif. clear: po_head, po_item, po_acct, po_text, return. refresh: po_item, po_acct, po_text, return. endform. *&---------------------------------------------------------------------* *& Form CREATE_REQUISITION *&---------------------------------------------------------------------* * Anlegen Bestellanforderung 黚er BAPI_REQUISITION_CREATE *----------------------------------------------------------------------* form create_requisition. clear error_rq. clear rq_exist. clear return. refresh return. * Aufruf BAPI zum Erzeugen der Bestellanforderung call function 'BAPI_REQUISITION_CREATE' exporting skip_items_with_error = 'X' importing number = h_banfn tables requisition_items = req_item requisition_account_assignment = req_acct requisition_item_text = req_text return = return exceptions others = 0. * Auswertung der aufgetretenen Fehler und Fortschreiben Protokoll loop at return. error_rq = 'X'. move-corresponding return to prot_rq. append prot_rq. endloop. * Banfnummer merken if h_banfn ne space. rq_exist = 'X'. object_rq-number = h_banfn. append object_rq. endif. clear: req_item, req_acct, req_text, return. refresh: req_item, req_acct, req_text, return. endform. *&---------------------------------------------------------------------* *& Form CREATE_RESERVATION *&---------------------------------------------------------------------* * Anlegen Reservierung 黚er BAPI_RESERVATION_CREATE *----------------------------------------------------------------------* form create_reservation. clear return. refresh return. * Aufruf BAPI zum Erzeugen der Reservierungen call function 'BAPI_RESERVATION_CREATE' exporting reservation_header = res_head importing reservation = h_rsnum tables reservation_items = res_item return = return exceptions others = 0. * Auswertung der aufgetretenen Fehler und Fortschreiben Protokoll loop at return. error_rs = 'X'. move-corresponding return to prot_rs. prot_rs-material = res_item-material. append prot_rs. endloop. * Reservierungsnummer merken if h_rsnum ne space. rs_exist = 'X'. object_rs-number = h_rsnum. append object_rs. endif. clear: res_item, res_head, return. refresh: res_item, return. endform. *&--------------------------------------------------------------------- * Erzeugen Kundenauftrag *---------------------------------------------------------------------- form create_sd_order. sort object_po by katalog number. loop at object_po where katalog ne space. * f黮len 躡ergabefelder / - tabelle f黵 SD sd_index = sy-tabix. field-set 'PO_NUMBER' 1 object_po-number. next = 0. loop at ban where katalog eq object_po-katalog. add 1 to next. edi_quan = ban-quantity. condense edi_quan. edi_date = ban-deliv_date. perform unit_of_measure_to_iso using ban-unit. field-set 'ORDER_ITEM-QUANTITY' next edi_quan. field-set 'ORDER_ITEM-MATERIAL' next ban-vend_mat. field-set 'ORDER_ITEM-UNIT_ISO' next ban-unit. field-set 'ORDER_ITEM-DELIV_DATE' next edi_date. endloop. * zur點ksetzen Katalog in OBJECT_PO -> diese PO ist bereits weg sd_katalog = object_po-katalog. clear object_po-katalog. modify object_po index sd_index. perform sd_browser_redirect_post. endloop. * keine weiteren POs mehr ans SD zu 黚ergeben if sy-subrc ne 0. no_more_po = 'X'. endif. endform. *&---------------------------------------------------------------------* *& Konvertieren ISO-Currency in internes SAP-Format *&---------------------------------------------------------------------* form currency_to_sap using cts_currency. data: h_waers like ekko-waers. data: h_currency(3). h_currency = cts_currency. clear exitflag. call function 'CURRENCY_CODE_ISO_TO_SAP' exporting iso_code = h_currency importing sap_code = h_waers exceptions not_found = 1 others = 2. * Konvertierung erfolgreich - Feld umsetzen if sy-subrc eq 0. cts_currency = h_waers. else. exitflag = 'X'. endif. endform. *&---------------------------------------------------------------------* *& Form DETERMINE_MATERIAL_INFORECORD *&---------------------------------------------------------------------* * Ermitteln Materialstamm 黚er Lieferantenmaterial aus Infosatz *----------------------------------------------------------------------* form determine_material_inforecord using dmi_vendormat dmi_vendor dmi_material dmi_info_rec. * local table data heina like bapieina occurs 1 with header line. clear: dmi_material, dmi_info_rec. * determine material via vendor material number and vendor number call function 'BAPI_INFORECORD_GETLIST' exporting vendor = dmi_vendor vend_mat = dmi_vendormat purchorg_data = ' ' general_data = 'X' tables inforecord_general = heina return = return exceptions others = 0. read table heina index 1. check sy-subrc eq 0. dmi_material = heina-material. dmi_info_rec = heina-info_rec. endform. *&---------------------------------------------------------------------* *& Form DETERMINE_MATERIAL_MANUFACT *&---------------------------------------------------------------------* * Ermitteln Materialstamm 黚er Herstellerteilenummer und -Code *----------------------------------------------------------------------* form determine_material_manufact using dmm_manufactmat dmm_manufactcode dmm_material. * local tables data hmfrpn like bapimatmfrpn occurs 1 with header line. data hmat like bapimatlst occurs 1 with header line. * determine vendor via the manufacturer code clear: cred_exp, cred_imp. refresh: cred_exp, cred_imp. cred_exp-comp_code = global-co_code. cred_exp-tabname = 'LFA1'. cred_exp-fieldname = 'EMNFR'. cred_exp-fieldvalue = dmm_manufactcode. append cred_exp. * determine internal manufacturer call function 'BAPI_CREDITOR_FIND' tables selopt_tab = cred_exp result_tab = cred_imp exceptions others = 0. read table cred_imp index 1. check sy-subrc eq 0. check not cred_imp-vendor_no is initial. * determine material master with the vendornumber and manufactmat refresh hmfrpn. hmfrpn-manu_mat = dmm_manufactmat. hmfrpn-mfr_no = cred_imp-vendor_no. append hmfrpn. ban-mfr_no = cred_imp-vendor_no. call function 'BAPI_MATERIAL_GETLIST' tables manufacturerpartnumb = hmfrpn matnrlist = hmat exceptions others = 0. read table hmat index 1. check sy-subrc eq 0. dmm_material = hmat-material. endform. *&--------------------------------------------------------------------- * F黮len Kontierungsblockdaten zur Pr黤ung *---------------------------------------------------------------------- form fill_bapicobl. clear bapicobl. bapicobl-pstng_date = sy-datlo. bapicobl-doc_date = sy-datlo. bapicobl-comp_code = global-co_code. bapicobl-bus_area = bapipogna-bus_area. bapicobl-gl_account = bapipogna-g_l_acct. bapicobl-func_area = bapipogna-func_area. bapicobl-func_area_long = bapipogna-func_area_long. bapicobl-co_area = bapipogna-co_area. bapicobl-costcenter = bapipogna-cost_ctr. bapicobl-orderid = bapipogna-order_no. bapicobl-cost_obj = bapipogna-cost_obj. bapicobl-profit_ctr = bapipogna-profit_ctr. bapicobl-wbs_element = bapipogna-wbs_elem_e. bapicobl-network = bapipogna-network. bapicobl-assetmainno = bapipogna-asset_no. bapicobl-assetsubno = bapipogna-sub_number. bapicobl-plant = global-plant. *BAPICOBL-material = bapieban-material. "nur in Position bapicobl-sales_ord = bapipogna-sd_doc. bapicobl-sched_line = bapipogna-sdoc_item. bapicobl-s_ord_item = bapipogna-sched_line. bapicobl-rec_ind = bapipogna-rec_ind. bapicobl-part_acct = bapipogna-part_acct. bapicobl-funds_ctr = bapipogna-funds_ctr. bapicobl-cmmt_item = bapipogna-cmmt_item. bapicobl-cmmt_item_long = bapipogna-cmmt_item_long. bapicobl-fund = bapipogna-fund. endform. *&--------------------------------------------------------------------- * 躡ernehmen Kontierungsblockdaten nach der Pr黤ung *---------------------------------------------------------------------- form fill_bapipogna. bapipogna-bus_area = bapicobl-bus_area. bapipogna-g_l_acct = bapicobl-gl_account. bapipogna-func_area = bapicobl-func_area. bapipogna-func_area_long = bapicobl-func_area_long. bapipogna-co_area = bapicobl-co_area. bapipogna-cost_ctr = bapicobl-costcenter. bapipogna-order_no = bapicobl-orderid. bapipogna-cost_obj = bapicobl-cost_obj. bapipogna-profit_ctr = bapicobl-profit_ctr. bapipogna-wbs_elem_e = bapicobl-wbs_element. bapipogna-network = bapicobl-network. bapipogna-asset_no = bapicobl-assetmainno. bapipogna-sub_number = bapicobl-assetsubno. bapipogna-sd_doc = bapicobl-sales_ord. bapipogna-sdoc_item = bapicobl-sched_line. bapipogna-sched_line = bapicobl-s_ord_item. bapipogna-rec_ind = bapicobl-rec_ind. bapipogna-part_acct = bapicobl-part_acct. bapipogna-funds_ctr = bapicobl-funds_ctr. bapipogna-cmmt_item = bapicobl-cmmt_item. bapipogna-cmmt_item_long = bapicobl-cmmt_item_long. bapipogna-fund = bapicobl-fund. endform. *&--------------------------------------------------------------------- * F黮len Bestellkopfdaten *---------------------------------------------------------------------- form fill_po_head. po_head-doc_type = zug-doc_type. po_head-purch_org = zug-purch_org. po_head-pur_group = ban-pur_group. po_head-agreement = zug-agreement. po_head-vendor = zug-fixed_vend. po_head-created_by = ban-preq_name. if po_head-created_by eq space. po_head-created_by = sy-uname. endif. endform. *&--------------------------------------------------------------------- * F黮len Bestellpositionsdaten *---------------------------------------------------------------------- form fill_po_item. move-corresponding ban to po_item. if ban-po_price ne space. "88951/KB po_item-po_price = 'X'. "88951/KB endif. "88951/KB po_item-po_item = ban-preq_item. po_item-agreement = zug-agreement. po_item-agmt_item = zug-agmt_item. po_item-info_rec = zug-info_rec. po_item-orderpr_un = po_item-unit. "106225/KB perform value_to_bapicurr using ban-preis po_item-net_price ban-currency. append po_item. endform. *&--------------------------------------------------------------------- * F黮len Bestelleinteilungsdaten *---------------------------------------------------------------------- form fill_po_sched. po_sched-po_item = ban-preq_item. po_sched-serial_no = '01'. po_sched-del_datcat = ban-del_datcat. po_sched-deliv_date = ban-deliv_date. po_sched-quantity = ban-quantity. append po_sched. endform. *&--------------------------------------------------------------------- * F黮len Bestellkontierungsdaten *---------------------------------------------------------------------- form fill_po_acct. move-corresponding bsc to po_acct. po_acct-po_item = ban-preq_item. po_acct-quantity = ban-quantity. append po_acct. endform. *&--------------------------------------------------------------------- * F黮len Bestelltexte *---------------------------------------------------------------------- form fill_po_text. move-corresponding bantx to po_text. po_text-po_item = ban-preq_item. append po_text. endform. *&---------------------------------------------------------------------* *& Form FILL_REQ_ITEM *&---------------------------------------------------------------------* * F黮len Positionsdaten in 躡ergabetabellen f黵 BAPI..CREATE *----------------------------------------------------------------------* form fill_req_item. move-corresponding ban to req_item. if req_item-manuf_prof is initial. clear req_item-pur_mat. endif. if req_item-preq_name eq space. req_item-preq_name = sy-uname. endif. perform value_to_bapicurr using ban-preis req_item-c_amt_bapi ban-currency. append req_item. endform. *&---------------------------------------------------------------------* *& Form FILL_REQ_ACCT *&---------------------------------------------------------------------* * F黮len Kontierungsdaten Banf in 躡ergabetabelle f黵 BAPI..CREATE *----------------------------------------------------------------------* form fill_req_acct. move-corresponding bsc to req_acct. append req_acct. endform. *&---------------------------------------------------------------------* *& Form FILL_REQ_TEXT *&---------------------------------------------------------------------* * F黮len Banftexte in 躡ergabetabelle f黵 BAPI..CREATE *----------------------------------------------------------------------* form fill_req_text. move-corresponding bantx to req_text. append req_text. endform. *&---------------------------------------------------------------------* *& Form FILL_RES_HEAD *&---------------------------------------------------------------------* * F黮len Kopfdaten Reservierung in 躡ergabestruktur f黵 CREATE *----------------------------------------------------------------------* form fill_res_head. move-corresponding bsc to res_head. res_head-created_by = ban-preq_name. res_head-res_no = ban-preq_no. res_head-move_type = global-move_type. res_head-res_date = sy-datlo. res_head-plant = ban-plant. if res_head-created_by eq space. res_head-created_by = sy-uname. endif. endform. *&---------------------------------------------------------------------* *& Form FILL_RES_ITEM *&---------------------------------------------------------------------* * F黮len Positionsdaten Reservierung in 躡ergabetabelle f黵 CREATE *----------------------------------------------------------------------* form fill_res_item. move-corresponding bsc to res_item. res_item-material = ban-material. res_item-short_text = ban-short_text. res_item-plant = ban-plant. res_item-store_loc = ban-store_loc. res_item-batch = ban-batch. res_item-req_date = ban-deliv_date. res_item-quantity = ban-quantity. res_item-unit = ban-unit. if res_item-gr_rcpt eq space. res_item-gr_rcpt = sy-uname. endif. append res_item. endform. *&---------------------------------------------------------------------* *& Form FILL_XEKPO *&---------------------------------------------------------------------* * versorgen interne Tabelle XEKPO mit internen Werten *----------------------------------------------------------------------* form fill_xekpo tables po_itemdet structure bapiekpo xekpo structure ekpo using object_po-salesdocument. xekpo-mandt = sy-mandt. xekpo-ebeln = po_itemdet-po_number. xekpo-ebelp = po_itemdet-po_item. xekpo-labnr = object_po-salesdocument. xekpo-idnlf = po_itemdet-vend_mat. append xekpo. endform. *&---------------------------------------------------------------------* *& Ermitteln g黮tige Kataloge *&---------------------------------------------------------------------* form get_catalogs using gca_mat_grp gca_plant. refresh: h_cat, catalogs. clear : h_cat, catalogs. call function 'BAPI_PROCOPERATION_GETCATALOGS' exporting material_group = gca_mat_grp plant = gca_plant tables valid_catalogs = h_cat return = return. loop at h_cat. catalogs-katalog = h_cat-catalog. catalogs-lifnr = h_cat-vendor. catalogs-ekorg = h_cat-purch_org. catalogs-sd_catalog = h_cat-sd_catalog. catalogs-katbez = h_cat-cat_text. append catalogs. endloop. endform. *&---------------------------------------------------------------------* *& Ermitteln Hausw鋒rung als Vorschlagsw鋒rung *&---------------------------------------------------------------------* form get_currency. data: begin of compdeta. include structure bapi0002_2. data: end of compdeta. check global-currency is initial. check not global-co_code is initial. call function 'BAPI_COMPANYCODE_GETDETAIL' exporting companycodeid = global-co_code importing companycode_detail = compdeta. global-currency = compdeta-currency. endform. *&---------------------------------------------------------------------* *& Ermitteln Buchungskreis aus GLOBAL-PLANT *&---------------------------------------------------------------------* form get_company_code. check global-co_code is initial. if global-plant ne t001w-werks. select single * from t001w where werks eq global-plant. check sy-subrc eq 0. endif. if t001k-bwkey ne t001w-bwkey. select single * from t001k where bwkey eq t001w-bwkey. check sy-subrc eq 0. endif. global-co_code = t001k-bukrs. endform. *&---------------------------------------------------------------------* *& Ermitteln Kundennummer f黵 SD-Katalog *&---------------------------------------------------------------------* form get_customer_number. clear: bapi1008_5, bapireturn, customer_no. * read the company code level date for the customer number at vendor call function 'BAPI_CREDITOR_GETDETAIL' exporting creditorid = sel_vendor companycode = global-co_code importing creditor_company_detail = bapi1008_5 return = bapireturn exceptions others = 0. * if no error occured - move customer number in the internal field check bapireturn-type ne 'E'. customer_no = bapi1008_5-act_at_ven. endform. *&---------------------------------------------------------------------* *& Ermitteln F4-Hilfen f黵 versch. Felder *&---------------------------------------------------------------------* form get_helpvalues tables f4_tab1 structure bapif4b f4_tab2 structure bapif4c f4_tab3 structure bapif4d f4_tab4 structure bapif4e using ghv_objname ghv_method ghv_parameter ghv_field. * call BAPI for the helpvalues call function 'BAPI_HELPVALUES_GET' exporting objname = ghv_objname method = ghv_method parameter = ghv_parameter field = ghv_field tables selection_for_helpvalues = f4_tab1 helpvalues = f4_tab2 values_for_field = f4_tab3 description_for_helpvalues = f4_tab4 exceptions others = 0. endform. *&---------------------------------------------------------------------* *& Erzeugen Textzeilen f黵 neue Position *&---------------------------------------------------------------------* form init_bantx. clear bantx. do 3 times. bantx-preq_item = ban-preq_item. append bantx. enddo. endform. *&---------------------------------------------------------------------* *& Erzeugen Kontierungszeile f黵 neue Position *&---------------------------------------------------------------------* form init_bsc. clear bankey. bankey-preq_item = ban-preq_item. read table ban with key bankey binary search. check sy-subrc eq 0. clear bsckey. bsckey-preq_item = ban-preq_item. bsckey-serial_no = '01'. read table bsc with key bsckey binary search. h_index1 = sy-tabix. if sy-subrc ne 0. move-corresponding bsckey to bsc. move-corresponding global to bsc. if global-g_l_acct is initial. clear h_wbs_elem. * Aufruf zu einem sp鋞eren Release auf BAPI umstellen - mom. nicht da call function 'ME_ACCOUNT_ASSIGNMENT' exporting i_matnr = ban-pur_mat i_werks = ban-plant i_bwtar = space i_sobkz = space i_vbeln = space i_vbelp = '000000' i_ps_psp_pnr = h_wbs_elem i_kzbws = space i_knttp = ban-acctasscat i_matkl = ban-mat_grp importing e_sakto = bsc-g_l_acct exceptions others = 0. endif. bsc-preq_qty = ban-quantity. insert bsc index h_index1. endif. endform. *&--------------------------------------------------------------------- * Globale Daten initialisieren *---------------------------------------------------------------------- form init_global_data. get parameter id 'WRK' field h_werks. if bapipogn-plant is initial. bapipogn-plant = h_werks. endif. get parameter id 'EKG' field h_ekgrp. if bapipogn-pur_group is initial. bapipogn-pur_group = h_ekgrp. endif. get parameter id 'WGR' field h_matkl. if bapipogn-mat_grp is initial. bapipogn-mat_grp = h_matkl. endif. get parameter id 'LAG' field h_lgort. if bapipogn-store_loc is initial. bapipogn-store_loc = h_lgort. endif. get parameter id 'CNT' field h_kostl. if bapipogna-cost_ctr is initial. bapipogna-cost_ctr = h_kostl. endif. get parameter id 'BSA' field h_bsart. if bapipogn-doc_type is initial. bapipogn-doc_type = h_bsart. endif. get parameter id 'BWA' field h_bwart. if bapipogn-move_type is initial. bapipogn-move_type = h_bwart. endif. if bapipogn-acctasscat is initial. bapipogn-acctasscat = 'K'. endif. if bapipogn-preq_name is initial. bapipogn-preq_name = sy-uname. endif. if bapipogna-gr_rcpt is initial. bapipogna-gr_rcpt = sy-uname. endif. if bapipogna-g_l_acct is initial. clear h_wbs_elem. * Aufruf zu einem sp鋞eren Release auf BAPI umstellen - mom. nicht da call function 'ME_ACCOUNT_ASSIGNMENT' exporting i_matnr = space i_werks = bapipogn-plant i_bwtar = space i_sobkz = space i_vbeln = space i_vbelp = '000000' i_ps_psp_pnr = h_wbs_elem i_kzbws = space i_knttp = bapipogn-acctasscat i_matkl = bapipogn-mat_grp importing e_sakto = bapipogna-g_l_acct exceptions others = 0. endif. endform. *&---------------------------------------------------------------------* *& Verf黦barkeitspr黤ung Material anstossen *&---------------------------------------------------------------------* form material_availability using maa_item maa_material maa_plant maa_quantity maa_unit maa_delivdate. clear: xwmdvsx, xwmdvex. refresh: xwmdvsx, xwmdvex. * Zur點ksetzen AVAIL zur Position loop at avail where preq_item eq maa_item. delete avail. endloop. * F黮len 躡ergabestrukturen xwmdvsx-req_date = maa_delivdate. xwmdvsx-req_qty = maa_quantity. append xwmdvsx. * Aufruf Verf黦barkeitspr黤ung call function 'BAPI_MATERIAL_AVAILABILITY' exporting plant = maa_plant material = maa_material unit = maa_unit check_rule = '03' importing endleadtme = end_rlt av_qty_plt = avail_qty_plant dialogflag = not_available tables wmdvsx = xwmdvsx wmdvex = xwmdvex exceptions error_message = 1. * zuerst angeforderte Menge in Tabelle eintragen, bzw. 1. Eintrag mod. loop at avail where preq_item eq maa_item. avail-preq_item = maa_item. avail-select = 'X'. avail-menge = maa_quantity. avail-lfdat = maa_delivdate. avail-available = 'No'. avail-unit = maa_unit. modify avail index sy-tabix. exit. endloop. if sy-subrc ne 0. avail-preq_item = maa_item. avail-select = 'X'. avail-menge = maa_quantity. avail-lfdat = maa_delivdate. avail-available = 'No'. avail-unit = maa_unit. append avail. endif. clear h_menge. * nun die Daten aus der Verf黦barkeit hinten anh鋘gen loop at xwmdvex. avail_key-preq_item = maa_item. avail_key-select = 'X'. avail_key-menge = xwmdvex-com_qty + h_menge. avail_key-lfdat = xwmdvex-com_date. read table avail with key avail_key. if sy-subrc ne 0. move-corresponding avail_key to avail. clear avail-select. avail-available = 'Yes'. if not avail-menge is initial. avail-unit = maa_unit. append avail. endif. else. avail-available = 'Yes'. modify avail index sy-tabix. endif. h_menge = avail_key-menge. endloop. endform. *&---------------------------------------------------------------------* *& Verf黦barkeitspr黤ung Material anstossen und Daten 黚ernehmen *&---------------------------------------------------------------------* form material_availability_check. * Aufruf Verf黦barkeit mit ge鋘derter Menge oder Termin perform material_availability using ban-preq_item ban-material ban-plant ban-quantity ban-unit ban-deliv_date. * Pr黤en, ob diese Menge zum gew黱schten Termin verf黦bar -> Ampel avail_key-preq_item = ban-preq_item. avail_key-select = 'X'. avail_key-menge = ban-quantity. avail_key-lfdat = ban-deliv_date. read table avail with key avail_key. if sy-subrc eq 0 and avail-available eq 'Yes'. ban-available = 'X'. ban-avail_qty = ban-quantity. endif. endform. *&---------------------------------------------------------------------* *& Lesen Material mit Materialnummer *&---------------------------------------------------------------------* form material_get using h_matnr. clear: no_material, no_status_b. * pr黤en, ob Material bereits gelesen read table mat_tab with key h_matnr binary search. * wenn nicht, nachlesen if sy-subrc ne 0. h_tabix = sy-tabix. clear: mtcom, mt06e, mtcor. mtcom-kenng = 'MT06E'. mtcom-matnr = h_matnr. mtcom-werks = global-plant. mtcom-spras = sy-langu. mtcom-pstat = 'EBD'. mtcom-kzspr = 'X'. mtcom-spr_meins = 'X'. mtcom-kzmpn = 'X'. call function 'MATERIAL_READ' exporting schluessel = mtcom importing matdaten = mt06e return = mtcor tables seqmat01 = tdummy exceptions error_message = 01. * Material nicht vorhanden if mt06e is initial or sy-subrc ne 0. no_material = 'X'. exit. endif. * Buchhaltungssicht ist Minimum if mtcom-pstat ca 'B' and mtcor-fstat ca 'B'. no_status_b = 'X'. exit. endif. * sichern Daten in interner Tabelle mat_tab-pur_mat = h_matnr. mat_tab-material = mt06e-bmatn. if mt06e-mprof is initial. mat_tab-material = h_matnr. endif. mat_tab-manuf_prof = mt06e-mprof. mat_tab-short_text = mt06e-maktx. mat_tab-mat_grp = mt06e-matkl. mat_tab-unit = mt06e-meins. if mt06e-vprsv ne space. mat_tab-c_amt_bapi = mt06e-verpr. if mt06e-vprsv eq 'S'. mat_tab-c_amt_bapi = mt06e-stprs. endif. mat_tab-price_unit = mt06e-peinh. endif. mat_tab-plant = global-plant. mat_tab-pur_group = mt06e-ekgrp. if mat_tab-pur_group eq space. mat_tab-pur_group = global-pur_group. endif. insert mat_tab index h_tabix. endif. endform. *&--------------------------------------------------------------------- * Erzeugen neue leere Positionszeilen *---------------------------------------------------------------------- form new_items. sort ban by preq_no preq_item. clear ban. h-tabix = 1. h_bnfpo = 0. * diese Abfrage nur sicherheitshalber if ban[] is initial. do 10 times. h_bnfpo = h_bnfpo + 1. ban-preq_item = h_bnfpo. ban-quantity = 1. ban-c_amt_bapi = 1. ban-preis = 1. ban-deliv_date = sy-datlo. ban-del_datcat = '1'. append ban. enddo. else. * ab 50 Positionen geht nix mehr - Fehler und tsch describe table ban lines count1. if count1 ge 50. message s067. clear ok-code. exit. endif. read table ban index count1. h_bnfpo = ban-preq_item. clear ban. * wenn noch was geht, werden einfach 5 neue aufgemacht... do 5 times. h_bnfpo = h_bnfpo + 1. ban-preq_item = h_bnfpo. ban-quantity = 1. ban-c_amt_bapi = 1. ban-preis = 1. ban-deliv_date = sy-datlo. ban-del_datcat = '1'. append ban. enddo. endif. endform. *&--------------------------------------------------------------------- * Fortschreiben Kundenauftragsnummer in den Bestellungen *---------------------------------------------------------------------- form po_confirmation. loop at object_po where salesdocument ne space. clear: po_itemdet, xekpo. refresh: po_itemdet, xekpo. * sperren Bestellung call function 'MM_ENQUEUE_DOCUMENT' exporting i_ebeln = object_po-number i_bstyp = 'F'. * besorgen Positionsdaten call function 'BAPI_PO_GETDETAIL' exporting purchaseorder = object_po-number tables po_items = po_itemdet return = return. * f黮len interne Struktur f黵 Position plus f黮len SD-Auftragsnummer loop at po_itemdet. perform fill_xekpo tables po_itemdet xekpo using object_po-salesdocument. endloop. if not xekpo[] is initial. * verbuchen 膎derung aber ohne 膎derungsbeleg call function 'ME_UPDATE_DOCUMENT_RESPONSE' "IN UPDATE TASK tables xekpo = xekpo exceptions update_mistake = 01. else. * falls keine Positionen vorhanden, entsperren Bestellung call function 'DEQUEUE_EMEKKOE' exporting ebeln = object_po-number. endif. endloop. endform. *&--------------------------------------------------------------------- * Neuvergeben Positionsnummern nach L鰏chen einer Position *---------------------------------------------------------------------- form prepare_preq_item. data: h_preqitem like bapieban-preq_item. sort ban by preq_no preq_item. next = 0. loop at ban. add 1 to next. check ban-preq_item ne next. h_preqitem = ban-preq_item. ban-preq_item = next. modify ban index sy-tabix. loop at bsc where preq_item eq h_preqitem. bsc-preq_item = ban-preq_item. modify bsc index sy-tabix. endloop. loop at bantx where preq_item eq h_preqitem. bantx-preq_item = ban-preq_item. modify bantx index sy-tabix. endloop. if ban-update ne space. h_banpos = ban-preq_item. endif. endloop. endform. *&--------------------------------------------------------------------- * Lesen interne Tabelle BAN mit Key *---------------------------------------------------------------------- form read_ban_with_key using rbw_item. clear bankey. bankey-preq_item = rbw_item. read table ban with key bankey. endform. *&--------------------------------------------------------------------- * Lesen interne Tabelle BSC mit Key *---------------------------------------------------------------------- form read_bsc_with_key using rbw_item. clear bsckey. bsckey-preq_item = rbw_item. bsckey-serial_no = '01'. read table bsc with key bsckey. endform. *&--------------------------------------------------------------------- * Lesen vorhandene Bestellungen zum User f黵 Status *---------------------------------------------------------------------- form read_po_items. check read_po ne space. * zur點ksetzen alle betroffenen Tabellen clear: spo_head, spo_item, po_item, spo_acct, spo_sched, spo_hist, spo_hist_sum. refresh: spo_head, spo_item, po_item, spo_acct, spo_sched, spo_hist, &nb |

