Problem: You want to execute additional actions after transport has been imported to the destination system. You also want to save results of these actions to the transport’s log.
Solution: At first, solution is not so easy to find.
First of all you need a BADI which will be executed after a transport has been imported. You can find one in the SPRO tcode. Its name is CTS_IMPORT_FEEDBACK.
This BADI has only one method which has only one import parameter – a table with information about all the transports imported to the system. What you need to do is implement all your extra actions in this method.
Second part of the solution is even harder to come up with. Most of the Function Modules found for this task have no description nor documentation so it is quite hard to figure out what should be done and how.
You will need two FMs:
- STRF_SETNAME_TEMPPROT_SINGLE – it will return the name of the transport’s log file;
- TR_WRITE_LOG – it will actually write your message to the log file of the transport.
So, now all is left to do is put together few lines of code:
DATA: lv_log_file TYPE trfile, lv_msg_type TYPE errortyp VALUE 'S'. CALL FUNCTION 'STRF_SETNAME_TEMPPROT_SINGLE' EXPORTING acttype = 'Q' IMPORTING file = lv_log_file EXCEPTIONS wrong_call = 1 OTHERS = 2. CHECK sy-subrc = 0. PERFORM write_message_to_file IN PROGRAM rddfdbck IF FOUND USING lv_log_file lv_msg_type '00' '001' 'This is my message in log' '' '' ''.
DATA: lv_log_file TYPE trfile, lv_msg_type TYPE errortyp VALUE 'S'. CALL FUNCTION 'STRF_SETNAME_TEMPPROT_SINGLE' EXPORTING acttype = 'Q' IMPORTING file = lv_log_file EXCEPTIONS wrong_call = 1 OTHERS = 2. CHECK sy-subrc = 0. PERFORM write_message_to_file IN PROGRAM rddfdbck IF FOUND USING lv_log_file lv_msg_type '00' '001' 'This is my message in log' '' '' ''.
You can call FM TR_WRITE_LOG directly. I find it easier to call procedure WRITE_MESSAGE_TO_FILE from program RDDFDBCK.
Also, if you put 'E’ (Error) in the message type your message will be marked red in the transport’s log. During the synchronous import user will be informed about the error with a popup window.
Komentowanie jest zakończone.