2012 Aug 02 8:51 AM
Hello Experts
I want to rename the structure, but as there is no direct method or FM to do so, am creating a new structure and copying all the contents to the new one and deleting old one. And i want to do this programatically.
So for creating new structure i ran the SAP process of creating structure in DEBUG mode and found 2 things, one FM 'RS_DD_ADD' and one method ' call method cl_wb_ddic=>access_ddic_via_manager'.
Both are creating the structure, but both are taking me to the screen of the newly created structure to enter fields and all, which i dont want.
So for this any suggestion ?
Regards,
Ankur Sharma.
2012 Aug 02 11:11 AM
You can rename using combination of DD_TABL* functions.
DATA: lt_dd03p TYPE TABLE OF dd03p,
ls_dd03p TYPE dd03p,
ls_dd09l TYPE dd09l,
ls_dd02v TYPE dd02v.
CALL FUNCTION 'DD_TABL_GET'
EXPORTING
tabl_name = 'YYMARC_S'
WITHTEXT = 'X'
IMPORTING
dd02v_wa_a = ls_dd02v
dd09l_wa_a = ls_dd09l
TABLES
dd03p_tab_a = lt_dd03p
EXCEPTIONS
access_failure = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
LOOP AT lt_dd03p INTO ls_dd03p.
ls_dd03p-tabname = 'YYMARC_S_NEW'.
MODIFY lt_dd03p FROM ls_dd03p.
ENDLOOP.
ls_dd02v-tabname = 'YYMARC_S_NEW'.
CALL FUNCTION 'RS_DD_DELETE_OBJ'
EXPORTING
no_ask = 'X'
objname = 'YYMARC_S'
objtype = 'S'
EXCEPTIONS
not_executed = 01
object_not_found = 02
object_not_specified = 03
permission_failure = 04.
CALL FUNCTION 'DD_TABL_PUT'
EXPORTING
dd02v_wa = ls_dd02v
dd09l_wa = ls_dd09l
put_state = 'A'
tabl_name = 'YYMARC_S_NEW'
TABLES
dd03p_tab = lt_dd03p
EXCEPTIONS
db_access_failure = 1
object_inconsistent = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Thanks,
Shambu
2012 Aug 02 10:54 AM
Hi Ankur,
Instead of renaming the structure, from SE11 you can copy the structure with a new name and can delete the old structure. That would be the easiest option.
You have any restrictions in doing that?
Regards,
Velayutham A.
2012 Aug 02 11:11 AM
You can rename using combination of DD_TABL* functions.
DATA: lt_dd03p TYPE TABLE OF dd03p,
ls_dd03p TYPE dd03p,
ls_dd09l TYPE dd09l,
ls_dd02v TYPE dd02v.
CALL FUNCTION 'DD_TABL_GET'
EXPORTING
tabl_name = 'YYMARC_S'
WITHTEXT = 'X'
IMPORTING
dd02v_wa_a = ls_dd02v
dd09l_wa_a = ls_dd09l
TABLES
dd03p_tab_a = lt_dd03p
EXCEPTIONS
access_failure = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
LOOP AT lt_dd03p INTO ls_dd03p.
ls_dd03p-tabname = 'YYMARC_S_NEW'.
MODIFY lt_dd03p FROM ls_dd03p.
ENDLOOP.
ls_dd02v-tabname = 'YYMARC_S_NEW'.
CALL FUNCTION 'RS_DD_DELETE_OBJ'
EXPORTING
no_ask = 'X'
objname = 'YYMARC_S'
objtype = 'S'
EXCEPTIONS
not_executed = 01
object_not_found = 02
object_not_specified = 03
permission_failure = 04.
CALL FUNCTION 'DD_TABL_PUT'
EXPORTING
dd02v_wa = ls_dd02v
dd09l_wa = ls_dd09l
put_state = 'A'
tabl_name = 'YYMARC_S_NEW'
TABLES
dd03p_tab = lt_dd03p
EXCEPTIONS
db_access_failure = 1
object_inconsistent = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Thanks,
Shambu
2012 Aug 02 12:20 PM
Hi Shambu VS ,
Thanks a lot.
I thought there are no FM to create new structure / table. I searched and debugged structure creation process, but did not find this FM. Even i randomly tried in SE37 DD_TABLE_PUT coz i thought as DD_DTEL_PUT is there so there might be a chance that for structure and table also it will be there. But only difference is i wrote extra E.
Between how you found this FM, i mean DD_TABL_PUT ?
Regards,
Ankur Sharma