08-12-2014 8:36 AM
Hi Experts,
I have taken a Field(mess) type c length 100. and i wrote the code as below
wa_log-mess+0(10) = 'PsKey |'.
wa_log-mess+10(11) = 'GL acc |'.
wa_log-mess+21(28) = 'Amount |'.
wa_log-mess+49(11) = 'Pr ctr |'.
wa_log-mess+60(10) = 'Bus Area |'.
APPEND wa_log TO it_log. " Appending heading to the final internal table
IF ls_bapi_currencyamount-amt_doccur > 0.
wa_log-mess+0(9) = 'H'.
ELSE.
wa_log-mess+0(9) = 'S'.
ls_bapi_currencyamount-amt_doccur =
ls_bapi_currencyamount-amt_doccur * -1.
ENDIF.
wa_log-mess+09(1) = '|'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = ls_bapi_accountgl-gl_account
IMPORTING
OUTPUT = ls_bapi_accountgl-gl_account.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = ls_bapi_accountgl-profit_ctr
IMPORTING
OUTPUT = ls_bapi_accountgl-profit_ctr.
wa_log-mess+10(10) = ls_bapi_accountgl-gl_account.
wa_log-mess+20(1) = '|'.
wa_log-mess+21(27) = ls_bapi_currencyamount-amt_doccur.
wa_log-mess+48(1) = '|'.
wa_log-mess+49(10) = ls_bapi_accountgl-profit_ctr.
wa_log-mess+59(1) = '|'.
wa_log-mess+60(4) = ls_bapi_accountgl-bus_area.
wa_log-mess+69(1) = '|'.
APPEND wa_log TO it_log. " main values along with pipe symbol is appended.
my problem is when i display the alv output the | (pipe) alignment between first row i.e, heading row and and main value rows not coming correctly. But when i check in debug mode, print preview and spool the alignment looks correct. but am facing only problem when displaying as ALV. Please suggest what need to be added.
Thanks,
Neeta
08-14-2014 9:42 AM
Hello everyone,
Please take a deep breath and think about why alignment is incorrect.
If you paste that text in Notepad, alignment is correct.
If you paste it in Microsoft Word, alignment is incorrect.
SAP list is able to show it properly.
Modern ALV is messing up the alignment.
The reason is Monospaced font
The width of letter is fixed in monospaced font. Modern fonts have a variable width.
Now the question is how to change font of ALV. You can change style like bold,italic easily.
The font is inherited from a setting in SAP GUI options.
If you change that global font setting, ALV output would be as desired, but SAP GUI would look prehistoric.
As a test, I changed font from Tahoma to Lucida Console which is monospaced or fixed-width.
Now the ALV output is like this.
However, same font is applied to rest of the SAP GUI.
/.
08-12-2014 10:02 AM
Dear Neeta,
Why cant you create a structure with 5 fields so that you dont need to care about pipeline and the alignment will be done automatically.
08-12-2014 10:51 AM
Hi Pious,
please see below screen shot of output. there is a sentence 'No Errors in Document posting' appended to final table, so that i cannot go for separate fields. please suggest.
Thanks,
Neeta
08-12-2014 10:57 AM
Then try with this code for the header.
wa_log-mess+0(9) = 'PsKey'.
wa_log-mess+09(1) = '|'.
wa_log-mess+10(10) = 'GL acc'.
wa_log-mess+20(1) = '|'.
wa_log-mess+21(27) = 'Amount'.
wa_log-mess+48(1) = '|'.
wa_log-mess+49(10) = 'Pr ctr'.
wa_log-mess+59(1) = '|'.
wa_log-mess+60(4) = 'Bus Area'.
wa_log-mess+69(1) = '|'.
APPEND wa_log TO it_log.
08-12-2014 11:16 AM
Hi Pious,
I tried with above code still has the same issue.
Neeta.
08-12-2014 10:50 AM
Dear Neeta,
I think you better use field category in ALV.
Ex:
TYPE-POOLS: SLIS.
DATA: i_fcat TYPE slis_t_fieldcat_alv ,
wa_fcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DEFINE append_fcat.
wa_fcat-fieldname = &1.
wa_fcat-seltext_m = &2.
wa_fcat-outputlen = &3.
wa_fcat-tabname = &4.
APPEND wa_fcat TO i_fcat.
CLEAR wa_fcat.
END-OF-DEFINITION.
append_fcat: 'PSKEY' 'PsKey' 10 'LS_BAPI_CURRENCYAMOUNT',
'GL_ACCOUNT' 'GL acc' 10 'LS_BAPI_ACCOUNTGL',
'AMT_DOCCUR' 'Amount' 27 'LS_BAPI_CURRENCYAMOUNT',
'PROFIT_CTR' 'Pr ctr' 10 'LS_BAPI_ACCOUNTGL',
'BUS_AREA' 'Bus Area' 4 'LS_BAPI_ACCOUNTGL'.
08-12-2014 11:19 AM
Hi Ruks,
its ALV display am following same as above.
Thanks,
08-12-2014 11:57 AM
Try this..,
wa_log-mess+0(9) = 'PsKey'.
wa_log-mess+09(1) = '|'.
wa_log-mess+10(10) = 'GL acc'.
wa_log-mess+20(1) = '|'.
wa_log-mess+21(27) = 'Amount'.
wa_log-mess+48(1) = '|'.
wa_log-mess+49(10) = 'Pr ctr'.
wa_log-mess+59(1) = '|'.
wa_log-mess+60(8) = 'Bus Area'.
wa_log-mess+69(1) = '|'.
APPEND wa_log TO it_log.
and also change
wa_log-mess+60(8) = ls_bapi_accountgl-bus_area.
08-12-2014 12:08 PM
08-12-2014 12:20 PM
Hi,
Calculate field lengths (characters) properly and assign | at correct positions. All columns must have values with equal length.
Simple as that.
08-12-2014 1:28 PM
Hi Rawat,
I have given as per the field length. still no use.
Thanks,
08-12-2014 1:35 PM
Hi Neetha,
try this,
data: mess(100) TYPE c OCCURS 0 WITH HEADER LINE,
it_fcat TYPE slis_t_fieldcat_alv,
wa_fcat TYPE slis_fieldcat_alv.
START-OF-SELECTION.
mess+0(10) = 'PsKey |'.
mess+10(11) = 'GL acc |'.
mess+21(27) = 'Amount |'.
mess+49(11) = 'Pr ctr |'.
mess+60(10) = 'Bus Area |'.
APPEND mess.
CLEAR mess.
mess+0(8) = 'H'.
mess+8(1) = '|'.
mess+10(10) = '123456'.
mess+20(1) = '|'.
mess+21(26) = '100'.
mess+31(1) = '|'.
mess+49(10) = 'COR'.
mess+59(1) = '|'.
mess+60(4) = '100'.
mess+69(1) = '|'.
APPEND mess.
loop at mess.
WRITE:/ mess.
ENDLOOP.
Regards,
Venkat.
08-12-2014 1:51 PM
Hi Venkat,
its working fine with write statement. But problem is with ALV display.
Thanks,
08-14-2014 7:34 AM
Oho... Seems to be this is something related character space. In general some letters taking more space (ex: 'W' take more space while 'I' taking less space than others). Therefore i'm not sure it's possible to align this with ' REUSE_ALV_GRID_DISPLAY' function. But if you can use ' REUSE_ALV_LIST_DISPLAY' problem will be solve.
Thanks
08-12-2014 6:31 PM
08-14-2014 8:20 AM
Hi Neetha,
Please try with below piece of code -
DATA : w_pskey TYPE char10 VALUE 'PsKey',
w_gl_acc TYPE char10 VALUE 'GL acc',
w_amount TYPE char27 VALUE 'Amount',
w_pr_ctr TYPE char10 VALUE 'Pr ctr'.
w_bus_are TYPE char10 VALUE 'Bus Area'.
CONCATENATE w_pskey w_gl_acc w_amount w_pr_ctr w_bus_are
INTO wa_log-mess SEPARATED BY '|' RESPECTING BLANKS.
APPEND wa_log TO it_log.
IF ls_bapi_currencyamount-amt_doccur > 0.
w_pskey = 'H'.
ELSE.
w_pskey = 'S'.
ls_bapi_currencyamount-amt_doccur =
ls_bapi_currencyamount-amt_doccur * -1.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = ls_bapi_accountgl-gl_account
IMPORTING
output = ls_bapi_accountgl-gl_account.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = ls_bapi_accountgl-profit_ctr
IMPORTING
output = ls_bapi_accountgl-profit_ctr.
w_gl_acc = ls_bapi_accountgl-gl_account.
w_amount = ls_bapi_currencyamount-amt_doccur.
w_pr_are = ls_bapi_accountgl-profit_ctr.
w_bus_are = ls_bapi_accountgl-bus_area.
CONCATENATE w_pskey w_gl_acc w_amount w_pr_ctr w_bus_are
INTO wa_log- mess SEPARATED BY '|' RESPECTING BLANKS.
APPEND wa_log TO it_log.
08-14-2014 8:49 AM
When Displaying it in ALV I'm quite sure you will not be able to display the pipes in equal positions. This depends on the values which were entered in the field.
For example:
1.row: textA | text2
2.row: text | text2
In both cases I have 6 characters for the text following by the pipe. But in first row the fifth character is 'A', in second row its blank. And in most lists, like here in my quote as well as in ALV Grid, the position of each character depends on the characters before it, and in this case the character 'A' is longer then the character 'blank', so there alway will be an offset. It's like working with spaces in Microsoft Word, it is nearly impossible to put words straight under each other.
Easiest way would be to separate your content at any | into seperate fields in ALV.
Regards
Michael
08-14-2014 9:42 AM
Hello everyone,
Please take a deep breath and think about why alignment is incorrect.
If you paste that text in Notepad, alignment is correct.
If you paste it in Microsoft Word, alignment is incorrect.
SAP list is able to show it properly.
Modern ALV is messing up the alignment.
The reason is Monospaced font
The width of letter is fixed in monospaced font. Modern fonts have a variable width.
Now the question is how to change font of ALV. You can change style like bold,italic easily.
The font is inherited from a setting in SAP GUI options.
If you change that global font setting, ALV output would be as desired, but SAP GUI would look prehistoric.
As a test, I changed font from Tahoma to Lucida Console which is monospaced or fixed-width.
Now the ALV output is like this.
However, same font is applied to rest of the SAP GUI.
/.
08-20-2014 1:13 PM