‎2009 Feb 19 8:54 AM
Hi Gurus,
I am facing an issue.
In my top of page subroutine I want to align my texts...few as left justified, few centralised & few right justified....
But I am not able to do so....everything is left justified.....
I am not using OOPS method.....using normal ALV grid FM...
Following is the subroutine used :-
FORM top-of-page.
DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader,
l_tab_space(10) TYPE c VALUE ' :',
l_hdr_asset(50) TYPE c,
l_hdr_rprtdt(50) TYPE c,
l_hdr_rundt(50) TYPE c,
l_hdr_deprec(50) TYPE c.
* Title
CONCATENATE text-e03 sy-datum INTO l_hdr_rundt SEPARATED BY space.
wa_header-typ = 'S'.
wa_header-info = l_hdr_rundt.
APPEND wa_header TO t_header.
CLEAR wa_header.
wa_header-typ = 'A'.
wa_header-info = text-e00.
APPEND wa_header TO t_header.
CLEAR wa_header.
CONCATENATE text-e01 g_anlkl INTO l_hdr_asset SEPARATED BY space.
wa_header-typ = 'S'.
wa_header-info = l_hdr_asset.
APPEND wa_header TO t_header.
CLEAR wa_header.
CONCATENATE text-e04 s_afabe-low INTO l_hdr_deprec SEPARATED BY space.
wa_header-typ = 'S'.
wa_header-info = l_hdr_deprec.
APPEND wa_header TO t_header.
CLEAR wa_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
ENDFORM.
Thanks Winnie
‎2009 Feb 19 9:08 AM
Winnie,
I guess by default everything will be left justified when it comes to Top of page of an ALV Grid.Even I faced this issue,a few sdn threads say it's not possible.May be we can workaround like giving dots so that the headings gets alligned as per the requirement.Sounds like a crude solution
K.Kiran.
‎2009 Feb 19 9:10 AM
‎2009 Feb 19 9:16 AM
U might not get centered justified / right justified . but can print spaces in front of text.
concatenate spaces with the text you want to print.
If U just type a space this will not be shown , simply condensed.
for space , type ALT+255 (hold on ALT tab and type 255) this is equivalent to one space ..
Title
CONCATENATE' ' text-e03 sy-datum INTO l_hdr_rundt SEPARATED BY space.
wa_header-typ = 'S'.
wa_header-info = l_hdr_rundt.
APPEND wa_header TO t_header.
CLEAR wa_header.
‎2009 Feb 19 9:23 AM
Hi,
if you write as below,
WRITE l_hdr_rundt TO wa_header-info RIGHT-JUSTIFIED.
instead of simply moving like below.
wa_header-info = l_hdr_rundt.
i think it should work.
the same way you can write for LEFT or CENTERED.
hope this shluld be helpful..
Regards.
Sravan
Edited by: Sravan Kumar on Feb 19, 2009 10:24 AM
‎2009 Feb 19 9:23 AM
Hi,
Mke use of fieldcatalog.
Refer the below code.
DATA :
T_FCAT TYPE SLIS_T_FIELDCAT_ALV,
F_FCAT LIKE LINE OF T_FCAT.
F_FCAT-FIELDNAME = 'CARRID'.
F_FCAT-REPTEXT_DDIC = 'Carrid'.
F_FCAT-JUST = 'C'. (This is for justification. C-Centered,L-Left ,R---Right )
F_FCAT-EMPHASIZE = 'C710'.
F_FCAT-COL_POS = 2.
APPEND F_FCAT TO T_FCAT.
CLEAR F_FCAT.
( Fill the fieldcatalogue with justification )
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'FS'
IT_FIELDCAT = T_FCAT
TABLES
T_OUTTAB = ITAB
‎2009 Feb 19 9:36 AM
Hello,
You can try a workaround:
*---------------------Local variable declaration
DATA : l_v_program TYPE sy-repid. "Program name
*---------------------Local constant declaration
CONSTANTS: l_c_top TYPE slis_formname VALUE 'F_TOP_OF_PAGE'.
*Storing program name
l_v_program = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_v_program
i_callback_html_top_of_page = l_c_top
is_layout = st_layout
it_fieldcat = fp_it_fieldcat
TABLES
t_outtab = fp_it_final
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc IS NOT INITIAL.
*Error in Displaying the Report
MESSAGE i014.
LEAVE LIST-PROCESSING.
ENDIF.
*&--------------------------------------------------------------------*
*& Form f_top_of_page
*&--------------------------------------------------------------------*
* Display the Top Of Page
*---------------------------------------------------------------------*
FORM f_top_of_page USING cl_dd TYPE REF TO cl_dd_document.
DATA:
v_string TYPE sdydo_text_element,
v_tab TYPE abap_char1.
v_tab = cl_abap_char_utilities=>horizontal_tab.
v_string = 'Left- Aligned'.
CALL METHOD cl_dd->add_text
EXPORTING
text = v_string.
CALL METHOD cl_dd->add_gap
EXPORTING
width = 160.
v_string = 'Centred'.
CALL METHOD cl_dd->add_text
EXPORTING
text = v_string.
CALL METHOD cl_dd->add_gap
EXPORTING
width = 180.
v_string = 'Right-Aligned'.
CALL METHOD cl_dd->add_text
EXPORTING
text = v_string.
ENDFORM. " f_top_of_pageI think there must be a better solution than this )
BR,
Suhas
‎2009 Feb 19 1:15 PM
Hi Winnie,
perpare a fieldcatalog ..
data: t_fcat type slis_t_fieldcat_alv with header line .
t_fcat-fieldname = ' ' .
t_fcat-col_pos = ''.
t_fcat-reptext = '<heading>'.
t_fcat-just = 'L' or 'R' or 'C'.
append t_fcat.
Regards,
Mdi.Deeba
‎2009 Feb 19 1:37 PM
Hi Winnie,
[aligning data in ALV|http://www.sap-img.com/abap/aligning-data-in-alv-grid-using-function-modules.htm]
Regards,
Sravanthi
‎2009 Feb 20 5:24 AM
Hi Winnie,
you will have to use an HTML_TOP_OF_PAGE and you can align the text you want display in any position.
CALL METHOD p_doc->add_text
EXPORTING
text = anytext.
ENDIF.
CALL METHOD p_doc->add_gap
EXPORTING
width = 175. ( you can specify your distance)
cheers