cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing Fields on DTP via ABAP

Former Member
0 Kudos

Hi Experts,

I am writing an ABAP report that provides settings on DTPs.  I have succesfully obtained almost all the settings of the DTP using ABAP. 

Some of the DTP settings on the Update and Extraction tabs are depedent on the type of data source or data target defined in the DTP.

For example, on the Update tab, if the data target is ODSO, then "further processing without master data / no further processing without master data" options are visible.  But if the target is CUBE, you just have a checkbox "no update without Master data." 

My question is how exactly do I get these selections that depend on the type of source or target via ABAP code? 

I've looked over the class CL_RSBK_DTP, but these selection fields are not available in any of those methods from what I can tell.  However, on that class is a reference to an "update command template" and an "extraction command template" (these classes are available via the GET_OBJ_REF_TPL_U and GET_OBJ_REF_TPL_X methods).  I suspect these two objects contain the fields I need to get the settings for.  I've looked over those classes, though, and it isn't apparent to me how to obtain these custom field settings that are populated based on the source or target type. 

Can someone please help by providing code that will obtain this?  For example, just show me the code that will obtain the "further processing without master data/no further processing without master data" setting on the DTP if the target type is ODSO. 

Thanks,

Kevin

Accepted Solutions (1)

Accepted Solutions (1)

sascha_reissig
Participant
0 Kudos

Hi Kevin,

is it this what you're looking for?

DATA: LR_DTP                      type ref to cl_rsbk_dtp.

DATA: LR_CAST                   type ref to cl_rsbk_cmd_tpl.

DATA: LR_UPDATE_CMD  type ref to OBJECT.

PARAMETERS: P_DTP TYPE RSBKDTPNM.

LR_DTP                       = cl_rsbk_dtp=>factory( p_dtp ).

LR_UPDATE_CMD ?= LR_DTP->get_obj_ref_tpl_u( ).

LR_CAST                  ?= LR_UPDATE_CMD.

Now you can get the attribute values you might need.

Regards,

Sascha

Former Member
0 Kudos

Sascha-

Need a bit more specific information than that.  Why are you casting to CL_RSBK_CMD_TPL rather than using CL_RSBK_CMD_TPL_U?

And what are the methods on CL_RSBK_CMD_TPL that will give me the field name and field values?  The methods are a bit obscure to understand, and this is SAP so there is no documentation.  Any code example you can provide will be very helpful-- it doesn't matter what type of target object, just sample code getting the custom field value that comes up based on the target type. 

Thanks,

Kevin

Former Member
0 Kudos

Hi Kevin,

See my code below, I hope it helps you

     PARAMETERS: p_dtp TYPE rsbkdtpnm.


     DATA: o_dtp TYPE REF TO cl_rsbk_dtp,

           o_tlp TYPE REF TO cl_rsbc_u_odso_tpl.

     o_dtp = cl_rsbk_dtp=>factory( p_dtp ).

     o_tlp ?= o_dtp->get_obj_ref_tpl_u( ).

     IF o_tlp->n_only_check_sids = 'X'.

       WRITE 'No Furter Processing Without Master Data'.

     ELSE.

       WRITE 'Furter Processing Without Master Data'.

     ENDIF.

Regards,

Paulo.

sascha_reissig
Participant
0 Kudos

Hi Kevin, you're right, there is no need to cast it in the way I mentioned. It was just a code snippet. Anyway here is the code:

DATA: lr_dtp                TYPE REF TO cl_rsbk_dtp.

DATA: lr_update_cmd TYPE REF TO cl_rsbk_cmd_tpl_u. .

PARAMETERS: p_dtp  TYPE rsbkdtpnm. .

lr_dtp = cl_rsbk_dtp=>factory( p_dtp ). .

lr_update_cmd ?= lr_dtp->get_obj_ref_tpl_u( ).

CASE lr_update_cmd->n_cmd.

  WHEN 'U_CUBE'.    

    "Attribute: LR_UPDATE_CMD->N_CHECK_SIDS.    

    "Attribute: LR_UPDATE_CMD->N_NCUM_INIT..

  WHEN 'U_ODSO'.    

   "Attribute: N_ONLY_CHECK_SIDS..

  WHEN OTHERS. ..

ENDCASE.

 

