* 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.
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.
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.
*&---------------------------------------------------------------------*
*& ?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.
* 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.
*&---------------------------------------------------------------------*
*& 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
* 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
*&---------------------------------------------------------------------*
*& ?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.
* 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
* 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.
*&---------------------------------------------------------------------
* 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.
*&---------------------------------------------------------------------*
*& 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.
*&---------------------------------------------------------------------*
*& 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.
*&---------------------------------------------------------------------
* F?len Kontierungsblockdaten zur Pr?ung
*----------------------------------------------------------------------
form fill_bapicobl.
*&---------------------------------------------------------------------
* ?ernehmen Kontierungsblockdaten nach der Pr?ung
*----------------------------------------------------------------------
form fill_bapipogna.
*&---------------------------------------------------------------------
* 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.
*&---------------------------------------------------------------------*
*& 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.
* 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.
*&---------------------------------------------------------------------*
*& 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.
*&---------------------------------------------------------------------
* 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.
* 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.
* 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.
*&---------------------------------------------------------------------
* Lesen vorhandene Bestellungen zum User f? Status
*----------------------------------------------------------------------
form read_po_items.
* lesen alle PO-items zum User
call function 'BAPI_PO_GETITEMS'
exporting
doc_date = sel_date
preq_name = sy-uname
with_po_headers = 'X'
tables
po_headers = spo_head
po_items = po_item
return = return
exceptions
others = 0.
* l?chen der Dienstleistungen
loop at po_item.
if po_item-item_cat = '9'.
delete po_item.
endif.
endloop.
sort spo_head by po_number.
clear: h_ebeln,
po_details.
refresh: po_details.
* Aufruf GETDETAIL wegen Ampel auf ?ersichtsbild - Historie
* Wird auf dem ?ersichtsbild das Detailbild zur Bestellung gew?lt,
* mu?nicht noch der GETDETAIL aufgerufen werden - merken in int. Tab.
loop at po_item.
* nur beim Gruppenwechsel den GETDETAIL aufrufen
if po_item-po_number ne h_ebeln and
h_ebeln ne space.
clear: po_itemdet, po_acct, po_sched, po_hist, po_hist_sum.
refresh: po_itemdet, po_acct, po_sched, po_hist, po_hist_sum.
call function 'BAPI_PO_GETDETAIL'
exporting
purchaseorder = h_ebeln
items = 'X'
account_assignment = 'X'
schedules = 'X'
history = 'X'
tables
po_items = po_itemdet
po_item_account_assignment = po_acct
po_item_schedules = po_sched
po_item_history = po_hist
po_item_history_totals = po_hist_sum
return = return
exceptions
others = 0.
* merken aller Daten zur Bestellung in internen Tabellen f? Detailbild
read table spo_head with key h_ebeln binary search.
move-corresponding spo_head to spo_item.
loop at po_itemdet.
detailkey-number = po_itemdet-po_number.
detailkey-position = po_itemdet-po_item.
read table po_details with key detailkey.
if sy-subrc eq 0.
move-corresponding po_itemdet to spo_item.
spo_item-preq_name = sy-uname.
append spo_item.
endif.
endloop.
loop at po_acct.
spo_acct-po_number = po_itemdet-po_number.
detailkey-number = po_itemdet-po_number.
detailkey-position = po_acct-po_item.
read table po_details with key detailkey.
if sy-subrc eq 0.
move-corresponding po_acct to spo_acct.
append spo_acct.
endif.
endloop.
loop at po_sched.
spo_sched-po_number = po_itemdet-po_number.
detailkey-number = po_itemdet-po_number.
detailkey-position = po_sched-po_item.
read table po_details with key detailkey.
if sy-subrc eq 0.
move-corresponding po_sched to spo_sched.
append spo_sched.
endif.
endloop.
loop at po_hist.
spo_hist-po_number = po_itemdet-po_number.
detailkey-number = po_itemdet-po_number.
detailkey-position = po_hist-po_item.
read table po_details with key detailkey.
if sy-subrc eq 0.
move-corresponding po_hist to spo_hist.
append spo_hist.
endif.
endloop.
loop at po_hist_sum.
spo_hist_sum-po_number = po_itemdet-po_number.
detailkey-number = po_itemdet-po_number.
detailkey-position = po_hist_sum-po_item.
read table po_details with key detailkey.
if sy-subrc eq 0.
move-corresponding po_hist_sum to spo_hist_sum.
append spo_hist_sum.
endif.
endloop.
endif.
h_ebeln = po_item-po_number.
po_details-po_number = po_item-po_number.
po_details-po_item = po_item-po_item.
append po_details.
endloop.
* merken aller Daten zur Bestellung in internen Tabellen f? Detailbild
read table spo_head with key h_ebeln binary search.
move-corresponding spo_head to spo_item.
loop at po_itemdet.
detailkey-number = po_itemdet-po_number.
detailkey-position = po_itemdet-po_item.
read table po_item with key detailkey.
if sy-subrc eq 0.
move-corresponding po_itemdet to spo_item.
spo_item-preq_name = sy-uname.
append spo_item.
endif.
endloop.
loop at po_acct.
spo_acct-po_number = po_itemdet-po_number.
detailkey-number = po_itemdet-po_number.
detailkey-position = po_acct-po_item.
read table po_item with key detailkey.
if sy-subrc eq 0.
move-corresponding po_acct to spo_acct.
append spo_acct.
endif.
endloop.
loop at po_sched.
spo_sched-po_number = po_itemdet-po_number.
detailkey-number = po_itemdet-po_number.
detailkey-position = po_sched-po_item.
read table po_item with key detailkey.
if sy-subrc eq 0.
move-corresponding po_sched to spo_sched.
append spo_sched.
endif.
endloop.
loop at po_hist.
spo_hist-po_number = po_itemdet-po_number.
detailkey-number = po_itemdet-po_number.
detailkey-position = po_hist-po_item.
read table po_item with key detailkey.
if sy-subrc eq 0.
move-corresponding po_hist to spo_hist.
append spo_hist.
endif.
endloop.
loop at po_hist_sum.
spo_hist_sum-po_number = po_itemdet-po_number.
detailkey-number = po_itemdet-po_number.
detailkey-position = po_hist_sum-po_item.
read table po_item with key detailkey.
if sy-subrc eq 0.
move-corresponding po_hist_sum to spo_hist_sum.
append spo_hist_sum.
endif.
endloop.
endif.
* Auswerten f? Ampelanzeige (hier wird vorerst nur die WEMNG und WESPS
* in die Auswertung genommen)
sort spo_hist_sum by po_number po_item.
loop at spo_item.
h_index = sy-tabix.
clear pokey.
pokey-po_number = spo_item-po_number.
pokey-po_item = spo_item-po_item.
read table spo_hist_sum with key pokey binary search.
if sy-subrc ne 0.
spo_item-cl_ind = red.
else.
if spo_hist_sum-deliv_qty ge spo_item-quantity or
spo_hist_sum-blocked_qy ge spo_item-quantity.
spo_item-cl_ind = green.
else.
if spo_hist_sum-deliv_qty eq 0 and
spo_hist_sum-blocked_qy eq 0.
spo_item-cl_ind = red.
else.
spo_item-cl_ind = yellow.
endif.
endif.
endif.
modify spo_item index h_index.
endloop.
if spo_item[] is initial.
clear read_po.
endif.
endform.
*&---------------------------------------------------------------------
* Lesen Bestellposition f? Statusdetailbild
*----------------------------------------------------------------------
form read_po_detail.
* Position mu?in internen Tabellen vorhanden sein - Daten bereitstellen
sort spo_item by po_number po_item.
sort spo_head by po_number.
sort spo_hist_sum by po_number po_item.
sort spo_acct by po_number po_item.
sort spo_sched by po_number po_item.
read table spo_head with key pokey-po_number binary search.
read table spo_hist_sum with key pokey binary search.
if sy-subrc ne 0.
clear spo_hist_sum.
endif.
read table spo_sched with key pokey binary search.
if sy-subrc ne 0.
clear spo_sched.
endif.
read table spo_acct with key pokey binary search.
if sy-subrc ne 0.
clear spo_acct.
endif.
endform.
*&---------------------------------------------------------------------
* Lesen vorhandene Bestellanforderungen zum User f? Status
*----------------------------------------------------------------------
form read_requisitions.
check read_rq ne space.
clear: req_stat, req_item.
refresh: req_stat, req_item.
*&---------------------------------------------------------------------
* Lesen vorhandene Reservierungen zum User f? Status
*----------------------------------------------------------------------
form read_reservations.
check read_rs ne space.
clear: res_stat, res_stat1.
refresh: res_stat, res_stat1.
* f?len Statustabelle
loop at res_stat1.
move-corresponding res_stat1 to res_stat.
if res_stat1-withd_quan ge res_stat1-quantity.
res_stat-cl_ind = green.
else.
if res_stat-withd_quan = 0.
res_stat-cl_ind = red.
else.
res_stat-cl_ind = yellow.
endif.
endif.
append res_stat.
endloop.
if res_stat[] is initial.
clear read_rs.
endif.
endform.
*&---------------------------------------------------------------------
* Lesen Detail Reservierung f? Statusdetailbild
*----------------------------------------------------------------------
form read_reservations_detail.
* zuerst lesen, ob GETDETAIL bereits aufgerufen
read table sres_item with key reskey binary search.
clear h_meins1.
if sy-subrc ne 0.
* falls nicht - nachlesen und in SRES_ITEM merken
clear: res_itemdet, bapirkpf.
refresh: res_itemdet.
call function 'BAPI_RESERVATION_GETDETAIL'
exporting
reservation = reskey-res_no
importing
reservation_header = bapirkpf
tables
reservation_items = res_itemdet
return = return
exceptions
others = 0.
loop at res_itemdet.
read table sres_item with key reskey binary search.
if sy-subrc ne 0.
move-corresponding bapirkpf to sres_item.
move-corresponding res_itemdet to sres_item.
insert sres_item index sy-tabix.
endif.
endloop.
endif.
h_meins1 = sres_item-unit.
endform.
*&---------------------------------------------------------------------
* Refresh all internal tables and structures
*----------------------------------------------------------------------
form refresh_all.
* f?len der ?ergabetabellen f? 'Entscheidungsbapi'
loop at ban where update ne space.
move-corresponding ban to proc.
proc-catalog = ban-katalog.
perform value_to_bapicurr using ban-preis proc-c_amt_bapi
ban-currency.
append proc.
endloop.
loop at bsc.
move-corresponding bsc to proc_acct.
append proc_acct.
endloop.
* Analysieren Positionen nach Customizing und Positionsdaten
if not proc[] is initial.
call function 'BAPI_PROCOPERATION_GETINFO'
tables
procurement_item = proc
procurement_account = proc_acct
return = return
exceptions
others = 0.
endif.
* Zuerst alle Positionen ohne Objektzuordnung in Protokolltabelle
loop at proc where obj_to_gen ne req and
obj_to_gen ne res and
obj_to_gen ne po.
error_pr = 'X'.
move-corresponding proc to proc_prot.
append proc_prot.
endloop.
* Dann alle Banfpositionen
loop at proc where obj_to_gen eq req.
perform read_ban_with_key using proc-preq_item.
perform fill_req_item.
loop at bsc where preq_item eq proc-preq_item.
perform fill_req_acct.
endloop.
loop at bantx where preq_item eq proc-preq_item
and text_line ne space.
perform fill_req_text.
endloop.
endloop.
if not req_item[] is initial.
perform create_requisition.
endif.
clear error_rs.
clear rs_exist.
* Dann alle Reservierungen
loop at proc where obj_to_gen eq res.
perform read_ban_with_key using proc-preq_item.
perform read_bsc_with_key using proc-preq_item.
perform fill_res_head.
perform fill_res_item.
* Reservierung pro Position anlegen, wegen der Kontierung im Kopf
perform create_reservation.
endloop.
clear error_po.
clear po_exist.
* Zuletzt alle Bestellungen abarbeiten
loop at proc where obj_to_gen eq po.
* Gruppenwechsel in Bezugsquelle abfragen - nur einmal Kopfdaten
if zug-fixed_vend ne proc-fixed_vend or
zug-agreement ne proc-agreement or
zug-purch_org ne proc-purch_org or
zug-doc_type ne proc-doc_type.
if not zug is initial.
clear sd_katalog.
perform read_ban_with_key using zug-preq_item.
perform fill_po_head.
if ban-sd ne space.
sd_katalog = ban-katalog.
endif.
perform create_po.
clear sd_katalog.
endif.
endif.
move-corresponding proc to zug.
perform read_ban_with_key using proc-preq_item.
perform fill_po_item.
perform fill_po_sched.
loop at bsc where preq_item eq proc-preq_item.
perform fill_po_acct.
endloop.
loop at bantx where preq_item eq proc-preq_item
and text_line ne space.
perform fill_po_text.
endloop.
endloop.
* letzte Bestellung sichern
check not zug is initial.
clear sd_katalog.
perform read_ban_with_key using zug-preq_item.
perform fill_po_head.
if ban-sd ne space.
sd_katalog = ban-katalog.
endif.
perform create_po.
clear sd_katalog.
* Aufruf Kundenauftrag f? alle Bestellungen aus SD/Retail
perform create_sd_order.
endform.
*&---------------------------------------------------------------------
* Setzen HOOK-URL und rufen SD-Katalog f? Buchen
*----------------------------------------------------------------------
form sd_browser_redirect_post.
*&---------------------------------------------------------------------*
*& ?dern Position ?er das Detailbild - Verf?barkeitsdaten
*&---------------------------------------------------------------------*
form store_availability.
clear bankey.
bankey-preq_item = bapieban-preq_item.
read table ban with key bankey binary search.
h_index = sy-tabix.
* 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.
*&---------------------------------------------------------------------
* Globale Daten merken und in der Struktur GLOBAL sichern
*----------------------------------------------------------------------
form store_global_data.
move-corresponding bapipogn to global.
perform get_catalogs using global-mat_grp global-plant.
perform get_company_code.
perform get_currency.
perform check_account_assignment.
check exitflag eq space.
move-corresponding bapipogna to global.
loop at ban where update ne space.
* bei Materialposition Warengruppe nicht aus Global ?erschreiben
if ban-pur_mat ne space.
h_matkl = ban-mat_grp.
endif.
move-corresponding global to ban.
if ban-pur_mat ne space.
ban-mat_grp = h_matkl.
endif.
modify ban.
endloop.
loop at bsc.
move-corresponding global to bsc.
modify bsc.
endloop.
endform.
*&---------------------------------------------------------------------*
*& ?dern Position ?er das Detailbild - Bezugsquellen
*&---------------------------------------------------------------------*
form store_source_of_supply.
read table sosweb index select_sos.
check sy-subrc eq 0.
clear bankey.
bankey-preq_item = bapieban-preq_item.
read table ban with key bankey binary search.
h_index = sy-tabix.
* zur?ksetzen Preis?ernahme in PO, wenn pos. nicht aus Katalog,
* aber nun g?tige Bezugsquelle sitzt
* bei Katalogpositionen werden nur zus?zl. Konditionen aus der
* Bezugsquelle ?ernommen, aber nicht der Bruttopreis - der aus Katalog
if not ban-po_price is initial and
ban-katalog is initial and
( not ban-agreement is initial or
not ban-info_rec is initial ).
clear ban-po_price.
endif.
modify ban index h_index.
endform.
*&---------------------------------------------------------------------*
*& Form REFRESH_STATUS_TABLES for new selection
*&---------------------------------------------------------------------*
form refresh_status_tables.
*&---------------------------------------------------------------------*
*& Konvertieren SAP-UNIT in ISO-Unit
*&---------------------------------------------------------------------*
form unit_of_measure_to_iso using uof_unit.
data: h_unit_iso(3).
call function 'UNIT_OF_MEASURE_SAP_TO_ISO'
exporting
sap_code = uof_unit
importing
iso_code = h_unit_iso
exceptions
not_found = 1
no_iso_code = 2
others = 3.
* Konvertierung erfolgreich - Feld umsetzen
* fall Konvertierung nicht erfolgreich mit Katalogunit einfach weiter
if sy-subrc eq 0.
uof_unit = h_unit_iso.
endif.
endform.
*&---------------------------------------------------------------------*
*& Konvertieren ISO-UNIT in internes SAP-Format
*&---------------------------------------------------------------------*
form unit_of_measure_to_sap using uof_unit.
data: h_unit like t006-msehi.
clear exitflag.
call function 'UNIT_OF_MEASURE_ISO_TO_SAP'
exporting
iso_code = uof_unit
importing
sap_code = h_unit
exceptions
not_found = 1
others = 2.
* Konvertierung erfolgreich - Feld umsetzen
* fall Konvertierung nicht erfolgreich mit Katalogunit einfach weiter
if sy-subrc eq 0.
uof_unit = h_unit.
else.
exitflag = 'X'.
endif.
endform.
*&---------------------------------------------------------------------*
*& Konvertieren interner Wert in BAPICURR-Format
*&---------------------------------------------------------------------*
form value_to_bapicurr using vtb_preis vtb_preqprice vtb_currency.
*&---------------------------------------------------------------------*
*& Konvertieren externer Wert in internes SAP-Format
*&---------------------------------------------------------------------*
form value_to_sap using vts_currency vts_value.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.