2006 Aug 11 12:43 PM
Hi all,
I have two fields for example x1 and x2 which r been displayed in the ALV grid ( pulled into an internal table) would like to add these two fields X1+X2 and display into a column in the alv..
any example to read tht particular line and add these two fields.
thxs,
vin.
Hi all,
I have two fields for example x1 and x2 which r been displayed in the ALV grid ( pulled into an internal table) would like to add these two fields X1+X2 and display into a column in the alv..
any example to read tht particular line and add these two fields.
thxs,
vin.
2006 Aug 11 12:47 PM
Hi,
have three fields , first populate the two fields, and then later populate the third one with first two fields.
and then show it using alv.
Regards
vijay
2006 Aug 11 1:02 PM
Hi,
Check the sample code.
REPORT ztest_alv .
TYPE-POOLS: slis.
DATA: x_fieldcat TYPE slis_fieldcat_alv,
it_fieldcat TYPE slis_t_fieldcat_alv,
l_layout TYPE slis_layout_alv.
DATA: BEGIN OF itab OCCURS 0,
field1 TYPE i,
field2 TYPE i,
field3 TYPE i,
END OF itab.
DO 20 TIMES.
itab-field1 = sy-index.
itab-field2 = sy-index + 1.
APPEND itab.
CLEAR itab.
ENDDO.
LOOP AT itab.
itab-field3 = itab-field1 + itab-field2.
MODIFY itab INDEX sy-tabix.
ENDLOOP.
x_fieldcat-fieldname = 'FIELD1'.
x_fieldcat-seltext_l = 'One'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 1.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
x_fieldcat-fieldname = 'FIELD2'.
x_fieldcat-seltext_l = 'Two'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 2.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
x_fieldcat-fieldname = 'FIELD3'.
x_fieldcat-seltext_l = 'Sum'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 3.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = l_layout
it_fieldcat = it_fieldcat
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.Regards
vijay
2006 Aug 11 12:50 PM
declare one more field in internal table and add the first 2 fields and assign to the new field,
then pass the internal table to the ALV