Purpose Call with tables and structures (BAPI_SALESORDER_SIMULATE) We want to call up a BAPI function, passing and returning values in structures and tables. |
// item table for UI // BAPI stuctures
and tables for BAPI_SALESORDER_SIMULATE endif // display UI InputField (0,0) "Customer" (0,20) size=10 name="kunnr" techName="VBAK-KUNNR"// custmer name returned by BAPI // Item table Column "St" size=3 name="status" -readOnly Column "Material" size=18 name="matnr" techName="VBAP-MATNR" Column "Quantity" size=10 name="quantity" Column "Unit" size=6 name="unit" -readOnly Column "Text" size=30 name="shorttext" -readOnly Column "Price" size=10 name="price" -readOnly Column "Curr" size=5 name="currency" -readOnly Column "Deliv.Date" size=12 name="avail_date" -readOnly Column "Quantity" size=10 name="avail_quantity" -readOnly // Button to determine prices and availablity process="determine_price.txt"
// fill order header (fixed data) Set V[header_in.sales_org] "1000" Set V[header_in.distr_chan] "10" Set V[header_in.division] "00" // fill partner table Set V[partners.partn_numb.1] "&V[kunnr]" // fill items table label next_itemif V[orderitems.matnr.&V[k]] Set V[items_in.material.&V[k]] "&V[orderitems.matnr.&V[k]]" // the quantity requires 3 decimals in the BAPI interface Set V[items_in.req_qty.&V[k]] "&V[orderitems.quantity.&V[k]]" * 1000 Set V[k] &V[k] + 1 goto next_item endif // call up the order simulation export.order_header_in="header_in" _ export.order_partners="partners" _ export.order_items_in="items_in" _ import.sold_to_party="sold_to" _ import.order_items_out="items_out" _ import.order_schedule_ex="schedule_ex" _ import.return="bapireturn" // any error message? Return "E: &V[bapireturn.message]" -statusline endif // copy results into order item table label next_item_out if V[items_in.material.&V[k]] Set V[orderitems.price.&V[k]] "&V[items_out.net_value1.&V[k]]" / 10000 decimals=2 Set V[orderitems.unit.&V[k]] "&V[items_out.sales_unit.&V[k]]" Set V[orderitems.shorttext.&V[k]] "&V[items_out.short_text.&V[k]]" Set V[orderitems.currency.&V[k]] "&V[items_out.currency.&V[k]]" // determine availability from schedule table Clear V[orderitems.avail_date.&V[k]] Clear V[orderitems.avail_quantity.&V[k]] Set V[n] 1 label next_delivery if V[schedule_ex.itm_number.&V[n]] if V[schedule_ex.itm_number.&V[n]=&V[items_out.itm_number.&V[k]]] _ and V[schedule_ex.req_qty.&V[n]>0] Set V[orderitems.avail_date.&V[k]] "&V[schedule_ex.req_date.&V[n]]" Set V[orderitems.avail_quantity.&V[k]] "&V[schedule_ex.req_qty.&V[n]]" / 1000 decimals=0 goto set_status_icon endif Set V[n] &V[n] + 1 goto next_delivery endif // set red status icon if no price could be
determined Set V[orderitems.status.&V[k]] "@5B@" // green OK icon if V[orderitems.price.&V[k]=0.00] Set V[orderitems.status.&V[k]] "@5D\QNo price available@" // yellow endif if not V[orderitems.avail_quantity.&V[k]=&V[orderitems.quantity.&V[k]]] Set V[orderitems.status.&V[k]] "@5C\QProduct not available@" // red endif Set
V[k]
&V[k]
+ 1 // done |
Components |