on 03-19-2016 7:02 PM
Hello,
I want to post events in Transportation Management for ‘Freight Order/Booking with an own program. I’m using BAPI “/SAPTRX/BAPI_EH_POST”.
Business Requirement is:
Creating Event (e.g. DEPARTURE) for a freight order/booking with event date.
The program does not insert/change the event (in tab "EXECUTION” of freight order)
Remark: we are not using an own system for SAP EM.
SAP TM and SAP EM are running in the same system
I’m using the following settings
In freight order type application object "ODT30_TO" is assigned, allowed events for the order types are:
ARRIV_DEST
COUPLING
DECOUPLING
DEPARTURE
LOAD_BEGIN
LOAD_END
POD
POPU
UNLOAD_BEGIN
UNLOAD_END
The program has the following coding:
Some information to the coding:
** Fill table prior to BAPI call.
* Mandatory Data
refresh lt_applobjects.
ls_applobjects-appsys = 'TMXCLNT700'. .
ls_applobjects-appobjtype = 'ODT30_TO'.
ls_applobjects-appobjid = '56EAB2E0CCBC5D91E1000000AC101684'. "Freight Order!!!
ls_applobjects-busproctype = 'TMS_TOR'.
ls_applobjects-update_indicator = 'I'.
APPEND ls_applobjects TO lt_applobjects.
*Controldata
refresh lt_controldata.
ls_controldata-appsys = 'TMXCLNT700'.
ls_controldata-appobjtype = 'ODT30_TO'.
ls_controldata-appobjid = '56EAB2E0CCBC5D91E1000000AC101684'. " Freight Order!!!
ls_controldata-paramname = 'FREIGHT_ORDER'.
ls_controldata-value = '4100000351'. "Freight Order ls_appob.
*ls_controldata-value = ls_prio.
APPEND ls_controldata TO lt_controldata.
*trackingid
ls_trackiddata-appsys = 'TMXCLNT700'.
ls_trackiddata-appobjtype = 'ODT30_TO' .
ls_trackiddata-appobjid = '56EAB2E0CCBC5D91E1000000AC101684'.
ls_trackiddata-trxcod = 'DEPARTURE'. "Event !!!!!
ls_trackiddata-trxid = '56EAB2E0CCBC5D91E1000000AC101684'. "Freight Order
ls_trackiddata-START_DATE = sy-datum - 1.
ls_trackiddata-msrid = 'X'.
*ls_trackiddata-msrid = 'X'.
APPEND ls_trackiddata TO lt_trackiddata.
*
CALL FUNCTION '/SAPTRX/BAPI_EH_POST'
EXPORTING
simulate = ls_sim
TABLES
applobjects = lt_applobjects
controldata = lt_controldata
infodata = lt_infodata
milestonedata = lt_milestones
trackiddata = lt_trackiddata
* INFOOBJDATA =
* EXTENSIONIN =
* EXTENSIONOUT =
RETURN = lt_return
.
if ls_sim is initial.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
endif.
loop at lt_return into ls_return.
write: / ls_return-TYPE ,
ls_return-ID ,
ls_return-NUMBER ,
ls_return-MESSAGE.
endloop.
the BAPi return message looks like
S /SAPTRX/TS_APP 704 EM TMXCLNT700: Using mapping profile ODT30_TOR for application object type ODT30_TO
I /SAPTRX/APP_LOG 020 Posting data from appl. sys TMXCLNT700, appl. object ODT30_TO/56EAB2E0CCBC5D91E1000000AC101684, status = 1
I /SAPTRX/APP_LOG 022 Updating event handler
.... but freight order has not changed
Is there a missing functionality to that the event handler has to start?????
Thanks in advance
Georg
Hi George,
To post an event, you have to use /SAPTRX/BAPI_EH_ADDEVENTMSG_02 and not /SAPTRX/BAPI_EH_POST.
Here is the sample and modify it to your needs:
REPORT ZZTEST.
data: lt_hdr type STANDARD TABLE OF /SAPTRX/BAPI_EVM_HEADER,
ls_hdr type /SAPTRX/BAPI_EVM_HEADER,
lt_ret type STANDARD TABLE OF BAPIRET2.
ls_hdr-EVTCNT = '1'.
ls_hdr-EVTID = 'DEPARTURE'.
ls_hdr-TRXCOD = 'TO'. " Use TOR_TEC if TO doesn't work.
ls_hdr-TRXID = '00000000004100000351'. " Complete FO number
ls_hdr-EVTDAT = sy-datum.
ls_hdr-EVTTIM = sy-uzeit.
ls_hdr-EVTZON = sy-zonlo.
append ls_hdr to lt_hdr.
CALL FUNCTION '/SAPTRX/BAPI_EH_ADDEVENTMSG_02'
EXPORTING
* SIMULATE = p_sim
* BLOCKONERRORIN =
* SKIPCHECK =
SYNCHRONOUS = 'X'
* BUFFER_MODE =
* EH_GENERATION_MODE =
* EH_GENERATION_FUNCTION =
* PREPROCESS_MODE =
* PREPROCESS_FUNCTION =
* IMPORTING
* ERROROCCURRED =
TABLES
trackingheader = lt_hdr
return = lt_ret
.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
------------
Also, have you tried using Event Types in Application Interface instead of the custom code?
Thanks,
Vishnu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vishnu,
thanks for your quick answer. I've implemented the program (I used TRXCOD = "TOR_TEC") as you recommended it. But I'm getting the following messages.
I /SAPTRX/MSIO 058 Event message has been posted to SAP Event Management
I /SAPTRX/APP_LOG 058 Processing event messages for event handler ODT30_TO / 00000000004100000370
I /SAPTRX/APP_LOG 093 Message processing aborted. Not in list of allowed unexp. event codes
When checking my events in transaction "/SAPTRX/EVM_STATUS" I can see that the status in "green" (Processed). but in NWBC-function "Display ROAD FREIGTH" in tab "EXECUTION" the events are not reported.
I also can see that the program has created an entries in table /SAPTRX/EVM_HDR not /SAPTRX/EH_HDR.
When I compare entries in /SAPTRX/EVM_HDR which are posted manual in NWBC and with program I see that the manual posing has filled other fields like "SNDNAM", "LODID1" and also some others.
Is there some other parameter missing??
Georg
Hi Georg,
The messages are informational only and not errors.
>>>"I also can see that the program has created an entries in table /SAPTRX/EVM_HDR not /SAPTRX/EH_HDR."
That's correct. You are posting events which will show up in EVM_HDR and not in EH_HDR. Event Handlers will show up EH_HDR though.
For SNDNAM and LOCID1, you need to populate them in the bapi which I gave you( /SAPTRX/BAPI_EH_ADDEVENTMSG_02).
SNDNAM will be in " TRACKINGHEADER " structure and LOCID1 will be in TRACKLOCATION structure.
In order for events to show up in EXECUTION tab, you need to have setup proper config between TM and EM and event handlers should be getting created for your TM objects like FO/BO/FU etc.
Thanks,
Vishnu
Hi Georg,
You can see event message with event handler link in table /SAPTRX/EH_EVMSG.
1. Go to table /SAPTRX/EVM_MSG and give tracking id and get GUI ID.
2. Pass event message GUID in table /SAPTRX/EH_EVMSG to check event message posted against event handler correctly.
If /SAPTRX/EH_EVMSG-NOT_RELEVANT marked as "X" for reported event message, then it is not posted correctly and it won't be visible in EH LIST against event handler.
Regards
GGOPII
Hola a todos.
Estoy enla version EM HANA 2020. Aqui no tengo esos Modulos de funciones disponibles. Que aplicaria aqui para la Publicacion de eventos.
Si pudieras ayudarme lo agradeceria.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
4 | |
3 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.