Application Development 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: 

Conversion of Unit of Measure in ALV Grid

Former Member
0 Kudos

Hi all,

I am using function 'REUSE_ALV_GRID_DISPLAY' to display some records in ALV grid. The record displays material, the quantity of the material consumed and the unit of measure (UoM) of the quantity. I am fetching the data from the table AUFM and the field I am using for UoM is ERFME.

The problem is that when the UoM is displayed in the ALV, it is displayed as KAR but when i print the report or check the print preview, the UoM is displayed as CAR. I want to display CAR also in the ALV.

I have tried using the function 'CONVERSION_EXIT_CUNIT_OUTPUT' which converts the KAR to CAR in the ALV, but when I print it or check the print preivew , it shows asterisks (*) in the UoM field.

Can anyone tell me why this is happening and how I can solve this problem? Any help will be greatly appreciated.

Regards,

Hamza

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Hamza ,

I had the problem you have mentioned but when I used the function 'CONVERSION_EXIT_CUNIT_OUTPUT' the problem was solved . The only thing that I can suggest you is , to give it a try, change the data type of UoM to char(3) .

Hope this helps.

4 REPLIES 4

Former Member
0 Kudos

Hi Hamza ,

I had the problem you have mentioned but when I used the function 'CONVERSION_EXIT_CUNIT_OUTPUT' the problem was solved . The only thing that I can suggest you is , to give it a try, change the data type of UoM to char(3) .

Hope this helps.

0 Kudos

Hi Ozkar,

I tried the function 'CONVERSION_EXIT_CUNIT_OUTPUT', it worked fine when displaying the UoM in the ALV, meaning it displayed CAR instead of KAR, but when I printed the list or chicked the print preview, it displayed stars (***) in the UoM field.

Anyway, I tried something else and now it is working fine. I am writing below what I did so that if anyone else has this problem, they can also do what I did.

As I said before, the UoM field was showing KAR instead of CAR in the ALV. So after passing the data to an internal table which would be used to display the data in the ALV, I called the function 'CONVERSION_EXIT_CUNIT_OUTPUT' and converted KAR to CAR. this displayed CAR in the ALV.

Now, to also get CAR in the print out and print preview,I declared variables gt_event_exit and lt_event_exit.

DATA: gt_event_exit TYPE STANDARD TABLE OF slis_event_exit,

lt_event_exit TYPE slis_event_exit.

The variable will 'lt_event_exit' will contain the function codes of the Print(&RNT) and Print Preview (&RNT_PREV) buttons on the ALV. In the form where I am calling the function 'REUSE_ALV_GRID_DISPLAY', I pass the function codes to lt_event_exit and append it to the internal table gt_event_exit.

lt_event_exit-ucomm = '&RNT'.

lt_event_exit-before = 'X'.

APPEND lt_event_exit TO gt_event_exit.

lt_event_exit-ucomm = '&RNT_PREV'.

lt_event_exit-before = 'X'.

APPEND lt_event_exit TO gt_event_exit.

Next I pass this table to the parameter 'IT_EVENT_EXIT' of 'REUSE_ALV_GRID_DISPLAY'. I also create a form USER_COMMAND and pass this form to the parameter 'I_CALLBACK_USER_COMMAND' of 'REUSE_ALV_GRID_DISPLAY' as shown below.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_USER_COMMAND = 'USER_COMMAND '

IT_EVENT_EXIT = gt_event_exit

What the above does is that, when a user clicks on the print or print preview button, the system instead of printing the list, it passes the control to the form USER_COMMAND. After the form is processed, it prints the list.

In the form, I placed a loop on the internal table containing the data to be shown and simply converted the CAR back to KAR. The code is given below.

FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield .

CASE r_ucomm .

WHEN '&RNT' OR '&RNT_PREV'.

LOOP AT i_final .

CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'

EXPORTING

input = i_final-erfme

language = sy-langu

IMPORTING

output = i_final-erfme

EXCEPTIONS

unit_not_found = .

MODIFY i_final.

ENDLOOP.

  • WHEN .

  • WHEN OTHERS.

ENDCASE.

I hope this is helpful to anyone who has the same problem as I did. Now what I cant figure out is why the system automatically converts KAR to CAR when displaying print preview or when printing the list.

Well, thanks anyway for the suggestion Ozkar.

Regards,

Hamza

Former Member
0 Kudos

Hi Hamza,

Pass wa_fieldcat-edit_mask = '==CUNIT'

for the resoective Unit of Measure field.

This will take care of the conversions.

Regards,

Adit

0 Kudos

This answer is right.

Manually using of conversion route is not necessary but verbose.

All you have to do is  to set the mask in field catergories.