‎2019 Jun 14 8:27 AM
I want to align text to left and right based on some condition in same colomn in OOPs ALV(set_table_for_first_display). I can't use 'lvc_s_fcat-just' as this apply to every row for the colomn.
‎2019 Jun 14 9:40 AM
You may use a different style for each cell by defining a style column in your ALV table named YOURSTYLECOL of type LVC_T_STYL (table of combination { field name, style 1, style 2, ... }).
Transmit its name via the layout parameter IS_LAYOUT-STYLEFNAME = 'YOURSTYLECOL'.
In every row of your ALV table, fill this style table with as many rows as number of cells to apply a style. The style 1 may have values from constants ALV_STYLE* from the include <CL_ALV_CONTROL>, for instance ALV_STYLE_ALIGN_RIGHT_CENTER. Some style constants correspond only to STYLE1, others to STYLE2, etc.
‎2019 Jun 14 9:29 AM
I do not know if you you can rely on structure LVC_S_STYL (table type LVC_T_STYLE), you can give a try with them.
You can check the BCALV... demo reports
‎2019 Jun 14 9:40 AM
You may use a different style for each cell by defining a style column in your ALV table named YOURSTYLECOL of type LVC_T_STYL (table of combination { field name, style 1, style 2, ... }).
Transmit its name via the layout parameter IS_LAYOUT-STYLEFNAME = 'YOURSTYLECOL'.
In every row of your ALV table, fill this style table with as many rows as number of cells to apply a style. The style 1 may have values from constants ALV_STYLE* from the include <CL_ALV_CONTROL>, for instance ALV_STYLE_ALIGN_RIGHT_CENTER. Some style constants correspond only to STYLE1, others to STYLE2, etc.
‎2019 Jun 14 2:17 PM
Hi Sandra,
Thanks for your response but i have used this logic and i didn't get result as per my requirement.
‎2019 Jun 14 2:39 PM
Probably you did something wrong. In my system, it works well:
DATA go_alv TYPE REF TO cl_gui_alv_grid.
TYPES : BEGIN OF ty_scarr2.
INCLUDE TYPE scarr AS scarr.
TYPES: styles TYPE lvc_t_styl,
END OF ty_scarr2,
ty_scarr2s TYPE STANDARD TABLE OF ty_scarr2 WITH EMPTY KEY.
INCLUDE <cl_alv_control>.
DATA gt_scarr2 TYPE ty_scarr2s.
PARAMETERS dummy.
AT SELECTION-SCREEN OUTPUT.
IF go_alv IS INITIAL.
CREATE OBJECT go_alv
EXPORTING
i_parent = cl_gui_container=>screen0.
SELECT * FROM scarr INTO TABLE @DATA(gt_scarr).
LOOP AT gt_scarr ASSIGNING FIELD-SYMBOL(<scarr>).
gt_scarr2 = VALUE #( BASE gt_scarr2 (
scarr = <scarr>
styles = VALUE #( ( fieldname = 'CARRNAME' style = alv_style_align_right_center ) ) ) ).
ENDLOOP.
go_alv->set_table_for_first_display(
EXPORTING
i_structure_name = 'SCARR'
is_layout = VALUE #( stylefname = 'STYLES' )
CHANGING
it_outtab = gt_scarr2 ).
ENDIF.
AT SELECTION-SCREEN ON EXIT-COMMAND.
go_alv->free( ).
FREE go_alv.
Screenshot:

‎2019 Jun 14 1:55 PM
** declaration for ALV Columns
DATA : gr_columns TYPE REF TO cl_salv_columns_table,
gr_column TYPE REF TO cl_salv_column .
TRY . gr_column ?= lo_cols->get_column( 'ZREV' ).
gr_column->set_medium_text( 'Rev.Chrgs.Appl.' ).
gr_column->set_short_text( 'Rev.Chrgs' ).
gr_column->set_alignment( value = if_salv_form_c_h_align=>center ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
"Here using set_alignment you can set the alignment as per your need
‎2019 Jun 14 2:18 PM
‎2019 Jun 14 3:18 PM
Hi Anurag,
To get it done , please refer program - BCALV_EDIT_07
Here SAP Tried dynamic representation for drop down table .
the same way you can handle it for alignment too by changing the it_outtab as per your need .
Sandra Rossi has provided the solution for this .‎2019 Jun 14 3:32 PM
How is the ALV drop down demo program related to the question? (it doesn't even handle styles and alignments)
‎2019 Jun 14 3:55 PM
this is what SAP has done to handle the rows dynamically , by adding an additional field to it , handling it with as per the needs , i was looking for it , then i saw your comment you have also did it in similar way , that's why i have mentioned you have provided the solution .