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: 

Field catalog issue using REUSE_ALV_FIELDCATALOG_MERGE

former_member852447
Active Participant
0 Kudos

Hello experts,

I am using FM REUSE_ALV_FIELDCATALOG_MERGE and the field catalog is created fron the program.

The field catalog finds the date field from the program but my internal table has been changed to make the date output YYYY/MM/DD.

When I input the internal table in FM REUSE_ALV_GRID_DISPLAY the output displays the date as DD/MM/YYYY which is not what I want.

How can I get FM REAUSE_ALV_GRID_DISPLAY to output the date in the format YYYY/MM/DD which is in my input table.

I have spent a lot of time researching SDN on this but cannot find a similar solution however I did find some examples of changing the field catalogue. Can anybody suggest this is the way to go and if I would use the edit mask field in the field catalog or is there a better way.

Thanks for any suggestions

1 ACCEPTED SOLUTION

Former Member
0 Kudos

The field is type d or dats, right? As a result, the display is by user settings. So, declare the field as char (10). Put your date into it without doing WRITE (concatenate substrings separated by '/').

5 REPLIES 5

former_member186741
Active Contributor
0 Kudos

I think you can use a field exit for this.

This means creating a field element and a domain in the data dictionary, the domain will need to have a conversion exit set by putting an entry in the 'Convers. Routine' field, eg MYDAT.

You will need to create two function mdules as below:

eg, CONVERSION_EXIT_MYDAT_OUTPUT

and CONVERSION_EXIT_MYDAT_INPUT

Your internal table will now need to refer to the data element you have created instead of the one you are currently using. ALV should automatically pick up the conversion exits and show the ouitput as you desire.

FUNCTION CONVERSION_EXIT_MYDAT_OUTPUT.

*"----


""Local Interface:

*" IMPORTING

*" REFERENCE(INPUT) TYPE DATS

*" EXPORTING

*" REFERENCE(OUTPUT)

*"----


concatenate input(4) '/' input4(2) '/' input6

into output.

ENDFUNCTION.

FUNCTION CONVERSION_EXIT_MYDAT_INPUT.

*"----


""Local Interface:

*" IMPORTING

*" REFERENCE(INPUT)

*" EXPORTING

*" REFERENCE(OUTPUT) TYPE DATS

*"----


data l_string type string.

l_string = input.

replace all occurrences of '/' in l_string with ' '.

output = l_string.

ENDFUNCTION.

Former Member
0 Kudos

Hi,

After executing the function module, you can modify the date field of the internal table.

data : str type string.

str = it_tab-date.

"Now concatenate

concatentae str+6(4) "Year

'/'

str+3(2) " Month

'/'

str+0(2) " date

into str.

This will give you YYYY/MM/DD

former_member852447
Active Participant
0 Kudos

Hello Neil,

Thank you for your reply. I am not familiar with field exits but will work through it. I may have further questions going forward.

Hello Ruchak,

I do not understand your recommendation. I have already changed the internal table to the required format which I am entering into SAP FM REUSE_ALV_GRID_DISPLAY but that FM changes the output back to the incorrect format so I do not get a second chance of changing the output. Please explain in more detail what you mean.

Former Member
0 Kudos

The field is type d or dats, right? As a result, the display is by user settings. So, declare the field as char (10). Put your date into it without doing WRITE (concatenate substrings separated by '/').

former_member852447
Active Participant
0 Kudos

Thank you Breakpoint (and all that replied) problem solved