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

Multiple values in ALV field

Former Member
0 Likes
2,369

Hello!

I have to display currency amount and currency key in one line in one ALV field. I have spent hours looking for answer and couldn't find one.

At the moment the relevant part of my field catalog looks like this:

s_fieldcat-fieldname = 'LOCCURAM'.
   s_fieldcat-ref_table = 'SBOOK'.
   s_fieldcat-outputlen = '10'.
   s_fieldcat-coltext = 'Amount'.
   s_fieldcat-currency = 'LOCCURKEY'.
   s_fieldcat-col_pos = 6.
   APPEND s_fieldcat TO t_fieldcat.
   CLEAR s_fieldcat.

   s_fieldcat-fieldname = 'LOCCURKEY'.
   s_fieldcat-ref_table = 'SBOOK'.
   s_fieldcat-outputlen = '10'.
   s_fieldcat-coltext = 'Amount'.
   s_fieldcat-col_pos = 7.
   APPEND s_fieldcat TO t_fieldcat.
   CLEAR s_fieldcat.

The values are stored in an internal table.

These two should be displayed in one field one after another.

Secondly I have to display city and country in one field in 2 lines.

Relevant code for that:

s_fieldcat-fieldname = 'CITYFROM'.
   s_fieldcat-ref_table = 'SPFLI'.
   s_fieldcat-outputlen = '15'.
   s_fieldcat-coltext = 'From'.
   s_fieldcat-col_pos = 3.
    APPEND s_fieldcat TO t_fieldcat.
   CLEAR s_fieldcat.

   s_fieldcat-fieldname = 'COUNTRYFRNAME'.
   s_fieldcat-ref_table = 'T005T'.
   s_fieldcat-outputlen = '15'.
   s_fieldcat-coltext = 'From'.
   s_fieldcat-col_pos = 3.
   APPEND s_fieldcat TO t_fieldcat.
   CLEAR s_fieldcat.

It all works fine when i displaying in separate columns.

Thank you!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,637

Hi

It's not possible by ALV: they are distinct fields and so ALV will show then in distinct columns

Max

Hello!

I have to display currency amount and currency key in one line in one ALV field. I have spent hours looking for answer and couldn't find one.

At the moment the relevant part of my field catalog looks like this:

s_fieldcat-fieldname = 'LOCCURAM'.
   s_fieldcat-ref_table = 'SBOOK'.
   s_fieldcat-outputlen = '10'.
   s_fieldcat-coltext = 'Amount'.
   s_fieldcat-currency = 'LOCCURKEY'.
   s_fieldcat-col_pos = 6.
   APPEND s_fieldcat TO t_fieldcat.
   CLEAR s_fieldcat.

   s_fieldcat-fieldname = 'LOCCURKEY'.
   s_fieldcat-ref_table = 'SBOOK'.
   s_fieldcat-outputlen = '10'.
   s_fieldcat-coltext = 'Amount'.
   s_fieldcat-col_pos = 7.
   APPEND s_fieldcat TO t_fieldcat.
   CLEAR s_fieldcat.

The values are stored in an internal table.

These two should be displayed in one field one after another.

Secondly I have to display city and country in one field in 2 lines.

Relevant code for that:

s_fieldcat-fieldname = 'CITYFROM'.
   s_fieldcat-ref_table = 'SPFLI'.
   s_fieldcat-outputlen = '15'.
   s_fieldcat-coltext = 'From'.
   s_fieldcat-col_pos = 3.
    APPEND s_fieldcat TO t_fieldcat.
   CLEAR s_fieldcat.

   s_fieldcat-fieldname = 'COUNTRYFRNAME'.
   s_fieldcat-ref_table = 'T005T'.
   s_fieldcat-outputlen = '15'.
   s_fieldcat-coltext = 'From'.
   s_fieldcat-col_pos = 3.
   APPEND s_fieldcat TO t_fieldcat.
   CLEAR s_fieldcat.

It all works fine when i displaying in separate columns.

Thank you!

9 REPLIES 9
Read only

Former Member
0 Likes
1,637

Hi

Try to Refresh the internal table and try it sir

Read only

Former Member
0 Likes
1,638

Hi

It's not possible by ALV: they are distinct fields and so ALV will show then in distinct columns

Max

Read only

0 Likes
1,637

So can i combine the data before passing it to the field?

I tried to WRITE the LOCCURAM to a char type variable to CONCATENATE with LOCCURKEY, but the variable was left empty.

Code was something like this:

DATA: lv_money(100) TYPE c.

WRITE SBOOK-LOCCURAM TO lv_money.

I assume the reason could be that the SELECT statement gets several hundreds of entries and can't store them in one variable.

Read only

0 Likes
1,637

Hello,

I don´t think the reason is the SELECT statement. I think the reason es de TYPE definition. I recomend you set a smaller length for lv_money, and use CONCATENATE and CONDENSE lv_money NO-GAPS.

Fidel.

Read only

0 Likes
1,637

Could you please provide few code lines for me to mess around?

And where should i put it - in the SELECT or FIELD CATALOG creation FORM?

Read only

0 Likes
1,637

You have any loop to the internal table where are info?

If you have one put there, if not you can create it.

The code is in this form:

LOOP AT it_data into lw_data.

     CONCATENATE lw_data-LOCCURAM lw_data-LOCCURKEY into lw_data-var_concatenate.

     CONDENSE lw_data-var_concatenate NO-GAPS.

ENDLOOP.


Read only

0 Likes
1,637

Hi Niklavs,

Create a field type char(15) in your output table.

Then after your select statement when populating your ALV output table,

you must move the amount field to a char type field before you can concatenate.

lv_curram(10) type c.

Move LOCCURAM to lv_curram.

Concatenate LV_CURRAM LOCCURKEY into t_output-amount separated by space.

Condense t_output-amount. "----> This will hold the value you need to pass in the FIELD CATALOG.

Hope it helps!

Mark

Read only

yogendra_bhaskar
Contributor
0 Likes
1,637
Read only

Former Member
0 Likes
1,637

Thank you for answers, but i figured it out before i got them

Just to take a look here is code i added after my SELECT statement:

LOOP at gt_report INTO wa_report.
      WRITE wa_report-LOCCURAM TO lv_money.
      WRITE wa_report-LOCCURKEY TO lv_money1.
      CONCATENATE lv_money lv_money1 INTO lv_money2 SEPARATED BY space.
      WRITE lv_money2 TO wa_report-money.
      MODIFY gt_report FROM wa_report.
ENDLOOP.

Points rewarded.

And how about my second question where i have to put city and country in one field 2 lines? It seems that CONCATENATE with NEWLINE will not work in ALV. And since i am forced to use GRID_DISPLAY i guess i will need another "workaround" outside ALV.