Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
SaiPhani07
Explorer
Hi All,

Follow the sample code for achieving this requirement

NOTE: The syntax used only works in SAPGUI and SAPGUI related elements, and that the commands are not allowed in ABAP Cloud.

My requirement is to insert a record to custom table and also have to added the record to customizing request and to move the inserted data/table entries from one client to another client using that Customizing request

I am passing the data through parameter from the selection Screen .
*&---------------------------------------------------------------------*
*& Report ZTASK_TRSN1
*&---------------------------------------------------------------------*
*
*&Description: Adding Record in Data base and Customising Transport Request
*&
*&---------------------------------------------------------------------*
REPORT ztask_trsn1.

TABLES:e071.

DATA: lt_e071 TYPE STANDARD TABLE OF e071,
lt_e071k TYPE STANDARD TABLE OF e071k,

ls_cust TYPE zfi_sncustomer,
ls_order TYPE e071-trkorr,
ls_task TYPE e071k-trkorr,

lv_task TYPE cts_recording_entries.

SELECTION-SCREEN:BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000.
PARAMETERS:P_CUSTNO TYPE zfi_sncustomer-custno OBLIGATORY MATCHCODE OBJECT zsh_custno ,
P_name type zfi_sncustomer-CUstname,
p_city type zfi_sncustomer-city,
p_cun type zfi_sncustomer-country.
SELECTION-SCREEN:end of BLOCK b1.

"using this fm a screen will generated after the selection screen
CALL FUNCTION 'TRINT_ORDER_CHOICE'
EXPORTING
wi_order_type = 'W' "customising request
wi_task_type = 'Q' "Customizing Task
wi_category = 'CUST' "Client-specific Customizing
IMPORTING
we_order = ls_order
we_task = ls_task
TABLES
wt_e071 = lt_e071
wt_e071k = lt_e071k
EXCEPTIONS
no_correction_selected = 1
display_mode = 2
object_append_error = 3
recursive_call = 4
wrong_order_type = 5
OTHERS = 6.

"passing data to workarea using the parameters in the selection screen
ls_cust-mandt = sy-mandt.
ls_cust-custno = p_custno.
ls_cust-custname = p_name.
ls_cust-city = p_city.
ls_cust-country = p_cun.

"zfi_sncustomer is my custom table name and tabu for table contents
INSERT VALUE #(
trkorr = ls_task
pgmid = 'R3TR'
object = 'TABU'
obj_name = 'ZFI_SNCUSTOMER'
objfunc = 'K'
) INTO TABLE lt_e071.

"custno is the mandatory field so passing custno and sy-mandt to tabkey.
INSERT VALUE #(
trkorr = ls_task
pgmid = 'R3TR'
object = 'TABU'
objname = 'ZFI_SNCUSTOMER'
mastertype = 'TABU'
mastername = 'ZFI_SNCUSTOMER'
tabkey = |{ sy-mandt }{ ls_cust-custno }|
) INTO TABLE lt_e071k.

"inserting data to custom table
INSERT zfi_sncustomer FROM ls_cust.

"assign data to the transport request
CALL FUNCTION 'TR_APPEND_TO_COMM_OBJS_KEYS'
EXPORTING
wi_trkorr = ls_task
TABLES
wt_e071 = lt_e071
wt_e071k = lt_e071k
EXCEPTIONS
key_char_in_non_char_field = 1
key_check_keysyntax_error = 2
key_inttab_table = 3
key_longer_field_but_no_generc = 4
key_missing_key_master_fields = 5
key_missing_key_tablekey = 6
key_non_char_but_no_generic = 7
key_no_key_fields = 8
key_string_longer_char_key = 9
key_table_has_no_fields = 10
key_table_not_activ = 11
key_unallowed_key_function = 12
key_unallowed_key_object = 13
key_unallowed_key_objname = 14
key_unallowed_key_pgmid = 15
key_without_header = 16
ob_check_obj_error = 17
ob_devclass_no_exist = 18
ob_empty_key = 19
ob_generic_objectname = 20
ob_ill_delivery_transport = 21
ob_ill_lock = 22
ob_ill_parts_transport = 23
ob_ill_source_system = 24
ob_ill_system_object = 25
ob_ill_target = 26
ob_inttab_table = 27
ob_local_object = 28
ob_locked_by_other = 29
ob_modif_only_in_modif_order = 30
ob_name_too_long = 31
ob_no_append_of_corr_entry = 32
ob_no_append_of_c_member = 33
ob_no_consolidation_transport = 34
ob_no_original = 35
ob_no_shared_repairs = 36
ob_no_systemname = 37
ob_no_systemtype = 38
ob_no_tadir = 39
ob_no_tadir_not_lockable = 40
ob_privat_object = 41
ob_repair_only_in_repair_order = 42
ob_reserved_name = 43
ob_syntax_error = 44
ob_table_has_no_fields = 45
ob_table_not_activ = 46
tr_enqueue_failed = 47
tr_errors_in_error_table = 48
tr_ill_korrnum = 49
tr_lockmod_failed = 50
tr_lock_enqueue_failed = 51
tr_not_owner = 52
tr_no_systemname = 53
tr_no_systemtype = 54
tr_order_not_exist = 55
tr_order_released = 56
tr_order_update_error = 57
tr_wrong_order_type = 58
ob_invalid_target_system = 59
tr_no_authorization = 60
ob_wrong_tabletyp = 61
ob_wrong_category = 62
ob_system_error = 63
ob_unlocal_objekt_in_local_ord = 64
tr_wrong_client = 65
ob_wrong_client = 66
key_wrong_client = 67
OTHERS = 68.
IF sy-subrc = 0.
" table entries added successfull
ENDIF.

That it , You can check in SE09 and You can see new customising request is created


Here , 100 is my client id and 107 is custno which is primary key in my Custom table .

go to SCC1 tcode in another CLIENT, provide your source client and transport request.

Select "Including Request sub tasks".

Select test run and click on Start Immediately.

Once test run is completed successfully, uncheck test run and click on Start Immediately.

Changes would now be copied to the target system.

Check your custom table and you will see the data inserted

Summary: Thanks for Viewing, Hope it helps and any feedback will be appreciated, Please Comment below and Please follow my account for more content.
4 Comments
Labels in this area