‎2020 Aug 07 2:43 PM
Hi I had a requirement to create a TR using BAPI instead of LB01.
You people can use the below code to create it.
*&---------------------------------------------------------------------*
*& Report ZL_TR_CREATE
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zl_tr_create.
DATA: lv_error LIKE sy-subrc.
DATA: lt_ltba LIKE TABLE OF ltba.
DATA: lw_ltba LIKE ltba.
DATA i_update_task TYPE rl02a-verbu VALUE 'X'.
DATA i_commit_work TYPE rl02a-commi VALUE 'X'.
lw_ltba-tabix = '1'.
lw_ltba-lgnum = 'ZWH'.
lw_ltba-matnr = '70000570'.
lw_ltba-werks = 'Z110'.
lw_ltba-lgort = 'WARE'.
lw_ltba-menga = '1.000'.
lw_ltba-betyp = 'D'.
lw_ltba-benum = '4500019789'.
lw_ltba-bwlvs = '521'.
APPEND lw_ltba TO lt_ltba.
CALL FUNCTION 'L_TR_CREATE_CHECK'
EXPORTING
i_number = 'X'
i_single_item = 'X'
TABLES
t_ltba = lt_ltba
EXCEPTIONS
ITEM_ERROR = 1.
CALL FUNCTION 'L_TR_CREATE'
EXPORTING
i_single_item = 'X'
i_save_only_all = 'X'
i_update_task = 'X'
i_commit_work = ' '
TABLES
t_ltba = lt_ltba
EXCEPTIONS
item_error = 1
no_entry_in_int_table = 2
item_without_number = 3
no_update_item_error = 4
error_message = 5
OTHERS = 99.
CASE sy-subrc.
WHEN 1.
WRITE : 'item_error'.
WHEN 2.
WRITE : 'no_entry_in_int_table'.
WHEN 3.
WRITE: 'item_without_number'.
WHEN 4.
WRITE : 'no_update_item_error'.
ENDCASE.
CALL FUNCTION 'L_TR_CREATE_UPDATE'
EXPORTING
i_update_task = i_update_task
i_commit_work = i_commit_work
EXCEPTIONS
NO_ENTRY_IN_INT_TABLE = 1
ITEM_WITHOUT_NUMBER = 2.
‎2020 Aug 07 2:46 PM
Hello Praveen
I think it might be a better solution to create a SAP Blog entry with such information. Giving a bit of background and explaining how the code works in such a post could be very helpful.
Kind regards,
Mateusz‎2020 Aug 07 3:22 PM
mateuszadamus, thanks for you comment, otherwise I would be still trying to figure out what the problem is.
‎2020 Dec 08 3:04 PM
Right now i wont have proper source to explain
But if you use the above code it will help to you.
Thanks