Now you can combine this for example with this code snippet below (I didn't had the time to finalize the code for you, sorry) and put it into an RFC function module to check any delta between the systems:...


*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:

*"  IMPORTING

*"  VALUE(IV_OBJNAME) TYPE  SOBJ_NAME

*"  EXPORTING

*"    VALUE(EV_MAXSIZE) TYPE  RSBKMAXSIZE

*"  TABLES

*"      ET_SOURCE STRUCTURE  RSBKDTP

*"      ET_FILTER STRUCTURE  RSBK_S_SELECT

*"      ET_FILTER_CODE STRUCTURE  MCH_S_SOURCECODE

*"      ET_GRP STRUCTURE  RSBK_S_FIELDS_KEYFL OPTIONAL

*"  EXCEPTIONS

*"      SYSTEM_FAILURE

*"      COMMUNICATION_FAILURE

*"      RESOURCE_FAILURE

*"----------------------------------------------------------------------
field-symbols: <fs_line> type any.  

data: lv_objname            type rsbkdtp-dtp.  

data: lv_size_o               type rsbkmaxsize.  

data: lr_dtp                      type ref to cl_rsbk_dtp.  

data: l_r_filter                  type ref to cl_rsbc_filter.  

data: lt_dtprule                type mch_t_sourcecode.  

data: lr_error_hdl            type ref to cl_rsbc_error_handler_tpl.  

data: lr_if_error               type ref to if_rsbc_error_handler.  

field-symbols: <fs_fields> type rsbk_sx_fields_keyfl.  

field-symbols: <fs_content> type any.  

lv_objname = iv_objname.  

select * from rsbkdtp into table et_source     where dtp    = lv_objname     and  objvers = 'A'.  

if sy-subrc ne 0.    

  select * from rsbkdtp into table et_source       where dtp    = lv_objname       and  objvers = 'M'.  

endif.  

try.      

  lr_dtp = cl_rsbk_dtp=>factory( lv_objname ).     

  lr_dtp->get_obj_ref_maintain( ).      

  " Filter Max      

  call method lr_dtp->if_rsbk_dtp_display~get_maxsize receiving r_maxsize = ev_maxsize.     

   l_r_filter = lr_dtp->get_obj_ref_filter( ).     

    loop at l_r_filter->n_t_seltab assigning <fs_line>.

         insert into table et_filter.      

   endloop.      

   call method l_r_filter->get_dtprule         importing           e_t_dtprule = lt_dtprule.      

   loop at lt_dtprule assigning <fs_line> .       

       insert into table et_filter_code.      

   endloop.      

  call method lr_dtp->if_rsbk_dtp_display~get_obj_ref_error_handler         receiving           r_r_error_handler = lr_error_hdl.      

   if lr_error_hdl is bound.        

      lr_if_error ?= lr_error_hdl.        

        loop at lr_if_error->p_t_fields assigning             where segid = '0001'.          

            loop at -t_fields assigning  <fs_fields>.            

              insert into table et_grp.          

           endloop.        

       endloop.      

  endif.    

catch cx_root.  

endtry.

Any other questions are welcome.

Regards, Sascha

Former Member
0 Kudos

Because you opened up the idea of casting to specific classes for these objects, I have to give you the full credit.  Both answers were very helpful! 

Here is my code for anyone else that might want it...

Um.... okay, it's not letting me paste.  Nevermind. 

Thanks again for the help!!!

Former Member
0 Kudos

Sascha,

Sorry to bother you again, but I have one other question for you.  I'm trying to find the top two fields, Active Table (with Archive) and

Active Table (Without Archive) in the class CL_RSDD_X_DS_TPL when the DTP has a source type of ODSO.  I cannot find them.  They should be attributes named N_USE_DB_AND_ARCHIVE and N_USE_DB in that class, but they are not found anywhere.  I am able to find the bottom two fields on that class (N_USE_ARCHIVE and N_CHANGELOG_EXTRACTION). 

Any idea where these two fields are located (what class)?  Thanks.  If you have code, that will be very helpful.   

sascha_reissig
Participant
0 Kudos

Hi Kevin, is this what you're looking for (see pic above)? Regards, Sascha

Former Member
0 Kudos

That was helpful.  N_USE_ARCHIVE is populated with a "*" when the (with archive) option is selected, or blank when without archive is selected.  I suspect N_USE_DB and N_USE_DB_AND_ARCHIVE are deprecated fields because I cannot find them used anywhere. 

Answers (1)

Answers (1)

MGrob
Active Contributor
0 Kudos

Hi Kevin

I'm not much help here but I'm curious what you are up to.. Can you tell us something about the business background on this?

Martin

Former Member
0 Kudos

This is a convenience report.  We have many DTPs, and need a way to compare all the DTP settings between different clients (e.g. Production, Quality, Dev).  My program captures everything into an ALV grid except those fields that only display depending on the target type and source type on the Update and Extraction tabs respectively. 

Former Member
0 Kudos

Hi Kevin,

Could you please send me full code for this requirement. i have a same requirement.

Thanks & Regards,

puneet