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

Conversion Routines

Former Member
0 Likes
1,942

Hi All,

I am facing an issue in my program related to conversion routines.Below is the sample code of my program where I am facing the trouble.Based on the field I am fetching the conversion routine from table dd03m and passing the conversion routine name to the l_convexit.Concatenating it with the function module to another string(lv_conv_inpfm).


When I am calling the function module and importing the kunnr value as 1000 to it through the field-symbol(<fs_header_line1>) and while exporting it is not returning as what I am expecting(0000001000) and it is returning as same value as 1000.Why?Can anyone suggest me how to resolve it.Thanks in Advance.


CONCATENATE 'CONVERSION_EXIT_' L_CONVEXIT '_INPUT' INTO LV_CONV_INPFM.

                 CALL FUNCTION LV_CONV_INPFM
                   EXPORTING
                     INPUT  = <FS_HEADER_LINE1>
                   IMPORTING
                     OUTPUT = <FS_HEADER_LINE1>.



Regards,

Chakradhar.



10 REPLIES 10
Read only

Former Member
0 Likes
1,764

Hi Chakri,

Can you provide the conversion exit name?

Read only

Former Member
0 Likes
1,764

Hi Srikanth,

Thanks for your reply.The conversion exit name will be chnaging dynamicall y based on the field(For ex:If field is kunnr then conversion exit will be conversion_exit_alpha_input and if the field is matnr then conversion exit will be conversion_exit_matn1_input)This changes of function module will be ocncatenated into lv_conv_inpfm. Then these function module is called with export and import parametrs.For the sample code you can see it in my above post.

Regards,

Chakradhar.

Read only

0 Likes
1,764

Hi Chakri,

Need more information to analyze further, must be something to do with the FS used. Conversion Exit ALPHA works on the type of the field for padding leading zeros. This might be the issue.

Read only

0 Likes
1,764

Hi Srikanth,

I am using the conversion routine conversion_exit_alpha_input in my program with using a same field name for  importing and exporting.

Below is the code of my program related to the conversion routine.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
                          EXPORTING
                             INPUT         = <fs_header_line1>
                         IMPORTING
                           OUTPUT        =  <fs_header_line1>.


In the above code <fs_header_line1> is a field symbol with value 1000 as I am using conversion routine the value should change to '0000001000' but it is not changing and returning the same value as 1000. If the conversion routine returns the value as 0000001000 then I can check whether the value is existing in the value table of KUNNR.If I pass the pass value as 1000 and checking in its value table it is showing as that value is not present in kna1 table.So, I am using conversion routine to change the value of 1000 to 0000001000 so that the value will present in the kna1 table.

If any clarifications needed I can provide them.Thanks in Advance.



Regards,

Chakradhar.

Read only

0 Likes
1,764

Chakri,

can you provide detail of how <fs_header_line1> is declared?

Read only

0 Likes
1,764

Hi Srikanth,

field-symols:<fs_header_line1> type any.

Read only

0 Likes
1,764

Chakri,

The field symbol defined as type ANY might not work with ALPHA as the number of leading zero's to be padded with, cannot be determined, if static type is not given. For certain conversions u might have to go ahead with static types.

Read only

0 Likes
1,764

Srikanth,

Thanks for your replies.I resolved my isssue using the following code.

              CREATE DATA lp_data TYPE (l_field).
                ASSIGN lp_data->* TO <fs_header_line1>.


                CONCATENATE 'CONVERSION_EXIT_' L_CONVEXIT '_INPUT' INTO LV_CONV_INPFM.

                 CALL FUNCTION LV_CONV_INPFM
                   EXPORTING
                     INPUT  = l_value
                   IMPORTING
                     OUTPUT = <FS_header_line1>.


Regards,

Chakradhar

Read only

VenkatRamesh_V
Active Contributor
0 Likes
1,764

Hi,

Try this code i am getting table value,

TABLES: kna1.
PARAMETERS: cu type kna1-kunnr.

data: customer TYPE string.

FIELD-SYMBOLS: <fs> TYPE ANY.

START-OF-SELECTION.

if  cu IS NOT INITIAL.

SHIFT cu LEFT DELETING LEADING '0'.

ASSIGN cu to <fs>.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
   EXPORTING
     INPUT         = <fs>
  IMPORTING
    OUTPUT        <fs>
           .

MOVE <fs> to customer.

WRITE customer.

endif.




Regards,

Venkat.

Read only

0 Likes
1,764

Hi Venkat,

Thanks for your reply.In your program you are defining cu as type kna1-kunnr and assigning it to the field symbol.So, you are getting the output.Whereas in my program the fields are dynamic and the same conversion routine function module  should work for all the cases.I cannot hardcode the fieldsymbol to the specific type.

Regards,

Chakradhar.