Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Domain Conversion Routines

0 Likes
4,512

I want to get the field name and table name while I am inside a conversion routine i.e. I want to see the table name and field name or at least the data element for which the conversion routine is being processed while I am still inside a conversion routine. Is that possible??

13 REPLIES 13
Read only

Former Member
0 Likes
3,354
Read only

0 Likes
3,354

Hi,

Thanks a lot for your reply.

But what I meant was: A conversion routine usually has only 2 interface parameters: INPUT and OUTPUT.

Now, when a conversion routing is being processed, is there any way we may know what was the type of the field whose value is being passed to the conversion routine as an INPUT??

Ex: Say there exists a dummy conversion exit (CE):

Conversion_exit_00001_output.

Now suppose this conversion exit is assigned to domains 'ztest1' and 'ztest2' and these domains are attached to

data elements 'zdtel1' and 'zdtel2' respectively. So, the same CE is applicable to both the Data Elements. Now These data elements are used as table fields in two diiferent tables. Now if the table field are being displayed, the C.E will be called automatically, Now, is there any way to know that the input value is of type 'zdtel1' or 'zdtel2' while I am still inside the CE. Is there any system field like syst or something else or is it possible by pointers etc...

Thanks,

Siddhartha.

Message was edited by: Siddhartha Mishra

Read only

0 Likes
3,354

Hi,

have you tried the RTTI framework?

Something like (untested code):

DATA: lo_descr TYPE REF TO CL_ABAP_TYPE_DESCR.
lo_descr = CL_ABAP_ELEMDESCR=>DESCRIBE_BY_DATA( INPUT ).
lv_dataelement_name = lo_descr->get_relative_name( ).

You might have to downcast lo_descr to an instance of CL_ABAP_ELEMDESCR or similar.

Cheers
   Adi

Read only

0 Likes
3,354

So you didn't check the describe statement did you?

DESCRIBE FIELD <f> HELP-ID <h>.

This will give you the data element used...

Cheers,

Manu.

Read only

0 Likes
3,354

HI,

The describe statement does not work as the interface of the CE routine is something like this:

*" IMPORTING

*" VALUE(INPUT)

*" EXPORTING

*" VALUE(OUTPUT)

So, the describe statement for the field "input" will try to find the data element of its type which in this case doesnt fetch any. I wished to get the type of the field that called this CE through its dataelement and hence domain it referred to.

Perhaps this is not possible as the same CE can be used in multiple domains...like ALPHA...

Thanks,

Siddhartha.

 

Read only

0 Likes
3,354

So... you didn't even tried... I did a check by myself and this is perfectly working:

DATA: l_bukrs type bukrs.

CALL FUNCTION 'ZZTEST'
  EXPORTING
    input         = l_bukrs.

With an FM interface like:

*" IMPORTING

*" VALUE(INPUT)

*" EXPORTING

*" VALUE(OUTPUT)

I coded a describe statement within the FM and got the value 'BUKRS' in help-id...

Is that not what you expect??

Manu.

Read only

0 Likes
3,354

Hi Manu,

Thanks for all the efforts you are putting in..

I did try...I will tell you how you can recreate my scenario...

Create a Domain...Attach a custom CE (say ZTEST) to it...Then attach your domain to a Data Element....

Put this DTEL in a table and fill the table with some entries....

Now, in the CE routine ZTEST if you will write this describe statement....i did the same and am not getting any result....(you can select data from a table and display it in ALV so as to debug the CE)...

In case of calling the FM through your report ... it is very possible that your describe statement would have worked..might be input takes the type of I_bukrs dynamically (m not sure though)...

Thanks,

Siddhartha.

Read only

0 Likes
3,354

Hi,

Hmm indeed you're right, my bad... Unless called directly, It cannot work.

In fact the conversion routine is called dynamically by the form CONVERSION_EXIT defined in program SAPCNVE...

The call is done this way:

FIELD-SYMBOLS: <FNAME>, <INPUT>, <OUTPUT>.      "#EC *

CALL'AB_GET_C_PARMS'ID'P1'FIELD <FNAME>                          

                        ID 'P2' FIELD <INPUT>    
                        ID 'P3' FIELD <OUTPUT>.

  CALL FUNCTION <FNAME>

       EXPORTING
            INPUT  = <INPUT>

IMPORTING
OUTPUT = <OUTPUT>.

So when a conversion routine is called by the system, the input parameter is always sent untyped, whatever the type used in the related source field...

Kr,

Manu.

Read only

0 Likes
3,354

Hi All,

Thanks a lot for all your help. But I think its not very possible to get the data type of the data being passed as input to a Conversion Routine, while being inside of it.

Regards,

Siddhartha Mishra.

Read only

0 Likes
3,354

Well , what is the need to get the data type while debugging the standard conversion exit function module . Please explain what is your need in doing this.

What you can do is to note down the mask from the function called. For example "CONVERSION_EXIT_ABPSP_INPUT" - Here ABPSP is your mask.

Pass this mask to table DD01L field CONVEXIT and get the data type from field DATATYPE,LENG etc.

Read only

0 Likes
3,354

Although it is probably technically possible, for me domain is only to provide technical details of the object which you use. As CE is part of this technical entity this should be of no matter to the program which data element it uses at the moment. The program should only do semantical distinction at data element level (as this is its purpose).

I.e. CE CONVERSION_EXIT_PDATE_OUTPUT requires on input date in format 'DDMMYYYY' while it outputs date in format 'DD.MM.YYYY'. Any data element which uses this CE should technically behave the same (you should always expect data be formatted in this manner at the output). At the same time two distinct data elements (Start Date, Birthday) using this CE can be used in program and receive separate logic depending on their meanings.

In your case trying to distinguish what data element uses certain domain is mixing these two roles. I suggest to introduce new data element and use its domain's CE.

Regards

Marcin

Read only

0 Likes
3,354

Hi,

Thanks for the reply but this method will not be very helpful if the same CE has been used in multiple domains like ALPHA...

Thanks,

Siddhartha.

Read only

Kartik2
Contributor
0 Likes
3,354

Dear Siddhartha Mishra,

you may try the following, it is tested and it displays name of the data element. Here you have to use the static method describe_by_data of class cl_abap_typedescr and the resulting value is to be down casted to the type cl_abap_elemdescr.

   ************************************************************************
*** Program                : YKK_DE_RUN_TIME
*** Author                   : Kartik P
*** Creation Date         : 23/04/2012
*** Requested By        : Self
*** Reference Document  :
*** Description             : To get the name of data type of variable during
***                       run time
*** Project             : NA
*** SAP Transport       : NA
************************************************************************

REPORT  ykk_de_run_time.

DATA :

  gv_test        TYPE zkknamede,

* Runtime Type Services
  ls_descr_ref   TYPE REF TO cl_abap_elemdescr    .


START-OF-SELECTION.

  gv_test = 'Hello'.

* Down casting type cl_abap_typedescr to cl_abap_elemdescr
  ls_descr_ref ?= cl_abap_typedescr=>describe_by_data( gv_test ).

  WRITE ls_descr_ref->absolute_name.

output - \TYPE=ZKKNAMEDE

Hope it helps, thanks and regards,

kartik