Introduction
In order to use the “import from transport” function in the BC Set editor, the data must be recorded in the context of a transport object (TOBJ) and the business configuration maintenance object (SMBC) must maintain the corresponding transport object attribute.
This blog explains the necessary steps to enable existing SMBC objects for the “import from transport” functionality. Newly generated SMBC objects are automatically enabled.
This blog is relevant for
Further reading:
Related blog postsLearn how you can use ABAP technology to develop innovative applications and business solutions across SAP’s portfolio on SAP Learning Site.
Case 1: Transport object is already used in the BC app
As of release 2302, when you use the ADT wizard to generate a business configuration maintenance object (SMBC), a transport object (TOBJ) is generated by default and used in the behavior implementation. In this case you only need to maintain the new “Transport Object” attribute of the SMBC object.
You can do this manually in the ADT editor of the SMBC object or programmatically. First you need to find out the name of the transport object. In most cases the name is equal to the name of the SMBC object. You can open the behavior implementation class and check the first couple of rows to verify the name of the transport object ( depending on the release the object was created: CO_TRANSPORT_OBJECT or TDAT_NAME )
CLASS LHC_COMPANYCODEALL DEFINITION FINAL INHERITING FROM CL_ABAP_BEHAVIOR_HANDLER.
PUBLIC SECTION.
CONSTANTS:
CO_ENTITY TYPE abp_entity_name VALUE `ZI_COMPANYCODE_S`,
CO_TRANSPORT_OBJECT TYPE mbc_cp_api=>indiv_transaction_obj_name VALUE `ZCOMPANYCODE`,
CO_AUTHORIZATION_ENTITY TYPE abp_entity_name VALUE `ZI_COMPANYCODE`.CLASS LHC_RAP_TDAT_CTS DEFINITION FINAL.
PUBLIC SECTION.
CLASS-METHODS:
GET
RETURNING
VALUE(RESULT) TYPE REF TO IF_MBC_CP_RAP_TDAT_CTS.
ENDCLASS.
CLASS LHC_RAP_TDAT_CTS IMPLEMENTATION.
METHOD GET.
result = mbc_cp_api=>rap_tdat_cts( tdat_name = ‘ZTAB6’
You can maintain the attribute “Transport Object” in the “Service Configuration” section of the SMBC object in the ADT editor. Save and activate.
You can update this attribute also programmatically:
CLASS zset_tobj DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zset_tobj IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DATA smbc_id TYPE TABLE OF if_mbc_cp_api_business_config=>ty_technical_id WITH EMPTY KEY.
SELECT ABAPObject FROM I_CustABAPObjDirectoryEntry
WHERE ABAPObjectType = ‘SMBC’ AND ABAPObject LIKE ‘<NAMESPACE>%’
INTO TABLE @smbc_id .
LOOP AT smbc_id ASSIGNING FIELD-SYMBOL(<smbc_id>).
out->write( |SMBC object: { <smbc_id> }| ).
TRY.
DATA(tobj) = mbc_cp_api=>business_configuration_api( <smbc_id> )->read( )-transport_object.
IF tobj IS NOT INITIAL.
out->write( |TOBJ already set: { tobj }| ).
ELSE.
mbc_cp_api=>business_configuration_api( <smbc_id> )->update_transport_object(
transport_object = <smbc_id> “if the table list of the transport object does not match the table list of the behavior definition an exception is raised
transport = ‘<Workbench Request>’ ). “transport=space for local objects
out->write( |TOBJ set: { mbc_cp_api=>business_configuration_api( <smbc_id> )->read( )-transport_object }| ).
ENDIF.
CATCH cx_root INTO DATA(exc).
out->write( |Error: { exc->get_text( ) }| ).
ENDTRY.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
Use Case 2: The BC app does not use a transport object
Delete the existing BC app and create it again using the ADT wizard.
If you cannot do that, you can also use the ADT wizard to generate a new BC app for the table(s) with different object names. Move the generated transport object to the package of the old BC app and maintain the transport object attribute of the old SMBC object.
If necessary, adjust the generated TOBJ by changing the table piece list.
Adjust the old behavior implementation class by by replacing the existing method implementation with the equivalent method implementation of the new behavior implementation class. Adjust the constants to match the old object names.
You can now delete the newly generated objects.
IntroductionIn order to use the “import from transport” function in the BC Set editor, the data must be recorded in the context of a transport object (TOBJ) and the business configuration maintenance object (SMBC) must maintain the corresponding transport object attribute.This blog explains the necessary steps to enable existing SMBC objects for the “import from transport” functionality. Newly generated SMBC objects are automatically enabled.This blog is relevant forFurther reading:Related blog postsLearn how you can use ABAP technology to develop innovative applications and business solutions across SAP’s portfolio on SAP Learning Site.Case 1: Transport object is already used in the BC appAs of release 2302, when you use the ADT wizard to generate a business configuration maintenance object (SMBC), a transport object (TOBJ) is generated by default and used in the behavior implementation. In this case you only need to maintain the new “Transport Object” attribute of the SMBC object.You can do this manually in the ADT editor of the SMBC object or programmatically. First you need to find out the name of the transport object. In most cases the name is equal to the name of the SMBC object. You can open the behavior implementation class and check the first couple of rows to verify the name of the transport object ( depending on the release the object was created: CO_TRANSPORT_OBJECT or TDAT_NAME )CLASS LHC_COMPANYCODEALL DEFINITION FINAL INHERITING FROM CL_ABAP_BEHAVIOR_HANDLER.
PUBLIC SECTION.
CONSTANTS:
CO_ENTITY TYPE abp_entity_name VALUE `ZI_COMPANYCODE_S`,
CO_TRANSPORT_OBJECT TYPE mbc_cp_api=>indiv_transaction_obj_name VALUE `ZCOMPANYCODE`,
CO_AUTHORIZATION_ENTITY TYPE abp_entity_name VALUE `ZI_COMPANYCODE`.CLASS LHC_RAP_TDAT_CTS DEFINITION FINAL.
PUBLIC SECTION.
CLASS-METHODS:
GET
RETURNING
VALUE(RESULT) TYPE REF TO IF_MBC_CP_RAP_TDAT_CTS.
ENDCLASS.
CLASS LHC_RAP_TDAT_CTS IMPLEMENTATION.
METHOD GET.
result = mbc_cp_api=>rap_tdat_cts( tdat_name = ‘ZTAB6’You can maintain the attribute “Transport Object” in the “Service Configuration” section of the SMBC object in the ADT editor. Save and activate.You can update this attribute also programmatically:CLASS zset_tobj DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zset_tobj IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DATA smbc_id TYPE TABLE OF if_mbc_cp_api_business_config=>ty_technical_id WITH EMPTY KEY.
SELECT ABAPObject FROM I_CustABAPObjDirectoryEntry
WHERE ABAPObjectType = ‘SMBC’ AND ABAPObject LIKE ‘<NAMESPACE>%’
INTO TABLE @smbc_id .
LOOP AT smbc_id ASSIGNING FIELD-SYMBOL(<smbc_id>).
out->write( |SMBC object: { <smbc_id> }| ).
TRY.
DATA(tobj) = mbc_cp_api=>business_configuration_api( <smbc_id> )->read( )-transport_object.
IF tobj IS NOT INITIAL.
out->write( |TOBJ already set: { tobj }| ).
ELSE.
mbc_cp_api=>business_configuration_api( <smbc_id> )->update_transport_object(
transport_object = <smbc_id> “if the table list of the transport object does not match the table list of the behavior definition an exception is raised
transport = ‘<Workbench Request>’ ). “transport=space for local objects
out->write( |TOBJ set: { mbc_cp_api=>business_configuration_api( <smbc_id> )->read( )-transport_object }| ).
ENDIF.
CATCH cx_root INTO DATA(exc).
out->write( |Error: { exc->get_text( ) }| ).
ENDTRY.
ENDLOOP.
ENDMETHOD.
ENDCLASS.Use Case 2: The BC app does not use a transport objectDelete the existing BC app and create it again using the ADT wizard.If you cannot do that, you can also use the ADT wizard to generate a new BC app for the table(s) with different object names. Move the generated transport object to the package of the old BC app and maintain the transport object attribute of the old SMBC object.If necessary, adjust the generated TOBJ by changing the table piece list.Adjust the old behavior implementation class by by replacing the existing method implementation with the equivalent method implementation of the new behavior implementation class. Adjust the constants to match the old object names.You can now delete the newly generated objects. Read More Technology Blog Posts by SAP articles
#SAP
#SAPTechnologyblog