Skip to Content
0
Former Member
Jun 30, 2010 at 06:45 AM

creating a database table/structure at runtime : problem in transport reque

60 Views

Hi,

I'm using the below code to create a structure at runtime. This creates the structure at runtime succesfully but instead of inserting that in the child request (task), it inserts the same into partent request (transport request).PLease help.

&----


*& Report ZTEST_CREATE_DBTABLE

*&

&----


*&

*&

&----


REPORT ZCREATE_DBTABLE11.

constants:

c_reqtext TYPE e07t-as4text

VALUE 'ODI Transport Request',

c_request TYPE e070-trfunction

VALUE 'K',

c_task TYPE e070-trfunction

VALUE 'S'.

DATA : BEGIN OF struct OCCURS 0,

tabname TYPE dd02v-tabname,

END OF struct.

DATA:

wa_headerstruct LIKE dd02v,

t_structure TYPE STANDARD TABLE OF dd03p

WITH HEADER LINE,

trans_req_no TYPE e070-trkorr,

task_number TYPE e070-trkorr,

wa_struct LIKE LINE OF struct,

obj_name TYPE tadir-obj_name,

es_tadir TYPE tadir,

et_log TYPE sprot_u_tab,

e071 TYPE STANDARD TABLE OF e071,

lv_sysid TYPE srcsystem,

wa_e071 TYPE e071.

START-OF-SELECTION.

CLEAR trans_req_no.

CALL FUNCTION 'IW_C_CREATE_TRANSPORT_REQUEST'

EXPORTING

description = c_reqtext

transport_kind = c_request

langu = sy-langu

IMPORTING

commfile = trans_req_no

EXCEPTIONS

language_missing = 1

number_range_full = 2

unallowed_trfunction = 3

no_authorization = 4

create_transport_error = 5

OTHERS = 6.

IF sy-subrc <> 0.

CLEAR trans_req_no.

ENDIF.

CLEAR task_number.

CALL FUNCTION 'TRINT_INSERT_NEW_COMM'

EXPORTING

wi_kurztext = c_reqtext

wi_trfunction = c_task

iv_username = sy-uname

wi_strkorr = trans_req_no

wi_client = sy-mandt

IMPORTING

we_trkorr = task_number.

IF sy-subrc <> 0.

CLEAR task_number.

ENDIF.

CLEAR t_structure.

REFRESH t_structure.

wa_headerstruct-tabname = 'ZTEST_DBTAA'.

wa_headerstruct-ddlanguage = sy-langu.

wa_headerstruct-tabclass = 'INTTAB'.

wa_headerstruct-ddtext = 'ODI GET SAP MODULES '.

t_structure-tabname = wa_headerstruct-tabname.

t_structure-fieldname = 'FIELD1'.

t_structure-position = '1'.

t_structure-rollname = 'CHAR20'.

APPEND t_structure.

CLEAR t_structure.

t_structure-tabname = wa_headerstruct-tabname.

t_structure-fieldname = 'SHORT_TEXT'.

t_structure-position = '2'.

t_structure-rollname = 'CHAR40'.

APPEND t_structure.

CLEAR t_structure.

struct-tabname = wa_headerstruct-tabname.

APPEND struct.

CLEAR struct.

CALL FUNCTION 'DDIF_TABL_PUT'

EXPORTING

name = wa_headerstruct-tabname

dd02v_wa = wa_headerstruct

TABLES

dd03p_tab = t_structure

EXCEPTIONS

tabl_not_found = 1

name_inconsistent = 2

tabl_inconsistent = 3

put_failure = 4

put_refused = 5

OTHERS = 6.

CALL FUNCTION 'DDIF_TABL_ACTIVATE'

EXPORTING

name = wa_headerstruct-tabname

auth_chk = space

EXCEPTIONS

not_found = 1

put_failure = 2

OTHERS = 3.

LOOP AT struct INTO wa_struct.

obj_name = wa_struct-tabname.

lv_sysid = sy-sysid.

CALL FUNCTION 'TRINT_TADIR_INSERT'

EXPORTING

author = sy-uname

masterlang = sy-langu

devclass = 'ZODI_DEVCLASS'

genflag = ' '

object = 'TABL'

obj_name = obj_name

pgmid = 'R3TR'

srcsystem = lv_sysid

IMPORTING

es_tadir = es_tadir

EXCEPTIONS

object_exists_global = 1

object_exists_local = 2

OTHERS = 3.

wa_e071-trkorr = trans_req_no.

wa_e071-as4pos = '1'.

wa_e071-pgmid = 'R3TR'.

wa_e071-object = 'TABL'.

wa_e071-obj_name = obj_name.

wa_e071-lockflag = 'X'.

APPEND wa_e071 TO e071.

CLEAR wa_e071.

wa_e071-trkorr = trans_req_no.

wa_e071-as4pos = '2'.

wa_e071-pgmid = 'LIMU'.

wa_e071-object = 'TABD'.

wa_e071-obj_name = obj_name.

wa_e071-lockflag = 'X'.

APPEND wa_e071 TO e071.

CLEAR wa_e071.

CALL FUNCTION 'TRINT_REQUEST_CHOICE'

EXPORTING

iv_suppress_dialog = 'X'

iv_request_types = 'KL'

iv_request = trans_req_no

IMPORTING

et_log = et_log

TABLES

it_e071 = e071.

ENDLOOP.