Skip to content

Instantly share code, notes, and snippets.

@js1972
Created October 31, 2014 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save js1972/c780aa6746d277dc5dd3 to your computer and use it in GitHub Desktop.
Save js1972/c780aa6746d277dc5dd3 to your computer and use it in GitHub Desktop.
Create a PPO order for error management in ABAP.
report y_create_ppo_order.
"
" Sample program to create a PPO Order for error management.
"
" The PPO Component and Business Process is configured in SPRO
" under Cross Application Components -> General Application
" Functions -> Postprocessing Office.
"
" The OBJTPYE (ZJASON below) is what the PPO desktop (worklist)
" sorts and groups on. If f_checkbar-checkinputobjects is true
" then the main object must also be valid in config.
"
" The main message is shown in the overview. The messages tab
" is only seen when the user drills into the Order.
"
" See the ABAP Help on each of the functions below for more
" info.
"
start-of-selection.
data main_object type /sappo/bapi_str_object.
data main_message type /sappo/bapi_str_message.
data order_id type /sappo/bapi_str_order_key.
data return_tab type bapiret2_t.
data messages type table of /sappo/bapi_str_message.
main_object-objcat = '1'.
main_object-objtype = 'ZINPEX'. "'ZJASON'
main_object-objkey = '1234567892'. "delivery number, po number or whatever
main_message-msgid = 'ZM'.
main_message-msgty = 'E'.
main_message-msgno = '021'.
main_message-msgv1 = 'HELLO'.
append main_message to messages.
append main_message to messages.
append main_message to messages.
data component type /sappo/dte_component value 'ZINPEX'. "from config
data businessprocess type /sappo/dte_business_process value 'ZADVSHIPNO'. "from config
data f_checkbar type /sappo/bapi_str_checkbar.
f_checkbar-checkinputmessages = abap_true.
f_checkbar-checkinputobjets = abap_true.
f_checkbar-checkbadimessages = abap_true.
f_checkbar-checkbadiobjets = abap_true.
call function '/SAPPO/BAPI_ORDER_SET_CONTEXT'
exporting
component = component
businessprocess = businessprocess
businessprocessid = 'JASONS SCENARIO' "free text shown in the addit. data section of ppo order
checkbar = f_checkbar.
" This function can be repeated many times to create multiple orders.
call function '/SAPPO/BAPI_ORDER_CREATE'
exporting
mainobject = main_object
* basicobject = " Base object
* envobject1 = " Environment Object 1
* envobject2 = " Environment Object 2
mainmessage = main_message
* crtble_order_attr =
postdate = sy-datum
creationdate = sy-datum
importing
order = order_id
tables
* objects = " Additional Objects
messages = messages
return = return_tab.
call function '/SAPPO/BAPI_ORDER_SAVE'.
call function 'BAPI_TRANSACTION_COMMIT'.
write: / 'Order created with id: ', order_id.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment