2012 Aug 13 3:50 PM
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!
2012 Aug 13 5:32 PM
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!
2012 Aug 13 5:17 PM
2012 Aug 13 5:32 PM
Hi
It's not possible by ALV: they are distinct fields and so ALV will show then in distinct columns
Max
2012 Aug 13 5:43 PM
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.
2012 Aug 13 6:11 PM
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.
2012 Aug 13 6:14 PM
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?
2012 Aug 14 10:04 AM
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.
2012 Aug 14 10:06 AM
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
2012 Aug 14 10:24 AM
hi Niklavs ,
try this:
http://sample-code-abap.blogspot.in/2008/01/printing-multiple-line-header-and.html
Regards ,
Yogendra Bhaskar
2012 Aug 14 3:27 PM
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.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |